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

Catch and report error when IBL map fails to load #8303

Merged
merged 1 commit into from
Nov 21, 2019
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
10 changes: 7 additions & 3 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
@@ -4705,9 +4705,13 @@ import ShadowMode from './ShadowMode.js';
if (defined(this._specularEnvironmentMaps)) {
this._specularEnvironmentMapAtlas = new OctahedralProjectedCubeMap(this._specularEnvironmentMaps);
var that = this;
this._specularEnvironmentMapAtlas.readyPromise.then(function() {
that._shouldRegenerateShaders = true;
});
this._specularEnvironmentMapAtlas.readyPromise
.then(function() {
that._shouldRegenerateShaders = true;
})
.otherwise(function(error) {
console.error('Error loading specularEnvironmentMaps: ' + error);
});
}

// Regenerate shaders to not use an environment map. Will be set to true again if there was a new environment map and it is ready.
3 changes: 2 additions & 1 deletion Source/Scene/OctahedralProjectedCubeMap.js
Original file line number Diff line number Diff line change
@@ -233,6 +233,7 @@ import when from '../ThirdParty/when.js';
*/
OctahedralProjectedCubeMap.prototype.update = function(frameState) {
var context = frameState.context;

if (!OctahedralProjectedCubeMap.isSupported(context)) {
return;
}
@@ -262,7 +263,7 @@ import when from '../ThirdParty/when.js';
loadKTX(this._url).then(function(buffers) {
that._cubeMapBuffers = buffers;
that._loading = false;
});
}).otherwise(this._readyPromise.reject);
this._loading = true;
}
if (!defined(this._cubeMapBuffers)) {
27 changes: 26 additions & 1 deletion Specs/Scene/OctahedralProjectedCubeMapSpec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cartesian3 } from '../../Source/Cesium.js';
import { Cartesian3, defined } from '../../Source/Cesium.js';
import { ComputeEngine } from '../../Source/Cesium.js';
import { Pass } from '../../Source/Cesium.js';
import { OctahedralProjectedCubeMap } from '../../Source/Cesium.js';
@@ -190,4 +190,29 @@ describe('Scene/OctahedralProjectedCubeMap', function() {
projection.destroy();
});
});

it('rejects when environment map fails to load.', function() {
if (!OctahedralProjectedCubeMap.isSupported(context)) {
return;
}

var projection = new OctahedralProjectedCubeMap('http://invalid.url');
var frameState = createFrameState(context);
var error;

projection.readyPromise
.then(function() {
fail('Should not resolve.');
})
.otherwise(function(e) {
error = e;
expect(error).toBeDefined();
expect(projection.ready).toEqual(false);
});

return pollToPromise(function() {
projection.update(frameState);
return defined(error);
});
});
}, 'WebGL');