用于鼠标拾取的OBJMTLLoader对象周围的three.js boundingBox

时间:2015-09-03 08:27:31

标签: javascript three.js bounding-box

我正在寻找一个解决方案来获取我用OBJMTLLoader加载的对象周围的边界框。我需要这个,因为我加载的Object对我的鼠标拾取方法没有反应,所以我会尝试使用boundingBox运行它。

这就是我最后的尝试:

function furnitureII(){
var loaderI = new THREE.OBJMTLLoader();
loaderI.load('models/lettoCiliegio.obj', 'models/lettoCiliegio.mtl', function(object) {
    var bbox = new THREE.Box3().setFromObject(object);    
    object.position.z = 5;
    object.position.y = -5.95;
    object.position.x = 10;
    object.scale.set(0.05,0.05,0.05);
    scene.add(bbox);
});    
}

错误:TypeError:bbox.position未定义 如果我为盒子设置位置,它也不起作用。

function furnitureII(){
var loaderI = new THREE.OBJMTLLoader();
loaderI.load('models/lettoCiliegio.obj', 'models/lettoCiliegio.mtl', function(object) {
    var bbox = new THREE.Box3().setFromObject(object); 
    bbox.position.set(2,-4,0);
    object.position.z = 5;
    object.position.y = -5.95;
    object.position.x = 10;
    object.scale.set(0.05,0.05,0.05);
    scene.add(bbox);
});}

0 个答案:

没有答案