cesium 0.21 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/Assets/Textures/moonSmall.jpg +0 -0
  3. data/app/assets/javascripts/Cesium.js +10 -1
  4. data/app/assets/javascripts/Core/Cartesian2.js +28 -0
  5. data/app/assets/javascripts/Core/Cartesian3.js +28 -0
  6. data/app/assets/javascripts/Core/Cartesian4.js +28 -0
  7. data/app/assets/javascripts/Core/CatmullRomSpline.js +3 -3
  8. data/app/assets/javascripts/Core/Clock.js +7 -7
  9. data/app/assets/javascripts/Core/Color.js +1 -1
  10. data/app/assets/javascripts/Core/ComponentDatatype.js +11 -7
  11. data/app/assets/javascripts/Core/CorridorGeometryLibrary.js +23 -29
  12. data/app/assets/javascripts/Core/Ellipsoid.js +6 -0
  13. data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +5 -4
  14. data/app/assets/javascripts/Core/Event.js +2 -1
  15. data/app/assets/javascripts/Core/ExtentGeometry.js +1 -1
  16. data/app/assets/javascripts/Core/ExtentOutlineGeometry.js +1 -1
  17. data/app/assets/javascripts/Core/GeometryAttributes.js +1 -1
  18. data/app/assets/javascripts/Core/GeometryInstance.js +2 -2
  19. data/app/assets/javascripts/Core/GeometryPipeline.js +10 -7
  20. data/app/assets/javascripts/Core/HermiteSpline.js +1 -1
  21. data/app/assets/javascripts/Core/Iau2000Orientation.js +132 -0
  22. data/app/assets/javascripts/Core/IauOrientationAxes.js +98 -0
  23. data/app/assets/javascripts/Core/IauOrientationParameters.js +48 -0
  24. data/app/assets/javascripts/Core/IntersectionTests.js +5 -5
  25. data/app/assets/javascripts/Core/JulianDate.js +27 -5
  26. data/app/assets/javascripts/Core/Math.js +9 -0
  27. data/app/assets/javascripts/Core/Matrix2.js +1 -142
  28. data/app/assets/javascripts/Core/Matrix3.js +168 -153
  29. data/app/assets/javascripts/Core/Matrix4.js +0 -249
  30. data/app/assets/javascripts/Core/NearFarScalar.js +13 -0
  31. data/app/assets/javascripts/Core/PolygonGeometry.js +1 -1
  32. data/app/assets/javascripts/Core/PolygonOutlineGeometry.js +2 -2
  33. data/app/assets/javascripts/Core/PolygonPipeline.js +2 -2
  34. data/app/assets/javascripts/Core/PolylinePipeline.js +7 -3
  35. data/app/assets/javascripts/Core/PolylineVolumeGeometry.js +239 -0
  36. data/app/assets/javascripts/Core/PolylineVolumeGeometryLibrary.js +404 -0
  37. data/app/assets/javascripts/Core/PolylineVolumeOutlineGeometry.js +154 -0
  38. data/app/assets/javascripts/Core/Quaternion.js +37 -10
  39. data/app/assets/javascripts/Core/Shapes.js +26 -2
  40. data/app/assets/javascripts/Core/Simon1994PlanetaryPositions.js +3 -3
  41. data/app/assets/javascripts/Core/TimeInterval.js +28 -17
  42. data/app/assets/javascripts/Core/TimeIntervalCollection.js +30 -0
  43. data/app/assets/javascripts/Core/Transforms.js +5 -5
  44. data/app/assets/javascripts/Core/WallGeometryLibrary.js +2 -2
  45. data/app/assets/javascripts/Core/getFilenameFromUri.js +37 -0
  46. data/app/assets/javascripts/DynamicScene/ColorMaterialProperty.js +2 -2
  47. data/app/assets/javascripts/DynamicScene/CzmlDataSource.js +96 -18
  48. data/app/assets/javascripts/DynamicScene/DataSource.js +8 -0
  49. data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +15 -3
  50. data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +6 -1
  51. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +1 -1
  52. data/app/assets/javascripts/DynamicScene/DynamicLabel.js +12 -1
  53. data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +5 -0
  54. data/app/assets/javascripts/DynamicScene/DynamicObject.js +44 -17
  55. data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +3 -3
  56. data/app/assets/javascripts/DynamicScene/DynamicPoint.js +12 -1
  57. data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +11 -2
  58. data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +10 -30
  59. data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +5 -20
  60. data/app/assets/javascripts/DynamicScene/GeoJsonDataSource.js +26 -8
  61. data/app/assets/javascripts/DynamicScene/GridMaterialProperty.js +2 -2
  62. data/app/assets/javascripts/DynamicScene/ImageMaterialProperty.js +2 -2
  63. data/app/assets/javascripts/DynamicScene/PolylineOutlineMaterialProperty.js +66 -0
  64. data/app/assets/javascripts/DynamicScene/PositionProperty.js +3 -3
  65. data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +1 -1
  66. data/app/assets/javascripts/DynamicScene/SampledProperty.js +14 -8
  67. data/app/assets/javascripts/Renderer/AutomaticUniforms.js +4 -3
  68. data/app/assets/javascripts/Renderer/Context.js +16 -2
  69. data/app/assets/javascripts/Renderer/UniformState.js +14 -14
  70. data/app/assets/javascripts/Scene/Billboard.js +102 -26
  71. data/app/assets/javascripts/Scene/BillboardCollection.js +69 -16
  72. data/app/assets/javascripts/Scene/Camera.js +7 -7
  73. data/app/assets/javascripts/Scene/CameraController.js +23 -12
  74. data/app/assets/javascripts/Scene/CameraFlightPath.js +11 -11
  75. data/app/assets/javascripts/Scene/CentralBodySurface.js +1 -1
  76. data/app/assets/javascripts/Scene/CustomSensorVolume.js +17 -2
  77. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +79 -24
  78. data/app/assets/javascripts/Scene/ExtentPrimitive.js +17 -1
  79. data/app/assets/javascripts/Scene/Label.js +94 -18
  80. data/app/assets/javascripts/Scene/LabelCollection.js +6 -2
  81. data/app/assets/javascripts/Scene/Moon.js +150 -0
  82. data/app/assets/javascripts/Scene/Polygon.js +18 -1
  83. data/app/assets/javascripts/Scene/Polyline.js +32 -13
  84. data/app/assets/javascripts/Scene/PolylineCollection.js +7 -6
  85. data/app/assets/javascripts/Scene/Primitive.js +2 -2
  86. data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +12 -0
  87. data/app/assets/javascripts/Scene/Scene.js +122 -14
  88. data/app/assets/javascripts/Scene/SceneTransforms.js +2 -2
  89. data/app/assets/javascripts/Scene/SceneTransitioner.js +4 -4
  90. data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1 -1
  91. data/app/assets/javascripts/Scene/SkyBox.js +53 -48
  92. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +2 -2
  93. data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +36 -14
  94. data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +27 -9
  95. data/app/assets/javascripts/Shaders/Builtin/Functions/phong.glsl +13 -0
  96. data/app/assets/javascripts/Shaders/Builtin/Functions/phong.js +10 -0
  97. data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +24 -0
  98. data/app/assets/javascripts/Shaders/EllipsoidFS.js +21 -1
  99. data/app/assets/javascripts/Widgets/CesiumWidget/CesiumWidget.js +30 -9
  100. data/app/assets/javascripts/Widgets/HomeButton/HomeButtonViewModel.js +6 -5
  101. data/app/assets/javascripts/Widgets/Viewer/Viewer.js +13 -0
  102. data/app/assets/javascripts/Widgets/Viewer/viewerDynamicObjectMixin.js +46 -4
  103. data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +16 -8
  104. data/app/assets/javascripts/Workers/createPolylineVolumeGeometry.js +23 -0
  105. data/app/assets/javascripts/Workers/createPolylineVolumeOutlineGeometry.js +23 -0
  106. data/lib/cesium/version.rb +1 -1
  107. metadata +15 -5
  108. data/test/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,404 @@
