本文介绍了如何从aframe中的3D对象获取包围盒信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在一个aframe项目中,该项目涉及将未知大小的3D对象加载到我的场景中。自然,我想在将对象放入场景之前将其调整为一定大小(例如固定高度)。但是,如何从对象的边界框中提取宽度,高度和深度之类的信息呢?
I am working on an aframe project that involves loading 3D objects of unknown sizes into my scene. Naturally I would want to resize the object to a certain size (like fixed height) before I put it in the scene. But how do I extract information like width, height and depth from the object's bounding box?
推荐答案
您需要使用A -Frame的基础three.js API。该答案已,但这里是A-Frame版本:
You'll need to use A-Frame's underlying three.js APIs here. That answer has been posted for three.js before, but here's an A-Frame version:
// get three.js object from aframe entity
var el = document.querySelector('#my-element');
var object = el.getObject3D('mesh');
// compute bounding box
var bbox = new THREE.Box3().setFromObject(obj);
console.log(bbox.min, bbox.max)
这篇关于如何从aframe中的3D对象获取包围盒信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!