Three.js - 导入Blender JSON模型的错误边界框 [英] Three.js - Wrong Bounding Box importing Blender JSON model

查看:159
本文介绍了Three.js - 导入Blender JSON模型的错误边界框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在操作从Blender加载的对象时遇到了一些问题。我认为枢轴点总是设置为0,0,0而不是当前对象的位置。我正确地定位并导入Blender场景中的对象,但是我在旋转它时遇到了问题。

I am having some problems manipulating the objects I load from Blender. I think the pivot point is always set to 0,0,0 instead of the current object's position. I correctly position and import the objects in the Blender scene, but then I have problems rotating them.

我使用了BoundingBoxHelper来查看发生了什么,但边界框是没有出现在周围的物体,但在世界中心,并且有一个单位的大小(我猜这是默认值)

I have used BoundingBoxHelper to see what is happening, but the bounding box is not appearing surrounding the object but centered in the world and with a 1-unit size (I guess that is the default)

这是我用来加载外星人的代码:

This is the code I use to load the alien:

texture6 = THREE.ImageUtils.loadTexture('images/alien1.png', {}, function() {
        renderer.render(scene, camera);
    });

    loader = new THREE.JSONLoader();
    loader.load( "models/alien1.js", function( geometry ) {
        geometry.computeFaceNormals();
        geometry.computeCentroids();
        geometry.computeBoundingBox();

        var mat = new THREE.MeshBasicMaterial({map: texture6,transparent: true, color:0x00FF00} );
        var mesh = new THREE.Mesh( geometry, mat );
        scene.add(mesh);

        bbHelper = new THREE.BoundingBoxHelper( mesh, 0xff0000 );
        scene.add( bbHelper );
    });

这就是结果:
(红色边界框应该围绕绿色外星人但是在场景的中心)

And this is the result: (The red bounding box should be surrounding the green alien but is in the center of the scene)

有什么建议吗?

推荐答案

你需要调用 bbHelper.update()

如果对象正在移动,则在渲染循环中进行调用。

Make the call in the render loop if the object is moving.

three.js r.59

three.js r.59

这篇关于Three.js - 导入Blender JSON模型的错误边界框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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