Tutorial by Examples

We can use the componentchanged event to listen for changes to the entity: entity.addEventListener('componentchanged', function (evt) { if (evt.detail.name === 'position') { console.log('Entity has moved from', evt.detail.oldData, 'to', evt.detail.newData, '!'); } });
We can use the child-attached and child-detached events to listen for when the scene attaches or detaches an entity: entity.addEventListener('child-attached', function (evt) { if (evt.detail.el.tagName.toLowerCase() === 'a-box') { console.log('a box element has been attached'); }; }); ...
Updating Multi-Property Component Data To update component data for a multi-property component, we can pass the name of a registered component as the componentName, and pass an object of properties as the value. A string is also acceptable (e.g., type: spot; distance: 30), but objects will save A-F...
We can simply retrieve an entity using DOM APIs. <a-entity id="mario"></a-entity> var el = document.querySelector('#mario');
For example, if we wanted to grab an entity’s three.js camera object or material object, we could reach into its components var camera = document.querySelector('a-entity[camera]').components.camera.camera; var material = document.querySelector('a-entity[material]').components.material.material; ...

Page 1 of 1