Hi,
I have a mesh in a running babylonjs Scene (either imported by calling SceneLoader.ImportMeshAsync
or created by a function like CreateBox
- in case that matters).
I set its position and direction (which I am assuming is the orientation in the scene…) like this:
mesh.setAbsolutePosition(new Vector3(1, 2, 3));
mesh.setDirection(new Vector3(1, 0, 0));
I activated a GizmoManager in the scene for rotation and enabled gizmo on my mesh:
const m = new GizmoManager(scene);
m.rotationGizmoEnabled = true;
m.attachableMeshes = [mesh];
I see the mesh rendered on the canvas.
Let’s say that as a user, at runtime, I click the mesh, see the gizmo, and use gizmo to rotate that mesh just very slightly.
Now as I user I click a button that dumps this mesh’ getDirection()
to console, and I want to see that the mesh’ orientation changed just very slightly… Here is where I have a problem:
First, of course, getDirection()
has a required argument; I don’t know what to pass in there. All I want if to get back the same (or slightly different if the mesh has been rotated slightly by the user) direction/orientation that I passed to that mesh previously by calling setDirection()
. If I pass to getDirection
some Vector3 values (say new Vector3(1, 0, 0)
or new Vector3(1, 0, 1)
or whatever), I do get some values returned by that getDirection()
, but they are unexpected and I don’t know how to interpret them.
So my simple question is - how do I get the direction/orientation from the mesh, having previously set it using mesh.setDirection(new Vector3(1, 0, 1))
? Or maybe calling setDirection isn’t the way to specify the mesh’ orientation in the the scene… then what is the way?..
If someone offers guidance on how I should be thinking about that localAxis
that’s associated with mesh’ direction, I would also appreciate that greatly.
Thank you very much!
Seva