A-Frame Web Framework for VR/AR

1.7.1 · active · verified Sun Apr 19

A-Frame is an open-source web framework designed for building virtual reality (VR), augmented reality (AR), and general 3D experiences directly within a web browser using declarative HTML. It abstracts away the complexities of WebXR and Three.js, making 3D content creation accessible to a broader audience, including web developers, educators, and artists. The current stable version is 1.7.1, released in April 2025. A-Frame typically releases minor versions every few months, incorporating updates to its underlying Three.js dependency and adding new WebXR features. Key differentiators include its entity-component-system (ECS) architecture, which promotes reusability and modularity, and its focus on performance for interactive WebXR experiences. It supports various platforms, from mobile to desktop and dedicated VR/AR headsets compatible with WebXR.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic A-Frame scene with a camera, a ground, a sky, and a rotating box. It also includes a custom 'rotator' component defined in JavaScript and applied to the box, showcasing A-Frame's extensibility.

<!DOCTYPE html>
<html>
  <head>
    <title>A-Frame Quickstart</title>
    <script src="https://unpkg.com/aframe/dist/aframe-master.min.js"></script>
    <script>
      // Register a custom component
      AFRAME.registerComponent('rotator', {
        schema: { speed: { type: 'number', default: 1000 } },
        init: function () {
          this.el.setAttribute('animation', {
            property: 'rotation',
            to: '0 360 0',
            loop: true,
            dur: this.data.speed
          });
        },
        update: function () {
          this.el.setAttribute('animation', {
            property: 'rotation',
            to: '0 360 0',
            loop: true,
            dur: this.data.speed
          });
        }
      });
    </script>
  </head>
  <body>
    <a-scene background="color: #FAFAFA">
      <!-- Camera with controls -->
      <a-entity camera look-controls wasd-controls position="0 1.6 0"></a-entity>

      <!-- Simple rotating box -->
      <a-box position="0 1 -3" rotation="0 45 0" color="#4CC3D9" rotator="speed: 2000"></a-box>

      <!-- Ground plane -->
      <a-plane position="0 0 -4" rotation="-90 0 0" width="10" height="10" color="#7BC8A4"></a-plane>

      <!-- Sky -->
      <a-sky color="#ECECEC"></a-sky>
    </a-scene>
  </body>
</html>

view raw JSON →