@hztxi/cesium-engine 25.0.4 → 25.0.6

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 (122) hide show
  1. package/Build/Workers/chunk-247MLVK2.js +124 -0
  2. package/Build/Workers/chunk-26I7TIAE.js +58 -0
  3. package/Build/Workers/chunk-26OYTC24.js +38 -0
  4. package/Build/Workers/chunk-2IMOZG7R.js +973 -0
  5. package/Build/Workers/chunk-2L6JGSYJ.js +57 -0
  6. package/Build/Workers/chunk-32N2SB76.js +56 -0
  7. package/Build/Workers/chunk-37WL527K.js +1287 -0
  8. package/Build/Workers/chunk-3IGH46TC.js +1054 -0
  9. package/Build/Workers/chunk-47BSFGJC.js +837 -0
  10. package/Build/Workers/chunk-4J7PL5AM.js +454 -0
  11. package/Build/Workers/chunk-4UMO63VY.js +76 -0
  12. package/Build/Workers/chunk-5YI3TQQC.js +778 -0
  13. package/Build/Workers/chunk-AEZQ2UWS.js +288 -0
  14. package/Build/Workers/chunk-AXE2ZIEG.js +219 -0
  15. package/Build/Workers/chunk-BDR7GL3E.js +1067 -0
  16. package/Build/Workers/chunk-C342XITR.js +44 -0
  17. package/Build/Workers/chunk-CWAUXQRF.js +754 -0
  18. package/Build/Workers/chunk-E5F7LDEP.js +3201 -0
  19. package/Build/Workers/chunk-FAKYMBUA.js +1046 -0
  20. package/Build/Workers/chunk-FSK4OZOO.js +352 -0
  21. package/Build/Workers/chunk-FSLRYNZ6.js +682 -0
  22. package/Build/Workers/chunk-GMDOGAXK.js +2719 -0
  23. package/Build/Workers/chunk-GRAFCIPA.js +455 -0
  24. package/Build/Workers/chunk-HEY4IOS3.js +140 -0
  25. package/Build/Workers/chunk-HRWFO57T.js +301 -0
  26. package/Build/Workers/chunk-HTCLVUBZ.js +82 -0
  27. package/Build/Workers/chunk-I2Q7XDRA.js +630 -0
  28. package/Build/Workers/chunk-ILPH3NF7.js +3794 -0
  29. package/Build/Workers/chunk-JZUUODN6.js +97 -0
  30. package/Build/Workers/chunk-KWVB54J6.js +241 -0
  31. package/Build/Workers/chunk-M3B3ZUU2.js +476 -0
  32. package/Build/Workers/chunk-MKR6YCMG.js +497 -0
  33. package/Build/Workers/chunk-MROMS2RL.js +162 -0
  34. package/Build/Workers/chunk-MUNAUSK7.js +280 -0
  35. package/Build/Workers/chunk-NHU5JEPP.js +1344 -0
  36. package/Build/Workers/chunk-OODXPB45.js +73 -0
  37. package/Build/Workers/chunk-OXZ5J3JW.js +368 -0
  38. package/Build/Workers/chunk-QBSWSTHY.js +257 -0
  39. package/Build/Workers/chunk-QDJYG7QL.js +352 -0
  40. package/Build/Workers/chunk-RX3U2BBW.js +1483 -0
  41. package/Build/Workers/chunk-S3XHL7GO.js +1992 -0
  42. package/Build/Workers/chunk-SBIC4OGS.js +171 -0
  43. package/Build/Workers/chunk-T4CYNROE.js +102 -0
  44. package/Build/Workers/chunk-T5VLPB4H.js +414 -0
  45. package/Build/Workers/chunk-TX763OWB.js +387 -0
  46. package/Build/Workers/chunk-UTAWMCSE.js +163 -0
  47. package/Build/Workers/chunk-VETQOADR.js +2342 -0
  48. package/Build/Workers/chunk-VXRWOM3T.js +101 -0
  49. package/Build/Workers/chunk-WVVFCMYF.js +147 -0
  50. package/Build/Workers/chunk-XAVNBZQ6.js +56 -0
  51. package/Build/Workers/chunk-XDSDR62Y.js +1800 -0
  52. package/Build/Workers/chunk-XDZCVNIZ.js +198 -0
  53. package/Build/Workers/chunk-XNLCW2OI.js +138 -0
  54. package/Build/Workers/chunk-XNQ2BTJD.js +693 -0
  55. package/Build/Workers/chunk-XZYBDSFP.js +305 -0
  56. package/Build/Workers/chunk-YDYN3RPI.js +398 -0
  57. package/Build/Workers/chunk-YMMEQBEW.js +511 -0
  58. package/Build/Workers/chunk-YQFOQAXD.js +9230 -0
  59. package/Build/Workers/combineGeometry.js +24 -24
  60. package/Build/Workers/createBoxGeometry.js +18 -18
  61. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  62. package/Build/Workers/createCircleGeometry.js +26 -26
  63. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  64. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  65. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  66. package/Build/Workers/createCorridorGeometry.js +29 -29
  67. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  68. package/Build/Workers/createCylinderGeometry.js +20 -20
  69. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  70. package/Build/Workers/createEllipseGeometry.js +26 -26
  71. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  73. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  74. package/Build/Workers/createFrustumGeometry.js +18 -18
  75. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  76. package/Build/Workers/createGeometry.js +24 -24
  77. package/Build/Workers/createGroundPolylineGeometry.js +23 -23
  78. package/Build/Workers/createPlaneGeometry.js +16 -16
  79. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  80. package/Build/Workers/createPolygonGeometry.js +32 -32
  81. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  82. package/Build/Workers/createPolylineGeometry.js +25 -25
  83. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  84. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  85. package/Build/Workers/createRectangleGeometry.js +27 -27
  86. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  87. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  88. package/Build/Workers/createSphereGeometry.js +19 -19
  89. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  90. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  91. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  92. package/Build/Workers/createVectorTileGeometries.js +24 -24
  93. package/Build/Workers/createVectorTilePoints.js +13 -13
  94. package/Build/Workers/createVectorTilePolygons.js +22 -22
  95. package/Build/Workers/createVectorTilePolylines.js +14 -14
  96. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +26 -26
  97. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -23
  98. package/Build/Workers/createVerticesFromHeightmap.js +23 -23
  99. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +21 -21
  100. package/Build/Workers/createWallGeometry.js +24 -24
  101. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  102. package/Build/Workers/decodeDraco.js +10 -10
  103. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  104. package/Build/Workers/decodeI3S.js +10 -10
  105. package/Build/Workers/gaussianSplatSorter.js +4 -4
  106. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  107. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  108. package/Build/Workers/transcodeKTX2.js +6 -6
  109. package/Build/Workers/transferTypedArrayTest.js +1 -1
  110. package/Build/Workers/upsampleQuantizedTerrainMesh.js +23 -23
  111. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +26 -26
  112. package/Source/Scene/ClassificationPrimitive.js +63 -3
  113. package/Source/Scene/PolylineCollection.js +4 -2
  114. package/Source/Shaders/PolylineShadowVolumeMorphVS.glsl +14 -1
  115. package/Source/Shaders/PolylineShadowVolumeMorphVS.js +14 -1
  116. package/Source/Shaders/PolylineShadowVolumeVS.glsl +7 -0
  117. package/Source/Shaders/PolylineShadowVolumeVS.js +7 -0
  118. package/Source/Shaders/PolylineVS.glsl +16 -6
  119. package/Source/Shaders/PolylineVS.js +16 -6
  120. package/Source/ThirdParty/zip-module.wasm +0 -0
  121. package/index.js +183 -183
  122. package/package.json +10 -10
