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

Workaround for undefined geometric error #5574

Merged
merged 1 commit into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ define([
this.geometricError = header.geometricError;

if (!defined(this.geometricError)) {
throw new RuntimeError('geometricError must be defined');
this.geometricError = defined(parent) ? parent.geometricError : tileset._geometricError;
Cesium3DTile._deprecationWarning('geometricErrorUndefined', 'Required property geometricError is undefined for this tile. Using parent\'s geometric error instead.');
}

var refine;
Expand Down
47 changes: 29 additions & 18 deletions Specs/Scene/Cesium3DTileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ defineSuite([
var mockTileset = {
debugShowBoundingVolume : true,
debugShowViewerRequestVolume : true,
modelMatrix : Matrix4.IDENTITY
modelMatrix : Matrix4.IDENTITY,
_geometricError : 2
};

var centerLongitude = -1.31968;
Expand All @@ -141,14 +142,6 @@ defineSuite([
expect(tile.isDestroyed()).toEqual(true);
});

it('throws if geometricError is undefined', function() {
var tileWithoutGeometricError = clone(tileWithBoundingSphere, true);
delete tileWithoutGeometricError.geometricError;
expect(function() {
return new Cesium3DTile(mockTileset, '/some_url', tileWithoutGeometricError, undefined);
}).toThrowRuntimeError();
});

it('throws if boundingVolume is undefined', function() {
var tileWithoutBoundingVolume = clone(tileWithBoundingSphere, true);
delete tileWithoutBoundingVolume.boundingVolume;
Expand All @@ -165,6 +158,33 @@ defineSuite([
}).toThrowRuntimeError();
});

it('logs deprecation warning if refine is lowercase', function() {
spyOn(Cesium3DTile, '_deprecationWarning');
var header = clone(tileWithBoundingSphere, true);
header.refine = 'replace';
var tile = new Cesium3DTile(mockTileset, '/some_url', header, undefined);
expect(tile.refine).toBe(Cesium3DTileRefine.REPLACE);
expect(Cesium3DTile._deprecationWarning).toHaveBeenCalled();
});

it('logs deprecation warning if geometric error is undefined', function() {
spyOn(Cesium3DTile, '_deprecationWarning');

var geometricErrorMissing = clone(tileWithBoundingSphere, true);
delete geometricErrorMissing.geometricError;

var parent = new Cesium3DTile(mockTileset, '/some_url', tileWithBoundingSphere, undefined);
var child = new Cesium3DTile(mockTileset, '/some_url', geometricErrorMissing, parent);
expect(child.geometricError).toBe(parent.geometricError);
expect(child.geometricError).toBe(1);

var tile = new Cesium3DTile(mockTileset, '/some_url', geometricErrorMissing, undefined);
expect(tile.geometricError).toBe(mockTileset._geometricError);
expect(tile.geometricError).toBe(2);

expect(Cesium3DTile._deprecationWarning.calls.count()).toBe(2);
});

describe('bounding volumes', function() {
it('can have a bounding sphere', function() {
var tile = new Cesium3DTile(mockTileset, '/some_url', tileWithBoundingSphere, undefined);
Expand Down Expand Up @@ -297,15 +317,6 @@ defineSuite([
var newCenter = Cartesian3.fromRadians(newLongitude, newLatitude);
expect(boundingSphere.center).toEqualEpsilon(newCenter, CesiumMath.EPSILON7);
});

it('logs deprecation warning if refine is lowercase', function() {
spyOn(Cesium3DTile, '_deprecationWarning');
var header = clone(tileWithBoundingSphere, true);
header.refine = 'replace';
var tile = new Cesium3DTile(mockTileset, '/some_url', header, undefined);
expect(tile.refine).toBe(Cesium3DTileRefine.REPLACE);
expect(Cesium3DTile._deprecationWarning).toHaveBeenCalled();
});
});

describe('debug bounding volumes', function() {
Expand Down