aframe - Changing src of <a-box> with JavaScript -
i able change src of img element addressing it's id. first define element id "lol".
<img id="lol" src="" />
i click button activates function, changes src:
<script> document.getelementbyid('lol').setattribute('src', `data.value[0].thumbnailurl); </script>`
now while works img tag, not work a-box element:
<a-box id="lol" src="flammer.png" position="-10 0.5 1" rotation="0 45 0" width="1" height="1" depth="1"></a-box>
any appreciated, thanks.
works me after bit of tweaking. run in chrome.
<!doctype html> <html> <head> </head> <body > <p>open inspector , @ src parameter of a-box boo.png</p> <a-box id="lol" src="flammer.png" position="-10 0.5 1" rotation="0 45 0" width="1" height="1" depth="1"></a-box> </body> <script> var data = {value:[{thumbnailurl:"boo.png"}, {thumbnailurl:"blah.png"}]} alert('before: src or a-box=' + document.getelementbyid("lol").getattribute("src")) document.getelementbyid("lol").setattribute("src", data.value[0].thumbnailurl); alert('after: src or a-box=' + document.getelementbyid("lol").getattribute("src")) </script> </html>
Comments
Post a Comment