src/shaders/standard.js
function (data) {
    var self = this;
    var material = this.material;
    var envMap = data.envMap;
    var sphericalEnvMap = data.sphericalEnvMap;

    // No envMap defined or already loading.
    if ((!envMap && !sphericalEnvMap) || this.isLoadingEnvMap) {
      material.envMap = null;
      material.needsUpdate = true;
      return;
    }
    this.isLoadingEnvMap = true;

    // if a spherical env map is defined then use it.
    if (sphericalEnvMap) {
      this.el.sceneEl.systems.material.loadTexture(sphericalEnvMap, {src: sphericalEnvMap}, function textureLoaded (texture) {
        self.isLoadingEnvMap = false;
        texture.mapping = THREE.SphericalReflectionMapping;
        material.envMap = texture;
        utils.material.handleTextureEvents(self.el, texture);
        material.needsUpdate = true;
      });
      return;
    }

    // Another material is already loading this texture. Wait on promise.
    if (texturePromises[envMap]) {
      texturePromises[envMap].then(function (cube) {
        self.isLoadingEnvMap = false;
        material.envMap = cube;
        utils.material.handleTextureEvents(self.el, cube);
        material.needsUpdate = true;
      });
      return;
    }

    // Material is first to load this texture. Load and resolve texture.
    texturePromises[envMap] = new Promise(function (resolve) {
      utils.srcLoader.validateCubemapSrc(envMap, function loadEnvMap (urls) {
        CubeLoader.load(urls, function (cube) {
          // Texture loaded.
          self.isLoadingEnvMap = false;
          material.envMap = cube;
          utils.material.handleTextureEvents(self.el, cube);
          resolve(cube);
        });
      });
    });
  }
function (data) {
    var self = this;
    var material = this.material;
    var envMap = data.envMap;
    var sphericalEnvMap = data.sphericalEnvMap;

    // No envMap defined or already loading.
    if ((!envMap && !sphericalEnvMap) || this.isLoadingEnvMap) {
      material.envMap = null;
      material.needsUpdate = true;
      return;
    }
    this.isLoadingEnvMap = true;

    // if a spherical env map is defined then use it.
    if (sphericalEnvMap) {
      this.el.sceneEl.systems.material.loadTexture(sphericalEnvMap, {src: sphericalEnvMap}, function textureLoaded (texture) {
        self.isLoadingEnvMap = false;
        texture.mapping = THREE.SphericalReflectionMapping;
        material.envMap = texture;
        utils.material.handleTextureEvents(self.el, texture);
        material.needsUpdate = true;
      });
      return;
    }

    // Another material is already loading this texture. Wait on promise.
    if (texturePromises[envMap]) {
      texturePromises[envMap].then(function (cube) {
        self.isLoadingEnvMap = false;
        material.envMap = cube;
        utils.material.handleTextureEvents(self.el, cube);
        material.needsUpdate = true;
      });
      return;
    }

    // Material is first to load this texture. Load and resolve texture.
    texturePromises[envMap] = new Promise(function (resolve) {
      utils.srcLoader.validateCubemapSrc(envMap, function loadEnvMap (urls) {
        CubeLoader.load(urls, function (cube) {
          // Texture loaded.
          self.isLoadingEnvMap = false;
          material.envMap = cube;
          utils.material.handleTextureEvents(self.el, cube);
          resolve(cube);
        });
      });
    });
  }
function ( data ) { var self = this ; var material = this . material ; var envMap = data . envMap ; var sphericalEnvMap = data . sphericalEnvMap ; // No envMap defined or already loading. if ( ( ! envMap && ! sphericalEnvMap ) || this . isLoadingEnvMap ) { material . envMap = null ; material . needsUpdate = true ; return ; } this . isLoadingEnvMap = true ; // if a spherical env map is defined then use it. if ( sphericalEnvMap ) { this . el . sceneEl . systems . material . loadTexture ( sphericalEnvMap , { src : sphericalEnvMap } , function textureLoaded ( texture ) { self . isLoadingEnvMap = false ; texture . mapping = THREE . SphericalReflectionMapping ; material . envMap = texture ; utils . material . handleTextureEvents ( self . el , texture ) ; material . needsUpdate = true ; } ) ; return ; } // Another material is already loading this texture. Wait on promise. if ( texturePromises [ envMap ] ) { texturePromises [ envMap ] . then ( function ( cube ) { self . isLoadingEnvMap = false ; material . envMap = cube ; utils . material . handleTextureEvents ( self . el , cube ) ; material . needsUpdate = true ; } ) ; return ; } // Material is first to load this texture. Load and resolve texture. texturePromises [ envMap ] = new Promise ( function ( resolve ) { utils . srcLoader . validateCubemapSrc ( envMap , function loadEnvMap ( urls ) { CubeLoader . load ( urls , function ( cube ) { // Texture loaded. self . isLoadingEnvMap = false ; material . envMap = cube ; utils . material . handleTextureEvents ( self . el , cube ) ; resolve ( cube ) ; } ) ; } ) ; } ) ; }
Handle environment cubemap. Textures are cached in texturePromises.
Handle environment cubemap . Textures are cached in texturePromises .