threejs collada模型位置 [英] threejs collada model location

查看:705
本文介绍了threejs collada模型位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究THREEJS框架来渲染* .dae模型.有几种dae模型.我对模型的位置有疑问.当我渲染它们时,每个模型都有一个不同的位置.我将其位置设置为dae.position.set(0,0,0);,但不幸的是,它的位置并不理想.

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.

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

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);.

您有什么想法,为什么模型不在x,y,z的零位置上.

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

感谢您的帮助.我对Three.js完全陌生.我希望我能清楚地解释自己:)

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

推荐答案

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

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

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

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

three.js r.87

这篇关于threejs collada模型位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