@rtzh/engine 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/Source/Scene/GltfLoader.js +2 -2
  2. package/package.json +1 -1
  3. package/Build/ThirdParty/Workers/zip-web-worker.js +0 -640
  4. package/Build/Workers/chunk-245NZYCR.js +0 -124
  5. package/Build/Workers/chunk-25BA4527.js +0 -837
  6. package/Build/Workers/chunk-4HXPSZRC.js +0 -1483
  7. package/Build/Workers/chunk-4Z26IS65.js +0 -3514
  8. package/Build/Workers/chunk-55IROWAX.js +0 -139
  9. package/Build/Workers/chunk-56XTN5NJ.js +0 -1800
  10. package/Build/Workers/chunk-5VZISKJF.js +0 -629
  11. package/Build/Workers/chunk-5WAG5YKS.js +0 -368
  12. package/Build/Workers/chunk-66YGZWBI.js +0 -1317
  13. package/Build/Workers/chunk-6H33B6OL.js +0 -37
  14. package/Build/Workers/chunk-6LZBBEA7.js +0 -439
  15. package/Build/Workers/chunk-6XJO625E.js +0 -497
  16. package/Build/Workers/chunk-75UGCVME.js +0 -102
  17. package/Build/Workers/chunk-7B23DD46.js +0 -1054
  18. package/Build/Workers/chunk-7NCJH26L.js +0 -352
  19. package/Build/Workers/chunk-AIW5F22O.js +0 -352
  20. package/Build/Workers/chunk-AL22JVIA.js +0 -256
  21. package/Build/Workers/chunk-AVSQILVI.js +0 -75
  22. package/Build/Workers/chunk-B2VFNYD7.js +0 -280
  23. package/Build/Workers/chunk-BOV6T7FO.js +0 -44
  24. package/Build/Workers/chunk-DP76S3IQ.js +0 -1067
  25. package/Build/Workers/chunk-EDIUN7V3.js +0 -219
  26. package/Build/Workers/chunk-EKMWNF4U.js +0 -55
  27. package/Build/Workers/chunk-ELXGXAYS.js +0 -682
  28. package/Build/Workers/chunk-FVYRV2T6.js +0 -455
  29. package/Build/Workers/chunk-GDIBU55R.js +0 -778
  30. package/Build/Workers/chunk-HAY6YE7M.js +0 -97
  31. package/Build/Workers/chunk-I76SRIKN.js +0 -138
  32. package/Build/Workers/chunk-IELTSYPZ.js +0 -241
  33. package/Build/Workers/chunk-J4MIJCN5.js +0 -171
  34. package/Build/Workers/chunk-JFO3ELF3.js +0 -642
  35. package/Build/Workers/chunk-K4IMD7KH.js +0 -162
  36. package/Build/Workers/chunk-KFMCOG26.js +0 -692
  37. package/Build/Workers/chunk-KH2OWUUA.js +0 -163
  38. package/Build/Workers/chunk-KQIZ7AFF.js +0 -8366
  39. package/Build/Workers/chunk-KVE5EAPO.js +0 -398
  40. package/Build/Workers/chunk-OAOREOSO.js +0 -940
  41. package/Build/Workers/chunk-OFJRMGNX.js +0 -788
  42. package/Build/Workers/chunk-PLLZB3R4.js +0 -198
  43. package/Build/Workers/chunk-POY6ZE32.js +0 -2058
  44. package/Build/Workers/chunk-PV5B2YNB.js +0 -2719
  45. package/Build/Workers/chunk-Q2DXNFYW.js +0 -414
  46. package/Build/Workers/chunk-QWV2DM66.js +0 -1443
  47. package/Build/Workers/chunk-R73BHGGI.js +0 -305
  48. package/Build/Workers/chunk-S3AE3MZZ.js +0 -511
  49. package/Build/Workers/chunk-SBFTVHRW.js +0 -57
  50. package/Build/Workers/chunk-SOR7PD4V.js +0 -114
  51. package/Build/Workers/chunk-TO7TWUET.js +0 -476
  52. package/Build/Workers/chunk-TSAJNE4K.js +0 -101
  53. package/Build/Workers/chunk-TWF4XRZ6.js +0 -73
  54. package/Build/Workers/chunk-UTWLMOPM.js +0 -387
  55. package/Build/Workers/chunk-UYT2PBMV.js +0 -58
  56. package/Build/Workers/chunk-WAS3IHIQ.js +0 -288
  57. package/Build/Workers/chunk-WO5ZNC7S.js +0 -1045
  58. package/Build/Workers/chunk-X65Y2JSA.js +0 -55
  59. package/Build/Workers/chunk-XOVHLPKW.js +0 -299
  60. package/Build/Workers/chunk-YPGJSFOO.js +0 -1460
  61. package/Build/Workers/combineGeometry.js +0 -66
  62. package/Build/Workers/createBoxGeometry.js +0 -58
  63. package/Build/Workers/createBoxOutlineGeometry.js +0 -231
  64. package/Build/Workers/createCircleGeometry.js +0 -201
  65. package/Build/Workers/createCircleOutlineGeometry.js +0 -147
  66. package/Build/Workers/createCoplanarPolygonGeometry.js +0 -505
  67. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +0 -225
  68. package/Build/Workers/createCorridorGeometry.js +0 -1258
  69. package/Build/Workers/createCorridorOutlineGeometry.js +0 -563
  70. package/Build/Workers/createCylinderGeometry.js +0 -60
  71. package/Build/Workers/createCylinderOutlineGeometry.js +0 -231
  72. package/Build/Workers/createEllipseGeometry.js +0 -72
  73. package/Build/Workers/createEllipseOutlineGeometry.js +0 -65
  74. package/Build/Workers/createEllipsoidGeometry.js +0 -59
  75. package/Build/Workers/createEllipsoidOutlineGeometry.js +0 -61
  76. package/Build/Workers/createFrustumGeometry.js +0 -58
  77. package/Build/Workers/createFrustumOutlineGeometry.js +0 -234
  78. package/Build/Workers/createGeometry.js +0 -173
  79. package/Build/Workers/createGroundPolylineGeometry.js +0 -1602
  80. package/Build/Workers/createPlaneGeometry.js +0 -223
  81. package/Build/Workers/createPlaneOutlineGeometry.js +0 -124
  82. package/Build/Workers/createPolygonGeometry.js +0 -1404
  83. package/Build/Workers/createPolygonOutlineGeometry.js +0 -532
  84. package/Build/Workers/createPolylineGeometry.js +0 -491
  85. package/Build/Workers/createPolylineVolumeGeometry.js +0 -374
  86. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +0 -272
  87. package/Build/Workers/createRectangleGeometry.js +0 -1264
  88. package/Build/Workers/createRectangleOutlineGeometry.js +0 -476
  89. package/Build/Workers/createSimplePolylineGeometry.js +0 -397
  90. package/Build/Workers/createSphereGeometry.js +0 -116
  91. package/Build/Workers/createSphereOutlineGeometry.js +0 -116
  92. package/Build/Workers/createTaskProcessorWorker.js +0 -32
  93. package/Build/Workers/createVectorTileClampedPolylines.js +0 -492
  94. package/Build/Workers/createVectorTileGeometries.js +0 -387
  95. package/Build/Workers/createVectorTilePoints.js +0 -114
  96. package/Build/Workers/createVectorTilePolygons.js +0 -386
  97. package/Build/Workers/createVectorTilePolylines.js +0 -262
  98. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +0 -91
  99. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +0 -565
  100. package/Build/Workers/createVerticesFromHeightmap.js +0 -2254
  101. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +0 -499
  102. package/Build/Workers/createWallGeometry.js +0 -487
  103. package/Build/Workers/createWallOutlineGeometry.js +0 -335
  104. package/Build/Workers/decodeDraco.js +0 -369
  105. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +0 -2680
  106. package/Build/Workers/decodeI3S.js +0 -1339
  107. package/Build/Workers/gaussianSplatSorter.js +0 -62
  108. package/Build/Workers/gaussianSplatTextureGenerator.js +0 -68
  109. package/Build/Workers/incrementallyBuildTerrainPicker.js +0 -121
  110. package/Build/Workers/transcodeKTX2.js +0 -3463
  111. package/Build/Workers/transferTypedArrayTest.js +0 -41
  112. package/Build/Workers/upsampleQuantizedTerrainMesh.js +0 -820
  113. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +0 -95
