Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load 3D object at runtime in 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.

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.

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?

like image 687
Felix Avatar asked Mar 26 '26 02:03

Felix


1 Answers

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

Just set the model component with setAttribute:

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

or

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

like image 152
ngokevin Avatar answered Mar 28 '26 01:03

ngokevin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!