Hello, and I have been working on a scene whereby I would like to align some mesh instances to an imported GLTF model. The mesh was created in Blender, has had the transformations applied, and was packed using gltfpack (which creates a separate transform and mesh nodes in the output GLTF).
After importing the mesh I create instances of a cube, and position them at locations along the mesh (like pins on a map). In order to better align the instances with the mesh I am casting a ray towards the GLTF mesh and using the hit distance and normal to offset and rotate the mesh. Without baking the transform into the mesh vertices (bakeCurrentTransformIntoVertices) the normal information I get back from the ray hit is incorrect, after baking the vertices the ray no longer hits the surface.
The following playground shows the issue I am having:
(toggle the enableBakeVertices boolean to show the error)
I have included some logic to display the surface normals of the mesh I want to align with, and some more to show the rays being cast. The parent transform has been removed from the root hierarchy of the imported GLTF, and then it’s position is reset; this was necessary to retain the original position of the child mesh after baking the vertices.
The issue, simply, is that my ray intersection tests fail after baking the vertices, despite the normals drawing in the correct positions. Using the same code on a rotated plane (MeshBuilder.CreatePlane) works, although I do not need to do the same work to detach the plane from a parent hierarchy or to reset a parent TransformNode’s rotation and position.
Thanks for any advice you might be able to lend, and please let me know if I am doing anything glaringly wrong,