@rtzh/engine 0.0.1 → 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 (115) hide show
  1. package/Source/Scene/GltfLoader.js +2 -2
  2. package/Source/Scene/Model/CustomShader.js +2 -2
  3. package/index.js +504 -504
  4. package/package.json +1 -1
  5. package/Build/ThirdParty/Workers/zip-web-worker.js +0 -640
  6. package/Build/Workers/chunk-245NZYCR.js +0 -124
  7. package/Build/Workers/chunk-25BA4527.js +0 -837
  8. package/Build/Workers/chunk-4HXPSZRC.js +0 -1483
  9. package/Build/Workers/chunk-4Z26IS65.js +0 -3514
  10. package/Build/Workers/chunk-55IROWAX.js +0 -139
  11. package/Build/Workers/chunk-56XTN5NJ.js +0 -1800
  12. package/Build/Workers/chunk-5VZISKJF.js +0 -629
  13. package/Build/Workers/chunk-5WAG5YKS.js +0 -368
  14. package/Build/Workers/chunk-66YGZWBI.js +0 -1317
  15. package/Build/Workers/chunk-6H33B6OL.js +0 -37
  16. package/Build/Workers/chunk-6LZBBEA7.js +0 -439
  17. package/Build/Workers/chunk-6XJO625E.js +0 -497
  18. package/Build/Workers/chunk-75UGCVME.js +0 -102
  19. package/Build/Workers/chunk-7B23DD46.js +0 -1054
  20. package/Build/Workers/chunk-7NCJH26L.js +0 -352
  21. package/Build/Workers/chunk-AIW5F22O.js +0 -352
  22. package/Build/Workers/chunk-AL22JVIA.js +0 -256
  23. package/Build/Workers/chunk-AVSQILVI.js +0 -75
  24. package/Build/Workers/chunk-B2VFNYD7.js +0 -280
  25. package/Build/Workers/chunk-BOV6T7FO.js +0 -44
  26. package/Build/Workers/chunk-DP76S3IQ.js +0 -1067
  27. package/Build/Workers/chunk-EDIUN7V3.js +0 -219
  28. package/Build/Workers/chunk-EKMWNF4U.js +0 -55
  29. package/Build/Workers/chunk-ELXGXAYS.js +0 -682
  30. package/Build/Workers/chunk-FVYRV2T6.js +0 -455
  31. package/Build/Workers/chunk-GDIBU55R.js +0 -778
  32. package/Build/Workers/chunk-HAY6YE7M.js +0 -97
  33. package/Build/Workers/chunk-I76SRIKN.js +0 -138
  34. package/Build/Workers/chunk-IELTSYPZ.js +0 -241
  35. package/Build/Workers/chunk-J4MIJCN5.js +0 -171
  36. package/Build/Workers/chunk-JFO3ELF3.js +0 -642
  37. package/Build/Workers/chunk-K4IMD7KH.js +0 -162
  38. package/Build/Workers/chunk-KFMCOG26.js +0 -692
  39. package/Build/Workers/chunk-KH2OWUUA.js +0 -163
  40. package/Build/Workers/chunk-KQIZ7AFF.js +0 -8366
  41. package/Build/Workers/chunk-KVE5EAPO.js +0 -398
  42. package/Build/Workers/chunk-OAOREOSO.js +0 -940
  43. package/Build/Workers/chunk-OFJRMGNX.js +0 -788
  44. package/Build/Workers/chunk-PLLZB3R4.js +0 -198
  45. package/Build/Workers/chunk-POY6ZE32.js +0 -2058
  46. package/Build/Workers/chunk-PV5B2YNB.js +0 -2719
  47. package/Build/Workers/chunk-Q2DXNFYW.js +0 -414
  48. package/Build/Workers/chunk-QWV2DM66.js +0 -1443
  49. package/Build/Workers/chunk-R73BHGGI.js +0 -305
  50. package/Build/Workers/chunk-S3AE3MZZ.js +0 -511
  51. package/Build/Workers/chunk-SBFTVHRW.js +0 -57
  52. package/Build/Workers/chunk-SOR7PD4V.js +0 -114
  53. package/Build/Workers/chunk-TO7TWUET.js +0 -476
  54. package/Build/Workers/chunk-TSAJNE4K.js +0 -101
  55. package/Build/Workers/chunk-TWF4XRZ6.js +0 -73
  56. package/Build/Workers/chunk-UTWLMOPM.js +0 -387
  57. package/Build/Workers/chunk-UYT2PBMV.js +0 -58
  58. package/Build/Workers/chunk-WAS3IHIQ.js +0 -288
  59. package/Build/Workers/chunk-WO5ZNC7S.js +0 -1045
  60. package/Build/Workers/chunk-X65Y2JSA.js +0 -55
  61. package/Build/Workers/chunk-XOVHLPKW.js +0 -299
  62. package/Build/Workers/chunk-YPGJSFOO.js +0 -1460
  63. package/Build/Workers/combineGeometry.js +0 -66
  64. package/Build/Workers/createBoxGeometry.js +0 -58
  65. package/Build/Workers/createBoxOutlineGeometry.js +0 -231
  66. package/Build/Workers/createCircleGeometry.js +0 -201
  67. package/Build/Workers/createCircleOutlineGeometry.js +0 -147
  68. package/Build/Workers/createCoplanarPolygonGeometry.js +0 -505
  69. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +0 -225
  70. package/Build/Workers/createCorridorGeometry.js +0 -1258
  71. package/Build/Workers/createCorridorOutlineGeometry.js +0 -563
  72. package/Build/Workers/createCylinderGeometry.js +0 -60
  73. package/Build/Workers/createCylinderOutlineGeometry.js +0 -231
  74. package/Build/Workers/createEllipseGeometry.js +0 -72
  75. package/Build/Workers/createEllipseOutlineGeometry.js +0 -65
  76. package/Build/Workers/createEllipsoidGeometry.js +0 -59
  77. package/Build/Workers/createEllipsoidOutlineGeometry.js +0 -61
  78. package/Build/Workers/createFrustumGeometry.js +0 -58
  79. package/Build/Workers/createFrustumOutlineGeometry.js +0 -234
  80. package/Build/Workers/createGeometry.js +0 -173
  81. package/Build/Workers/createGroundPolylineGeometry.js +0 -1602
  82. package/Build/Workers/createPlaneGeometry.js +0 -223
  83. package/Build/Workers/createPlaneOutlineGeometry.js +0 -124
  84. package/Build/Workers/createPolygonGeometry.js +0 -1404
  85. package/Build/Workers/createPolygonOutlineGeometry.js +0 -532
  86. package/Build/Workers/createPolylineGeometry.js +0 -491
  87. package/Build/Workers/createPolylineVolumeGeometry.js +0 -374
  88. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +0 -272
  89. package/Build/Workers/createRectangleGeometry.js +0 -1264
  90. package/Build/Workers/createRectangleOutlineGeometry.js +0 -476
  91. package/Build/Workers/createSimplePolylineGeometry.js +0 -397
  92. package/Build/Workers/createSphereGeometry.js +0 -116
  93. package/Build/Workers/createSphereOutlineGeometry.js +0 -116
  94. package/Build/Workers/createTaskProcessorWorker.js +0 -32
  95. package/Build/Workers/createVectorTileClampedPolylines.js +0 -492
  96. package/Build/Workers/createVectorTileGeometries.js +0 -387
  97. package/Build/Workers/createVectorTilePoints.js +0 -114
  98. package/Build/Workers/createVectorTilePolygons.js +0 -386
  99. package/Build/Workers/createVectorTilePolylines.js +0 -262
  100. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +0 -91
  101. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +0 -565
  102. package/Build/Workers/createVerticesFromHeightmap.js +0 -2254
  103. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +0 -499
  104. package/Build/Workers/createWallGeometry.js +0 -487
  105. package/Build/Workers/createWallOutlineGeometry.js +0 -335
  106. package/Build/Workers/decodeDraco.js +0 -369
  107. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +0 -2680
  108. package/Build/Workers/decodeI3S.js +0 -1339
  109. package/Build/Workers/gaussianSplatSorter.js +0 -62
  110. package/Build/Workers/gaussianSplatTextureGenerator.js +0 -68
  111. package/Build/Workers/incrementallyBuildTerrainPicker.js +0 -121
  112. package/Build/Workers/transcodeKTX2.js +0 -3463
  113. package/Build/Workers/transferTypedArrayTest.js +0 -41
  114. package/Build/Workers/upsampleQuantizedTerrainMesh.js +0 -820
  115. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +0 -95
