Reputation: 21
Good day guys
I want to cange a .dae dynamically with this in js
AFRAME.registerComponent('model-overrider', {
init: function() {
document.querySelector('#tree').setAttribute('src',modelo);
}
and the html looks
<a-assets >
<a-asset-item id="tree" src=" "></a-asset-item>
</a-assets>
<a-entity collada-model="#tree" model-overrider></a-entity>
but I can´t make it work
thanks for your help,
sincerely,
Diego Ramirez.
Upvotes: 0
Views: 132
Reputation: 6034
I believe we cannot assign a new src
to an a-asset-item
dynamically. Instead, we can set the a-entity
's collada-model
as follows:
var e = document.querySelector('#myEntity');
e.setAttribute("collada-model", 'url(tree.dae)');
Upvotes: 2