threejs collada 模型位置

threejs collada model location

我一直在研究三个渲染 *.dae 模型的框架。有几种 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