Skip to content

Commit

Permalink
specs
Browse files Browse the repository at this point in the history
  • Loading branch information
hpinkos committed Oct 18, 2018
1 parent f1f051f commit 9c8fcc5
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Specs/DataSources/StaticGeometryPerMaterialBatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defineSuite([
'Core/Math',
'Core/TimeInterval',
'Core/TimeIntervalCollection',
'DataSources/BoxGeometryUpdater',
'DataSources/CheckerboardMaterialProperty',
'DataSources/ColorMaterialProperty',
'DataSources/ConstantPositionProperty',
'DataSources/ConstantProperty',
Expand All @@ -18,6 +20,7 @@ defineSuite([
'DataSources/PolylineArrowMaterialProperty',
'DataSources/PolylineGeometryUpdater',
'DataSources/PolylineGraphics',
'DataSources/StripeMaterialProperty',
'DataSources/TimeIntervalCollectionProperty',
'Scene/MaterialAppearance',
'Scene/PolylineColorAppearance',
Expand All @@ -35,6 +38,8 @@ defineSuite([
CesiumMath,
TimeInterval,
TimeIntervalCollection,
BoxGeometryUpdater,
CheckerboardMaterialProeprty,
ColorMaterialProperty,
ConstantPositionProperty,
ConstantProperty,
Expand All @@ -45,6 +50,7 @@ defineSuite([
PolylineArrowMaterialProperty,
PolylineGeometryUpdater,
PolylineGraphics,
StripeMaterialProperty,
TimeIntervalCollectionProperty,
MaterialAppearance,
PolylineColorAppearance,
Expand Down Expand Up @@ -312,4 +318,64 @@ defineSuite([
batch.removeAllPrimitives();
});
});

it('removes all updaters', function() {
var batch = new StaticGeometryPerMaterialBatch(scene.primitives, MaterialAppearance, undefined, false, ShadowMode.DISABLED);

function buildEntity(MaterialProperty) {
var material = new MaterialProperty({
evenColor : Color.YELLOW,
oddColor: Color.BLUE
});

return new Entity({
position : new Cartesian3(1234, 5678, 9101112),
ellipse : {
semiMajorAxis : 2,
semiMinorAxis : 1,
height : 0,
material: material
}
});
}

function renderScene() {
scene.initializeFrame();
var isUpdated = batch.update(time);
scene.render(time);
return isUpdated;
}

var entity1 = buildEntity(StripeMaterialProperty);
var entity2 = buildEntity(CheckerboardMaterialProeprty);
var entity3 = buildEntity(StripeMaterialProperty);
var entity4 = buildEntity(CheckerboardMaterialProeprty);

var updater1 = new EllipseGeometryUpdater(entity1, scene);
var updater2 = new EllipseGeometryUpdater(entity2, scene);
var updater3 = new EllipseGeometryUpdater(entity3, scene);
var updater4 = new EllipseGeometryUpdater(entity4, scene);
var emptyUpdater = new BoxGeometryUpdater(entity1, scene);

batch.add(time, updater1);
batch.add(time, updater2);
batch.add(time, updater3);
batch.add(time, updater4);
return pollToPromise(renderScene)
.then(function() {
expect(scene.primitives.length).toEqual(2);
})
.then(function() {
batch.remove(updater1);
batch.remove(updater2);
batch.remove(emptyUpdater);
batch.remove(updater3);
batch.remove(updater4);
return pollToPromise(renderScene);
})
.then(function() {
expect(scene.primitives.length).toEqual(0);
batch.removeAllPrimitives();
});
});
});

0 comments on commit 9c8fcc5

Please sign in to comment.