Skip to content

Commit

Permalink
Merge pull request #4165 from AnalyticalGraphicsInc/dynamic-geometrie…
Browse files Browse the repository at this point in the history
…s-on-terrain

Fixed typo when creating GroundPrimitives.
  • Loading branch information
mramato authored Aug 2, 2016
2 parents 9b20bee + 8fa2ff3 commit 2671660
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Source/DataSources/CorridorGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ define([
}

this._primitive = groundPrimitives.add(new GroundPrimitive({
geometryInstance : new GeometryInstance({
geometryInstances : new GeometryInstance({
id : entity,
geometry : new CorridorGeometry(options),
attributes: {
Expand Down
8 changes: 8 additions & 0 deletions Source/DataSources/DataSourceDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/EventHelper',
'../Scene/GroundPrimitive',
'./BillboardVisualizer',
'./BoundingSphereState',
'./BoxGeometryUpdater',
Expand All @@ -33,6 +34,7 @@ define([
destroyObject,
DeveloperError,
EventHelper,
GroundPrimitive,
BillboardVisualizer,
BoundingSphereState,
BoxGeometryUpdater,
Expand Down Expand Up @@ -77,6 +79,8 @@ define([
throw new DeveloperError('dataSourceCollection is required.');
}
//>>includeEnd('debug');

GroundPrimitive.initializeTerrainHeights();

var scene = options.scene;
var dataSourceCollection = options.dataSourceCollection;
Expand Down Expand Up @@ -231,6 +235,10 @@ define([
}
//>>includeEnd('debug');

if (!GroundPrimitive._initialized) {
return false;
}

var result = true;

var i;
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/EllipseGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ define([
}

this._primitive = groundPrimitives.add(new GroundPrimitive({
geometryInstance : new GeometryInstance({
geometryInstances : new GeometryInstance({
id : entity,
geometry : new EllipseGeometry(options),
attributes: {
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/PolygonGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ define([
}

this._primitive = groundPrimitives.add(new GroundPrimitive({
geometryInstance : new GeometryInstance({
geometryInstances : new GeometryInstance({
id : entity,
geometry : new PolygonGeometry(options),
attributes: {
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/RectangleGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ define([
}

this._primitive = groundPrimitives.add(new GroundPrimitive({
geometryInstance : new GeometryInstance({
geometryInstances : new GeometryInstance({
id : entity,
geometry : new RectangleGeometry(options),
attributes: {
Expand Down
33 changes: 33 additions & 0 deletions Specs/DataSources/DataSourceDisplaySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defineSuite([
'DataSources/BoundingSphereState',
'DataSources/DataSourceCollection',
'DataSources/Entity',
'Scene/GroundPrimitive',
'Specs/createScene',
'Specs/MockDataSource'
], function(
Expand All @@ -17,6 +18,7 @@ defineSuite([
BoundingSphereState,
DataSourceCollection,
Entity,
GroundPrimitive,
createScene,
MockDataSource) {
'use strict';
Expand All @@ -27,10 +29,17 @@ defineSuite([
beforeAll(function() {
scene = createScene();
dataSourceCollection = new DataSourceCollection();

return GroundPrimitive.initializeTerrainHeights();
});

afterAll(function() {
scene.destroyForSpecs();

// Leave ground primitive uninitialized
GroundPrimitive._initialized = false;
GroundPrimitive._initPromise = undefined;
GroundPrimitive._terrainHeights = undefined;
});

afterEach(function() {
Expand Down Expand Up @@ -339,4 +348,28 @@ defineSuite([
return display.update();
}).toThrowDeveloperError();
});

it('verify update returns false till terrain heights are initialized', function() {
GroundPrimitive._initialized = false;
GroundPrimitive._initPromise = undefined;
GroundPrimitive._terrainHeights = undefined;

var source1 = new MockDataSource();
var source2 = new MockDataSource();

display = new DataSourceDisplay({
scene : scene,
dataSourceCollection : dataSourceCollection,
visualizersCallback : visualizersCallback
});
dataSourceCollection.add(source1);
dataSourceCollection.add(source2);
display.update(Iso8601.MINIMUM_VALUE);
expect(display.ready).toBe(false);

return GroundPrimitive.initializeTerrainHeights().then(function() {
display.update(Iso8601.MINIMUM_VALUE);
expect(display.ready).toBe(true);
});
});
}, 'WebGL');
9 changes: 9 additions & 0 deletions Specs/DataSources/GeometryVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ defineSuite([
'DataSources/StaticGeometryPerMaterialBatch',
'DataSources/StaticGroundGeometryColorBatch',
'DataSources/StaticOutlineGeometryBatch',
'Scene/GroundPrimitive',
'Specs/createDynamicProperty',
'Specs/createScene',
'Specs/pollToPromise'
Expand All @@ -48,6 +49,7 @@ defineSuite([
StaticGeometryPerMaterialBatch,
StaticGroundGeometryColorBatch,
StaticOutlineGeometryBatch,
GroundPrimitive,
createDynamicProperty,
createScene,
pollToPromise) {
Expand All @@ -58,10 +60,17 @@ defineSuite([
var scene;
beforeAll(function() {
scene = createScene();

return GroundPrimitive.initializeTerrainHeights();
});

afterAll(function() {
scene.destroyForSpecs();

// Leave ground primitive uninitialized
GroundPrimitive._initialized = false;
GroundPrimitive._initPromise = undefined;
GroundPrimitive._terrainHeights = undefined;
});

it('Can create and destroy', function() {
Expand Down
11 changes: 7 additions & 4 deletions Specs/Scene/GroundPrimitiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,23 @@ defineSuite([
var primitive;
var depthPrimitive;

beforeAll(function(done) {
beforeAll(function() {
scene = createScene();
scene.fxaa = false;

context = scene.context;

ellipsoid = Ellipsoid.WGS84;
GroundPrimitive.initializeTerrainHeights().then(function() {
done();
});
return GroundPrimitive.initializeTerrainHeights();
});

afterAll(function() {
scene.destroyForSpecs();

// Leave ground primitive uninitialized
GroundPrimitive._initialized = false;
GroundPrimitive._initPromise = undefined;
GroundPrimitive._terrainHeights = undefined;
});

function MockGlobePrimitive(primitive) {
Expand Down

0 comments on commit 2671660

Please # to comment.