threejs坐标转换
threejs坐标转换
世界坐标转局部坐标
//head为需要改变的bone的父节点 let head=this.scene.getObjectByName('head'); const v3 = new THREE.Vector3(); head.getWorldPosition(v3); let bone = this.scene.getObjectByName(boneData[i].name); // 小球的世界坐标减去骨骼父节点的世界坐标,小球为在对应骨骼点展示的sphere bone.position.set( -boneData[i].world_position.x-v3.x, boneData[i].world_position.y-v3.y, boneData[i].world_position.z-v3.z )
局部坐标转世界坐标
const v3 = new THREE.Vector3();
object.getWorldPosition(v3);
sphere.position.set(v3.x, v3.y, v3.z);