Systems can help separate logic and behavior from data if desired. We let systems handle the heavy lifting, and components only worry about managing its data through its lifecycle methods:
AFRAME.registerSystem('my-component', {
createComplexObject: function (data) {
// Do calculations and stuff with data.
return new ComplexObject(data);
}
});
AFRAME.registerComponent('my-component', {
init: function () {
this.myObject = null;
},
update: function () {
// Do stuff with `this.data`.
this.myObject = this.system.createComplexObject(this.data);
}
});