index.js
function () {
    var collisionEntities;
    var data = this.data;
    var el = this.el;

    if (!data.collisionEntities) {
      this.collisionEntities = [];
      return;
    }

    collisionEntities = [].slice.call(el.sceneEl.querySelectorAll(data.collisionEntities));
    this.collisionEntities = collisionEntities;

    // Update entity list on attach.
    this.childAttachHandler = function childAttachHandler (evt) {
      if (!evt.detail.el.matches(data.collisionEntities)) { return; }
      collisionEntities.push(evt.detail.el);
    };
    el.sceneEl.addEventListener('child-attached', this.childAttachHandler);

    // Update entity list on detach.
    this.childDetachHandler = function childDetachHandler (evt) {
      var index;
      if (!evt.detail.el.matches(data.collisionEntities)) { return; }
      index = collisionEntities.indexOf(evt.detail.el);
      if (index === -1) { return; }
      collisionEntities.splice(index, 1);
    };
    el.sceneEl.addEventListener('child-detached', this.childDetachHandler);
  }
function () {
    var collisionEntities;
    var data = this.data;
    var el = this.el;

    if (!data.collisionEntities) {
      this.collisionEntities = [];
      return;
    }

    collisionEntities = [].slice.call(el.sceneEl.querySelectorAll(data.collisionEntities));
    this.collisionEntities = collisionEntities;

    // Update entity list on attach.
    this.childAttachHandler = function childAttachHandler (evt) {
      if (!evt.detail.el.matches(data.collisionEntities)) { return; }
      collisionEntities.push(evt.detail.el);
    };
    el.sceneEl.addEventListener('child-attached', this.childAttachHandler);

    // Update entity list on detach.
    this.childDetachHandler = function childDetachHandler (evt) {
      var index;
      if (!evt.detail.el.matches(data.collisionEntities)) { return; }
      index = collisionEntities.indexOf(evt.detail.el);
      if (index === -1) { return; }
      collisionEntities.splice(index, 1);
    };
    el.sceneEl.addEventListener('child-detached', this.childDetachHandler);
  }
function ( ) { var collisionEntities ; var data = this . data ; var el = this . el ; if ( ! data . collisionEntities ) { this . collisionEntities = [ ] ; return ; } collisionEntities = [ ] . slice . call ( el . sceneEl . querySelectorAll ( data . collisionEntities ) ) ; this . collisionEntities = collisionEntities ; // Update entity list on attach. this . childAttachHandler = function childAttachHandler ( evt ) { if ( ! evt . detail . el . matches ( data . collisionEntities ) ) { return ; } collisionEntities . push ( evt . detail . el ) ; } ; el . sceneEl . addEventListener ( 'child-attached' , this . childAttachHandler ) ; // Update entity list on detach. this . childDetachHandler = function childDetachHandler ( evt ) { var index ; if ( ! evt . detail . el . matches ( data . collisionEntities ) ) { return ; } index = collisionEntities . indexOf ( evt . detail . el ) ; if ( index === - 1 ) { return ; } collisionEntities . splice ( index , 1 ) ; } ; el . sceneEl . addEventListener ( 'child-detached' , this . childDetachHandler ) ; }
Run `querySelectorAll` for `collisionEntities` and maintain it with `child-attached`
and `child-detached` events.
Run querySelectorAll for collisionEntities and maintain it with child - attached and child - detached events .