@@ -1,1602 +0,0 @@
1
- /**
2
- * @license
3
- * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 0.0.1
5
- *
6
- * Copyright 2011-2022 Cesium Contributors
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- *
20
- * Columbus View (Pat. Pend.)
21
- *
22
- * Portions licensed separately.
23
- * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24
- */
25
-
26
- import {
27
- WebMercatorProjection_default
28
- } from "./chunk-SOR7PD4V.js";
29
- import {
30
- ArcType_default
31
- } from "./chunk-X65Y2JSA.js";
32
- import {
33
- EncodedCartesian3_default
34
- } from "./chunk-75UGCVME.js";
35
- import {
36
- EllipsoidGeodesic_default
37
- } from "./chunk-AIW5F22O.js";
38
- import {
39
- arrayRemoveDuplicates_default
40
- } from "./chunk-HAY6YE7M.js";
41
- import {
42
- EllipsoidRhumbLine_default
43
- } from "./chunk-FVYRV2T6.js";
44
- import {
45
- IntersectionTests_default
46
- } from "./chunk-66YGZWBI.js";
47
- import {
48
- Plane_default
49
- } from "./chunk-J4MIJCN5.js";
50
- import {
51
- GeometryAttribute_default,
52
- Geometry_default
53
- } from "./chunk-XOVHLPKW.js";
54
- import {
55
- BoundingSphere_default,
56
- GeographicProjection_default
57
- } from "./chunk-OAOREOSO.js";
58
- import "./chunk-EKMWNF4U.js";
59
- import {
60
- Quaternion_default,
61
- Rectangle_default,
62
- Resource_default,
63
- buildModuleUrl_default
64
- } from "./chunk-KQIZ7AFF.js";
65
- import "./chunk-POY6ZE32.js";
66
- import {
67
- ComponentDatatype_default
68
- } from "./chunk-AL22JVIA.js";
69
- import "./chunk-5VZISKJF.js";
70
- import "./chunk-UYT2PBMV.js";
71
- import {
72
- Cartesian2_default,
73
- Cartographic_default,
74
- Ellipsoid_default
75
- } from "./chunk-YPGJSFOO.js";
76
- import {
77
- Cartesian3_default,
78
- Frozen_default,
79
- Matrix3_default
80
- } from "./chunk-QWV2DM66.js";
81
- import {
82
- Math_default
83
- } from "./chunk-6XJO625E.js";
84
- import {
85
- Check_default,
86
- DeveloperError_default
87
- } from "./chunk-KH2OWUUA.js";
88
- import {
89
- defined_default
90
- } from "./chunk-AVSQILVI.js";
91
-
92
- // packages/engine/Source/Core/GeographicTilingScheme.js
93
- function GeographicTilingScheme(options) {
94
- options = options ?? Frozen_default.EMPTY_OBJECT;
95
- this._ellipsoid = options.ellipsoid ?? Ellipsoid_default.default;
96
- this._rectangle = options.rectangle ?? Rectangle_default.MAX_VALUE;
97
- this._projection = new GeographicProjection_default(this._ellipsoid);
98
- this._numberOfLevelZeroTilesX = options.numberOfLevelZeroTilesX ?? 2;
99
- this._numberOfLevelZeroTilesY = options.numberOfLevelZeroTilesY ?? 1;
100
- }
101
- Object.defineProperties(GeographicTilingScheme.prototype, {
102
- /**
103
- * Gets the ellipsoid that is tiled by this tiling scheme.
104
- * @memberof GeographicTilingScheme.prototype
105
- * @type {Ellipsoid}
106
- */
107
- ellipsoid: {
108
- get: function() {
109
- return this._ellipsoid;
110
- }
111
- },
112
- /**
113
- * Gets the rectangle, in radians, covered by this tiling scheme.
114
- * @memberof GeographicTilingScheme.prototype
115
- * @type {Rectangle}
116
- */
117
- rectangle: {
118
- get: function() {
119
- return this._rectangle;
120
- }
121
- },
122
- /**
123
- * Gets the map projection used by this tiling scheme.
124
- * @memberof GeographicTilingScheme.prototype
125
- * @type {MapProjection}
126
- */
127
- projection: {
128
- get: function() {
129
- return this._projection;
130
- }
131
- }
132
- });
133
- GeographicTilingScheme.prototype.getNumberOfXTilesAtLevel = function(level) {
134
- return this._numberOfLevelZeroTilesX << level;
135
- };
136
- GeographicTilingScheme.prototype.getNumberOfYTilesAtLevel = function(level) {
137
- return this._numberOfLevelZeroTilesY << level;
138
- };
139
- GeographicTilingScheme.prototype.rectangleToNativeRectangle = function(rectangle, result) {
140
- Check_default.defined("rectangle", rectangle);
141
- const west = Math_default.toDegrees(rectangle.west);
142
- const south = Math_default.toDegrees(rectangle.south);
143
- const east = Math_default.toDegrees(rectangle.east);
144
- const north = Math_default.toDegrees(rectangle.north);
145
- if (!defined_default(result)) {
146
- return new Rectangle_default(west, south, east, north);
147
- }
148
- result.west = west;
149
- result.south = south;
150
- result.east = east;
151
- result.north = north;
152
- return result;
153
- };
154
- GeographicTilingScheme.prototype.tileXYToNativeRectangle = function(x, y, level, result) {
155
- const rectangleRadians = this.tileXYToRectangle(x, y, level, result);
156
- rectangleRadians.west = Math_default.toDegrees(rectangleRadians.west);
157
- rectangleRadians.south = Math_default.toDegrees(rectangleRadians.south);
158
- rectangleRadians.east = Math_default.toDegrees(rectangleRadians.east);
159
- rectangleRadians.north = Math_default.toDegrees(rectangleRadians.north);
160
- return rectangleRadians;
161
- };
162
- GeographicTilingScheme.prototype.tileXYToRectangle = function(x, y, level, result) {
163
- const rectangle = this._rectangle;
164
- const xTiles = this.getNumberOfXTilesAtLevel(level);
165
- const yTiles = this.getNumberOfYTilesAtLevel(level);
166
- const xTileWidth = rectangle.width / xTiles;
167
- const west = x * xTileWidth + rectangle.west;
168
- const east = (x + 1) * xTileWidth + rectangle.west;
169
- const yTileHeight = rectangle.height / yTiles;
170
- const north = rectangle.north - y * yTileHeight;
171
- const south = rectangle.north - (y + 1) * yTileHeight;
172
- if (!defined_default(result)) {
173
- result = new Rectangle_default(west, south, east, north);
174
- }
175
- result.west = west;
176
- result.south = south;
177
- result.east = east;
178
- result.north = north;
179
- return result;
180
- };
181
- GeographicTilingScheme.prototype.positionToTileXY = function(position, level, result) {
182
- const rectangle = this._rectangle;
183
- if (!Rectangle_default.contains(rectangle, position)) {
184
- return void 0;
185
- }
186
- const xTiles = this.getNumberOfXTilesAtLevel(level);
187
- const yTiles = this.getNumberOfYTilesAtLevel(level);
188
- const xTileWidth = rectangle.width / xTiles;
189
- const yTileHeight = rectangle.height / yTiles;
190
- let longitude = position.longitude;
191
- if (rectangle.east < rectangle.west) {
192
- longitude += Math_default.TWO_PI;
193
- }
194
- let xTileCoordinate = (longitude - rectangle.west) / xTileWidth | 0;
195
- if (xTileCoordinate >= xTiles) {
196
- xTileCoordinate = xTiles - 1;
197
- }
198
- let yTileCoordinate = (rectangle.north - position.latitude) / yTileHeight | 0;
199
- if (yTileCoordinate >= yTiles) {
200
- yTileCoordinate = yTiles - 1;
201
- }
202
- if (!defined_default(result)) {
203
- return new Cartesian2_default(xTileCoordinate, yTileCoordinate);
204
- }
205
- result.x = xTileCoordinate;
206
- result.y = yTileCoordinate;
207
- return result;
208
- };
209
- var GeographicTilingScheme_default = GeographicTilingScheme;
210
-
211
- // packages/engine/Source/Core/ApproximateTerrainHeights.js
212
- var scratchDiagonalCartesianNE = new Cartesian3_default();
213
- var scratchDiagonalCartesianSW = new Cartesian3_default();
214
- var scratchDiagonalCartographic = new Cartographic_default();
215
- var scratchCenterCartesian = new Cartesian3_default();
216
- var scratchSurfaceCartesian = new Cartesian3_default();
217
- var scratchBoundingSphere = new BoundingSphere_default();
218
- var tilingScheme = new GeographicTilingScheme_default();
219
- var scratchCorners = [
220
- new Cartographic_default(),
221
- new Cartographic_default(),
222
- new Cartographic_default(),
223
- new Cartographic_default()
224
- ];
225
- var scratchTileXY = new Cartesian2_default();
226
- var ApproximateTerrainHeights = {};
227
- ApproximateTerrainHeights.initialize = function() {
228
- let initPromise = ApproximateTerrainHeights._initPromise;
229
- if (defined_default(initPromise)) {
230
- return initPromise;
231
- }
232
- initPromise = Resource_default.fetchJson(
233
- buildModuleUrl_default("Assets/approximateTerrainHeights.json")
234
- ).then(function(json) {
235
- ApproximateTerrainHeights._terrainHeights = json;
236
- });
237
- ApproximateTerrainHeights._initPromise = initPromise;
238
- return initPromise;
239
- };
240
- ApproximateTerrainHeights.getMinimumMaximumHeights = function(rectangle, ellipsoid) {
241
- Check_default.defined("rectangle", rectangle);
242
- if (!defined_default(ApproximateTerrainHeights._terrainHeights)) {
243
- throw new DeveloperError_default(
244
- "You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function"
245
- );
246
- }
247
- ellipsoid = ellipsoid ?? Ellipsoid_default.default;
248
- const xyLevel = getTileXYLevel(rectangle);
249
- let minTerrainHeight = ApproximateTerrainHeights._defaultMinTerrainHeight;
250
- let maxTerrainHeight = ApproximateTerrainHeights._defaultMaxTerrainHeight;
251
- if (defined_default(xyLevel)) {
252
- const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;
253
- const heights = ApproximateTerrainHeights._terrainHeights[key];
254
- if (defined_default(heights)) {
255
- minTerrainHeight = heights[0];
256
- maxTerrainHeight = heights[1];
257
- }
258
- ellipsoid.cartographicToCartesian(
259
- Rectangle_default.northeast(rectangle, scratchDiagonalCartographic),
260
- scratchDiagonalCartesianNE
261
- );
262
- ellipsoid.cartographicToCartesian(
263
- Rectangle_default.southwest(rectangle, scratchDiagonalCartographic),
264
- scratchDiagonalCartesianSW
265
- );
266
- Cartesian3_default.midpoint(
267
- scratchDiagonalCartesianSW,
268
- scratchDiagonalCartesianNE,
269
- scratchCenterCartesian
270
- );
271
- const surfacePosition = ellipsoid.scaleToGeodeticSurface(
272
- scratchCenterCartesian,
273
- scratchSurfaceCartesian
274
- );
275
- if (defined_default(surfacePosition)) {
276
- const distance = Cartesian3_default.distance(
277
- scratchCenterCartesian,
278
- surfacePosition
279
- );
280
- minTerrainHeight = Math.min(minTerrainHeight, -distance);
281
- } else {
282
- minTerrainHeight = ApproximateTerrainHeights._defaultMinTerrainHeight;
283
- }
284
- }
285
- minTerrainHeight = Math.max(
286
- ApproximateTerrainHeights._defaultMinTerrainHeight,
287
- minTerrainHeight
288
- );
289
- return {
290
- minimumTerrainHeight: minTerrainHeight,
291
- maximumTerrainHeight: maxTerrainHeight
292
- };
293
- };
294
- ApproximateTerrainHeights.getBoundingSphere = function(rectangle, ellipsoid) {
295
- Check_default.defined("rectangle", rectangle);
296
- if (!defined_default(ApproximateTerrainHeights._terrainHeights)) {
297
- throw new DeveloperError_default(
298
- "You must call ApproximateTerrainHeights.initialize and wait for the promise to resolve before using this function"
299
- );
300
- }
301
- ellipsoid = ellipsoid ?? Ellipsoid_default.default;
302
- const xyLevel = getTileXYLevel(rectangle);
303
- let maxTerrainHeight = ApproximateTerrainHeights._defaultMaxTerrainHeight;
304
- if (defined_default(xyLevel)) {
305
- const key = `${xyLevel.level}-${xyLevel.x}-${xyLevel.y}`;
306
- const heights = ApproximateTerrainHeights._terrainHeights[key];
307
- if (defined_default(heights)) {
308
- maxTerrainHeight = heights[1];
309
- }
310
- }
311
- const result = BoundingSphere_default.fromRectangle3D(rectangle, ellipsoid, 0);
312
- BoundingSphere_default.fromRectangle3D(
313
- rectangle,
314
- ellipsoid,
315
- maxTerrainHeight,
316
- scratchBoundingSphere
317
- );
318
- return BoundingSphere_default.union(result, scratchBoundingSphere, result);
319
- };
320
- function getTileXYLevel(rectangle) {
321
- Cartographic_default.fromRadians(
322
- rectangle.east,
323
- rectangle.north,
324
- 0,
325
- scratchCorners[0]
326
- );
327
- Cartographic_default.fromRadians(
328
- rectangle.west,
329
- rectangle.north,
330
- 0,
331
- scratchCorners[1]
332
- );
333
- Cartographic_default.fromRadians(
334
- rectangle.east,
335
- rectangle.south,
336
- 0,
337
- scratchCorners[2]
338
- );
339
- Cartographic_default.fromRadians(
340
- rectangle.west,
341
- rectangle.south,
342
- 0,
343
- scratchCorners[3]
344
- );
345
- let lastLevelX = 0, lastLevelY = 0;
346
- let currentX = 0, currentY = 0;
347
- const maxLevel = ApproximateTerrainHeights._terrainHeightsMaxLevel;
348
- let i;
349
- for (i = 0; i <= maxLevel; ++i) {
350
- let failed = false;
351
- for (let j = 0; j < 4; ++j) {
352
- const corner = scratchCorners[j];
353
- tilingScheme.positionToTileXY(corner, i, scratchTileXY);
354
- if (j === 0) {
355
- currentX = scratchTileXY.x;
356
- currentY = scratchTileXY.y;
357
- } else if (currentX !== scratchTileXY.x || currentY !== scratchTileXY.y) {
358
- failed = true;
359
- break;
360
- }
361
- }
362
- if (failed) {
363
- break;
364
- }
365
- lastLevelX = currentX;
366
- lastLevelY = currentY;
367
- }
368
- if (i === 0) {
369
- return void 0;
370
- }
371
- return {
372
- x: lastLevelX,
373
- y: lastLevelY,
374
- level: i > maxLevel ? maxLevel : i - 1
375
- };
376
- }
377
- ApproximateTerrainHeights._terrainHeightsMaxLevel = 6;
378
- ApproximateTerrainHeights._defaultMaxTerrainHeight = 9e3;
379
- ApproximateTerrainHeights._defaultMinTerrainHeight = -1e5;
380
- ApproximateTerrainHeights._terrainHeights = void 0;
381
- ApproximateTerrainHeights._initPromise = void 0;
382
- Object.defineProperties(ApproximateTerrainHeights, {
383
- /**
384
- * Determines if the terrain heights are initialized and ready to use. To initialize the terrain heights,
385
- * call {@link ApproximateTerrainHeights#initialize} and wait for the returned promise to resolve.
386
- * @type {boolean}
387
- * @readonly
388
- * @memberof ApproximateTerrainHeights
389
- */
390
- initialized: {
391
- get: function() {
392
- return defined_default(ApproximateTerrainHeights._terrainHeights);
393
- }
394
- }
395
- });
396
- var ApproximateTerrainHeights_default = ApproximateTerrainHeights;
397
-
398
- // packages/engine/Source/Core/GroundPolylineGeometry.js
399
- var PROJECTIONS = [GeographicProjection_default, WebMercatorProjection_default];
400
- var PROJECTION_COUNT = PROJECTIONS.length;
401
- var MITER_BREAK_SMALL = Math.cos(Math_default.toRadians(30));
402
- var MITER_BREAK_LARGE = Math.cos(Math_default.toRadians(150));
403
- var WALL_INITIAL_MIN_HEIGHT = 0;
404
- var WALL_INITIAL_MAX_HEIGHT = 1e3;
405
- function GroundPolylineGeometry(options) {
406
- options = options ?? Frozen_default.EMPTY_OBJECT;
407
- const positions = options.positions;
408
- if (!defined_default(positions) || positions.length < 2) {
409
- throw new DeveloperError_default("At least two positions are required.");
410
- }
411
- if (defined_default(options.arcType) && options.arcType !== ArcType_default.GEODESIC && options.arcType !== ArcType_default.RHUMB) {
412
- throw new DeveloperError_default(
413
- "Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB."
414
- );
415
- }
416
- this.width = options.width ?? 1;
417
- this._positions = positions;
418
- this.granularity = options.granularity ?? 9999;
419
- this.loop = options.loop ?? false;
420
- this.arcType = options.arcType ?? ArcType_default.GEODESIC;
421
- this._ellipsoid = Ellipsoid_default.default;
422
- this._projectionIndex = 0;
423
- this._workerName = "createGroundPolylineGeometry";
424
- this._scene3DOnly = false;
425
- }
426
- Object.defineProperties(GroundPolylineGeometry.prototype, {
427
- /**
428
- * The number of elements used to pack the object into an array.
429
- * @memberof GroundPolylineGeometry.prototype
430
- * @type {number}
431
- * @readonly
432
- * @private
433
- */
434
- packedLength: {
435
- get: function() {
436
- return 1 + this._positions.length * 3 + 1 + 1 + 1 + Ellipsoid_default.packedLength + 1 + 1;
437
- }
438
- }
439
- });
440
- GroundPolylineGeometry.setProjectionAndEllipsoid = function(groundPolylineGeometry, mapProjection) {
441
- let projectionIndex = 0;
442
- for (let i = 0; i < PROJECTION_COUNT; i++) {
443
- if (mapProjection instanceof PROJECTIONS[i]) {
444
- projectionIndex = i;
445
- break;
446
- }
447
- }
448
- groundPolylineGeometry._projectionIndex = projectionIndex;
449
- groundPolylineGeometry._ellipsoid = mapProjection.ellipsoid;
450
- };
451
- var cart3Scratch1 = new Cartesian3_default();
452
- var cart3Scratch2 = new Cartesian3_default();
453
- var cart3Scratch3 = new Cartesian3_default();
454
- function computeRightNormal(start, end, maxHeight, ellipsoid, result) {
455
- const startBottom = getPosition(ellipsoid, start, 0, cart3Scratch1);
456
- const startTop = getPosition(ellipsoid, start, maxHeight, cart3Scratch2);
457
- const endBottom = getPosition(ellipsoid, end, 0, cart3Scratch3);
458
- const up = direction(startTop, startBottom, cart3Scratch2);
459
- const forward = direction(endBottom, startBottom, cart3Scratch3);
460
- Cartesian3_default.cross(forward, up, result);
461
- return Cartesian3_default.normalize(result, result);
462
- }
463
- var interpolatedCartographicScratch = new Cartographic_default();
464
- var interpolatedBottomScratch = new Cartesian3_default();
465
- var interpolatedTopScratch = new Cartesian3_default();
466
- var interpolatedNormalScratch = new Cartesian3_default();
467
- function interpolateSegment(start, end, minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) {
468
- if (granularity === 0) {
469
- return;
470
- }
471
- let ellipsoidLine;
472
- if (arcType === ArcType_default.GEODESIC) {
473
- ellipsoidLine = new EllipsoidGeodesic_default(start, end, ellipsoid);
474
- } else if (arcType === ArcType_default.RHUMB) {
475
- ellipsoidLine = new EllipsoidRhumbLine_default(start, end, ellipsoid);
476
- }
477
- const surfaceDistance = ellipsoidLine.surfaceDistance;
478
- if (surfaceDistance < granularity) {
479
- return;
480
- }
481
- const interpolatedNormal = computeRightNormal(
482
- start,
483
- end,
484
- maxHeight,
485
- ellipsoid,
486
- interpolatedNormalScratch
487
- );
488
- const segments = Math.ceil(surfaceDistance / granularity);
489
- const interpointDistance = surfaceDistance / segments;
490
- let distanceFromStart = interpointDistance;
491
- const pointsToAdd = segments - 1;
492
- let packIndex = normalsArray.length;
493
- for (let i = 0; i < pointsToAdd; i++) {
494
- const interpolatedCartographic = ellipsoidLine.interpolateUsingSurfaceDistance(
495
- distanceFromStart,
496
- interpolatedCartographicScratch
497
- );
498
- const interpolatedBottom = getPosition(
499
- ellipsoid,
500
- interpolatedCartographic,
501
- minHeight,
502
- interpolatedBottomScratch
503
- );
504
- const interpolatedTop = getPosition(
505
- ellipsoid,
506
- interpolatedCartographic,
507
- maxHeight,
508
- interpolatedTopScratch
509
- );
510
- Cartesian3_default.pack(interpolatedNormal, normalsArray, packIndex);
511
- Cartesian3_default.pack(interpolatedBottom, bottomPositionsArray, packIndex);
512
- Cartesian3_default.pack(interpolatedTop, topPositionsArray, packIndex);
513
- cartographicsArray.push(interpolatedCartographic.latitude);
514
- cartographicsArray.push(interpolatedCartographic.longitude);
515
- packIndex += 3;
516
- distanceFromStart += interpointDistance;
517
- }
518
- }
519
- var heightlessCartographicScratch = new Cartographic_default();
520
- function getPosition(ellipsoid, cartographic, height, result) {
521
- Cartographic_default.clone(cartographic, heightlessCartographicScratch);
522
- heightlessCartographicScratch.height = height;
523
- return Cartographic_default.toCartesian(
524
- heightlessCartographicScratch,
525
- ellipsoid,
526
- result
527
- );
528
- }
529
- GroundPolylineGeometry.pack = function(value, array, startingIndex) {
530
- Check_default.typeOf.object("value", value);
531
- Check_default.defined("array", array);
532
- let index = startingIndex ?? 0;
533
- const positions = value._positions;
534
- const positionsLength = positions.length;
535
- array[index++] = positionsLength;
536
- for (let i = 0; i < positionsLength; ++i) {
537
- const cartesian = positions[i];
538
- Cartesian3_default.pack(cartesian, array, index);
539
- index += 3;
540
- }
541
- array[index++] = value.granularity;
542
- array[index++] = value.loop ? 1 : 0;
543
- array[index++] = value.arcType;
544
- Ellipsoid_default.pack(value._ellipsoid, array, index);
545
- index += Ellipsoid_default.packedLength;
546
- array[index++] = value._projectionIndex;
547
- array[index++] = value._scene3DOnly ? 1 : 0;
548
- return array;
549
- };
550
- GroundPolylineGeometry.unpack = function(array, startingIndex, result) {
551
- Check_default.defined("array", array);
552
- let index = startingIndex ?? 0;
553
- const positionsLength = array[index++];
554
- const positions = new Array(positionsLength);
555
- for (let i = 0; i < positionsLength; i++) {
556
- positions[i] = Cartesian3_default.unpack(array, index);
557
- index += 3;
558
- }
559
- const granularity = array[index++];
560
- const loop = array[index++] === 1;
561
- const arcType = array[index++];
562
- const ellipsoid = Ellipsoid_default.unpack(array, index);
563
- index += Ellipsoid_default.packedLength;
564
- const projectionIndex = array[index++];
565
- const scene3DOnly = array[index++] === 1;
566
- if (!defined_default(result)) {
567
- result = new GroundPolylineGeometry({
568
- positions
569
- });
570
- }
571
- result._positions = positions;
572
- result.granularity = granularity;
573
- result.loop = loop;
574
- result.arcType = arcType;
575
- result._ellipsoid = ellipsoid;
576
- result._projectionIndex = projectionIndex;
577
- result._scene3DOnly = scene3DOnly;
578
- return result;
579
- };
580
- function direction(target, origin, result) {
581
- Cartesian3_default.subtract(target, origin, result);
582
- Cartesian3_default.normalize(result, result);
583
- return result;
584
- }
585
- function tangentDirection(target, origin, up, result) {
586
- result = direction(target, origin, result);
587
- result = Cartesian3_default.cross(result, up, result);
588
- result = Cartesian3_default.normalize(result, result);
589
- result = Cartesian3_default.cross(up, result, result);
590
- return result;
591
- }
592
- var toPreviousScratch = new Cartesian3_default();
593
- var toNextScratch = new Cartesian3_default();
594
- var forwardScratch = new Cartesian3_default();
595
- var vertexUpScratch = new Cartesian3_default();
596
- var cosine90 = 0;
597
- var cosine180 = -1;
598
- function computeVertexMiterNormal(previousBottom, vertexBottom, vertexTop, nextBottom, result) {
599
- const up = direction(vertexTop, vertexBottom, vertexUpScratch);
600
- const toPrevious = tangentDirection(
601
- previousBottom,
602
- vertexBottom,
603
- up,
604
- toPreviousScratch
605
- );
606
- const toNext = tangentDirection(nextBottom, vertexBottom, up, toNextScratch);
607
- if (Math_default.equalsEpsilon(
608
- Cartesian3_default.dot(toPrevious, toNext),
609
- cosine180,
610
- Math_default.EPSILON5
611
- )) {
612
- result = Cartesian3_default.cross(up, toPrevious, result);
613
- result = Cartesian3_default.normalize(result, result);
614
- return result;
615
- }
616
- result = Cartesian3_default.add(toNext, toPrevious, result);
617
- result = Cartesian3_default.normalize(result, result);
618
- const forward = Cartesian3_default.cross(up, result, forwardScratch);
619
- if (Cartesian3_default.dot(toNext, forward) < cosine90) {
620
- result = Cartesian3_default.negate(result, result);
621
- }
622
- return result;
623
- }
624
- var XZ_PLANE = Plane_default.fromPointNormal(Cartesian3_default.ZERO, Cartesian3_default.UNIT_Y);
625
- var previousBottomScratch = new Cartesian3_default();
626
- var vertexBottomScratch = new Cartesian3_default();
627
- var vertexTopScratch = new Cartesian3_default();
628
- var nextBottomScratch = new Cartesian3_default();
629
- var vertexNormalScratch = new Cartesian3_default();
630
- var intersectionScratch = new Cartesian3_default();
631
- var cartographicScratch0 = new Cartographic_default();
632
- var cartographicScratch1 = new Cartographic_default();
633
- var cartographicIntersectionScratch = new Cartographic_default();
634
- GroundPolylineGeometry.createGeometry = function(groundPolylineGeometry) {
635
- const compute2dAttributes = !groundPolylineGeometry._scene3DOnly;
636
- let loop = groundPolylineGeometry.loop;
637
- const ellipsoid = groundPolylineGeometry._ellipsoid;
638
- const granularity = groundPolylineGeometry.granularity;
639
- const arcType = groundPolylineGeometry.arcType;
640
- const projection = new PROJECTIONS[groundPolylineGeometry._projectionIndex](
641
- ellipsoid
642
- );
643
- const minHeight = WALL_INITIAL_MIN_HEIGHT;
644
- const maxHeight = WALL_INITIAL_MAX_HEIGHT;
645
- let index;
646
- let i;
647
- const positions = groundPolylineGeometry._positions;
648
- const positionsLength = positions.length;
649
- if (positionsLength === 2) {
650
- loop = false;
651
- }
652
- let p0;
653
- let p1;
654
- let c0;
655
- let c1;
656
- const rhumbLine = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
657
- let intersection;
658
- let intersectionCartographic;
659
- let intersectionLongitude;
660
- const splitPositions = [positions[0]];
661
- for (i = 0; i < positionsLength - 1; i++) {
662
- p0 = positions[i];
663
- p1 = positions[i + 1];
664
- intersection = IntersectionTests_default.lineSegmentPlane(
665
- p0,
666
- p1,
667
- XZ_PLANE,
668
- intersectionScratch
669
- );
670
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
671
- if (groundPolylineGeometry.arcType === ArcType_default.GEODESIC) {
672
- splitPositions.push(Cartesian3_default.clone(intersection));
673
- } else if (groundPolylineGeometry.arcType === ArcType_default.RHUMB) {
674
- intersectionLongitude = ellipsoid.cartesianToCartographic(
675
- intersection,
676
- cartographicScratch0
677
- ).longitude;
678
- c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0);
679
- c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1);
680
- rhumbLine.setEndPoints(c0, c1);
681
- intersectionCartographic = rhumbLine.findIntersectionWithLongitude(
682
- intersectionLongitude,
683
- cartographicIntersectionScratch
684
- );
685
- intersection = ellipsoid.cartographicToCartesian(
686
- intersectionCartographic,
687
- intersectionScratch
688
- );
689
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
690
- splitPositions.push(Cartesian3_default.clone(intersection));
691
- }
692
- }
693
- }
694
- splitPositions.push(p1);
695
- }
696
- if (loop) {
697
- p0 = positions[positionsLength - 1];
698
- p1 = positions[0];
699
- intersection = IntersectionTests_default.lineSegmentPlane(
700
- p0,
701
- p1,
702
- XZ_PLANE,
703
- intersectionScratch
704
- );
705
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
706
- if (groundPolylineGeometry.arcType === ArcType_default.GEODESIC) {
707
- splitPositions.push(Cartesian3_default.clone(intersection));
708
- } else if (groundPolylineGeometry.arcType === ArcType_default.RHUMB) {
709
- intersectionLongitude = ellipsoid.cartesianToCartographic(
710
- intersection,
711
- cartographicScratch0
712
- ).longitude;
713
- c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0);
714
- c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1);
715
- rhumbLine.setEndPoints(c0, c1);
716
- intersectionCartographic = rhumbLine.findIntersectionWithLongitude(
717
- intersectionLongitude,
718
- cartographicIntersectionScratch
719
- );
720
- intersection = ellipsoid.cartographicToCartesian(
721
- intersectionCartographic,
722
- intersectionScratch
723
- );
724
- if (defined_default(intersection) && !Cartesian3_default.equalsEpsilon(intersection, p0, Math_default.EPSILON7) && !Cartesian3_default.equalsEpsilon(intersection, p1, Math_default.EPSILON7)) {
725
- splitPositions.push(Cartesian3_default.clone(intersection));
726
- }
727
- }
728
- }
729
- }
730
- let cartographicsLength = splitPositions.length;
731
- let cartographics = new Array(cartographicsLength);
732
- for (i = 0; i < cartographicsLength; i++) {
733
- const cartographic = Cartographic_default.fromCartesian(
734
- splitPositions[i],
735
- ellipsoid
736
- );
737
- cartographic.height = 0;
738
- cartographics[i] = cartographic;
739
- }
740
- cartographics = arrayRemoveDuplicates_default(
741
- cartographics,
742
- Cartographic_default.equalsEpsilon
743
- );
744
- cartographicsLength = cartographics.length;
745
- if (cartographicsLength < 2) {
746
- return void 0;
747
- }
748
- const cartographicsArray = [];
749
- const normalsArray = [];
750
- const bottomPositionsArray = [];
751
- const topPositionsArray = [];
752
- let previousBottom = previousBottomScratch;
753
- let vertexBottom = vertexBottomScratch;
754
- let vertexTop = vertexTopScratch;
755
- let nextBottom = nextBottomScratch;
756
- let vertexNormal = vertexNormalScratch;
757
- const startCartographic = cartographics[0];
758
- const nextCartographic = cartographics[1];
759
- const prestartCartographic = cartographics[cartographicsLength - 1];
760
- previousBottom = getPosition(
761
- ellipsoid,
762
- prestartCartographic,
763
- minHeight,
764
- previousBottom
765
- );
766
- nextBottom = getPosition(ellipsoid, nextCartographic, minHeight, nextBottom);
767
- vertexBottom = getPosition(
768
- ellipsoid,
769
- startCartographic,
770
- minHeight,
771
- vertexBottom
772
- );
773
- vertexTop = getPosition(ellipsoid, startCartographic, maxHeight, vertexTop);
774
- if (loop) {
775
- vertexNormal = computeVertexMiterNormal(
776
- previousBottom,
777
- vertexBottom,
778
- vertexTop,
779
- nextBottom,
780
- vertexNormal
781
- );
782
- } else {
783
- vertexNormal = computeRightNormal(
784
- startCartographic,
785
- nextCartographic,
786
- maxHeight,
787
- ellipsoid,
788
- vertexNormal
789
- );
790
- }
791
- Cartesian3_default.pack(vertexNormal, normalsArray, 0);
792
- Cartesian3_default.pack(vertexBottom, bottomPositionsArray, 0);
793
- Cartesian3_default.pack(vertexTop, topPositionsArray, 0);
794
- cartographicsArray.push(startCartographic.latitude);
795
- cartographicsArray.push(startCartographic.longitude);
796
- interpolateSegment(
797
- startCartographic,
798
- nextCartographic,
799
- minHeight,
800
- maxHeight,
801
- granularity,
802
- arcType,
803
- ellipsoid,
804
- normalsArray,
805
- bottomPositionsArray,
806
- topPositionsArray,
807
- cartographicsArray
808
- );
809
- for (i = 1; i < cartographicsLength - 1; ++i) {
810
- previousBottom = Cartesian3_default.clone(vertexBottom, previousBottom);
811
- vertexBottom = Cartesian3_default.clone(nextBottom, vertexBottom);
812
- const vertexCartographic = cartographics[i];
813
- getPosition(ellipsoid, vertexCartographic, maxHeight, vertexTop);
814
- getPosition(ellipsoid, cartographics[i + 1], minHeight, nextBottom);
815
- computeVertexMiterNormal(
816
- previousBottom,
817
- vertexBottom,
818
- vertexTop,
819
- nextBottom,
820
- vertexNormal
821
- );
822
- index = normalsArray.length;
823
- Cartesian3_default.pack(vertexNormal, normalsArray, index);
824
- Cartesian3_default.pack(vertexBottom, bottomPositionsArray, index);
825
- Cartesian3_default.pack(vertexTop, topPositionsArray, index);
826
- cartographicsArray.push(vertexCartographic.latitude);
827
- cartographicsArray.push(vertexCartographic.longitude);
828
- interpolateSegment(
829
- cartographics[i],
830
- cartographics[i + 1],
831
- minHeight,
832
- maxHeight,
833
- granularity,
834
- arcType,
835
- ellipsoid,
836
- normalsArray,
837
- bottomPositionsArray,
838
- topPositionsArray,
839
- cartographicsArray
840
- );
841
- }
842
- const endCartographic = cartographics[cartographicsLength - 1];
843
- const preEndCartographic = cartographics[cartographicsLength - 2];
844
- vertexBottom = getPosition(
845
- ellipsoid,
846
- endCartographic,
847
- minHeight,
848
- vertexBottom
849
- );
850
- vertexTop = getPosition(ellipsoid, endCartographic, maxHeight, vertexTop);
851
- if (loop) {
852
- const postEndCartographic = cartographics[0];
853
- previousBottom = getPosition(
854
- ellipsoid,
855
- preEndCartographic,
856
- minHeight,
857
- previousBottom
858
- );
859
- nextBottom = getPosition(
860
- ellipsoid,
861
- postEndCartographic,
862
- minHeight,
863
- nextBottom
864
- );
865
- vertexNormal = computeVertexMiterNormal(
866
- previousBottom,
867
- vertexBottom,
868
- vertexTop,
869
- nextBottom,
870
- vertexNormal
871
- );
872
- } else {
873
- vertexNormal = computeRightNormal(
874
- preEndCartographic,
875
- endCartographic,
876
- maxHeight,
877
- ellipsoid,
878
- vertexNormal
879
- );
880
- }
881
- index = normalsArray.length;
882
- Cartesian3_default.pack(vertexNormal, normalsArray, index);
883
- Cartesian3_default.pack(vertexBottom, bottomPositionsArray, index);
884
- Cartesian3_default.pack(vertexTop, topPositionsArray, index);
885
- cartographicsArray.push(endCartographic.latitude);
886
- cartographicsArray.push(endCartographic.longitude);
887
- if (loop) {
888
- interpolateSegment(
889
- endCartographic,
890
- startCartographic,
891
- minHeight,
892
- maxHeight,
893
- granularity,
894
- arcType,
895
- ellipsoid,
896
- normalsArray,
897
- bottomPositionsArray,
898
- topPositionsArray,
899
- cartographicsArray
900
- );
901
- index = normalsArray.length;
902
- for (i = 0; i < 3; ++i) {
903
- normalsArray[index + i] = normalsArray[i];
904
- bottomPositionsArray[index + i] = bottomPositionsArray[i];
905
- topPositionsArray[index + i] = topPositionsArray[i];
906
- }
907
- cartographicsArray.push(startCartographic.latitude);
908
- cartographicsArray.push(startCartographic.longitude);
909
- }
910
- return generateGeometryAttributes(
911
- loop,
912
- projection,
913
- bottomPositionsArray,
914
- topPositionsArray,
915
- normalsArray,
916
- cartographicsArray,
917
- compute2dAttributes
918
- );
919
- };
920
- var lineDirectionScratch = new Cartesian3_default();
921
- var matrix3Scratch = new Matrix3_default();
922
- var quaternionScratch = new Quaternion_default();
923
- function breakMiter(endGeometryNormal, startBottom, endBottom, endTop) {
924
- const lineDirection = direction(endBottom, startBottom, lineDirectionScratch);
925
- const dot = Cartesian3_default.dot(lineDirection, endGeometryNormal);
926
- if (dot > MITER_BREAK_SMALL || dot < MITER_BREAK_LARGE) {
927
- const vertexUp = direction(endTop, endBottom, vertexUpScratch);
928
- const angle = dot < MITER_BREAK_LARGE ? Math_default.PI_OVER_TWO : -Math_default.PI_OVER_TWO;
929
- const quaternion = Quaternion_default.fromAxisAngle(
930
- vertexUp,
931
- angle,
932
- quaternionScratch
933
- );
934
- const rotationMatrix = Matrix3_default.fromQuaternion(quaternion, matrix3Scratch);
935
- Matrix3_default.multiplyByVector(
936
- rotationMatrix,
937
- endGeometryNormal,
938
- endGeometryNormal
939
- );
940
- return true;
941
- }
942
- return false;
943
- }
944
- var endPosCartographicScratch = new Cartographic_default();
945
- var normalStartpointScratch = new Cartesian3_default();
946
- var normalEndpointScratch = new Cartesian3_default();
947
- function projectNormal(projection, cartographic, normal, projectedPosition, result) {
948
- const position = Cartographic_default.toCartesian(
949
- cartographic,
950
- projection._ellipsoid,
951
- normalStartpointScratch
952
- );
953
- let normalEndpoint = Cartesian3_default.add(position, normal, normalEndpointScratch);
954
- let flipNormal = false;
955
- const ellipsoid = projection._ellipsoid;
956
- let normalEndpointCartographic = ellipsoid.cartesianToCartographic(
957
- normalEndpoint,
958
- endPosCartographicScratch
959
- );
960
- if (Math.abs(cartographic.longitude - normalEndpointCartographic.longitude) > Math_default.PI_OVER_TWO) {
961
- flipNormal = true;
962
- normalEndpoint = Cartesian3_default.subtract(
963
- position,
964
- normal,
965
- normalEndpointScratch
966
- );
967
- normalEndpointCartographic = ellipsoid.cartesianToCartographic(
968
- normalEndpoint,
969
- endPosCartographicScratch
970
- );
971
- }
972
- normalEndpointCartographic.height = 0;
973
- const normalEndpointProjected = projection.project(
974
- normalEndpointCartographic,
975
- result
976
- );
977
- result = Cartesian3_default.subtract(
978
- normalEndpointProjected,
979
- projectedPosition,
980
- result
981
- );
982
- result.z = 0;
983
- result = Cartesian3_default.normalize(result, result);
984
- if (flipNormal) {
985
- Cartesian3_default.negate(result, result);
986
- }
987
- return result;
988
- }
989
- var adjustHeightNormalScratch = new Cartesian3_default();
990
- var adjustHeightOffsetScratch = new Cartesian3_default();
991
- function adjustHeights(bottom, top, minHeight, maxHeight, adjustHeightBottom, adjustHeightTop) {
992
- const adjustHeightNormal = Cartesian3_default.subtract(
993
- top,
994
- bottom,
995
- adjustHeightNormalScratch
996
- );
997
- Cartesian3_default.normalize(adjustHeightNormal, adjustHeightNormal);
998
- const distanceForBottom = minHeight - WALL_INITIAL_MIN_HEIGHT;
999
- let adjustHeightOffset = Cartesian3_default.multiplyByScalar(
1000
- adjustHeightNormal,
1001
- distanceForBottom,
1002
- adjustHeightOffsetScratch
1003
- );
1004
- Cartesian3_default.add(bottom, adjustHeightOffset, adjustHeightBottom);
1005
- const distanceForTop = maxHeight - WALL_INITIAL_MAX_HEIGHT;
1006
- adjustHeightOffset = Cartesian3_default.multiplyByScalar(
1007
- adjustHeightNormal,
1008
- distanceForTop,
1009
- adjustHeightOffsetScratch
1010
- );
1011
- Cartesian3_default.add(top, adjustHeightOffset, adjustHeightTop);
1012
- }
1013
- var nudgeDirectionScratch = new Cartesian3_default();
1014
- function nudgeXZ(start, end) {
1015
- const startToXZdistance = Plane_default.getPointDistance(XZ_PLANE, start);
1016
- const endToXZdistance = Plane_default.getPointDistance(XZ_PLANE, end);
1017
- let offset = nudgeDirectionScratch;
1018
- if (Math_default.equalsEpsilon(startToXZdistance, 0, Math_default.EPSILON2)) {
1019
- offset = direction(end, start, offset);
1020
- Cartesian3_default.multiplyByScalar(offset, Math_default.EPSILON2, offset);
1021
- Cartesian3_default.add(start, offset, start);
1022
- } else if (Math_default.equalsEpsilon(endToXZdistance, 0, Math_default.EPSILON2)) {
1023
- offset = direction(start, end, offset);
1024
- Cartesian3_default.multiplyByScalar(offset, Math_default.EPSILON2, offset);
1025
- Cartesian3_default.add(end, offset, end);
1026
- }
1027
- }
1028
- function nudgeCartographic(start, end) {
1029
- const absStartLon = Math.abs(start.longitude);
1030
- const absEndLon = Math.abs(end.longitude);
1031
- if (Math_default.equalsEpsilon(absStartLon, Math_default.PI, Math_default.EPSILON11)) {
1032
- const endSign = Math_default.sign(end.longitude);
1033
- start.longitude = endSign * (absStartLon - Math_default.EPSILON11);
1034
- return 1;
1035
- } else if (Math_default.equalsEpsilon(absEndLon, Math_default.PI, Math_default.EPSILON11)) {
1036
- const startSign = Math_default.sign(start.longitude);
1037
- end.longitude = startSign * (absEndLon - Math_default.EPSILON11);
1038
- return 2;
1039
- }
1040
- return 0;
1041
- }
1042
- var startCartographicScratch = new Cartographic_default();
1043
- var endCartographicScratch = new Cartographic_default();
1044
- var segmentStartTopScratch = new Cartesian3_default();
1045
- var segmentEndTopScratch = new Cartesian3_default();
1046
- var segmentStartBottomScratch = new Cartesian3_default();
1047
- var segmentEndBottomScratch = new Cartesian3_default();
1048
- var segmentStartNormalScratch = new Cartesian3_default();
1049
- var segmentEndNormalScratch = new Cartesian3_default();
1050
- var getHeightCartographics = [
1051
- startCartographicScratch,
1052
- endCartographicScratch
1053
- ];
1054
- var getHeightRectangleScratch = new Rectangle_default();
1055
- var adjustHeightStartTopScratch = new Cartesian3_default();
1056
- var adjustHeightEndTopScratch = new Cartesian3_default();
1057
- var adjustHeightStartBottomScratch = new Cartesian3_default();
1058
- var adjustHeightEndBottomScratch = new Cartesian3_default();
1059
- var segmentStart2DScratch = new Cartesian3_default();
1060
- var segmentEnd2DScratch = new Cartesian3_default();
1061
- var segmentStartNormal2DScratch = new Cartesian3_default();
1062
- var segmentEndNormal2DScratch = new Cartesian3_default();
1063
- var offsetScratch = new Cartesian3_default();
1064
- var startUpScratch = new Cartesian3_default();
1065
- var endUpScratch = new Cartesian3_default();
1066
- var rightScratch = new Cartesian3_default();
1067
- var startPlaneNormalScratch = new Cartesian3_default();
1068
- var endPlaneNormalScratch = new Cartesian3_default();
1069
- var encodeScratch = new EncodedCartesian3_default();
1070
- var encodeScratch2D = new EncodedCartesian3_default();
1071
- var forwardOffset2DScratch = new Cartesian3_default();
1072
- var right2DScratch = new Cartesian3_default();
1073
- var normalNudgeScratch = new Cartesian3_default();
1074
- var scratchBoundingSpheres = [new BoundingSphere_default(), new BoundingSphere_default()];
1075
- var REFERENCE_INDICES = [
1076
- 0,
1077
- 2,
1078
- 1,
1079
- 0,
1080
- 3,
1081
- 2,
1082
- // right
1083
- 0,
1084
- 7,
1085
- 3,
1086
- 0,
1087
- 4,
1088
- 7,
1089
- // start
1090
- 0,
1091
- 5,
1092
- 4,
1093
- 0,
1094
- 1,
1095
- 5,
1096
- // bottom
1097
- 5,
1098
- 7,
1099
- 4,
1100
- 5,
1101
- 6,
1102
- 7,
1103
- // left
1104
- 5,
1105
- 2,
1106
- 6,
1107
- 5,
1108
- 1,
1109
- 2,
1110
- // end
1111
- 3,
1112
- 6,
1113
- 2,
1114
- 3,
1115
- 7,
1116
- 6
1117
- // top
1118
- ];
1119
- var REFERENCE_INDICES_LENGTH = REFERENCE_INDICES.length;
1120
- function generateGeometryAttributes(loop, projection, bottomPositionsArray, topPositionsArray, normalsArray, cartographicsArray, compute2dAttributes) {
1121
- let i;
1122
- let index;
1123
- const ellipsoid = projection._ellipsoid;
1124
- const segmentCount = bottomPositionsArray.length / 3 - 1;
1125
- const vertexCount = segmentCount * 8;
1126
- const arraySizeVec4 = vertexCount * 4;
1127
- const indexCount = segmentCount * 36;
1128
- const indices = vertexCount > 65535 ? new Uint32Array(indexCount) : new Uint16Array(indexCount);
1129
- const positionsArray = new Float64Array(vertexCount * 3);
1130
- const startHiAndForwardOffsetX = new Float32Array(arraySizeVec4);
1131
- const startLoAndForwardOffsetY = new Float32Array(arraySizeVec4);
1132
- const startNormalAndForwardOffsetZ = new Float32Array(arraySizeVec4);
1133
- const endNormalAndTextureCoordinateNormalizationX = new Float32Array(
1134
- arraySizeVec4
1135
- );
1136
- const rightNormalAndTextureCoordinateNormalizationY = new Float32Array(
1137
- arraySizeVec4
1138
- );
1139
- let startHiLo2D;
1140
- let offsetAndRight2D;
1141
- let startEndNormals2D;
1142
- let texcoordNormalization2D;
1143
- if (compute2dAttributes) {
1144
- startHiLo2D = new Float32Array(arraySizeVec4);
1145
- offsetAndRight2D = new Float32Array(arraySizeVec4);
1146
- startEndNormals2D = new Float32Array(arraySizeVec4);
1147
- texcoordNormalization2D = new Float32Array(vertexCount * 2);
1148
- }
1149
- const cartographicsLength = cartographicsArray.length / 2;
1150
- let length2D = 0;
1151
- const startCartographic = startCartographicScratch;
1152
- startCartographic.height = 0;
1153
- const endCartographic = endCartographicScratch;
1154
- endCartographic.height = 0;
1155
- let segmentStartCartesian = segmentStartTopScratch;
1156
- let segmentEndCartesian = segmentEndTopScratch;
1157
- if (compute2dAttributes) {
1158
- index = 0;
1159
- for (i = 1; i < cartographicsLength; i++) {
1160
- startCartographic.latitude = cartographicsArray[index];
1161
- startCartographic.longitude = cartographicsArray[index + 1];
1162
- endCartographic.latitude = cartographicsArray[index + 2];
1163
- endCartographic.longitude = cartographicsArray[index + 3];
1164
- segmentStartCartesian = projection.project(
1165
- startCartographic,
1166
- segmentStartCartesian
1167
- );
1168
- segmentEndCartesian = projection.project(
1169
- endCartographic,
1170
- segmentEndCartesian
1171
- );
1172
- length2D += Cartesian3_default.distance(
1173
- segmentStartCartesian,
1174
- segmentEndCartesian
1175
- );
1176
- index += 2;
1177
- }
1178
- }
1179
- const positionsLength = topPositionsArray.length / 3;
1180
- segmentEndCartesian = Cartesian3_default.unpack(
1181
- topPositionsArray,
1182
- 0,
1183
- segmentEndCartesian
1184
- );
1185
- let length3D = 0;
1186
- index = 3;
1187
- for (i = 1; i < positionsLength; i++) {
1188
- segmentStartCartesian = Cartesian3_default.clone(
1189
- segmentEndCartesian,
1190
- segmentStartCartesian
1191
- );
1192
- segmentEndCartesian = Cartesian3_default.unpack(
1193
- topPositionsArray,
1194
- index,
1195
- segmentEndCartesian
1196
- );
1197
- length3D += Cartesian3_default.distance(segmentStartCartesian, segmentEndCartesian);
1198
- index += 3;
1199
- }
1200
- let j;
1201
- index = 3;
1202
- let cartographicsIndex = 0;
1203
- let vec2sWriteIndex = 0;
1204
- let vec3sWriteIndex = 0;
1205
- let vec4sWriteIndex = 0;
1206
- let miterBroken = false;
1207
- let endBottom = Cartesian3_default.unpack(
1208
- bottomPositionsArray,
1209
- 0,
1210
- segmentEndBottomScratch
1211
- );
1212
- let endTop = Cartesian3_default.unpack(topPositionsArray, 0, segmentEndTopScratch);
1213
- let endGeometryNormal = Cartesian3_default.unpack(
1214
- normalsArray,
1215
- 0,
1216
- segmentEndNormalScratch
1217
- );
1218
- if (loop) {
1219
- const preEndBottom = Cartesian3_default.unpack(
1220
- bottomPositionsArray,
1221
- bottomPositionsArray.length - 6,
1222
- segmentStartBottomScratch
1223
- );
1224
- if (breakMiter(endGeometryNormal, preEndBottom, endBottom, endTop)) {
1225
- endGeometryNormal = Cartesian3_default.negate(
1226
- endGeometryNormal,
1227
- endGeometryNormal
1228
- );
1229
- }
1230
- }
1231
- let lengthSoFar3D = 0;
1232
- let lengthSoFar2D = 0;
1233
- let sumHeights = 0;
1234
- for (i = 0; i < segmentCount; i++) {
1235
- const startBottom = Cartesian3_default.clone(endBottom, segmentStartBottomScratch);
1236
- const startTop = Cartesian3_default.clone(endTop, segmentStartTopScratch);
1237
- let startGeometryNormal = Cartesian3_default.clone(
1238
- endGeometryNormal,
1239
- segmentStartNormalScratch
1240
- );
1241
- if (miterBroken) {
1242
- startGeometryNormal = Cartesian3_default.negate(
1243
- startGeometryNormal,
1244
- startGeometryNormal
1245
- );
1246
- }
1247
- endBottom = Cartesian3_default.unpack(
1248
- bottomPositionsArray,
1249
- index,
1250
- segmentEndBottomScratch
1251
- );
1252
- endTop = Cartesian3_default.unpack(topPositionsArray, index, segmentEndTopScratch);
1253
- endGeometryNormal = Cartesian3_default.unpack(
1254
- normalsArray,
1255
- index,
1256
- segmentEndNormalScratch
1257
- );
1258
- miterBroken = breakMiter(endGeometryNormal, startBottom, endBottom, endTop);
1259
- startCartographic.latitude = cartographicsArray[cartographicsIndex];
1260
- startCartographic.longitude = cartographicsArray[cartographicsIndex + 1];
1261
- endCartographic.latitude = cartographicsArray[cartographicsIndex + 2];
1262
- endCartographic.longitude = cartographicsArray[cartographicsIndex + 3];
1263
- let start2D;
1264
- let end2D;
1265
- let startGeometryNormal2D;
1266
- let endGeometryNormal2D;
1267
- if (compute2dAttributes) {
1268
- const nudgeResult = nudgeCartographic(startCartographic, endCartographic);
1269
- start2D = projection.project(startCartographic, segmentStart2DScratch);
1270
- end2D = projection.project(endCartographic, segmentEnd2DScratch);
1271
- const direction2D = direction(end2D, start2D, forwardOffset2DScratch);
1272
- direction2D.y = Math.abs(direction2D.y);
1273
- startGeometryNormal2D = segmentStartNormal2DScratch;
1274
- endGeometryNormal2D = segmentEndNormal2DScratch;
1275
- if (nudgeResult === 0 || Cartesian3_default.dot(direction2D, Cartesian3_default.UNIT_Y) > MITER_BREAK_SMALL) {
1276
- startGeometryNormal2D = projectNormal(
1277
- projection,
1278
- startCartographic,
1279
- startGeometryNormal,
1280
- start2D,
1281
- segmentStartNormal2DScratch
1282
- );
1283
- endGeometryNormal2D = projectNormal(
1284
- projection,
1285
- endCartographic,
1286
- endGeometryNormal,
1287
- end2D,
1288
- segmentEndNormal2DScratch
1289
- );
1290
- } else if (nudgeResult === 1) {
1291
- endGeometryNormal2D = projectNormal(
1292
- projection,
1293
- endCartographic,
1294
- endGeometryNormal,
1295
- end2D,
1296
- segmentEndNormal2DScratch
1297
- );
1298
- startGeometryNormal2D.x = 0;
1299
- startGeometryNormal2D.y = Math_default.sign(
1300
- startCartographic.longitude - Math.abs(endCartographic.longitude)
1301
- );
1302
- startGeometryNormal2D.z = 0;
1303
- } else {
1304
- startGeometryNormal2D = projectNormal(
1305
- projection,
1306
- startCartographic,
1307
- startGeometryNormal,
1308
- start2D,
1309
- segmentStartNormal2DScratch
1310
- );
1311
- endGeometryNormal2D.x = 0;
1312
- endGeometryNormal2D.y = Math_default.sign(
1313
- startCartographic.longitude - endCartographic.longitude
1314
- );
1315
- endGeometryNormal2D.z = 0;
1316
- }
1317
- }
1318
- const segmentLength3D = Cartesian3_default.distance(startTop, endTop);
1319
- const encodedStart = EncodedCartesian3_default.fromCartesian(
1320
- startBottom,
1321
- encodeScratch
1322
- );
1323
- const forwardOffset = Cartesian3_default.subtract(
1324
- endBottom,
1325
- startBottom,
1326
- offsetScratch
1327
- );
1328
- const forward = Cartesian3_default.normalize(forwardOffset, rightScratch);
1329
- let startUp = Cartesian3_default.subtract(startTop, startBottom, startUpScratch);
1330
- startUp = Cartesian3_default.normalize(startUp, startUp);
1331
- let rightNormal = Cartesian3_default.cross(forward, startUp, rightScratch);
1332
- rightNormal = Cartesian3_default.normalize(rightNormal, rightNormal);
1333
- let startPlaneNormal = Cartesian3_default.cross(
1334
- startUp,
1335
- startGeometryNormal,
1336
- startPlaneNormalScratch
1337
- );
1338
- startPlaneNormal = Cartesian3_default.normalize(startPlaneNormal, startPlaneNormal);
1339
- let endUp = Cartesian3_default.subtract(endTop, endBottom, endUpScratch);
1340
- endUp = Cartesian3_default.normalize(endUp, endUp);
1341
- let endPlaneNormal = Cartesian3_default.cross(
1342
- endGeometryNormal,
1343
- endUp,
1344
- endPlaneNormalScratch
1345
- );
1346
- endPlaneNormal = Cartesian3_default.normalize(endPlaneNormal, endPlaneNormal);
1347
- const texcoordNormalization3DX = segmentLength3D / length3D;
1348
- const texcoordNormalization3DY = lengthSoFar3D / length3D;
1349
- let segmentLength2D = 0;
1350
- let encodedStart2D;
1351
- let forwardOffset2D;
1352
- let right2D;
1353
- let texcoordNormalization2DX = 0;
1354
- let texcoordNormalization2DY = 0;
1355
- if (compute2dAttributes) {
1356
- segmentLength2D = Cartesian3_default.distance(start2D, end2D);
1357
- encodedStart2D = EncodedCartesian3_default.fromCartesian(
1358
- start2D,
1359
- encodeScratch2D
1360
- );
1361
- forwardOffset2D = Cartesian3_default.subtract(
1362
- end2D,
1363
- start2D,
1364
- forwardOffset2DScratch
1365
- );
1366
- right2D = Cartesian3_default.normalize(forwardOffset2D, right2DScratch);
1367
- const swap = right2D.x;
1368
- right2D.x = right2D.y;
1369
- right2D.y = -swap;
1370
- texcoordNormalization2DX = segmentLength2D / length2D;
1371
- texcoordNormalization2DY = lengthSoFar2D / length2D;
1372
- }
1373
- for (j = 0; j < 8; j++) {
1374
- const vec4Index = vec4sWriteIndex + j * 4;
1375
- const vec2Index = vec2sWriteIndex + j * 2;
1376
- const wIndex = vec4Index + 3;
1377
- const rightPlaneSide = j < 4 ? 1 : -1;
1378
- const topBottomSide = j === 2 || j === 3 || j === 6 || j === 7 ? 1 : -1;
1379
- Cartesian3_default.pack(encodedStart.high, startHiAndForwardOffsetX, vec4Index);
1380
- startHiAndForwardOffsetX[wIndex] = forwardOffset.x;
1381
- Cartesian3_default.pack(encodedStart.low, startLoAndForwardOffsetY, vec4Index);
1382
- startLoAndForwardOffsetY[wIndex] = forwardOffset.y;
1383
- Cartesian3_default.pack(
1384
- startPlaneNormal,
1385
- startNormalAndForwardOffsetZ,
1386
- vec4Index
1387
- );
1388
- startNormalAndForwardOffsetZ[wIndex] = forwardOffset.z;
1389
- Cartesian3_default.pack(
1390
- endPlaneNormal,
1391
- endNormalAndTextureCoordinateNormalizationX,
1392
- vec4Index
1393
- );
1394
- endNormalAndTextureCoordinateNormalizationX[wIndex] = texcoordNormalization3DX * rightPlaneSide;
1395
- Cartesian3_default.pack(
1396
- rightNormal,
1397
- rightNormalAndTextureCoordinateNormalizationY,
1398
- vec4Index
1399
- );
1400
- let texcoordNormalization = texcoordNormalization3DY * topBottomSide;
1401
- if (texcoordNormalization === 0 && topBottomSide < 0) {
1402
- texcoordNormalization = 9;
1403
- }
1404
- rightNormalAndTextureCoordinateNormalizationY[wIndex] = texcoordNormalization;
1405
- if (compute2dAttributes) {
1406
- startHiLo2D[vec4Index] = encodedStart2D.high.x;
1407
- startHiLo2D[vec4Index + 1] = encodedStart2D.high.y;
1408
- startHiLo2D[vec4Index + 2] = encodedStart2D.low.x;
1409
- startHiLo2D[vec4Index + 3] = encodedStart2D.low.y;
1410
- startEndNormals2D[vec4Index] = -startGeometryNormal2D.y;
1411
- startEndNormals2D[vec4Index + 1] = startGeometryNormal2D.x;
1412
- startEndNormals2D[vec4Index + 2] = endGeometryNormal2D.y;
1413
- startEndNormals2D[vec4Index + 3] = -endGeometryNormal2D.x;
1414
- offsetAndRight2D[vec4Index] = forwardOffset2D.x;
1415
- offsetAndRight2D[vec4Index + 1] = forwardOffset2D.y;
1416
- offsetAndRight2D[vec4Index + 2] = right2D.x;
1417
- offsetAndRight2D[vec4Index + 3] = right2D.y;
1418
- texcoordNormalization2D[vec2Index] = texcoordNormalization2DX * rightPlaneSide;
1419
- texcoordNormalization = texcoordNormalization2DY * topBottomSide;
1420
- if (texcoordNormalization === 0 && topBottomSide < 0) {
1421
- texcoordNormalization = 9;
1422
- }
1423
- texcoordNormalization2D[vec2Index + 1] = texcoordNormalization;
1424
- }
1425
- }
1426
- const adjustHeightStartBottom = adjustHeightStartBottomScratch;
1427
- const adjustHeightEndBottom = adjustHeightEndBottomScratch;
1428
- const adjustHeightStartTop = adjustHeightStartTopScratch;
1429
- const adjustHeightEndTop = adjustHeightEndTopScratch;
1430
- const getHeightsRectangle = Rectangle_default.fromCartographicArray(
1431
- getHeightCartographics,
1432
- getHeightRectangleScratch
1433
- );
1434
- const minMaxHeights = ApproximateTerrainHeights_default.getMinimumMaximumHeights(
1435
- getHeightsRectangle,
1436
- ellipsoid
1437
- );
1438
- const minHeight = minMaxHeights.minimumTerrainHeight;
1439
- const maxHeight = minMaxHeights.maximumTerrainHeight;
1440
- sumHeights += Math.abs(minHeight);
1441
- sumHeights += Math.abs(maxHeight);
1442
- adjustHeights(
1443
- startBottom,
1444
- startTop,
1445
- minHeight,
1446
- maxHeight,
1447
- adjustHeightStartBottom,
1448
- adjustHeightStartTop
1449
- );
1450
- adjustHeights(
1451
- endBottom,
1452
- endTop,
1453
- minHeight,
1454
- maxHeight,
1455
- adjustHeightEndBottom,
1456
- adjustHeightEndTop
1457
- );
1458
- let normalNudge = Cartesian3_default.multiplyByScalar(
1459
- rightNormal,
1460
- Math_default.EPSILON5,
1461
- normalNudgeScratch
1462
- );
1463
- Cartesian3_default.add(
1464
- adjustHeightStartBottom,
1465
- normalNudge,
1466
- adjustHeightStartBottom
1467
- );
1468
- Cartesian3_default.add(adjustHeightEndBottom, normalNudge, adjustHeightEndBottom);
1469
- Cartesian3_default.add(adjustHeightStartTop, normalNudge, adjustHeightStartTop);
1470
- Cartesian3_default.add(adjustHeightEndTop, normalNudge, adjustHeightEndTop);
1471
- nudgeXZ(adjustHeightStartBottom, adjustHeightEndBottom);
1472
- nudgeXZ(adjustHeightStartTop, adjustHeightEndTop);
1473
- Cartesian3_default.pack(adjustHeightStartBottom, positionsArray, vec3sWriteIndex);
1474
- Cartesian3_default.pack(adjustHeightEndBottom, positionsArray, vec3sWriteIndex + 3);
1475
- Cartesian3_default.pack(adjustHeightEndTop, positionsArray, vec3sWriteIndex + 6);
1476
- Cartesian3_default.pack(adjustHeightStartTop, positionsArray, vec3sWriteIndex + 9);
1477
- normalNudge = Cartesian3_default.multiplyByScalar(
1478
- rightNormal,
1479
- -2 * Math_default.EPSILON5,
1480
- normalNudgeScratch
1481
- );
1482
- Cartesian3_default.add(
1483
- adjustHeightStartBottom,
1484
- normalNudge,
1485
- adjustHeightStartBottom
1486
- );
1487
- Cartesian3_default.add(adjustHeightEndBottom, normalNudge, adjustHeightEndBottom);
1488
- Cartesian3_default.add(adjustHeightStartTop, normalNudge, adjustHeightStartTop);
1489
- Cartesian3_default.add(adjustHeightEndTop, normalNudge, adjustHeightEndTop);
1490
- nudgeXZ(adjustHeightStartBottom, adjustHeightEndBottom);
1491
- nudgeXZ(adjustHeightStartTop, adjustHeightEndTop);
1492
- Cartesian3_default.pack(
1493
- adjustHeightStartBottom,
1494
- positionsArray,
1495
- vec3sWriteIndex + 12
1496
- );
1497
- Cartesian3_default.pack(
1498
- adjustHeightEndBottom,
1499
- positionsArray,
1500
- vec3sWriteIndex + 15
1501
- );
1502
- Cartesian3_default.pack(adjustHeightEndTop, positionsArray, vec3sWriteIndex + 18);
1503
- Cartesian3_default.pack(adjustHeightStartTop, positionsArray, vec3sWriteIndex + 21);
1504
- cartographicsIndex += 2;
1505
- index += 3;
1506
- vec2sWriteIndex += 16;
1507
- vec3sWriteIndex += 24;
1508
- vec4sWriteIndex += 32;
1509
- lengthSoFar3D += segmentLength3D;
1510
- lengthSoFar2D += segmentLength2D;
1511
- }
1512
- index = 0;
1513
- let indexOffset = 0;
1514
- for (i = 0; i < segmentCount; i++) {
1515
- for (j = 0; j < REFERENCE_INDICES_LENGTH; j++) {
1516
- indices[index + j] = REFERENCE_INDICES[j] + indexOffset;
1517
- }
1518
- indexOffset += 8;
1519
- index += REFERENCE_INDICES_LENGTH;
1520
- }
1521
- const boundingSpheres = scratchBoundingSpheres;
1522
- BoundingSphere_default.fromVertices(
1523
- bottomPositionsArray,
1524
- Cartesian3_default.ZERO,
1525
- 3,
1526
- boundingSpheres[0]
1527
- );
1528
- BoundingSphere_default.fromVertices(
1529
- topPositionsArray,
1530
- Cartesian3_default.ZERO,
1531
- 3,
1532
- boundingSpheres[1]
1533
- );
1534
- const boundingSphere = BoundingSphere_default.fromBoundingSpheres(boundingSpheres);
1535
- boundingSphere.radius += sumHeights / (segmentCount * 2);
1536
- const attributes = {
1537
- position: new GeometryAttribute_default({
1538
- componentDatatype: ComponentDatatype_default.DOUBLE,
1539
- componentsPerAttribute: 3,
1540
- normalize: false,
1541
- values: positionsArray
1542
- }),
1543
- startHiAndForwardOffsetX: getVec4GeometryAttribute(
1544
- startHiAndForwardOffsetX
1545
- ),
1546
- startLoAndForwardOffsetY: getVec4GeometryAttribute(
1547
- startLoAndForwardOffsetY
1548
- ),
1549
- startNormalAndForwardOffsetZ: getVec4GeometryAttribute(
1550
- startNormalAndForwardOffsetZ
1551
- ),
1552
- endNormalAndTextureCoordinateNormalizationX: getVec4GeometryAttribute(
1553
- endNormalAndTextureCoordinateNormalizationX
1554
- ),
1555
- rightNormalAndTextureCoordinateNormalizationY: getVec4GeometryAttribute(
1556
- rightNormalAndTextureCoordinateNormalizationY
1557
- )
1558
- };
1559
- if (compute2dAttributes) {
1560
- attributes.startHiLo2D = getVec4GeometryAttribute(startHiLo2D);
1561
- attributes.offsetAndRight2D = getVec4GeometryAttribute(offsetAndRight2D);
1562
- attributes.startEndNormals2D = getVec4GeometryAttribute(startEndNormals2D);
1563
- attributes.texcoordNormalization2D = new GeometryAttribute_default({
1564
- componentDatatype: ComponentDatatype_default.FLOAT,
1565
- componentsPerAttribute: 2,
1566
- normalize: false,
1567
- values: texcoordNormalization2D
1568
- });
1569
- }
1570
- return new Geometry_default({
1571
- attributes,
1572
- indices,
1573
- boundingSphere
1574
- });
1575
- }
1576
- function getVec4GeometryAttribute(typedArray) {
1577
- return new GeometryAttribute_default({
1578
- componentDatatype: ComponentDatatype_default.FLOAT,
1579
- componentsPerAttribute: 4,
1580
- normalize: false,
1581
- values: typedArray
1582
- });
1583
- }
1584
- GroundPolylineGeometry._projectNormal = projectNormal;
1585
- var GroundPolylineGeometry_default = GroundPolylineGeometry;
1586
-
1587
- // packages/engine/Source/Workers/createGroundPolylineGeometry.js
1588
- function createGroundPolylineGeometry(groundPolylineGeometry, offset) {
1589
- return ApproximateTerrainHeights_default.initialize().then(function() {
1590
- if (defined_default(offset)) {
1591
- groundPolylineGeometry = GroundPolylineGeometry_default.unpack(
1592
- groundPolylineGeometry,
1593
- offset
1594
- );
1595
- }
1596
- return GroundPolylineGeometry_default.createGeometry(groundPolylineGeometry);
1597
- });
1598
- }
1599
- var createGroundPolylineGeometry_default = createGroundPolylineGeometry;
1600
- export {
1601
- createGroundPolylineGeometry_default as default
1602
- };