I’m a bit stuck with coordinate transformations. For some reason, I need to pass “axe” to the ref of the mesh and not to the group as it is currently. the problem is that the coordinated transformation happening in the second group will obviously not be correct anymore. How may do this transformation?
// current situation
<group ref={axe} dispose={null}>
<group position={[0.12, -0.21, 0.87]} rotation={[0, Math.PI / 1.8, -0.3]} scale={scale}>
<mesh geometry={nodes.Cube.geometry} material={materials['Material.001']} />
</group>
</group>
// what i want
<group position={[0.12, -0.21, 0.87]} rotation={[0, Math.PI / 1.8, -0.3]} scale={scale}>
<mesh ref={axe} geometry={nodes.Cube.geometry} material={materials['Material.001']} />
</group>
// part of the code where there I set the coordinate.
axe.current.rotation.set(camera.rotation._x, camera.rotation._y, camera.rotation._z)
axe.current.position.copy(camera.position).add(camera.getWorldDirection(ROTATION))
not sure i understand, you’re doing it, you change the order by targeting different groups/meshes as pivot points, this will have a different outcome. if the pivot lies outside and you rotate, everything offset from that will be rotated accordingly. if the pivot lies in the midst of a model it will rotate around itself.
I wasn’t very clear.
What I want is to fusion all the coordinate transformations and get rid of all the groups and only pass ref={axe} to mesh. And that “axe” contains also the transformation induced by the position translation and rotation that were previously in group.
The following may illustrate better what I want.
// current situation
<group ref={axe} dispose={null}>
<group position={[0.12, -0.21, 0.87]} rotation={[0, Math.PI / 1.8, -0.3]} scale={scale}>
<mesh geometry={nodes.Cube.geometry} material={materials['Material.001']} />
</group>
</group>
// what I want. This should give the exact same position and rotation that the code above.
<mesh ref={newAxeRef} geometry={nodes.Cube.geometry} material={materials['Material.001']} />