threejs how to rotate around object's own center,instead of world center

前端 未结 5 723
渐次进展
渐次进展 2020-11-27 03:27

\"enter

two objects in the scene. the cube rotate axis should be the cube\'s center,th

5条回答
  •  感情败类
    2020-11-27 03:57

    If there are multiple meshes (which is most common), set the position of the parent node in the scene graph to achieve the goal of centering the model. If the scene graph is like this gltfObject -> childObject ->.. -> array of meshes

    const bbox = new THREE.Box3().setFromObject( gltfObject );
    const offset = new THREE.Vector3();
    bbox.getCenter(offset).negate();
    childObject.position.set(offset.x, offset.y, offset.z);
    

提交回复
热议问题