Essentially in my scene I have an entity with laser controls and a raycaster in the following structure:
<a-scene>
<a-entity laser-controls raycaster ...>
<!--<a-entity id="inventory" ...> Could be inserted here-->
</a-entity>
<!--<a-entity id="inventory" ...> Could be inserted here-->
</a-scene>
My objective is to summon the inventory at the current x,y position of the laser line, I already have access to the point corresponding to the end of the laser line. I don't want the inventory to move from that position again. If I set the inventory to be the child of the raycaster it always moves with the line. If I set the inventory to be the child of the scene whilst setting it's position to the world coordinates of the point where it's supposed to be, it just does not work.
Approaches I've tried and failed:
- Starting the inventory as raycaster child and changing parent to the scene and applying the world matrix of the raycaster
- Keeping inventory as raycaster child, capturing it's initial world matrix and setting that same world matrix on every tick
And finally, my current approach (with code) that still fails
1.Convering the local coordinates of the line end to world coordinates
2.Appending inventory to scene
3.Converting the world coordinates from line end into local coordinates of the scene
4.Applying the position in 3 to the inventory
let v = this.emptyVec
v.copy(this.raycaster.components.line.data.end)
this.raycaster.object3D.localToWorld(v);
this.el.appendChild(inventoryNode) //this.el is the scene
this.el.object3D.worldToLocal(v);
const {x,y} = v
inventoryNode.object3D.position.set(x,y,inventoryZDistance)
TLDR: How do I set an entity to the position of the raycaster line end at the point in time I add it to the scene and have it remain in that position forever