@@ -0,0 +1,305 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 1.141.6
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
+ Quaternion_default
28
+ } from "./chunk-YQFOQAXD.js";
29
+ import {
30
+ Cartesian3_default,
31
+ Matrix3_default
32
+ } from "./chunk-VETQOADR.js";
33
+ import {
34
+ Math_default
35
+ } from "./chunk-MKR6YCMG.js";
36
+
37
+ // packages/engine/Source/Core/EllipseGeometryLibrary.js
38
+ var EllipseGeometryLibrary = {};
39
+ var rotAxis = new Cartesian3_default();
40
+ var tempVec = new Cartesian3_default();
41
+ var unitQuat = new Quaternion_default();
42
+ var rotMtx = new Matrix3_default();
43
+ function pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, result) {
44
+ const azimuth = theta + rotation;
45
+ Cartesian3_default.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);
46
+ Cartesian3_default.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);
47
+ Cartesian3_default.add(rotAxis, tempVec, rotAxis);
48
+ let cosThetaSquared = Math.cos(theta);
49
+ cosThetaSquared = cosThetaSquared * cosThetaSquared;
50
+ let sinThetaSquared = Math.sin(theta);
51
+ sinThetaSquared = sinThetaSquared * sinThetaSquared;
52
+ const radius = ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);
53
+ const angle = radius / mag;
54
+ Quaternion_default.fromAxisAngle(rotAxis, angle, unitQuat);
55
+ Matrix3_default.fromQuaternion(unitQuat, rotMtx);
56
+ Matrix3_default.multiplyByVector(rotMtx, unitPos, result);
57
+ Cartesian3_default.normalize(result, result);
58
+ Cartesian3_default.multiplyByScalar(result, mag, result);
59
+ return result;
60
+ }
61
+ var scratchCartesian1 = new Cartesian3_default();
62
+ var scratchCartesian2 = new Cartesian3_default();
63
+ var scratchCartesian3 = new Cartesian3_default();
64
+ var scratchNormal = new Cartesian3_default();
65
+ EllipseGeometryLibrary.raisePositionsToHeight = function(positions, options, extrude) {
66
+ const ellipsoid = options.ellipsoid;
67
+ const height = options.height;
68
+ const extrudedHeight = options.extrudedHeight;
69
+ const size = extrude ? positions.length / 3 * 2 : positions.length / 3;
70
+ const finalPositions = new Float64Array(size * 3);
71
+ const length = positions.length;
72
+ const bottomOffset = extrude ? length : 0;
73
+ for (let i = 0; i < length; i += 3) {
74
+ const i1 = i + 1;
75
+ const i2 = i + 2;
76
+ const position = Cartesian3_default.fromArray(positions, i, scratchCartesian1);
77
+ ellipsoid.scaleToGeodeticSurface(position, position);
78
+ const extrudedPosition = Cartesian3_default.clone(position, scratchCartesian2);
79
+ const normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
80
+ const scaledNormal = Cartesian3_default.multiplyByScalar(
81
+ normal,
82
+ height,
83
+ scratchCartesian3
84
+ );
85
+ Cartesian3_default.add(position, scaledNormal, position);
86
+ if (extrude) {
87
+ Cartesian3_default.multiplyByScalar(normal, extrudedHeight, scaledNormal);
88
+ Cartesian3_default.add(extrudedPosition, scaledNormal, extrudedPosition);
89
+ finalPositions[i + bottomOffset] = extrudedPosition.x;
90
+ finalPositions[i1 + bottomOffset] = extrudedPosition.y;
91
+ finalPositions[i2 + bottomOffset] = extrudedPosition.z;
92
+ }
93
+ finalPositions[i] = position.x;
94
+ finalPositions[i1] = position.y;
95
+ finalPositions[i2] = position.z;
96
+ }
97
+ return finalPositions;
98
+ };
99
+ var unitPosScratch = new Cartesian3_default();
100
+ var eastVecScratch = new Cartesian3_default();
101
+ var northVecScratch = new Cartesian3_default();
102
+ EllipseGeometryLibrary.computeEllipsePositions = function(options, addFillPositions, addEdgePositions) {
103
+ const semiMinorAxis = options.semiMinorAxis;
104
+ const semiMajorAxis = options.semiMajorAxis;
105
+ const rotation = options.rotation;
106
+ const center = options.center;
107
+ const granularity = options.granularity * 8;
108
+ const aSqr = semiMinorAxis * semiMinorAxis;
109
+ const bSqr = semiMajorAxis * semiMajorAxis;
110
+ const ab = semiMajorAxis * semiMinorAxis;
111
+ const mag = Cartesian3_default.magnitude(center);
112
+ const unitPos = Cartesian3_default.normalize(center, unitPosScratch);
113
+ let eastVec = Cartesian3_default.cross(Cartesian3_default.UNIT_Z, center, eastVecScratch);
114
+ eastVec = Cartesian3_default.normalize(eastVec, eastVec);
115
+ const northVec = Cartesian3_default.cross(unitPos, eastVec, northVecScratch);
116
+ let numPts = 1 + Math.ceil(Math_default.PI_OVER_TWO / granularity);
117
+ const deltaTheta = Math_default.PI_OVER_TWO / (numPts - 1);
118
+ let theta = Math_default.PI_OVER_TWO - numPts * deltaTheta;
119
+ if (theta < 0) {
120
+ numPts -= Math.ceil(Math.abs(theta) / deltaTheta);
121
+ }
122
+ const size = 2 * (numPts * (numPts + 2));
123
+ const positions = addFillPositions ? new Array(size * 3) : void 0;
124
+ let positionIndex = 0;
125
+ let position = scratchCartesian1;
126
+ let reflectedPosition = scratchCartesian2;
127
+ const outerPositionsLength = numPts * 4 * 3;
128
+ let outerRightIndex = outerPositionsLength - 1;
129
+ let outerLeftIndex = 0;
130
+ const outerPositions = addEdgePositions ? new Array(outerPositionsLength) : void 0;
131
+ let i;
132
+ let j;
133
+ let numInterior;
134
+ let t;
135
+ let interiorPosition;
136
+ theta = Math_default.PI_OVER_TWO;
137
+ position = pointOnEllipsoid(
138
+ theta,
139
+ rotation,
140
+ northVec,
141
+ eastVec,
142
+ aSqr,
143
+ ab,
144
+ bSqr,
145
+ mag,
146
+ unitPos,
147
+ position
148
+ );
149
+ if (addFillPositions) {
150
+ positions[positionIndex++] = position.x;
151
+ positions[positionIndex++] = position.y;
152
+ positions[positionIndex++] = position.z;
153
+ }
154
+ if (addEdgePositions) {
155
+ outerPositions[outerRightIndex--] = position.z;
156
+ outerPositions[outerRightIndex--] = position.y;
157
+ outerPositions[outerRightIndex--] = position.x;
158
+ }
159
+ theta = Math_default.PI_OVER_TWO - deltaTheta;
160
+ for (i = 1; i < numPts + 1; ++i) {
161
+ position = pointOnEllipsoid(
162
+ theta,
163
+ rotation,
164
+ northVec,
165
+ eastVec,
166
+ aSqr,
167
+ ab,
168
+ bSqr,
169
+ mag,
170
+ unitPos,
171
+ position
172
+ );
173
+ reflectedPosition = pointOnEllipsoid(
174
+ Math.PI - theta,
175
+ rotation,
176
+ northVec,
177
+ eastVec,
178
+ aSqr,
179
+ ab,
180
+ bSqr,
181
+ mag,
182
+ unitPos,
183
+ reflectedPosition
184
+ );
185
+ if (addFillPositions) {
186
+ positions[positionIndex++] = position.x;
187
+ positions[positionIndex++] = position.y;
188
+ positions[positionIndex++] = position.z;
189
+ numInterior = 2 * i + 2;
190
+ for (j = 1; j < numInterior - 1; ++j) {
191
+ t = j / (numInterior - 1);
192
+ interiorPosition = Cartesian3_default.lerp(
193
+ position,
194
+ reflectedPosition,
195
+ t,
196
+ scratchCartesian3
197
+ );
198
+ positions[positionIndex++] = interiorPosition.x;
199
+ positions[positionIndex++] = interiorPosition.y;
200
+ positions[positionIndex++] = interiorPosition.z;
201
+ }
202
+ positions[positionIndex++] = reflectedPosition.x;
203
+ positions[positionIndex++] = reflectedPosition.y;
204
+ positions[positionIndex++] = reflectedPosition.z;
205
+ }
206
+ if (addEdgePositions) {
207
+ outerPositions[outerRightIndex--] = position.z;
208
+ outerPositions[outerRightIndex--] = position.y;
209
+ outerPositions[outerRightIndex--] = position.x;
210
+ outerPositions[outerLeftIndex++] = reflectedPosition.x;
211
+ outerPositions[outerLeftIndex++] = reflectedPosition.y;
212
+ outerPositions[outerLeftIndex++] = reflectedPosition.z;
213
+ }
214
+ theta = Math_default.PI_OVER_TWO - (i + 1) * deltaTheta;
215
+ }
216
+ for (i = numPts; i > 1; --i) {
217
+ theta = Math_default.PI_OVER_TWO - (i - 1) * deltaTheta;
218
+ position = pointOnEllipsoid(
219
+ -theta,
220
+ rotation,
221
+ northVec,
222
+ eastVec,
223
+ aSqr,
224
+ ab,
225
+ bSqr,
226
+ mag,
227
+ unitPos,
228
+ position
229
+ );
230
+ reflectedPosition = pointOnEllipsoid(
231
+ theta + Math.PI,
232
+ rotation,
233
+ northVec,
234
+ eastVec,
235
+ aSqr,
236
+ ab,
237
+ bSqr,
238
+ mag,
239
+ unitPos,
240
+ reflectedPosition
241
+ );
242
+ if (addFillPositions) {
243
+ positions[positionIndex++] = position.x;
244
+ positions[positionIndex++] = position.y;
245
+ positions[positionIndex++] = position.z;
246
+ numInterior = 2 * (i - 1) + 2;
247
+ for (j = 1; j < numInterior - 1; ++j) {
248
+ t = j / (numInterior - 1);
249
+ interiorPosition = Cartesian3_default.lerp(
250
+ position,
251
+ reflectedPosition,
252
+ t,
253
+ scratchCartesian3
254
+ );
255
+ positions[positionIndex++] = interiorPosition.x;
256
+ positions[positionIndex++] = interiorPosition.y;
257
+ positions[positionIndex++] = interiorPosition.z;
258
+ }
259
+ positions[positionIndex++] = reflectedPosition.x;
260
+ positions[positionIndex++] = reflectedPosition.y;
261
+ positions[positionIndex++] = reflectedPosition.z;
262
+ }
263
+ if (addEdgePositions) {
264
+ outerPositions[outerRightIndex--] = position.z;
265
+ outerPositions[outerRightIndex--] = position.y;
266
+ outerPositions[outerRightIndex--] = position.x;
267
+ outerPositions[outerLeftIndex++] = reflectedPosition.x;
268
+ outerPositions[outerLeftIndex++] = reflectedPosition.y;
269
+ outerPositions[outerLeftIndex++] = reflectedPosition.z;
270
+ }
271
+ }
272
+ theta = Math_default.PI_OVER_TWO;
273
+ position = pointOnEllipsoid(
274
+ -theta,
275
+ rotation,
276
+ northVec,
277
+ eastVec,
278
+ aSqr,
279
+ ab,
280
+ bSqr,
281
+ mag,
282
+ unitPos,
283
+ position
284
+ );
285
+ const r = {};
286
+ if (addFillPositions) {
287
+ positions[positionIndex++] = position.x;
288
+ positions[positionIndex++] = position.y;
289
+ positions[positionIndex++] = position.z;
290
+ r.positions = positions;
291
+ r.numPts = numPts;
292
+ }
293
+ if (addEdgePositions) {
294
+ outerPositions[outerRightIndex--] = position.z;
295
+ outerPositions[outerRightIndex--] = position.y;
296
+ outerPositions[outerRightIndex--] = position.x;
297
+ r.outerPositions = outerPositions;
298
+ }
299
+ return r;
300
+ };
301
+ var EllipseGeometryLibrary_default = EllipseGeometryLibrary;
302
+
303
+ export {
304
+ EllipseGeometryLibrary_default
305
+ };
@@ -0,0 +1,398 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 1.141.6
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
+ CylinderGeometryLibrary_default
28
+ } from "./chunk-OODXPB45.js";
29
+ import {
30
+ GeometryOffsetAttribute_default
31
+ } from "./chunk-26OYTC24.js";
32
+ import {
33
+ VertexFormat_default
34
+ } from "./chunk-XNLCW2OI.js";
35
+ import {
36
+ IndexDatatype_default
37
+ } from "./chunk-HEY4IOS3.js";
38
+ import {
39
+ GeometryAttributes_default
40
+ } from "./chunk-C342XITR.js";
41
+ import {
42
+ GeometryAttribute_default,
43
+ Geometry_default,
44
+ PrimitiveType_default
45
+ } from "./chunk-HRWFO57T.js";
46
+ import {
47
+ BoundingSphere_default
48
+ } from "./chunk-37WL527K.js";
49
+ import {
50
+ ComponentDatatype_default
51
+ } from "./chunk-QBSWSTHY.js";
52
+ import {
53
+ Cartesian2_default
54
+ } from "./chunk-S3XHL7GO.js";
55
+ import {
56
+ Cartesian3_default,
57
+ Frozen_default
58
+ } from "./chunk-VETQOADR.js";
59
+ import {
60
+ Math_default
61
+ } from "./chunk-MKR6YCMG.js";
62
+ import {
63
+ DeveloperError_default
64
+ } from "./chunk-UTAWMCSE.js";
65
+ import {
66
+ defined_default
67
+ } from "./chunk-HTCLVUBZ.js";
68
+
69
+ // packages/engine/Source/Core/CylinderGeometry.js
70
+ var radiusScratch = new Cartesian2_default();
71
+ var normalScratch = new Cartesian3_default();
72
+ var bitangentScratch = new Cartesian3_default();
73
+ var tangentScratch = new Cartesian3_default();
74
+ var positionScratch = new Cartesian3_default();
75
+ function CylinderGeometry(options) {
76
+ options = options ?? Frozen_default.EMPTY_OBJECT;
77
+ const length = options.length;
78
+ const topRadius = options.topRadius;
79
+ const bottomRadius = options.bottomRadius;
80
+ const vertexFormat = options.vertexFormat ?? VertexFormat_default.DEFAULT;
81
+ const slices = options.slices ?? 128;
82
+ if (!defined_default(length)) {
83
+ throw new DeveloperError_default("options.length must be defined.");
84
+ }
85
+ if (!defined_default(topRadius)) {
86
+ throw new DeveloperError_default("options.topRadius must be defined.");
87
+ }
88
+ if (!defined_default(bottomRadius)) {
89
+ throw new DeveloperError_default("options.bottomRadius must be defined.");
90
+ }
91
+ if (slices < 3) {
92
+ throw new DeveloperError_default(
93
+ "options.slices must be greater than or equal to 3."
94
+ );
95
+ }
96
+ if (defined_default(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute_default.TOP) {
97
+ throw new DeveloperError_default(
98
+ "GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry."
99
+ );
100
+ }
101
+ this._length = length;
102
+ this._topRadius = topRadius;
103
+ this._bottomRadius = bottomRadius;
104
+ this._vertexFormat = VertexFormat_default.clone(vertexFormat);
105
+ this._slices = slices;
106
+ this._offsetAttribute = options.offsetAttribute;
107
+ this._workerName = "createCylinderGeometry";
108
+ }
109
+ CylinderGeometry.packedLength = VertexFormat_default.packedLength + 5;
110
+ CylinderGeometry.pack = function(value, array, startingIndex) {
111
+ if (!defined_default(value)) {
112
+ throw new DeveloperError_default("value is required");
113
+ }
114
+ if (!defined_default(array)) {
115
+ throw new DeveloperError_default("array is required");
116
+ }
117
+ startingIndex = startingIndex ?? 0;
118
+ VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
119
+ startingIndex += VertexFormat_default.packedLength;
120
+ array[startingIndex++] = value._length;
121
+ array[startingIndex++] = value._topRadius;
122
+ array[startingIndex++] = value._bottomRadius;
123
+ array[startingIndex++] = value._slices;
124
+ array[startingIndex] = value._offsetAttribute ?? -1;
125
+ return array;
126
+ };
127
+ var scratchVertexFormat = new VertexFormat_default();
128
+ var scratchOptions = {
129
+ vertexFormat: scratchVertexFormat,
130
+ length: void 0,
131
+ topRadius: void 0,
132
+ bottomRadius: void 0,
133
+ slices: void 0,
134
+ offsetAttribute: void 0
135
+ };
136
+ CylinderGeometry.unpack = function(array, startingIndex, result) {
137
+ if (!defined_default(array)) {
138
+ throw new DeveloperError_default("array is required");
139
+ }
140
+ startingIndex = startingIndex ?? 0;
141
+ const vertexFormat = VertexFormat_default.unpack(
142
+ array,
143
+ startingIndex,
144
+ scratchVertexFormat
145
+ );
146
+ startingIndex += VertexFormat_default.packedLength;
147
+ const length = array[startingIndex++];
148
+ const topRadius = array[startingIndex++];
149
+ const bottomRadius = array[startingIndex++];
150
+ const slices = array[startingIndex++];
151
+ const offsetAttribute = array[startingIndex];
152
+ if (!defined_default(result)) {
153
+ scratchOptions.length = length;
154
+ scratchOptions.topRadius = topRadius;
155
+ scratchOptions.bottomRadius = bottomRadius;
156
+ scratchOptions.slices = slices;
157
+ scratchOptions.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
158
+ return new CylinderGeometry(scratchOptions);
159
+ }
160
+ result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
161
+ result._length = length;
162
+ result._topRadius = topRadius;
163
+ result._bottomRadius = bottomRadius;
164
+ result._slices = slices;
165
+ result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
166
+ return result;
167
+ };
168
+ CylinderGeometry.createGeometry = function(cylinderGeometry) {
169
+ let length = cylinderGeometry._length;
170
+ const topRadius = cylinderGeometry._topRadius;
171
+ const bottomRadius = cylinderGeometry._bottomRadius;
172
+ const vertexFormat = cylinderGeometry._vertexFormat;
173
+ const slices = cylinderGeometry._slices;
174
+ if (length <= 0 || topRadius < 0 || bottomRadius < 0 || topRadius === 0 && bottomRadius === 0) {
175
+ return;
176
+ }
177
+ const twoSlices = slices + slices;
178
+ const threeSlices = slices + twoSlices;
179
+ const numVertices = twoSlices + twoSlices;
180
+ const positions = CylinderGeometryLibrary_default.computePositions(
181
+ length,
182
+ topRadius,
183
+ bottomRadius,
184
+ slices,
185
+ true
186
+ );
187
+ const st = vertexFormat.st ? new Float32Array(numVertices * 2) : void 0;
188
+ const normals = vertexFormat.normal ? new Float32Array(numVertices * 3) : void 0;
189
+ const tangents = vertexFormat.tangent ? new Float32Array(numVertices * 3) : void 0;
190
+ const bitangents = vertexFormat.bitangent ? new Float32Array(numVertices * 3) : void 0;
191
+ let i;
192
+ const computeNormal = vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent;
193
+ if (computeNormal) {
194
+ const computeTangent = vertexFormat.tangent || vertexFormat.bitangent;
195
+ let normalIndex = 0;
196
+ let tangentIndex = 0;
197
+ let bitangentIndex = 0;
198
+ const theta = Math.atan2(bottomRadius - topRadius, length);
199
+ const normal = normalScratch;
200
+ normal.z = Math.sin(theta);
201
+ const normalScale = Math.cos(theta);
202
+ let tangent = tangentScratch;
203
+ let bitangent = bitangentScratch;
204
+ for (i = 0; i < slices; i++) {
205
+ const angle = i / slices * Math_default.TWO_PI;
206
+ const x = normalScale * Math.cos(angle);
207
+ const y = normalScale * Math.sin(angle);
208
+ if (computeNormal) {
209
+ normal.x = x;
210
+ normal.y = y;
211
+ if (computeTangent) {
212
+ tangent = Cartesian3_default.normalize(
213
+ Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal, tangent),
214
+ tangent
215
+ );
216
+ }
217
+ if (vertexFormat.normal) {
218
+ normals[normalIndex++] = normal.x;
219
+ normals[normalIndex++] = normal.y;
220
+ normals[normalIndex++] = normal.z;
221
+ normals[normalIndex++] = normal.x;
222
+ normals[normalIndex++] = normal.y;
223
+ normals[normalIndex++] = normal.z;
224
+ }
225
+ if (vertexFormat.tangent) {
226
+ tangents[tangentIndex++] = tangent.x;
227
+ tangents[tangentIndex++] = tangent.y;
228
+ tangents[tangentIndex++] = tangent.z;
229
+ tangents[tangentIndex++] = tangent.x;
230
+ tangents[tangentIndex++] = tangent.y;
231
+ tangents[tangentIndex++] = tangent.z;
232
+ }
233
+ if (vertexFormat.bitangent) {
234
+ bitangent = Cartesian3_default.normalize(
235
+ Cartesian3_default.cross(normal, tangent, bitangent),
236
+ bitangent
237
+ );
238
+ bitangents[bitangentIndex++] = bitangent.x;
239
+ bitangents[bitangentIndex++] = bitangent.y;
240
+ bitangents[bitangentIndex++] = bitangent.z;
241
+ bitangents[bitangentIndex++] = bitangent.x;
242
+ bitangents[bitangentIndex++] = bitangent.y;
243
+ bitangents[bitangentIndex++] = bitangent.z;
244
+ }
245
+ }
246
+ }
247
+ for (i = 0; i < slices; i++) {
248
+ if (vertexFormat.normal) {
249
+ normals[normalIndex++] = 0;
250
+ normals[normalIndex++] = 0;
251
+ normals[normalIndex++] = -1;
252
+ }
253
+ if (vertexFormat.tangent) {
254
+ tangents[tangentIndex++] = 1;
255
+ tangents[tangentIndex++] = 0;
256
+ tangents[tangentIndex++] = 0;
257
+ }
258
+ if (vertexFormat.bitangent) {
259
+ bitangents[bitangentIndex++] = 0;
260
+ bitangents[bitangentIndex++] = -1;
261
+ bitangents[bitangentIndex++] = 0;
262
+ }
263
+ }
264
+ for (i = 0; i < slices; i++) {
265
+ if (vertexFormat.normal) {
266
+ normals[normalIndex++] = 0;
267
+ normals[normalIndex++] = 0;
268
+ normals[normalIndex++] = 1;
269
+ }
270
+ if (vertexFormat.tangent) {
271
+ tangents[tangentIndex++] = 1;
272
+ tangents[tangentIndex++] = 0;
273
+ tangents[tangentIndex++] = 0;
274
+ }
275
+ if (vertexFormat.bitangent) {
276
+ bitangents[bitangentIndex++] = 0;
277
+ bitangents[bitangentIndex++] = 1;
278
+ bitangents[bitangentIndex++] = 0;
279
+ }
280
+ }
281
+ }
282
+ const numIndices = 12 * slices - 12;
283
+ const indices = IndexDatatype_default.createTypedArray(numVertices, numIndices);
284
+ let index = 0;
285
+ let j = 0;
286
+ for (i = 0; i < slices - 1; i++) {
287
+ indices[index++] = j;
288
+ indices[index++] = j + 2;
289
+ indices[index++] = j + 3;
290
+ indices[index++] = j;
291
+ indices[index++] = j + 3;
292
+ indices[index++] = j + 1;
293
+ j += 2;
294
+ }
295
+ indices[index++] = twoSlices - 2;
296
+ indices[index++] = 0;
297
+ indices[index++] = 1;
298
+ indices[index++] = twoSlices - 2;
299
+ indices[index++] = 1;
300
+ indices[index++] = twoSlices - 1;
301
+ for (i = 1; i < slices - 1; i++) {
302
+ indices[index++] = twoSlices + i + 1;
303
+ indices[index++] = twoSlices + i;
304
+ indices[index++] = twoSlices;
305
+ }
306
+ for (i = 1; i < slices - 1; i++) {
307
+ indices[index++] = threeSlices;
308
+ indices[index++] = threeSlices + i;
309
+ indices[index++] = threeSlices + i + 1;
310
+ }
311
+ let textureCoordIndex = 0;
312
+ if (vertexFormat.st) {
313
+ const rad = Math.max(topRadius, bottomRadius);
314
+ for (i = 0; i < numVertices; i++) {
315
+ const position = Cartesian3_default.fromArray(positions, i * 3, positionScratch);
316
+ st[textureCoordIndex++] = (position.x + rad) / (2 * rad);
317
+ st[textureCoordIndex++] = (position.y + rad) / (2 * rad);
318
+ }
319
+ }
320
+ const attributes = new GeometryAttributes_default();
321
+ if (vertexFormat.position) {
322
+ attributes.position = new GeometryAttribute_default({
323
+ componentDatatype: ComponentDatatype_default.DOUBLE,
324
+ componentsPerAttribute: 3,
325
+ values: positions
326
+ });
327
+ }
328
+ if (vertexFormat.normal) {
329
+ attributes.normal = new GeometryAttribute_default({
330
+ componentDatatype: ComponentDatatype_default.FLOAT,
331
+ componentsPerAttribute: 3,
332
+ values: normals
333
+ });
334
+ }
335
+ if (vertexFormat.tangent) {
336
+ attributes.tangent = new GeometryAttribute_default({
337
+ componentDatatype: ComponentDatatype_default.FLOAT,
338
+ componentsPerAttribute: 3,
339
+ values: tangents
340
+ });
341
+ }
342
+ if (vertexFormat.bitangent) {
343
+ attributes.bitangent = new GeometryAttribute_default({
344
+ componentDatatype: ComponentDatatype_default.FLOAT,
345
+ componentsPerAttribute: 3,
346
+ values: bitangents
347
+ });
348
+ }
349
+ if (vertexFormat.st) {
350
+ attributes.st = new GeometryAttribute_default({
351
+ componentDatatype: ComponentDatatype_default.FLOAT,
352
+ componentsPerAttribute: 2,
353
+ values: st
354
+ });
355
+ }
356
+ radiusScratch.x = length * 0.5;
357
+ radiusScratch.y = Math.max(bottomRadius, topRadius);
358
+ const boundingSphere = new BoundingSphere_default(
359
+ Cartesian3_default.ZERO,
360
+ Cartesian2_default.magnitude(radiusScratch)
361
+ );
362
+ if (defined_default(cylinderGeometry._offsetAttribute)) {
363
+ length = positions.length;
364
+ const offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
365
+ const applyOffset = new Uint8Array(length / 3).fill(offsetValue);
366
+ attributes.applyOffset = new GeometryAttribute_default({
367
+ componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
368
+ componentsPerAttribute: 1,
369
+ values: applyOffset
370
+ });
371
+ }
372
+ return new Geometry_default({
373
+ attributes,
374
+ indices,
375
+ primitiveType: PrimitiveType_default.TRIANGLES,
376
+ boundingSphere,
377
+ offsetAttribute: cylinderGeometry._offsetAttribute
378
+ });
379
+ };
380
+ var unitCylinderGeometry;
381
+ CylinderGeometry.getUnitCylinder = function() {
382
+ if (!defined_default(unitCylinderGeometry)) {
383
+ unitCylinderGeometry = CylinderGeometry.createGeometry(
384
+ new CylinderGeometry({
385
+ topRadius: 1,
386
+ bottomRadius: 1,
387
+ length: 1,
388
+ vertexFormat: VertexFormat_default.POSITION_ONLY
389
+ })
390
+ );
391
+ }
392
+ return unitCylinderGeometry;
393
+ };
394
+ var CylinderGeometry_default = CylinderGeometry;
395
+
396
+ export {
397
+ CylinderGeometry_default
398
+ };