Skip to content

Commit 241a775

Browse files
authored
Use loadCubeMapTexture instead of CubeTextureLoader for light probes (#5735)
1 parent b910db8 commit 241a775

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

‎src/components/light.js‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as mathUtils from '../utils/math.js'
66

77
vardegToRad=THREE.MathUtils.degToRad;
88
varwarn=debug('components:light:warn');
9-
varCubeLoader=newTHREE.CubeTextureLoader();
109

1110
varprobeCache={};
1211

@@ -349,26 +348,22 @@ export var Component = registerComponent('light',{
349348
}
350349

351350
// Populate the cache if not done for this envMap yet
351+
varsceneEl=this.el.sceneEl;
352352
if(probeCache[data.envMap]===undefined){
353-
probeCache[data.envMap]=newwindow.Promise(function(resolve){
354-
srcLoader.validateCubemapSrc(data.envMap,functionloadEnvMap(urls){
355-
CubeLoader.load(urls,function(cube){
356-
vartempLightProbe=LightProbeGenerator.fromCubeTexture(cube);
357-
probeCache[data.envMap]=tempLightProbe;
353+
probeCache[data.envMap]=newPromise(function(resolve){
354+
srcLoader.validateCubemapSrc(data.envMap,functionloadEnvMap(srcs){
355+
sceneEl.systems.material.loadCubeMapTexture(srcs,function(texture){
356+
vartempLightProbe=LightProbeGenerator.fromCubeTexture(texture);
358357
resolve(tempLightProbe);
359358
});
360359
});
361360
});
362361
}
363362

364363
// Copy over light probe properties
365-
if(probeCache[data.envMap]instanceofwindow.Promise){
366-
probeCache[data.envMap].then(function(tempLightProbe){
367-
light.copy(tempLightProbe);
368-
});
369-
}elseif(probeCache[data.envMap]instanceofTHREE.LightProbe){
370-
light.copy(probeCache[data.envMap]);
371-
}
364+
probeCache[data.envMap].then(function(tempLightProbe){
365+
light.copy(tempLightProbe);
366+
});
372367
},
373368

374369
onSetTarget: function(targetEl,light){

0 commit comments

Comments
(0)