@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,1404 +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
- BoundingRectangle_default
28
- } from "./chunk-EDIUN7V3.js";
29
- import {
30
- PolygonGeometryLibrary_default
31
- } from "./chunk-7B23DD46.js";
32
- import {
33
- ArcType_default
34
- } from "./chunk-X65Y2JSA.js";
35
- import {
36
- GeometryInstance_default
37
- } from "./chunk-SBFTVHRW.js";
38
- import {
39
- GeometryPipeline_default
40
- } from "./chunk-PV5B2YNB.js";
41
- import "./chunk-6LZBBEA7.js";
42
- import "./chunk-75UGCVME.js";
43
- import {
44
- GeometryOffsetAttribute_default
45
- } from "./chunk-6H33B6OL.js";
46
- import {
47
- VertexFormat_default
48
- } from "./chunk-I76SRIKN.js";
49
- import {
50
- EllipsoidTangentPlane_default
51
- } from "./chunk-WAS3IHIQ.js";
52
- import "./chunk-K4IMD7KH.js";
53
- import {
54
- PolygonPipeline_default,
55
- WindingOrder_default
56
- } from "./chunk-WO5ZNC7S.js";
57
- import "./chunk-HAY6YE7M.js";
58
- import "./chunk-FVYRV2T6.js";
59
- import {
60
- IntersectionTests_default,
61
- Ray_default
62
- } from "./chunk-66YGZWBI.js";
63
- import "./chunk-J4MIJCN5.js";
64
- import {
65
- IndexDatatype_default
66
- } from "./chunk-55IROWAX.js";
67
- import "./chunk-BOV6T7FO.js";
68
- import {
69
- GeometryAttribute_default,
70
- Geometry_default
71
- } from "./chunk-XOVHLPKW.js";
72
- import {
73
- BoundingSphere_default
74
- } from "./chunk-OAOREOSO.js";
75
- import "./chunk-EKMWNF4U.js";
76
- import {
77
- Quaternion_default,
78
- Rectangle_default
79
- } from "./chunk-KQIZ7AFF.js";
80
- import "./chunk-POY6ZE32.js";
81
- import {
82
- ComponentDatatype_default
83
- } from "./chunk-AL22JVIA.js";
84
- import "./chunk-5VZISKJF.js";
85
- import "./chunk-UYT2PBMV.js";
86
- import {
87
- Cartesian2_default,
88
- Cartographic_default,
89
- Ellipsoid_default
90
- } from "./chunk-YPGJSFOO.js";
91
- import {
92
- Cartesian3_default,
93
- Frozen_default,
94
- Matrix3_default
95
- } from "./chunk-QWV2DM66.js";
96
- import {
97
- Math_default
98
- } from "./chunk-6XJO625E.js";
99
- import {
100
- Check_default,
101
- DeveloperError_default
102
- } from "./chunk-KH2OWUUA.js";
103
- import {
104
- defined_default
105
- } from "./chunk-AVSQILVI.js";
106
-
107
- // packages/engine/Source/Core/Stereographic.js
108
- function Stereographic(position, tangentPlane) {
109
- this.position = position;
110
- if (!defined_default(this.position)) {
111
- this.position = new Cartesian2_default();
112
- }
113
- this.tangentPlane = tangentPlane;
114
- if (!defined_default(this.tangentPlane)) {
115
- this.tangentPlane = Stereographic.NORTH_POLE_TANGENT_PLANE;
116
- }
117
- }
118
- Object.defineProperties(Stereographic.prototype, {
119
- /**
120
- * Gets the ellipsoid.
121
- * @memberof Stereographic.prototype
122
- * @type {Ellipsoid}
123
- */
124
- ellipsoid: {
125
- get: function() {
126
- return this.tangentPlane.ellipsoid;
127
- }
128
- },
129
- /**
130
- * Gets the x coordinate
131
- * @memberof Stereographic.prototype
132
- * @type {number}
133
- */
134
- x: {
135
- get: function() {
136
- return this.position.x;
137
- }
138
- },
139
- /**
140
- * Gets the y coordinate
141
- * @memberof Stereographic.prototype
142
- * @type {number}
143
- */
144
- y: {
145
- get: function() {
146
- return this.position.y;
147
- }
148
- },
149
- /**
150
- * Computes the conformal latitude, or the ellipsoidal latitude projected onto an arbitrary sphere.
151
- * @memberof Stereographic.prototype
152
- * @type {number}
153
- */
154
- conformalLatitude: {
155
- get: function() {
156
- const r = Cartesian2_default.magnitude(this.position);
157
- const d = 2 * this.ellipsoid.maximumRadius;
158
- const sign = this.tangentPlane.plane.normal.z;
159
- return sign * (Math_default.PI_OVER_TWO - 2 * Math.atan2(r, d));
160
- }
161
- },
162
- /**
163
- * Computes the longitude
164
- * @memberof Stereographic.prototype
165
- * @type {number}
166
- */
167
- longitude: {
168
- get: function() {
169
- let longitude = Math_default.PI_OVER_TWO + Math.atan2(this.y, this.x);
170
- if (longitude > Math.PI) {
171
- longitude -= Math_default.TWO_PI;
172
- }
173
- return longitude;
174
- }
175
- }
176
- });
177
- var scratchCartographic = new Cartographic_default();
178
- var scratchCartesian = new Cartesian3_default();
179
- Stereographic.prototype.getLatitude = function(ellipsoid) {
180
- if (!defined_default(ellipsoid)) {
181
- ellipsoid = Ellipsoid_default.default;
182
- }
183
- scratchCartographic.latitude = this.conformalLatitude;
184
- scratchCartographic.longitude = this.longitude;
185
- scratchCartographic.height = 0;
186
- const cartesian = this.ellipsoid.cartographicToCartesian(
187
- scratchCartographic,
188
- scratchCartesian
189
- );
190
- ellipsoid.cartesianToCartographic(cartesian, scratchCartographic);
191
- return scratchCartographic.latitude;
192
- };
193
- var scratchProjectPointOntoPlaneRay = new Ray_default();
194
- var scratchProjectPointOntoPlaneRayDirection = new Cartesian3_default();
195
- var scratchProjectPointOntoPlaneCartesian3 = new Cartesian3_default();
196
- Stereographic.fromCartesian = function(cartesian, result) {
197
- Check_default.defined("cartesian", cartesian);
198
- const sign = Math_default.signNotZero(cartesian.z);
199
- let tangentPlane = Stereographic.NORTH_POLE_TANGENT_PLANE;
200
- let origin = Stereographic.SOUTH_POLE;
201
- if (sign < 0) {
202
- tangentPlane = Stereographic.SOUTH_POLE_TANGENT_PLANE;
203
- origin = Stereographic.NORTH_POLE;
204
- }
205
- const ray = scratchProjectPointOntoPlaneRay;
206
- ray.origin = tangentPlane.ellipsoid.scaleToGeocentricSurface(
207
- cartesian,
208
- ray.origin
209
- );
210
- ray.direction = Cartesian3_default.subtract(
211
- ray.origin,
212
- origin,
213
- scratchProjectPointOntoPlaneRayDirection
214
- );
215
- Cartesian3_default.normalize(ray.direction, ray.direction);
216
- const intersectionPoint = IntersectionTests_default.rayPlane(
217
- ray,
218
- tangentPlane.plane,
219
- scratchProjectPointOntoPlaneCartesian3
220
- );
221
- const v = Cartesian3_default.subtract(intersectionPoint, origin, intersectionPoint);
222
- const x = Cartesian3_default.dot(tangentPlane.xAxis, v);
223
- const y = sign * Cartesian3_default.dot(tangentPlane.yAxis, v);
224
- if (!defined_default(result)) {
225
- return new Stereographic(new Cartesian2_default(x, y), tangentPlane);
226
- }
227
- result.position = new Cartesian2_default(x, y);
228
- result.tangentPlane = tangentPlane;
229
- return result;
230
- };
231
- Stereographic.fromCartesianArray = function(cartesians, result) {
232
- Check_default.defined("cartesians", cartesians);
233
- const length = cartesians.length;
234
- if (!defined_default(result)) {
235
- result = new Array(length);
236
- } else {
237
- result.length = length;
238
- }
239
- for (let i = 0; i < length; i++) {
240
- result[i] = Stereographic.fromCartesian(cartesians[i], result[i]);
241
- }
242
- return result;
243
- };
244
- Stereographic.clone = function(stereographic, result) {
245
- if (!defined_default(stereographic)) {
246
- return void 0;
247
- }
248
- if (!defined_default(result)) {
249
- return new Stereographic(
250
- stereographic.position,
251
- stereographic.tangentPlane
252
- );
253
- }
254
- result.position = stereographic.position;
255
- result.tangentPlane = stereographic.tangentPlane;
256
- return result;
257
- };
258
- Stereographic.HALF_UNIT_SPHERE = Object.freeze(new Ellipsoid_default(0.5, 0.5, 0.5));
259
- Stereographic.NORTH_POLE = Object.freeze(new Cartesian3_default(0, 0, 0.5));
260
- Stereographic.SOUTH_POLE = Object.freeze(new Cartesian3_default(0, 0, -0.5));
261
- Stereographic.NORTH_POLE_TANGENT_PLANE = Object.freeze(
262
- new EllipsoidTangentPlane_default(
263
- Stereographic.NORTH_POLE,
264
- Stereographic.HALF_UNIT_SPHERE
265
- )
266
- );
267
- Stereographic.SOUTH_POLE_TANGENT_PLANE = Object.freeze(
268
- new EllipsoidTangentPlane_default(
269
- Stereographic.SOUTH_POLE,
270
- Stereographic.HALF_UNIT_SPHERE
271
- )
272
- );
273
- var Stereographic_default = Stereographic;
274
-
275
- // packages/engine/Source/Core/PolygonGeometry.js
276
- var scratchCarto1 = new Cartographic_default();
277
- var scratchCarto2 = new Cartographic_default();
278
- function adjustPosHeightsForNormal(position, p1, p2, ellipsoid) {
279
- const carto1 = ellipsoid.cartesianToCartographic(position, scratchCarto1);
280
- const height = carto1.height;
281
- const p1Carto = ellipsoid.cartesianToCartographic(p1, scratchCarto2);
282
- p1Carto.height = height;
283
- ellipsoid.cartographicToCartesian(p1Carto, p1);
284
- const p2Carto = ellipsoid.cartesianToCartographic(p2, scratchCarto2);
285
- p2Carto.height = height - 100;
286
- ellipsoid.cartographicToCartesian(p2Carto, p2);
287
- }
288
- var scratchBoundingRectangle = new BoundingRectangle_default();
289
- var scratchPosition = new Cartesian3_default();
290
- var scratchNormal = new Cartesian3_default();
291
- var scratchTangent = new Cartesian3_default();
292
- var scratchBitangent = new Cartesian3_default();
293
- var p1Scratch = new Cartesian3_default();
294
- var p2Scratch = new Cartesian3_default();
295
- var scratchPerPosNormal = new Cartesian3_default();
296
- var scratchPerPosTangent = new Cartesian3_default();
297
- var scratchPerPosBitangent = new Cartesian3_default();
298
- var appendTextureCoordinatesOrigin = new Cartesian2_default();
299
- var appendTextureCoordinatesCartesian2 = new Cartesian2_default();
300
- var appendTextureCoordinatesCartesian3 = new Cartesian3_default();
301
- var appendTextureCoordinatesQuaternion = new Quaternion_default();
302
- var appendTextureCoordinatesMatrix3 = new Matrix3_default();
303
- var tangentMatrixScratch = new Matrix3_default();
304
- function computeAttributes(options) {
305
- const vertexFormat = options.vertexFormat;
306
- const geometry = options.geometry;
307
- const shadowVolume = options.shadowVolume;
308
- const flatPositions = geometry.attributes.position.values;
309
- const flatTexcoords = defined_default(geometry.attributes.st) ? geometry.attributes.st.values : void 0;
310
- let length = flatPositions.length;
311
- const wall = options.wall;
312
- const top = options.top || wall;
313
- const bottom = options.bottom || wall;
314
- if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent || shadowVolume) {
315
- const boundingRectangle = options.boundingRectangle;
316
- const rotationAxis = options.rotationAxis;
317
- const projectTo2d = options.projectTo2d;
318
- const ellipsoid = options.ellipsoid;
319
- const stRotation = options.stRotation;
320
- const perPositionHeight = options.perPositionHeight;
321
- const origin = appendTextureCoordinatesOrigin;
322
- origin.x = boundingRectangle.x;
323
- origin.y = boundingRectangle.y;
324
- const textureCoordinates = vertexFormat.st ? new Float32Array(2 * (length / 3)) : void 0;
325
- let normals;
326
- if (vertexFormat.normal) {
327
- if (perPositionHeight && top && !wall) {
328
- normals = geometry.attributes.normal.values;
329
- } else {
330
- normals = new Float32Array(length);
331
- }
332
- }
333
- const tangents = vertexFormat.tangent ? new Float32Array(length) : void 0;
334
- const bitangents = vertexFormat.bitangent ? new Float32Array(length) : void 0;
335
- const extrudeNormals = shadowVolume ? new Float32Array(length) : void 0;
336
- let textureCoordIndex = 0;
337
- let attrIndex = 0;
338
- let normal = scratchNormal;
339
- let tangent = scratchTangent;
340
- let bitangent = scratchBitangent;
341
- let recomputeNormal = true;
342
- let textureMatrix = appendTextureCoordinatesMatrix3;
343
- let tangentRotationMatrix = tangentMatrixScratch;
344
- if (stRotation !== 0) {
345
- let rotation = Quaternion_default.fromAxisAngle(
346
- rotationAxis,
347
- stRotation,
348
- appendTextureCoordinatesQuaternion
349
- );
350
- textureMatrix = Matrix3_default.fromQuaternion(rotation, textureMatrix);
351
- rotation = Quaternion_default.fromAxisAngle(
352
- rotationAxis,
353
- -stRotation,
354
- appendTextureCoordinatesQuaternion
355
- );
356
- tangentRotationMatrix = Matrix3_default.fromQuaternion(
357
- rotation,
358
- tangentRotationMatrix
359
- );
360
- } else {
361
- textureMatrix = Matrix3_default.clone(Matrix3_default.IDENTITY, textureMatrix);
362
- tangentRotationMatrix = Matrix3_default.clone(
363
- Matrix3_default.IDENTITY,
364
- tangentRotationMatrix
365
- );
366
- }
367
- let bottomOffset = 0;
368
- let bottomOffset2 = 0;
369
- if (top && bottom) {
370
- bottomOffset = length / 2;
371
- bottomOffset2 = length / 3;
372
- length /= 2;
373
- }
374
- for (let i = 0; i < length; i += 3) {
375
- const position = Cartesian3_default.fromArray(
376
- flatPositions,
377
- i,
378
- appendTextureCoordinatesCartesian3
379
- );
380
- if (vertexFormat.st) {
381
- if (!defined_default(flatTexcoords)) {
382
- let p = Matrix3_default.multiplyByVector(
383
- textureMatrix,
384
- position,
385
- scratchPosition
386
- );
387
- p = ellipsoid.scaleToGeodeticSurface(p, p);
388
- const st = projectTo2d([p], appendTextureCoordinatesCartesian2)[0];
389
- Cartesian2_default.subtract(st, origin, st);
390
- const stx = Math_default.clamp(st.x / boundingRectangle.width, 0, 1);
391
- const sty = Math_default.clamp(st.y / boundingRectangle.height, 0, 1);
392
- if (bottom) {
393
- textureCoordinates[textureCoordIndex + bottomOffset2] = stx;
394
- textureCoordinates[textureCoordIndex + 1 + bottomOffset2] = sty;
395
- }
396
- if (top) {
397
- textureCoordinates[textureCoordIndex] = stx;
398
- textureCoordinates[textureCoordIndex + 1] = sty;
399
- }
400
- textureCoordIndex += 2;
401
- }
402
- }
403
- if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent || shadowVolume) {
404
- const attrIndex1 = attrIndex + 1;
405
- const attrIndex2 = attrIndex + 2;
406
- if (wall) {
407
- if (i + 3 < length) {
408
- const p1 = Cartesian3_default.fromArray(flatPositions, i + 3, p1Scratch);
409
- if (recomputeNormal) {
410
- const p2 = Cartesian3_default.fromArray(
411
- flatPositions,
412
- i + length,
413
- p2Scratch
414
- );
415
- if (perPositionHeight) {
416
- adjustPosHeightsForNormal(position, p1, p2, ellipsoid);
417
- }
418
- Cartesian3_default.subtract(p1, position, p1);
419
- Cartesian3_default.subtract(p2, position, p2);
420
- normal = Cartesian3_default.normalize(
421
- Cartesian3_default.cross(p2, p1, normal),
422
- normal
423
- );
424
- recomputeNormal = false;
425
- }
426
- if (Cartesian3_default.equalsEpsilon(p1, position, Math_default.EPSILON10)) {
427
- recomputeNormal = true;
428
- }
429
- }
430
- if (vertexFormat.tangent || vertexFormat.bitangent) {
431
- bitangent = ellipsoid.geodeticSurfaceNormal(position, bitangent);
432
- if (vertexFormat.tangent) {
433
- tangent = Cartesian3_default.normalize(
434
- Cartesian3_default.cross(bitangent, normal, tangent),
435
- tangent
436
- );
437
- }
438
- }
439
- } else {
440
- normal = ellipsoid.geodeticSurfaceNormal(position, normal);
441
- if (vertexFormat.tangent || vertexFormat.bitangent) {
442
- if (perPositionHeight) {
443
- scratchPerPosNormal = Cartesian3_default.fromArray(
444
- normals,
445
- attrIndex,
446
- scratchPerPosNormal
447
- );
448
- scratchPerPosTangent = Cartesian3_default.cross(
449
- Cartesian3_default.UNIT_Z,
450
- scratchPerPosNormal,
451
- scratchPerPosTangent
452
- );
453
- scratchPerPosTangent = Cartesian3_default.normalize(
454
- Matrix3_default.multiplyByVector(
455
- tangentRotationMatrix,
456
- scratchPerPosTangent,
457
- scratchPerPosTangent
458
- ),
459
- scratchPerPosTangent
460
- );
461
- if (vertexFormat.bitangent) {
462
- scratchPerPosBitangent = Cartesian3_default.normalize(
463
- Cartesian3_default.cross(
464
- scratchPerPosNormal,
465
- scratchPerPosTangent,
466
- scratchPerPosBitangent
467
- ),
468
- scratchPerPosBitangent
469
- );
470
- }
471
- }
472
- tangent = Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal, tangent);
473
- tangent = Cartesian3_default.normalize(
474
- Matrix3_default.multiplyByVector(tangentRotationMatrix, tangent, tangent),
475
- tangent
476
- );
477
- if (vertexFormat.bitangent) {
478
- bitangent = Cartesian3_default.normalize(
479
- Cartesian3_default.cross(normal, tangent, bitangent),
480
- bitangent
481
- );
482
- }
483
- }
484
- }
485
- if (vertexFormat.normal) {
486
- if (options.wall) {
487
- normals[attrIndex + bottomOffset] = normal.x;
488
- normals[attrIndex1 + bottomOffset] = normal.y;
489
- normals[attrIndex2 + bottomOffset] = normal.z;
490
- } else if (bottom) {
491
- normals[attrIndex + bottomOffset] = -normal.x;
492
- normals[attrIndex1 + bottomOffset] = -normal.y;
493
- normals[attrIndex2 + bottomOffset] = -normal.z;
494
- }
495
- if (top && !perPositionHeight || wall) {
496
- normals[attrIndex] = normal.x;
497
- normals[attrIndex1] = normal.y;
498
- normals[attrIndex2] = normal.z;
499
- }
500
- }
501
- if (shadowVolume) {
502
- if (wall) {
503
- normal = ellipsoid.geodeticSurfaceNormal(position, normal);
504
- }
505
- extrudeNormals[attrIndex + bottomOffset] = -normal.x;
506
- extrudeNormals[attrIndex1 + bottomOffset] = -normal.y;
507
- extrudeNormals[attrIndex2 + bottomOffset] = -normal.z;
508
- }
509
- if (vertexFormat.tangent) {
510
- if (options.wall) {
511
- tangents[attrIndex + bottomOffset] = tangent.x;
512
- tangents[attrIndex1 + bottomOffset] = tangent.y;
513
- tangents[attrIndex2 + bottomOffset] = tangent.z;
514
- } else if (bottom) {
515
- tangents[attrIndex + bottomOffset] = -tangent.x;
516
- tangents[attrIndex1 + bottomOffset] = -tangent.y;
517
- tangents[attrIndex2 + bottomOffset] = -tangent.z;
518
- }
519
- if (top) {
520
- if (perPositionHeight) {
521
- tangents[attrIndex] = scratchPerPosTangent.x;
522
- tangents[attrIndex1] = scratchPerPosTangent.y;
523
- tangents[attrIndex2] = scratchPerPosTangent.z;
524
- } else {
525
- tangents[attrIndex] = tangent.x;
526
- tangents[attrIndex1] = tangent.y;
527
- tangents[attrIndex2] = tangent.z;
528
- }
529
- }
530
- }
531
- if (vertexFormat.bitangent) {
532
- if (bottom) {
533
- bitangents[attrIndex + bottomOffset] = bitangent.x;
534
- bitangents[attrIndex1 + bottomOffset] = bitangent.y;
535
- bitangents[attrIndex2 + bottomOffset] = bitangent.z;
536
- }
537
- if (top) {
538
- if (perPositionHeight) {
539
- bitangents[attrIndex] = scratchPerPosBitangent.x;
540
- bitangents[attrIndex1] = scratchPerPosBitangent.y;
541
- bitangents[attrIndex2] = scratchPerPosBitangent.z;
542
- } else {
543
- bitangents[attrIndex] = bitangent.x;
544
- bitangents[attrIndex1] = bitangent.y;
545
- bitangents[attrIndex2] = bitangent.z;
546
- }
547
- }
548
- }
549
- attrIndex += 3;
550
- }
551
- }
552
- if (vertexFormat.st && !defined_default(flatTexcoords)) {
553
- geometry.attributes.st = new GeometryAttribute_default({
554
- componentDatatype: ComponentDatatype_default.FLOAT,
555
- componentsPerAttribute: 2,
556
- values: textureCoordinates
557
- });
558
- }
559
- if (vertexFormat.normal) {
560
- geometry.attributes.normal = new GeometryAttribute_default({
561
- componentDatatype: ComponentDatatype_default.FLOAT,
562
- componentsPerAttribute: 3,
563
- values: normals
564
- });
565
- }
566
- if (vertexFormat.tangent) {
567
- geometry.attributes.tangent = new GeometryAttribute_default({
568
- componentDatatype: ComponentDatatype_default.FLOAT,
569
- componentsPerAttribute: 3,
570
- values: tangents
571
- });
572
- }
573
- if (vertexFormat.bitangent) {
574
- geometry.attributes.bitangent = new GeometryAttribute_default({
575
- componentDatatype: ComponentDatatype_default.FLOAT,
576
- componentsPerAttribute: 3,
577
- values: bitangents
578
- });
579
- }
580
- if (shadowVolume) {
581
- geometry.attributes.extrudeDirection = new GeometryAttribute_default({
582
- componentDatatype: ComponentDatatype_default.FLOAT,
583
- componentsPerAttribute: 3,
584
- values: extrudeNormals
585
- });
586
- }
587
- }
588
- if (options.extrude && defined_default(options.offsetAttribute)) {
589
- const size = flatPositions.length / 3;
590
- let offsetAttribute = new Uint8Array(size);
591
- if (options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
592
- if (top && bottom || wall) {
593
- offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
594
- } else if (top) {
595
- offsetAttribute = offsetAttribute.fill(1);
596
- }
597
- } else {
598
- const offsetValue = options.offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
599
- offsetAttribute = offsetAttribute.fill(offsetValue);
600
- }
601
- geometry.attributes.applyOffset = new GeometryAttribute_default({
602
- componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
603
- componentsPerAttribute: 1,
604
- values: offsetAttribute
605
- });
606
- }
607
- return geometry;
608
- }
609
- var createGeometryFromPositionsExtrudedPositions = [];
610
- function createGeometryFromPositionsExtruded(ellipsoid, polygon2, textureCoordinates, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat, arcType) {
611
- const geos = {
612
- walls: []
613
- };
614
- let i;
615
- if (closeTop || closeBottom) {
616
- const topGeo = PolygonGeometryLibrary_default.createGeometryFromPositions(
617
- ellipsoid,
618
- polygon2,
619
- textureCoordinates,
620
- granularity,
621
- perPositionHeight,
622
- vertexFormat,
623
- arcType
624
- );
625
- const edgePoints = topGeo.attributes.position.values;
626
- const indices = topGeo.indices;
627
- let numPositions;
628
- let newIndices;
629
- if (closeTop && closeBottom) {
630
- const topBottomPositions = edgePoints.concat(edgePoints);
631
- numPositions = topBottomPositions.length / 3;
632
- newIndices = IndexDatatype_default.createTypedArray(
633
- numPositions,
634
- indices.length * 2
635
- );
636
- newIndices.set(indices);
637
- const ilength = indices.length;
638
- const length = numPositions / 2;
639
- for (i = 0; i < ilength; i += 3) {
640
- const i0 = newIndices[i] + length;
641
- const i1 = newIndices[i + 1] + length;
642
- const i2 = newIndices[i + 2] + length;
643
- newIndices[i + ilength] = i2;
644
- newIndices[i + 1 + ilength] = i1;
645
- newIndices[i + 2 + ilength] = i0;
646
- }
647
- topGeo.attributes.position.values = topBottomPositions;
648
- if (perPositionHeight && vertexFormat.normal) {
649
- const normals = topGeo.attributes.normal.values;
650
- topGeo.attributes.normal.values = new Float32Array(
651
- topBottomPositions.length
652
- );
653
- topGeo.attributes.normal.values.set(normals);
654
- }
655
- if (vertexFormat.st && defined_default(textureCoordinates)) {
656
- const texcoords = topGeo.attributes.st.values;
657
- topGeo.attributes.st.values = new Float32Array(numPositions * 2);
658
- topGeo.attributes.st.values = texcoords.concat(texcoords);
659
- }
660
- topGeo.indices = newIndices;
661
- } else if (closeBottom) {
662
- numPositions = edgePoints.length / 3;
663
- newIndices = IndexDatatype_default.createTypedArray(numPositions, indices.length);
664
- for (i = 0; i < indices.length; i += 3) {
665
- newIndices[i] = indices[i + 2];
666
- newIndices[i + 1] = indices[i + 1];
667
- newIndices[i + 2] = indices[i];
668
- }
669
- topGeo.indices = newIndices;
670
- }
671
- geos.topAndBottom = new GeometryInstance_default({
672
- geometry: topGeo
673
- });
674
- }
675
- let outerRing = hierarchy.outerRing;
676
- const tangentPlane = EllipsoidTangentPlane_default.fromPoints(outerRing, ellipsoid);
677
- let positions2D = tangentPlane.projectPointsOntoPlane(
678
- outerRing,
679
- createGeometryFromPositionsExtrudedPositions
680
- );
681
- let windingOrder = PolygonPipeline_default.computeWindingOrder2D(positions2D);
682
- if (windingOrder === WindingOrder_default.CLOCKWISE) {
683
- outerRing = outerRing.slice().reverse();
684
- }
685
- let wallGeo = PolygonGeometryLibrary_default.computeWallGeometry(
686
- outerRing,
687
- textureCoordinates,
688
- ellipsoid,
689
- granularity,
690
- perPositionHeight,
691
- arcType
692
- );
693
- geos.walls.push(
694
- new GeometryInstance_default({
695
- geometry: wallGeo
696
- })
697
- );
698
- const holes = hierarchy.holes;
699
- for (i = 0; i < holes.length; i++) {
700
- let hole = holes[i];
701
- positions2D = tangentPlane.projectPointsOntoPlane(
702
- hole,
703
- createGeometryFromPositionsExtrudedPositions
704
- );
705
- windingOrder = PolygonPipeline_default.computeWindingOrder2D(positions2D);
706
- if (windingOrder === WindingOrder_default.COUNTER_CLOCKWISE) {
707
- hole = hole.slice().reverse();
708
- }
709
- wallGeo = PolygonGeometryLibrary_default.computeWallGeometry(
710
- hole,
711
- textureCoordinates,
712
- ellipsoid,
713
- granularity,
714
- perPositionHeight,
715
- arcType
716
- );
717
- geos.walls.push(
718
- new GeometryInstance_default({
719
- geometry: wallGeo
720
- })
721
- );
722
- }
723
- return geos;
724
- }
725
- function PolygonGeometry(options) {
726
- Check_default.typeOf.object("options", options);
727
- Check_default.typeOf.object("options.polygonHierarchy", options.polygonHierarchy);
728
- if (defined_default(options.perPositionHeight) && options.perPositionHeight && defined_default(options.height)) {
729
- throw new DeveloperError_default(
730
- "Cannot use both options.perPositionHeight and options.height"
731
- );
732
- }
733
- if (defined_default(options.arcType) && options.arcType !== ArcType_default.GEODESIC && options.arcType !== ArcType_default.RHUMB) {
734
- throw new DeveloperError_default(
735
- "Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB."
736
- );
737
- }
738
- const polygonHierarchy = options.polygonHierarchy;
739
- const vertexFormat = options.vertexFormat ?? VertexFormat_default.DEFAULT;
740
- const ellipsoid = options.ellipsoid ?? Ellipsoid_default.default;
741
- const granularity = options.granularity ?? Math_default.RADIANS_PER_DEGREE;
742
- const stRotation = options.stRotation ?? 0;
743
- const textureCoordinates = options.textureCoordinates;
744
- const perPositionHeight = options.perPositionHeight ?? false;
745
- const perPositionHeightExtrude = perPositionHeight && defined_default(options.extrudedHeight);
746
- let height = options.height ?? 0;
747
- let extrudedHeight = options.extrudedHeight ?? height;
748
- if (!perPositionHeightExtrude) {
749
- const h = Math.max(height, extrudedHeight);
750
- extrudedHeight = Math.min(height, extrudedHeight);
751
- height = h;
752
- }
753
- this._vertexFormat = VertexFormat_default.clone(vertexFormat);
754
- this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
755
- this._granularity = granularity;
756
- this._stRotation = stRotation;
757
- this._height = height;
758
- this._extrudedHeight = extrudedHeight;
759
- this._closeTop = options.closeTop ?? true;
760
- this._closeBottom = options.closeBottom ?? true;
761
- this._polygonHierarchy = polygonHierarchy;
762
- this._perPositionHeight = perPositionHeight;
763
- this._perPositionHeightExtrude = perPositionHeightExtrude;
764
- this._shadowVolume = options.shadowVolume ?? false;
765
- this._workerName = "createPolygonGeometry";
766
- this._offsetAttribute = options.offsetAttribute;
767
- this._arcType = options.arcType ?? ArcType_default.GEODESIC;
768
- this._rectangle = void 0;
769
- this._textureCoordinateRotationPoints = void 0;
770
- this._textureCoordinates = textureCoordinates;
771
- this.packedLength = PolygonGeometryLibrary_default.computeHierarchyPackedLength(
772
- polygonHierarchy,
773
- Cartesian3_default
774
- ) + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + (textureCoordinates ? PolygonGeometryLibrary_default.computeHierarchyPackedLength(
775
- textureCoordinates,
776
- Cartesian2_default
777
- ) : 1) + 12;
778
- }
779
- PolygonGeometry.fromPositions = function(options) {
780
- options = options ?? Frozen_default.EMPTY_OBJECT;
781
- Check_default.defined("options.positions", options.positions);
782
- const newOptions = {
783
- polygonHierarchy: {
784
- positions: options.positions
785
- },
786
- height: options.height,
787
- extrudedHeight: options.extrudedHeight,
788
- vertexFormat: options.vertexFormat,
789
- stRotation: options.stRotation,
790
- ellipsoid: options.ellipsoid,
791
- granularity: options.granularity,
792
- perPositionHeight: options.perPositionHeight,
793
- closeTop: options.closeTop,
794
- closeBottom: options.closeBottom,
795
- offsetAttribute: options.offsetAttribute,
796
- arcType: options.arcType,
797
- textureCoordinates: options.textureCoordinates
798
- };
799
- return new PolygonGeometry(newOptions);
800
- };
801
- PolygonGeometry.pack = function(value, array, startingIndex) {
802
- Check_default.typeOf.object("value", value);
803
- Check_default.defined("array", array);
804
- startingIndex = startingIndex ?? 0;
805
- startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
806
- value._polygonHierarchy,
807
- array,
808
- startingIndex,
809
- Cartesian3_default
810
- );
811
- Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
812
- startingIndex += Ellipsoid_default.packedLength;
813
- VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
814
- startingIndex += VertexFormat_default.packedLength;
815
- array[startingIndex++] = value._height;
816
- array[startingIndex++] = value._extrudedHeight;
817
- array[startingIndex++] = value._granularity;
818
- array[startingIndex++] = value._stRotation;
819
- array[startingIndex++] = value._perPositionHeightExtrude ? 1 : 0;
820
- array[startingIndex++] = value._perPositionHeight ? 1 : 0;
821
- array[startingIndex++] = value._closeTop ? 1 : 0;
822
- array[startingIndex++] = value._closeBottom ? 1 : 0;
823
- array[startingIndex++] = value._shadowVolume ? 1 : 0;
824
- array[startingIndex++] = value._offsetAttribute ?? -1;
825
- array[startingIndex++] = value._arcType;
826
- if (defined_default(value._textureCoordinates)) {
827
- startingIndex = PolygonGeometryLibrary_default.packPolygonHierarchy(
828
- value._textureCoordinates,
829
- array,
830
- startingIndex,
831
- Cartesian2_default
832
- );
833
- } else {
834
- array[startingIndex++] = -1;
835
- }
836
- array[startingIndex++] = value.packedLength;
837
- return array;
838
- };
839
- var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
840
- var scratchVertexFormat = new VertexFormat_default();
841
- var dummyOptions = {
842
- polygonHierarchy: {}
843
- };
844
- PolygonGeometry.unpack = function(array, startingIndex, result) {
845
- Check_default.defined("array", array);
846
- startingIndex = startingIndex ?? 0;
847
- const polygonHierarchy = PolygonGeometryLibrary_default.unpackPolygonHierarchy(
848
- array,
849
- startingIndex,
850
- Cartesian3_default
851
- );
852
- startingIndex = polygonHierarchy.startingIndex;
853
- delete polygonHierarchy.startingIndex;
854
- const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
855
- startingIndex += Ellipsoid_default.packedLength;
856
- const vertexFormat = VertexFormat_default.unpack(
857
- array,
858
- startingIndex,
859
- scratchVertexFormat
860
- );
861
- startingIndex += VertexFormat_default.packedLength;
862
- const height = array[startingIndex++];
863
- const extrudedHeight = array[startingIndex++];
864
- const granularity = array[startingIndex++];
865
- const stRotation = array[startingIndex++];
866
- const perPositionHeightExtrude = array[startingIndex++] === 1;
867
- const perPositionHeight = array[startingIndex++] === 1;
868
- const closeTop = array[startingIndex++] === 1;
869
- const closeBottom = array[startingIndex++] === 1;
870
- const shadowVolume = array[startingIndex++] === 1;
871
- const offsetAttribute = array[startingIndex++];
872
- const arcType = array[startingIndex++];
873
- const textureCoordinates = array[startingIndex] === -1 ? void 0 : PolygonGeometryLibrary_default.unpackPolygonHierarchy(
874
- array,
875
- startingIndex,
876
- Cartesian2_default
877
- );
878
- if (defined_default(textureCoordinates)) {
879
- startingIndex = textureCoordinates.startingIndex;
880
- delete textureCoordinates.startingIndex;
881
- } else {
882
- startingIndex++;
883
- }
884
- const packedLength = array[startingIndex++];
885
- if (!defined_default(result)) {
886
- result = new PolygonGeometry(dummyOptions);
887
- }
888
- result._polygonHierarchy = polygonHierarchy;
889
- result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
890
- result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
891
- result._height = height;
892
- result._extrudedHeight = extrudedHeight;
893
- result._granularity = granularity;
894
- result._stRotation = stRotation;
895
- result._perPositionHeightExtrude = perPositionHeightExtrude;
896
- result._perPositionHeight = perPositionHeight;
897
- result._closeTop = closeTop;
898
- result._closeBottom = closeBottom;
899
- result._shadowVolume = shadowVolume;
900
- result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
901
- result._arcType = arcType;
902
- result._textureCoordinates = textureCoordinates;
903
- result.packedLength = packedLength;
904
- return result;
905
- };
906
- var scratchCartesian0 = new Cartesian2_default();
907
- var scratchCartesian1 = new Cartesian2_default();
908
- var scratchPolarClosest = new Stereographic_default();
909
- function expandRectangle(polar, lastPolar, ellipsoid, arcType, polygon2, result) {
910
- const longitude = polar.longitude;
911
- const lonAdjusted = longitude >= 0 ? longitude : longitude + Math_default.TWO_PI;
912
- polygon2.westOverIdl = Math.min(polygon2.westOverIdl, lonAdjusted);
913
- polygon2.eastOverIdl = Math.max(polygon2.eastOverIdl, lonAdjusted);
914
- result.west = Math.min(result.west, longitude);
915
- result.east = Math.max(result.east, longitude);
916
- const latitude = polar.getLatitude(ellipsoid);
917
- let segmentLatitude = latitude;
918
- result.south = Math.min(result.south, latitude);
919
- result.north = Math.max(result.north, latitude);
920
- if (arcType !== ArcType_default.RHUMB) {
921
- const segment = Cartesian2_default.subtract(
922
- lastPolar.position,
923
- polar.position,
924
- scratchCartesian0
925
- );
926
- const t = Cartesian2_default.dot(lastPolar.position, segment) / Cartesian2_default.dot(segment, segment);
927
- if (t > 0 && t < 1) {
928
- const projected = Cartesian2_default.add(
929
- lastPolar.position,
930
- Cartesian2_default.multiplyByScalar(segment, -t, segment),
931
- scratchCartesian1
932
- );
933
- const closestPolar = Stereographic_default.clone(lastPolar, scratchPolarClosest);
934
- closestPolar.position = projected;
935
- const adjustedLatitude = closestPolar.getLatitude(ellipsoid);
936
- result.south = Math.min(result.south, adjustedLatitude);
937
- result.north = Math.max(result.north, adjustedLatitude);
938
- if (Math.abs(latitude) > Math.abs(adjustedLatitude)) {
939
- segmentLatitude = adjustedLatitude;
940
- }
941
- }
942
- }
943
- const direction = lastPolar.x * polar.y - polar.x * lastPolar.y;
944
- let angle = Math.sign(direction);
945
- if (angle !== 0) {
946
- angle *= Cartesian2_default.angleBetween(lastPolar.position, polar.position);
947
- }
948
- if (segmentLatitude >= 0) {
949
- polygon2.northAngle += angle;
950
- }
951
- if (segmentLatitude <= 0) {
952
- polygon2.southAngle += angle;
953
- }
954
- }
955
- var scratchPolar = new Stereographic_default();
956
- var scratchPolarPrevious = new Stereographic_default();
957
- var polygon = {
958
- northAngle: 0,
959
- southAngle: 0,
960
- westOverIdl: 0,
961
- eastOverIdl: 0
962
- };
963
- PolygonGeometry.computeRectangleFromPositions = function(positions, ellipsoid, arcType, result) {
964
- Check_default.defined("positions", positions);
965
- if (!defined_default(result)) {
966
- result = new Rectangle_default();
967
- }
968
- if (positions.length < 3) {
969
- return result;
970
- }
971
- result.west = Number.POSITIVE_INFINITY;
972
- result.east = Number.NEGATIVE_INFINITY;
973
- result.south = Number.POSITIVE_INFINITY;
974
- result.north = Number.NEGATIVE_INFINITY;
975
- polygon.northAngle = 0;
976
- polygon.southAngle = 0;
977
- polygon.westOverIdl = Number.POSITIVE_INFINITY;
978
- polygon.eastOverIdl = Number.NEGATIVE_INFINITY;
979
- const positionsLength = positions.length;
980
- let lastPolarPosition = Stereographic_default.fromCartesian(
981
- positions[0],
982
- scratchPolarPrevious
983
- );
984
- for (let i = 1; i < positionsLength; i++) {
985
- const polarPosition = Stereographic_default.fromCartesian(
986
- positions[i],
987
- scratchPolar
988
- );
989
- expandRectangle(
990
- polarPosition,
991
- lastPolarPosition,
992
- ellipsoid,
993
- arcType,
994
- polygon,
995
- result
996
- );
997
- lastPolarPosition = Stereographic_default.clone(polarPosition, lastPolarPosition);
998
- }
999
- expandRectangle(
1000
- Stereographic_default.fromCartesian(positions[0], scratchPolar),
1001
- lastPolarPosition,
1002
- ellipsoid,
1003
- arcType,
1004
- polygon,
1005
- result
1006
- );
1007
- if (result.east - result.west > polygon.eastOverIdl - polygon.westOverIdl) {
1008
- result.west = polygon.westOverIdl;
1009
- result.east = polygon.eastOverIdl;
1010
- if (result.east > Math_default.PI) {
1011
- result.east = result.east - Math_default.TWO_PI;
1012
- }
1013
- if (result.west > Math_default.PI) {
1014
- result.west = result.west - Math_default.TWO_PI;
1015
- }
1016
- }
1017
- if (Math_default.equalsEpsilon(
1018
- Math.abs(polygon.northAngle),
1019
- Math_default.TWO_PI,
1020
- Math_default.EPSILON10
1021
- )) {
1022
- result.north = Math_default.PI_OVER_TWO;
1023
- result.east = Math_default.PI;
1024
- result.west = -Math_default.PI;
1025
- }
1026
- if (Math_default.equalsEpsilon(
1027
- Math.abs(polygon.southAngle),
1028
- Math_default.TWO_PI,
1029
- Math_default.EPSILON10
1030
- )) {
1031
- result.south = -Math_default.PI_OVER_TWO;
1032
- result.east = Math_default.PI;
1033
- result.west = -Math_default.PI;
1034
- }
1035
- return result;
1036
- };
1037
- var scratchPolarForPlane = new Stereographic_default();
1038
- function getTangentPlane(rectangle, positions, ellipsoid) {
1039
- if (rectangle.height >= Math_default.PI || rectangle.width >= Math_default.PI) {
1040
- const polar = Stereographic_default.fromCartesian(
1041
- positions[0],
1042
- scratchPolarForPlane
1043
- );
1044
- return polar.tangentPlane;
1045
- }
1046
- return EllipsoidTangentPlane_default.fromPoints(positions, ellipsoid);
1047
- }
1048
- var scratchCartographicCyllindrical = new Cartographic_default();
1049
- function createProjectTo2d(rectangle, outerPositions, ellipsoid) {
1050
- return (positions, results) => {
1051
- if (rectangle.height >= Math_default.PI || rectangle.width >= Math_default.PI) {
1052
- if (rectangle.south < 0 && rectangle.north > 0) {
1053
- if (!defined_default(results)) {
1054
- results = [];
1055
- }
1056
- for (let i = 0; i < positions.length; ++i) {
1057
- const cartographic = ellipsoid.cartesianToCartographic(
1058
- positions[i],
1059
- scratchCartographicCyllindrical
1060
- );
1061
- results[i] = new Cartesian2_default(
1062
- cartographic.longitude / Math_default.PI,
1063
- cartographic.latitude / Math_default.PI_OVER_TWO
1064
- );
1065
- }
1066
- results.length = positions.length;
1067
- return results;
1068
- }
1069
- return Stereographic_default.fromCartesianArray(positions, results);
1070
- }
1071
- const tangentPlane = EllipsoidTangentPlane_default.fromPoints(
1072
- outerPositions,
1073
- ellipsoid
1074
- );
1075
- return tangentPlane.projectPointsOntoPlane(positions, results);
1076
- };
1077
- }
1078
- function createProjectPositionTo2d(rectangle, outerRing, ellipsoid) {
1079
- if (rectangle.height >= Math_default.PI || rectangle.width >= Math_default.PI) {
1080
- return (position, result) => {
1081
- if (rectangle.south < 0 && rectangle.north > 0) {
1082
- const cartographic = ellipsoid.cartesianToCartographic(
1083
- position,
1084
- scratchCartographicCyllindrical
1085
- );
1086
- if (!defined_default(result)) {
1087
- result = new Cartesian2_default();
1088
- }
1089
- result.x = cartographic.longitude / Math_default.PI;
1090
- result.y = cartographic.latitude / Math_default.PI_OVER_TWO;
1091
- return result;
1092
- }
1093
- return Stereographic_default.fromCartesian(position, result);
1094
- };
1095
- }
1096
- const tangentPlane = EllipsoidTangentPlane_default.fromPoints(outerRing, ellipsoid);
1097
- return (position, result) => {
1098
- return tangentPlane.projectPointsOntoPlane(position, result);
1099
- };
1100
- }
1101
- function createSplitPolygons(rectangle, ellipsoid, arcType, perPositionHeight) {
1102
- return (polygons, results) => {
1103
- if (!perPositionHeight && (rectangle.height >= Math_default.PI_OVER_TWO || rectangle.width >= 2 * Math_default.PI_OVER_THREE)) {
1104
- return PolygonGeometryLibrary_default.splitPolygonsOnEquator(
1105
- polygons,
1106
- ellipsoid,
1107
- arcType,
1108
- results
1109
- );
1110
- }
1111
- return polygons;
1112
- };
1113
- }
1114
- function computeBoundingRectangle(outerRing, rectangle, ellipsoid, stRotation) {
1115
- if (rectangle.height >= Math_default.PI || rectangle.width >= Math_default.PI) {
1116
- return BoundingRectangle_default.fromRectangle(
1117
- rectangle,
1118
- void 0,
1119
- scratchBoundingRectangle
1120
- );
1121
- }
1122
- const outerPositions = outerRing;
1123
- const tangentPlane = EllipsoidTangentPlane_default.fromPoints(
1124
- outerPositions,
1125
- ellipsoid
1126
- );
1127
- return PolygonGeometryLibrary_default.computeBoundingRectangle(
1128
- tangentPlane.plane.normal,
1129
- tangentPlane.projectPointOntoPlane.bind(tangentPlane),
1130
- outerPositions,
1131
- stRotation,
1132
- scratchBoundingRectangle
1133
- );
1134
- }
1135
- PolygonGeometry.createGeometry = function(polygonGeometry) {
1136
- const vertexFormat = polygonGeometry._vertexFormat;
1137
- const ellipsoid = polygonGeometry._ellipsoid;
1138
- const granularity = polygonGeometry._granularity;
1139
- const stRotation = polygonGeometry._stRotation;
1140
- const polygonHierarchy = polygonGeometry._polygonHierarchy;
1141
- const perPositionHeight = polygonGeometry._perPositionHeight;
1142
- const closeTop = polygonGeometry._closeTop;
1143
- const closeBottom = polygonGeometry._closeBottom;
1144
- const arcType = polygonGeometry._arcType;
1145
- const textureCoordinates = polygonGeometry._textureCoordinates;
1146
- const hasTextureCoordinates = defined_default(textureCoordinates);
1147
- const outerPositions = polygonHierarchy.positions;
1148
- if (outerPositions.length < 3) {
1149
- return;
1150
- }
1151
- const rectangle = polygonGeometry.rectangle;
1152
- const results = PolygonGeometryLibrary_default.polygonsFromHierarchy(
1153
- polygonHierarchy,
1154
- hasTextureCoordinates,
1155
- createProjectTo2d(rectangle, outerPositions, ellipsoid),
1156
- !perPositionHeight,
1157
- ellipsoid,
1158
- createSplitPolygons(rectangle, ellipsoid, arcType, perPositionHeight)
1159
- );
1160
- const hierarchy = results.hierarchy;
1161
- const polygons = results.polygons;
1162
- const dummyFunction = function(identity) {
1163
- return identity;
1164
- };
1165
- const textureCoordinatePolygons = hasTextureCoordinates ? PolygonGeometryLibrary_default.polygonsFromHierarchy(
1166
- textureCoordinates,
1167
- true,
1168
- dummyFunction,
1169
- false,
1170
- ellipsoid
1171
- ).polygons : void 0;
1172
- if (hierarchy.length === 0) {
1173
- return;
1174
- }
1175
- const outerRing = hierarchy[0].outerRing;
1176
- const boundingRectangle = computeBoundingRectangle(
1177
- outerRing,
1178
- rectangle,
1179
- ellipsoid,
1180
- stRotation
1181
- );
1182
- const geometries = [];
1183
- const height = polygonGeometry._height;
1184
- const extrudedHeight = polygonGeometry._extrudedHeight;
1185
- const extrude = polygonGeometry._perPositionHeightExtrude || !Math_default.equalsEpsilon(height, extrudedHeight, 0, Math_default.EPSILON2);
1186
- const options = {
1187
- perPositionHeight,
1188
- vertexFormat,
1189
- geometry: void 0,
1190
- rotationAxis: getTangentPlane(rectangle, outerRing, ellipsoid).plane.normal,
1191
- projectTo2d: createProjectPositionTo2d(rectangle, outerRing, ellipsoid),
1192
- boundingRectangle,
1193
- ellipsoid,
1194
- stRotation,
1195
- textureCoordinates: void 0,
1196
- bottom: false,
1197
- top: true,
1198
- wall: false,
1199
- extrude: false,
1200
- arcType
1201
- };
1202
- let i;
1203
- if (extrude) {
1204
- options.extrude = true;
1205
- options.top = closeTop;
1206
- options.bottom = closeBottom;
1207
- options.shadowVolume = polygonGeometry._shadowVolume;
1208
- options.offsetAttribute = polygonGeometry._offsetAttribute;
1209
- for (i = 0; i < polygons.length; i++) {
1210
- const splitGeometry = createGeometryFromPositionsExtruded(
1211
- ellipsoid,
1212
- polygons[i],
1213
- hasTextureCoordinates ? textureCoordinatePolygons[i] : void 0,
1214
- granularity,
1215
- hierarchy[i],
1216
- perPositionHeight,
1217
- closeTop,
1218
- closeBottom,
1219
- vertexFormat,
1220
- arcType
1221
- );
1222
- let topAndBottom;
1223
- if (closeTop && closeBottom) {
1224
- topAndBottom = splitGeometry.topAndBottom;
1225
- options.geometry = PolygonGeometryLibrary_default.scaleToGeodeticHeightExtruded(
1226
- topAndBottom.geometry,
1227
- height,
1228
- extrudedHeight,
1229
- ellipsoid,
1230
- perPositionHeight
1231
- );
1232
- } else if (closeTop) {
1233
- topAndBottom = splitGeometry.topAndBottom;
1234
- topAndBottom.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
1235
- topAndBottom.geometry.attributes.position.values,
1236
- height,
1237
- ellipsoid,
1238
- !perPositionHeight
1239
- );
1240
- options.geometry = topAndBottom.geometry;
1241
- } else if (closeBottom) {
1242
- topAndBottom = splitGeometry.topAndBottom;
1243
- topAndBottom.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
1244
- topAndBottom.geometry.attributes.position.values,
1245
- extrudedHeight,
1246
- ellipsoid,
1247
- true
1248
- );
1249
- options.geometry = topAndBottom.geometry;
1250
- }
1251
- if (closeTop || closeBottom) {
1252
- options.wall = false;
1253
- topAndBottom.geometry = computeAttributes(options);
1254
- geometries.push(topAndBottom);
1255
- }
1256
- const walls = splitGeometry.walls;
1257
- options.wall = true;
1258
- for (let k = 0; k < walls.length; k++) {
1259
- const wall = walls[k];
1260
- options.geometry = PolygonGeometryLibrary_default.scaleToGeodeticHeightExtruded(
1261
- wall.geometry,
1262
- height,
1263
- extrudedHeight,
1264
- ellipsoid,
1265
- perPositionHeight
1266
- );
1267
- wall.geometry = computeAttributes(options);
1268
- geometries.push(wall);
1269
- }
1270
- }
1271
- } else {
1272
- for (i = 0; i < polygons.length; i++) {
1273
- const geometryInstance = new GeometryInstance_default({
1274
- geometry: PolygonGeometryLibrary_default.createGeometryFromPositions(
1275
- ellipsoid,
1276
- polygons[i],
1277
- hasTextureCoordinates ? textureCoordinatePolygons[i] : void 0,
1278
- granularity,
1279
- perPositionHeight,
1280
- vertexFormat,
1281
- arcType
1282
- )
1283
- });
1284
- geometryInstance.geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
1285
- geometryInstance.geometry.attributes.position.values,
1286
- height,
1287
- ellipsoid,
1288
- !perPositionHeight
1289
- );
1290
- options.geometry = geometryInstance.geometry;
1291
- geometryInstance.geometry = computeAttributes(options);
1292
- if (defined_default(polygonGeometry._offsetAttribute)) {
1293
- const length = geometryInstance.geometry.attributes.position.values.length;
1294
- const offsetValue = polygonGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
1295
- const applyOffset = new Uint8Array(length / 3).fill(offsetValue);
1296
- geometryInstance.geometry.attributes.applyOffset = new GeometryAttribute_default({
1297
- componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
1298
- componentsPerAttribute: 1,
1299
- values: applyOffset
1300
- });
1301
- }
1302
- geometries.push(geometryInstance);
1303
- }
1304
- }
1305
- const geometry = GeometryPipeline_default.combineInstances(geometries)[0];
1306
- geometry.attributes.position.values = new Float64Array(
1307
- geometry.attributes.position.values
1308
- );
1309
- geometry.indices = IndexDatatype_default.createTypedArray(
1310
- geometry.attributes.position.values.length / 3,
1311
- geometry.indices
1312
- );
1313
- const attributes = geometry.attributes;
1314
- const boundingSphere = BoundingSphere_default.fromVertices(
1315
- attributes.position.values
1316
- );
1317
- if (!vertexFormat.position) {
1318
- delete attributes.position;
1319
- }
1320
- return new Geometry_default({
1321
- attributes,
1322
- indices: geometry.indices,
1323
- primitiveType: geometry.primitiveType,
1324
- boundingSphere,
1325
- offsetAttribute: polygonGeometry._offsetAttribute
1326
- });
1327
- };
1328
- PolygonGeometry.createShadowVolume = function(polygonGeometry, minHeightFunc, maxHeightFunc) {
1329
- const granularity = polygonGeometry._granularity;
1330
- const ellipsoid = polygonGeometry._ellipsoid;
1331
- const minHeight = minHeightFunc(granularity, ellipsoid);
1332
- const maxHeight = maxHeightFunc(granularity, ellipsoid);
1333
- return new PolygonGeometry({
1334
- polygonHierarchy: polygonGeometry._polygonHierarchy,
1335
- ellipsoid,
1336
- stRotation: polygonGeometry._stRotation,
1337
- granularity,
1338
- perPositionHeight: false,
1339
- extrudedHeight: minHeight,
1340
- height: maxHeight,
1341
- vertexFormat: VertexFormat_default.POSITION_ONLY,
1342
- shadowVolume: true,
1343
- arcType: polygonGeometry._arcType
1344
- });
1345
- };
1346
- function textureCoordinateRotationPoints(polygonGeometry) {
1347
- const stRotation = -polygonGeometry._stRotation;
1348
- if (stRotation === 0) {
1349
- return [0, 0, 0, 1, 1, 0];
1350
- }
1351
- const ellipsoid = polygonGeometry._ellipsoid;
1352
- const positions = polygonGeometry._polygonHierarchy.positions;
1353
- const boundingRectangle = polygonGeometry.rectangle;
1354
- return Geometry_default._textureCoordinateRotationPoints(
1355
- positions,
1356
- stRotation,
1357
- ellipsoid,
1358
- boundingRectangle
1359
- );
1360
- }
1361
- Object.defineProperties(PolygonGeometry.prototype, {
1362
- /**
1363
- * @private
1364
- */
1365
- rectangle: {
1366
- get: function() {
1367
- if (!defined_default(this._rectangle)) {
1368
- const positions = this._polygonHierarchy.positions;
1369
- this._rectangle = PolygonGeometry.computeRectangleFromPositions(
1370
- positions,
1371
- this._ellipsoid,
1372
- this._arcType
1373
- );
1374
- }
1375
- return this._rectangle;
1376
- }
1377
- },
1378
- /**
1379
- * For remapping texture coordinates when rendering PolygonGeometries as GroundPrimitives.
1380
- * @private
1381
- */
1382
- textureCoordinateRotationPoints: {
1383
- get: function() {
1384
- if (!defined_default(this._textureCoordinateRotationPoints)) {
1385
- this._textureCoordinateRotationPoints = textureCoordinateRotationPoints(this);
1386
- }
1387
- return this._textureCoordinateRotationPoints;
1388
- }
1389
- }
1390
- });
1391
- var PolygonGeometry_default = PolygonGeometry;
1392
-
1393
- // packages/engine/Source/Workers/createPolygonGeometry.js
1394
- function createPolygonGeometry(polygonGeometry, offset) {
1395
- if (defined_default(offset)) {
1396
- polygonGeometry = PolygonGeometry_default.unpack(polygonGeometry, offset);
1397
- }
1398
- polygonGeometry._ellipsoid = Ellipsoid_default.clone(polygonGeometry._ellipsoid);
1399
- return PolygonGeometry_default.createGeometry(polygonGeometry);
1400
- }
1401
- var createPolygonGeometry_default = createPolygonGeometry;
1402
- export {
1403
- createPolygonGeometry_default as default
1404
- };