Skip to content

Commit

Permalink
Make a copy of the array of geometry instances before passing to the …
Browse files Browse the repository at this point in the history
…Primitive constructor.

In the batches, the `geometries` is a live reference to the array inside the AssociativeArray owned by the batch. We need to make a copy of the array so that subsequent changes to the batch don't affect the Primitive's view of the instances, which could happen during async creation or combining.
  • Loading branch information
shunter committed Jan 28, 2020
1 parent 5c09a75 commit f006fae
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/DataSources/StaticGeometryColorBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ import Property from './Property.js';
primitive = new Primitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
geometryInstances : geometries.slice(),
appearance : new this.appearanceType({
translucent : this.translucent,
closed : this.closed
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/StaticGeometryPerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import Property from './Property.js';
primitive = new Primitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
geometryInstances : geometries.slice(),
appearance : new this.appearanceType({
material : this.material,
translucent : this.material.isTranslucent(),
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/StaticGroundGeometryColorBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import Property from './Property.js';
primitive = new GroundPrimitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
geometryInstances : geometries.slice(),
classificationType : this.classificationType
});
primitives.add(primitive, this.zIndex);
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/StaticGroundGeometryPerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ import Property from './Property.js';
primitive = new GroundPrimitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
geometryInstances : geometries.slice(),
appearance : new this.appearanceType({
material : this.material
// translucent and closed properties overridden
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/StaticGroundPolylinePerMaterialBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ import Property from './Property.js';
primitive = new GroundPolylinePrimitive({
show : false,
asynchronous : this._asynchronous,
geometryInstances : geometries,
geometryInstances : geometries.slice(),
appearance : new this.appearanceType(),
classificationType : this.classificationType
});
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/StaticOutlineGeometryBatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import Property from './Property.js';
primitive = new Primitive({
show : false,
asynchronous : true,
geometryInstances : geometries,
geometryInstances : geometries.slice(),
appearance : new PerInstanceColorAppearance({
flat : true,
translucent : this.translucent,
Expand Down

0 comments on commit f006fae

Please sign in to comment.