@RaananW my man! Or anyone else that knows and can clarify things for me…
When entering immersive WebXR mode, I see two meshes that represent my Oculus Quest controllers. I would like to create a mesh (a box for now) on the side of the controllers where my palm would be (so there is a little offset).
Using the WebXR emulator’s initial pose, the controllers are facing straight forward and I’m able to create and place my box meshes next to the controller meshes:
This looks right:
And I do this using a function like this, where the input mesh is the “controller-0-tracked-pointer-right-grip” grip mesh created by the default web xr experience:
makeGrabAreaMesh(mesh: AbstractMesh, handedness: string) {
let myGrabBox = MeshBuilder.CreateBox("abc", { size: 0.1 }, this.scene)
myGrabBox.position.copyFrom(mesh.position) // <-- not entirely sure why we need this? But without it the boxes such appear at origin. But why does playground example below work with simple box meshes?
myGrabBox.visibility = 0.5
myGrabBox.showBoundingBox = true
myGrabBox.setParent(mesh)
if (handedness[0] === 'l') {
myGrabBox.locallyTranslate(new Vector3(0.1, 0, 0))
} else {
myGrabBox.locallyTranslate(new Vector3(-0.1, 0, 0))
}
return myGrabBox
}
Notice that I parented my box mesh to the grip mesh and at first all seems well. Except in practice, on the actual Oculus Quest, one can never start out in a perfect initial position with controllers pointing exactly forward. And so my boxes were not perfectly on the side or symmetrical with each other.
In fact, even in the emulator, if I first tweak the rotation of the controller orientation before entering immersive mode, and then when I enter immersive mode the offset is still just to the side, but didn’t track with the rotation.
Tweaked emulator left controller so it faces more left
Entered Immersive mode, notice box is still offset to the side but not on the side of the controller
I thought that when we parent a mesh, it “inherits” whatever rotation is on the parent?
Such as in this playground, the child snaps to whatever orientation the parent is in
https://playground.babylonjs.com/#47CRKL
But that doesn’t seem to occur in my webXR situation.
Can you shed some light on what this happens, what I’m missing? How I should correctly parent my box mesh so it tracks to the side of the controller no matter what the rotation?
Thanks in advance!