aframe Components Register a custom A-Frame component


AFRAME.registerComponent (name, definition)

Register an A-Frame component. We must register components before we use them anywhere in . Meaning from an HTML file, components should come in order before .

  • {string} name - Component name. The component’s public API as represented through an HTML attribute name.
  • {Object} definition - Component definition. Contains schema and lifecycle handler methods.

Registering component in foo in your js file e.g foo-component.js

AFRAME.registerComponent('foo', {
  schema: {},
  init: function () {},
  update: function () {},
  tick: function () {},
  remove: function () {},
  pause: function () {},
  play: function () {}

Usage of foo component in your scene

    <script src="aframe.min.js"></script>
    <script src="foo-component.js"></script>
      <a-entity foo></a-entity>