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
var degToRad = THREE.MathUtils.degToRad;
88
var warn = debug('components:light:warn');
9-
var CubeLoader = new THREE.CubeTextureLoader();
109

1110
var probeCache = {};
1211

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

351350
// Populate the cache if not done for this envMap yet
351+
var sceneEl = this.el.sceneEl;
352352
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);
358357
resolve(tempLightProbe);
359358
});
360359
});
361360
});
362361
}
363362

364363
// 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+
});
372367
},
373368

374369
onSetTarget: function (targetEl, light) {

0 commit comments

Comments
 (0)