Blazor3D icon indicating copy to clipboard operation
Blazor3D copied to clipboard

Creating grids and aligning them with uploaded .STLs

Open richardrobrts opened this issue 2 years ago • 5 comments

I've created a program that takes in an .STL file input, gets the corresponding URL for the object from the filestream, and renders it with Blazor3D. I'm trying to then add a new GridHelper, whose dimensions are relative to the size of the object rendered, something like GridHelper(Object.Length*2). I thought I had found the correct source for the rendered object's dimensions in the scene's child's Objects.Mesh.Geometry, however since it's a mesh, all of the dimensions are the default values (1,1,1), even if two meshes are vastly different in size.

My question is, is there a way I can find an 'absolute size' or another metric to handle things like varied grid size or camera location?

richardrobrts avatar Nov 02 '23 18:11 richardrobrts

Also, this technically isn't the same issue, but whenever I try to rotate one of the meshes, it becomes a cube instead of staying as a mesh. Is there a way to avoid this?

richardrobrts avatar Nov 02 '23 21:11 richardrobrts

My question is, is there a way I can find an 'absolute size' or another metric to handle things like varied grid size or camera location?

Hi. When you load the stl or any other file type, no info is supplied from JS to .NET side. Please, see https://github.com/HomagGroup/Blazor3D/issues/30 for more info.

simutaroman avatar Nov 05 '23 17:11 simutaroman

Also, this technically isn't the same issue, but whenever I try to rotate one of the meshes, it becomes a cube instead of staying as a mesh. Is there a way to avoid this?

I have never seen such behavior before. are you trying to rotate programmatically?

simutaroman avatar Nov 05 '23 17:11 simutaroman

Also, this technically isn't the same issue, but whenever I try to rotate one of the meshes, it becomes a cube instead of staying as a mesh. Is there a way to avoid this?

I have never seen such behavior before. are you trying to rotate programmatically?

if (e.Key == "w") { keyPressMessage = "W key held down"; scene.Children.Last().Rotation.X += 3; View3D1.UpdateScene(); }

Yes, I have code like this for each of the rotation directions. Is this not the intended way?

richardrobrts avatar Nov 06 '23 15:11 richardrobrts

there are 2 moments:

  • when you load the stl file, information about geometry is NOT sent to the .NET side. so, your c# code knows nothing about current geometry. the default cube geometry is created instead
  • when you use View3D1.UpdateScene(), the scene from .NET part is converted to JSON, then it is sent to JS part. then js scene is cleared and recreated using sent JSON. So, you have default cube geometry instead of loaded file

unfortunately, the current state of the Blazor3D doesn't provide functionality required by you

simutaroman avatar Nov 07 '23 08:11 simutaroman