@@ -6,7 +6,6 @@ import * as mathUtils from '../utils/math.js';
6
6
7
7
var degToRad = THREE . MathUtils . degToRad ;
8
8
var warn = debug ( 'components:light:warn' ) ;
9
- var CubeLoader = new THREE . CubeTextureLoader ( ) ;
10
9
11
10
var probeCache = { } ;
12
11
@@ -349,26 +348,22 @@ export var Component = registerComponent('light', {
349
348
}
350
349
351
350
// Populate the cache if not done for this envMap yet
351
+ var sceneEl = this . el . sceneEl ;
352
352
if ( probeCache [ data . envMap ] === undefined ) {
353
- probeCache [ data . envMap ] = new window . Promise ( function ( resolve ) {
354
- srcLoader . validateCubemapSrc ( data . envMap , function loadEnvMap ( urls ) {
355
- CubeLoader . load ( urls , function ( cube ) {
356
- var tempLightProbe = LightProbeGenerator . fromCubeTexture ( cube ) ;
357
- probeCache [ data . envMap ] = tempLightProbe ;
353
+ probeCache [ data . envMap ] = new Promise ( function ( resolve ) {
354
+ srcLoader . validateCubemapSrc ( data . envMap , function loadEnvMap ( srcs ) {
355
+ sceneEl . systems . material . loadCubeMapTexture ( srcs , function ( texture ) {
356
+ var tempLightProbe = LightProbeGenerator . fromCubeTexture ( texture ) ;
358
357
resolve ( tempLightProbe ) ;
359
358
} ) ;
360
359
} ) ;
361
360
} ) ;
362
361
}
363
362
364
363
// Copy over light probe properties
365
- if ( probeCache [ data . envMap ] instanceof window . Promise ) {
366
- probeCache [ data . envMap ] . then ( function ( tempLightProbe ) {
367
- light . copy ( tempLightProbe ) ;
368
- } ) ;
369
- } else if ( probeCache [ data . envMap ] instanceof THREE . LightProbe ) {
370
- light . copy ( probeCache [ data . envMap ] ) ;
371
- }
364
+ probeCache [ data . envMap ] . then ( function ( tempLightProbe ) {
365
+ light . copy ( tempLightProbe ) ;
366
+ } ) ;
372
367
} ,
373
368
374
369
onSetTarget : function ( targetEl , light ) {
0 commit comments