最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Three.js: wrong BoundingBox after scaling a geometry - Stack Overflow

programmeradmin0浏览0评论

In my scene I have a simple cube:

var test = new THREE.Mesh(new THREE.CubeGeometry(10,10,10), new THREE.MeshBasicMaterial());
scene.add(test);

This cube is getting traversed/scaled through the user with THREE.TransformControls. What I need is the boundingbox of the cube after these interactions. So I'm doing

test.geometryputeBoundingBox();
var bb = test.geometry.boundingBox;
bb.translate(test.localToWorld( new THREE.Vector3()));

But I always get a wrong boundingbox! The translation is puted correct, but not the scale. The width and heigth of the boundingbox is always 10 ...

Is this a bug or feature? How do I get the correct boundingbox of my cube?

In my scene I have a simple cube:

var test = new THREE.Mesh(new THREE.CubeGeometry(10,10,10), new THREE.MeshBasicMaterial());
scene.add(test);

This cube is getting traversed/scaled through the user with THREE.TransformControls. What I need is the boundingbox of the cube after these interactions. So I'm doing

test.geometry.puteBoundingBox();
var bb = test.geometry.boundingBox;
bb.translate(test.localToWorld( new THREE.Vector3()));

But I always get a wrong boundingbox! The translation is puted correct, but not the scale. The width and heigth of the boundingbox is always 10 ...

Is this a bug or feature? How do I get the correct boundingbox of my cube?

Share Improve this question asked Aug 27, 2013 at 9:15 PanChanPanChan 3821 gold badge6 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You can pute the world-axis-aligned bounding box of an object (including its children) like so:

var box = new THREE.Box3();
box.setFromObject( object );

Have a look at the source code so you understand what it is doing.

three.js. r.60

发布评论

评论列表(0)

  1. 暂无评论