Skip to content

Custom loaded mesh is turned into a BoxGeometry when view is updated #40

@SorenMaagaard

Description

@SorenMaagaard

When a custom mesh is loaded using View3D1.Import3DModelAsync, and then subsequently changed from the scene, the model is changed into a BoxGeometry.

How to reproduce:

This can be reproduced simply using the examples.

  1. Modify OnCreateCubeButtonClick in Example04.razor in the Blazor3D.Examples.WebAsm project, to Import a 3D model instead of creating a box.
    I used the stl loading from Example02.razor and turned OnCreateCubeButtonClick into this:
    private async Task OnCreateCubeButtonClick()
    {
        var settings = new ImportSettings
            {
                Format = Import3DFormats.Stl,
                FileURL = "https://threejs.org/examples/models/stl/ascii/slotted_disk.stl",
            };
        lastCubeGuid = await View3D1.Import3DModelAsync(settings);
        await View3D1.SetCameraPositionAsync(new Vector3(0, 3, 3), new Vector3(0, 1, 0));
        msg = $"created new cube with id = {lastCubeGuid}";
        StateHasChanged();
        lastCubeGuid = Guid.Empty;
    }
  1. Run the app, go to Example04, click the Create Cube button and see that it loads the STL corrctly.
  2. Select the loaded model in the view, optionally modify the X, Y or Z values, and click `Update selected cube position"

Expected behavior

The model moves to the specified position

Actual behavior

The model moves and is now turned into a BoxGeometry.

I guess this happens because when the Mesh is accessed from the scene, by default it is a BoxGeometry, and View3D1.UpdateScene(); the replaces the loaded model with a BoxGeometry.

Is there any workaround for this, or am I just doing something completely wrong here 😄

Note: My goal is to load to meshes from stl, and and by using sliders, rotate them individually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions