두 개의 메시가 추가 된 THREE.Scene
은 meshA
과 meshB
이며, 각각 다른 방식으로 회전되었습니다. 제 목표는 meshB
을 장면에서 제거하고 meshA
의 하위 항목으로 다시 추가하는 것입니다. 글로벌 위치와 순환 게재를 유지하는 것, 즉 meshB
의 위치와 순환은이 코드 전후에 동일하게 나타나야합니다. 다음과 같이Three.js - 상대 회전 계산
나의 현재 거의 작업 시도는 다음과 같습니다
이var globalOffset = new THREE.Vector3().subVectors(meshB.position, meshA.position);
var localOffset = meshA.worldToLocal(meshB.position);
var rotationOffset = meshA.quaternion.clone().inverse();
var rotation = meshB.quaternion.clone().multiply(rotationOffset);
scene.remove(meshB);
meshA.add(meshB);
meshB.position = localOffset;
meshB.rotation.setFromQuaternion(rotation);
위치 결정이 잘 작동; 회전은 meshA
과 meshB
이 모두 같은 축을 중심으로 회전 한 경우에만 작동합니다. meshA
및 meshB
을 다른 축을 중심으로 회전하면 meshB
이이 코드 전후로 회전을 전환하는 것처럼 보입니다.
위의 코드 (또는 다른 접근법에 대한 아이디어)를 수정하여 이전에 동일한 "전역"회전을 제거하고 장면에 다시 추가 한 아이디어가 있습니까?
감사합니다.