@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,1264 +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
- RectangleGeometryLibrary_default
28
- } from "./chunk-IELTSYPZ.js";
29
- import {
30
- GeometryInstance_default
31
- } from "./chunk-SBFTVHRW.js";
32
- import {
33
- GeometryPipeline_default
34
- } from "./chunk-PV5B2YNB.js";
35
- import "./chunk-6LZBBEA7.js";
36
- import "./chunk-75UGCVME.js";
37
- import {
38
- GeometryOffsetAttribute_default
39
- } from "./chunk-6H33B6OL.js";
40
- import {
41
- VertexFormat_default
42
- } from "./chunk-I76SRIKN.js";
43
- import {
44
- PolygonPipeline_default
45
- } from "./chunk-WO5ZNC7S.js";
46
- import "./chunk-FVYRV2T6.js";
47
- import "./chunk-66YGZWBI.js";
48
- import "./chunk-J4MIJCN5.js";
49
- import {
50
- IndexDatatype_default
51
- } from "./chunk-55IROWAX.js";
52
- import {
53
- GeometryAttributes_default
54
- } from "./chunk-BOV6T7FO.js";
55
- import {
56
- GeometryAttribute_default,
57
- Geometry_default,
58
- PrimitiveType_default
59
- } from "./chunk-XOVHLPKW.js";
60
- import {
61
- BoundingSphere_default
62
- } from "./chunk-OAOREOSO.js";
63
- import "./chunk-EKMWNF4U.js";
64
- import {
65
- Matrix2_default,
66
- Quaternion_default,
67
- Rectangle_default
68
- } from "./chunk-KQIZ7AFF.js";
69
- import "./chunk-POY6ZE32.js";
70
- import {
71
- ComponentDatatype_default
72
- } from "./chunk-AL22JVIA.js";
73
- import "./chunk-5VZISKJF.js";
74
- import "./chunk-UYT2PBMV.js";
75
- import {
76
- Cartesian2_default,
77
- Cartographic_default,
78
- Ellipsoid_default
79
- } from "./chunk-YPGJSFOO.js";
80
- import {
81
- Cartesian3_default,
82
- Frozen_default,
83
- Matrix3_default
84
- } from "./chunk-QWV2DM66.js";
85
- import {
86
- Math_default
87
- } from "./chunk-6XJO625E.js";
88
- import {
89
- Check_default,
90
- DeveloperError_default
91
- } from "./chunk-KH2OWUUA.js";
92
- import {
93
- defined_default
94
- } from "./chunk-AVSQILVI.js";
95
-
96
- // packages/engine/Source/Core/RectangleGeometry.js
97
- var positionScratch = new Cartesian3_default();
98
- var normalScratch = new Cartesian3_default();
99
- var tangentScratch = new Cartesian3_default();
100
- var bitangentScratch = new Cartesian3_default();
101
- var rectangleScratch = new Rectangle_default();
102
- var stScratch = new Cartesian2_default();
103
- var bottomBoundingSphere = new BoundingSphere_default();
104
- var topBoundingSphere = new BoundingSphere_default();
105
- function createAttributes(vertexFormat, attributes) {
106
- const geo = new Geometry_default({
107
- attributes: new GeometryAttributes_default(),
108
- primitiveType: PrimitiveType_default.TRIANGLES
109
- });
110
- geo.attributes.position = new GeometryAttribute_default({
111
- componentDatatype: ComponentDatatype_default.DOUBLE,
112
- componentsPerAttribute: 3,
113
- values: attributes.positions
114
- });
115
- if (vertexFormat.normal) {
116
- geo.attributes.normal = new GeometryAttribute_default({
117
- componentDatatype: ComponentDatatype_default.FLOAT,
118
- componentsPerAttribute: 3,
119
- values: attributes.normals
120
- });
121
- }
122
- if (vertexFormat.tangent) {
123
- geo.attributes.tangent = new GeometryAttribute_default({
124
- componentDatatype: ComponentDatatype_default.FLOAT,
125
- componentsPerAttribute: 3,
126
- values: attributes.tangents
127
- });
128
- }
129
- if (vertexFormat.bitangent) {
130
- geo.attributes.bitangent = new GeometryAttribute_default({
131
- componentDatatype: ComponentDatatype_default.FLOAT,
132
- componentsPerAttribute: 3,
133
- values: attributes.bitangents
134
- });
135
- }
136
- return geo;
137
- }
138
- function calculateAttributes(positions, vertexFormat, ellipsoid, tangentRotationMatrix) {
139
- const length = positions.length;
140
- const normals = vertexFormat.normal ? new Float32Array(length) : void 0;
141
- const tangents = vertexFormat.tangent ? new Float32Array(length) : void 0;
142
- const bitangents = vertexFormat.bitangent ? new Float32Array(length) : void 0;
143
- let attrIndex = 0;
144
- const bitangent = bitangentScratch;
145
- const tangent = tangentScratch;
146
- let normal = normalScratch;
147
- if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
148
- for (let i = 0; i < length; i += 3) {
149
- const p = Cartesian3_default.fromArray(positions, i, positionScratch);
150
- const attrIndex1 = attrIndex + 1;
151
- const attrIndex2 = attrIndex + 2;
152
- normal = ellipsoid.geodeticSurfaceNormal(p, normal);
153
- if (vertexFormat.tangent || vertexFormat.bitangent) {
154
- Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal, tangent);
155
- Matrix3_default.multiplyByVector(tangentRotationMatrix, tangent, tangent);
156
- Cartesian3_default.normalize(tangent, tangent);
157
- if (vertexFormat.bitangent) {
158
- Cartesian3_default.normalize(
159
- Cartesian3_default.cross(normal, tangent, bitangent),
160
- bitangent
161
- );
162
- }
163
- }
164
- if (vertexFormat.normal) {
165
- normals[attrIndex] = normal.x;
166
- normals[attrIndex1] = normal.y;
167
- normals[attrIndex2] = normal.z;
168
- }
169
- if (vertexFormat.tangent) {
170
- tangents[attrIndex] = tangent.x;
171
- tangents[attrIndex1] = tangent.y;
172
- tangents[attrIndex2] = tangent.z;
173
- }
174
- if (vertexFormat.bitangent) {
175
- bitangents[attrIndex] = bitangent.x;
176
- bitangents[attrIndex1] = bitangent.y;
177
- bitangents[attrIndex2] = bitangent.z;
178
- }
179
- attrIndex += 3;
180
- }
181
- }
182
- return createAttributes(vertexFormat, {
183
- positions,
184
- normals,
185
- tangents,
186
- bitangents
187
- });
188
- }
189
- var v1Scratch = new Cartesian3_default();
190
- var v2Scratch = new Cartesian3_default();
191
- function calculateAttributesWall(positions, vertexFormat, ellipsoid) {
192
- const length = positions.length;
193
- const normals = vertexFormat.normal ? new Float32Array(length) : void 0;
194
- const tangents = vertexFormat.tangent ? new Float32Array(length) : void 0;
195
- const bitangents = vertexFormat.bitangent ? new Float32Array(length) : void 0;
196
- let normalIndex = 0;
197
- let tangentIndex = 0;
198
- let bitangentIndex = 0;
199
- let recomputeNormal = true;
200
- let bitangent = bitangentScratch;
201
- let tangent = tangentScratch;
202
- let normal = normalScratch;
203
- if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
204
- for (let i = 0; i < length; i += 6) {
205
- const p = Cartesian3_default.fromArray(positions, i, positionScratch);
206
- const p1 = Cartesian3_default.fromArray(positions, (i + 6) % length, v1Scratch);
207
- if (recomputeNormal) {
208
- const p2 = Cartesian3_default.fromArray(positions, (i + 3) % length, v2Scratch);
209
- Cartesian3_default.subtract(p1, p, p1);
210
- Cartesian3_default.subtract(p2, p, p2);
211
- normal = Cartesian3_default.normalize(Cartesian3_default.cross(p2, p1, normal), normal);
212
- recomputeNormal = false;
213
- }
214
- if (Cartesian3_default.equalsEpsilon(p1, p, Math_default.EPSILON10)) {
215
- recomputeNormal = true;
216
- }
217
- if (vertexFormat.tangent || vertexFormat.bitangent) {
218
- bitangent = ellipsoid.geodeticSurfaceNormal(p, bitangent);
219
- if (vertexFormat.tangent) {
220
- tangent = Cartesian3_default.normalize(
221
- Cartesian3_default.cross(bitangent, normal, tangent),
222
- tangent
223
- );
224
- }
225
- }
226
- if (vertexFormat.normal) {
227
- normals[normalIndex++] = normal.x;
228
- normals[normalIndex++] = normal.y;
229
- normals[normalIndex++] = normal.z;
230
- normals[normalIndex++] = normal.x;
231
- normals[normalIndex++] = normal.y;
232
- normals[normalIndex++] = normal.z;
233
- }
234
- if (vertexFormat.tangent) {
235
- tangents[tangentIndex++] = tangent.x;
236
- tangents[tangentIndex++] = tangent.y;
237
- tangents[tangentIndex++] = tangent.z;
238
- tangents[tangentIndex++] = tangent.x;
239
- tangents[tangentIndex++] = tangent.y;
240
- tangents[tangentIndex++] = tangent.z;
241
- }
242
- if (vertexFormat.bitangent) {
243
- bitangents[bitangentIndex++] = bitangent.x;
244
- bitangents[bitangentIndex++] = bitangent.y;
245
- bitangents[bitangentIndex++] = bitangent.z;
246
- bitangents[bitangentIndex++] = bitangent.x;
247
- bitangents[bitangentIndex++] = bitangent.y;
248
- bitangents[bitangentIndex++] = bitangent.z;
249
- }
250
- }
251
- }
252
- return createAttributes(vertexFormat, {
253
- positions,
254
- normals,
255
- tangents,
256
- bitangents
257
- });
258
- }
259
- function constructRectangle(rectangleGeometry, computedOptions) {
260
- const vertexFormat = rectangleGeometry._vertexFormat;
261
- const ellipsoid = rectangleGeometry._ellipsoid;
262
- const height = computedOptions.height;
263
- const width = computedOptions.width;
264
- const northCap = computedOptions.northCap;
265
- const southCap = computedOptions.southCap;
266
- let rowStart = 0;
267
- let rowEnd = height;
268
- let rowHeight = height;
269
- let size = 0;
270
- if (northCap) {
271
- rowStart = 1;
272
- rowHeight -= 1;
273
- size += 1;
274
- }
275
- if (southCap) {
276
- rowEnd -= 1;
277
- rowHeight -= 1;
278
- size += 1;
279
- }
280
- size += width * rowHeight;
281
- const positions = vertexFormat.position ? new Float64Array(size * 3) : void 0;
282
- const textureCoordinates = vertexFormat.st ? new Float32Array(size * 2) : void 0;
283
- let posIndex = 0;
284
- let stIndex = 0;
285
- const position = positionScratch;
286
- const st = stScratch;
287
- let minX = Number.MAX_VALUE;
288
- let minY = Number.MAX_VALUE;
289
- let maxX = -Number.MAX_VALUE;
290
- let maxY = -Number.MAX_VALUE;
291
- for (let row = rowStart; row < rowEnd; ++row) {
292
- for (let col = 0; col < width; ++col) {
293
- RectangleGeometryLibrary_default.computePosition(
294
- computedOptions,
295
- ellipsoid,
296
- vertexFormat.st,
297
- row,
298
- col,
299
- position,
300
- st
301
- );
302
- positions[posIndex++] = position.x;
303
- positions[posIndex++] = position.y;
304
- positions[posIndex++] = position.z;
305
- if (vertexFormat.st) {
306
- textureCoordinates[stIndex++] = st.x;
307
- textureCoordinates[stIndex++] = st.y;
308
- minX = Math.min(minX, st.x);
309
- minY = Math.min(minY, st.y);
310
- maxX = Math.max(maxX, st.x);
311
- maxY = Math.max(maxY, st.y);
312
- }
313
- }
314
- }
315
- if (northCap) {
316
- RectangleGeometryLibrary_default.computePosition(
317
- computedOptions,
318
- ellipsoid,
319
- vertexFormat.st,
320
- 0,
321
- 0,
322
- position,
323
- st
324
- );
325
- positions[posIndex++] = position.x;
326
- positions[posIndex++] = position.y;
327
- positions[posIndex++] = position.z;
328
- if (vertexFormat.st) {
329
- textureCoordinates[stIndex++] = st.x;
330
- textureCoordinates[stIndex++] = st.y;
331
- minX = st.x;
332
- minY = st.y;
333
- maxX = st.x;
334
- maxY = st.y;
335
- }
336
- }
337
- if (southCap) {
338
- RectangleGeometryLibrary_default.computePosition(
339
- computedOptions,
340
- ellipsoid,
341
- vertexFormat.st,
342
- height - 1,
343
- 0,
344
- position,
345
- st
346
- );
347
- positions[posIndex++] = position.x;
348
- positions[posIndex++] = position.y;
349
- positions[posIndex] = position.z;
350
- if (vertexFormat.st) {
351
- textureCoordinates[stIndex++] = st.x;
352
- textureCoordinates[stIndex] = st.y;
353
- minX = Math.min(minX, st.x);
354
- minY = Math.min(minY, st.y);
355
- maxX = Math.max(maxX, st.x);
356
- maxY = Math.max(maxY, st.y);
357
- }
358
- }
359
- if (vertexFormat.st && (minX < 0 || minY < 0 || maxX > 1 || maxY > 1)) {
360
- for (let k = 0; k < textureCoordinates.length; k += 2) {
361
- textureCoordinates[k] = (textureCoordinates[k] - minX) / (maxX - minX);
362
- textureCoordinates[k + 1] = (textureCoordinates[k + 1] - minY) / (maxY - minY);
363
- }
364
- }
365
- const geo = calculateAttributes(
366
- positions,
367
- vertexFormat,
368
- ellipsoid,
369
- computedOptions.tangentRotationMatrix
370
- );
371
- let indicesSize = 6 * (width - 1) * (rowHeight - 1);
372
- if (northCap) {
373
- indicesSize += 3 * (width - 1);
374
- }
375
- if (southCap) {
376
- indicesSize += 3 * (width - 1);
377
- }
378
- const indices = IndexDatatype_default.createTypedArray(size, indicesSize);
379
- let index = 0;
380
- let indicesIndex = 0;
381
- let i;
382
- for (i = 0; i < rowHeight - 1; ++i) {
383
- for (let j = 0; j < width - 1; ++j) {
384
- const upperLeft = index;
385
- const lowerLeft = upperLeft + width;
386
- const lowerRight = lowerLeft + 1;
387
- const upperRight = upperLeft + 1;
388
- indices[indicesIndex++] = upperLeft;
389
- indices[indicesIndex++] = lowerLeft;
390
- indices[indicesIndex++] = upperRight;
391
- indices[indicesIndex++] = upperRight;
392
- indices[indicesIndex++] = lowerLeft;
393
- indices[indicesIndex++] = lowerRight;
394
- ++index;
395
- }
396
- ++index;
397
- }
398
- if (northCap || southCap) {
399
- let northIndex = size - 1;
400
- const southIndex = size - 1;
401
- if (northCap && southCap) {
402
- northIndex = size - 2;
403
- }
404
- let p1;
405
- let p2;
406
- index = 0;
407
- if (northCap) {
408
- for (i = 0; i < width - 1; i++) {
409
- p1 = index;
410
- p2 = p1 + 1;
411
- indices[indicesIndex++] = northIndex;
412
- indices[indicesIndex++] = p1;
413
- indices[indicesIndex++] = p2;
414
- ++index;
415
- }
416
- }
417
- if (southCap) {
418
- index = (rowHeight - 1) * width;
419
- for (i = 0; i < width - 1; i++) {
420
- p1 = index;
421
- p2 = p1 + 1;
422
- indices[indicesIndex++] = p1;
423
- indices[indicesIndex++] = southIndex;
424
- indices[indicesIndex++] = p2;
425
- ++index;
426
- }
427
- }
428
- }
429
- geo.indices = indices;
430
- if (vertexFormat.st) {
431
- geo.attributes.st = new GeometryAttribute_default({
432
- componentDatatype: ComponentDatatype_default.FLOAT,
433
- componentsPerAttribute: 2,
434
- values: textureCoordinates
435
- });
436
- }
437
- return geo;
438
- }
439
- function addWallPositions(wallPositions, posIndex, i, topPositions, bottomPositions) {
440
- wallPositions[posIndex++] = topPositions[i];
441
- wallPositions[posIndex++] = topPositions[i + 1];
442
- wallPositions[posIndex++] = topPositions[i + 2];
443
- wallPositions[posIndex++] = bottomPositions[i];
444
- wallPositions[posIndex++] = bottomPositions[i + 1];
445
- wallPositions[posIndex] = bottomPositions[i + 2];
446
- return wallPositions;
447
- }
448
- function addWallTextureCoordinates(wallTextures, stIndex, i, st) {
449
- wallTextures[stIndex++] = st[i];
450
- wallTextures[stIndex++] = st[i + 1];
451
- wallTextures[stIndex++] = st[i];
452
- wallTextures[stIndex] = st[i + 1];
453
- return wallTextures;
454
- }
455
- var scratchVertexFormat = new VertexFormat_default();
456
- function constructExtrudedRectangle(rectangleGeometry, computedOptions) {
457
- const shadowVolume = rectangleGeometry._shadowVolume;
458
- const offsetAttributeValue = rectangleGeometry._offsetAttribute;
459
- const vertexFormat = rectangleGeometry._vertexFormat;
460
- const minHeight = rectangleGeometry._extrudedHeight;
461
- const maxHeight = rectangleGeometry._surfaceHeight;
462
- const ellipsoid = rectangleGeometry._ellipsoid;
463
- const height = computedOptions.height;
464
- const width = computedOptions.width;
465
- let i;
466
- if (shadowVolume) {
467
- const newVertexFormat = VertexFormat_default.clone(
468
- vertexFormat,
469
- scratchVertexFormat
470
- );
471
- newVertexFormat.normal = true;
472
- rectangleGeometry._vertexFormat = newVertexFormat;
473
- }
474
- const topBottomGeo = constructRectangle(rectangleGeometry, computedOptions);
475
- if (shadowVolume) {
476
- rectangleGeometry._vertexFormat = vertexFormat;
477
- }
478
- let topPositions = PolygonPipeline_default.scaleToGeodeticHeight(
479
- topBottomGeo.attributes.position.values,
480
- maxHeight,
481
- ellipsoid,
482
- false
483
- );
484
- topPositions = new Float64Array(topPositions);
485
- let length = topPositions.length;
486
- const newLength = length * 2;
487
- const positions = new Float64Array(newLength);
488
- positions.set(topPositions);
489
- const bottomPositions = PolygonPipeline_default.scaleToGeodeticHeight(
490
- topBottomGeo.attributes.position.values,
491
- minHeight,
492
- ellipsoid
493
- );
494
- positions.set(bottomPositions, length);
495
- topBottomGeo.attributes.position.values = positions;
496
- const normals = vertexFormat.normal ? new Float32Array(newLength) : void 0;
497
- const tangents = vertexFormat.tangent ? new Float32Array(newLength) : void 0;
498
- const bitangents = vertexFormat.bitangent ? new Float32Array(newLength) : void 0;
499
- const textures = vertexFormat.st ? new Float32Array(newLength / 3 * 2) : void 0;
500
- let topSt;
501
- let topNormals;
502
- if (vertexFormat.normal) {
503
- topNormals = topBottomGeo.attributes.normal.values;
504
- normals.set(topNormals);
505
- for (i = 0; i < length; i++) {
506
- topNormals[i] = -topNormals[i];
507
- }
508
- normals.set(topNormals, length);
509
- topBottomGeo.attributes.normal.values = normals;
510
- }
511
- if (shadowVolume) {
512
- topNormals = topBottomGeo.attributes.normal.values;
513
- if (!vertexFormat.normal) {
514
- topBottomGeo.attributes.normal = void 0;
515
- }
516
- const extrudeNormals = new Float32Array(newLength);
517
- for (i = 0; i < length; i++) {
518
- topNormals[i] = -topNormals[i];
519
- }
520
- extrudeNormals.set(topNormals, length);
521
- topBottomGeo.attributes.extrudeDirection = new GeometryAttribute_default({
522
- componentDatatype: ComponentDatatype_default.FLOAT,
523
- componentsPerAttribute: 3,
524
- values: extrudeNormals
525
- });
526
- }
527
- let offsetValue;
528
- const hasOffsets = defined_default(offsetAttributeValue);
529
- if (hasOffsets) {
530
- const size = length / 3 * 2;
531
- let offsetAttribute = new Uint8Array(size);
532
- if (offsetAttributeValue === GeometryOffsetAttribute_default.TOP) {
533
- offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
534
- } else {
535
- offsetValue = offsetAttributeValue === GeometryOffsetAttribute_default.NONE ? 0 : 1;
536
- offsetAttribute = offsetAttribute.fill(offsetValue);
537
- }
538
- topBottomGeo.attributes.applyOffset = new GeometryAttribute_default({
539
- componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
540
- componentsPerAttribute: 1,
541
- values: offsetAttribute
542
- });
543
- }
544
- if (vertexFormat.tangent) {
545
- const topTangents = topBottomGeo.attributes.tangent.values;
546
- tangents.set(topTangents);
547
- for (i = 0; i < length; i++) {
548
- topTangents[i] = -topTangents[i];
549
- }
550
- tangents.set(topTangents, length);
551
- topBottomGeo.attributes.tangent.values = tangents;
552
- }
553
- if (vertexFormat.bitangent) {
554
- const topBitangents = topBottomGeo.attributes.bitangent.values;
555
- bitangents.set(topBitangents);
556
- bitangents.set(topBitangents, length);
557
- topBottomGeo.attributes.bitangent.values = bitangents;
558
- }
559
- if (vertexFormat.st) {
560
- topSt = topBottomGeo.attributes.st.values;
561
- textures.set(topSt);
562
- textures.set(topSt, length / 3 * 2);
563
- topBottomGeo.attributes.st.values = textures;
564
- }
565
- const indices = topBottomGeo.indices;
566
- const indicesLength = indices.length;
567
- const posLength = length / 3;
568
- const newIndices = IndexDatatype_default.createTypedArray(
569
- newLength / 3,
570
- indicesLength * 2
571
- );
572
- newIndices.set(indices);
573
- for (i = 0; i < indicesLength; i += 3) {
574
- newIndices[i + indicesLength] = indices[i + 2] + posLength;
575
- newIndices[i + 1 + indicesLength] = indices[i + 1] + posLength;
576
- newIndices[i + 2 + indicesLength] = indices[i] + posLength;
577
- }
578
- topBottomGeo.indices = newIndices;
579
- const northCap = computedOptions.northCap;
580
- const southCap = computedOptions.southCap;
581
- let rowHeight = height;
582
- let widthMultiplier = 2;
583
- let perimeterPositions = 0;
584
- let corners = 4;
585
- let dupliateCorners = 4;
586
- if (northCap) {
587
- widthMultiplier -= 1;
588
- rowHeight -= 1;
589
- perimeterPositions += 1;
590
- corners -= 2;
591
- dupliateCorners -= 1;
592
- }
593
- if (southCap) {
594
- widthMultiplier -= 1;
595
- rowHeight -= 1;
596
- perimeterPositions += 1;
597
- corners -= 2;
598
- dupliateCorners -= 1;
599
- }
600
- perimeterPositions += widthMultiplier * width + 2 * rowHeight - corners;
601
- const wallCount = (perimeterPositions + dupliateCorners) * 2;
602
- let wallPositions = new Float64Array(wallCount * 3);
603
- const wallExtrudeNormals = shadowVolume ? new Float32Array(wallCount * 3) : void 0;
604
- let wallOffsetAttribute = hasOffsets ? new Uint8Array(wallCount) : void 0;
605
- let wallTextures = vertexFormat.st ? new Float32Array(wallCount * 2) : void 0;
606
- const computeTopOffsets = offsetAttributeValue === GeometryOffsetAttribute_default.TOP;
607
- if (hasOffsets && !computeTopOffsets) {
608
- offsetValue = offsetAttributeValue === GeometryOffsetAttribute_default.ALL ? 1 : 0;
609
- wallOffsetAttribute = wallOffsetAttribute.fill(offsetValue);
610
- }
611
- let posIndex = 0;
612
- let stIndex = 0;
613
- let extrudeNormalIndex = 0;
614
- let wallOffsetIndex = 0;
615
- const area = width * rowHeight;
616
- let threeI;
617
- for (i = 0; i < area; i += width) {
618
- threeI = i * 3;
619
- wallPositions = addWallPositions(
620
- wallPositions,
621
- posIndex,
622
- threeI,
623
- topPositions,
624
- bottomPositions
625
- );
626
- posIndex += 6;
627
- if (vertexFormat.st) {
628
- wallTextures = addWallTextureCoordinates(
629
- wallTextures,
630
- stIndex,
631
- i * 2,
632
- topSt
633
- );
634
- stIndex += 4;
635
- }
636
- if (shadowVolume) {
637
- extrudeNormalIndex += 3;
638
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
639
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
640
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
641
- }
642
- if (computeTopOffsets) {
643
- wallOffsetAttribute[wallOffsetIndex++] = 1;
644
- wallOffsetIndex += 1;
645
- }
646
- }
647
- if (!southCap) {
648
- for (i = area - width; i < area; i++) {
649
- threeI = i * 3;
650
- wallPositions = addWallPositions(
651
- wallPositions,
652
- posIndex,
653
- threeI,
654
- topPositions,
655
- bottomPositions
656
- );
657
- posIndex += 6;
658
- if (vertexFormat.st) {
659
- wallTextures = addWallTextureCoordinates(
660
- wallTextures,
661
- stIndex,
662
- i * 2,
663
- topSt
664
- );
665
- stIndex += 4;
666
- }
667
- if (shadowVolume) {
668
- extrudeNormalIndex += 3;
669
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
670
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
671
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
672
- }
673
- if (computeTopOffsets) {
674
- wallOffsetAttribute[wallOffsetIndex++] = 1;
675
- wallOffsetIndex += 1;
676
- }
677
- }
678
- } else {
679
- const southIndex = northCap ? area + 1 : area;
680
- threeI = southIndex * 3;
681
- for (i = 0; i < 2; i++) {
682
- wallPositions = addWallPositions(
683
- wallPositions,
684
- posIndex,
685
- threeI,
686
- topPositions,
687
- bottomPositions
688
- );
689
- posIndex += 6;
690
- if (vertexFormat.st) {
691
- wallTextures = addWallTextureCoordinates(
692
- wallTextures,
693
- stIndex,
694
- southIndex * 2,
695
- topSt
696
- );
697
- stIndex += 4;
698
- }
699
- if (shadowVolume) {
700
- extrudeNormalIndex += 3;
701
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
702
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
703
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
704
- }
705
- if (computeTopOffsets) {
706
- wallOffsetAttribute[wallOffsetIndex++] = 1;
707
- wallOffsetIndex += 1;
708
- }
709
- }
710
- }
711
- for (i = area - 1; i > 0; i -= width) {
712
- threeI = i * 3;
713
- wallPositions = addWallPositions(
714
- wallPositions,
715
- posIndex,
716
- threeI,
717
- topPositions,
718
- bottomPositions
719
- );
720
- posIndex += 6;
721
- if (vertexFormat.st) {
722
- wallTextures = addWallTextureCoordinates(
723
- wallTextures,
724
- stIndex,
725
- i * 2,
726
- topSt
727
- );
728
- stIndex += 4;
729
- }
730
- if (shadowVolume) {
731
- extrudeNormalIndex += 3;
732
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
733
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
734
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
735
- }
736
- if (computeTopOffsets) {
737
- wallOffsetAttribute[wallOffsetIndex++] = 1;
738
- wallOffsetIndex += 1;
739
- }
740
- }
741
- if (!northCap) {
742
- for (i = width - 1; i >= 0; i--) {
743
- threeI = i * 3;
744
- wallPositions = addWallPositions(
745
- wallPositions,
746
- posIndex,
747
- threeI,
748
- topPositions,
749
- bottomPositions
750
- );
751
- posIndex += 6;
752
- if (vertexFormat.st) {
753
- wallTextures = addWallTextureCoordinates(
754
- wallTextures,
755
- stIndex,
756
- i * 2,
757
- topSt
758
- );
759
- stIndex += 4;
760
- }
761
- if (shadowVolume) {
762
- extrudeNormalIndex += 3;
763
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
764
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
765
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
766
- }
767
- if (computeTopOffsets) {
768
- wallOffsetAttribute[wallOffsetIndex++] = 1;
769
- wallOffsetIndex += 1;
770
- }
771
- }
772
- } else {
773
- const northIndex = area;
774
- threeI = northIndex * 3;
775
- for (i = 0; i < 2; i++) {
776
- wallPositions = addWallPositions(
777
- wallPositions,
778
- posIndex,
779
- threeI,
780
- topPositions,
781
- bottomPositions
782
- );
783
- posIndex += 6;
784
- if (vertexFormat.st) {
785
- wallTextures = addWallTextureCoordinates(
786
- wallTextures,
787
- stIndex,
788
- northIndex * 2,
789
- topSt
790
- );
791
- stIndex += 4;
792
- }
793
- if (shadowVolume) {
794
- extrudeNormalIndex += 3;
795
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
796
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
797
- wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
798
- }
799
- if (computeTopOffsets) {
800
- wallOffsetAttribute[wallOffsetIndex++] = 1;
801
- wallOffsetIndex += 1;
802
- }
803
- }
804
- }
805
- let geo = calculateAttributesWall(wallPositions, vertexFormat, ellipsoid);
806
- if (vertexFormat.st) {
807
- geo.attributes.st = new GeometryAttribute_default({
808
- componentDatatype: ComponentDatatype_default.FLOAT,
809
- componentsPerAttribute: 2,
810
- values: wallTextures
811
- });
812
- }
813
- if (shadowVolume) {
814
- geo.attributes.extrudeDirection = new GeometryAttribute_default({
815
- componentDatatype: ComponentDatatype_default.FLOAT,
816
- componentsPerAttribute: 3,
817
- values: wallExtrudeNormals
818
- });
819
- }
820
- if (hasOffsets) {
821
- geo.attributes.applyOffset = new GeometryAttribute_default({
822
- componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
823
- componentsPerAttribute: 1,
824
- values: wallOffsetAttribute
825
- });
826
- }
827
- const wallIndices = IndexDatatype_default.createTypedArray(
828
- wallCount,
829
- perimeterPositions * 6
830
- );
831
- let upperLeft;
832
- let lowerLeft;
833
- let lowerRight;
834
- let upperRight;
835
- length = wallPositions.length / 3;
836
- let index = 0;
837
- for (i = 0; i < length - 1; i += 2) {
838
- upperLeft = i;
839
- upperRight = (upperLeft + 2) % length;
840
- const p1 = Cartesian3_default.fromArray(wallPositions, upperLeft * 3, v1Scratch);
841
- const p2 = Cartesian3_default.fromArray(wallPositions, upperRight * 3, v2Scratch);
842
- if (Cartesian3_default.equalsEpsilon(p1, p2, Math_default.EPSILON10)) {
843
- continue;
844
- }
845
- lowerLeft = (upperLeft + 1) % length;
846
- lowerRight = (lowerLeft + 2) % length;
847
- wallIndices[index++] = upperLeft;
848
- wallIndices[index++] = lowerLeft;
849
- wallIndices[index++] = upperRight;
850
- wallIndices[index++] = upperRight;
851
- wallIndices[index++] = lowerLeft;
852
- wallIndices[index++] = lowerRight;
853
- }
854
- geo.indices = wallIndices;
855
- geo = GeometryPipeline_default.combineInstances([
856
- new GeometryInstance_default({
857
- geometry: topBottomGeo
858
- }),
859
- new GeometryInstance_default({
860
- geometry: geo
861
- })
862
- ]);
863
- return geo[0];
864
- }
865
- var scratchRectanglePoints = [
866
- new Cartesian3_default(),
867
- new Cartesian3_default(),
868
- new Cartesian3_default(),
869
- new Cartesian3_default()
870
- ];
871
- var nwScratch = new Cartographic_default();
872
- var stNwScratch = new Cartographic_default();
873
- function computeRectangle(rectangle, granularity, rotation, ellipsoid, result) {
874
- if (rotation === 0) {
875
- return Rectangle_default.clone(rectangle, result);
876
- }
877
- const computedOptions = RectangleGeometryLibrary_default.computeOptions(
878
- rectangle,
879
- granularity,
880
- rotation,
881
- 0,
882
- rectangleScratch,
883
- nwScratch
884
- );
885
- const height = computedOptions.height;
886
- const width = computedOptions.width;
887
- const positions = scratchRectanglePoints;
888
- RectangleGeometryLibrary_default.computePosition(
889
- computedOptions,
890
- ellipsoid,
891
- false,
892
- 0,
893
- 0,
894
- positions[0]
895
- );
896
- RectangleGeometryLibrary_default.computePosition(
897
- computedOptions,
898
- ellipsoid,
899
- false,
900
- 0,
901
- width - 1,
902
- positions[1]
903
- );
904
- RectangleGeometryLibrary_default.computePosition(
905
- computedOptions,
906
- ellipsoid,
907
- false,
908
- height - 1,
909
- 0,
910
- positions[2]
911
- );
912
- RectangleGeometryLibrary_default.computePosition(
913
- computedOptions,
914
- ellipsoid,
915
- false,
916
- height - 1,
917
- width - 1,
918
- positions[3]
919
- );
920
- return Rectangle_default.fromCartesianArray(positions, ellipsoid, result);
921
- }
922
- function RectangleGeometry(options) {
923
- options = options ?? Frozen_default.EMPTY_OBJECT;
924
- const rectangle = options.rectangle;
925
- Check_default.typeOf.object("rectangle", rectangle);
926
- Rectangle_default._validate(rectangle);
927
- if (rectangle.north < rectangle.south) {
928
- throw new DeveloperError_default(
929
- "options.rectangle.north must be greater than or equal to options.rectangle.south"
930
- );
931
- }
932
- const height = options.height ?? 0;
933
- const extrudedHeight = options.extrudedHeight ?? height;
934
- this._rectangle = Rectangle_default.clone(rectangle);
935
- this._granularity = options.granularity ?? Math_default.RADIANS_PER_DEGREE;
936
- this._ellipsoid = Ellipsoid_default.clone(options.ellipsoid ?? Ellipsoid_default.default);
937
- this._surfaceHeight = Math.max(height, extrudedHeight);
938
- this._rotation = options.rotation ?? 0;
939
- this._stRotation = options.stRotation ?? 0;
940
- this._vertexFormat = VertexFormat_default.clone(
941
- options.vertexFormat ?? VertexFormat_default.DEFAULT
942
- );
943
- this._extrudedHeight = Math.min(height, extrudedHeight);
944
- this._shadowVolume = options.shadowVolume ?? false;
945
- this._workerName = "createRectangleGeometry";
946
- this._offsetAttribute = options.offsetAttribute;
947
- this._rotatedRectangle = void 0;
948
- this._textureCoordinateRotationPoints = void 0;
949
- }
950
- RectangleGeometry.packedLength = Rectangle_default.packedLength + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 7;
951
- RectangleGeometry.pack = function(value, array, startingIndex) {
952
- Check_default.typeOf.object("value", value);
953
- Check_default.defined("array", array);
954
- startingIndex = startingIndex ?? 0;
955
- Rectangle_default.pack(value._rectangle, array, startingIndex);
956
- startingIndex += Rectangle_default.packedLength;
957
- Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
958
- startingIndex += Ellipsoid_default.packedLength;
959
- VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
960
- startingIndex += VertexFormat_default.packedLength;
961
- array[startingIndex++] = value._granularity;
962
- array[startingIndex++] = value._surfaceHeight;
963
- array[startingIndex++] = value._rotation;
964
- array[startingIndex++] = value._stRotation;
965
- array[startingIndex++] = value._extrudedHeight;
966
- array[startingIndex++] = value._shadowVolume ? 1 : 0;
967
- array[startingIndex] = value._offsetAttribute ?? -1;
968
- return array;
969
- };
970
- var scratchRectangle = new Rectangle_default();
971
- var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
972
- var scratchOptions = {
973
- rectangle: scratchRectangle,
974
- ellipsoid: scratchEllipsoid,
975
- vertexFormat: scratchVertexFormat,
976
- granularity: void 0,
977
- height: void 0,
978
- rotation: void 0,
979
- stRotation: void 0,
980
- extrudedHeight: void 0,
981
- shadowVolume: void 0,
982
- offsetAttribute: void 0
983
- };
984
- RectangleGeometry.unpack = function(array, startingIndex, result) {
985
- Check_default.defined("array", array);
986
- startingIndex = startingIndex ?? 0;
987
- const rectangle = Rectangle_default.unpack(array, startingIndex, scratchRectangle);
988
- startingIndex += Rectangle_default.packedLength;
989
- const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
990
- startingIndex += Ellipsoid_default.packedLength;
991
- const vertexFormat = VertexFormat_default.unpack(
992
- array,
993
- startingIndex,
994
- scratchVertexFormat
995
- );
996
- startingIndex += VertexFormat_default.packedLength;
997
- const granularity = array[startingIndex++];
998
- const surfaceHeight = array[startingIndex++];
999
- const rotation = array[startingIndex++];
1000
- const stRotation = array[startingIndex++];
1001
- const extrudedHeight = array[startingIndex++];
1002
- const shadowVolume = array[startingIndex++] === 1;
1003
- const offsetAttribute = array[startingIndex];
1004
- if (!defined_default(result)) {
1005
- scratchOptions.granularity = granularity;
1006
- scratchOptions.height = surfaceHeight;
1007
- scratchOptions.rotation = rotation;
1008
- scratchOptions.stRotation = stRotation;
1009
- scratchOptions.extrudedHeight = extrudedHeight;
1010
- scratchOptions.shadowVolume = shadowVolume;
1011
- scratchOptions.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
1012
- return new RectangleGeometry(scratchOptions);
1013
- }
1014
- result._rectangle = Rectangle_default.clone(rectangle, result._rectangle);
1015
- result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
1016
- result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
1017
- result._granularity = granularity;
1018
- result._surfaceHeight = surfaceHeight;
1019
- result._rotation = rotation;
1020
- result._stRotation = stRotation;
1021
- result._extrudedHeight = extrudedHeight;
1022
- result._shadowVolume = shadowVolume;
1023
- result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
1024
- return result;
1025
- };
1026
- RectangleGeometry.computeRectangle = function(options, result) {
1027
- options = options ?? Frozen_default.EMPTY_OBJECT;
1028
- const rectangle = options.rectangle;
1029
- Check_default.typeOf.object("rectangle", rectangle);
1030
- Rectangle_default._validate(rectangle);
1031
- if (rectangle.north < rectangle.south) {
1032
- throw new DeveloperError_default(
1033
- "options.rectangle.north must be greater than or equal to options.rectangle.south"
1034
- );
1035
- }
1036
- const granularity = options.granularity ?? Math_default.RADIANS_PER_DEGREE;
1037
- const ellipsoid = options.ellipsoid ?? Ellipsoid_default.default;
1038
- const rotation = options.rotation ?? 0;
1039
- return computeRectangle(rectangle, granularity, rotation, ellipsoid, result);
1040
- };
1041
- var tangentRotationMatrixScratch = new Matrix3_default();
1042
- var quaternionScratch = new Quaternion_default();
1043
- var centerScratch = new Cartographic_default();
1044
- RectangleGeometry.createGeometry = function(rectangleGeometry) {
1045
- if (Math_default.equalsEpsilon(
1046
- rectangleGeometry._rectangle.north,
1047
- rectangleGeometry._rectangle.south,
1048
- Math_default.EPSILON10
1049
- ) || Math_default.equalsEpsilon(
1050
- rectangleGeometry._rectangle.east,
1051
- rectangleGeometry._rectangle.west,
1052
- Math_default.EPSILON10
1053
- )) {
1054
- return void 0;
1055
- }
1056
- let rectangle = rectangleGeometry._rectangle;
1057
- const ellipsoid = rectangleGeometry._ellipsoid;
1058
- const rotation = rectangleGeometry._rotation;
1059
- const stRotation = rectangleGeometry._stRotation;
1060
- const vertexFormat = rectangleGeometry._vertexFormat;
1061
- const computedOptions = RectangleGeometryLibrary_default.computeOptions(
1062
- rectangle,
1063
- rectangleGeometry._granularity,
1064
- rotation,
1065
- stRotation,
1066
- rectangleScratch,
1067
- nwScratch,
1068
- stNwScratch
1069
- );
1070
- const tangentRotationMatrix = tangentRotationMatrixScratch;
1071
- if (stRotation !== 0 || rotation !== 0) {
1072
- const center = Rectangle_default.center(rectangle, centerScratch);
1073
- const axis = ellipsoid.geodeticSurfaceNormalCartographic(center, v1Scratch);
1074
- Quaternion_default.fromAxisAngle(axis, -stRotation, quaternionScratch);
1075
- Matrix3_default.fromQuaternion(quaternionScratch, tangentRotationMatrix);
1076
- } else {
1077
- Matrix3_default.clone(Matrix3_default.IDENTITY, tangentRotationMatrix);
1078
- }
1079
- const surfaceHeight = rectangleGeometry._surfaceHeight;
1080
- const extrudedHeight = rectangleGeometry._extrudedHeight;
1081
- const extrude = !Math_default.equalsEpsilon(
1082
- surfaceHeight,
1083
- extrudedHeight,
1084
- 0,
1085
- Math_default.EPSILON2
1086
- );
1087
- computedOptions.lonScalar = 1 / rectangleGeometry._rectangle.width;
1088
- computedOptions.latScalar = 1 / rectangleGeometry._rectangle.height;
1089
- computedOptions.tangentRotationMatrix = tangentRotationMatrix;
1090
- let geometry;
1091
- let boundingSphere;
1092
- rectangle = rectangleGeometry._rectangle;
1093
- if (extrude) {
1094
- geometry = constructExtrudedRectangle(rectangleGeometry, computedOptions);
1095
- const topBS = BoundingSphere_default.fromRectangle3D(
1096
- rectangle,
1097
- ellipsoid,
1098
- surfaceHeight,
1099
- topBoundingSphere
1100
- );
1101
- const bottomBS = BoundingSphere_default.fromRectangle3D(
1102
- rectangle,
1103
- ellipsoid,
1104
- extrudedHeight,
1105
- bottomBoundingSphere
1106
- );
1107
- boundingSphere = BoundingSphere_default.union(topBS, bottomBS);
1108
- } else {
1109
- geometry = constructRectangle(rectangleGeometry, computedOptions);
1110
- geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
1111
- geometry.attributes.position.values,
1112
- surfaceHeight,
1113
- ellipsoid,
1114
- false
1115
- );
1116
- if (defined_default(rectangleGeometry._offsetAttribute)) {
1117
- const length = geometry.attributes.position.values.length;
1118
- const offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
1119
- const applyOffset = new Uint8Array(length / 3).fill(offsetValue);
1120
- geometry.attributes.applyOffset = new GeometryAttribute_default({
1121
- componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
1122
- componentsPerAttribute: 1,
1123
- values: applyOffset
1124
- });
1125
- }
1126
- boundingSphere = BoundingSphere_default.fromRectangle3D(
1127
- rectangle,
1128
- ellipsoid,
1129
- surfaceHeight
1130
- );
1131
- }
1132
- if (!vertexFormat.position) {
1133
- delete geometry.attributes.position;
1134
- }
1135
- return new Geometry_default({
1136
- attributes: geometry.attributes,
1137
- indices: geometry.indices,
1138
- primitiveType: geometry.primitiveType,
1139
- boundingSphere,
1140
- offsetAttribute: rectangleGeometry._offsetAttribute
1141
- });
1142
- };
1143
- RectangleGeometry.createShadowVolume = function(rectangleGeometry, minHeightFunc, maxHeightFunc) {
1144
- const granularity = rectangleGeometry._granularity;
1145
- const ellipsoid = rectangleGeometry._ellipsoid;
1146
- const minHeight = minHeightFunc(granularity, ellipsoid);
1147
- const maxHeight = maxHeightFunc(granularity, ellipsoid);
1148
- return new RectangleGeometry({
1149
- rectangle: rectangleGeometry._rectangle,
1150
- rotation: rectangleGeometry._rotation,
1151
- ellipsoid,
1152
- stRotation: rectangleGeometry._stRotation,
1153
- granularity,
1154
- extrudedHeight: maxHeight,
1155
- height: minHeight,
1156
- vertexFormat: VertexFormat_default.POSITION_ONLY,
1157
- shadowVolume: true
1158
- });
1159
- };
1160
- var unrotatedTextureRectangleScratch = new Rectangle_default();
1161
- var points2DScratch = [new Cartesian2_default(), new Cartesian2_default(), new Cartesian2_default()];
1162
- var rotation2DScratch = new Matrix2_default();
1163
- var rectangleCenterScratch = new Cartographic_default();
1164
- function textureCoordinateRotationPoints(rectangleGeometry) {
1165
- if (rectangleGeometry._stRotation === 0) {
1166
- return [0, 0, 0, 1, 1, 0];
1167
- }
1168
- const rectangle = Rectangle_default.clone(
1169
- rectangleGeometry._rectangle,
1170
- unrotatedTextureRectangleScratch
1171
- );
1172
- const granularity = rectangleGeometry._granularity;
1173
- const ellipsoid = rectangleGeometry._ellipsoid;
1174
- const rotation = rectangleGeometry._rotation - rectangleGeometry._stRotation;
1175
- const unrotatedTextureRectangle = computeRectangle(
1176
- rectangle,
1177
- granularity,
1178
- rotation,
1179
- ellipsoid,
1180
- unrotatedTextureRectangleScratch
1181
- );
1182
- const points2D = points2DScratch;
1183
- points2D[0].x = unrotatedTextureRectangle.west;
1184
- points2D[0].y = unrotatedTextureRectangle.south;
1185
- points2D[1].x = unrotatedTextureRectangle.west;
1186
- points2D[1].y = unrotatedTextureRectangle.north;
1187
- points2D[2].x = unrotatedTextureRectangle.east;
1188
- points2D[2].y = unrotatedTextureRectangle.south;
1189
- const boundingRectangle = rectangleGeometry.rectangle;
1190
- const toDesiredInComputed = Matrix2_default.fromRotation(
1191
- rectangleGeometry._stRotation,
1192
- rotation2DScratch
1193
- );
1194
- const boundingRectangleCenter = Rectangle_default.center(
1195
- boundingRectangle,
1196
- rectangleCenterScratch
1197
- );
1198
- for (let i = 0; i < 3; ++i) {
1199
- const point2D = points2D[i];
1200
- point2D.x -= boundingRectangleCenter.longitude;
1201
- point2D.y -= boundingRectangleCenter.latitude;
1202
- Matrix2_default.multiplyByVector(toDesiredInComputed, point2D, point2D);
1203
- point2D.x += boundingRectangleCenter.longitude;
1204
- point2D.y += boundingRectangleCenter.latitude;
1205
- point2D.x = (point2D.x - boundingRectangle.west) / boundingRectangle.width;
1206
- point2D.y = (point2D.y - boundingRectangle.south) / boundingRectangle.height;
1207
- }
1208
- const minXYCorner = points2D[0];
1209
- const maxYCorner = points2D[1];
1210
- const maxXCorner = points2D[2];
1211
- const result = new Array(6);
1212
- Cartesian2_default.pack(minXYCorner, result);
1213
- Cartesian2_default.pack(maxYCorner, result, 2);
1214
- Cartesian2_default.pack(maxXCorner, result, 4);
1215
- return result;
1216
- }
1217
- Object.defineProperties(RectangleGeometry.prototype, {
1218
- /**
1219
- * @private
1220
- */
1221
- rectangle: {
1222
- get: function() {
1223
- if (!defined_default(this._rotatedRectangle)) {
1224
- this._rotatedRectangle = computeRectangle(
1225
- this._rectangle,
1226
- this._granularity,
1227
- this._rotation,
1228
- this._ellipsoid
1229
- );
1230
- }
1231
- return this._rotatedRectangle;
1232
- }
1233
- },
1234
- /**
1235
- * For remapping texture coordinates when rendering RectangleGeometries as GroundPrimitives.
1236
- * This version permits skew in textures by computing offsets directly in cartographic space and
1237
- * more accurately approximates rendering RectangleGeometries with height as standard Primitives.
1238
- * @see Geometry#_textureCoordinateRotationPoints
1239
- * @private
1240
- */
1241
- textureCoordinateRotationPoints: {
1242
- get: function() {
1243
- if (!defined_default(this._textureCoordinateRotationPoints)) {
1244
- this._textureCoordinateRotationPoints = textureCoordinateRotationPoints(this);
1245
- }
1246
- return this._textureCoordinateRotationPoints;
1247
- }
1248
- }
1249
- });
1250
- var RectangleGeometry_default = RectangleGeometry;
1251
-
1252
- // packages/engine/Source/Workers/createRectangleGeometry.js
1253
- function createRectangleGeometry(rectangleGeometry, offset) {
1254
- if (defined_default(offset)) {
1255
- rectangleGeometry = RectangleGeometry_default.unpack(rectangleGeometry, offset);
1256
- }
1257
- rectangleGeometry._ellipsoid = Ellipsoid_default.clone(rectangleGeometry._ellipsoid);
1258
- rectangleGeometry._rectangle = Rectangle_default.clone(rectangleGeometry._rectangle);
1259
- return RectangleGeometry_default.createGeometry(rectangleGeometry);
1260
- }
1261
- var createRectangleGeometry_default = createRectangleGeometry;
1262
- export {
1263
- createRectangleGeometry_default as default
1264
- };