1
+ /*global define*/
2
+ define(['Core/defined', 'Core/Cartesian2', 'Core/Cartesian3', 'Core/Cartesian4', 'Core/Cartographic', 'Core/CornerType', 'Core/DeveloperError', 'Core/EllipsoidTangentPlane', 'Core/PolylinePipeline', 'Core/Matrix3', 'Core/Matrix4', 'Core/Quaternion', 'Core/Transforms', 'Core/Math'], function(
3
+ defined,
4
+ Cartesian2,
5
+ Cartesian3,
6
+ Cartesian4,
7
+ Cartographic,
8
+ CornerType,
9
+ DeveloperError,
10
+ EllipsoidTangentPlane,
11
+ PolylinePipeline,
12
+ Matrix3,
13
+ Matrix4,
14
+ Quaternion,
15
+ Transforms,
16
+ CesiumMath) {
17
+ "use strict";
18
+
19
+ var scratch2Array = [new Cartesian3(), new Cartesian3()];
20
+ var scratchCartesian1 = new Cartesian3();
21
+ var scratchCartesian2 = new Cartesian3();
22
+ var scratchCartesian3 = new Cartesian3();
23
+ var scratchCartesian4 = new Cartesian3();
24
+ var scratchCartesian5 = new Cartesian3();
25
+ var scratchCartesian6 = new Cartesian3();
26
+ var scratchCartesian7 = new Cartesian3();
27
+ var scratchCartesian8 = new Cartesian3();
28
+ var scratchCartesian9 = new Cartesian3();
29
+
30
+ var scratch1 = new Cartesian3();
31
+ var scratch2 = new Cartesian3();
32
+
33
+ /**
34
+ * @private
35
+ */
36
+ var PolylineVolumeGeometryLibrary = {};
37
+
38
+ var cartographic = new Cartographic();
39
+ function scaleToSurface(positions, ellipsoid) {
40
+ var heights = new Array(positions.length);
41
+ for ( var i = 0; i < positions.length; i++) {
42
+ var pos = positions[i];
43
+ cartographic = ellipsoid.cartesianToCartographic(pos, cartographic);
44
+ heights[i] = cartographic.height;
45
+ positions[i] = ellipsoid.scaleToGeodeticSurface(pos, pos);
46
+ }
47
+ return heights;
48
+ }
49
+
50
+ function subdivideHeights(points, h0, h1, granularity) {
51
+ var p0 = points[0];
52
+ var p1 = points[1];
53
+ var angleBetween = Cartesian3.angleBetween(p0, p1);
54
+ var numPoints = Math.ceil(angleBetween / granularity);
55
+ var heights = new Array(numPoints);
56
+ var i;
57
+ if (h0 === h1) {
58
+ for (i = 0; i < numPoints; i++) {
59
+ heights[i] = h0;
60
+ }
61
+ heights.push(h1);
62
+ return heights;
63
+ }
64
+
65
+ var dHeight = h1 - h0;
66
+ var heightPerVertex = dHeight / (numPoints);
67
+
68
+ for (i = 1; i < numPoints; i++) {
69
+ var h = h0 + i * heightPerVertex;
70
+ heights[i] = h;
71
+ }
72
+
73
+ heights[0] = h0;
74
+ heights.push(h1);
75
+ return heights;
76
+ }
77
+
78
+ function computeRotationAngle(start, end, position, ellipsoid) {
79
+ var tangentPlane = new EllipsoidTangentPlane(position, ellipsoid);
80
+ var next = tangentPlane.projectPointOntoPlane(Cartesian3.add(position, start, nextScratch), nextScratch);
81
+ var prev = tangentPlane.projectPointOntoPlane(Cartesian3.add(position, end, prevScratch), prevScratch);
82
+ var angle = Cartesian2.angleBetween(next, prev);
83
+
84
+ return (prev.x * next.y - prev.y * next.x >= 0.0) ? -angle : angle;
85
+ }
86
+
87
+ var negativeX = new Cartesian4(-1, 0, 0, 0);
88
+ var transform = new Matrix4();
89
+ var translation = new Matrix4();
90
+ var rotationZ = new Matrix3();
91
+ var scaleMatrix = Matrix3.IDENTITY.clone();
92
+ var westScratch = new Cartesian4();
93
+ var finalPosScratch = new Cartesian4();
94
+ var heightCartesian = new Cartesian3();
95
+ function addPosition(center, left, shape, finalPositions, ellipsoid, height, xScalar, repeat) {
96
+ var west = westScratch;
97
+ var finalPosition = finalPosScratch;
98
+ transform = Transforms.eastNorthUpToFixedFrame(center, ellipsoid, transform);
99
+
100
+ west = Matrix4.multiplyByVector(transform, negativeX, west);
101
+ west = Cartesian3.normalize(west, west);
102
+ var angle = computeRotationAngle(west, left, center, ellipsoid);
103
+ rotationZ = Matrix3.fromRotationZ(angle, rotationZ);
104
+
105
+ heightCartesian.z = height;
106
+ transform = Matrix4.multiply(transform, Matrix4.fromRotationTranslation(rotationZ, heightCartesian, translation), transform);
107
+ var scale = scaleMatrix;
108
+ scale[0] = xScalar;
109
+
110
+ for ( var j = 0; j < repeat; j++) {
111
+ for ( var i = 0; i < shape.length; i += 3) {
112
+ finalPosition = Cartesian3.fromArray(shape, i, finalPosition);
113
+ finalPosition = Matrix3.multiplyByVector(scale, finalPosition, finalPosition);
114
+ finalPosition = Matrix4.multiplyByPoint(transform, finalPosition, finalPosition);
115
+ finalPositions.push(finalPosition.x, finalPosition.y, finalPosition.z);
116
+ }
117
+ }
118
+
119
+ return finalPositions;
120
+ }
121
+
122
+ var centerScratch = new Cartesian3();
123
+ function addPositions(centers, left, shape, finalPositions, ellipsoid, heights, xScalar) {
124
+ for ( var i = 0; i < centers.length; i += 3) {
125
+ var center = Cartesian3.fromArray(centers, i, centerScratch);
126
+ finalPositions = addPosition(center, left, shape, finalPositions, ellipsoid, heights[i / 3], xScalar, 1);
127
+ }
128
+ return finalPositions;
129
+ }
130
+
131
+ function convertShapeTo3DDuplicate(shape2D, boundingRectangle) { //orientate 2D shape to XZ plane center at (0, 0, 0), duplicate points
132
+ var length = shape2D.length;
133
+ var shape = new Array(length * 6);
134
+ var index = 0;
135
+ var xOffset = boundingRectangle.x + boundingRectangle.width / 2;
136
+ var yOffset = boundingRectangle.y + boundingRectangle.height / 2;
137
+
138
+ var point = shape2D[0];
139
+ shape[index++] = point.x - xOffset;
140
+ shape[index++] = 0.0;
141
+ shape[index++] = point.y - yOffset;
142
+ for ( var i = 1; i < length; i++) {
143
+ point = shape2D[i];
144
+ var x = point.x - xOffset;
145
+ var z = point.y - yOffset;
146
+ shape[index++] = x;
147
+ shape[index++] = 0.0;
148
+ shape[index++] = z;
149
+
150
+ shape[index++] = x;
151
+ shape[index++] = 0.0;
152
+ shape[index++] = z;
153
+ }
154
+ point = shape2D[0];
155
+ shape[index++] = point.x - xOffset;
156
+ shape[index++] = 0.0;
157
+ shape[index++] = point.y - yOffset;
158
+
159
+ return shape;
160
+ }
161
+
162
+ function convertShapeTo3D(shape2D, boundingRectangle) { //orientate 2D shape to XZ plane center at (0, 0, 0)
163
+ var length = shape2D.length;
164
+ var shape = new Array(length * 3);
165
+ var index = 0;
166
+ var xOffset = boundingRectangle.x + boundingRectangle.width / 2;
167
+ var yOffset = boundingRectangle.y + boundingRectangle.height / 2;
168
+
169
+ for ( var i = 0; i < length; i++) {
170
+ shape[index++] = shape2D[i].x - xOffset;
171
+ shape[index++] = 0;
172
+ shape[index++] = shape2D[i].y - yOffset;
173
+ }
174
+
175
+ return shape;
176
+ }
177
+
178
+ var quaterion = new Quaternion();
179
+ var startPointScratch = new Cartesian3();
180
+ var rotMatrix = new Matrix3();
181
+ function computeRoundCorner(pivot, startPoint, endPoint, cornerType, leftIsOutside, ellipsoid, finalPositions, shape, height, duplicatePoints) {
182
+ var angle = Cartesian3.angleBetween(Cartesian3.subtract(startPoint, pivot, scratch1), Cartesian3.subtract(endPoint, pivot, scratch2));
183
+ var granularity = (cornerType.value === CornerType.BEVELED.value) ? 0 : Math.ceil(angle / CesiumMath.toRadians(5));
184
+
185
+ var m;
186
+ if (leftIsOutside) {
187
+ m = Matrix3.fromQuaternion(Quaternion.fromAxisAngle(Cartesian3.negate(pivot, scratch1), angle / (granularity + 1), quaterion), rotMatrix);
188
+ } else {
189
+ m = Matrix3.fromQuaternion(Quaternion.fromAxisAngle(pivot, angle / (granularity + 1), quaterion), rotMatrix);
190
+ }
191
+
192
+ var left;
193
+ var surfacePoint;
194
+ startPoint = Cartesian3.clone(startPoint, startPointScratch);
195
+ if (granularity > 0) {
196
+ var repeat = duplicatePoints ? 2 : 1;
197
+ for ( var i = 0; i < granularity; i++) {
198
+ startPoint = Matrix3.multiplyByVector(m, startPoint, startPoint);
199
+ left = Cartesian3.subtract(startPoint, pivot, scratch1);
200
+ left = Cartesian3.normalize(left, left);
201
+ if (!leftIsOutside) {
202
+ left = Cartesian3.negate(left, left);
203
+ }
204
+ surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
205
+ finalPositions = addPosition(surfacePoint, left, shape, finalPositions, ellipsoid, height, 1, repeat);
206
+ }
207
+ } else {
208
+ left = Cartesian3.subtract(startPoint, pivot, scratch1);
209
+ left = Cartesian3.normalize(left, left);
210
+ if (!leftIsOutside) {
211
+ left = Cartesian3.negate(left, left);
212
+ }
213
+ surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
214
+ finalPositions = addPosition(surfacePoint, left, shape, finalPositions, ellipsoid, height, 1, 1);
215
+
216
+ endPoint = Cartesian3.clone(endPoint, startPointScratch);
217
+ left = Cartesian3.subtract(endPoint, pivot, scratch1);
218
+ left = Cartesian3.normalize(left, left);
219
+ if (!leftIsOutside) {
220
+ left = Cartesian3.negate(left, left);
221
+ }
222
+ surfacePoint = ellipsoid.scaleToGeodeticSurface(endPoint, scratch2);
223
+ finalPositions = addPosition(surfacePoint, left, shape, finalPositions, ellipsoid, height, 1, 1);
224
+ }
225
+
226
+ return finalPositions;
227
+ }
228
+
229
+ PolylineVolumeGeometryLibrary.removeDuplicatesFromShape = function(shapePositions) {
230
+ var length = shapePositions.length;
231
+ var cleanedPositions = [];
232
+ for ( var i0 = length - 1, i1 = 0; i1 < length; i0 = i1++) {
233
+ var v0 = shapePositions[i0];
234
+ var v1 = shapePositions[i1];
235
+
236
+ if (!Cartesian2.equals(v0, v1)) {
237
+ cleanedPositions.push(v1); // Shallow copy!
238
+ }
239
+ }
240
+
241
+ return cleanedPositions;
242
+ };
243
+
244
+ var nextScratch = new Cartesian3();
245
+ var prevScratch = new Cartesian3();
246
+ PolylineVolumeGeometryLibrary.angleIsGreaterThanPi = function(forward, backward, position, ellipsoid) {
247
+ var tangentPlane = new EllipsoidTangentPlane(position, ellipsoid);
248
+ var next = tangentPlane.projectPointOntoPlane(Cartesian3.add(position, forward, nextScratch), nextScratch);
249
+ var prev = tangentPlane.projectPointOntoPlane(Cartesian3.add(position, backward, prevScratch), prevScratch);
250
+
251
+ return ((prev.x * next.y) - (prev.y * next.x)) >= 0.0;
252
+ };
253
+
254
+ function latLonEquals(c0, c1) {
255
+ return ((CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON6)) && (CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON6)));
256
+ }
257
+ var carto0 = new Cartographic();
258
+ var carto1 = new Cartographic();
259
+ PolylineVolumeGeometryLibrary.removeDuplicatesFromPositions = function(positions, ellipsoid) {
260
+ var length = positions.length;
261
+ if (length < 2) {
262
+ return positions.slice(0);
263
+ }
264
+
265
+ var cleanedPositions = [];
266
+ cleanedPositions.push(positions[0]);
267
+
268
+ for (var i = 1; i < length; ++i) {
269
+ var v0 = positions[i - 1];
270
+ var v1 = positions[i];
271
+ var c0 = ellipsoid.cartesianToCartographic(v0, carto0);
272
+ var c1 = ellipsoid.cartesianToCartographic(v1, carto1);
273
+
274
+ if (!latLonEquals(c0, c1)) {
275
+ cleanedPositions.push(v1); // Shallow copy!
276
+ }
277
+ }
278
+
279
+ return cleanedPositions;
280
+ };
281
+
282
+ PolylineVolumeGeometryLibrary.computePositions = function(positions, shape2D, boundingRectangle, geometry, duplicatePoints) {
283
+ var ellipsoid = geometry._ellipsoid;
284
+ var heights = scaleToSurface(positions, ellipsoid);
285
+ var granularity = geometry._granularity;
286
+ var cornerType = geometry._cornerType;
287
+ var shapeForSides = duplicatePoints ? convertShapeTo3DDuplicate(shape2D, boundingRectangle) : convertShapeTo3D(shape2D, boundingRectangle);
288
+ var shapeForEnds = duplicatePoints ? convertShapeTo3D(shape2D, boundingRectangle) : undefined;
289
+ var heightOffset = boundingRectangle.height / 2;
290
+ var width = boundingRectangle.width / 2;
291
+ var length = positions.length;
292
+ var finalPositions = [];
293
+ var ends = duplicatePoints ? [] : undefined;
294
+
295
+ var forward = scratchCartesian1;
296
+ var backward = scratchCartesian2;
297
+ var cornerDirection = scratchCartesian3;
298
+ var surfaceNormal = scratchCartesian4;
299
+ var pivot = scratchCartesian5;
300
+ var start = scratchCartesian6;
301
+ var end = scratchCartesian7;
302
+ var left = scratchCartesian8;
303
+ var previousPosition = scratchCartesian9;
304
+
305
+ var position = positions[0];
306
+ var nextPosition = positions[1];
307
+ surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
308
+ forward = Cartesian3.subtract(nextPosition, position, forward);
309
+ forward = Cartesian3.normalize(forward, forward);
310
+ left = Cartesian3.cross(surfaceNormal, forward, left);
311
+ left = Cartesian3.normalize(left, left);
312
+ var h0 = heights[0];
313
+ var h1 = heights[1];
314
+ if (duplicatePoints) {
315
+ ends = addPosition(position, left, shapeForEnds, ends, ellipsoid, h0 + heightOffset, 1, 1);
316
+ }
317
+ previousPosition = Cartesian3.clone(position, previousPosition);
318
+ position = nextPosition;
319
+ backward = Cartesian3.negate(forward, backward);
320
+ var subdividedHeights;
321
+ var subdividedPositions;
322
+ for ( var i = 1; i < length - 1; i++) {
323
+ var repeat = duplicatePoints ? 2 : 1;
324
+ nextPosition = positions[i + 1];
325
+ forward = Cartesian3.subtract(nextPosition, position, forward);
326
+ forward = Cartesian3.normalize(forward, forward);
327
+ cornerDirection = Cartesian3.add(forward, backward, cornerDirection);
328
+ cornerDirection = Cartesian3.normalize(cornerDirection, cornerDirection);
329
+ surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
330
+ var doCorner = !Cartesian3.equalsEpsilon(Cartesian3.negate(cornerDirection, scratch1), surfaceNormal, CesiumMath.EPSILON2);
331
+ if (doCorner) {
332
+ cornerDirection = Cartesian3.cross(cornerDirection, surfaceNormal, cornerDirection);
333
+ cornerDirection = Cartesian3.cross(surfaceNormal, cornerDirection, cornerDirection);
334
+ cornerDirection = Cartesian3.normalize(cornerDirection, cornerDirection);
335
+ var scalar = 1 / Math.max(0.25, (Cartesian3.magnitude(Cartesian3.cross(cornerDirection, backward, scratch1))));
336
+ var leftIsOutside = PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(forward, backward, position, ellipsoid);
337
+ if (leftIsOutside) {
338
+ pivot = Cartesian3.add(position, Cartesian3.multiplyByScalar(cornerDirection, scalar * width, cornerDirection), pivot);
339
+ start = Cartesian3.add(pivot, Cartesian3.multiplyByScalar(left, width, start), start);
340
+ scratch2Array[0] = Cartesian3.clone(previousPosition, scratch2Array[0]);
341
+ scratch2Array[1] = Cartesian3.clone(start, scratch2Array[1]);
342
+ subdividedHeights = subdivideHeights(scratch2Array, h0 + heightOffset, h1 + heightOffset, granularity);
343
+ subdividedPositions = PolylinePipeline.scaleToSurface(scratch2Array);
344
+ finalPositions = addPositions(subdividedPositions, left, shapeForSides, finalPositions, ellipsoid, subdividedHeights, 1);
345
+ left = Cartesian3.cross(surfaceNormal, forward, left);
346
+ left = Cartesian3.normalize(left, left);
347
+ end = Cartesian3.add(pivot, Cartesian3.multiplyByScalar(left, width, end), end);
348
+ if (cornerType.value === CornerType.ROUNDED.value || cornerType.value === CornerType.BEVELED.value) {
349
+ computeRoundCorner(pivot, start, end, cornerType, leftIsOutside, ellipsoid, finalPositions, shapeForSides, h1 + heightOffset, duplicatePoints);
350
+ } else {
351
+ cornerDirection = Cartesian3.negate(cornerDirection, cornerDirection);
352
+ finalPositions = addPosition(position, cornerDirection, shapeForSides, finalPositions, ellipsoid, h1 + heightOffset, scalar, repeat);
353
+ }
354
+ previousPosition = Cartesian3.clone(end, previousPosition);
355
+ } else {
356
+ pivot = Cartesian3.add(position, Cartesian3.multiplyByScalar(cornerDirection, scalar * width, cornerDirection), pivot);
357
+ start = Cartesian3.add(pivot, Cartesian3.multiplyByScalar(left, -width, start), start);
358
+ scratch2Array[0] = Cartesian3.clone(previousPosition, scratch2Array[0]);
359
+ scratch2Array[1] = Cartesian3.clone(start, scratch2Array[1]);
360
+ subdividedHeights = subdivideHeights(scratch2Array, h0 + heightOffset, h1 + heightOffset, granularity);
361
+ subdividedPositions = PolylinePipeline.scaleToSurface(scratch2Array, granularity, ellipsoid);
362
+ finalPositions = addPositions(subdividedPositions, left, shapeForSides, finalPositions, ellipsoid, subdividedHeights, 1);
363
+ left = Cartesian3.cross(surfaceNormal, forward, left);
364
+ left = Cartesian3.normalize(left, left);
365
+ end = Cartesian3.add(pivot, Cartesian3.multiplyByScalar(left, -width, end), end);
366
+ if (cornerType.value === CornerType.ROUNDED.value || cornerType.value === CornerType.BEVELED.value) {
367
+ computeRoundCorner(pivot, start, end, cornerType, leftIsOutside, ellipsoid, finalPositions, shapeForSides, h1 + heightOffset, duplicatePoints);
368
+ } else {
369
+ finalPositions = addPosition(position, cornerDirection, shapeForSides, finalPositions, ellipsoid, h1 + heightOffset, scalar, repeat);
370
+ }
371
+ previousPosition = Cartesian3.clone(end, previousPosition);
372
+ }
373
+ backward = Cartesian3.negate(forward, backward);
374
+ } else {
375
+ finalPositions = addPosition(previousPosition, left, shapeForSides, finalPositions, ellipsoid, h0 + heightOffset, 1, 1);
376
+ previousPosition = position;
377
+ }
378
+ h0 = h1;
379
+ h1 = heights[i + 1];
380
+ position = nextPosition;
381
+ }
382
+
383
+ scratch2Array[0] = Cartesian3.clone(previousPosition, scratch2Array[0]);
384
+ scratch2Array[1] = Cartesian3.clone(position, scratch2Array[1]);
385
+ subdividedHeights = subdivideHeights(scratch2Array, h0 + heightOffset, h1 + heightOffset, granularity);
386
+ subdividedPositions = PolylinePipeline.scaleToSurface(scratch2Array, granularity, ellipsoid);
387
+ finalPositions = addPositions(subdividedPositions, left, shapeForSides, finalPositions, ellipsoid, subdividedHeights, 1);
388
+ if (duplicatePoints) {
389
+ ends = addPosition(position, left, shapeForEnds, ends, ellipsoid, h1 + heightOffset, 1, 1);
390
+ }
391
+
392
+ length = finalPositions.length;
393
+ var posLength = duplicatePoints ? length + ends.length : length;
394
+ var combinedPositions = new Float64Array(posLength);
395
+ combinedPositions.set(finalPositions);
396
+ if (duplicatePoints) {
397
+ combinedPositions.set(ends, length);
398
+ }
399
+
400
+ return combinedPositions;
401
+ };
402
+
403
+ return PolylineVolumeGeometryLibrary;
404
+ });
@@ -0,0 +1,154 @@
1
+ /*global define*/
2
+ define(['Core/defined', 'Core/DeveloperError', 'Core/Cartesian3', 'Core/CornerType', 'Core/ComponentDatatype', 'Core/Ellipsoid', 'Core/Geometry', 'Core/GeometryPipeline', 'Core/IndexDatatype', 'Core/Math', 'Core/PolygonPipeline', 'Core/PolylineVolumeGeometryLibrary', 'Core/PrimitiveType', 'Core/defaultValue', 'Core/BoundingSphere', 'Core/BoundingRectangle', 'Core/GeometryAttribute', 'Core/GeometryAttributes', 'Core/WindingOrder'], function(
3
+ defined,
4
+ DeveloperError,
5
+ Cartesian3,
6
+ CornerType,
7
+ ComponentDatatype,
8
+ Ellipsoid,
9
+ Geometry,
10
+ GeometryPipeline,
11
+ IndexDatatype,
12
+ CesiumMath,
13
+ PolygonPipeline,
14
+ PolylineVolumeGeometryLibrary,
15
+ PrimitiveType,
16
+ defaultValue,
17
+ BoundingSphere,
18
+ BoundingRectangle,
19
+ GeometryAttribute,
20
+ GeometryAttributes,
21
+ WindingOrder) {
22
+ "use strict";
23
+
24
+ function computeAttributes(positions, shape, boundingRectangle, ellipsoid) {
25
+ var attributes = new GeometryAttributes();
26
+ attributes.position = new GeometryAttribute({
27
+ componentDatatype : ComponentDatatype.DOUBLE,
28
+ componentsPerAttribute : 3,
29
+ values : positions
30
+ });
31
+
32
+ var shapeLength = shape.length;
33
+ var vertexCount = attributes.position.values.length / 3;
34
+ var positionLength = positions.length / 3;
35
+ var shapeCount = positionLength / shapeLength;
36
+ var indices = IndexDatatype.createTypedArray(vertexCount, 2 * shapeLength * (shapeCount + 1));
37
+ var i, j;
38
+ var index = 0;
39
+ i = 0;
40
+ var offset = i * shapeLength;
41
+ for (j = 0; j < shapeLength - 1; j++) {
42
+ indices[index++] = j + offset;
43
+ indices[index++] = j + offset + 1;
44
+ }
45
+ indices[index++] = shapeLength - 1 + offset;
46
+ indices[index++] = offset;
47
+
48
+ i = shapeCount - 1;
49
+ offset = i * shapeLength;
50
+ for (j = 0; j < shapeLength - 1; j++) {
51
+ indices[index++] = j + offset;
52
+ indices[index++] = j + offset + 1;
53
+ }
54
+ indices[index++] = shapeLength - 1 + offset;
55
+ indices[index++] = offset;
56
+
57
+ for (i = 0; i < shapeCount - 1; i++) {
58
+ var firstOffset = shapeLength * i;
59
+ var secondOffset = firstOffset + shapeLength;
60
+ for (j = 0; j < shapeLength; j++) {
61
+ indices[index++] = j + firstOffset;
62
+ indices[index++] = j + secondOffset;
63
+ }
64
+ }
65
+
66
+ var geometry = new Geometry({
67
+ attributes : attributes,
68
+ indices : IndexDatatype.createTypedArray(vertexCount, indices),
69
+ boundingSphere : BoundingSphere.fromVertices(positions),
70
+ primitiveType : PrimitiveType.LINES
71
+ });
72
+
73
+ return geometry;
74
+ }
75
+
76
+ /**
77
+ * A description of a polyline with a volume (a 2D shape extruded along a polyline).
78
+ *
79
+ * @alias PolylineVolumeOutlineGeometry
80
+ * @constructor
81
+ *
82
+ * @param {Array} options.polylinePositions An array of {Cartesain3} positions that define the center of the polyline volume.
83
+ * @param {Number} options.shapePositions An array of {Cartesian2} positions that define the shape to be extruded along the polyline
84
+ * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference.
85
+ * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
86
+ * @param {Boolean} [options.cornerType = CornerType.ROUNDED] Determines the style of the corners.
87
+ *
88
+ * @exception {DeveloperError} options.polylinePositions is required.
89
+ * @exception {DeveloperError} options.shapePositions is required.
90
+ *
91
+ * @see PolylineVolumeOutlineGeometry#createGeometry
92
+ *
93
+ * @example
94
+ * var volumeOutline = new PolylineVolumeOutlineGeometry({
95
+ * polylinePositions : ellipsoid.cartographicArrayToCartesianArray([
96
+ * Cartographic.fromDegrees(-72.0, 40.0),
97
+ * Cartographic.fromDegrees(-70.0, 35.0)
98
+ * ]),
99
+ * shapePositions : Shapes.compute2DCircle(100000.0)
100
+ * });
101
+ */
102
+ var PolylineVolumeOutlineGeometry = function(options) {
103
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
104
+ var positions = options.polylinePositions;
105
+ if (!defined(positions)) {
106
+ throw new DeveloperError('options.polylinePositions is required.');
107
+ }
108
+ var shape = options.shapePositions;
109
+ if (!defined(shape)) {
110
+ throw new DeveloperError('options.shapePositions is required.');
111
+ }
112
+
113
+ this._positions = positions;
114
+ this._shape = shape;
115
+ this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
116
+ this._cornerType = defaultValue(options.cornerType, CornerType.ROUNDED);
117
+ this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE);
118
+ this._workerName = 'createPolylineVolumeOutlineGeometry';
119
+ };
120
+
121
+ /**
122
+ * Computes the geometric representation of the outline of a polyline with a volume, including its vertices, indices, and a bounding sphere.
123
+ * @memberof PolylineVolumeOutlineGeometry
124
+ *
125
+ * @param {PolylineVolumeOutlineGeometry} polylineVolumeOutlineGeometry A description of the polyline volume outline.
126
+ *
127
+ * @returns {Geometry} The computed vertices and indices.
128
+ *
129
+ * @exception {DeveloperError} Count of unique polyline positions must be greater than 1.
130
+ * @exception {DeveloperError} Count of unique shape positions must be at least 3.
131
+ */
132
+ var brScratch = new BoundingRectangle();
133
+ PolylineVolumeOutlineGeometry.createGeometry = function(polylineVolumeOutlineGeometry) {
134
+ var positions = polylineVolumeOutlineGeometry._positions;
135
+ var cleanPositions = PolylineVolumeGeometryLibrary.removeDuplicatesFromPositions(positions, polylineVolumeOutlineGeometry._ellipsoid);
136
+ if (cleanPositions.length < 2) {
137
+ throw new DeveloperError('Count of unique polyline positions must be greater than 1.');
138
+ }
139
+ var shape2D = polylineVolumeOutlineGeometry._shape;
140
+ shape2D = PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(shape2D);
141
+ if (shape2D.length < 3) {
142
+ throw new DeveloperError('Count of unique shape positions must be at least 3.');
143
+ }
144
+ if (PolygonPipeline.computeWindingOrder2D(shape2D).value === WindingOrder.CLOCKWISE.value) {
145
+ shape2D.reverse();
146
+ }
147
+ var boundingRectangle = BoundingRectangle.fromPoints(shape2D, brScratch);
148
+
149
+ var computedPositions = PolylineVolumeGeometryLibrary.computePositions(cleanPositions, shape2D, boundingRectangle, polylineVolumeOutlineGeometry, false);
150
+ return computeAttributes(computedPositions, shape2D, boundingRectangle, polylineVolumeOutlineGeometry._ellipsoid);
151
+ };
152
+
153
+ return PolylineVolumeOutlineGeometry;
154
+ });