@gmgis/gm-sdk 1.12.5 → 2.0.2

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 (159) hide show
  1. package/dist/dist/index.js +1848 -0
  2. package/dist/gm.min.js +16983 -16483
  3. package/dist/index.js +1436 -1434
  4. package/dist/resources/ThirdParty/Workers/pako_deflate.min.js +1 -2
  5. package/dist/resources/ThirdParty/Workers/pako_inflate.min.js +1 -2
  6. package/dist/resources/ThirdParty/Workers/z-worker-pako.js +1 -1
  7. package/dist/resources/ThirdParty/google-earth-dbroot-parser.js +1 -8337
  8. package/dist/resources/ThirdParty/wasm_splats_bg.wasm +0 -0
  9. package/dist/resources/Workers/chunk-35SHYARM.js +26 -0
  10. package/dist/resources/Workers/chunk-37F5JSTI.js +26 -0
  11. package/dist/resources/Workers/chunk-3SSKC3VN.js +26 -0
  12. package/dist/resources/Workers/chunk-3W4GT7KQ.js +26 -0
  13. package/dist/resources/Workers/chunk-4IW2T6GF.js +26 -0
  14. package/dist/resources/Workers/chunk-5YEWO3HT.js +26 -0
  15. package/dist/resources/Workers/chunk-64RSHJUE.js +28 -0
  16. package/dist/resources/Workers/chunk-77IHZJJ3.js +26 -0
  17. package/dist/resources/Workers/chunk-7HTKERZY.js +26 -0
  18. package/dist/resources/Workers/{chunk-I2ITFFPX.js → chunk-A56XVLQR.js} +2 -13
  19. package/dist/resources/Workers/chunk-AJYK4IVJ.js +26 -0
  20. package/dist/resources/Workers/{chunk-PRGYLLJT.js → chunk-ARG42DC4.js} +2 -31
  21. package/dist/resources/Workers/chunk-AU7IKHOH.js +26 -0
  22. package/dist/resources/Workers/chunk-B4AA3ARO.js +26 -0
  23. package/dist/resources/Workers/chunk-CNCV5UL7.js +26 -0
  24. package/dist/resources/Workers/chunk-CYCB63OH.js +26 -0
  25. package/dist/resources/Workers/{chunk-DI5NGJUP.js → chunk-D6AA5QVT.js} +2 -20
  26. package/dist/resources/Workers/chunk-D6C66QON.js +26 -0
  27. package/dist/resources/Workers/chunk-DEPHB2WM.js +26 -0
  28. package/dist/resources/Workers/chunk-DMEY62ID.js +26 -0
  29. package/dist/resources/Workers/chunk-DQQ63PYM.js +26 -0
  30. package/dist/resources/Workers/chunk-ED5JPB3S.js +27 -0
  31. package/dist/resources/Workers/chunk-EZUYS2JF.js +26 -0
  32. package/dist/resources/Workers/chunk-FEVXJ54I.js +26 -0
  33. package/dist/resources/Workers/chunk-G5AGHVVC.js +26 -0
  34. package/dist/resources/Workers/{chunk-7JO7GPJN.js → chunk-GBYLG25F.js} +2 -15
  35. package/dist/resources/Workers/chunk-GILIDQNQ.js +26 -0
  36. package/dist/resources/Workers/chunk-HMIYSTF6.js +26 -0
  37. package/dist/resources/Workers/chunk-HTFSEEMT.js +26 -0
  38. package/dist/resources/Workers/chunk-HWXX4CWK.js +26 -0
  39. package/dist/resources/Workers/chunk-IYTZ52EY.js +26 -0
  40. package/dist/resources/Workers/chunk-J6UP6FLE.js +26 -0
  41. package/dist/resources/Workers/chunk-LEYMRMBK.js +27 -0
  42. package/dist/resources/Workers/chunk-M3MGYQSL.js +26 -0
  43. package/dist/resources/Workers/chunk-N4VJKXZS.js +26 -0
  44. package/dist/resources/Workers/chunk-NB3ML6JO.js +26 -0
  45. package/dist/resources/Workers/chunk-OFUUQVMR.js +26 -0
  46. package/dist/resources/Workers/chunk-OSW76XDF.js +26 -0
  47. package/dist/resources/Workers/chunk-PSPPBZWI.js +66 -0
  48. package/dist/resources/Workers/chunk-QN3VOORQ.js +26 -0
  49. package/dist/resources/Workers/chunk-QOUAJ6TL.js +26 -0
  50. package/dist/resources/Workers/chunk-RCV6KWXS.js +26 -0
  51. package/dist/resources/Workers/chunk-TCGIRNHN.js +26 -0
  52. package/dist/resources/Workers/chunk-U4IEOH5K.js +26 -0
  53. package/dist/resources/Workers/chunk-UP6I5URU.js +26 -0
  54. package/dist/resources/Workers/chunk-VTAIKJXX.js +26 -0
  55. package/dist/resources/Workers/chunk-VTBDSFTG.js +26 -0
  56. package/dist/resources/Workers/chunk-VW6VD53G.js +26 -0
  57. package/dist/resources/Workers/chunk-WGGIH7QW.js +26 -0
  58. package/dist/resources/Workers/chunk-WWA5PL4H.js +26 -0
  59. package/dist/resources/Workers/{chunk-6CHGCNMW.js → chunk-WZDE3RYP.js} +4 -34
  60. package/dist/resources/Workers/chunk-XRL4AVS5.js +26 -0
  61. package/dist/resources/Workers/combineGeometry.js +2 -40
  62. package/dist/resources/Workers/createBoxGeometry.js +2 -32
  63. package/dist/resources/Workers/createBoxOutlineGeometry.js +2 -209
  64. package/dist/resources/Workers/createCircleGeometry.js +2 -175
  65. package/dist/resources/Workers/createCircleOutlineGeometry.js +2 -121
  66. package/dist/resources/Workers/createCoplanarPolygonGeometry.js +2 -481
  67. package/dist/resources/Workers/createCoplanarPolygonOutlineGeometry.js +2 -199
  68. package/dist/resources/Workers/createCorridorGeometry.js +2 -1237
  69. package/dist/resources/Workers/createCorridorOutlineGeometry.js +2 -542
  70. package/dist/resources/Workers/createCylinderGeometry.js +2 -34
  71. package/dist/resources/Workers/createCylinderOutlineGeometry.js +2 -205
  72. package/dist/resources/Workers/createEllipseGeometry.js +2 -45
  73. package/dist/resources/Workers/createEllipseOutlineGeometry.js +2 -38
  74. package/dist/resources/Workers/createEllipsoidGeometry.js +2 -33
  75. package/dist/resources/Workers/createEllipsoidOutlineGeometry.js +2 -35
  76. package/dist/resources/Workers/createFrustumGeometry.js +2 -32
  77. package/dist/resources/Workers/createFrustumOutlineGeometry.js +2 -210
  78. package/dist/resources/Workers/createGeometry.js +2 -144
  79. package/dist/resources/Workers/createGroundPolylineGeometry.js +2 -1582
  80. package/dist/resources/Workers/createPlaneGeometry.js +2 -198
  81. package/dist/resources/Workers/createPlaneOutlineGeometry.js +2 -98
  82. package/dist/resources/Workers/createPolygonGeometry.js +2 -1381
  83. package/dist/resources/Workers/createPolygonOutlineGeometry.js +2 -509
  84. package/dist/resources/Workers/createPolylineGeometry.js +2 -470
  85. package/dist/resources/Workers/createPolylineVolumeGeometry.js +2 -354
  86. package/dist/resources/Workers/createPolylineVolumeOutlineGeometry.js +2 -251
  87. package/dist/resources/Workers/createRectangleGeometry.js +2 -1246
  88. package/dist/resources/Workers/createRectangleOutlineGeometry.js +2 -453
  89. package/dist/resources/Workers/createSimplePolylineGeometry.js +2 -374
  90. package/dist/resources/Workers/createSphereGeometry.js +2 -92
  91. package/dist/resources/Workers/createSphereOutlineGeometry.js +2 -92
  92. package/dist/resources/Workers/createTaskProcessorWorker.js +2 -8
  93. package/dist/resources/Workers/createVectorTileClampedPolylines.js +2 -466
  94. package/dist/resources/Workers/createVectorTileGeometries.js +2 -361
  95. package/dist/resources/Workers/createVectorTilePoints.js +2 -88
  96. package/dist/resources/Workers/createVectorTilePolygons.js +2 -359
  97. package/dist/resources/Workers/createVectorTilePolylines.js +2 -236
  98. package/dist/resources/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +2 -539
  99. package/dist/resources/Workers/createVerticesFromHeightmap.js +2 -2252
  100. package/dist/resources/Workers/createVerticesFromQuantizedTerrainMesh.js +2 -729
  101. package/dist/resources/Workers/createWallGeometry.js +2 -464
  102. package/dist/resources/Workers/createWallOutlineGeometry.js +2 -312
  103. package/dist/resources/Workers/decodeDraco.js +2 -345
  104. package/dist/resources/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2642
  105. package/dist/resources/Workers/decodeI3S.js +2 -1319
  106. package/dist/resources/Workers/gaussianSplatSorter.js +26 -0
  107. package/dist/resources/Workers/gaussianSplatTextureGenerator.js +26 -0
  108. package/dist/resources/Workers/transcodeKTX2.js +29 -3360
  109. package/dist/resources/Workers/transferTypedArrayTest.js +2 -17
  110. package/dist/resources/Workers/upsampleQuantizedTerrainMesh.js +2 -793
  111. package/package.json +74 -74
  112. package/dist/resources/ThirdParty/Workers/basis_transcoder.js +0 -21
  113. package/dist/resources/Workers/chunk-26GA3JAM.js +0 -139
  114. package/dist/resources/Workers/chunk-27HUZ7SA.js +0 -305
  115. package/dist/resources/Workers/chunk-2ZGOQXYU.js +0 -171
  116. package/dist/resources/Workers/chunk-3Q2L65QU.js +0 -1258
  117. package/dist/resources/Workers/chunk-472HQ3EH.js +0 -100
  118. package/dist/resources/Workers/chunk-5ODQSF26.js +0 -101
  119. package/dist/resources/Workers/chunk-5OOFQLKF.js +0 -634
  120. package/dist/resources/Workers/chunk-5PTXS2GO.js +0 -10390
  121. package/dist/resources/Workers/chunk-76BYBWHP.js +0 -122
  122. package/dist/resources/Workers/chunk-7BMOHCPM.js +0 -390
  123. package/dist/resources/Workers/chunk-7KTQP4VB.js +0 -59
  124. package/dist/resources/Workers/chunk-7O373FFS.js +0 -665
  125. package/dist/resources/Workers/chunk-AD63PIY6.js +0 -163
  126. package/dist/resources/Workers/chunk-BHQJ2NT7.js +0 -353
  127. package/dist/resources/Workers/chunk-C6YYBQXW.js +0 -102
  128. package/dist/resources/Workers/chunk-CKY7HOHV.js +0 -287
  129. package/dist/resources/Workers/chunk-DHYHSFFJ.js +0 -73
  130. package/dist/resources/Workers/chunk-E27BLMDD.js +0 -115
  131. package/dist/resources/Workers/chunk-E63IIM5T.js +0 -75
  132. package/dist/resources/Workers/chunk-E6V6SQZW.js +0 -456
  133. package/dist/resources/Workers/chunk-EJZTDTUH.js +0 -138
  134. package/dist/resources/Workers/chunk-FDOV2LBJ.js +0 -220
  135. package/dist/resources/Workers/chunk-FIGIZHAQ.js +0 -684
  136. package/dist/resources/Workers/chunk-GESF4OXQ.js +0 -1800
  137. package/dist/resources/Workers/chunk-GGZJN2TI.js +0 -2717
  138. package/dist/resources/Workers/chunk-GNBFYG7F.js +0 -1481
  139. package/dist/resources/Workers/chunk-GWCFU2SA.js +0 -300
  140. package/dist/resources/Workers/chunk-IBLIYJZR.js +0 -196
  141. package/dist/resources/Workers/chunk-JW4FOI6M.js +0 -476
  142. package/dist/resources/Workers/chunk-K4GQUNB5.js +0 -262
  143. package/dist/resources/Workers/chunk-M3GMB5OP.js +0 -834
  144. package/dist/resources/Workers/chunk-MXIZJAPH.js +0 -629
  145. package/dist/resources/Workers/chunk-N5KJGGCM.js +0 -1073
  146. package/dist/resources/Workers/chunk-NGPPMXRM.js +0 -435
  147. package/dist/resources/Workers/chunk-O3E4OAOE.js +0 -511
  148. package/dist/resources/Workers/chunk-PGRPDNHG.js +0 -1048
  149. package/dist/resources/Workers/chunk-S6MRMMQU.js +0 -157
  150. package/dist/resources/Workers/chunk-SMDOP47J.js +0 -945
  151. package/dist/resources/Workers/chunk-TGONEMZO.js +0 -421
  152. package/dist/resources/Workers/chunk-TKVT5GQM.js +0 -781
  153. package/dist/resources/Workers/chunk-U72QNFOJ.js +0 -758
  154. package/dist/resources/Workers/chunk-VJZB3WAV.js +0 -963
  155. package/dist/resources/Workers/chunk-VU2MNO7L.js +0 -239
  156. package/dist/resources/Workers/chunk-XY4BATBS.js +0 -500
  157. package/dist/resources/Workers/chunk-YFXQECWV.js +0 -2857
  158. package/dist/resources/Workers/chunk-YSGTGQQO.js +0 -398
  159. package/dist/resources/Workers/chunk-YZ733KKS.js +0 -368
