Skip to content
Advertisement

A-Frame Asset Management System blocks JavaScript code

I’m coding an A-Frame project for our University at the moment with a PHP Backend. Whenever I try to load an a-asset-item in the a-assets section, my JavaScript code stops working. I tried changing the gltf model to a glb and to a obj/mtl and I tried using a CDN model from a A-Frame tutorial. If I don’t load the models or if I load them inline, my code works perfectly fine. You can find the relevant parts here on Glitch: https://glitch.com/edit/#!/join/fff06b7f-11bb-4fdd-a0b0-7f7b7ca4e9cc

Thanks for your help!

Best, Andi

Advertisement

Answer

The HTML is duplicated. Two <a-scene>, A-Frame imported twice… Also PHP code mixed in. It looks like a misunderstanding about how PHP works. The PHP code is run by the server and the client receives valid HTML with no PHP code in it. See the basic tutorial and notice the server side PHP code with <?php echo '<p>Hello World</p>'; ?> and what the client browser receives <p>Hello World</p>

I removed the PHP code from the index.html and left only the scene with the models. Notice that scripts and model URLs are incorrect and the audio assets are missing. In Glitch you can click on the assets within the asset folder to copy the URLs. With URLs corrected and code that depends on server side removed the models load fine:

https://glitch.com/edit/#!/goldenrod-clear-furniture?path=index.html%3A34%3A54

You will have to look for JavaScript errors in the browser console and make sure the client / server communication is working as expected. I don’t think there’s anything wrong on the A-Frame side besides incorrect asset URLs.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement