threejs collada model location

淺唱寂寞╮ 提交于 2019-12-25 04:43:27

问题


I have been working on THREEJS framework to render *.dae models. There are several dae models. I have a problem with the location of the models. When I render them, each model has a different location. I set their location dae.position.set(0,0,0); but unfortunately, it doesn't work perfectly.

For example, for one model I have to set the location as dae.position.set(-2, -31, 6.5); and then model is on the location(0,0,0). I check it with AXES axes.position.set(0,0,0);.

Do you have any idea, why is the model not on the zero location for x,y,z.

Thank you for helping. I am totally new to three.js. I hope I explained myself clearly :)


回答1:


The vertices of the model are offset from the origin, so you are compensating by setting the dae.position.

You can automatically adjust the dae position by recentering the model like so:

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



来源:https://stackoverflow.com/questions/31514187/threejs-collada-model-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!