如何在运行时在框架中加载3D对象? [英] How to load 3D object at runtime in aframe?

查看:83
本文介绍了如何在运行时在框架中加载3D对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个需要在运行时加载3D对象的Aframe项目。我已经阅读了A-Frame文档,并且aframe似乎根本不支持运行时资产加载。

I am working on an aframe project where runtime loading of 3D object is required. I have read A-Frame documentations, and aframe doesn't seem to support runtime assets loading at all.

我通过以下方式发现了该aframe-asset-on-demand组件: protyze( https://github.com/protyze/aframe-asset-on-需求组件),它似乎允许在运行时加载img,音频和视频。但是其文档并没有表明在运行时将3D对象(如.obj或.dae文件)加载到文件中的可能性。

I discovered this aframe-asset-on-demand-component by protyze (https://github.com/protyze/aframe-asset-on-demand-component) and it seems to allow runtime loading of img, audio and video. But its documentation does not indicate the possibility of loading 3D objects like files in .obj or .dae at runtime.

是否有人尝试使用上述组件来实现运行时?加载3D对象?还是有其他替代方法可以实现此目的?

Has anyone tried using the above-mentioned component to achieve runtime loading of 3D objects? Or is there any alternative ways to achieve this purpose?

推荐答案

忽略< a-assets> ,因为这是用于运行前网络预加载。

Ignore <a-assets> since that is for pre-runtime network preloading.

只需使用setAttribute设置模型组件:

Just set the model component with setAttribute:

el.setAttribute('gltf-model','path / to / model.gltf')

el.setAttribute('obj-model',{obj:'path / to / model.obj'})

这篇关于如何在运行时在框架中加载3D对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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