Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid attempting to load cubemap when envMap is not set for probe light (fix #5610) #5611

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/components/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,25 +345,30 @@ module.exports.Component = registerComponent('light', {
if (!data.envMap) {
// reset parameters if no map
light.copy(new THREE.LightProbe());
return;
}

// Populate the cache if not done for this envMap yet
if (probeCache[data.envMap] === undefined) {
probeCache[data.envMap] = new window.Promise(function (resolve) {
utils.srcLoader.validateCubemapSrc(data.envMap, function loadEnvMap (urls) {
CubeLoader.load(urls, function (cube) {
var tempLightProbe = THREE.LightProbeGenerator.fromCubeTexture(cube);
probeCache[data.envMap] = tempLightProbe;
resolve(tempLightProbe);
});
});
});
}

// Copy over light probe properties
if (probeCache[data.envMap] instanceof window.Promise) {
probeCache[data.envMap].then(function (tempLightProbe) {
light.copy(tempLightProbe);
});
}
if (probeCache[data.envMap] instanceof THREE.LightProbe) {
} else if (probeCache[data.envMap] instanceof THREE.LightProbe) {
light.copy(probeCache[data.envMap]);
}
probeCache[data.envMap] = new window.Promise(function (resolve) {
utils.srcLoader.validateCubemapSrc(data.envMap, function loadEnvMap (urls) {
CubeLoader.load(urls, function (cube) {
var tempLightProbe = THREE.LightProbeGenerator.fromCubeTexture(cube);
probeCache[data.envMap] = tempLightProbe;
light.copy(tempLightProbe);
});
});
});
},

onSetTarget: function (targetEl, light) {
Expand Down
Loading