6
A
回答
6
可以访问3d.io实体的three.js所对象是这样的:
var threeElem = document.getElementById("custom-id").components['io3d-data3d'].data3dView.threeParent
然后你可以使用从three.js所本地边框:
var bbox = new THREE.Box3().setFromObject(threeElem)
像这样你可以得到最小/最大范围whi你可以用它来确定原点。
我希望能回答你的问题。让我知道!
编辑: 家具,很可能会基于Madlaina的回答
var threeElem = document.getElementById("custom-id").components['io3d-furniture'].data3dView.threeParent
4
。我需要确保该模型前
addModelToScene(type) {
let scene = document.querySelector('a-scene');
let model = document.createElement('a-entity');
model.setAttribute('io3d-data3d', getModelKey(type))
model.addEventListener('model-loaded',() => {
// Access the three.js object of the 3d.io
let threeElem = model.components['io3d-data3d'].data3dView.threeParent
// create the bounding box
let bbox = new THREE.Box3().setFromObject(threeElem)
// Calculate the center-point offsets from the max and min points
const offsetX = (bbox.max.x + bbox.min.x)/2
const offsetY = (bbox.max.y + bbox.min.y)/2
const offsetZ = (bbox.max.z + bbox.min.z)/2
// apply the offset
model.setAttribute('position', {x:-offsetX,y:-offsetY, z:-offsetZ})
});
scene.appendChild(model);
}
+0
很酷!很高兴它的作品!我一定会在自己的草稿中使用它 –
相关问题
- 1. 如何使用模型衍生API获取模型大小或边界框?
- 2. 获取城市边界框
- 3. xtk中相机的型号和旋转中心的边界框
- 4. 如何计算边界框的中心?
- 5. 从ggmap对象中获取边界框
- 6. MKCoordinateRegion是否跨越中心到边界或边界?
- 7. 获取视图的框架/边界
- 8. 获取地块()边界框的值
- 9. 获取SVG路径的边界框
- 10. 获取边界框内的点
- 11. 获取所有机构的边界框
- 12. 如何获取边界的边界值?
- 13. UIView UIScrollview - 框架,边界,中心混淆
- 14. UIInterfaceOrientation,CGAffineTransform,框架,边界和中心
- 15. 从中心坐标创建边界框
- 16. GeoServer REST API获取边界框
- 17. 在OpenLayers边界框内获取标记
- 18. 将Blob的质心与边界框的中心进行比较
- 19. 使用CSS获取心形边框?
- 20. 获取尽可能多的多边形的最小边界框
- 21. 获取滑块的边界
- 22. 获取四边形边界的边界区域
- 23. 以margin为中心的元素的负边界边界:0 auto;
- 24. 如何获取R中openmap()的特定城市的边界框?
- 25. 如何获取C#中的HTMLAgilityPack DOM元素的边界框?
- 26. 如何获取JFrame中轴框的边界?
- 27. 如何获取c#中屏幕上的文本边界框?
- 28. 如何获取YOLO对象检测中边界框的坐标?
- 29. 如何获取wpf中多个项目的边界框?
- 30. 在pdf中获取每个字形的边界框 - iOS
作品十分感谢,只是一个小错字。 'Data3dView'应该是'data3dView'。 这是我最初尝试过的,但它没有工作,因为模型尚未加载。这是通过听“模型加载”事件来解决的。 我将在下面添加我的解决方案作为答案,供其他人参考。 –
非常感谢。我在我的回答中修复了错字:) –