Threejs collada模型位置



我一直在用THREEJS框架渲染*。dae的模型。有几个大的模型。我对模型的位置有个问题。当我渲染它们时,每个模型都有不同的位置。我设置了他们的位置dae.position.set(0,0,0);,但不幸的是,它不能完美地工作。

例如,对于一个模型,我必须将位置设置为dae.position.set(-2, -31, 6.5);,然后模型位于位置(0,0,0)上。我用AXES axes.position.set(0,0,0);检查了一下。

你知道为什么模型不在x,y,z的零点位置吗?

谢谢你的帮助。我对three.js完全陌生。我希望我解释清楚了

模型的顶点与原点偏移,因此您可以通过设置dae.position进行补偿。

您可以通过重新进入模型来自动调整dae位置,如下所示:

var box = new THREE.Box3().setFromObject( dae ); // compute the bounding box of the model
box.getCenter( dae.position ); // set dae.position to be the center of the bounding box
dae.position.multiplyScalar( - 1 ); // negate the dae.position coordinates

three.js r.87

最新更新