【问题标题】:threejs collada model locationthreejs collada 模型位置
【发布时间】:2015-10-09 10:32:42
【问题描述】:

我一直在研究 THREEJS 框架来渲染 *.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 完全陌生。我希望我清楚地解释了自己:)

【问题讨论】:

    标签: model three.js collada


    【解决方案1】:

    模型的顶点偏离原点,因此您通过设置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

    【讨论】:

    • 非常感谢。它完全适合我。但我有一个问题,你能解释一下它是如何工作的吗?例如,我没有将框添加到屏幕(scene.add(box);)但模型无论如何都是居中的。
    猜你喜欢
    • 2012-10-06
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 2018-07-21
    • 2014-07-25
    • 1970-01-01
    • 2014-12-09
    相关资源
    最近更新 更多