I’m trying to execute a simple translation and then movement of a box:
Step 1: Move the box to a desired absolute position (I use set setAbsolutePosition)
Step 2: Point the box so that it is pointing in the same direction as a normal vector of an adjacent mesh. Let’s use BABYLON.Axis.X for sake of simplicity. (I use setDirection)
Step 3: Move the box again slightly in the “forward” direction from where its pointing. (I use movePOV)
POV movement really pertains to how the mesh being defined in an external program like blender. In order for a Mesh to move in terms of the mesh’s own “Point of View”, that being in terms of its current position and rotation, you need to know what is the “front” of the mesh.
Blender
Inside blender my front looksat -Y axis as seen in this screenshot
Babylon
After importing the GLB in Babylon, the front of my mesh looksat the +Z axis.
Issue
MovePOV amountUp actually doesnt work as expected even with definedFacingForward=false as it moves the mesh forward and not Up. Any idea how I can make the GLB work just like non-glb cube in the above playground https://playground.babylonjs.com/#6XIT28#3263
Have you tried setting scene.useRightHandedSystem = true? glb files have a different coordinate system than Babylon, so some special transformations must take place when loading a file. scene.useRightHandedSystem = true disables these transformations.
But Step 2 doesn’t: The face doesn’t point to +X axis. Making me think I can’t use setDirection as is and have to do some math to ensure that the axes of the GLB are lined up with BABYLON’s axis. Scene scene.useRightHandedSystem has other side effects that I’d like to avoid. So I’m thinking I’ll have to write a separate setDirection function for this mesh instead of calling the setdirection on the Mesh class. Any idea on who to get the Delta between the worldcoordinate system and the meshes’ coordinate system?
Step 3 has probably the same problem - there needs to be some translation of the coordinate systems done. I’d like it to be standard with BABYLON’s left handed system.
Did you try unparent it from this root node created from the blender import and parent it to a new (abstractMesh or transformNode)? I’m not 100% sure but I believe this could do the trick.