Skip to content

Commit 58ef208

Browse files
authored
Merge pull request #6815 from AnalyticalGraphicsInc/fix-entity-scratch-variables
Don't overwrite scratch variables in entity visualizers
2 parents 40ba971 + 5518a72 commit 58ef208

File tree

4 files changed

+61
-59
lines changed

4 files changed

+61
-59
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Change Log
2323
* Fixed an issue where glTF 2.0 models sometimes wouldn't be centered in the view after putting the camera on them. [#6784](https://github.com/AnalyticalGraphicsInc/cesium/issues/6784)
2424
* Fixed a bug that caused eye dome lighting for point clouds to fail in Safari on macOS and Edge on Windows by removing the dependency on floating point color textures. [#6792](https://github.com/AnalyticalGraphicsInc/cesium/issues/6792)
2525
* Fixed a bug that caused polylines on terrain to render incorrectly in 2D and Columbus View with a `WebMercatorProjection`. [#6809](https://github.com/AnalyticalGraphicsInc/cesium/issues/6809)
26+
* Fixed a bug that caused billboard positions to be set incorrectly when using a `CallbackProperty`. [#6815](https://github.com/AnalyticalGraphicsInc/cesium/pull/6815)
2627

2728
### 1.47 - 2018-07-02
2829

Source/DataSources/BillboardVisualizer.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ define([
4444
var defaultSizeInMeters = false;
4545
var defaultDisableDepthTestDistance = 0.0;
4646

47-
var position = new Cartesian3();
48-
var color = new Color();
49-
var eyeOffset = new Cartesian3();
50-
var pixelOffset = new Cartesian2();
51-
var scaleByDistance = new NearFarScalar();
52-
var translucencyByDistance = new NearFarScalar();
53-
var pixelOffsetScaleByDistance = new NearFarScalar();
54-
var boundingRectangle = new BoundingRectangle();
55-
var distanceDisplayCondition = new DistanceDisplayCondition();
47+
var positionScratch = new Cartesian3();
48+
var colorScratch = new Color();
49+
var eyeOffsetScratch = new Cartesian3();
50+
var pixelOffsetScratch = new Cartesian2();
51+
var scaleByDistanceScratch = new NearFarScalar();
52+
var translucencyByDistanceScratch = new NearFarScalar();
53+
var pixelOffsetScaleByDistanceScratch = new NearFarScalar();
54+
var boundingRectangleScratch = new BoundingRectangle();
55+
var distanceDisplayConditionScratch = new DistanceDisplayCondition();
5656

5757
function EntityData(entity) {
5858
this.entity = entity;
@@ -110,9 +110,9 @@ define([
110110
var textureValue;
111111
var billboard = item.billboard;
112112
var show = entity.isShowing && entity.isAvailable(time) && Property.getValueOrDefault(billboardGraphics._show, time, true);
113-
113+
var position;
114114
if (show) {
115-
position = Property.getValueOrUndefined(entity._position, time, position);
115+
position = Property.getValueOrUndefined(entity._position, time, positionScratch);
116116
textureValue = Property.getValueOrUndefined(billboardGraphics._image, time);
117117
show = defined(position) && defined(textureValue);
118118
}
@@ -140,25 +140,25 @@ define([
140140
item.textureValue = textureValue;
141141
}
142142
billboard.position = position;
143-
billboard.color = Property.getValueOrDefault(billboardGraphics._color, time, defaultColor, color);
144-
billboard.eyeOffset = Property.getValueOrDefault(billboardGraphics._eyeOffset, time, defaultEyeOffset, eyeOffset);
143+
billboard.color = Property.getValueOrDefault(billboardGraphics._color, time, defaultColor, colorScratch);
144+
billboard.eyeOffset = Property.getValueOrDefault(billboardGraphics._eyeOffset, time, defaultEyeOffset, eyeOffsetScratch);
145145
billboard.heightReference = Property.getValueOrDefault(billboardGraphics._heightReference, time, defaultHeightReference);
146-
billboard.pixelOffset = Property.getValueOrDefault(billboardGraphics._pixelOffset, time, defaultPixelOffset, pixelOffset);
146+
billboard.pixelOffset = Property.getValueOrDefault(billboardGraphics._pixelOffset, time, defaultPixelOffset, pixelOffsetScratch);
147147
billboard.scale = Property.getValueOrDefault(billboardGraphics._scale, time, defaultScale);
148148
billboard.rotation = Property.getValueOrDefault(billboardGraphics._rotation, time, defaultRotation);
149149
billboard.alignedAxis = Property.getValueOrDefault(billboardGraphics._alignedAxis, time, defaultAlignedAxis);
150150
billboard.horizontalOrigin = Property.getValueOrDefault(billboardGraphics._horizontalOrigin, time, defaultHorizontalOrigin);
151151
billboard.verticalOrigin = Property.getValueOrDefault(billboardGraphics._verticalOrigin, time, defaultVerticalOrigin);
152152
billboard.width = Property.getValueOrUndefined(billboardGraphics._width, time);
153153
billboard.height = Property.getValueOrUndefined(billboardGraphics._height, time);
154-
billboard.scaleByDistance = Property.getValueOrUndefined(billboardGraphics._scaleByDistance, time, scaleByDistance);
155-
billboard.translucencyByDistance = Property.getValueOrUndefined(billboardGraphics._translucencyByDistance, time, translucencyByDistance);
156-
billboard.pixelOffsetScaleByDistance = Property.getValueOrUndefined(billboardGraphics._pixelOffsetScaleByDistance, time, pixelOffsetScaleByDistance);
154+
billboard.scaleByDistance = Property.getValueOrUndefined(billboardGraphics._scaleByDistance, time, scaleByDistanceScratch);
155+
billboard.translucencyByDistance = Property.getValueOrUndefined(billboardGraphics._translucencyByDistance, time, translucencyByDistanceScratch);
156+
billboard.pixelOffsetScaleByDistance = Property.getValueOrUndefined(billboardGraphics._pixelOffsetScaleByDistance, time, pixelOffsetScaleByDistanceScratch);
157157
billboard.sizeInMeters = Property.getValueOrDefault(billboardGraphics._sizeInMeters, time, defaultSizeInMeters);
158-
billboard.distanceDisplayCondition = Property.getValueOrUndefined(billboardGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
158+
billboard.distanceDisplayCondition = Property.getValueOrUndefined(billboardGraphics._distanceDisplayCondition, time, distanceDisplayConditionScratch);
159159
billboard.disableDepthTestDistance = Property.getValueOrDefault(billboardGraphics._disableDepthTestDistance, time, defaultDisableDepthTestDistance);
160160

161-
var subRegion = Property.getValueOrUndefined(billboardGraphics._imageSubRegion, time, boundingRectangle);
161+
var subRegion = Property.getValueOrUndefined(billboardGraphics._imageSubRegion, time, boundingRectangleScratch);
162162
if (defined(subRegion)) {
163163
billboard.setImageSubRegion(billboard._imageId, subRegion);
164164
}

Source/DataSources/LabelVisualizer.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ define([
5050
var defaultVerticalOrigin = VerticalOrigin.CENTER;
5151
var defaultDisableDepthTestDistance = 0.0;
5252

53-
var position = new Cartesian3();
54-
var fillColor = new Color();
55-
var outlineColor = new Color();
56-
var backgroundColor = new Color();
57-
var backgroundPadding = new Cartesian2();
58-
var eyeOffset = new Cartesian3();
59-
var pixelOffset = new Cartesian2();
60-
var translucencyByDistance = new NearFarScalar();
61-
var pixelOffsetScaleByDistance = new NearFarScalar();
62-
var scaleByDistance = new NearFarScalar();
63-
var distanceDisplayCondition = new DistanceDisplayCondition();
53+
var positionScratch = new Cartesian3();
54+
var fillColorScratch = new Color();
55+
var outlineColorScratch = new Color();
56+
var backgroundColorScratch = new Color();
57+
var backgroundPaddingScratch = new Cartesian2();
58+
var eyeOffsetScratch = new Cartesian3();
59+
var pixelOffsetScratch = new Cartesian2();
60+
var translucencyByDistanceScratch = new NearFarScalar();
61+
var pixelOffsetScaleByDistanceScratch = new NearFarScalar();
62+
var scaleByDistanceScratch = new NearFarScalar();
63+
var distanceDisplayConditionScratch = new DistanceDisplayCondition();
6464

6565
function EntityData(entity) {
6666
this.entity = entity;
@@ -120,9 +120,9 @@ define([
120120
var text;
121121
var label = item.label;
122122
var show = entity.isShowing && entity.isAvailable(time) && Property.getValueOrDefault(labelGraphics._show, time, true);
123-
123+
var position;
124124
if (show) {
125-
position = Property.getValueOrUndefined(entity._position, time, position);
125+
position = Property.getValueOrUndefined(entity._position, time, positionScratch);
126126
text = Property.getValueOrUndefined(labelGraphics._text, time);
127127
show = defined(position) && defined(text);
128128
}
@@ -149,21 +149,21 @@ define([
149149
label.scale = Property.getValueOrDefault(labelGraphics._scale, time, defaultScale);
150150
label.font = Property.getValueOrDefault(labelGraphics._font, time, defaultFont);
151151
label.style = Property.getValueOrDefault(labelGraphics._style, time, defaultStyle);
152-
label.fillColor = Property.getValueOrDefault(labelGraphics._fillColor, time, defaultFillColor, fillColor);
153-
label.outlineColor = Property.getValueOrDefault(labelGraphics._outlineColor, time, defaultOutlineColor, outlineColor);
152+
label.fillColor = Property.getValueOrDefault(labelGraphics._fillColor, time, defaultFillColor, fillColorScratch);
153+
label.outlineColor = Property.getValueOrDefault(labelGraphics._outlineColor, time, defaultOutlineColor, outlineColorScratch);
154154
label.outlineWidth = Property.getValueOrDefault(labelGraphics._outlineWidth, time, defaultOutlineWidth);
155155
label.showBackground = Property.getValueOrDefault(labelGraphics._showBackground, time, defaultShowBackground);
156-
label.backgroundColor = Property.getValueOrDefault(labelGraphics._backgroundColor, time, defaultBackgroundColor, backgroundColor);
157-
label.backgroundPadding = Property.getValueOrDefault(labelGraphics._backgroundPadding, time, defaultBackgroundPadding, backgroundPadding);
158-
label.pixelOffset = Property.getValueOrDefault(labelGraphics._pixelOffset, time, defaultPixelOffset, pixelOffset);
159-
label.eyeOffset = Property.getValueOrDefault(labelGraphics._eyeOffset, time, defaultEyeOffset, eyeOffset);
156+
label.backgroundColor = Property.getValueOrDefault(labelGraphics._backgroundColor, time, defaultBackgroundColor, backgroundColorScratch);
157+
label.backgroundPadding = Property.getValueOrDefault(labelGraphics._backgroundPadding, time, defaultBackgroundPadding, backgroundPaddingScratch);
158+
label.pixelOffset = Property.getValueOrDefault(labelGraphics._pixelOffset, time, defaultPixelOffset, pixelOffsetScratch);
159+
label.eyeOffset = Property.getValueOrDefault(labelGraphics._eyeOffset, time, defaultEyeOffset, eyeOffsetScratch);
160160
label.heightReference = Property.getValueOrDefault(labelGraphics._heightReference, time, defaultHeightReference);
161161
label.horizontalOrigin = Property.getValueOrDefault(labelGraphics._horizontalOrigin, time, defaultHorizontalOrigin);
162162
label.verticalOrigin = Property.getValueOrDefault(labelGraphics._verticalOrigin, time, defaultVerticalOrigin);
163-
label.translucencyByDistance = Property.getValueOrUndefined(labelGraphics._translucencyByDistance, time, translucencyByDistance);
164-
label.pixelOffsetScaleByDistance = Property.getValueOrUndefined(labelGraphics._pixelOffsetScaleByDistance, time, pixelOffsetScaleByDistance);
165-
label.scaleByDistance = Property.getValueOrUndefined(labelGraphics._scaleByDistance, time, scaleByDistance);
166-
label.distanceDisplayCondition = Property.getValueOrUndefined(labelGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
163+
label.translucencyByDistance = Property.getValueOrUndefined(labelGraphics._translucencyByDistance, time, translucencyByDistanceScratch);
164+
label.pixelOffsetScaleByDistance = Property.getValueOrUndefined(labelGraphics._pixelOffsetScaleByDistance, time, pixelOffsetScaleByDistanceScratch);
165+
label.scaleByDistance = Property.getValueOrUndefined(labelGraphics._scaleByDistance, time, scaleByDistanceScratch);
166+
label.distanceDisplayCondition = Property.getValueOrUndefined(labelGraphics._distanceDisplayCondition, time, distanceDisplayConditionScratch);
167167
label.disableDepthTestDistance = Property.getValueOrDefault(labelGraphics._disableDepthTestDistance, time, defaultDisableDepthTestDistance);
168168
}
169169
return true;

Source/DataSources/PointVisualizer.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ define([
3232
var defaultPixelSize = 1.0;
3333
var defaultDisableDepthTestDistance = 0.0;
3434

35-
var color = new Color();
36-
var position = new Cartesian3();
37-
var outlineColor = new Color();
38-
var scaleByDistance = new NearFarScalar();
39-
var translucencyByDistance = new NearFarScalar();
40-
var distanceDisplayCondition = new DistanceDisplayCondition();
35+
var colorScratch = new Color();
36+
var positionScratch = new Cartesian3();
37+
var outlineColorScratch = new Color();
38+
var scaleByDistanceScratch = new NearFarScalar();
39+
var translucencyByDistanceScratch = new NearFarScalar();
40+
var distanceDisplayConditionScratch = new DistanceDisplayCondition();
4141

4242
function EntityData(entity) {
4343
this.entity = entity;
@@ -99,8 +99,9 @@ define([
9999
var billboard = item.billboard;
100100
var heightReference = Property.getValueOrDefault(pointGraphics._heightReference, time, HeightReference.NONE);
101101
var show = entity.isShowing && entity.isAvailable(time) && Property.getValueOrDefault(pointGraphics._show, time, true);
102+
var position;
102103
if (show) {
103-
position = Property.getValueOrUndefined(entity._position, time, position);
104+
position = Property.getValueOrUndefined(entity._position, time, positionScratch);
104105
show = defined(position);
105106
}
106107
if (!show) {
@@ -138,25 +139,25 @@ define([
138139
if (defined(pointPrimitive)) {
139140
pointPrimitive.show = true;
140141
pointPrimitive.position = position;
141-
pointPrimitive.scaleByDistance = Property.getValueOrUndefined(pointGraphics._scaleByDistance, time, scaleByDistance);
142-
pointPrimitive.translucencyByDistance = Property.getValueOrUndefined(pointGraphics._translucencyByDistance, time, translucencyByDistance);
143-
pointPrimitive.color = Property.getValueOrDefault(pointGraphics._color, time, defaultColor, color);
144-
pointPrimitive.outlineColor = Property.getValueOrDefault(pointGraphics._outlineColor, time, defaultOutlineColor, outlineColor);
142+
pointPrimitive.scaleByDistance = Property.getValueOrUndefined(pointGraphics._scaleByDistance, time, scaleByDistanceScratch);
143+
pointPrimitive.translucencyByDistance = Property.getValueOrUndefined(pointGraphics._translucencyByDistance, time, translucencyByDistanceScratch);
144+
pointPrimitive.color = Property.getValueOrDefault(pointGraphics._color, time, defaultColor, colorScratch);
145+
pointPrimitive.outlineColor = Property.getValueOrDefault(pointGraphics._outlineColor, time, defaultOutlineColor, outlineColorScratch);
145146
pointPrimitive.outlineWidth = Property.getValueOrDefault(pointGraphics._outlineWidth, time, defaultOutlineWidth);
146147
pointPrimitive.pixelSize = Property.getValueOrDefault(pointGraphics._pixelSize, time, defaultPixelSize);
147-
pointPrimitive.distanceDisplayCondition = Property.getValueOrUndefined(pointGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
148+
pointPrimitive.distanceDisplayCondition = Property.getValueOrUndefined(pointGraphics._distanceDisplayCondition, time, distanceDisplayConditionScratch);
148149
pointPrimitive.disableDepthTestDistance = Property.getValueOrDefault(pointGraphics._disableDepthTestDistance, time, defaultDisableDepthTestDistance);
149150
} else if (defined(billboard)) {
150151
billboard.show = true;
151152
billboard.position = position;
152-
billboard.scaleByDistance = Property.getValueOrUndefined(pointGraphics._scaleByDistance, time, scaleByDistance);
153-
billboard.translucencyByDistance = Property.getValueOrUndefined(pointGraphics._translucencyByDistance, time, translucencyByDistance);
154-
billboard.distanceDisplayCondition = Property.getValueOrUndefined(pointGraphics._distanceDisplayCondition, time, distanceDisplayCondition);
153+
billboard.scaleByDistance = Property.getValueOrUndefined(pointGraphics._scaleByDistance, time, scaleByDistanceScratch);
154+
billboard.translucencyByDistance = Property.getValueOrUndefined(pointGraphics._translucencyByDistance, time, translucencyByDistanceScratch);
155+
billboard.distanceDisplayCondition = Property.getValueOrUndefined(pointGraphics._distanceDisplayCondition, time, distanceDisplayConditionScratch);
155156
billboard.disableDepthTestDistance = Property.getValueOrDefault(pointGraphics._disableDepthTestDistance, time, defaultDisableDepthTestDistance);
156157
billboard.heightReference = heightReference;
157158

158-
var newColor = Property.getValueOrDefault(pointGraphics._color, time, defaultColor, color);
159-
var newOutlineColor = Property.getValueOrDefault(pointGraphics._outlineColor, time, defaultOutlineColor, outlineColor);
159+
var newColor = Property.getValueOrDefault(pointGraphics._color, time, defaultColor, colorScratch);
160+
var newOutlineColor = Property.getValueOrDefault(pointGraphics._outlineColor, time, defaultOutlineColor, outlineColorScratch);
160161
var newOutlineWidth = Math.round(Property.getValueOrDefault(pointGraphics._outlineWidth, time, defaultOutlineWidth));
161162
var newPixelSize = Math.max(1, Math.round(Property.getValueOrDefault(pointGraphics._pixelSize, time, defaultPixelSize)));
162163

0 commit comments

Comments
 (0)