Build Virtual Reality experiences using A-Frame framework

A developer who writes somethings useful.
Search for a command to run...

A developer who writes somethings useful.
Welcome to the Crawl Budget Circus! šŖ Step right up, ladies and gentlemen! Today, weāre diving into the thrilling world of crawl budgetsāthe magical limit that determines how much time Googlebot spends crawling your website. Think of it as a circus ...

A simple math trick discovered by Indian mathematician D. R. Kaprekar

Efficiency at Your Fingertips in Visual Studio Code

Tracing the Roots of the World Wide Web and HTML Evolution

Unlocking Unpopular Functions in JavaScript for Better Code

This article is for the beginner in virtual reality development. Therefore to keep it simple, the article contains the key focus area points to get quickly on board.
Building virtual reality experiences is one of the next things that every tech giant company is focusing on. And why not, this experience is so awesome that anyone can get amazed in a second.
Facebook takes....sorry, Meta takes it too seriously. š
But taking a hand into the development for a new person is tedious as it requires installing development tools/SDK(For instance Unity), needs to learn new tools; maybe language too, and then deployment of an app for the final result to feel it in a real.
A-Frame takes initiative to remove all these obstacles and provides the web-based framework that the majority of the developer know; HTML & JAVASCRIPT
A-Frame is built upon Three.js. Three.js is a JavaScript library which deals with 3D objects and animation using WebGL.
In a simple term, A-Frame provides top-level abreaction based on WebGL language and gives an API to build web-based VR applications.

One of the important feature: Declarative HTML
ā¤ļø HTML is easy to read and copy-and-paste. Since A-Frame can be used from HTML, A-Frame is accessible to everyone: web developers, VR enthusiasts, educators, artists, makers, kids.
Literally, you can just write couple of html lines and feel proud on your self š.
A-Frame is not the replacement of Threejs but it provides quick setup and abstraction to build VR apps.
ThreeJS is the generalized framework that is used to develop 3D objects and animation.
Primitives are the predefined components by the A-Frame such as box, circle, sky, cylinder, etc... That makes it super easy to do some exciting stuff even for the novice developer in this domain.
If you want to render a box at some position then put it below primitive and there you go!
<a-box position="-1 1.5 -5" color="#00ff00"></a-box>
But wait, before moving to the custom primitive, we still need to check one more thing; Component.
A component is a reusable piece of an element. A-frame provides registerComponent API to create it and exposes several events to handle objects dynamically.
AFRAME.registerComponent('foo', {
schema: {}, // Used to defined properties for the component
init: function () {}, // Called once when the component is initialized. Used to set up initial state and instantiate variables.
update: function () {}, // Called both when the component is initialized and whenever any of the componentās properties is updated
tick: function () {}, // Called continuously(Render loop) and where all magic animation is of object is done.
remove: function () {}, // Called whenever the component is detached from the entity
pause: function () {}, // Called when the entity or scene pauses
play: function () {} // Called once when the component is initialized and is called when the entity or scene resumes.
});
Check out an example of the custom component "animate-circle".
tick method in a component is called 90 times per second and radius is managed at a certain point to the up and down.
Schema is passed as a key-pair value separated by a semicolon in the HTML.
A component can be attached to the entity(a-entity). An entity is like a <div> in A-frame and without attaching a component to it, it's just like an empty <div>.
In the previous example, a custom component was made and it was added to the a-entity whereas if we define primitives, it can be used directly as an HTML tag(<a-animate-cirlce>) and schema value can be passed as an individual attribute.
Primitives can consider as syntactic sugar which is more readable to the newcomers.