aframe-playground

A playground for learning about A-frame

View the Project on GitHub jgbarah/aframe-playground

Back to the main page

Building a scene with JavaScript

Let’s work in js-01, creating a scene from scratch using JavaScript. In other words, in HTML will have only an a-scene element, and a JS script that, when the HTML document is loaded in the browser, injects the rest of the scene in the DOM, as children of a-secene.

Check the resulting virtual reality scene.

Same scene, with movement-controls.

Building a scene with an A-Frame component

Now, let’s do the same, but with an A-Frame component.

Check the resulting virtual reality scene.

Events

Events can be added via properties of components (for example, the animation component responds to events if its property startEvents is used), or vía JavaScript handlers.

Check the resulting virtual reality scene.