@@ -1,2717 +0,0 @@
1
- /**
2
- * @license
3
- * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.122
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
- AttributeCompression_default
28
- } from "./chunk-NGPPMXRM.js";
29
- import {
30
- EncodedCartesian3_default
31
- } from "./chunk-C6YYBQXW.js";
32
- import {
33
- IntersectionTests_default
34
- } from "./chunk-3Q2L65QU.js";
35
- import {
36
- Plane_default
37
- } from "./chunk-2ZGOQXYU.js";
38
- import {
39
- IndexDatatype_default
40
- } from "./chunk-26GA3JAM.js";
41
- import {
42
- GeometryAttribute_default,
43
- GeometryType_default,
44
- Geometry_default,
45
- PrimitiveType_default
46
- } from "./chunk-GWCFU2SA.js";
47
- import {
48
- BoundingSphere_default,
49
- GeographicProjection_default,
50
- Intersect_default
51
- } from "./chunk-VJZB3WAV.js";
52
- import {
53
- Cartesian4_default,
54
- Matrix4_default
55
- } from "./chunk-5PTXS2GO.js";
56
- import {
57
- ComponentDatatype_default
58
- } from "./chunk-K4GQUNB5.js";
59
- import {
60
- Cartesian2_default,
61
- Cartesian3_default,
62
- Cartographic_default,
63
- Matrix3_default
64
- } from "./chunk-YFXQECWV.js";
65
- import {
66
- Math_default
67
- } from "./chunk-XY4BATBS.js";
68
- import {
69
- defaultValue_default
70
- } from "./chunk-7JO7GPJN.js";
71
- import {
72
- Check_default,
73
- DeveloperError_default
74
- } from "./chunk-AD63PIY6.js";
75
- import {
76
- defined_default
77
- } from "./chunk-E63IIM5T.js";
78
-
79
- // packages/engine/Source/Core/barycentricCoordinates.js
80
- var scratchCartesian1 = new Cartesian3_default();
81
- var scratchCartesian2 = new Cartesian3_default();
82
- var scratchCartesian3 = new Cartesian3_default();
83
- function barycentricCoordinates(point, p0, p1, p2, result) {
84
- Check_default.defined("point", point);
85
- Check_default.defined("p0", p0);
86
- Check_default.defined("p1", p1);
87
- Check_default.defined("p2", p2);
88
- if (!defined_default(result)) {
89
- result = new Cartesian3_default();
90
- }
91
- let v02;
92
- let v12;
93
- let v22;
94
- let dot00;
95
- let dot01;
96
- let dot02;
97
- let dot11;
98
- let dot12;
99
- if (!defined_default(p0.z)) {
100
- if (Cartesian2_default.equalsEpsilon(point, p0, Math_default.EPSILON14)) {
101
- return Cartesian3_default.clone(Cartesian3_default.UNIT_X, result);
102
- }
103
- if (Cartesian2_default.equalsEpsilon(point, p1, Math_default.EPSILON14)) {
104
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Y, result);
105
- }
106
- if (Cartesian2_default.equalsEpsilon(point, p2, Math_default.EPSILON14)) {
107
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Z, result);
108
- }
109
- v02 = Cartesian2_default.subtract(p1, p0, scratchCartesian1);
110
- v12 = Cartesian2_default.subtract(p2, p0, scratchCartesian2);
111
- v22 = Cartesian2_default.subtract(point, p0, scratchCartesian3);
112
- dot00 = Cartesian2_default.dot(v02, v02);
113
- dot01 = Cartesian2_default.dot(v02, v12);
114
- dot02 = Cartesian2_default.dot(v02, v22);
115
- dot11 = Cartesian2_default.dot(v12, v12);
116
- dot12 = Cartesian2_default.dot(v12, v22);
117
- } else {
118
- if (Cartesian3_default.equalsEpsilon(point, p0, Math_default.EPSILON14)) {
119
- return Cartesian3_default.clone(Cartesian3_default.UNIT_X, result);
120
- }
121
- if (Cartesian3_default.equalsEpsilon(point, p1, Math_default.EPSILON14)) {
122
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Y, result);
123
- }
124
- if (Cartesian3_default.equalsEpsilon(point, p2, Math_default.EPSILON14)) {
125
- return Cartesian3_default.clone(Cartesian3_default.UNIT_Z, result);
126
- }
127
- v02 = Cartesian3_default.subtract(p1, p0, scratchCartesian1);
128
- v12 = Cartesian3_default.subtract(p2, p0, scratchCartesian2);
129
- v22 = Cartesian3_default.subtract(point, p0, scratchCartesian3);
130
- dot00 = Cartesian3_default.dot(v02, v02);
131
- dot01 = Cartesian3_default.dot(v02, v12);
132
- dot02 = Cartesian3_default.dot(v02, v22);
133
- dot11 = Cartesian3_default.dot(v12, v12);
134
- dot12 = Cartesian3_default.dot(v12, v22);
135
- }
136
- result.y = dot11 * dot02 - dot01 * dot12;
137
- result.z = dot00 * dot12 - dot01 * dot02;
138
- const q = dot00 * dot11 - dot01 * dot01;
139
- if (q === 0) {
140
- return void 0;
141
- }
142
- result.y /= q;
143
- result.z /= q;
144
- result.x = 1 - result.y - result.z;
145
- return result;
146
- }
147
- var barycentricCoordinates_default = barycentricCoordinates;
148
-
149
- // packages/engine/Source/Core/Tipsify.js
150
- var Tipsify = {};
151
- Tipsify.calculateACMR = function(options) {
152
- options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
153
- const indices = options.indices;
154
- let maximumIndex = options.maximumIndex;
155
- const cacheSize = defaultValue_default(options.cacheSize, 24);
156
- if (!defined_default(indices)) {
157
- throw new DeveloperError_default("indices is required.");
158
- }
159
- const numIndices = indices.length;
160
- if (numIndices < 3 || numIndices % 3 !== 0) {
161
- throw new DeveloperError_default("indices length must be a multiple of three.");
162
- }
163
- if (maximumIndex <= 0) {
164
- throw new DeveloperError_default("maximumIndex must be greater than zero.");
165
- }
166
- if (cacheSize < 3) {
167
- throw new DeveloperError_default("cacheSize must be greater than two.");
168
- }
169
- if (!defined_default(maximumIndex)) {
170
- maximumIndex = 0;
171
- let currentIndex = 0;
172
- let intoIndices = indices[currentIndex];
173
- while (currentIndex < numIndices) {
174
- if (intoIndices > maximumIndex) {
175
- maximumIndex = intoIndices;
176
- }
177
- ++currentIndex;
178
- intoIndices = indices[currentIndex];
179
- }
180
- }
181
- const vertexTimeStamps = [];
182
- for (let i = 0; i < maximumIndex + 1; i++) {
183
- vertexTimeStamps[i] = 0;
184
- }
185
- let s = cacheSize + 1;
186
- for (let j = 0; j < numIndices; ++j) {
187
- if (s - vertexTimeStamps[indices[j]] > cacheSize) {
188
- vertexTimeStamps[indices[j]] = s;
189
- ++s;
190
- }
191
- }
192
- return (s - cacheSize + 1) / (numIndices / 3);
193
- };
194
- Tipsify.tipsify = function(options) {
195
- options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
196
- const indices = options.indices;
197
- const maximumIndex = options.maximumIndex;
198
- const cacheSize = defaultValue_default(options.cacheSize, 24);
199
- let cursor;
200
- function skipDeadEnd(vertices2, deadEnd2, indices2, maximumIndexPlusOne2) {
201
- while (deadEnd2.length >= 1) {
202
- const d = deadEnd2[deadEnd2.length - 1];
203
- deadEnd2.splice(deadEnd2.length - 1, 1);
204
- if (vertices2[d].numLiveTriangles > 0) {
205
- return d;
206
- }
207
- }
208
- while (cursor < maximumIndexPlusOne2) {
209
- if (vertices2[cursor].numLiveTriangles > 0) {
210
- ++cursor;
211
- return cursor - 1;
212
- }
213
- ++cursor;
214
- }
215
- return -1;
216
- }
217
- function getNextVertex(indices2, cacheSize2, oneRing2, vertices2, s2, deadEnd2, maximumIndexPlusOne2) {
218
- let n = -1;
219
- let p;
220
- let m = -1;
221
- let itOneRing = 0;
222
- while (itOneRing < oneRing2.length) {
223
- const index2 = oneRing2[itOneRing];
224
- if (vertices2[index2].numLiveTriangles) {
225
- p = 0;
226
- if (s2 - vertices2[index2].timeStamp + 2 * vertices2[index2].numLiveTriangles <= cacheSize2) {
227
- p = s2 - vertices2[index2].timeStamp;
228
- }
229
- if (p > m || m === -1) {
230
- m = p;
231
- n = index2;
232
- }
233
- }
234
- ++itOneRing;
235
- }
236
- if (n === -1) {
237
- return skipDeadEnd(vertices2, deadEnd2, indices2, maximumIndexPlusOne2);
238
- }
239
- return n;
240
- }
241
- if (!defined_default(indices)) {
242
- throw new DeveloperError_default("indices is required.");
243
- }
244
- const numIndices = indices.length;
245
- if (numIndices < 3 || numIndices % 3 !== 0) {
246
- throw new DeveloperError_default("indices length must be a multiple of three.");
247
- }
248
- if (maximumIndex <= 0) {
249
- throw new DeveloperError_default("maximumIndex must be greater than zero.");
250
- }
251
- if (cacheSize < 3) {
252
- throw new DeveloperError_default("cacheSize must be greater than two.");
253
- }
254
- let maximumIndexPlusOne = 0;
255
- let currentIndex = 0;
256
- let intoIndices = indices[currentIndex];
257
- const endIndex = numIndices;
258
- if (defined_default(maximumIndex)) {
259
- maximumIndexPlusOne = maximumIndex + 1;
260
- } else {
261
- while (currentIndex < endIndex) {
262
- if (intoIndices > maximumIndexPlusOne) {
263
- maximumIndexPlusOne = intoIndices;
264
- }
265
- ++currentIndex;
266
- intoIndices = indices[currentIndex];
267
- }
268
- if (maximumIndexPlusOne === -1) {
269
- return 0;
270
- }
271
- ++maximumIndexPlusOne;
272
- }
273
- const vertices = [];
274
- let i;
275
- for (i = 0; i < maximumIndexPlusOne; i++) {
276
- vertices[i] = {
277
- numLiveTriangles: 0,
278
- timeStamp: 0,
279
- vertexTriangles: []
280
- };
281
- }
282
- currentIndex = 0;
283
- let triangle = 0;
284
- while (currentIndex < endIndex) {
285
- vertices[indices[currentIndex]].vertexTriangles.push(triangle);
286
- ++vertices[indices[currentIndex]].numLiveTriangles;
287
- vertices[indices[currentIndex + 1]].vertexTriangles.push(triangle);
288
- ++vertices[indices[currentIndex + 1]].numLiveTriangles;
289
- vertices[indices[currentIndex + 2]].vertexTriangles.push(triangle);
290
- ++vertices[indices[currentIndex + 2]].numLiveTriangles;
291
- ++triangle;
292
- currentIndex += 3;
293
- }
294
- let f = 0;
295
- let s = cacheSize + 1;
296
- cursor = 1;
297
- let oneRing = [];
298
- const deadEnd = [];
299
- let vertex;
300
- let intoVertices;
301
- let currentOutputIndex = 0;
302
- const outputIndices = [];
303
- const numTriangles = numIndices / 3;
304
- const triangleEmitted = [];
305
- for (i = 0; i < numTriangles; i++) {
306
- triangleEmitted[i] = false;
307
- }
308
- let index;
309
- let limit;
310
- while (f !== -1) {
311
- oneRing = [];
312
- intoVertices = vertices[f];
313
- limit = intoVertices.vertexTriangles.length;
314
- for (let k = 0; k < limit; ++k) {
315
- triangle = intoVertices.vertexTriangles[k];
316
- if (!triangleEmitted[triangle]) {
317
- triangleEmitted[triangle] = true;
318
- currentIndex = triangle + triangle + triangle;
319
- for (let j = 0; j < 3; ++j) {
320
- index = indices[currentIndex];
321
- oneRing.push(index);
322
- deadEnd.push(index);
323
- outputIndices[currentOutputIndex] = index;
324
- ++currentOutputIndex;
325
- vertex = vertices[index];
326
- --vertex.numLiveTriangles;
327
- if (s - vertex.timeStamp > cacheSize) {
328
- vertex.timeStamp = s;
329
- ++s;
330
- }
331
- ++currentIndex;
332
- }
333
- }
334
- }
335
- f = getNextVertex(
336
- indices,
337
- cacheSize,
338
- oneRing,
339
- vertices,
340
- s,
341
- deadEnd,
342
- maximumIndexPlusOne
343
- );
344
- }
345
- return outputIndices;
346
- };
347
- var Tipsify_default = Tipsify;
348
-
349
- // packages/engine/Source/Core/GeometryPipeline.js
350
- var GeometryPipeline = {};
351
- function addTriangle(lines, index, i0, i1, i2) {
352
- lines[index++] = i0;
353
- lines[index++] = i1;
354
- lines[index++] = i1;
355
- lines[index++] = i2;
356
- lines[index++] = i2;
357
- lines[index] = i0;
358
- }
359
- function trianglesToLines(triangles) {
360
- const count = triangles.length;
361
- const size = count / 3 * 6;
362
- const lines = IndexDatatype_default.createTypedArray(count, size);
363
- let index = 0;
364
- for (let i = 0; i < count; i += 3, index += 6) {
365
- addTriangle(lines, index, triangles[i], triangles[i + 1], triangles[i + 2]);
366
- }
367
- return lines;
368
- }
369
- function triangleStripToLines(triangles) {
370
- const count = triangles.length;
371
- if (count >= 3) {
372
- const size = (count - 2) * 6;
373
- const lines = IndexDatatype_default.createTypedArray(count, size);
374
- addTriangle(lines, 0, triangles[0], triangles[1], triangles[2]);
375
- let index = 6;
376
- for (let i = 3; i < count; ++i, index += 6) {
377
- addTriangle(
378
- lines,
379
- index,
380
- triangles[i - 1],
381
- triangles[i],
382
- triangles[i - 2]
383
- );
384
- }
385
- return lines;
386
- }
387
- return new Uint16Array();
388
- }
389
- function triangleFanToLines(triangles) {
390
- if (triangles.length > 0) {
391
- const count = triangles.length - 1;
392
- const size = (count - 1) * 6;
393
- const lines = IndexDatatype_default.createTypedArray(count, size);
394
- const base = triangles[0];
395
- let index = 0;
396
- for (let i = 1; i < count; ++i, index += 6) {
397
- addTriangle(lines, index, base, triangles[i], triangles[i + 1]);
398
- }
399
- return lines;
400
- }
401
- return new Uint16Array();
402
- }
403
- GeometryPipeline.toWireframe = function(geometry) {
404
- if (!defined_default(geometry)) {
405
- throw new DeveloperError_default("geometry is required.");
406
- }
407
- const indices = geometry.indices;
408
- if (defined_default(indices)) {
409
- switch (geometry.primitiveType) {
410
- case PrimitiveType_default.TRIANGLES:
411
- geometry.indices = trianglesToLines(indices);
412
- break;
413
- case PrimitiveType_default.TRIANGLE_STRIP:
414
- geometry.indices = triangleStripToLines(indices);
415
- break;
416
- case PrimitiveType_default.TRIANGLE_FAN:
417
- geometry.indices = triangleFanToLines(indices);
418
- break;
419
- //>>includeStart('debug', pragmas.debug);
420
- default:
421
- throw new DeveloperError_default(
422
- "geometry.primitiveType must be TRIANGLES, TRIANGLE_STRIP, or TRIANGLE_FAN."
423
- );
424
- }
425
- geometry.primitiveType = PrimitiveType_default.LINES;
426
- }
427
- return geometry;
428
- };
429
- GeometryPipeline.createLineSegmentsForVectors = function(geometry, attributeName, length) {
430
- attributeName = defaultValue_default(attributeName, "normal");
431
- if (!defined_default(geometry)) {
432
- throw new DeveloperError_default("geometry is required.");
433
- }
434
- if (!defined_default(geometry.attributes.position)) {
435
- throw new DeveloperError_default("geometry.attributes.position is required.");
436
- }
437
- if (!defined_default(geometry.attributes[attributeName])) {
438
- throw new DeveloperError_default(
439
- `geometry.attributes must have an attribute with the same name as the attributeName parameter, ${attributeName}.`
440
- );
441
- }
442
- length = defaultValue_default(length, 1e4);
443
- const positions = geometry.attributes.position.values;
444
- const vectors = geometry.attributes[attributeName].values;
445
- const positionsLength = positions.length;
446
- const newPositions = new Float64Array(2 * positionsLength);
447
- let j = 0;
448
- for (let i = 0; i < positionsLength; i += 3) {
449
- newPositions[j++] = positions[i];
450
- newPositions[j++] = positions[i + 1];
451
- newPositions[j++] = positions[i + 2];
452
- newPositions[j++] = positions[i] + vectors[i] * length;
453
- newPositions[j++] = positions[i + 1] + vectors[i + 1] * length;
454
- newPositions[j++] = positions[i + 2] + vectors[i + 2] * length;
455
- }
456
- let newBoundingSphere;
457
- const bs = geometry.boundingSphere;
458
- if (defined_default(bs)) {
459
- newBoundingSphere = new BoundingSphere_default(bs.center, bs.radius + length);
460
- }
461
- return new Geometry_default({
462
- attributes: {
463
- position: new GeometryAttribute_default({
464
- componentDatatype: ComponentDatatype_default.DOUBLE,
465
- componentsPerAttribute: 3,
466
- values: newPositions
467
- })
468
- },
469
- primitiveType: PrimitiveType_default.LINES,
470
- boundingSphere: newBoundingSphere
471
- });
472
- };
473
- GeometryPipeline.createAttributeLocations = function(geometry) {
474
- if (!defined_default(geometry)) {
475
- throw new DeveloperError_default("geometry is required.");
476
- }
477
- const semantics = [
478
- "position",
479
- "positionHigh",
480
- "positionLow",
481
- // From VertexFormat.position - after 2D projection and high-precision encoding
482
- "position3DHigh",
483
- "position3DLow",
484
- "position2DHigh",
485
- "position2DLow",
486
- // From Primitive
487
- "pickColor",
488
- // From VertexFormat
489
- "normal",
490
- "st",
491
- "tangent",
492
- "bitangent",
493
- // For shadow volumes
494
- "extrudeDirection",
495
- // From compressing texture coordinates and normals
496
- "compressedAttributes"
497
- ];
498
- const attributes = geometry.attributes;
499
- const indices = {};
500
- let j = 0;
501
- let i;
502
- const len = semantics.length;
503
- for (i = 0; i < len; ++i) {
504
- const semantic = semantics[i];
505
- if (defined_default(attributes[semantic])) {
506
- indices[semantic] = j++;
507
- }
508
- }
509
- for (const name in attributes) {
510
- if (attributes.hasOwnProperty(name) && !defined_default(indices[name])) {
511
- indices[name] = j++;
512
- }
513
- }
514
- return indices;
515
- };
516
- GeometryPipeline.reorderForPreVertexCache = function(geometry) {
517
- if (!defined_default(geometry)) {
518
- throw new DeveloperError_default("geometry is required.");
519
- }
520
- const numVertices = Geometry_default.computeNumberOfVertices(geometry);
521
- const indices = geometry.indices;
522
- if (defined_default(indices)) {
523
- const indexCrossReferenceOldToNew = new Int32Array(numVertices);
524
- for (let i = 0; i < numVertices; i++) {
525
- indexCrossReferenceOldToNew[i] = -1;
526
- }
527
- const indicesIn = indices;
528
- const numIndices = indicesIn.length;
529
- const indicesOut = IndexDatatype_default.createTypedArray(numVertices, numIndices);
530
- let intoIndicesIn = 0;
531
- let intoIndicesOut = 0;
532
- let nextIndex = 0;
533
- let tempIndex;
534
- while (intoIndicesIn < numIndices) {
535
- tempIndex = indexCrossReferenceOldToNew[indicesIn[intoIndicesIn]];
536
- if (tempIndex !== -1) {
537
- indicesOut[intoIndicesOut] = tempIndex;
538
- } else {
539
- tempIndex = indicesIn[intoIndicesIn];
540
- indexCrossReferenceOldToNew[tempIndex] = nextIndex;
541
- indicesOut[intoIndicesOut] = nextIndex;
542
- ++nextIndex;
543
- }
544
- ++intoIndicesIn;
545
- ++intoIndicesOut;
546
- }
547
- geometry.indices = indicesOut;
548
- const attributes = geometry.attributes;
549
- for (const property in attributes) {
550
- if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
551
- const attribute = attributes[property];
552
- const elementsIn = attribute.values;
553
- let intoElementsIn = 0;
554
- const numComponents = attribute.componentsPerAttribute;
555
- const elementsOut = ComponentDatatype_default.createTypedArray(
556
- attribute.componentDatatype,
557
- nextIndex * numComponents
558
- );
559
- while (intoElementsIn < numVertices) {
560
- const temp = indexCrossReferenceOldToNew[intoElementsIn];
561
- if (temp !== -1) {
562
- for (let j = 0; j < numComponents; j++) {
563
- elementsOut[numComponents * temp + j] = elementsIn[numComponents * intoElementsIn + j];
564
- }
565
- }
566
- ++intoElementsIn;
567
- }
568
- attribute.values = elementsOut;
569
- }
570
- }
571
- }
572
- return geometry;
573
- };
574
- GeometryPipeline.reorderForPostVertexCache = function(geometry, cacheCapacity) {
575
- if (!defined_default(geometry)) {
576
- throw new DeveloperError_default("geometry is required.");
577
- }
578
- const indices = geometry.indices;
579
- if (geometry.primitiveType === PrimitiveType_default.TRIANGLES && defined_default(indices)) {
580
- const numIndices = indices.length;
581
- let maximumIndex = 0;
582
- for (let j = 0; j < numIndices; j++) {
583
- if (indices[j] > maximumIndex) {
584
- maximumIndex = indices[j];
585
- }
586
- }
587
- geometry.indices = Tipsify_default.tipsify({
588
- indices,
589
- maximumIndex,
590
- cacheSize: cacheCapacity
591
- });
592
- }
593
- return geometry;
594
- };
595
- function copyAttributesDescriptions(attributes) {
596
- const newAttributes = {};
597
- for (const attribute in attributes) {
598
- if (attributes.hasOwnProperty(attribute) && defined_default(attributes[attribute]) && defined_default(attributes[attribute].values)) {
599
- const attr = attributes[attribute];
600
- newAttributes[attribute] = new GeometryAttribute_default({
601
- componentDatatype: attr.componentDatatype,
602
- componentsPerAttribute: attr.componentsPerAttribute,
603
- normalize: attr.normalize,
604
- values: []
605
- });
606
- }
607
- }
608
- return newAttributes;
609
- }
610
- function copyVertex(destinationAttributes, sourceAttributes, index) {
611
- for (const attribute in sourceAttributes) {
612
- if (sourceAttributes.hasOwnProperty(attribute) && defined_default(sourceAttributes[attribute]) && defined_default(sourceAttributes[attribute].values)) {
613
- const attr = sourceAttributes[attribute];
614
- for (let k = 0; k < attr.componentsPerAttribute; ++k) {
615
- destinationAttributes[attribute].values.push(
616
- attr.values[index * attr.componentsPerAttribute + k]
617
- );
618
- }
619
- }
620
- }
621
- }
622
- GeometryPipeline.fitToUnsignedShortIndices = function(geometry) {
623
- if (!defined_default(geometry)) {
624
- throw new DeveloperError_default("geometry is required.");
625
- }
626
- if (defined_default(geometry.indices) && geometry.primitiveType !== PrimitiveType_default.TRIANGLES && geometry.primitiveType !== PrimitiveType_default.LINES && geometry.primitiveType !== PrimitiveType_default.POINTS) {
627
- throw new DeveloperError_default(
628
- "geometry.primitiveType must equal to PrimitiveType.TRIANGLES, PrimitiveType.LINES, or PrimitiveType.POINTS."
629
- );
630
- }
631
- const geometries = [];
632
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
633
- if (defined_default(geometry.indices) && numberOfVertices >= Math_default.SIXTY_FOUR_KILOBYTES) {
634
- let oldToNewIndex = [];
635
- let newIndices = [];
636
- let currentIndex = 0;
637
- let newAttributes = copyAttributesDescriptions(geometry.attributes);
638
- const originalIndices = geometry.indices;
639
- const numberOfIndices = originalIndices.length;
640
- let indicesPerPrimitive;
641
- if (geometry.primitiveType === PrimitiveType_default.TRIANGLES) {
642
- indicesPerPrimitive = 3;
643
- } else if (geometry.primitiveType === PrimitiveType_default.LINES) {
644
- indicesPerPrimitive = 2;
645
- } else if (geometry.primitiveType === PrimitiveType_default.POINTS) {
646
- indicesPerPrimitive = 1;
647
- }
648
- for (let j = 0; j < numberOfIndices; j += indicesPerPrimitive) {
649
- for (let k = 0; k < indicesPerPrimitive; ++k) {
650
- const x = originalIndices[j + k];
651
- let i = oldToNewIndex[x];
652
- if (!defined_default(i)) {
653
- i = currentIndex++;
654
- oldToNewIndex[x] = i;
655
- copyVertex(newAttributes, geometry.attributes, x);
656
- }
657
- newIndices.push(i);
658
- }
659
- if (currentIndex + indicesPerPrimitive >= Math_default.SIXTY_FOUR_KILOBYTES) {
660
- geometries.push(
661
- new Geometry_default({
662
- attributes: newAttributes,
663
- indices: newIndices,
664
- primitiveType: geometry.primitiveType,
665
- boundingSphere: geometry.boundingSphere,
666
- boundingSphereCV: geometry.boundingSphereCV
667
- })
668
- );
669
- oldToNewIndex = [];
670
- newIndices = [];
671
- currentIndex = 0;
672
- newAttributes = copyAttributesDescriptions(geometry.attributes);
673
- }
674
- }
675
- if (newIndices.length !== 0) {
676
- geometries.push(
677
- new Geometry_default({
678
- attributes: newAttributes,
679
- indices: newIndices,
680
- primitiveType: geometry.primitiveType,
681
- boundingSphere: geometry.boundingSphere,
682
- boundingSphereCV: geometry.boundingSphereCV
683
- })
684
- );
685
- }
686
- } else {
687
- geometries.push(geometry);
688
- }
689
- return geometries;
690
- };
691
- var scratchProjectTo2DCartesian3 = new Cartesian3_default();
692
- var scratchProjectTo2DCartographic = new Cartographic_default();
693
- GeometryPipeline.projectTo2D = function(geometry, attributeName, attributeName3D, attributeName2D, projection) {
694
- if (!defined_default(geometry)) {
695
- throw new DeveloperError_default("geometry is required.");
696
- }
697
- if (!defined_default(attributeName)) {
698
- throw new DeveloperError_default("attributeName is required.");
699
- }
700
- if (!defined_default(attributeName3D)) {
701
- throw new DeveloperError_default("attributeName3D is required.");
702
- }
703
- if (!defined_default(attributeName2D)) {
704
- throw new DeveloperError_default("attributeName2D is required.");
705
- }
706
- if (!defined_default(geometry.attributes[attributeName])) {
707
- throw new DeveloperError_default(
708
- `geometry must have attribute matching the attributeName argument: ${attributeName}.`
709
- );
710
- }
711
- if (geometry.attributes[attributeName].componentDatatype !== ComponentDatatype_default.DOUBLE) {
712
- throw new DeveloperError_default(
713
- "The attribute componentDatatype must be ComponentDatatype.DOUBLE."
714
- );
715
- }
716
- const attribute = geometry.attributes[attributeName];
717
- projection = defined_default(projection) ? projection : new GeographicProjection_default();
718
- const ellipsoid = projection.ellipsoid;
719
- const values3D = attribute.values;
720
- const projectedValues = new Float64Array(values3D.length);
721
- let index = 0;
722
- for (let i = 0; i < values3D.length; i += 3) {
723
- const value = Cartesian3_default.fromArray(
724
- values3D,
725
- i,
726
- scratchProjectTo2DCartesian3
727
- );
728
- const lonLat = ellipsoid.cartesianToCartographic(
729
- value,
730
- scratchProjectTo2DCartographic
731
- );
732
- if (!defined_default(lonLat)) {
733
- throw new DeveloperError_default(
734
- `Could not project point (${value.x}, ${value.y}, ${value.z}) to 2D.`
735
- );
736
- }
737
- const projectedLonLat = projection.project(
738
- lonLat,
739
- scratchProjectTo2DCartesian3
740
- );
741
- projectedValues[index++] = projectedLonLat.x;
742
- projectedValues[index++] = projectedLonLat.y;
743
- projectedValues[index++] = projectedLonLat.z;
744
- }
745
- geometry.attributes[attributeName3D] = attribute;
746
- geometry.attributes[attributeName2D] = new GeometryAttribute_default({
747
- componentDatatype: ComponentDatatype_default.DOUBLE,
748
- componentsPerAttribute: 3,
749
- values: projectedValues
750
- });
751
- delete geometry.attributes[attributeName];
752
- return geometry;
753
- };
754
- var encodedResult = {
755
- high: 0,
756
- low: 0
757
- };
758
- GeometryPipeline.encodeAttribute = function(geometry, attributeName, attributeHighName, attributeLowName) {
759
- if (!defined_default(geometry)) {
760
- throw new DeveloperError_default("geometry is required.");
761
- }
762
- if (!defined_default(attributeName)) {
763
- throw new DeveloperError_default("attributeName is required.");
764
- }
765
- if (!defined_default(attributeHighName)) {
766
- throw new DeveloperError_default("attributeHighName is required.");
767
- }
768
- if (!defined_default(attributeLowName)) {
769
- throw new DeveloperError_default("attributeLowName is required.");
770
- }
771
- if (!defined_default(geometry.attributes[attributeName])) {
772
- throw new DeveloperError_default(
773
- `geometry must have attribute matching the attributeName argument: ${attributeName}.`
774
- );
775
- }
776
- if (geometry.attributes[attributeName].componentDatatype !== ComponentDatatype_default.DOUBLE) {
777
- throw new DeveloperError_default(
778
- "The attribute componentDatatype must be ComponentDatatype.DOUBLE."
779
- );
780
- }
781
- const attribute = geometry.attributes[attributeName];
782
- const values = attribute.values;
783
- const length = values.length;
784
- const highValues = new Float32Array(length);
785
- const lowValues = new Float32Array(length);
786
- for (let i = 0; i < length; ++i) {
787
- EncodedCartesian3_default.encode(values[i], encodedResult);
788
- highValues[i] = encodedResult.high;
789
- lowValues[i] = encodedResult.low;
790
- }
791
- const componentsPerAttribute = attribute.componentsPerAttribute;
792
- geometry.attributes[attributeHighName] = new GeometryAttribute_default({
793
- componentDatatype: ComponentDatatype_default.FLOAT,
794
- componentsPerAttribute,
795
- values: highValues
796
- });
797
- geometry.attributes[attributeLowName] = new GeometryAttribute_default({
798
- componentDatatype: ComponentDatatype_default.FLOAT,
799
- componentsPerAttribute,
800
- values: lowValues
801
- });
802
- delete geometry.attributes[attributeName];
803
- return geometry;
804
- };
805
- var scratchCartesian32 = new Cartesian3_default();
806
- function transformPoint(matrix, attribute) {
807
- if (defined_default(attribute)) {
808
- const values = attribute.values;
809
- const length = values.length;
810
- for (let i = 0; i < length; i += 3) {
811
- Cartesian3_default.unpack(values, i, scratchCartesian32);
812
- Matrix4_default.multiplyByPoint(matrix, scratchCartesian32, scratchCartesian32);
813
- Cartesian3_default.pack(scratchCartesian32, values, i);
814
- }
815
- }
816
- }
817
- function transformVector(matrix, attribute) {
818
- if (defined_default(attribute)) {
819
- const values = attribute.values;
820
- const length = values.length;
821
- for (let i = 0; i < length; i += 3) {
822
- Cartesian3_default.unpack(values, i, scratchCartesian32);
823
- Matrix3_default.multiplyByVector(matrix, scratchCartesian32, scratchCartesian32);
824
- scratchCartesian32 = Cartesian3_default.normalize(
825
- scratchCartesian32,
826
- scratchCartesian32
827
- );
828
- Cartesian3_default.pack(scratchCartesian32, values, i);
829
- }
830
- }
831
- }
832
- var inverseTranspose = new Matrix4_default();
833
- var normalMatrix = new Matrix3_default();
834
- GeometryPipeline.transformToWorldCoordinates = function(instance) {
835
- if (!defined_default(instance)) {
836
- throw new DeveloperError_default("instance is required.");
837
- }
838
- const modelMatrix = instance.modelMatrix;
839
- if (Matrix4_default.equals(modelMatrix, Matrix4_default.IDENTITY)) {
840
- return instance;
841
- }
842
- const attributes = instance.geometry.attributes;
843
- transformPoint(modelMatrix, attributes.position);
844
- transformPoint(modelMatrix, attributes.prevPosition);
845
- transformPoint(modelMatrix, attributes.nextPosition);
846
- if (defined_default(attributes.normal) || defined_default(attributes.tangent) || defined_default(attributes.bitangent)) {
847
- Matrix4_default.inverse(modelMatrix, inverseTranspose);
848
- Matrix4_default.transpose(inverseTranspose, inverseTranspose);
849
- Matrix4_default.getMatrix3(inverseTranspose, normalMatrix);
850
- transformVector(normalMatrix, attributes.normal);
851
- transformVector(normalMatrix, attributes.tangent);
852
- transformVector(normalMatrix, attributes.bitangent);
853
- }
854
- const boundingSphere = instance.geometry.boundingSphere;
855
- if (defined_default(boundingSphere)) {
856
- instance.geometry.boundingSphere = BoundingSphere_default.transform(
857
- boundingSphere,
858
- modelMatrix,
859
- boundingSphere
860
- );
861
- }
862
- instance.modelMatrix = Matrix4_default.clone(Matrix4_default.IDENTITY);
863
- return instance;
864
- };
865
- function findAttributesInAllGeometries(instances, propertyName) {
866
- const length = instances.length;
867
- const attributesInAllGeometries = {};
868
- const attributes0 = instances[0][propertyName].attributes;
869
- let name;
870
- for (name in attributes0) {
871
- if (attributes0.hasOwnProperty(name) && defined_default(attributes0[name]) && defined_default(attributes0[name].values)) {
872
- const attribute = attributes0[name];
873
- let numberOfComponents = attribute.values.length;
874
- let inAllGeometries = true;
875
- for (let i = 1; i < length; ++i) {
876
- const otherAttribute = instances[i][propertyName].attributes[name];
877
- if (!defined_default(otherAttribute) || attribute.componentDatatype !== otherAttribute.componentDatatype || attribute.componentsPerAttribute !== otherAttribute.componentsPerAttribute || attribute.normalize !== otherAttribute.normalize) {
878
- inAllGeometries = false;
879
- break;
880
- }
881
- numberOfComponents += otherAttribute.values.length;
882
- }
883
- if (inAllGeometries) {
884
- attributesInAllGeometries[name] = new GeometryAttribute_default({
885
- componentDatatype: attribute.componentDatatype,
886
- componentsPerAttribute: attribute.componentsPerAttribute,
887
- normalize: attribute.normalize,
888
- values: ComponentDatatype_default.createTypedArray(
889
- attribute.componentDatatype,
890
- numberOfComponents
891
- )
892
- });
893
- }
894
- }
895
- }
896
- return attributesInAllGeometries;
897
- }
898
- var tempScratch = new Cartesian3_default();
899
- function combineGeometries(instances, propertyName) {
900
- const length = instances.length;
901
- let name;
902
- let i;
903
- let j;
904
- let k;
905
- const m = instances[0].modelMatrix;
906
- const haveIndices = defined_default(instances[0][propertyName].indices);
907
- const primitiveType = instances[0][propertyName].primitiveType;
908
- for (i = 1; i < length; ++i) {
909
- if (!Matrix4_default.equals(instances[i].modelMatrix, m)) {
910
- throw new DeveloperError_default("All instances must have the same modelMatrix.");
911
- }
912
- if (defined_default(instances[i][propertyName].indices) !== haveIndices) {
913
- throw new DeveloperError_default(
914
- "All instance geometries must have an indices or not have one."
915
- );
916
- }
917
- if (instances[i][propertyName].primitiveType !== primitiveType) {
918
- throw new DeveloperError_default(
919
- "All instance geometries must have the same primitiveType."
920
- );
921
- }
922
- }
923
- const attributes = findAttributesInAllGeometries(instances, propertyName);
924
- let values;
925
- let sourceValues;
926
- let sourceValuesLength;
927
- for (name in attributes) {
928
- if (attributes.hasOwnProperty(name)) {
929
- values = attributes[name].values;
930
- k = 0;
931
- for (i = 0; i < length; ++i) {
932
- sourceValues = instances[i][propertyName].attributes[name].values;
933
- sourceValuesLength = sourceValues.length;
934
- for (j = 0; j < sourceValuesLength; ++j) {
935
- values[k++] = sourceValues[j];
936
- }
937
- }
938
- }
939
- }
940
- let indices;
941
- if (haveIndices) {
942
- let numberOfIndices = 0;
943
- for (i = 0; i < length; ++i) {
944
- numberOfIndices += instances[i][propertyName].indices.length;
945
- }
946
- const numberOfVertices = Geometry_default.computeNumberOfVertices(
947
- new Geometry_default({
948
- attributes,
949
- primitiveType: PrimitiveType_default.POINTS
950
- })
951
- );
952
- const destIndices = IndexDatatype_default.createTypedArray(
953
- numberOfVertices,
954
- numberOfIndices
955
- );
956
- let destOffset = 0;
957
- let offset = 0;
958
- for (i = 0; i < length; ++i) {
959
- const sourceIndices = instances[i][propertyName].indices;
960
- const sourceIndicesLen = sourceIndices.length;
961
- for (k = 0; k < sourceIndicesLen; ++k) {
962
- destIndices[destOffset++] = offset + sourceIndices[k];
963
- }
964
- offset += Geometry_default.computeNumberOfVertices(instances[i][propertyName]);
965
- }
966
- indices = destIndices;
967
- }
968
- let center = new Cartesian3_default();
969
- let radius = 0;
970
- let bs;
971
- for (i = 0; i < length; ++i) {
972
- bs = instances[i][propertyName].boundingSphere;
973
- if (!defined_default(bs)) {
974
- center = void 0;
975
- break;
976
- }
977
- Cartesian3_default.add(bs.center, center, center);
978
- }
979
- if (defined_default(center)) {
980
- Cartesian3_default.divideByScalar(center, length, center);
981
- for (i = 0; i < length; ++i) {
982
- bs = instances[i][propertyName].boundingSphere;
983
- const tempRadius = Cartesian3_default.magnitude(
984
- Cartesian3_default.subtract(bs.center, center, tempScratch)
985
- ) + bs.radius;
986
- if (tempRadius > radius) {
987
- radius = tempRadius;
988
- }
989
- }
990
- }
991
- return new Geometry_default({
992
- attributes,
993
- indices,
994
- primitiveType,
995
- boundingSphere: defined_default(center) ? new BoundingSphere_default(center, radius) : void 0
996
- });
997
- }
998
- GeometryPipeline.combineInstances = function(instances) {
999
- if (!defined_default(instances) || instances.length < 1) {
1000
- throw new DeveloperError_default(
1001
- "instances is required and must have length greater than zero."
1002
- );
1003
- }
1004
- const instanceGeometry = [];
1005
- const instanceSplitGeometry = [];
1006
- const length = instances.length;
1007
- for (let i = 0; i < length; ++i) {
1008
- const instance = instances[i];
1009
- if (defined_default(instance.geometry)) {
1010
- instanceGeometry.push(instance);
1011
- } else if (defined_default(instance.westHemisphereGeometry) && defined_default(instance.eastHemisphereGeometry)) {
1012
- instanceSplitGeometry.push(instance);
1013
- }
1014
- }
1015
- const geometries = [];
1016
- if (instanceGeometry.length > 0) {
1017
- geometries.push(combineGeometries(instanceGeometry, "geometry"));
1018
- }
1019
- if (instanceSplitGeometry.length > 0) {
1020
- geometries.push(
1021
- combineGeometries(instanceSplitGeometry, "westHemisphereGeometry")
1022
- );
1023
- geometries.push(
1024
- combineGeometries(instanceSplitGeometry, "eastHemisphereGeometry")
1025
- );
1026
- }
1027
- return geometries;
1028
- };
1029
- var normal = new Cartesian3_default();
1030
- var v0 = new Cartesian3_default();
1031
- var v1 = new Cartesian3_default();
1032
- var v2 = new Cartesian3_default();
1033
- GeometryPipeline.computeNormal = function(geometry) {
1034
- if (!defined_default(geometry)) {
1035
- throw new DeveloperError_default("geometry is required.");
1036
- }
1037
- if (!defined_default(geometry.attributes.position) || !defined_default(geometry.attributes.position.values)) {
1038
- throw new DeveloperError_default(
1039
- "geometry.attributes.position.values is required."
1040
- );
1041
- }
1042
- if (!defined_default(geometry.indices)) {
1043
- throw new DeveloperError_default("geometry.indices is required.");
1044
- }
1045
- if (geometry.indices.length < 2 || geometry.indices.length % 3 !== 0) {
1046
- throw new DeveloperError_default(
1047
- "geometry.indices length must be greater than 0 and be a multiple of 3."
1048
- );
1049
- }
1050
- if (geometry.primitiveType !== PrimitiveType_default.TRIANGLES) {
1051
- throw new DeveloperError_default(
1052
- "geometry.primitiveType must be PrimitiveType.TRIANGLES."
1053
- );
1054
- }
1055
- const indices = geometry.indices;
1056
- const attributes = geometry.attributes;
1057
- const vertices = attributes.position.values;
1058
- const numVertices = attributes.position.values.length / 3;
1059
- const numIndices = indices.length;
1060
- const normalsPerVertex = new Array(numVertices);
1061
- const normalsPerTriangle = new Array(numIndices / 3);
1062
- const normalIndices = new Array(numIndices);
1063
- let i;
1064
- for (i = 0; i < numVertices; i++) {
1065
- normalsPerVertex[i] = {
1066
- indexOffset: 0,
1067
- count: 0,
1068
- currentCount: 0
1069
- };
1070
- }
1071
- let j = 0;
1072
- for (i = 0; i < numIndices; i += 3) {
1073
- const i0 = indices[i];
1074
- const i1 = indices[i + 1];
1075
- const i2 = indices[i + 2];
1076
- const i03 = i0 * 3;
1077
- const i13 = i1 * 3;
1078
- const i23 = i2 * 3;
1079
- v0.x = vertices[i03];
1080
- v0.y = vertices[i03 + 1];
1081
- v0.z = vertices[i03 + 2];
1082
- v1.x = vertices[i13];
1083
- v1.y = vertices[i13 + 1];
1084
- v1.z = vertices[i13 + 2];
1085
- v2.x = vertices[i23];
1086
- v2.y = vertices[i23 + 1];
1087
- v2.z = vertices[i23 + 2];
1088
- normalsPerVertex[i0].count++;
1089
- normalsPerVertex[i1].count++;
1090
- normalsPerVertex[i2].count++;
1091
- Cartesian3_default.subtract(v1, v0, v1);
1092
- Cartesian3_default.subtract(v2, v0, v2);
1093
- normalsPerTriangle[j] = Cartesian3_default.cross(v1, v2, new Cartesian3_default());
1094
- j++;
1095
- }
1096
- let indexOffset = 0;
1097
- for (i = 0; i < numVertices; i++) {
1098
- normalsPerVertex[i].indexOffset += indexOffset;
1099
- indexOffset += normalsPerVertex[i].count;
1100
- }
1101
- j = 0;
1102
- let vertexNormalData;
1103
- for (i = 0; i < numIndices; i += 3) {
1104
- vertexNormalData = normalsPerVertex[indices[i]];
1105
- let index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1106
- normalIndices[index] = j;
1107
- vertexNormalData.currentCount++;
1108
- vertexNormalData = normalsPerVertex[indices[i + 1]];
1109
- index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1110
- normalIndices[index] = j;
1111
- vertexNormalData.currentCount++;
1112
- vertexNormalData = normalsPerVertex[indices[i + 2]];
1113
- index = vertexNormalData.indexOffset + vertexNormalData.currentCount;
1114
- normalIndices[index] = j;
1115
- vertexNormalData.currentCount++;
1116
- j++;
1117
- }
1118
- const normalValues = new Float32Array(numVertices * 3);
1119
- for (i = 0; i < numVertices; i++) {
1120
- const i3 = i * 3;
1121
- vertexNormalData = normalsPerVertex[i];
1122
- Cartesian3_default.clone(Cartesian3_default.ZERO, normal);
1123
- if (vertexNormalData.count > 0) {
1124
- for (j = 0; j < vertexNormalData.count; j++) {
1125
- Cartesian3_default.add(
1126
- normal,
1127
- normalsPerTriangle[normalIndices[vertexNormalData.indexOffset + j]],
1128
- normal
1129
- );
1130
- }
1131
- if (Cartesian3_default.equalsEpsilon(Cartesian3_default.ZERO, normal, Math_default.EPSILON10)) {
1132
- Cartesian3_default.clone(
1133
- normalsPerTriangle[normalIndices[vertexNormalData.indexOffset]],
1134
- normal
1135
- );
1136
- }
1137
- }
1138
- if (Cartesian3_default.equalsEpsilon(Cartesian3_default.ZERO, normal, Math_default.EPSILON10)) {
1139
- normal.z = 1;
1140
- }
1141
- Cartesian3_default.normalize(normal, normal);
1142
- normalValues[i3] = normal.x;
1143
- normalValues[i3 + 1] = normal.y;
1144
- normalValues[i3 + 2] = normal.z;
1145
- }
1146
- geometry.attributes.normal = new GeometryAttribute_default({
1147
- componentDatatype: ComponentDatatype_default.FLOAT,
1148
- componentsPerAttribute: 3,
1149
- values: normalValues
1150
- });
1151
- return geometry;
1152
- };
1153
- var normalScratch = new Cartesian3_default();
1154
- var normalScale = new Cartesian3_default();
1155
- var tScratch = new Cartesian3_default();
1156
- GeometryPipeline.computeTangentAndBitangent = function(geometry) {
1157
- if (!defined_default(geometry)) {
1158
- throw new DeveloperError_default("geometry is required.");
1159
- }
1160
- const attributes = geometry.attributes;
1161
- const indices = geometry.indices;
1162
- if (!defined_default(attributes.position) || !defined_default(attributes.position.values)) {
1163
- throw new DeveloperError_default(
1164
- "geometry.attributes.position.values is required."
1165
- );
1166
- }
1167
- if (!defined_default(attributes.normal) || !defined_default(attributes.normal.values)) {
1168
- throw new DeveloperError_default("geometry.attributes.normal.values is required.");
1169
- }
1170
- if (!defined_default(attributes.st) || !defined_default(attributes.st.values)) {
1171
- throw new DeveloperError_default("geometry.attributes.st.values is required.");
1172
- }
1173
- if (!defined_default(indices)) {
1174
- throw new DeveloperError_default("geometry.indices is required.");
1175
- }
1176
- if (indices.length < 2 || indices.length % 3 !== 0) {
1177
- throw new DeveloperError_default(
1178
- "geometry.indices length must be greater than 0 and be a multiple of 3."
1179
- );
1180
- }
1181
- if (geometry.primitiveType !== PrimitiveType_default.TRIANGLES) {
1182
- throw new DeveloperError_default(
1183
- "geometry.primitiveType must be PrimitiveType.TRIANGLES."
1184
- );
1185
- }
1186
- const vertices = geometry.attributes.position.values;
1187
- const normals = geometry.attributes.normal.values;
1188
- const st = geometry.attributes.st.values;
1189
- const numVertices = geometry.attributes.position.values.length / 3;
1190
- const numIndices = indices.length;
1191
- const tan1 = new Array(numVertices * 3);
1192
- let i;
1193
- for (i = 0; i < tan1.length; i++) {
1194
- tan1[i] = 0;
1195
- }
1196
- let i03;
1197
- let i13;
1198
- let i23;
1199
- for (i = 0; i < numIndices; i += 3) {
1200
- const i0 = indices[i];
1201
- const i1 = indices[i + 1];
1202
- const i2 = indices[i + 2];
1203
- i03 = i0 * 3;
1204
- i13 = i1 * 3;
1205
- i23 = i2 * 3;
1206
- const i02 = i0 * 2;
1207
- const i12 = i1 * 2;
1208
- const i22 = i2 * 2;
1209
- const ux = vertices[i03];
1210
- const uy = vertices[i03 + 1];
1211
- const uz = vertices[i03 + 2];
1212
- const wx = st[i02];
1213
- const wy = st[i02 + 1];
1214
- const t1 = st[i12 + 1] - wy;
1215
- const t2 = st[i22 + 1] - wy;
1216
- const r = 1 / ((st[i12] - wx) * t2 - (st[i22] - wx) * t1);
1217
- const sdirx = (t2 * (vertices[i13] - ux) - t1 * (vertices[i23] - ux)) * r;
1218
- const sdiry = (t2 * (vertices[i13 + 1] - uy) - t1 * (vertices[i23 + 1] - uy)) * r;
1219
- const sdirz = (t2 * (vertices[i13 + 2] - uz) - t1 * (vertices[i23 + 2] - uz)) * r;
1220
- tan1[i03] += sdirx;
1221
- tan1[i03 + 1] += sdiry;
1222
- tan1[i03 + 2] += sdirz;
1223
- tan1[i13] += sdirx;
1224
- tan1[i13 + 1] += sdiry;
1225
- tan1[i13 + 2] += sdirz;
1226
- tan1[i23] += sdirx;
1227
- tan1[i23 + 1] += sdiry;
1228
- tan1[i23 + 2] += sdirz;
1229
- }
1230
- const tangentValues = new Float32Array(numVertices * 3);
1231
- const bitangentValues = new Float32Array(numVertices * 3);
1232
- for (i = 0; i < numVertices; i++) {
1233
- i03 = i * 3;
1234
- i13 = i03 + 1;
1235
- i23 = i03 + 2;
1236
- const n = Cartesian3_default.fromArray(normals, i03, normalScratch);
1237
- const t = Cartesian3_default.fromArray(tan1, i03, tScratch);
1238
- const scalar = Cartesian3_default.dot(n, t);
1239
- Cartesian3_default.multiplyByScalar(n, scalar, normalScale);
1240
- Cartesian3_default.normalize(Cartesian3_default.subtract(t, normalScale, t), t);
1241
- tangentValues[i03] = t.x;
1242
- tangentValues[i13] = t.y;
1243
- tangentValues[i23] = t.z;
1244
- Cartesian3_default.normalize(Cartesian3_default.cross(n, t, t), t);
1245
- bitangentValues[i03] = t.x;
1246
- bitangentValues[i13] = t.y;
1247
- bitangentValues[i23] = t.z;
1248
- }
1249
- geometry.attributes.tangent = new GeometryAttribute_default({
1250
- componentDatatype: ComponentDatatype_default.FLOAT,
1251
- componentsPerAttribute: 3,
1252
- values: tangentValues
1253
- });
1254
- geometry.attributes.bitangent = new GeometryAttribute_default({
1255
- componentDatatype: ComponentDatatype_default.FLOAT,
1256
- componentsPerAttribute: 3,
1257
- values: bitangentValues
1258
- });
1259
- return geometry;
1260
- };
1261
- var scratchCartesian22 = new Cartesian2_default();
1262
- var toEncode1 = new Cartesian3_default();
1263
- var toEncode2 = new Cartesian3_default();
1264
- var toEncode3 = new Cartesian3_default();
1265
- var encodeResult2 = new Cartesian2_default();
1266
- GeometryPipeline.compressVertices = function(geometry) {
1267
- if (!defined_default(geometry)) {
1268
- throw new DeveloperError_default("geometry is required.");
1269
- }
1270
- const extrudeAttribute = geometry.attributes.extrudeDirection;
1271
- let i;
1272
- let numVertices;
1273
- if (defined_default(extrudeAttribute)) {
1274
- const extrudeDirections = extrudeAttribute.values;
1275
- numVertices = extrudeDirections.length / 3;
1276
- const compressedDirections = new Float32Array(numVertices * 2);
1277
- let i2 = 0;
1278
- for (i = 0; i < numVertices; ++i) {
1279
- Cartesian3_default.fromArray(extrudeDirections, i * 3, toEncode1);
1280
- if (Cartesian3_default.equals(toEncode1, Cartesian3_default.ZERO)) {
1281
- i2 += 2;
1282
- continue;
1283
- }
1284
- encodeResult2 = AttributeCompression_default.octEncodeInRange(
1285
- toEncode1,
1286
- 65535,
1287
- encodeResult2
1288
- );
1289
- compressedDirections[i2++] = encodeResult2.x;
1290
- compressedDirections[i2++] = encodeResult2.y;
1291
- }
1292
- geometry.attributes.compressedAttributes = new GeometryAttribute_default({
1293
- componentDatatype: ComponentDatatype_default.FLOAT,
1294
- componentsPerAttribute: 2,
1295
- values: compressedDirections
1296
- });
1297
- delete geometry.attributes.extrudeDirection;
1298
- return geometry;
1299
- }
1300
- const normalAttribute = geometry.attributes.normal;
1301
- const stAttribute = geometry.attributes.st;
1302
- const hasNormal = defined_default(normalAttribute);
1303
- const hasSt = defined_default(stAttribute);
1304
- if (!hasNormal && !hasSt) {
1305
- return geometry;
1306
- }
1307
- const tangentAttribute = geometry.attributes.tangent;
1308
- const bitangentAttribute = geometry.attributes.bitangent;
1309
- const hasTangent = defined_default(tangentAttribute);
1310
- const hasBitangent = defined_default(bitangentAttribute);
1311
- let normals;
1312
- let st;
1313
- let tangents;
1314
- let bitangents;
1315
- if (hasNormal) {
1316
- normals = normalAttribute.values;
1317
- }
1318
- if (hasSt) {
1319
- st = stAttribute.values;
1320
- }
1321
- if (hasTangent) {
1322
- tangents = tangentAttribute.values;
1323
- }
1324
- if (hasBitangent) {
1325
- bitangents = bitangentAttribute.values;
1326
- }
1327
- const length = hasNormal ? normals.length : st.length;
1328
- const numComponents = hasNormal ? 3 : 2;
1329
- numVertices = length / numComponents;
1330
- let compressedLength = numVertices;
1331
- let numCompressedComponents = hasSt && hasNormal ? 2 : 1;
1332
- numCompressedComponents += hasTangent || hasBitangent ? 1 : 0;
1333
- compressedLength *= numCompressedComponents;
1334
- const compressedAttributes = new Float32Array(compressedLength);
1335
- let normalIndex = 0;
1336
- for (i = 0; i < numVertices; ++i) {
1337
- if (hasSt) {
1338
- Cartesian2_default.fromArray(st, i * 2, scratchCartesian22);
1339
- compressedAttributes[normalIndex++] = AttributeCompression_default.compressTextureCoordinates(scratchCartesian22);
1340
- }
1341
- const index = i * 3;
1342
- if (hasNormal && defined_default(tangents) && defined_default(bitangents)) {
1343
- Cartesian3_default.fromArray(normals, index, toEncode1);
1344
- Cartesian3_default.fromArray(tangents, index, toEncode2);
1345
- Cartesian3_default.fromArray(bitangents, index, toEncode3);
1346
- AttributeCompression_default.octPack(
1347
- toEncode1,
1348
- toEncode2,
1349
- toEncode3,
1350
- scratchCartesian22
1351
- );
1352
- compressedAttributes[normalIndex++] = scratchCartesian22.x;
1353
- compressedAttributes[normalIndex++] = scratchCartesian22.y;
1354
- } else {
1355
- if (hasNormal) {
1356
- Cartesian3_default.fromArray(normals, index, toEncode1);
1357
- compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
1358
- }
1359
- if (hasTangent) {
1360
- Cartesian3_default.fromArray(tangents, index, toEncode1);
1361
- compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
1362
- }
1363
- if (hasBitangent) {
1364
- Cartesian3_default.fromArray(bitangents, index, toEncode1);
1365
- compressedAttributes[normalIndex++] = AttributeCompression_default.octEncodeFloat(toEncode1);
1366
- }
1367
- }
1368
- }
1369
- geometry.attributes.compressedAttributes = new GeometryAttribute_default({
1370
- componentDatatype: ComponentDatatype_default.FLOAT,
1371
- componentsPerAttribute: numCompressedComponents,
1372
- values: compressedAttributes
1373
- });
1374
- if (hasNormal) {
1375
- delete geometry.attributes.normal;
1376
- }
1377
- if (hasSt) {
1378
- delete geometry.attributes.st;
1379
- }
1380
- if (hasBitangent) {
1381
- delete geometry.attributes.bitangent;
1382
- }
1383
- if (hasTangent) {
1384
- delete geometry.attributes.tangent;
1385
- }
1386
- return geometry;
1387
- };
1388
- function indexTriangles(geometry) {
1389
- if (defined_default(geometry.indices)) {
1390
- return geometry;
1391
- }
1392
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1393
- if (numberOfVertices < 3) {
1394
- throw new DeveloperError_default("The number of vertices must be at least three.");
1395
- }
1396
- if (numberOfVertices % 3 !== 0) {
1397
- throw new DeveloperError_default(
1398
- "The number of vertices must be a multiple of three."
1399
- );
1400
- }
1401
- const indices = IndexDatatype_default.createTypedArray(
1402
- numberOfVertices,
1403
- numberOfVertices
1404
- );
1405
- for (let i = 0; i < numberOfVertices; ++i) {
1406
- indices[i] = i;
1407
- }
1408
- geometry.indices = indices;
1409
- return geometry;
1410
- }
1411
- function indexTriangleFan(geometry) {
1412
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1413
- if (numberOfVertices < 3) {
1414
- throw new DeveloperError_default("The number of vertices must be at least three.");
1415
- }
1416
- const indices = IndexDatatype_default.createTypedArray(
1417
- numberOfVertices,
1418
- (numberOfVertices - 2) * 3
1419
- );
1420
- indices[0] = 1;
1421
- indices[1] = 0;
1422
- indices[2] = 2;
1423
- let indicesIndex = 3;
1424
- for (let i = 3; i < numberOfVertices; ++i) {
1425
- indices[indicesIndex++] = i - 1;
1426
- indices[indicesIndex++] = 0;
1427
- indices[indicesIndex++] = i;
1428
- }
1429
- geometry.indices = indices;
1430
- geometry.primitiveType = PrimitiveType_default.TRIANGLES;
1431
- return geometry;
1432
- }
1433
- function indexTriangleStrip(geometry) {
1434
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1435
- if (numberOfVertices < 3) {
1436
- throw new DeveloperError_default("The number of vertices must be at least 3.");
1437
- }
1438
- const indices = IndexDatatype_default.createTypedArray(
1439
- numberOfVertices,
1440
- (numberOfVertices - 2) * 3
1441
- );
1442
- indices[0] = 0;
1443
- indices[1] = 1;
1444
- indices[2] = 2;
1445
- if (numberOfVertices > 3) {
1446
- indices[3] = 0;
1447
- indices[4] = 2;
1448
- indices[5] = 3;
1449
- }
1450
- let indicesIndex = 6;
1451
- for (let i = 3; i < numberOfVertices - 1; i += 2) {
1452
- indices[indicesIndex++] = i;
1453
- indices[indicesIndex++] = i - 1;
1454
- indices[indicesIndex++] = i + 1;
1455
- if (i + 2 < numberOfVertices) {
1456
- indices[indicesIndex++] = i;
1457
- indices[indicesIndex++] = i + 1;
1458
- indices[indicesIndex++] = i + 2;
1459
- }
1460
- }
1461
- geometry.indices = indices;
1462
- geometry.primitiveType = PrimitiveType_default.TRIANGLES;
1463
- return geometry;
1464
- }
1465
- function indexLines(geometry) {
1466
- if (defined_default(geometry.indices)) {
1467
- return geometry;
1468
- }
1469
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1470
- if (numberOfVertices < 2) {
1471
- throw new DeveloperError_default("The number of vertices must be at least two.");
1472
- }
1473
- if (numberOfVertices % 2 !== 0) {
1474
- throw new DeveloperError_default("The number of vertices must be a multiple of 2.");
1475
- }
1476
- const indices = IndexDatatype_default.createTypedArray(
1477
- numberOfVertices,
1478
- numberOfVertices
1479
- );
1480
- for (let i = 0; i < numberOfVertices; ++i) {
1481
- indices[i] = i;
1482
- }
1483
- geometry.indices = indices;
1484
- return geometry;
1485
- }
1486
- function indexLineStrip(geometry) {
1487
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1488
- if (numberOfVertices < 2) {
1489
- throw new DeveloperError_default("The number of vertices must be at least two.");
1490
- }
1491
- const indices = IndexDatatype_default.createTypedArray(
1492
- numberOfVertices,
1493
- (numberOfVertices - 1) * 2
1494
- );
1495
- indices[0] = 0;
1496
- indices[1] = 1;
1497
- let indicesIndex = 2;
1498
- for (let i = 2; i < numberOfVertices; ++i) {
1499
- indices[indicesIndex++] = i - 1;
1500
- indices[indicesIndex++] = i;
1501
- }
1502
- geometry.indices = indices;
1503
- geometry.primitiveType = PrimitiveType_default.LINES;
1504
- return geometry;
1505
- }
1506
- function indexLineLoop(geometry) {
1507
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1508
- if (numberOfVertices < 2) {
1509
- throw new DeveloperError_default("The number of vertices must be at least two.");
1510
- }
1511
- const indices = IndexDatatype_default.createTypedArray(
1512
- numberOfVertices,
1513
- numberOfVertices * 2
1514
- );
1515
- indices[0] = 0;
1516
- indices[1] = 1;
1517
- let indicesIndex = 2;
1518
- for (let i = 2; i < numberOfVertices; ++i) {
1519
- indices[indicesIndex++] = i - 1;
1520
- indices[indicesIndex++] = i;
1521
- }
1522
- indices[indicesIndex++] = numberOfVertices - 1;
1523
- indices[indicesIndex] = 0;
1524
- geometry.indices = indices;
1525
- geometry.primitiveType = PrimitiveType_default.LINES;
1526
- return geometry;
1527
- }
1528
- function indexPrimitive(geometry) {
1529
- switch (geometry.primitiveType) {
1530
- case PrimitiveType_default.TRIANGLE_FAN:
1531
- return indexTriangleFan(geometry);
1532
- case PrimitiveType_default.TRIANGLE_STRIP:
1533
- return indexTriangleStrip(geometry);
1534
- case PrimitiveType_default.TRIANGLES:
1535
- return indexTriangles(geometry);
1536
- case PrimitiveType_default.LINE_STRIP:
1537
- return indexLineStrip(geometry);
1538
- case PrimitiveType_default.LINE_LOOP:
1539
- return indexLineLoop(geometry);
1540
- case PrimitiveType_default.LINES:
1541
- return indexLines(geometry);
1542
- }
1543
- return geometry;
1544
- }
1545
- function offsetPointFromXZPlane(p, isBehind) {
1546
- if (Math.abs(p.y) < Math_default.EPSILON6) {
1547
- if (isBehind) {
1548
- p.y = -Math_default.EPSILON6;
1549
- } else {
1550
- p.y = Math_default.EPSILON6;
1551
- }
1552
- }
1553
- }
1554
- function offsetTriangleFromXZPlane(p0, p1, p2) {
1555
- if (p0.y !== 0 && p1.y !== 0 && p2.y !== 0) {
1556
- offsetPointFromXZPlane(p0, p0.y < 0);
1557
- offsetPointFromXZPlane(p1, p1.y < 0);
1558
- offsetPointFromXZPlane(p2, p2.y < 0);
1559
- return;
1560
- }
1561
- const p0y = Math.abs(p0.y);
1562
- const p1y = Math.abs(p1.y);
1563
- const p2y = Math.abs(p2.y);
1564
- let sign;
1565
- if (p0y > p1y) {
1566
- if (p0y > p2y) {
1567
- sign = Math_default.sign(p0.y);
1568
- } else {
1569
- sign = Math_default.sign(p2.y);
1570
- }
1571
- } else if (p1y > p2y) {
1572
- sign = Math_default.sign(p1.y);
1573
- } else {
1574
- sign = Math_default.sign(p2.y);
1575
- }
1576
- const isBehind = sign < 0;
1577
- offsetPointFromXZPlane(p0, isBehind);
1578
- offsetPointFromXZPlane(p1, isBehind);
1579
- offsetPointFromXZPlane(p2, isBehind);
1580
- }
1581
- var c3 = new Cartesian3_default();
1582
- function getXZIntersectionOffsetPoints(p, p1, u12, v12) {
1583
- Cartesian3_default.add(
1584
- p,
1585
- Cartesian3_default.multiplyByScalar(
1586
- Cartesian3_default.subtract(p1, p, c3),
1587
- p.y / (p.y - p1.y),
1588
- c3
1589
- ),
1590
- u12
1591
- );
1592
- Cartesian3_default.clone(u12, v12);
1593
- offsetPointFromXZPlane(u12, true);
1594
- offsetPointFromXZPlane(v12, false);
1595
- }
1596
- var u1 = new Cartesian3_default();
1597
- var u2 = new Cartesian3_default();
1598
- var q1 = new Cartesian3_default();
1599
- var q2 = new Cartesian3_default();
1600
- var splitTriangleResult = {
1601
- positions: new Array(7),
1602
- indices: new Array(3 * 3)
1603
- };
1604
- function splitTriangle(p0, p1, p2) {
1605
- if (p0.x >= 0 || p1.x >= 0 || p2.x >= 0) {
1606
- return void 0;
1607
- }
1608
- offsetTriangleFromXZPlane(p0, p1, p2);
1609
- const p0Behind = p0.y < 0;
1610
- const p1Behind = p1.y < 0;
1611
- const p2Behind = p2.y < 0;
1612
- let numBehind = 0;
1613
- numBehind += p0Behind ? 1 : 0;
1614
- numBehind += p1Behind ? 1 : 0;
1615
- numBehind += p2Behind ? 1 : 0;
1616
- const indices = splitTriangleResult.indices;
1617
- if (numBehind === 1) {
1618
- indices[1] = 3;
1619
- indices[2] = 4;
1620
- indices[5] = 6;
1621
- indices[7] = 6;
1622
- indices[8] = 5;
1623
- if (p0Behind) {
1624
- getXZIntersectionOffsetPoints(p0, p1, u1, q1);
1625
- getXZIntersectionOffsetPoints(p0, p2, u2, q2);
1626
- indices[0] = 0;
1627
- indices[3] = 1;
1628
- indices[4] = 2;
1629
- indices[6] = 1;
1630
- } else if (p1Behind) {
1631
- getXZIntersectionOffsetPoints(p1, p2, u1, q1);
1632
- getXZIntersectionOffsetPoints(p1, p0, u2, q2);
1633
- indices[0] = 1;
1634
- indices[3] = 2;
1635
- indices[4] = 0;
1636
- indices[6] = 2;
1637
- } else if (p2Behind) {
1638
- getXZIntersectionOffsetPoints(p2, p0, u1, q1);
1639
- getXZIntersectionOffsetPoints(p2, p1, u2, q2);
1640
- indices[0] = 2;
1641
- indices[3] = 0;
1642
- indices[4] = 1;
1643
- indices[6] = 0;
1644
- }
1645
- } else if (numBehind === 2) {
1646
- indices[2] = 4;
1647
- indices[4] = 4;
1648
- indices[5] = 3;
1649
- indices[7] = 5;
1650
- indices[8] = 6;
1651
- if (!p0Behind) {
1652
- getXZIntersectionOffsetPoints(p0, p1, u1, q1);
1653
- getXZIntersectionOffsetPoints(p0, p2, u2, q2);
1654
- indices[0] = 1;
1655
- indices[1] = 2;
1656
- indices[3] = 1;
1657
- indices[6] = 0;
1658
- } else if (!p1Behind) {
1659
- getXZIntersectionOffsetPoints(p1, p2, u1, q1);
1660
- getXZIntersectionOffsetPoints(p1, p0, u2, q2);
1661
- indices[0] = 2;
1662
- indices[1] = 0;
1663
- indices[3] = 2;
1664
- indices[6] = 1;
1665
- } else if (!p2Behind) {
1666
- getXZIntersectionOffsetPoints(p2, p0, u1, q1);
1667
- getXZIntersectionOffsetPoints(p2, p1, u2, q2);
1668
- indices[0] = 0;
1669
- indices[1] = 1;
1670
- indices[3] = 0;
1671
- indices[6] = 2;
1672
- }
1673
- }
1674
- const positions = splitTriangleResult.positions;
1675
- positions[0] = p0;
1676
- positions[1] = p1;
1677
- positions[2] = p2;
1678
- positions.length = 3;
1679
- if (numBehind === 1 || numBehind === 2) {
1680
- positions[3] = u1;
1681
- positions[4] = u2;
1682
- positions[5] = q1;
1683
- positions[6] = q2;
1684
- positions.length = 7;
1685
- }
1686
- return splitTriangleResult;
1687
- }
1688
- function updateGeometryAfterSplit(geometry, computeBoundingSphere) {
1689
- const attributes = geometry.attributes;
1690
- if (attributes.position.values.length === 0) {
1691
- return void 0;
1692
- }
1693
- for (const property in attributes) {
1694
- if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
1695
- const attribute = attributes[property];
1696
- attribute.values = ComponentDatatype_default.createTypedArray(
1697
- attribute.componentDatatype,
1698
- attribute.values
1699
- );
1700
- }
1701
- }
1702
- const numberOfVertices = Geometry_default.computeNumberOfVertices(geometry);
1703
- geometry.indices = IndexDatatype_default.createTypedArray(
1704
- numberOfVertices,
1705
- geometry.indices
1706
- );
1707
- if (computeBoundingSphere) {
1708
- geometry.boundingSphere = BoundingSphere_default.fromVertices(
1709
- attributes.position.values
1710
- );
1711
- }
1712
- return geometry;
1713
- }
1714
- function copyGeometryForSplit(geometry) {
1715
- const attributes = geometry.attributes;
1716
- const copiedAttributes = {};
1717
- for (const property in attributes) {
1718
- if (attributes.hasOwnProperty(property) && defined_default(attributes[property]) && defined_default(attributes[property].values)) {
1719
- const attribute = attributes[property];
1720
- copiedAttributes[property] = new GeometryAttribute_default({
1721
- componentDatatype: attribute.componentDatatype,
1722
- componentsPerAttribute: attribute.componentsPerAttribute,
1723
- normalize: attribute.normalize,
1724
- values: []
1725
- });
1726
- }
1727
- }
1728
- return new Geometry_default({
1729
- attributes: copiedAttributes,
1730
- indices: [],
1731
- primitiveType: geometry.primitiveType
1732
- });
1733
- }
1734
- function updateInstanceAfterSplit(instance, westGeometry, eastGeometry) {
1735
- const computeBoundingSphere = defined_default(instance.geometry.boundingSphere);
1736
- westGeometry = updateGeometryAfterSplit(westGeometry, computeBoundingSphere);
1737
- eastGeometry = updateGeometryAfterSplit(eastGeometry, computeBoundingSphere);
1738
- if (defined_default(eastGeometry) && !defined_default(westGeometry)) {
1739
- instance.geometry = eastGeometry;
1740
- } else if (!defined_default(eastGeometry) && defined_default(westGeometry)) {
1741
- instance.geometry = westGeometry;
1742
- } else {
1743
- instance.westHemisphereGeometry = westGeometry;
1744
- instance.eastHemisphereGeometry = eastGeometry;
1745
- instance.geometry = void 0;
1746
- }
1747
- }
1748
- function generateBarycentricInterpolateFunction(CartesianType, numberOfComponents) {
1749
- const v0Scratch = new CartesianType();
1750
- const v1Scratch = new CartesianType();
1751
- const v2Scratch = new CartesianType();
1752
- return function(i0, i1, i2, coords, sourceValues, currentValues, insertedIndex, normalize) {
1753
- const v02 = CartesianType.fromArray(
1754
- sourceValues,
1755
- i0 * numberOfComponents,
1756
- v0Scratch
1757
- );
1758
- const v12 = CartesianType.fromArray(
1759
- sourceValues,
1760
- i1 * numberOfComponents,
1761
- v1Scratch
1762
- );
1763
- const v22 = CartesianType.fromArray(
1764
- sourceValues,
1765
- i2 * numberOfComponents,
1766
- v2Scratch
1767
- );
1768
- CartesianType.multiplyByScalar(v02, coords.x, v02);
1769
- CartesianType.multiplyByScalar(v12, coords.y, v12);
1770
- CartesianType.multiplyByScalar(v22, coords.z, v22);
1771
- const value = CartesianType.add(v02, v12, v02);
1772
- CartesianType.add(value, v22, value);
1773
- if (normalize) {
1774
- CartesianType.normalize(value, value);
1775
- }
1776
- CartesianType.pack(
1777
- value,
1778
- currentValues,
1779
- insertedIndex * numberOfComponents
1780
- );
1781
- };
1782
- }
1783
- var interpolateAndPackCartesian4 = generateBarycentricInterpolateFunction(
1784
- Cartesian4_default,
1785
- 4
1786
- );
1787
- var interpolateAndPackCartesian3 = generateBarycentricInterpolateFunction(
1788
- Cartesian3_default,
1789
- 3
1790
- );
1791
- var interpolateAndPackCartesian2 = generateBarycentricInterpolateFunction(
1792
- Cartesian2_default,
1793
- 2
1794
- );
1795
- var interpolateAndPackBoolean = function(i0, i1, i2, coords, sourceValues, currentValues, insertedIndex) {
1796
- const v12 = sourceValues[i0] * coords.x;
1797
- const v22 = sourceValues[i1] * coords.y;
1798
- const v3 = sourceValues[i2] * coords.z;
1799
- currentValues[insertedIndex] = v12 + v22 + v3 > Math_default.EPSILON6 ? 1 : 0;
1800
- };
1801
- var p0Scratch = new Cartesian3_default();
1802
- var p1Scratch = new Cartesian3_default();
1803
- var p2Scratch = new Cartesian3_default();
1804
- var barycentricScratch = new Cartesian3_default();
1805
- function computeTriangleAttributes(i0, i1, i2, point, positions, normals, tangents, bitangents, texCoords, extrudeDirections, applyOffset, currentAttributes, customAttributeNames, customAttributesLength, allAttributes, insertedIndex) {
1806
- if (!defined_default(normals) && !defined_default(tangents) && !defined_default(bitangents) && !defined_default(texCoords) && !defined_default(extrudeDirections) && customAttributesLength === 0) {
1807
- return;
1808
- }
1809
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
1810
- const p1 = Cartesian3_default.fromArray(positions, i1 * 3, p1Scratch);
1811
- const p2 = Cartesian3_default.fromArray(positions, i2 * 3, p2Scratch);
1812
- const coords = barycentricCoordinates_default(point, p0, p1, p2, barycentricScratch);
1813
- if (!defined_default(coords)) {
1814
- return;
1815
- }
1816
- if (defined_default(normals)) {
1817
- interpolateAndPackCartesian3(
1818
- i0,
1819
- i1,
1820
- i2,
1821
- coords,
1822
- normals,
1823
- currentAttributes.normal.values,
1824
- insertedIndex,
1825
- true
1826
- );
1827
- }
1828
- if (defined_default(extrudeDirections)) {
1829
- const d0 = Cartesian3_default.fromArray(extrudeDirections, i0 * 3, p0Scratch);
1830
- const d1 = Cartesian3_default.fromArray(extrudeDirections, i1 * 3, p1Scratch);
1831
- const d2 = Cartesian3_default.fromArray(extrudeDirections, i2 * 3, p2Scratch);
1832
- Cartesian3_default.multiplyByScalar(d0, coords.x, d0);
1833
- Cartesian3_default.multiplyByScalar(d1, coords.y, d1);
1834
- Cartesian3_default.multiplyByScalar(d2, coords.z, d2);
1835
- let direction;
1836
- if (!Cartesian3_default.equals(d0, Cartesian3_default.ZERO) || !Cartesian3_default.equals(d1, Cartesian3_default.ZERO) || !Cartesian3_default.equals(d2, Cartesian3_default.ZERO)) {
1837
- direction = Cartesian3_default.add(d0, d1, d0);
1838
- Cartesian3_default.add(direction, d2, direction);
1839
- Cartesian3_default.normalize(direction, direction);
1840
- } else {
1841
- direction = p0Scratch;
1842
- direction.x = 0;
1843
- direction.y = 0;
1844
- direction.z = 0;
1845
- }
1846
- Cartesian3_default.pack(
1847
- direction,
1848
- currentAttributes.extrudeDirection.values,
1849
- insertedIndex * 3
1850
- );
1851
- }
1852
- if (defined_default(applyOffset)) {
1853
- interpolateAndPackBoolean(
1854
- i0,
1855
- i1,
1856
- i2,
1857
- coords,
1858
- applyOffset,
1859
- currentAttributes.applyOffset.values,
1860
- insertedIndex
1861
- );
1862
- }
1863
- if (defined_default(tangents)) {
1864
- interpolateAndPackCartesian3(
1865
- i0,
1866
- i1,
1867
- i2,
1868
- coords,
1869
- tangents,
1870
- currentAttributes.tangent.values,
1871
- insertedIndex,
1872
- true
1873
- );
1874
- }
1875
- if (defined_default(bitangents)) {
1876
- interpolateAndPackCartesian3(
1877
- i0,
1878
- i1,
1879
- i2,
1880
- coords,
1881
- bitangents,
1882
- currentAttributes.bitangent.values,
1883
- insertedIndex,
1884
- true
1885
- );
1886
- }
1887
- if (defined_default(texCoords)) {
1888
- interpolateAndPackCartesian2(
1889
- i0,
1890
- i1,
1891
- i2,
1892
- coords,
1893
- texCoords,
1894
- currentAttributes.st.values,
1895
- insertedIndex
1896
- );
1897
- }
1898
- if (customAttributesLength > 0) {
1899
- for (let i = 0; i < customAttributesLength; i++) {
1900
- const attributeName = customAttributeNames[i];
1901
- genericInterpolate(
1902
- i0,
1903
- i1,
1904
- i2,
1905
- coords,
1906
- insertedIndex,
1907
- allAttributes[attributeName],
1908
- currentAttributes[attributeName]
1909
- );
1910
- }
1911
- }
1912
- }
1913
- function genericInterpolate(i0, i1, i2, coords, insertedIndex, sourceAttribute, currentAttribute) {
1914
- const componentsPerAttribute = sourceAttribute.componentsPerAttribute;
1915
- const sourceValues = sourceAttribute.values;
1916
- const currentValues = currentAttribute.values;
1917
- switch (componentsPerAttribute) {
1918
- case 4:
1919
- interpolateAndPackCartesian4(
1920
- i0,
1921
- i1,
1922
- i2,
1923
- coords,
1924
- sourceValues,
1925
- currentValues,
1926
- insertedIndex,
1927
- false
1928
- );
1929
- break;
1930
- case 3:
1931
- interpolateAndPackCartesian3(
1932
- i0,
1933
- i1,
1934
- i2,
1935
- coords,
1936
- sourceValues,
1937
- currentValues,
1938
- insertedIndex,
1939
- false
1940
- );
1941
- break;
1942
- case 2:
1943
- interpolateAndPackCartesian2(
1944
- i0,
1945
- i1,
1946
- i2,
1947
- coords,
1948
- sourceValues,
1949
- currentValues,
1950
- insertedIndex,
1951
- false
1952
- );
1953
- break;
1954
- default:
1955
- currentValues[insertedIndex] = sourceValues[i0] * coords.x + sourceValues[i1] * coords.y + sourceValues[i2] * coords.z;
1956
- }
1957
- }
1958
- function insertSplitPoint(currentAttributes, currentIndices, currentIndexMap, indices, currentIndex, point) {
1959
- const insertIndex = currentAttributes.position.values.length / 3;
1960
- if (currentIndex !== -1) {
1961
- const prevIndex = indices[currentIndex];
1962
- const newIndex = currentIndexMap[prevIndex];
1963
- if (newIndex === -1) {
1964
- currentIndexMap[prevIndex] = insertIndex;
1965
- currentAttributes.position.values.push(point.x, point.y, point.z);
1966
- currentIndices.push(insertIndex);
1967
- return insertIndex;
1968
- }
1969
- currentIndices.push(newIndex);
1970
- return newIndex;
1971
- }
1972
- currentAttributes.position.values.push(point.x, point.y, point.z);
1973
- currentIndices.push(insertIndex);
1974
- return insertIndex;
1975
- }
1976
- var NAMED_ATTRIBUTES = {
1977
- position: true,
1978
- normal: true,
1979
- bitangent: true,
1980
- tangent: true,
1981
- st: true,
1982
- extrudeDirection: true,
1983
- applyOffset: true
1984
- };
1985
- function splitLongitudeTriangles(instance) {
1986
- const geometry = instance.geometry;
1987
- const attributes = geometry.attributes;
1988
- const positions = attributes.position.values;
1989
- const normals = defined_default(attributes.normal) ? attributes.normal.values : void 0;
1990
- const bitangents = defined_default(attributes.bitangent) ? attributes.bitangent.values : void 0;
1991
- const tangents = defined_default(attributes.tangent) ? attributes.tangent.values : void 0;
1992
- const texCoords = defined_default(attributes.st) ? attributes.st.values : void 0;
1993
- const extrudeDirections = defined_default(attributes.extrudeDirection) ? attributes.extrudeDirection.values : void 0;
1994
- const applyOffset = defined_default(attributes.applyOffset) ? attributes.applyOffset.values : void 0;
1995
- const indices = geometry.indices;
1996
- const customAttributeNames = [];
1997
- for (const attributeName in attributes) {
1998
- if (attributes.hasOwnProperty(attributeName) && !NAMED_ATTRIBUTES[attributeName] && defined_default(attributes[attributeName])) {
1999
- customAttributeNames.push(attributeName);
2000
- }
2001
- }
2002
- const customAttributesLength = customAttributeNames.length;
2003
- const eastGeometry = copyGeometryForSplit(geometry);
2004
- const westGeometry = copyGeometryForSplit(geometry);
2005
- let currentAttributes;
2006
- let currentIndices;
2007
- let currentIndexMap;
2008
- let insertedIndex;
2009
- let i;
2010
- const westGeometryIndexMap = [];
2011
- westGeometryIndexMap.length = positions.length / 3;
2012
- const eastGeometryIndexMap = [];
2013
- eastGeometryIndexMap.length = positions.length / 3;
2014
- for (i = 0; i < westGeometryIndexMap.length; ++i) {
2015
- westGeometryIndexMap[i] = -1;
2016
- eastGeometryIndexMap[i] = -1;
2017
- }
2018
- const len = indices.length;
2019
- for (i = 0; i < len; i += 3) {
2020
- const i0 = indices[i];
2021
- const i1 = indices[i + 1];
2022
- const i2 = indices[i + 2];
2023
- let p0 = Cartesian3_default.fromArray(positions, i0 * 3);
2024
- let p1 = Cartesian3_default.fromArray(positions, i1 * 3);
2025
- let p2 = Cartesian3_default.fromArray(positions, i2 * 3);
2026
- const result = splitTriangle(p0, p1, p2);
2027
- if (defined_default(result) && result.positions.length > 3) {
2028
- const resultPositions = result.positions;
2029
- const resultIndices = result.indices;
2030
- const resultLength = resultIndices.length;
2031
- for (let j = 0; j < resultLength; ++j) {
2032
- const resultIndex = resultIndices[j];
2033
- const point = resultPositions[resultIndex];
2034
- if (point.y < 0) {
2035
- currentAttributes = westGeometry.attributes;
2036
- currentIndices = westGeometry.indices;
2037
- currentIndexMap = westGeometryIndexMap;
2038
- } else {
2039
- currentAttributes = eastGeometry.attributes;
2040
- currentIndices = eastGeometry.indices;
2041
- currentIndexMap = eastGeometryIndexMap;
2042
- }
2043
- insertedIndex = insertSplitPoint(
2044
- currentAttributes,
2045
- currentIndices,
2046
- currentIndexMap,
2047
- indices,
2048
- resultIndex < 3 ? i + resultIndex : -1,
2049
- point
2050
- );
2051
- computeTriangleAttributes(
2052
- i0,
2053
- i1,
2054
- i2,
2055
- point,
2056
- positions,
2057
- normals,
2058
- tangents,
2059
- bitangents,
2060
- texCoords,
2061
- extrudeDirections,
2062
- applyOffset,
2063
- currentAttributes,
2064
- customAttributeNames,
2065
- customAttributesLength,
2066
- attributes,
2067
- insertedIndex
2068
- );
2069
- }
2070
- } else {
2071
- if (defined_default(result)) {
2072
- p0 = result.positions[0];
2073
- p1 = result.positions[1];
2074
- p2 = result.positions[2];
2075
- }
2076
- if (p0.y < 0) {
2077
- currentAttributes = westGeometry.attributes;
2078
- currentIndices = westGeometry.indices;
2079
- currentIndexMap = westGeometryIndexMap;
2080
- } else {
2081
- currentAttributes = eastGeometry.attributes;
2082
- currentIndices = eastGeometry.indices;
2083
- currentIndexMap = eastGeometryIndexMap;
2084
- }
2085
- insertedIndex = insertSplitPoint(
2086
- currentAttributes,
2087
- currentIndices,
2088
- currentIndexMap,
2089
- indices,
2090
- i,
2091
- p0
2092
- );
2093
- computeTriangleAttributes(
2094
- i0,
2095
- i1,
2096
- i2,
2097
- p0,
2098
- positions,
2099
- normals,
2100
- tangents,
2101
- bitangents,
2102
- texCoords,
2103
- extrudeDirections,
2104
- applyOffset,
2105
- currentAttributes,
2106
- customAttributeNames,
2107
- customAttributesLength,
2108
- attributes,
2109
- insertedIndex
2110
- );
2111
- insertedIndex = insertSplitPoint(
2112
- currentAttributes,
2113
- currentIndices,
2114
- currentIndexMap,
2115
- indices,
2116
- i + 1,
2117
- p1
2118
- );
2119
- computeTriangleAttributes(
2120
- i0,
2121
- i1,
2122
- i2,
2123
- p1,
2124
- positions,
2125
- normals,
2126
- tangents,
2127
- bitangents,
2128
- texCoords,
2129
- extrudeDirections,
2130
- applyOffset,
2131
- currentAttributes,
2132
- customAttributeNames,
2133
- customAttributesLength,
2134
- attributes,
2135
- insertedIndex
2136
- );
2137
- insertedIndex = insertSplitPoint(
2138
- currentAttributes,
2139
- currentIndices,
2140
- currentIndexMap,
2141
- indices,
2142
- i + 2,
2143
- p2
2144
- );
2145
- computeTriangleAttributes(
2146
- i0,
2147
- i1,
2148
- i2,
2149
- p2,
2150
- positions,
2151
- normals,
2152
- tangents,
2153
- bitangents,
2154
- texCoords,
2155
- extrudeDirections,
2156
- applyOffset,
2157
- currentAttributes,
2158
- customAttributeNames,
2159
- customAttributesLength,
2160
- attributes,
2161
- insertedIndex
2162
- );
2163
- }
2164
- }
2165
- updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
2166
- }
2167
- var xzPlane = Plane_default.fromPointNormal(Cartesian3_default.ZERO, Cartesian3_default.UNIT_Y);
2168
- var offsetScratch = new Cartesian3_default();
2169
- var offsetPointScratch = new Cartesian3_default();
2170
- function computeLineAttributes(i0, i1, point, positions, insertIndex, currentAttributes, applyOffset) {
2171
- if (!defined_default(applyOffset)) {
2172
- return;
2173
- }
2174
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
2175
- if (Cartesian3_default.equalsEpsilon(p0, point, Math_default.EPSILON10)) {
2176
- currentAttributes.applyOffset.values[insertIndex] = applyOffset[i0];
2177
- } else {
2178
- currentAttributes.applyOffset.values[insertIndex] = applyOffset[i1];
2179
- }
2180
- }
2181
- function splitLongitudeLines(instance) {
2182
- const geometry = instance.geometry;
2183
- const attributes = geometry.attributes;
2184
- const positions = attributes.position.values;
2185
- const applyOffset = defined_default(attributes.applyOffset) ? attributes.applyOffset.values : void 0;
2186
- const indices = geometry.indices;
2187
- const eastGeometry = copyGeometryForSplit(geometry);
2188
- const westGeometry = copyGeometryForSplit(geometry);
2189
- let i;
2190
- const length = indices.length;
2191
- const westGeometryIndexMap = [];
2192
- westGeometryIndexMap.length = positions.length / 3;
2193
- const eastGeometryIndexMap = [];
2194
- eastGeometryIndexMap.length = positions.length / 3;
2195
- for (i = 0; i < westGeometryIndexMap.length; ++i) {
2196
- westGeometryIndexMap[i] = -1;
2197
- eastGeometryIndexMap[i] = -1;
2198
- }
2199
- for (i = 0; i < length; i += 2) {
2200
- const i0 = indices[i];
2201
- const i1 = indices[i + 1];
2202
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, p0Scratch);
2203
- const p1 = Cartesian3_default.fromArray(positions, i1 * 3, p1Scratch);
2204
- let insertIndex;
2205
- if (Math.abs(p0.y) < Math_default.EPSILON6) {
2206
- if (p0.y < 0) {
2207
- p0.y = -Math_default.EPSILON6;
2208
- } else {
2209
- p0.y = Math_default.EPSILON6;
2210
- }
2211
- }
2212
- if (Math.abs(p1.y) < Math_default.EPSILON6) {
2213
- if (p1.y < 0) {
2214
- p1.y = -Math_default.EPSILON6;
2215
- } else {
2216
- p1.y = Math_default.EPSILON6;
2217
- }
2218
- }
2219
- let p0Attributes = eastGeometry.attributes;
2220
- let p0Indices = eastGeometry.indices;
2221
- let p0IndexMap = eastGeometryIndexMap;
2222
- let p1Attributes = westGeometry.attributes;
2223
- let p1Indices = westGeometry.indices;
2224
- let p1IndexMap = westGeometryIndexMap;
2225
- const intersection = IntersectionTests_default.lineSegmentPlane(
2226
- p0,
2227
- p1,
2228
- xzPlane,
2229
- p2Scratch
2230
- );
2231
- if (defined_default(intersection)) {
2232
- const offset = Cartesian3_default.multiplyByScalar(
2233
- Cartesian3_default.UNIT_Y,
2234
- 5 * Math_default.EPSILON9,
2235
- offsetScratch
2236
- );
2237
- if (p0.y < 0) {
2238
- Cartesian3_default.negate(offset, offset);
2239
- p0Attributes = westGeometry.attributes;
2240
- p0Indices = westGeometry.indices;
2241
- p0IndexMap = westGeometryIndexMap;
2242
- p1Attributes = eastGeometry.attributes;
2243
- p1Indices = eastGeometry.indices;
2244
- p1IndexMap = eastGeometryIndexMap;
2245
- }
2246
- const offsetPoint = Cartesian3_default.add(
2247
- intersection,
2248
- offset,
2249
- offsetPointScratch
2250
- );
2251
- insertIndex = insertSplitPoint(
2252
- p0Attributes,
2253
- p0Indices,
2254
- p0IndexMap,
2255
- indices,
2256
- i,
2257
- p0
2258
- );
2259
- computeLineAttributes(
2260
- i0,
2261
- i1,
2262
- p0,
2263
- positions,
2264
- insertIndex,
2265
- p0Attributes,
2266
- applyOffset
2267
- );
2268
- insertIndex = insertSplitPoint(
2269
- p0Attributes,
2270
- p0Indices,
2271
- p0IndexMap,
2272
- indices,
2273
- -1,
2274
- offsetPoint
2275
- );
2276
- computeLineAttributes(
2277
- i0,
2278
- i1,
2279
- offsetPoint,
2280
- positions,
2281
- insertIndex,
2282
- p0Attributes,
2283
- applyOffset
2284
- );
2285
- Cartesian3_default.negate(offset, offset);
2286
- Cartesian3_default.add(intersection, offset, offsetPoint);
2287
- insertIndex = insertSplitPoint(
2288
- p1Attributes,
2289
- p1Indices,
2290
- p1IndexMap,
2291
- indices,
2292
- -1,
2293
- offsetPoint
2294
- );
2295
- computeLineAttributes(
2296
- i0,
2297
- i1,
2298
- offsetPoint,
2299
- positions,
2300
- insertIndex,
2301
- p1Attributes,
2302
- applyOffset
2303
- );
2304
- insertIndex = insertSplitPoint(
2305
- p1Attributes,
2306
- p1Indices,
2307
- p1IndexMap,
2308
- indices,
2309
- i + 1,
2310
- p1
2311
- );
2312
- computeLineAttributes(
2313
- i0,
2314
- i1,
2315
- p1,
2316
- positions,
2317
- insertIndex,
2318
- p1Attributes,
2319
- applyOffset
2320
- );
2321
- } else {
2322
- let currentAttributes;
2323
- let currentIndices;
2324
- let currentIndexMap;
2325
- if (p0.y < 0) {
2326
- currentAttributes = westGeometry.attributes;
2327
- currentIndices = westGeometry.indices;
2328
- currentIndexMap = westGeometryIndexMap;
2329
- } else {
2330
- currentAttributes = eastGeometry.attributes;
2331
- currentIndices = eastGeometry.indices;
2332
- currentIndexMap = eastGeometryIndexMap;
2333
- }
2334
- insertIndex = insertSplitPoint(
2335
- currentAttributes,
2336
- currentIndices,
2337
- currentIndexMap,
2338
- indices,
2339
- i,
2340
- p0
2341
- );
2342
- computeLineAttributes(
2343
- i0,
2344
- i1,
2345
- p0,
2346
- positions,
2347
- insertIndex,
2348
- currentAttributes,
2349
- applyOffset
2350
- );
2351
- insertIndex = insertSplitPoint(
2352
- currentAttributes,
2353
- currentIndices,
2354
- currentIndexMap,
2355
- indices,
2356
- i + 1,
2357
- p1
2358
- );
2359
- computeLineAttributes(
2360
- i0,
2361
- i1,
2362
- p1,
2363
- positions,
2364
- insertIndex,
2365
- currentAttributes,
2366
- applyOffset
2367
- );
2368
- }
2369
- }
2370
- updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
2371
- }
2372
- var cartesian2Scratch0 = new Cartesian2_default();
2373
- var cartesian2Scratch1 = new Cartesian2_default();
2374
- var cartesian3Scratch0 = new Cartesian3_default();
2375
- var cartesian3Scratch2 = new Cartesian3_default();
2376
- var cartesian3Scratch3 = new Cartesian3_default();
2377
- var cartesian3Scratch4 = new Cartesian3_default();
2378
- var cartesian3Scratch5 = new Cartesian3_default();
2379
- var cartesian3Scratch6 = new Cartesian3_default();
2380
- var cartesian4Scratch0 = new Cartesian4_default();
2381
- function updateAdjacencyAfterSplit(geometry) {
2382
- const attributes = geometry.attributes;
2383
- const positions = attributes.position.values;
2384
- const prevPositions = attributes.prevPosition.values;
2385
- const nextPositions = attributes.nextPosition.values;
2386
- const length = positions.length;
2387
- for (let j = 0; j < length; j += 3) {
2388
- const position = Cartesian3_default.unpack(positions, j, cartesian3Scratch0);
2389
- if (position.x > 0) {
2390
- continue;
2391
- }
2392
- const prevPosition = Cartesian3_default.unpack(
2393
- prevPositions,
2394
- j,
2395
- cartesian3Scratch2
2396
- );
2397
- if (position.y < 0 && prevPosition.y > 0 || position.y > 0 && prevPosition.y < 0) {
2398
- if (j - 3 > 0) {
2399
- prevPositions[j] = positions[j - 3];
2400
- prevPositions[j + 1] = positions[j - 2];
2401
- prevPositions[j + 2] = positions[j - 1];
2402
- } else {
2403
- Cartesian3_default.pack(position, prevPositions, j);
2404
- }
2405
- }
2406
- const nextPosition = Cartesian3_default.unpack(
2407
- nextPositions,
2408
- j,
2409
- cartesian3Scratch3
2410
- );
2411
- if (position.y < 0 && nextPosition.y > 0 || position.y > 0 && nextPosition.y < 0) {
2412
- if (j + 3 < length) {
2413
- nextPositions[j] = positions[j + 3];
2414
- nextPositions[j + 1] = positions[j + 4];
2415
- nextPositions[j + 2] = positions[j + 5];
2416
- } else {
2417
- Cartesian3_default.pack(position, nextPositions, j);
2418
- }
2419
- }
2420
- }
2421
- }
2422
- var offsetScalar = 5 * Math_default.EPSILON9;
2423
- var coplanarOffset = Math_default.EPSILON6;
2424
- function splitLongitudePolyline(instance) {
2425
- const geometry = instance.geometry;
2426
- const attributes = geometry.attributes;
2427
- const positions = attributes.position.values;
2428
- const prevPositions = attributes.prevPosition.values;
2429
- const nextPositions = attributes.nextPosition.values;
2430
- const expandAndWidths = attributes.expandAndWidth.values;
2431
- const texCoords = defined_default(attributes.st) ? attributes.st.values : void 0;
2432
- const colors = defined_default(attributes.color) ? attributes.color.values : void 0;
2433
- const eastGeometry = copyGeometryForSplit(geometry);
2434
- const westGeometry = copyGeometryForSplit(geometry);
2435
- let i;
2436
- let j;
2437
- let index;
2438
- let intersectionFound = false;
2439
- const length = positions.length / 3;
2440
- for (i = 0; i < length; i += 4) {
2441
- const i0 = i;
2442
- const i2 = i + 2;
2443
- const p0 = Cartesian3_default.fromArray(positions, i0 * 3, cartesian3Scratch0);
2444
- const p2 = Cartesian3_default.fromArray(positions, i2 * 3, cartesian3Scratch2);
2445
- if (Math.abs(p0.y) < coplanarOffset) {
2446
- p0.y = coplanarOffset * (p2.y < 0 ? -1 : 1);
2447
- positions[i * 3 + 1] = p0.y;
2448
- positions[(i + 1) * 3 + 1] = p0.y;
2449
- for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
2450
- prevPositions[j] = positions[i * 3];
2451
- prevPositions[j + 1] = positions[i * 3 + 1];
2452
- prevPositions[j + 2] = positions[i * 3 + 2];
2453
- }
2454
- }
2455
- if (Math.abs(p2.y) < coplanarOffset) {
2456
- p2.y = coplanarOffset * (p0.y < 0 ? -1 : 1);
2457
- positions[(i + 2) * 3 + 1] = p2.y;
2458
- positions[(i + 3) * 3 + 1] = p2.y;
2459
- for (j = i0 * 3; j < i0 * 3 + 4 * 3; j += 3) {
2460
- nextPositions[j] = positions[(i + 2) * 3];
2461
- nextPositions[j + 1] = positions[(i + 2) * 3 + 1];
2462
- nextPositions[j + 2] = positions[(i + 2) * 3 + 2];
2463
- }
2464
- }
2465
- let p0Attributes = eastGeometry.attributes;
2466
- let p0Indices = eastGeometry.indices;
2467
- let p2Attributes = westGeometry.attributes;
2468
- let p2Indices = westGeometry.indices;
2469
- const intersection = IntersectionTests_default.lineSegmentPlane(
2470
- p0,
2471
- p2,
2472
- xzPlane,
2473
- cartesian3Scratch4
2474
- );
2475
- if (defined_default(intersection)) {
2476
- intersectionFound = true;
2477
- const offset = Cartesian3_default.multiplyByScalar(
2478
- Cartesian3_default.UNIT_Y,
2479
- offsetScalar,
2480
- cartesian3Scratch5
2481
- );
2482
- if (p0.y < 0) {
2483
- Cartesian3_default.negate(offset, offset);
2484
- p0Attributes = westGeometry.attributes;
2485
- p0Indices = westGeometry.indices;
2486
- p2Attributes = eastGeometry.attributes;
2487
- p2Indices = eastGeometry.indices;
2488
- }
2489
- const offsetPoint = Cartesian3_default.add(
2490
- intersection,
2491
- offset,
2492
- cartesian3Scratch6
2493
- );
2494
- p0Attributes.position.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
2495
- p0Attributes.position.values.push(
2496
- offsetPoint.x,
2497
- offsetPoint.y,
2498
- offsetPoint.z
2499
- );
2500
- p0Attributes.position.values.push(
2501
- offsetPoint.x,
2502
- offsetPoint.y,
2503
- offsetPoint.z
2504
- );
2505
- p0Attributes.prevPosition.values.push(
2506
- prevPositions[i0 * 3],
2507
- prevPositions[i0 * 3 + 1],
2508
- prevPositions[i0 * 3 + 2]
2509
- );
2510
- p0Attributes.prevPosition.values.push(
2511
- prevPositions[i0 * 3 + 3],
2512
- prevPositions[i0 * 3 + 4],
2513
- prevPositions[i0 * 3 + 5]
2514
- );
2515
- p0Attributes.prevPosition.values.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z);
2516
- p0Attributes.nextPosition.values.push(
2517
- offsetPoint.x,
2518
- offsetPoint.y,
2519
- offsetPoint.z
2520
- );
2521
- p0Attributes.nextPosition.values.push(
2522
- offsetPoint.x,
2523
- offsetPoint.y,
2524
- offsetPoint.z
2525
- );
2526
- p0Attributes.nextPosition.values.push(
2527
- offsetPoint.x,
2528
- offsetPoint.y,
2529
- offsetPoint.z
2530
- );
2531
- p0Attributes.nextPosition.values.push(
2532
- offsetPoint.x,
2533
- offsetPoint.y,
2534
- offsetPoint.z
2535
- );
2536
- Cartesian3_default.negate(offset, offset);
2537
- Cartesian3_default.add(intersection, offset, offsetPoint);
2538
- p2Attributes.position.values.push(
2539
- offsetPoint.x,
2540
- offsetPoint.y,
2541
- offsetPoint.z
2542
- );
2543
- p2Attributes.position.values.push(
2544
- offsetPoint.x,
2545
- offsetPoint.y,
2546
- offsetPoint.z
2547
- );
2548
- p2Attributes.position.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
2549
- p2Attributes.prevPosition.values.push(
2550
- offsetPoint.x,
2551
- offsetPoint.y,
2552
- offsetPoint.z
2553
- );
2554
- p2Attributes.prevPosition.values.push(
2555
- offsetPoint.x,
2556
- offsetPoint.y,
2557
- offsetPoint.z
2558
- );
2559
- p2Attributes.prevPosition.values.push(
2560
- offsetPoint.x,
2561
- offsetPoint.y,
2562
- offsetPoint.z
2563
- );
2564
- p2Attributes.prevPosition.values.push(
2565
- offsetPoint.x,
2566
- offsetPoint.y,
2567
- offsetPoint.z
2568
- );
2569
- p2Attributes.nextPosition.values.push(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z);
2570
- p2Attributes.nextPosition.values.push(
2571
- nextPositions[i2 * 3],
2572
- nextPositions[i2 * 3 + 1],
2573
- nextPositions[i2 * 3 + 2]
2574
- );
2575
- p2Attributes.nextPosition.values.push(
2576
- nextPositions[i2 * 3 + 3],
2577
- nextPositions[i2 * 3 + 4],
2578
- nextPositions[i2 * 3 + 5]
2579
- );
2580
- const ew0 = Cartesian2_default.fromArray(
2581
- expandAndWidths,
2582
- i0 * 2,
2583
- cartesian2Scratch0
2584
- );
2585
- const width = Math.abs(ew0.y);
2586
- p0Attributes.expandAndWidth.values.push(-1, width, 1, width);
2587
- p0Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
2588
- p2Attributes.expandAndWidth.values.push(-1, width, 1, width);
2589
- p2Attributes.expandAndWidth.values.push(-1, -width, 1, -width);
2590
- let t = Cartesian3_default.magnitudeSquared(
2591
- Cartesian3_default.subtract(intersection, p0, cartesian3Scratch3)
2592
- );
2593
- t /= Cartesian3_default.magnitudeSquared(
2594
- Cartesian3_default.subtract(p2, p0, cartesian3Scratch3)
2595
- );
2596
- if (defined_default(colors)) {
2597
- const c0 = Cartesian4_default.fromArray(colors, i0 * 4, cartesian4Scratch0);
2598
- const c2 = Cartesian4_default.fromArray(colors, i2 * 4, cartesian4Scratch0);
2599
- const r = Math_default.lerp(c0.x, c2.x, t);
2600
- const g = Math_default.lerp(c0.y, c2.y, t);
2601
- const b = Math_default.lerp(c0.z, c2.z, t);
2602
- const a = Math_default.lerp(c0.w, c2.w, t);
2603
- for (j = i0 * 4; j < i0 * 4 + 2 * 4; ++j) {
2604
- p0Attributes.color.values.push(colors[j]);
2605
- }
2606
- p0Attributes.color.values.push(r, g, b, a);
2607
- p0Attributes.color.values.push(r, g, b, a);
2608
- p2Attributes.color.values.push(r, g, b, a);
2609
- p2Attributes.color.values.push(r, g, b, a);
2610
- for (j = i2 * 4; j < i2 * 4 + 2 * 4; ++j) {
2611
- p2Attributes.color.values.push(colors[j]);
2612
- }
2613
- }
2614
- if (defined_default(texCoords)) {
2615
- const s0 = Cartesian2_default.fromArray(texCoords, i0 * 2, cartesian2Scratch0);
2616
- const s3 = Cartesian2_default.fromArray(
2617
- texCoords,
2618
- (i + 3) * 2,
2619
- cartesian2Scratch1
2620
- );
2621
- const sx = Math_default.lerp(s0.x, s3.x, t);
2622
- for (j = i0 * 2; j < i0 * 2 + 2 * 2; ++j) {
2623
- p0Attributes.st.values.push(texCoords[j]);
2624
- }
2625
- p0Attributes.st.values.push(sx, s0.y);
2626
- p0Attributes.st.values.push(sx, s3.y);
2627
- p2Attributes.st.values.push(sx, s0.y);
2628
- p2Attributes.st.values.push(sx, s3.y);
2629
- for (j = i2 * 2; j < i2 * 2 + 2 * 2; ++j) {
2630
- p2Attributes.st.values.push(texCoords[j]);
2631
- }
2632
- }
2633
- index = p0Attributes.position.values.length / 3 - 4;
2634
- p0Indices.push(index, index + 2, index + 1);
2635
- p0Indices.push(index + 1, index + 2, index + 3);
2636
- index = p2Attributes.position.values.length / 3 - 4;
2637
- p2Indices.push(index, index + 2, index + 1);
2638
- p2Indices.push(index + 1, index + 2, index + 3);
2639
- } else {
2640
- let currentAttributes;
2641
- let currentIndices;
2642
- if (p0.y < 0) {
2643
- currentAttributes = westGeometry.attributes;
2644
- currentIndices = westGeometry.indices;
2645
- } else {
2646
- currentAttributes = eastGeometry.attributes;
2647
- currentIndices = eastGeometry.indices;
2648
- }
2649
- currentAttributes.position.values.push(p0.x, p0.y, p0.z);
2650
- currentAttributes.position.values.push(p0.x, p0.y, p0.z);
2651
- currentAttributes.position.values.push(p2.x, p2.y, p2.z);
2652
- currentAttributes.position.values.push(p2.x, p2.y, p2.z);
2653
- for (j = i * 3; j < i * 3 + 4 * 3; ++j) {
2654
- currentAttributes.prevPosition.values.push(prevPositions[j]);
2655
- currentAttributes.nextPosition.values.push(nextPositions[j]);
2656
- }
2657
- for (j = i * 2; j < i * 2 + 4 * 2; ++j) {
2658
- currentAttributes.expandAndWidth.values.push(expandAndWidths[j]);
2659
- if (defined_default(texCoords)) {
2660
- currentAttributes.st.values.push(texCoords[j]);
2661
- }
2662
- }
2663
- if (defined_default(colors)) {
2664
- for (j = i * 4; j < i * 4 + 4 * 4; ++j) {
2665
- currentAttributes.color.values.push(colors[j]);
2666
- }
2667
- }
2668
- index = currentAttributes.position.values.length / 3 - 4;
2669
- currentIndices.push(index, index + 2, index + 1);
2670
- currentIndices.push(index + 1, index + 2, index + 3);
2671
- }
2672
- }
2673
- if (intersectionFound) {
2674
- updateAdjacencyAfterSplit(westGeometry);
2675
- updateAdjacencyAfterSplit(eastGeometry);
2676
- }
2677
- updateInstanceAfterSplit(instance, westGeometry, eastGeometry);
2678
- }
2679
- GeometryPipeline.splitLongitude = function(instance) {
2680
- if (!defined_default(instance)) {
2681
- throw new DeveloperError_default("instance is required.");
2682
- }
2683
- const geometry = instance.geometry;
2684
- const boundingSphere = geometry.boundingSphere;
2685
- if (defined_default(boundingSphere)) {
2686
- const minX = boundingSphere.center.x - boundingSphere.radius;
2687
- if (minX > 0 || BoundingSphere_default.intersectPlane(boundingSphere, Plane_default.ORIGIN_ZX_PLANE) !== Intersect_default.INTERSECTING) {
2688
- return instance;
2689
- }
2690
- }
2691
- if (geometry.geometryType !== GeometryType_default.NONE) {
2692
- switch (geometry.geometryType) {
2693
- case GeometryType_default.POLYLINES:
2694
- splitLongitudePolyline(instance);
2695
- break;
2696
- case GeometryType_default.TRIANGLES:
2697
- splitLongitudeTriangles(instance);
2698
- break;
2699
- case GeometryType_default.LINES:
2700
- splitLongitudeLines(instance);
2701
- break;
2702
- }
2703
- } else {
2704
- indexPrimitive(geometry);
2705
- if (geometry.primitiveType === PrimitiveType_default.TRIANGLES) {
2706
- splitLongitudeTriangles(instance);
2707
- } else if (geometry.primitiveType === PrimitiveType_default.LINES) {
2708
- splitLongitudeLines(instance);
2709
- }
2710
- }
2711
- return instance;
2712
- };
2713
- var GeometryPipeline_default = GeometryPipeline;
2714
-
2715
- export {
2716
- GeometryPipeline_default
2717
- };