MCPcopy Index your code
hub / github.com/aframevr/aframe / updateComponents

Method updateComponents

src/core/a-entity.js:387–432  ·  view source on GitHub ↗

* Initialize or update all components. * Build data using initial components, defined attributes, mixins, and defaults. * Update default components before the rest. * * @property {function} getExtraComponents - Can be implemented to include component data * from other sources (e.g.,

()

Source from the content-addressed store, hash-verified

385 * from other sources (e.g., implemented by primitives).
386 */
387 updateComponents () {
388 var data;
389 var extraComponents;
390 var i;
391 var name;
392 var componentsToUpdate = this.componentsToUpdate;
393
394 if (!this.hasLoaded && !this.isLoading) { return; }
395
396 // Gather mixin-defined components.
397 for (i = 0; i < this.mixinEls.length; i++) {
398 for (name in this.mixinEls[i].componentCache) {
399 if (isComponent(name)) { componentsToUpdate[name] = true; }
400 }
401 }
402
403 // Gather from extra initial component data if defined (e.g., primitives).
404 if (this.getExtraComponents) {
405 extraComponents = this.getExtraComponents();
406 for (name in extraComponents) {
407 if (isComponent(name)) { componentsToUpdate[name] = true; }
408 }
409 }
410
411 // Gather entity-defined components.
412 for (i = 0; i < this.attributes.length; ++i) {
413 name = this.attributes[i].name;
414 if (OBJECT3D_COMPONENTS.indexOf(name) !== -1) { continue; }
415 if (isComponent(name)) { componentsToUpdate[name] = true; }
416 }
417
418 // object3D components first (position, rotation, scale, visible).
419 for (i = 0; i < OBJECT3D_COMPONENTS.length; i++) {
420 name = OBJECT3D_COMPONENTS[i];
421 if (!this.hasAttribute(name)) { continue; }
422 this.updateComponent(name, this.getDOMAttribute(name));
423 }
424
425 // Initialize or update rest of components.
426 for (name in componentsToUpdate) {
427 data = mergeComponentData(this.getDOMAttribute(name),
428 extraComponents && extraComponents[name]);
429 this.updateComponent(name, data);
430 delete componentsToUpdate[name];
431 }
432 }
433
434 /**
435 * Initialize, update, or remove a single component.

Callers 1

loadMethod · 0.80

Calls 5

updateComponentMethod · 0.95
getDOMAttributeMethod · 0.95
isComponentFunction · 0.85
mergeComponentDataFunction · 0.85
getExtraComponentsMethod · 0.80

Tested by

no test coverage detected