Skip to content

Commit 9fd6edc

Browse files
author
hpinkos
committed
specs
1 parent 620e7f1 commit 9fd6edc

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Specs/DataSources/StaticGroundPolylinePerMaterialBatchSpec.js

+48
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,54 @@ defineSuite([
122122
});
123123
});
124124

125+
it('updates color attribute after rebuilding geometry primitive', function() {
126+
if (!GroundPolylinePrimitive.isSupported(scene)) {
127+
// Don't fail if GroundPolylinePrimitive is not supported
128+
return;
129+
}
130+
131+
var polyline = createGroundPolyline();
132+
polyline.material = Color.RED;
133+
var entity = new Entity({
134+
availability: new TimeIntervalCollection([TimeInterval.fromIso8601({iso8601: '2018-02-14T04:00:00+1100/2018-02-14T04:30:00+1100'})]),
135+
polyline: polyline
136+
});
137+
138+
var batch = new StaticGroundPolylinePerMaterialBatch(scene.groundPrimitives);
139+
140+
var updater = new PolylineGeometryUpdater(entity, scene);
141+
batch.add(time, updater);
142+
143+
return pollToPromise(function() {
144+
scene.initializeFrame();
145+
var isUpdated = batch.update(time);
146+
scene.render(time);
147+
return isUpdated;
148+
}).then(function() {
149+
expect(scene.groundPrimitives.length).toEqual(1);
150+
var primitive = scene.groundPrimitives.get(0);
151+
var attributes = primitive.getGeometryInstanceAttributes(entity);
152+
expect(attributes.color).toEqual([255, 0, 0, 255]);
153+
154+
entity.polyline.material = Color.GREEN;
155+
updater._onEntityPropertyChanged(entity, 'polyline');
156+
batch.remove(updater);
157+
batch.add(time, updater);
158+
return pollToPromise(function() {
159+
scene.initializeFrame();
160+
var isUpdated = batch.update(time);
161+
scene.render(time);
162+
return isUpdated;
163+
}).then(function() {
164+
expect(scene.groundPrimitives.length).toEqual(1);
165+
var primitive = scene.groundPrimitives.get(0);
166+
var attributes = primitive.getGeometryInstanceAttributes(entity);
167+
expect(attributes.color).toEqual([0, 128, 0, 255]);
168+
batch.removeAllPrimitives();
169+
});
170+
});
171+
});
172+
125173
it('updates with sampled distance display condition out of range', function() {
126174
if (!GroundPolylinePrimitive.isSupported(scene)) {
127175
// Don't fail if GroundPolylinePrimitive is not supported

0 commit comments

Comments
 (0)