code: function (material) {
      var el = this.el;
      var mesh;
      var system = this.system;
  
      if (this.material) { disposeMaterial(this.material, system); }
  
      this.material = material;
      system.registerMaterial(material);
  
      // Set on mesh. If mesh does not exist, wait for it.
      mesh = el.getObject3D('mesh');
      if (mesh) {
        mesh.material = material;
      } else {
        el.addEventListener('object3dset', function waitForMesh (evt) {
          if (evt.detail.type !== 'mesh' || evt.target !== el) { return; }
          el.getObject3D('mesh').material = material;
          el.removeEventListener('object3dset', waitForMesh);
        });
      }
    }
docs: (Re)create new material. Has side-effects of setting `this.material` and updating
  material registration in scene.
  
  @param {object} data - Material component data.
  @param {object} type - Material type to create.
  @returns {object} Material.