I am facing an issue with my ferris wheel. The baskets on the wheel are not aligning correctly when the scene is rotated:
https://i.sstatic.net/Ek1mT.png
Everything functions as intended until the scene is rotated, causing the baskets to misalign with the rotation of the ferris wheel:
https://i.sstatic.net/rDR0R.png
How can I ensure that the baskets align with the wheel's position and remain pointed towards the ground during rotation?
The process of creating these baskets involves:
Creating spoke meshes that rotate evenly around the wheel, attached as children of the wheel. At the end of each spoke, empty objects named "dummy0," "dummy1," etc... are placed to track the spoke's position as the wheel rotates. These dummy objects are children of the spokes which are then children of the wheel.
The baskets are created separately as children of the scene, named "basket0," "basket1," etc...
During the rendering process, the wheel rotation is controlled by:
wheel.rotation.z+=controls.speed;
scene.rotation.x=controls.sceneRotation;//scene rotation
The position of each basket is determined within the render method through:
scene.updateMatrixWorld();
wheel.updateMatrixWorld();
for(var i = 0; i < numSpokes; i++){ scene.getObjectByName("basket"+i).position.setFromMatrixPosition(scene.getObjectByName("dummy"+i).matrixWorld);
}
This mechanism works without issues when the scene is not rotated, but encounters problems when the scene undergoes rotation.