Back to Aframe

Globals

docs/core/globals.md

1.7.16.4 KB
Original Source

A-Frame exposes its public interface through the window.AFRAME browser global. This same interface is also exposed when you import aframe (import AFRAME from 'aframe').

AFRAME Properties

PropertyDescription
AComponentComponent prototype.
AEntityEntity prototype.
ANodeBase node prototype that A-Frame elements inherit from.
ASceneScene prototype.
componentsObject of registered components.
geometriesObject of registered geometries .
primitives.primitivesObject of registered primitives.
registerComponentFunction to register a component.
registerGeometryFunction to register a geometry.
registerPrimitiveFunction to register a primitive like registering an A-Frame elements similar to <a-box>.
registerShaderFunction to register a material or shader.
schemaSchema-related utilities.
shadersObject of registered shaders.
systemsObject of registered systems.
THREEGlobal three.js object.
utilsA-Frame utility modules.
versionVersion of A-Frame build.

window Properties

PropertyDescription
AFRAMEThe object described above.

Requiring AFRAME in a Node.js Environment

It is possible to run A-Frame in Node.js to get access to its globals. The only catch is we need to supply a browser window mock since Node.js lacks a window object. You can do that with jsdom-global, and you also need to mock customElements.

js
const cleanup = require('jsdom-global')();
global.customElements = { define: function () {} };
const aframe = require('aframe');
console.log(aframe.version);
cleanup();

You can't use jsdom to run tests with aframe components because customElements api is missing. A-Frame is using karma to open a real browser to run the tests.