Refactor action handling in simulation components for improved clarity and efficiency
This commit is contained in:
@@ -174,12 +174,14 @@ function RotateControls3D({
|
||||
);
|
||||
const angleDelta = prevAngle - currentAngle;
|
||||
|
||||
const rotationMatrix = new THREE.Matrix4().makeRotationY(angleDelta);
|
||||
|
||||
rotatedObjects.forEach((obj: THREE.Object3D) => {
|
||||
if (obj.userData.modelUuid) {
|
||||
const relativePos = new THREE.Vector3().subVectors(obj.position, center);
|
||||
relativePos.applyAxisAngle(new THREE.Vector3(0, 1, 0), angleDelta);
|
||||
obj.position.copy(center).add(relativePos);
|
||||
obj.rotation.y += angleDelta;
|
||||
const relativePosition = new THREE.Vector3().subVectors(obj.position, center);
|
||||
relativePosition.applyMatrix4(rotationMatrix);
|
||||
obj.position.copy(center).add(relativePosition);
|
||||
obj.rotateOnWorldAxis(new THREE.Vector3(0, 1, 0), angleDelta);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user