@@ -1,1045 +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
- EllipsoidRhumbLine_default
28
- } from "./chunk-FVYRV2T6.js";
29
- import {
30
- GeometryAttribute_default,
31
- Geometry_default,
32
- PrimitiveType_default
33
- } from "./chunk-XOVHLPKW.js";
34
- import {
35
- ComponentDatatype_default
36
- } from "./chunk-AL22JVIA.js";
37
- import {
38
- WebGLConstants_default
39
- } from "./chunk-5VZISKJF.js";
40
- import {
41
- Cartesian2_default,
42
- Cartographic_default,
43
- Ellipsoid_default
44
- } from "./chunk-YPGJSFOO.js";
45
- import {
46
- Cartesian3_default
47
- } from "./chunk-QWV2DM66.js";
48
- import {
49
- Math_default
50
- } from "./chunk-6XJO625E.js";
51
- import {
52
- Check_default
53
- } from "./chunk-KH2OWUUA.js";
54
- import {
55
- defined_default
56
- } from "./chunk-AVSQILVI.js";
57
-
58
- // packages/engine/Source/Core/WindingOrder.js
59
- var WindingOrder = {
60
- /**
61
- * Vertices are in clockwise order.
62
- *
63
- * @type {number}
64
- * @constant
65
- */
66
- CLOCKWISE: WebGLConstants_default.CW,
67
- /**
68
- * Vertices are in counter-clockwise order.
69
- *
70
- * @type {number}
71
- * @constant
72
- */
73
- COUNTER_CLOCKWISE: WebGLConstants_default.CCW
74
- };
75
- WindingOrder.validate = function(windingOrder) {
76
- return windingOrder === WindingOrder.CLOCKWISE || windingOrder === WindingOrder.COUNTER_CLOCKWISE;
77
- };
78
- var WindingOrder_default = Object.freeze(WindingOrder);
79
-
80
- // node_modules/earcut/src/earcut.js
81
- var steiners = /* @__PURE__ */ new Set();
82
- var filteredOut = false;
83
- function earcut(data, holeIndices, dim = 2) {
84
- const hasHoles = holeIndices && holeIndices.length;
85
- const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
86
- if (steiners.size) steiners.clear();
87
- let outerNode = linkedList(data, 0, outerLen, dim, true);
88
- const triangles = [];
89
- if (!outerNode || outerNode.next === outerNode.prev) return triangles;
90
- let minX = 0, minY = 0, invSize = 0;
91
- if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
92
- if (data.length > 80 * dim) {
93
- minX = data[0];
94
- minY = data[1];
95
- let maxX = minX;
96
- let maxY = minY;
97
- for (let i = dim; i < outerLen; i += dim) {
98
- const x = data[i];
99
- const y = data[i + 1];
100
- if (x < minX) minX = x;
101
- if (y < minY) minY = y;
102
- if (x > maxX) maxX = x;
103
- if (y > maxY) maxY = y;
104
- }
105
- invSize = Math.max(maxX - minX, maxY - minY);
106
- invSize = invSize !== 0 ? 32767 / invSize : 0;
107
- }
108
- earcutLinked(outerNode, triangles, minX, minY, invSize);
109
- return triangles;
110
- }
111
- function linkedList(data, start, end, dim, clockwise) {
112
- let last = null;
113
- if (clockwise === signedArea(data, start, end, dim) > 0) {
114
- for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
115
- } else {
116
- for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);
117
- }
118
- if (last && equals(last, last.next)) {
119
- removeNode(last);
120
- last = last.next;
121
- }
122
- return last;
123
- }
124
- function filterPoints(start, end = start) {
125
- const full = end === start;
126
- let p = start, again;
127
- do {
128
- again = false;
129
- if (p !== p.next && (steiners.size === 0 || !steiners.has(p)) && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
130
- if (full || p === end) end = p.prev;
131
- filteredOut = true;
132
- removeNode(p);
133
- p = p.prev;
134
- again = true;
135
- } else if (full || p !== end) {
136
- p = p.next;
137
- again = !full;
138
- }
139
- } while (again || p !== end);
140
- return end;
141
- }
142
- function earcutLinked(ear, triangles, minX, minY, invSize) {
143
- if (invSize) indexCurve(ear, minX, minY, invSize);
144
- let stop = ear, cured = false;
145
- while (ear.prev !== ear.next) {
146
- const prev = ear.prev;
147
- const next = ear.next;
148
- if (area(prev, ear, next) < 0 && (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear))) {
149
- triangles.push(prev.i, ear.i, next.i);
150
- removeNode(ear);
151
- ear = next;
152
- stop = next;
153
- continue;
154
- }
155
- ear = next;
156
- if (ear === stop) {
157
- filteredOut = false;
158
- ear = filterPoints(ear);
159
- if (filteredOut) {
160
- stop = ear;
161
- continue;
162
- }
163
- if (!cured) {
164
- ear = cureLocalIntersections(ear, triangles);
165
- stop = ear;
166
- cured = true;
167
- continue;
168
- }
169
- splitEarcut(ear, triangles, minX, minY, invSize);
170
- break;
171
- }
172
- }
173
- }
174
- function isEar(ear) {
175
- const a = ear.prev, b = ear, c = ear.next, ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y, x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
176
- let p = c.next;
177
- while (p !== a) {
178
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && !(ax === p.x && ay === p.y) && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
179
- p = p.next;
180
- }
181
- return true;
182
- }
183
- function isEarHashed(ear, minX, minY, invSize) {
184
- const a = ear.prev, b = ear, c = ear.next, ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y, x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy), minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
185
- let p = ear.prevZ;
186
- while (p && p.z >= minZ) {
187
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== c && !(ax === p.x && ay === p.y) && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
188
- p = p.prevZ;
189
- }
190
- let n = ear.nextZ;
191
- while (n && n.z <= maxZ) {
192
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== c && !(ax === n.x && ay === n.y) && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
193
- n = n.nextZ;
194
- }
195
- return true;
196
- }
197
- function cureLocalIntersections(start, triangles) {
198
- let p = start;
199
- let cured = false;
200
- do {
201
- const a = p.prev, b = p.next.next;
202
- if (intersects(a, p, p.next, b, false) && locallyInside(a, b) && locallyInside(b, a)) {
203
- triangles.push(a.i, p.i, b.i);
204
- removeNode(p);
205
- removeNode(p.next);
206
- p = start = b;
207
- cured = true;
208
- }
209
- p = p.next;
210
- } while (p !== start);
211
- return cured ? filterPoints(p) : p;
212
- }
213
- function splitEarcut(start, triangles, minX, minY, invSize) {
214
- let a = start;
215
- do {
216
- let b = a.next.next;
217
- while (b !== a.prev) {
218
- if (a.i !== b.i && isValidDiagonal(a, b)) {
219
- let c = splitPolygon(a, b);
220
- a = filterPoints(a, a.next);
221
- c = filterPoints(c, c.next);
222
- earcutLinked(a, triangles, minX, minY, invSize);
223
- earcutLinked(c, triangles, minX, minY, invSize);
224
- return;
225
- }
226
- b = b.next;
227
- }
228
- a = a.next;
229
- } while (a !== start);
230
- }
231
- var indexActive = false;
232
- function eliminateHoles(data, holeIndices, outerNode, dim) {
233
- const queue = [];
234
- for (let i = 0, len = holeIndices.length; i < len; i++) {
235
- const start = holeIndices[i] * dim;
236
- const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
237
- const list = (
238
- /** @type {Node} */
239
- linkedList(data, start, end, dim, false)
240
- );
241
- if (list === list.next) steiners.add(list);
242
- queue.push(getLeftmost(list));
243
- }
244
- queue.sort(compareXYSlope);
245
- buildBlockIndex(data.length / dim, holeIndices.length);
246
- indexSegment(outerNode, outerNode);
247
- indexActive = true;
248
- for (let i = 0; i < queue.length; i++) {
249
- outerNode = eliminateHole(queue[i], outerNode);
250
- }
251
- indexActive = false;
252
- return filterPoints(outerNode);
253
- }
254
- function compareXYSlope(a, b) {
255
- return a.x - b.x || a.y - b.y || (a.next.y - a.y) / (a.next.x - a.x) - (b.next.y - b.y) / (b.next.x - b.x);
256
- }
257
- function eliminateHole(hole, outerNode) {
258
- const bridge = findHoleBridge(hole, outerNode);
259
- if (!bridge) {
260
- return outerNode;
261
- }
262
- const bridgeReverse = splitPolygon(bridge, hole);
263
- const bridge2 = bridgeReverse.next;
264
- indexSegment(bridge, bridge2.next);
265
- filterPoints(bridgeReverse, bridgeReverse.next);
266
- return filterPoints(bridge, bridge.next);
267
- }
268
- var K = 16;
269
- var blockBBox = new Float64Array(0);
270
- var numBlocks = 0;
271
- var blockHead = [];
272
- var blockStop = [];
273
- function buildBlockIndex(maxNodes, numHoles) {
274
- const maxBlocks = Math.ceil((maxNodes + 2 * numHoles) / K) + numHoles + 2;
275
- if (blockBBox.length < maxBlocks * 4) blockBBox = new Float64Array(maxBlocks * 4);
276
- numBlocks = 0;
277
- }
278
- function indexSegment(head, stop) {
279
- let p = head;
280
- do {
281
- const b = numBlocks++;
282
- blockHead[b] = p;
283
- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
284
- let k = 0;
285
- do {
286
- const c = p.next;
287
- p.z = b;
288
- if (p.x < minX) minX = p.x;
289
- if (p.x > maxX) maxX = p.x;
290
- if (p.y < minY) minY = p.y;
291
- if (p.y > maxY) maxY = p.y;
292
- if (c.x < minX) minX = c.x;
293
- if (c.x > maxX) maxX = c.x;
294
- if (c.y < minY) minY = c.y;
295
- if (c.y > maxY) maxY = c.y;
296
- p = c;
297
- } while (++k < K && p !== stop);
298
- blockStop[b] = p;
299
- const g = b * 4;
300
- blockBBox[g] = minX;
301
- blockBBox[g + 1] = minY;
302
- blockBBox[g + 2] = maxX;
303
- blockBBox[g + 3] = maxY;
304
- } while (p !== stop);
305
- }
306
- function growBlock(head, tail) {
307
- const g = head.z * 4;
308
- if (tail.x < blockBBox[g]) blockBBox[g] = tail.x;
309
- if (tail.y < blockBBox[g + 1]) blockBBox[g + 1] = tail.y;
310
- if (tail.x > blockBBox[g + 2]) blockBBox[g + 2] = tail.x;
311
- if (tail.y > blockBBox[g + 3]) blockBBox[g + 3] = tail.y;
312
- }
313
- function liveBlockStop(b) {
314
- let stop = blockStop[b];
315
- while (stop.prev.next !== stop) stop = stop.next;
316
- blockStop[b] = stop;
317
- return stop;
318
- }
319
- function liveBlockHead(b) {
320
- let head = blockHead[b];
321
- while (head.prev.next !== head) head = head.next;
322
- blockHead[b] = head;
323
- return head;
324
- }
325
- function findHoleBridge(hole, outerNode) {
326
- let p = outerNode;
327
- const hx = hole.x;
328
- const hy = hole.y;
329
- let qx = -Infinity;
330
- let m;
331
- if (equals(hole, p)) return p;
332
- for (let b = 0, g = 0; b < numBlocks; b++, g += 4) {
333
- if (hy < blockBBox[g + 1] || hy > blockBBox[g + 3] || blockBBox[g] > hx || blockBBox[g + 2] <= qx) continue;
334
- const stop = liveBlockStop(b);
335
- p = liveBlockHead(b);
336
- do {
337
- if (p.prev.next === p) {
338
- if (equals(hole, p.next)) return p.next;
339
- else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
340
- const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
341
- if (x <= hx && x > qx) {
342
- qx = x;
343
- m = p.x < p.next.x ? p : p.next;
344
- if (x === hx) return m;
345
- }
346
- }
347
- }
348
- p = p.next;
349
- } while (p !== stop);
350
- }
351
- if (!m) return null;
352
- const mx = m.x;
353
- const my = m.y;
354
- const tminY = Math.min(hy, my);
355
- const tmaxY = Math.max(hy, my);
356
- let tanMin = Infinity;
357
- for (let b = 0, g = 0; b < numBlocks; b++, g += 4) {
358
- if (blockBBox[g + 2] < mx || blockBBox[g] > hx || blockBBox[g + 3] < tminY || blockBBox[g + 1] > tmaxY) continue;
359
- const stop = liveBlockStop(b);
360
- p = liveBlockHead(b);
361
- do {
362
- if (p.prev.next === p && hx >= p.x && p.x >= mx && hx !== p.x && // skip dead nodes
363
- pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
364
- const tan = Math.abs(hy - p.y) / (hx - p.x);
365
- if ((locallyInside(p, hole) || p.y === hy && p.next.y === hy && p.next.x > hx) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
366
- m = p;
367
- tanMin = tan;
368
- }
369
- }
370
- p = p.next;
371
- } while (p !== stop);
372
- }
373
- return m;
374
- }
375
- function sectorContainsSector(m, p) {
376
- return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
377
- }
378
- var sortArr = [];
379
- var sortBuf = [];
380
- var zArr = new Uint32Array(0);
381
- var zBuf = new Uint32Array(0);
382
- var counts = new Uint32Array(256);
383
- function indexCurve(start, minX, minY, invSize) {
384
- let p = start;
385
- let n = 0;
386
- do {
387
- p.z = zOrder(p.x, p.y, minX, minY, invSize);
388
- sortArr[n++] = p;
389
- p = p.next;
390
- } while (p !== start);
391
- sortNodes(n);
392
- let prev = null;
393
- for (let i = 0; i < n; i++) {
394
- const node = sortArr[i];
395
- node.prevZ = prev;
396
- if (prev) prev.nextZ = node;
397
- prev = node;
398
- }
399
- prev.nextZ = null;
400
- }
401
- function sortNodes(n) {
402
- if (n <= 32) {
403
- for (let i = 1; i < n; i++) {
404
- const node = sortArr[i], z = node.z;
405
- let j = i - 1;
406
- while (j >= 0 && sortArr[j].z > z) {
407
- sortArr[j + 1] = sortArr[j];
408
- j--;
409
- }
410
- sortArr[j + 1] = node;
411
- }
412
- return;
413
- }
414
- if (zArr.length < n) {
415
- zArr = new Uint32Array(n);
416
- zBuf = new Uint32Array(n);
417
- sortBuf = new Array(n);
418
- }
419
- for (let i = 0; i < n; i++) zArr[i] = sortArr[i].z;
420
- radixPass(n, sortArr, zArr, sortBuf, zBuf, 0);
421
- radixPass(n, sortBuf, zBuf, sortArr, zArr, 8);
422
- radixPass(n, sortArr, zArr, sortBuf, zBuf, 16);
423
- radixPass(n, sortBuf, zBuf, sortArr, zArr, 24);
424
- }
425
- function radixPass(n, src, srcZ, dst, dstZ, shift) {
426
- counts.fill(0);
427
- for (let i = 0; i < n; i++) counts[srcZ[i] >>> shift & 255]++;
428
- let sum = 0;
429
- for (let b = 0; b < 256; b++) {
430
- const c = counts[b];
431
- counts[b] = sum;
432
- sum += c;
433
- }
434
- for (let i = 0; i < n; i++) {
435
- const z = srcZ[i];
436
- const pos = counts[z >>> shift & 255]++;
437
- dst[pos] = src[i];
438
- dstZ[pos] = z;
439
- }
440
- }
441
- function zOrder(x, y, minX, minY, invSize) {
442
- x = (x - minX) * invSize | 0;
443
- y = (y - minY) * invSize | 0;
444
- x = (x | x << 8) & 16711935;
445
- x = (x | x << 4) & 252645135;
446
- x = (x | x << 2) & 858993459;
447
- x = (x | x << 1) & 1431655765;
448
- y = (y | y << 8) & 16711935;
449
- y = (y | y << 4) & 252645135;
450
- y = (y | y << 2) & 858993459;
451
- y = (y | y << 1) & 1431655765;
452
- return x | y << 1;
453
- }
454
- function getLeftmost(start) {
455
- let p = start, leftmost = start;
456
- do {
457
- if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;
458
- p = p.next;
459
- } while (p !== start);
460
- return leftmost;
461
- }
462
- function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
463
- return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
464
- }
465
- function isValidDiagonal(a, b) {
466
- const zeroLength = equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0;
467
- return a.next.i !== b.i && (zeroLength || locallyInside(a, b) && locallyInside(b, a) && // // locally visible
468
- (area(a.prev, a, b.prev) !== 0 || area(a, b.prev, b) !== 0)) && // no opposite-facing sectors
469
- !intersectsPolygon(a, b) && (zeroLength || middleInside(a, b));
470
- }
471
- function area(p, q, r) {
472
- return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
473
- }
474
- function equals(p1, p2) {
475
- return p1.x === p2.x && p1.y === p2.y;
476
- }
477
- function intersects(p1, q1, p2, q2, includeBoundary = true) {
478
- const o1 = area(p1, q1, p2);
479
- const o2 = area(p1, q1, q2);
480
- const o3 = area(p2, q2, p1);
481
- const o4 = area(p2, q2, q1);
482
- if ((o1 > 0 && o2 < 0 || o1 < 0 && o2 > 0) && (o3 > 0 && o4 < 0 || o3 < 0 && o4 > 0)) return true;
483
- if (!includeBoundary) return false;
484
- if (o1 === 0 && onSegment(p1, p2, q1)) return true;
485
- if (o2 === 0 && onSegment(p1, q2, q1)) return true;
486
- if (o3 === 0 && onSegment(p2, p1, q2)) return true;
487
- if (o4 === 0 && onSegment(p2, q1, q2)) return true;
488
- return false;
489
- }
490
- function onSegment(p, q, r) {
491
- return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
492
- }
493
- function intersectsPolygon(a, b) {
494
- const minX = Math.min(a.x, b.x);
495
- const maxX = Math.max(a.x, b.x);
496
- const minY = Math.min(a.y, b.y);
497
- const maxY = Math.max(a.y, b.y);
498
- let p = a;
499
- do {
500
- const n = p.next;
501
- if (p.x > maxX && n.x > maxX || p.x < minX && n.x < minX || p.y > maxY && n.y > maxY || p.y < minY && n.y < minY) {
502
- p = n;
503
- continue;
504
- }
505
- if (p.i !== a.i && n.i !== a.i && p.i !== b.i && n.i !== b.i && intersects(p, n, a, b)) return true;
506
- p = n;
507
- } while (p !== a);
508
- return false;
509
- }
510
- function locallyInside(a, b) {
511
- return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
512
- }
513
- function middleInside(a, b) {
514
- let p = a;
515
- let inside = false;
516
- const px = (a.x + b.x) / 2;
517
- const py = (a.y + b.y) / 2;
518
- do {
519
- const n = p.next;
520
- if (p.y > py !== n.y > py && px < (n.x - p.x) * (py - p.y) / (n.y - p.y) + p.x)
521
- inside = !inside;
522
- p = n;
523
- } while (p !== a);
524
- return inside;
525
- }
526
- function splitPolygon(a, b) {
527
- const a2 = createNode(a.i, a.x, a.y), b2 = createNode(b.i, b.x, b.y), an = a.next, bp = b.prev;
528
- a.next = b;
529
- b.prev = a;
530
- a2.next = an;
531
- an.prev = a2;
532
- b2.next = a2;
533
- a2.prev = b2;
534
- bp.next = b2;
535
- b2.prev = bp;
536
- return b2;
537
- }
538
- function insertNode(i, x, y, last) {
539
- const p = createNode(i, x, y);
540
- if (!last) {
541
- p.prev = p;
542
- p.next = p;
543
- } else {
544
- p.next = last.next;
545
- p.prev = last;
546
- last.next.prev = p;
547
- last.next = p;
548
- }
549
- return p;
550
- }
551
- function removeNode(p) {
552
- p.next.prev = p.prev;
553
- p.prev.next = p.next;
554
- if (p.prevZ) p.prevZ.nextZ = p.nextZ;
555
- if (p.nextZ) p.nextZ.prevZ = p.prevZ;
556
- if (indexActive) growBlock(p.prev, p.next);
557
- }
558
- function createNode(i, x, y) {
559
- return (
560
- /** @type {Node} */
561
- /** @type {unknown} */
562
- {
563
- i,
564
- // vertex index in coordinates array
565
- x,
566
- y,
567
- // vertex coordinates
568
- prev: null,
569
- // previous and next vertex nodes in a polygon ring
570
- next: null,
571
- z: 0,
572
- // z-order curve value; doubles as owning block in the hole-bridge index during eliminateHoles
573
- prevZ: null,
574
- // previous and next nodes in z-order
575
- nextZ: null
576
- }
577
- );
578
- }
579
- function signedArea(data, start, end, dim) {
580
- let sum = 0;
581
- for (let i = start, j = end - dim; i < end; i += dim) {
582
- sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
583
- j = i;
584
- }
585
- return sum;
586
- }
587
-
588
- // packages/engine/Source/Core/PolygonPipeline.js
589
- var scaleToGeodeticHeightN = new Cartesian3_default();
590
- var scaleToGeodeticHeightP = new Cartesian3_default();
591
- var PolygonPipeline = {};
592
- PolygonPipeline.computeArea2D = function(positions) {
593
- Check_default.defined("positions", positions);
594
- Check_default.typeOf.number.greaterThanOrEquals(
595
- "positions.length",
596
- positions.length,
597
- 3
598
- );
599
- const length = positions.length;
600
- let area2 = 0;
601
- for (let i0 = length - 1, i1 = 0; i1 < length; i0 = i1++) {
602
- const v0 = positions[i0];
603
- const v1 = positions[i1];
604
- area2 += v0.x * v1.y - v1.x * v0.y;
605
- }
606
- return area2 * 0.5;
607
- };
608
- PolygonPipeline.computeWindingOrder2D = function(positions) {
609
- const area2 = PolygonPipeline.computeArea2D(positions);
610
- return area2 > 0 ? WindingOrder_default.COUNTER_CLOCKWISE : WindingOrder_default.CLOCKWISE;
611
- };
612
- PolygonPipeline.triangulate = function(positions, holes) {
613
- Check_default.defined("positions", positions);
614
- const flattenedPositions = Cartesian2_default.packArray(positions);
615
- return earcut(flattenedPositions, holes, 2);
616
- };
617
- var subdivisionV0Scratch = new Cartesian3_default();
618
- var subdivisionV1Scratch = new Cartesian3_default();
619
- var subdivisionV2Scratch = new Cartesian3_default();
620
- var subdivisionS0Scratch = new Cartesian3_default();
621
- var subdivisionS1Scratch = new Cartesian3_default();
622
- var subdivisionS2Scratch = new Cartesian3_default();
623
- var subdivisionMidScratch = new Cartesian3_default();
624
- var subdivisionT0Scratch = new Cartesian2_default();
625
- var subdivisionT1Scratch = new Cartesian2_default();
626
- var subdivisionT2Scratch = new Cartesian2_default();
627
- var subdivisionTexcoordMidScratch = new Cartesian2_default();
628
- PolygonPipeline.computeSubdivision = function(ellipsoid, positions, indices, texcoords, granularity) {
629
- granularity = granularity ?? Math_default.RADIANS_PER_DEGREE;
630
- const hasTexcoords = defined_default(texcoords);
631
- Check_default.typeOf.object("ellipsoid", ellipsoid);
632
- Check_default.defined("positions", positions);
633
- Check_default.defined("indices", indices);
634
- Check_default.typeOf.number.greaterThanOrEquals("indices.length", indices.length, 3);
635
- Check_default.typeOf.number.equals("indices.length % 3", "0", indices.length % 3, 0);
636
- Check_default.typeOf.number.greaterThan("granularity", granularity, 0);
637
- const triangles = indices.slice(0);
638
- let i;
639
- const length = positions.length;
640
- const subdividedPositions = new Array(length * 3);
641
- const subdividedTexcoords = new Array(length * 2);
642
- let q = 0;
643
- let p = 0;
644
- for (i = 0; i < length; i++) {
645
- const item = positions[i];
646
- subdividedPositions[q++] = item.x;
647
- subdividedPositions[q++] = item.y;
648
- subdividedPositions[q++] = item.z;
649
- if (hasTexcoords) {
650
- const texcoordItem = texcoords[i];
651
- subdividedTexcoords[p++] = texcoordItem.x;
652
- subdividedTexcoords[p++] = texcoordItem.y;
653
- }
654
- }
655
- const subdividedIndices = [];
656
- const edges = {};
657
- const radius = ellipsoid.maximumRadius;
658
- const minDistance = Math_default.chordLength(granularity, radius);
659
- const minDistanceSqrd = minDistance * minDistance;
660
- while (triangles.length > 0) {
661
- const i2 = triangles.pop();
662
- const i1 = triangles.pop();
663
- const i0 = triangles.pop();
664
- const v0 = Cartesian3_default.fromArray(
665
- subdividedPositions,
666
- i0 * 3,
667
- subdivisionV0Scratch
668
- );
669
- const v1 = Cartesian3_default.fromArray(
670
- subdividedPositions,
671
- i1 * 3,
672
- subdivisionV1Scratch
673
- );
674
- const v2 = Cartesian3_default.fromArray(
675
- subdividedPositions,
676
- i2 * 3,
677
- subdivisionV2Scratch
678
- );
679
- let t0, t1, t2;
680
- if (hasTexcoords) {
681
- t0 = Cartesian2_default.fromArray(
682
- subdividedTexcoords,
683
- i0 * 2,
684
- subdivisionT0Scratch
685
- );
686
- t1 = Cartesian2_default.fromArray(
687
- subdividedTexcoords,
688
- i1 * 2,
689
- subdivisionT1Scratch
690
- );
691
- t2 = Cartesian2_default.fromArray(
692
- subdividedTexcoords,
693
- i2 * 2,
694
- subdivisionT2Scratch
695
- );
696
- }
697
- const s0 = Cartesian3_default.multiplyByScalar(
698
- Cartesian3_default.normalize(v0, subdivisionS0Scratch),
699
- radius,
700
- subdivisionS0Scratch
701
- );
702
- const s1 = Cartesian3_default.multiplyByScalar(
703
- Cartesian3_default.normalize(v1, subdivisionS1Scratch),
704
- radius,
705
- subdivisionS1Scratch
706
- );
707
- const s2 = Cartesian3_default.multiplyByScalar(
708
- Cartesian3_default.normalize(v2, subdivisionS2Scratch),
709
- radius,
710
- subdivisionS2Scratch
711
- );
712
- const g0 = Cartesian3_default.magnitudeSquared(
713
- Cartesian3_default.subtract(s0, s1, subdivisionMidScratch)
714
- );
715
- const g1 = Cartesian3_default.magnitudeSquared(
716
- Cartesian3_default.subtract(s1, s2, subdivisionMidScratch)
717
- );
718
- const g2 = Cartesian3_default.magnitudeSquared(
719
- Cartesian3_default.subtract(s2, s0, subdivisionMidScratch)
720
- );
721
- const max = Math.max(g0, g1, g2);
722
- let edge;
723
- let mid;
724
- let midTexcoord;
725
- if (max > minDistanceSqrd) {
726
- if (g0 === max) {
727
- edge = `${Math.min(i0, i1)} ${Math.max(i0, i1)}`;
728
- i = edges[edge];
729
- if (!defined_default(i)) {
730
- mid = Cartesian3_default.add(v0, v1, subdivisionMidScratch);
731
- Cartesian3_default.multiplyByScalar(mid, 0.5, mid);
732
- subdividedPositions.push(mid.x, mid.y, mid.z);
733
- i = subdividedPositions.length / 3 - 1;
734
- edges[edge] = i;
735
- if (hasTexcoords) {
736
- midTexcoord = Cartesian2_default.add(t0, t1, subdivisionTexcoordMidScratch);
737
- Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
738
- subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
739
- }
740
- }
741
- triangles.push(i0, i, i2);
742
- triangles.push(i, i1, i2);
743
- } else if (g1 === max) {
744
- edge = `${Math.min(i1, i2)} ${Math.max(i1, i2)}`;
745
- i = edges[edge];
746
- if (!defined_default(i)) {
747
- mid = Cartesian3_default.add(v1, v2, subdivisionMidScratch);
748
- Cartesian3_default.multiplyByScalar(mid, 0.5, mid);
749
- subdividedPositions.push(mid.x, mid.y, mid.z);
750
- i = subdividedPositions.length / 3 - 1;
751
- edges[edge] = i;
752
- if (hasTexcoords) {
753
- midTexcoord = Cartesian2_default.add(t1, t2, subdivisionTexcoordMidScratch);
754
- Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
755
- subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
756
- }
757
- }
758
- triangles.push(i1, i, i0);
759
- triangles.push(i, i2, i0);
760
- } else if (g2 === max) {
761
- edge = `${Math.min(i2, i0)} ${Math.max(i2, i0)}`;
762
- i = edges[edge];
763
- if (!defined_default(i)) {
764
- mid = Cartesian3_default.add(v2, v0, subdivisionMidScratch);
765
- Cartesian3_default.multiplyByScalar(mid, 0.5, mid);
766
- subdividedPositions.push(mid.x, mid.y, mid.z);
767
- i = subdividedPositions.length / 3 - 1;
768
- edges[edge] = i;
769
- if (hasTexcoords) {
770
- midTexcoord = Cartesian2_default.add(t2, t0, subdivisionTexcoordMidScratch);
771
- Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
772
- subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
773
- }
774
- }
775
- triangles.push(i2, i, i1);
776
- triangles.push(i, i0, i1);
777
- }
778
- } else {
779
- subdividedIndices.push(i0);
780
- subdividedIndices.push(i1);
781
- subdividedIndices.push(i2);
782
- }
783
- }
784
- const geometryOptions = {
785
- attributes: {
786
- position: new GeometryAttribute_default({
787
- componentDatatype: ComponentDatatype_default.DOUBLE,
788
- componentsPerAttribute: 3,
789
- values: subdividedPositions
790
- })
791
- },
792
- indices: subdividedIndices,
793
- primitiveType: PrimitiveType_default.TRIANGLES
794
- };
795
- if (hasTexcoords) {
796
- geometryOptions.attributes.st = new GeometryAttribute_default({
797
- componentDatatype: ComponentDatatype_default.FLOAT,
798
- componentsPerAttribute: 2,
799
- values: subdividedTexcoords
800
- });
801
- }
802
- return new Geometry_default(geometryOptions);
803
- };
804
- var subdivisionC0Scratch = new Cartographic_default();
805
- var subdivisionC1Scratch = new Cartographic_default();
806
- var subdivisionC2Scratch = new Cartographic_default();
807
- var subdivisionCartographicScratch = new Cartographic_default();
808
- PolygonPipeline.computeRhumbLineSubdivision = function(ellipsoid, positions, indices, texcoords, granularity) {
809
- granularity = granularity ?? Math_default.RADIANS_PER_DEGREE;
810
- const hasTexcoords = defined_default(texcoords);
811
- Check_default.typeOf.object("ellipsoid", ellipsoid);
812
- Check_default.defined("positions", positions);
813
- Check_default.defined("indices", indices);
814
- Check_default.typeOf.number.greaterThanOrEquals("indices.length", indices.length, 3);
815
- Check_default.typeOf.number.equals("indices.length % 3", "0", indices.length % 3, 0);
816
- Check_default.typeOf.number.greaterThan("granularity", granularity, 0);
817
- const triangles = indices.slice(0);
818
- let i;
819
- const length = positions.length;
820
- const subdividedPositions = new Array(length * 3);
821
- const subdividedTexcoords = new Array(length * 2);
822
- let q = 0;
823
- let p = 0;
824
- for (i = 0; i < length; i++) {
825
- const item = positions[i];
826
- subdividedPositions[q++] = item.x;
827
- subdividedPositions[q++] = item.y;
828
- subdividedPositions[q++] = item.z;
829
- if (hasTexcoords) {
830
- const texcoordItem = texcoords[i];
831
- subdividedTexcoords[p++] = texcoordItem.x;
832
- subdividedTexcoords[p++] = texcoordItem.y;
833
- }
834
- }
835
- const subdividedIndices = [];
836
- const edges = {};
837
- const radius = ellipsoid.maximumRadius;
838
- const minDistance = Math_default.chordLength(granularity, radius);
839
- const rhumb0 = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
840
- const rhumb1 = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
841
- const rhumb2 = new EllipsoidRhumbLine_default(void 0, void 0, ellipsoid);
842
- while (triangles.length > 0) {
843
- const i2 = triangles.pop();
844
- const i1 = triangles.pop();
845
- const i0 = triangles.pop();
846
- const v0 = Cartesian3_default.fromArray(
847
- subdividedPositions,
848
- i0 * 3,
849
- subdivisionV0Scratch
850
- );
851
- const v1 = Cartesian3_default.fromArray(
852
- subdividedPositions,
853
- i1 * 3,
854
- subdivisionV1Scratch
855
- );
856
- const v2 = Cartesian3_default.fromArray(
857
- subdividedPositions,
858
- i2 * 3,
859
- subdivisionV2Scratch
860
- );
861
- let t0, t1, t2;
862
- if (hasTexcoords) {
863
- t0 = Cartesian2_default.fromArray(
864
- subdividedTexcoords,
865
- i0 * 2,
866
- subdivisionT0Scratch
867
- );
868
- t1 = Cartesian2_default.fromArray(
869
- subdividedTexcoords,
870
- i1 * 2,
871
- subdivisionT1Scratch
872
- );
873
- t2 = Cartesian2_default.fromArray(
874
- subdividedTexcoords,
875
- i2 * 2,
876
- subdivisionT2Scratch
877
- );
878
- }
879
- const c0 = ellipsoid.cartesianToCartographic(v0, subdivisionC0Scratch);
880
- const c1 = ellipsoid.cartesianToCartographic(v1, subdivisionC1Scratch);
881
- const c2 = ellipsoid.cartesianToCartographic(v2, subdivisionC2Scratch);
882
- rhumb0.setEndPoints(c0, c1);
883
- const g0 = rhumb0.surfaceDistance;
884
- rhumb1.setEndPoints(c1, c2);
885
- const g1 = rhumb1.surfaceDistance;
886
- rhumb2.setEndPoints(c2, c0);
887
- const g2 = rhumb2.surfaceDistance;
888
- const max = Math.max(g0, g1, g2);
889
- let edge;
890
- let mid;
891
- let midHeight;
892
- let midCartesian3;
893
- let midTexcoord;
894
- if (max > minDistance) {
895
- if (g0 === max) {
896
- edge = `${Math.min(i0, i1)} ${Math.max(i0, i1)}`;
897
- i = edges[edge];
898
- if (!defined_default(i)) {
899
- mid = rhumb0.interpolateUsingFraction(
900
- 0.5,
901
- subdivisionCartographicScratch
902
- );
903
- midHeight = (c0.height + c1.height) * 0.5;
904
- midCartesian3 = Cartesian3_default.fromRadians(
905
- mid.longitude,
906
- mid.latitude,
907
- midHeight,
908
- ellipsoid,
909
- subdivisionMidScratch
910
- );
911
- subdividedPositions.push(
912
- midCartesian3.x,
913
- midCartesian3.y,
914
- midCartesian3.z
915
- );
916
- i = subdividedPositions.length / 3 - 1;
917
- edges[edge] = i;
918
- if (hasTexcoords) {
919
- midTexcoord = Cartesian2_default.add(t0, t1, subdivisionTexcoordMidScratch);
920
- Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
921
- subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
922
- }
923
- }
924
- triangles.push(i0, i, i2);
925
- triangles.push(i, i1, i2);
926
- } else if (g1 === max) {
927
- edge = `${Math.min(i1, i2)} ${Math.max(i1, i2)}`;
928
- i = edges[edge];
929
- if (!defined_default(i)) {
930
- mid = rhumb1.interpolateUsingFraction(
931
- 0.5,
932
- subdivisionCartographicScratch
933
- );
934
- midHeight = (c1.height + c2.height) * 0.5;
935
- midCartesian3 = Cartesian3_default.fromRadians(
936
- mid.longitude,
937
- mid.latitude,
938
- midHeight,
939
- ellipsoid,
940
- subdivisionMidScratch
941
- );
942
- subdividedPositions.push(
943
- midCartesian3.x,
944
- midCartesian3.y,
945
- midCartesian3.z
946
- );
947
- i = subdividedPositions.length / 3 - 1;
948
- edges[edge] = i;
949
- if (hasTexcoords) {
950
- midTexcoord = Cartesian2_default.add(t1, t2, subdivisionTexcoordMidScratch);
951
- Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
952
- subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
953
- }
954
- }
955
- triangles.push(i1, i, i0);
956
- triangles.push(i, i2, i0);
957
- } else if (g2 === max) {
958
- edge = `${Math.min(i2, i0)} ${Math.max(i2, i0)}`;
959
- i = edges[edge];
960
- if (!defined_default(i)) {
961
- mid = rhumb2.interpolateUsingFraction(
962
- 0.5,
963
- subdivisionCartographicScratch
964
- );
965
- midHeight = (c2.height + c0.height) * 0.5;
966
- midCartesian3 = Cartesian3_default.fromRadians(
967
- mid.longitude,
968
- mid.latitude,
969
- midHeight,
970
- ellipsoid,
971
- subdivisionMidScratch
972
- );
973
- subdividedPositions.push(
974
- midCartesian3.x,
975
- midCartesian3.y,
976
- midCartesian3.z
977
- );
978
- i = subdividedPositions.length / 3 - 1;
979
- edges[edge] = i;
980
- if (hasTexcoords) {
981
- midTexcoord = Cartesian2_default.add(t2, t0, subdivisionTexcoordMidScratch);
982
- Cartesian2_default.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
983
- subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
984
- }
985
- }
986
- triangles.push(i2, i, i1);
987
- triangles.push(i, i0, i1);
988
- }
989
- } else {
990
- subdividedIndices.push(i0);
991
- subdividedIndices.push(i1);
992
- subdividedIndices.push(i2);
993
- }
994
- }
995
- const geometryOptions = {
996
- attributes: {
997
- position: new GeometryAttribute_default({
998
- componentDatatype: ComponentDatatype_default.DOUBLE,
999
- componentsPerAttribute: 3,
1000
- values: subdividedPositions
1001
- })
1002
- },
1003
- indices: subdividedIndices,
1004
- primitiveType: PrimitiveType_default.TRIANGLES
1005
- };
1006
- if (hasTexcoords) {
1007
- geometryOptions.attributes.st = new GeometryAttribute_default({
1008
- componentDatatype: ComponentDatatype_default.FLOAT,
1009
- componentsPerAttribute: 2,
1010
- values: subdividedTexcoords
1011
- });
1012
- }
1013
- return new Geometry_default(geometryOptions);
1014
- };
1015
- PolygonPipeline.scaleToGeodeticHeight = function(positions, height, ellipsoid, scaleToSurface) {
1016
- ellipsoid = ellipsoid ?? Ellipsoid_default.default;
1017
- let n = scaleToGeodeticHeightN;
1018
- let p = scaleToGeodeticHeightP;
1019
- height = height ?? 0;
1020
- scaleToSurface = scaleToSurface ?? true;
1021
- if (defined_default(positions)) {
1022
- const length = positions.length;
1023
- for (let i = 0; i < length; i += 3) {
1024
- Cartesian3_default.fromArray(positions, i, p);
1025
- if (scaleToSurface) {
1026
- p = ellipsoid.scaleToGeodeticSurface(p, p);
1027
- }
1028
- if (height !== 0) {
1029
- n = ellipsoid.geodeticSurfaceNormal(p, n);
1030
- Cartesian3_default.multiplyByScalar(n, height, n);
1031
- Cartesian3_default.add(p, n, p);
1032
- }
1033
- positions[i] = p.x;
1034
- positions[i + 1] = p.y;
1035
- positions[i + 2] = p.z;
1036
- }
1037
- }
1038
- return positions;
1039
- };
1040
- var PolygonPipeline_default = PolygonPipeline;
1041
-
1042
- export {
1043
- WindingOrder_default,
1044
- PolygonPipeline_default
1045
- };