deeptwins-cesium-engine 0.1.2 → 0.1.4

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 (219) hide show
  1. package/Build/Workers/chunk-2HWLF3FT.js +837 -0
  2. package/Build/Workers/chunk-2KXMJ5XS.js +3792 -0
  3. package/Build/Workers/chunk-2NPCLB3H.js +56 -0
  4. package/Build/Workers/chunk-2ZHQTIBH.js +1483 -0
  5. package/Build/Workers/chunk-3GLYOW63.js +352 -0
  6. package/Build/Workers/chunk-3L22KMPU.js +219 -0
  7. package/Build/Workers/chunk-3Q6V2B2I.js +73 -0
  8. package/Build/Workers/chunk-3QOKKRIG.js +387 -0
  9. package/Build/Workers/chunk-44YZFGRH.js +1800 -0
  10. package/Build/Workers/chunk-45VV4SBO.js +2342 -0
  11. package/Build/Workers/chunk-4EJ4AA2S.js +368 -0
  12. package/Build/Workers/chunk-4IJFHUL6.js +414 -0
  13. package/Build/Workers/chunk-4K3V5CGW.js +454 -0
  14. package/Build/Workers/chunk-4M4QL6KJ.js +305 -0
  15. package/Build/Workers/chunk-4YNRIEQ6.js +288 -0
  16. package/Build/Workers/chunk-56CVDPH5.js +352 -0
  17. package/Build/Workers/chunk-5CTAAPXH.js +1483 -0
  18. package/Build/Workers/chunk-5ISZ6NJD.js +102 -0
  19. package/Build/Workers/chunk-5SDHYIOS.js +56 -0
  20. package/Build/Workers/chunk-66TGUMCU.js +2719 -0
  21. package/Build/Workers/chunk-6EJMTDQJ.js +163 -0
  22. package/Build/Workers/chunk-6VWXYSMH.js +959 -0
  23. package/Build/Workers/chunk-6VZ7VB2Q.js +241 -0
  24. package/Build/Workers/chunk-7AMRE57Q.js +301 -0
  25. package/Build/Workers/chunk-7DH6C33H.js +398 -0
  26. package/Build/Workers/chunk-7VUS3FVE.js +38 -0
  27. package/Build/Workers/chunk-7Y3ZA6H3.js +198 -0
  28. package/Build/Workers/chunk-A6BMHZNA.js +38 -0
  29. package/Build/Workers/chunk-A7XY2MN7.js +171 -0
  30. package/Build/Workers/chunk-AC7ND63S.js +57 -0
  31. package/Build/Workers/chunk-AHCZ757M.js +9230 -0
  32. package/Build/Workers/chunk-ANOA7E7F.js +56 -0
  33. package/Build/Workers/chunk-AYO5HHV6.js +789 -0
  34. package/Build/Workers/chunk-BE2N56VZ.js +1344 -0
  35. package/Build/Workers/chunk-BR3BPM64.js +9230 -0
  36. package/Build/Workers/chunk-BVMRWGOK.js +455 -0
  37. package/Build/Workers/chunk-BXEL2NX7.js +455 -0
  38. package/Build/Workers/chunk-C5BO2JCG.js +278 -0
  39. package/Build/Workers/chunk-CIRQNZVR.js +301 -0
  40. package/Build/Workers/chunk-CM67CQME.js +305 -0
  41. package/Build/Workers/chunk-D3QIW4DH.js +630 -0
  42. package/Build/Workers/chunk-E5W7QIGZ.js +511 -0
  43. package/Build/Workers/chunk-E6CYGUJI.js +1054 -0
  44. package/Build/Workers/chunk-EIZ23IOX.js +414 -0
  45. package/Build/Workers/chunk-EIZJUMQY.js +101 -0
  46. package/Build/Workers/chunk-EXTMZJXB.js +82 -0
  47. package/Build/Workers/chunk-EYOOSIBW.js +682 -0
  48. package/Build/Workers/chunk-F37WADVC.js +1054 -0
  49. package/Build/Workers/chunk-FIWPJFHX.js +101 -0
  50. package/Build/Workers/chunk-FM32TNGT.js +198 -0
  51. package/Build/Workers/chunk-FOMYIEIB.js +476 -0
  52. package/Build/Workers/chunk-FWYDLSVQ.js +97 -0
  53. package/Build/Workers/chunk-HGZR6CZF.js +1067 -0
  54. package/Build/Workers/chunk-HIXHDABG.js +288 -0
  55. package/Build/Workers/chunk-HMCCZZWE.js +97 -0
  56. package/Build/Workers/chunk-HW54WHGM.js +2719 -0
  57. package/Build/Workers/chunk-IHYAI7GF.js +973 -0
  58. package/Build/Workers/chunk-INLQ7LVK.js +837 -0
  59. package/Build/Workers/chunk-IQMESTCB.js +124 -0
  60. package/Build/Workers/chunk-J4PISUNT.js +2342 -0
  61. package/Build/Workers/chunk-JSWU557I.js +693 -0
  62. package/Build/Workers/chunk-KHONDSQ7.js +693 -0
  63. package/Build/Workers/chunk-KLUL2SOE.js +352 -0
  64. package/Build/Workers/chunk-KMBLKQCC.js +1992 -0
  65. package/Build/Workers/chunk-KOTWWQN7.js +171 -0
  66. package/Build/Workers/chunk-KWV6ZTF4.js +163 -0
  67. package/Build/Workers/chunk-LSEFPQHG.js +476 -0
  68. package/Build/Workers/chunk-M66X4O24.js +44 -0
  69. package/Build/Workers/chunk-M6IXKBC7.js +1992 -0
  70. package/Build/Workers/chunk-MFUC3D5C.js +162 -0
  71. package/Build/Workers/chunk-MRMNELAH.js +82 -0
  72. package/Build/Workers/chunk-N3NUA5H2.js +3792 -0
  73. package/Build/Workers/chunk-NFB2NXJN.js +138 -0
  74. package/Build/Workers/chunk-NQAXBK4K.js +789 -0
  75. package/Build/Workers/chunk-NUGQWV6S.js +352 -0
  76. package/Build/Workers/chunk-O7S7WL7K.js +278 -0
  77. package/Build/Workers/chunk-ODZYB26X.js +1287 -0
  78. package/Build/Workers/chunk-OEHJY463.js +3201 -0
  79. package/Build/Workers/chunk-OMMRNMXF.js +44 -0
  80. package/Build/Workers/chunk-OZ3CQDO3.js +138 -0
  81. package/Build/Workers/chunk-PNXBG64I.js +219 -0
  82. package/Build/Workers/chunk-PYR35GK4.js +973 -0
  83. package/Build/Workers/chunk-Q4CXGW74.js +57 -0
  84. package/Build/Workers/chunk-QGISLKCW.js +147 -0
  85. package/Build/Workers/chunk-QQHVOJW6.js +497 -0
  86. package/Build/Workers/chunk-QWCMMRJW.js +58 -0
  87. package/Build/Workers/chunk-RDEZCHF4.js +398 -0
  88. package/Build/Workers/chunk-SJTE7FVN.js +778 -0
  89. package/Build/Workers/chunk-SM5T67LR.js +162 -0
  90. package/Build/Workers/chunk-T27NNXEU.js +58 -0
  91. package/Build/Workers/chunk-T4J5BWUO.js +511 -0
  92. package/Build/Workers/chunk-T6JS4BRN.js +140 -0
  93. package/Build/Workers/chunk-UH6DUQBW.js +140 -0
  94. package/Build/Workers/chunk-UJAH6XKF.js +73 -0
  95. package/Build/Workers/chunk-UKSTJ2PH.js +454 -0
  96. package/Build/Workers/chunk-UQCDCCZ7.js +368 -0
  97. package/Build/Workers/chunk-UXIFNEA3.js +1287 -0
  98. package/Build/Workers/chunk-UXJ6J5L7.js +56 -0
  99. package/Build/Workers/chunk-V4VUAZXI.js +1800 -0
  100. package/Build/Workers/chunk-VQH2YXO2.js +497 -0
  101. package/Build/Workers/chunk-VXKCLSE4.js +241 -0
  102. package/Build/Workers/chunk-W3U6YBEI.js +280 -0
  103. package/Build/Workers/chunk-W75ZVFKP.js +778 -0
  104. package/Build/Workers/chunk-WCDFJYFB.js +1344 -0
  105. package/Build/Workers/chunk-WME5M6W3.js +630 -0
  106. package/Build/Workers/chunk-XDQBQB64.js +1067 -0
  107. package/Build/Workers/chunk-Y6HOIWE5.js +959 -0
  108. package/Build/Workers/chunk-YEMC2ZOR.js +147 -0
  109. package/Build/Workers/chunk-YWNF3TPE.js +682 -0
  110. package/Build/Workers/chunk-Z55VGWJP.js +280 -0
  111. package/Build/Workers/chunk-Z5YWP24C.js +124 -0
  112. package/Build/Workers/chunk-ZHXCWUJB.js +387 -0
  113. package/Build/Workers/chunk-ZIMPUF2I.js +102 -0
  114. package/Build/Workers/chunk-ZKDWYQKC.js +3201 -0
  115. package/Build/Workers/combineGeometry.js +24 -22
  116. package/Build/Workers/createBoxGeometry.js +18 -16
  117. package/Build/Workers/createBoxOutlineGeometry.js +23 -25
  118. package/Build/Workers/createCircleGeometry.js +29 -27
  119. package/Build/Workers/createCircleOutlineGeometry.js +22 -20
  120. package/Build/Workers/createCoplanarPolygonGeometry.js +43 -43
  121. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +37 -35
  122. package/Build/Workers/createCorridorGeometry.js +46 -49
  123. package/Build/Workers/createCorridorOutlineGeometry.js +40 -43
  124. package/Build/Workers/createCylinderGeometry.js +20 -18
  125. package/Build/Workers/createCylinderOutlineGeometry.js +27 -25
  126. package/Build/Workers/createEllipseGeometry.js +28 -25
  127. package/Build/Workers/createEllipseOutlineGeometry.js +21 -18
  128. package/Build/Workers/createEllipsoidGeometry.js +19 -17
  129. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -16
  130. package/Build/Workers/createFrustumGeometry.js +18 -16
  131. package/Build/Workers/createFrustumOutlineGeometry.js +21 -21
  132. package/Build/Workers/createGeometry.js +31 -26
  133. package/Build/Workers/createGroundPolylineGeometry.js +188 -135
  134. package/Build/Workers/createPlaneGeometry.js +22 -21
  135. package/Build/Workers/createPlaneOutlineGeometry.js +15 -13
  136. package/Build/Workers/createPolygonGeometry.js +51 -52
  137. package/Build/Workers/createPolygonOutlineGeometry.js +43 -44
  138. package/Build/Workers/createPolylineGeometry.js +37 -40
  139. package/Build/Workers/createPolylineVolumeGeometry.js +41 -44
  140. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +36 -39
  141. package/Build/Workers/createRectangleGeometry.js +47 -53
  142. package/Build/Workers/createRectangleOutlineGeometry.js +32 -33
  143. package/Build/Workers/createSimplePolylineGeometry.js +33 -34
  144. package/Build/Workers/createSphereGeometry.js +20 -20
  145. package/Build/Workers/createSphereOutlineGeometry.js +19 -19
  146. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  147. package/Build/Workers/createVectorTileClampedPolylines.js +16 -14
  148. package/Build/Workers/createVectorTileGeometries.js +24 -22
  149. package/Build/Workers/createVectorTilePoints.js +15 -13
  150. package/Build/Workers/createVectorTilePolygons.js +24 -21
  151. package/Build/Workers/createVectorTilePolylines.js +16 -14
  152. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  153. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +29 -27
  154. package/Build/Workers/createVerticesFromHeightmap.js +42 -63
  155. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +26 -280
  156. package/Build/Workers/createWallGeometry.js +35 -36
  157. package/Build/Workers/createWallOutlineGeometry.js +33 -34
  158. package/Build/Workers/decodeDraco.js +10 -11
  159. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  160. package/Build/Workers/decodeI3S.js +16 -20
  161. package/Build/Workers/gaussianSplatSorter.js +4 -4
  162. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  163. package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
  164. package/Build/Workers/transcodeKTX2.js +42 -14
  165. package/Build/Workers/transferTypedArrayTest.js +1 -1
  166. package/Build/Workers/upsampleQuantizedTerrainMesh.js +24 -21
  167. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  168. package/Source/Shaders/BillboardCollectionFS.js +85 -81
  169. package/Source/Shaders/BillboardCollectionVS.js +60 -118
  170. package/Source/Shaders/Builtin/Constants/passCesium3DTile.js +1 -1
  171. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassification.js +1 -1
  172. package/Source/Shaders/Builtin/Constants/passCesium3DTileClassificationIgnoreShow.js +1 -1
  173. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdges.js +12 -0
  174. package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
  175. package/Source/Shaders/Builtin/Constants/passGaussianSplats.js +11 -0
  176. package/Source/Shaders/Builtin/Constants/passOpaque.js +1 -1
  177. package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
  178. package/Source/Shaders/Builtin/Constants/passTranslucent.js +1 -1
  179. package/Source/Shaders/Builtin/Constants/passVoxels.js +1 -1
  180. package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
  181. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  182. package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
  183. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  184. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
  185. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  186. package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
  187. package/Source/Shaders/EllipsoidVS.js +4 -4
  188. package/Source/Shaders/FXAA3_11.js +2 -0
  189. package/Source/Shaders/GlobeFS.js +22 -0
  190. package/Source/Shaders/GlobeVS.js +3 -2
  191. package/Source/Shaders/Model/MaterialStageFS.js +50 -20
  192. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  193. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  194. package/Source/Shaders/Model/ModelFS.js +32 -2
  195. package/Source/Shaders/Model/ModelVS.js +15 -1
  196. package/Source/Shaders/Model/PointCloudStylingStageVS.js +2 -1
  197. package/Source/Shaders/Model/PrimitiveOutlineStageFS.js +0 -1
  198. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  199. package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
  200. package/Source/Shaders/PolylineCommon.js +1 -1
  201. package/Source/Shaders/ShadowVolumeAppearanceFS.js +7 -15
  202. package/Source/Shaders/SkyAtmosphereVS.js +2 -1
  203. package/Source/Shaders/Voxels/IntersectBox.js +20 -33
  204. package/Source/Shaders/Voxels/IntersectCylinder.js +28 -32
  205. package/Source/Shaders/Voxels/IntersectDepth.js +10 -6
  206. package/Source/Shaders/Voxels/IntersectEllipsoid.js +12 -20
  207. package/Source/Shaders/Voxels/IntersectLongitude.js +21 -9
  208. package/Source/Shaders/Voxels/Intersection.js +3 -5
  209. package/Source/Shaders/Voxels/IntersectionUtils.js +2 -1
  210. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  211. package/Source/Shaders/Voxels/Octree.js +53 -61
  212. package/Source/Shaders/Voxels/VoxelFS.js +67 -52
  213. package/Source/Shaders/Voxels/VoxelUtils.js +0 -19
  214. package/index.js +346 -261
  215. package/package.json +1 -1
  216. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +0 -80
  217. package/Source/Shaders/Voxels/convertUvToBox.js +0 -46
  218. package/Source/Shaders/Voxels/convertUvToCylinder.js +0 -101
  219. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +0 -141
@@ -0,0 +1,1344 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.1.3
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
+ Interval_default
28
+ } from "./chunk-UXIFNEA3.js";
29
+ import {
30
+ Cartographic_default
31
+ } from "./chunk-KMBLKQCC.js";
32
+ import {
33
+ Cartesian3_default,
34
+ Matrix3_default
35
+ } from "./chunk-45VV4SBO.js";
36
+ import {
37
+ Math_default
38
+ } from "./chunk-QQHVOJW6.js";
39
+ import {
40
+ Check_default,
41
+ DeveloperError_default
42
+ } from "./chunk-6EJMTDQJ.js";
43
+ import {
44
+ defined_default
45
+ } from "./chunk-EXTMZJXB.js";
46
+
47
+ // packages/engine/Source/Core/QuadraticRealPolynomial.js
48
+ var QuadraticRealPolynomial = {};
49
+ QuadraticRealPolynomial.computeDiscriminant = function(a, b, c) {
50
+ if (typeof a !== "number") {
51
+ throw new DeveloperError_default("a is a required number.");
52
+ }
53
+ if (typeof b !== "number") {
54
+ throw new DeveloperError_default("b is a required number.");
55
+ }
56
+ if (typeof c !== "number") {
57
+ throw new DeveloperError_default("c is a required number.");
58
+ }
59
+ const discriminant = b * b - 4 * a * c;
60
+ return discriminant;
61
+ };
62
+ function addWithCancellationCheck(left, right, tolerance) {
63
+ const difference = left + right;
64
+ if (Math_default.sign(left) !== Math_default.sign(right) && Math.abs(difference / Math.max(Math.abs(left), Math.abs(right))) < tolerance) {
65
+ return 0;
66
+ }
67
+ return difference;
68
+ }
69
+ QuadraticRealPolynomial.computeRealRoots = function(a, b, c) {
70
+ if (typeof a !== "number") {
71
+ throw new DeveloperError_default("a is a required number.");
72
+ }
73
+ if (typeof b !== "number") {
74
+ throw new DeveloperError_default("b is a required number.");
75
+ }
76
+ if (typeof c !== "number") {
77
+ throw new DeveloperError_default("c is a required number.");
78
+ }
79
+ let ratio;
80
+ if (a === 0) {
81
+ if (b === 0) {
82
+ return [];
83
+ }
84
+ return [-c / b];
85
+ } else if (b === 0) {
86
+ if (c === 0) {
87
+ return [0, 0];
88
+ }
89
+ const cMagnitude = Math.abs(c);
90
+ const aMagnitude = Math.abs(a);
91
+ if (cMagnitude < aMagnitude && cMagnitude / aMagnitude < Math_default.EPSILON14) {
92
+ return [0, 0];
93
+ } else if (cMagnitude > aMagnitude && aMagnitude / cMagnitude < Math_default.EPSILON14) {
94
+ return [];
95
+ }
96
+ ratio = -c / a;
97
+ if (ratio < 0) {
98
+ return [];
99
+ }
100
+ const root = Math.sqrt(ratio);
101
+ return [-root, root];
102
+ } else if (c === 0) {
103
+ ratio = -b / a;
104
+ if (ratio < 0) {
105
+ return [ratio, 0];
106
+ }
107
+ return [0, ratio];
108
+ }
109
+ const b2 = b * b;
110
+ const four_ac = 4 * a * c;
111
+ const radicand = addWithCancellationCheck(b2, -four_ac, Math_default.EPSILON14);
112
+ if (radicand < 0) {
113
+ return [];
114
+ }
115
+ const q = -0.5 * addWithCancellationCheck(
116
+ b,
117
+ Math_default.sign(b) * Math.sqrt(radicand),
118
+ Math_default.EPSILON14
119
+ );
120
+ if (b > 0) {
121
+ return [q / a, c / q];
122
+ }
123
+ return [c / q, q / a];
124
+ };
125
+ var QuadraticRealPolynomial_default = QuadraticRealPolynomial;
126
+
127
+ // packages/engine/Source/Core/CubicRealPolynomial.js
128
+ var CubicRealPolynomial = {};
129
+ CubicRealPolynomial.computeDiscriminant = function(a, b, c, d) {
130
+ if (typeof a !== "number") {
131
+ throw new DeveloperError_default("a is a required number.");
132
+ }
133
+ if (typeof b !== "number") {
134
+ throw new DeveloperError_default("b is a required number.");
135
+ }
136
+ if (typeof c !== "number") {
137
+ throw new DeveloperError_default("c is a required number.");
138
+ }
139
+ if (typeof d !== "number") {
140
+ throw new DeveloperError_default("d is a required number.");
141
+ }
142
+ const a2 = a * a;
143
+ const b2 = b * b;
144
+ const c2 = c * c;
145
+ const d2 = d * d;
146
+ const discriminant = 18 * a * b * c * d + b2 * c2 - 27 * a2 * d2 - 4 * (a * c2 * c + b2 * b * d);
147
+ return discriminant;
148
+ };
149
+ function computeRealRoots(a, b, c, d) {
150
+ const A = a;
151
+ const B = b / 3;
152
+ const C = c / 3;
153
+ const D = d;
154
+ const AC = A * C;
155
+ const BD = B * D;
156
+ const B2 = B * B;
157
+ const C2 = C * C;
158
+ const delta1 = A * C - B2;
159
+ const delta2 = A * D - B * C;
160
+ const delta3 = B * D - C2;
161
+ const discriminant = 4 * delta1 * delta3 - delta2 * delta2;
162
+ let temp;
163
+ let temp1;
164
+ if (discriminant < 0) {
165
+ let ABar;
166
+ let CBar;
167
+ let DBar;
168
+ if (B2 * BD >= AC * C2) {
169
+ ABar = A;
170
+ CBar = delta1;
171
+ DBar = -2 * B * delta1 + A * delta2;
172
+ } else {
173
+ ABar = D;
174
+ CBar = delta3;
175
+ DBar = -D * delta2 + 2 * C * delta3;
176
+ }
177
+ const s = DBar < 0 ? -1 : 1;
178
+ const temp0 = -s * Math.abs(ABar) * Math.sqrt(-discriminant);
179
+ temp1 = -DBar + temp0;
180
+ const x = temp1 / 2;
181
+ const p = x < 0 ? -Math.pow(-x, 1 / 3) : Math.pow(x, 1 / 3);
182
+ const q = temp1 === temp0 ? -p : -CBar / p;
183
+ temp = CBar <= 0 ? p + q : -DBar / (p * p + q * q + CBar);
184
+ if (B2 * BD >= AC * C2) {
185
+ return [(temp - B) / A];
186
+ }
187
+ return [-D / (temp + C)];
188
+ }
189
+ const CBarA = delta1;
190
+ const DBarA = -2 * B * delta1 + A * delta2;
191
+ const CBarD = delta3;
192
+ const DBarD = -D * delta2 + 2 * C * delta3;
193
+ const squareRootOfDiscriminant = Math.sqrt(discriminant);
194
+ const halfSquareRootOf3 = Math.sqrt(3) / 2;
195
+ let theta = Math.abs(Math.atan2(A * squareRootOfDiscriminant, -DBarA) / 3);
196
+ temp = 2 * Math.sqrt(-CBarA);
197
+ let cosine = Math.cos(theta);
198
+ temp1 = temp * cosine;
199
+ let temp3 = temp * (-cosine / 2 - halfSquareRootOf3 * Math.sin(theta));
200
+ const numeratorLarge = temp1 + temp3 > 2 * B ? temp1 - B : temp3 - B;
201
+ const denominatorLarge = A;
202
+ const root1 = numeratorLarge / denominatorLarge;
203
+ theta = Math.abs(Math.atan2(D * squareRootOfDiscriminant, -DBarD) / 3);
204
+ temp = 2 * Math.sqrt(-CBarD);
205
+ cosine = Math.cos(theta);
206
+ temp1 = temp * cosine;
207
+ temp3 = temp * (-cosine / 2 - halfSquareRootOf3 * Math.sin(theta));
208
+ const numeratorSmall = -D;
209
+ const denominatorSmall = temp1 + temp3 < 2 * C ? temp1 + C : temp3 + C;
210
+ const root3 = numeratorSmall / denominatorSmall;
211
+ const E = denominatorLarge * denominatorSmall;
212
+ const F = -numeratorLarge * denominatorSmall - denominatorLarge * numeratorSmall;
213
+ const G = numeratorLarge * numeratorSmall;
214
+ const root2 = (C * F - B * G) / (-B * F + C * E);
215
+ if (root1 <= root2) {
216
+ if (root1 <= root3) {
217
+ if (root2 <= root3) {
218
+ return [root1, root2, root3];
219
+ }
220
+ return [root1, root3, root2];
221
+ }
222
+ return [root3, root1, root2];
223
+ }
224
+ if (root1 <= root3) {
225
+ return [root2, root1, root3];
226
+ }
227
+ if (root2 <= root3) {
228
+ return [root2, root3, root1];
229
+ }
230
+ return [root3, root2, root1];
231
+ }
232
+ CubicRealPolynomial.computeRealRoots = function(a, b, c, d) {
233
+ if (typeof a !== "number") {
234
+ throw new DeveloperError_default("a is a required number.");
235
+ }
236
+ if (typeof b !== "number") {
237
+ throw new DeveloperError_default("b is a required number.");
238
+ }
239
+ if (typeof c !== "number") {
240
+ throw new DeveloperError_default("c is a required number.");
241
+ }
242
+ if (typeof d !== "number") {
243
+ throw new DeveloperError_default("d is a required number.");
244
+ }
245
+ let roots;
246
+ let ratio;
247
+ if (a === 0) {
248
+ return QuadraticRealPolynomial_default.computeRealRoots(b, c, d);
249
+ } else if (b === 0) {
250
+ if (c === 0) {
251
+ if (d === 0) {
252
+ return [0, 0, 0];
253
+ }
254
+ ratio = -d / a;
255
+ const root = ratio < 0 ? -Math.pow(-ratio, 1 / 3) : Math.pow(ratio, 1 / 3);
256
+ return [root, root, root];
257
+ } else if (d === 0) {
258
+ roots = QuadraticRealPolynomial_default.computeRealRoots(a, 0, c);
259
+ if (roots.Length === 0) {
260
+ return [0];
261
+ }
262
+ return [roots[0], 0, roots[1]];
263
+ }
264
+ return computeRealRoots(a, 0, c, d);
265
+ } else if (c === 0) {
266
+ if (d === 0) {
267
+ ratio = -b / a;
268
+ if (ratio < 0) {
269
+ return [ratio, 0, 0];
270
+ }
271
+ return [0, 0, ratio];
272
+ }
273
+ return computeRealRoots(a, b, 0, d);
274
+ } else if (d === 0) {
275
+ roots = QuadraticRealPolynomial_default.computeRealRoots(a, b, c);
276
+ if (roots.length === 0) {
277
+ return [0];
278
+ } else if (roots[1] <= 0) {
279
+ return [roots[0], roots[1], 0];
280
+ } else if (roots[0] >= 0) {
281
+ return [0, roots[0], roots[1]];
282
+ }
283
+ return [roots[0], 0, roots[1]];
284
+ }
285
+ return computeRealRoots(a, b, c, d);
286
+ };
287
+ var CubicRealPolynomial_default = CubicRealPolynomial;
288
+
289
+ // packages/engine/Source/Core/QuarticRealPolynomial.js
290
+ var QuarticRealPolynomial = {};
291
+ QuarticRealPolynomial.computeDiscriminant = function(a, b, c, d, e) {
292
+ if (typeof a !== "number") {
293
+ throw new DeveloperError_default("a is a required number.");
294
+ }
295
+ if (typeof b !== "number") {
296
+ throw new DeveloperError_default("b is a required number.");
297
+ }
298
+ if (typeof c !== "number") {
299
+ throw new DeveloperError_default("c is a required number.");
300
+ }
301
+ if (typeof d !== "number") {
302
+ throw new DeveloperError_default("d is a required number.");
303
+ }
304
+ if (typeof e !== "number") {
305
+ throw new DeveloperError_default("e is a required number.");
306
+ }
307
+ const a2 = a * a;
308
+ const a3 = a2 * a;
309
+ const b2 = b * b;
310
+ const b3 = b2 * b;
311
+ const c2 = c * c;
312
+ const c3 = c2 * c;
313
+ const d2 = d * d;
314
+ const d3 = d2 * d;
315
+ const e2 = e * e;
316
+ const e3 = e2 * e;
317
+ const discriminant = b2 * c2 * d2 - 4 * b3 * d3 - 4 * a * c3 * d2 + 18 * a * b * c * d3 - 27 * a2 * d2 * d2 + 256 * a3 * e3 + e * (18 * b3 * c * d - 4 * b2 * c3 + 16 * a * c2 * c2 - 80 * a * b * c2 * d - 6 * a * b2 * d2 + 144 * a2 * c * d2) + e2 * (144 * a * b2 * c - 27 * b2 * b2 - 128 * a2 * c2 - 192 * a2 * b * d);
318
+ return discriminant;
319
+ };
320
+ function original(a3, a2, a1, a0) {
321
+ const a3Squared = a3 * a3;
322
+ const p = a2 - 3 * a3Squared / 8;
323
+ const q = a1 - a2 * a3 / 2 + a3Squared * a3 / 8;
324
+ const r = a0 - a1 * a3 / 4 + a2 * a3Squared / 16 - 3 * a3Squared * a3Squared / 256;
325
+ const cubicRoots = CubicRealPolynomial_default.computeRealRoots(
326
+ 1,
327
+ 2 * p,
328
+ p * p - 4 * r,
329
+ -q * q
330
+ );
331
+ if (cubicRoots.length > 0) {
332
+ const temp = -a3 / 4;
333
+ const hSquared = cubicRoots[cubicRoots.length - 1];
334
+ if (Math.abs(hSquared) < Math_default.EPSILON14) {
335
+ const roots = QuadraticRealPolynomial_default.computeRealRoots(1, p, r);
336
+ if (roots.length === 2) {
337
+ const root0 = roots[0];
338
+ const root1 = roots[1];
339
+ let y;
340
+ if (root0 >= 0 && root1 >= 0) {
341
+ const y0 = Math.sqrt(root0);
342
+ const y1 = Math.sqrt(root1);
343
+ return [temp - y1, temp - y0, temp + y0, temp + y1];
344
+ } else if (root0 >= 0 && root1 < 0) {
345
+ y = Math.sqrt(root0);
346
+ return [temp - y, temp + y];
347
+ } else if (root0 < 0 && root1 >= 0) {
348
+ y = Math.sqrt(root1);
349
+ return [temp - y, temp + y];
350
+ }
351
+ }
352
+ return [];
353
+ } else if (hSquared > 0) {
354
+ const h = Math.sqrt(hSquared);
355
+ const m = (p + hSquared - q / h) / 2;
356
+ const n = (p + hSquared + q / h) / 2;
357
+ const roots1 = QuadraticRealPolynomial_default.computeRealRoots(1, h, m);
358
+ const roots2 = QuadraticRealPolynomial_default.computeRealRoots(1, -h, n);
359
+ if (roots1.length !== 0) {
360
+ roots1[0] += temp;
361
+ roots1[1] += temp;
362
+ if (roots2.length !== 0) {
363
+ roots2[0] += temp;
364
+ roots2[1] += temp;
365
+ if (roots1[1] <= roots2[0]) {
366
+ return [roots1[0], roots1[1], roots2[0], roots2[1]];
367
+ } else if (roots2[1] <= roots1[0]) {
368
+ return [roots2[0], roots2[1], roots1[0], roots1[1]];
369
+ } else if (roots1[0] >= roots2[0] && roots1[1] <= roots2[1]) {
370
+ return [roots2[0], roots1[0], roots1[1], roots2[1]];
371
+ } else if (roots2[0] >= roots1[0] && roots2[1] <= roots1[1]) {
372
+ return [roots1[0], roots2[0], roots2[1], roots1[1]];
373
+ } else if (roots1[0] > roots2[0] && roots1[0] < roots2[1]) {
374
+ return [roots2[0], roots1[0], roots2[1], roots1[1]];
375
+ }
376
+ return [roots1[0], roots2[0], roots1[1], roots2[1]];
377
+ }
378
+ return roots1;
379
+ }
380
+ if (roots2.length !== 0) {
381
+ roots2[0] += temp;
382
+ roots2[1] += temp;
383
+ return roots2;
384
+ }
385
+ return [];
386
+ }
387
+ }
388
+ return [];
389
+ }
390
+ function neumark(a3, a2, a1, a0) {
391
+ const a1Squared = a1 * a1;
392
+ const a2Squared = a2 * a2;
393
+ const a3Squared = a3 * a3;
394
+ const p = -2 * a2;
395
+ const q = a1 * a3 + a2Squared - 4 * a0;
396
+ const r = a3Squared * a0 - a1 * a2 * a3 + a1Squared;
397
+ const cubicRoots = CubicRealPolynomial_default.computeRealRoots(1, p, q, r);
398
+ if (cubicRoots.length > 0) {
399
+ const y = cubicRoots[0];
400
+ const temp = a2 - y;
401
+ const tempSquared = temp * temp;
402
+ const g1 = a3 / 2;
403
+ const h1 = temp / 2;
404
+ const m = tempSquared - 4 * a0;
405
+ const mError = tempSquared + 4 * Math.abs(a0);
406
+ const n = a3Squared - 4 * y;
407
+ const nError = a3Squared + 4 * Math.abs(y);
408
+ let g2;
409
+ let h2;
410
+ if (y < 0 || m * nError < n * mError) {
411
+ const squareRootOfN = Math.sqrt(n);
412
+ g2 = squareRootOfN / 2;
413
+ h2 = squareRootOfN === 0 ? 0 : (a3 * h1 - a1) / squareRootOfN;
414
+ } else {
415
+ const squareRootOfM = Math.sqrt(m);
416
+ g2 = squareRootOfM === 0 ? 0 : (a3 * h1 - a1) / squareRootOfM;
417
+ h2 = squareRootOfM / 2;
418
+ }
419
+ let G;
420
+ let g;
421
+ if (g1 === 0 && g2 === 0) {
422
+ G = 0;
423
+ g = 0;
424
+ } else if (Math_default.sign(g1) === Math_default.sign(g2)) {
425
+ G = g1 + g2;
426
+ g = y / G;
427
+ } else {
428
+ g = g1 - g2;
429
+ G = y / g;
430
+ }
431
+ let H;
432
+ let h;
433
+ if (h1 === 0 && h2 === 0) {
434
+ H = 0;
435
+ h = 0;
436
+ } else if (Math_default.sign(h1) === Math_default.sign(h2)) {
437
+ H = h1 + h2;
438
+ h = a0 / H;
439
+ } else {
440
+ h = h1 - h2;
441
+ H = a0 / h;
442
+ }
443
+ const roots1 = QuadraticRealPolynomial_default.computeRealRoots(1, G, H);
444
+ const roots2 = QuadraticRealPolynomial_default.computeRealRoots(1, g, h);
445
+ if (roots1.length !== 0) {
446
+ if (roots2.length !== 0) {
447
+ if (roots1[1] <= roots2[0]) {
448
+ return [roots1[0], roots1[1], roots2[0], roots2[1]];
449
+ } else if (roots2[1] <= roots1[0]) {
450
+ return [roots2[0], roots2[1], roots1[0], roots1[1]];
451
+ } else if (roots1[0] >= roots2[0] && roots1[1] <= roots2[1]) {
452
+ return [roots2[0], roots1[0], roots1[1], roots2[1]];
453
+ } else if (roots2[0] >= roots1[0] && roots2[1] <= roots1[1]) {
454
+ return [roots1[0], roots2[0], roots2[1], roots1[1]];
455
+ } else if (roots1[0] > roots2[0] && roots1[0] < roots2[1]) {
456
+ return [roots2[0], roots1[0], roots2[1], roots1[1]];
457
+ }
458
+ return [roots1[0], roots2[0], roots1[1], roots2[1]];
459
+ }
460
+ return roots1;
461
+ }
462
+ if (roots2.length !== 0) {
463
+ return roots2;
464
+ }
465
+ }
466
+ return [];
467
+ }
468
+ QuarticRealPolynomial.computeRealRoots = function(a, b, c, d, e) {
469
+ if (typeof a !== "number") {
470
+ throw new DeveloperError_default("a is a required number.");
471
+ }
472
+ if (typeof b !== "number") {
473
+ throw new DeveloperError_default("b is a required number.");
474
+ }
475
+ if (typeof c !== "number") {
476
+ throw new DeveloperError_default("c is a required number.");
477
+ }
478
+ if (typeof d !== "number") {
479
+ throw new DeveloperError_default("d is a required number.");
480
+ }
481
+ if (typeof e !== "number") {
482
+ throw new DeveloperError_default("e is a required number.");
483
+ }
484
+ if (Math.abs(a) < Math_default.EPSILON15) {
485
+ return CubicRealPolynomial_default.computeRealRoots(b, c, d, e);
486
+ }
487
+ const a3 = b / a;
488
+ const a2 = c / a;
489
+ const a1 = d / a;
490
+ const a0 = e / a;
491
+ let k = a3 < 0 ? 1 : 0;
492
+ k += a2 < 0 ? k + 1 : k;
493
+ k += a1 < 0 ? k + 1 : k;
494
+ k += a0 < 0 ? k + 1 : k;
495
+ switch (k) {
496
+ case 0:
497
+ return original(a3, a2, a1, a0);
498
+ case 1:
499
+ return neumark(a3, a2, a1, a0);
500
+ case 2:
501
+ return neumark(a3, a2, a1, a0);
502
+ case 3:
503
+ return original(a3, a2, a1, a0);
504
+ case 4:
505
+ return original(a3, a2, a1, a0);
506
+ case 5:
507
+ return neumark(a3, a2, a1, a0);
508
+ case 6:
509
+ return original(a3, a2, a1, a0);
510
+ case 7:
511
+ return original(a3, a2, a1, a0);
512
+ case 8:
513
+ return neumark(a3, a2, a1, a0);
514
+ case 9:
515
+ return original(a3, a2, a1, a0);
516
+ case 10:
517
+ return original(a3, a2, a1, a0);
518
+ case 11:
519
+ return neumark(a3, a2, a1, a0);
520
+ case 12:
521
+ return original(a3, a2, a1, a0);
522
+ case 13:
523
+ return original(a3, a2, a1, a0);
524
+ case 14:
525
+ return original(a3, a2, a1, a0);
526
+ case 15:
527
+ return original(a3, a2, a1, a0);
528
+ default:
529
+ return void 0;
530
+ }
531
+ };
532
+ var QuarticRealPolynomial_default = QuarticRealPolynomial;
533
+
534
+ // packages/engine/Source/Core/Ray.js
535
+ var Ray = class _Ray {
536
+ /**
537
+ * @param {Cartesian3} [origin=Cartesian3.ZERO] The origin of the ray.
538
+ * @param {Cartesian3} [direction=Cartesian3.ZERO] The direction of the ray.
539
+ */
540
+ constructor(origin, direction) {
541
+ direction = Cartesian3_default.clone(direction ?? Cartesian3_default.ZERO);
542
+ if (!Cartesian3_default.equals(direction, Cartesian3_default.ZERO)) {
543
+ Cartesian3_default.normalize(direction, direction);
544
+ }
545
+ this.origin = Cartesian3_default.clone(origin ?? Cartesian3_default.ZERO);
546
+ this.direction = direction;
547
+ }
548
+ /**
549
+ * Duplicates a Ray instance.
550
+ *
551
+ * @param {Ray} ray The ray to duplicate.
552
+ * @param {Ray} [result] The object onto which to store the result.
553
+ * @returns {Ray} The modified result parameter or a new Ray instance if one was not provided. (Returns undefined if ray is undefined)
554
+ */
555
+ static clone(ray, result) {
556
+ if (!defined_default(ray)) {
557
+ return void 0;
558
+ }
559
+ if (!defined_default(result)) {
560
+ return new _Ray(ray.origin, ray.direction);
561
+ }
562
+ result.origin = Cartesian3_default.clone(ray.origin);
563
+ result.direction = Cartesian3_default.clone(ray.direction);
564
+ return result;
565
+ }
566
+ /**
567
+ * Computes the point along the ray given by r(t) = o + t*d,
568
+ * where o is the origin of the ray and d is the direction.
569
+ *
570
+ * @param {Ray} ray The ray.
571
+ * @param {number} t A scalar value.
572
+ * @param {Cartesian3} [result] The object in which the result will be stored.
573
+ * @returns {Cartesian3} The modified result parameter, or a new instance if none was provided.
574
+ *
575
+ * @example
576
+ * //Get the first intersection point of a ray and an ellipsoid.
577
+ * const intersection = Cesium.IntersectionTests.rayEllipsoid(ray, ellipsoid);
578
+ * const point = Cesium.Ray.getPoint(ray, intersection.start);
579
+ */
580
+ static getPoint(ray, t, result) {
581
+ Check_default.typeOf.object("ray", ray);
582
+ Check_default.typeOf.number("t", t);
583
+ if (!defined_default(result)) {
584
+ result = new Cartesian3_default();
585
+ }
586
+ result = Cartesian3_default.multiplyByScalar(ray.direction, t, result);
587
+ return Cartesian3_default.add(ray.origin, result, result);
588
+ }
589
+ };
590
+ var Ray_default = Ray;
591
+
592
+ // packages/engine/Source/Core/IntersectionTests.js
593
+ var IntersectionTests = {};
594
+ IntersectionTests.rayPlane = function(ray, plane, result) {
595
+ if (!defined_default(ray)) {
596
+ throw new DeveloperError_default("ray is required.");
597
+ }
598
+ if (!defined_default(plane)) {
599
+ throw new DeveloperError_default("plane is required.");
600
+ }
601
+ if (!defined_default(result)) {
602
+ result = new Cartesian3_default();
603
+ }
604
+ const origin = ray.origin;
605
+ const direction = ray.direction;
606
+ const normal = plane.normal;
607
+ const denominator = Cartesian3_default.dot(normal, direction);
608
+ if (Math.abs(denominator) < Math_default.EPSILON15) {
609
+ return void 0;
610
+ }
611
+ const t = (-plane.distance - Cartesian3_default.dot(normal, origin)) / denominator;
612
+ if (t < 0) {
613
+ return void 0;
614
+ }
615
+ result = Cartesian3_default.multiplyByScalar(direction, t, result);
616
+ return Cartesian3_default.add(origin, result, result);
617
+ };
618
+ var scratchEdge0 = new Cartesian3_default();
619
+ var scratchEdge1 = new Cartesian3_default();
620
+ var scratchPVec = new Cartesian3_default();
621
+ var scratchTVec = new Cartesian3_default();
622
+ var scratchQVec = new Cartesian3_default();
623
+ IntersectionTests.rayTriangleParametric = function(ray, p0, p1, p2, cullBackFaces) {
624
+ if (!defined_default(ray)) {
625
+ throw new DeveloperError_default("ray is required.");
626
+ }
627
+ if (!defined_default(p0)) {
628
+ throw new DeveloperError_default("p0 is required.");
629
+ }
630
+ if (!defined_default(p1)) {
631
+ throw new DeveloperError_default("p1 is required.");
632
+ }
633
+ if (!defined_default(p2)) {
634
+ throw new DeveloperError_default("p2 is required.");
635
+ }
636
+ cullBackFaces = cullBackFaces ?? false;
637
+ const origin = ray.origin;
638
+ const direction = ray.direction;
639
+ const edge0 = Cartesian3_default.subtract(p1, p0, scratchEdge0);
640
+ const edge1 = Cartesian3_default.subtract(p2, p0, scratchEdge1);
641
+ const p = Cartesian3_default.cross(direction, edge1, scratchPVec);
642
+ const det = Cartesian3_default.dot(edge0, p);
643
+ let tvec;
644
+ let q;
645
+ let u;
646
+ let v;
647
+ let t;
648
+ if (cullBackFaces) {
649
+ if (det < Math_default.EPSILON6) {
650
+ return void 0;
651
+ }
652
+ tvec = Cartesian3_default.subtract(origin, p0, scratchTVec);
653
+ u = Cartesian3_default.dot(tvec, p);
654
+ if (u < 0 || u > det) {
655
+ return void 0;
656
+ }
657
+ q = Cartesian3_default.cross(tvec, edge0, scratchQVec);
658
+ v = Cartesian3_default.dot(direction, q);
659
+ if (v < 0 || u + v > det) {
660
+ return void 0;
661
+ }
662
+ t = Cartesian3_default.dot(edge1, q) / det;
663
+ } else {
664
+ if (Math.abs(det) < Math_default.EPSILON6) {
665
+ return void 0;
666
+ }
667
+ const invDet = 1 / det;
668
+ tvec = Cartesian3_default.subtract(origin, p0, scratchTVec);
669
+ u = Cartesian3_default.dot(tvec, p) * invDet;
670
+ if (u < 0 || u > 1) {
671
+ return void 0;
672
+ }
673
+ q = Cartesian3_default.cross(tvec, edge0, scratchQVec);
674
+ v = Cartesian3_default.dot(direction, q) * invDet;
675
+ if (v < 0 || u + v > 1) {
676
+ return void 0;
677
+ }
678
+ t = Cartesian3_default.dot(edge1, q) * invDet;
679
+ }
680
+ return t;
681
+ };
682
+ IntersectionTests.rayTriangle = function(ray, p0, p1, p2, cullBackFaces, result) {
683
+ const t = IntersectionTests.rayTriangleParametric(
684
+ ray,
685
+ p0,
686
+ p1,
687
+ p2,
688
+ cullBackFaces
689
+ );
690
+ if (!defined_default(t) || t < 0) {
691
+ return void 0;
692
+ }
693
+ if (!defined_default(result)) {
694
+ result = new Cartesian3_default();
695
+ }
696
+ Cartesian3_default.multiplyByScalar(ray.direction, t, result);
697
+ return Cartesian3_default.add(ray.origin, result, result);
698
+ };
699
+ var scratchLineSegmentTriangleRay = new Ray_default();
700
+ IntersectionTests.lineSegmentTriangle = function(v0, v1, p0, p1, p2, cullBackFaces, result) {
701
+ if (!defined_default(v0)) {
702
+ throw new DeveloperError_default("v0 is required.");
703
+ }
704
+ if (!defined_default(v1)) {
705
+ throw new DeveloperError_default("v1 is required.");
706
+ }
707
+ if (!defined_default(p0)) {
708
+ throw new DeveloperError_default("p0 is required.");
709
+ }
710
+ if (!defined_default(p1)) {
711
+ throw new DeveloperError_default("p1 is required.");
712
+ }
713
+ if (!defined_default(p2)) {
714
+ throw new DeveloperError_default("p2 is required.");
715
+ }
716
+ const ray = scratchLineSegmentTriangleRay;
717
+ Cartesian3_default.clone(v0, ray.origin);
718
+ Cartesian3_default.subtract(v1, v0, ray.direction);
719
+ Cartesian3_default.normalize(ray.direction, ray.direction);
720
+ const t = IntersectionTests.rayTriangleParametric(
721
+ ray,
722
+ p0,
723
+ p1,
724
+ p2,
725
+ cullBackFaces
726
+ );
727
+ if (!defined_default(t) || t < 0 || t > Cartesian3_default.distance(v0, v1)) {
728
+ return void 0;
729
+ }
730
+ if (!defined_default(result)) {
731
+ result = new Cartesian3_default();
732
+ }
733
+ Cartesian3_default.multiplyByScalar(ray.direction, t, result);
734
+ return Cartesian3_default.add(ray.origin, result, result);
735
+ };
736
+ function solveQuadratic(a, b, c, result) {
737
+ const det = b * b - 4 * a * c;
738
+ if (det < 0) {
739
+ return void 0;
740
+ } else if (det > 0) {
741
+ const denom = 1 / (2 * a);
742
+ const disc = Math.sqrt(det);
743
+ const root0 = (-b + disc) * denom;
744
+ const root1 = (-b - disc) * denom;
745
+ if (root0 < root1) {
746
+ result.root0 = root0;
747
+ result.root1 = root1;
748
+ } else {
749
+ result.root0 = root1;
750
+ result.root1 = root0;
751
+ }
752
+ return result;
753
+ }
754
+ const root = -b / (2 * a);
755
+ if (root === 0) {
756
+ return void 0;
757
+ }
758
+ result.root0 = result.root1 = root;
759
+ return result;
760
+ }
761
+ var raySphereRoots = {
762
+ root0: 0,
763
+ root1: 0
764
+ };
765
+ function raySphere(ray, sphere, result) {
766
+ if (!defined_default(result)) {
767
+ result = new Interval_default();
768
+ }
769
+ const origin = ray.origin;
770
+ const direction = ray.direction;
771
+ const center = sphere.center;
772
+ const radiusSquared = sphere.radius * sphere.radius;
773
+ const diff = Cartesian3_default.subtract(origin, center, scratchPVec);
774
+ const a = Cartesian3_default.dot(direction, direction);
775
+ const b = 2 * Cartesian3_default.dot(direction, diff);
776
+ const c = Cartesian3_default.magnitudeSquared(diff) - radiusSquared;
777
+ const roots = solveQuadratic(a, b, c, raySphereRoots);
778
+ if (!defined_default(roots)) {
779
+ return void 0;
780
+ }
781
+ result.start = roots.root0;
782
+ result.stop = roots.root1;
783
+ return result;
784
+ }
785
+ IntersectionTests.raySphere = function(ray, sphere, result) {
786
+ if (!defined_default(ray)) {
787
+ throw new DeveloperError_default("ray is required.");
788
+ }
789
+ if (!defined_default(sphere)) {
790
+ throw new DeveloperError_default("sphere is required.");
791
+ }
792
+ result = raySphere(ray, sphere, result);
793
+ if (!defined_default(result) || result.stop < 0) {
794
+ return void 0;
795
+ }
796
+ result.start = Math.max(result.start, 0);
797
+ return result;
798
+ };
799
+ var scratchLineSegmentRay = new Ray_default();
800
+ IntersectionTests.lineSegmentSphere = function(p0, p1, sphere, result) {
801
+ if (!defined_default(p0)) {
802
+ throw new DeveloperError_default("p0 is required.");
803
+ }
804
+ if (!defined_default(p1)) {
805
+ throw new DeveloperError_default("p1 is required.");
806
+ }
807
+ if (!defined_default(sphere)) {
808
+ throw new DeveloperError_default("sphere is required.");
809
+ }
810
+ const ray = scratchLineSegmentRay;
811
+ Cartesian3_default.clone(p0, ray.origin);
812
+ const direction = Cartesian3_default.subtract(p1, p0, ray.direction);
813
+ const maxT = Cartesian3_default.magnitude(direction);
814
+ Cartesian3_default.normalize(direction, direction);
815
+ result = raySphere(ray, sphere, result);
816
+ if (!defined_default(result) || result.stop < 0 || result.start > maxT) {
817
+ return void 0;
818
+ }
819
+ result.start = Math.max(result.start, 0);
820
+ result.stop = Math.min(result.stop, maxT);
821
+ return result;
822
+ };
823
+ var scratchQ = new Cartesian3_default();
824
+ var scratchW = new Cartesian3_default();
825
+ IntersectionTests.rayEllipsoid = function(ray, ellipsoid) {
826
+ if (!defined_default(ray)) {
827
+ throw new DeveloperError_default("ray is required.");
828
+ }
829
+ if (!defined_default(ellipsoid)) {
830
+ throw new DeveloperError_default("ellipsoid is required.");
831
+ }
832
+ const inverseRadii = ellipsoid.oneOverRadii;
833
+ const q = Cartesian3_default.multiplyComponents(inverseRadii, ray.origin, scratchQ);
834
+ const w = Cartesian3_default.multiplyComponents(
835
+ inverseRadii,
836
+ ray.direction,
837
+ scratchW
838
+ );
839
+ const q2 = Cartesian3_default.magnitudeSquared(q);
840
+ const qw = Cartesian3_default.dot(q, w);
841
+ let difference, w2, product, discriminant, temp;
842
+ if (q2 > 1) {
843
+ if (qw >= 0) {
844
+ return void 0;
845
+ }
846
+ const qw2 = qw * qw;
847
+ difference = q2 - 1;
848
+ w2 = Cartesian3_default.magnitudeSquared(w);
849
+ product = w2 * difference;
850
+ if (qw2 < product) {
851
+ return void 0;
852
+ } else if (qw2 > product) {
853
+ discriminant = qw * qw - product;
854
+ temp = -qw + Math.sqrt(discriminant);
855
+ const root0 = temp / w2;
856
+ const root1 = difference / temp;
857
+ if (root0 < root1) {
858
+ return new Interval_default(root0, root1);
859
+ }
860
+ return {
861
+ start: root1,
862
+ stop: root0
863
+ };
864
+ }
865
+ const root = Math.sqrt(difference / w2);
866
+ return new Interval_default(root, root);
867
+ } else if (q2 < 1) {
868
+ difference = q2 - 1;
869
+ w2 = Cartesian3_default.magnitudeSquared(w);
870
+ product = w2 * difference;
871
+ discriminant = qw * qw - product;
872
+ temp = -qw + Math.sqrt(discriminant);
873
+ return new Interval_default(0, temp / w2);
874
+ }
875
+ if (qw < 0) {
876
+ w2 = Cartesian3_default.magnitudeSquared(w);
877
+ return new Interval_default(0, -qw / w2);
878
+ }
879
+ return void 0;
880
+ };
881
+ var scratchRayIntervalX = new Interval_default();
882
+ var scratchRayIntervalY = new Interval_default();
883
+ var scratchRayIntervalZ = new Interval_default();
884
+ IntersectionTests.rayAxisAlignedBoundingBox = function(ray, box, result) {
885
+ if (!defined_default(ray)) {
886
+ throw new DeveloperError_default("ray is required.");
887
+ }
888
+ if (!defined_default(box)) {
889
+ throw new DeveloperError_default("box is required.");
890
+ }
891
+ if (!defined_default(result)) {
892
+ result = new Interval_default();
893
+ }
894
+ const tx = rayIntervalAlongAABBAxis(
895
+ ray.origin.x,
896
+ ray.direction.x,
897
+ box.minimum.x,
898
+ box.maximum.x,
899
+ scratchRayIntervalX
900
+ );
901
+ const ty = rayIntervalAlongAABBAxis(
902
+ ray.origin.y,
903
+ ray.direction.y,
904
+ box.minimum.y,
905
+ box.maximum.y,
906
+ scratchRayIntervalY
907
+ );
908
+ const tz = rayIntervalAlongAABBAxis(
909
+ ray.origin.z,
910
+ ray.direction.z,
911
+ box.minimum.z,
912
+ box.maximum.z,
913
+ scratchRayIntervalZ
914
+ );
915
+ result.start = tx.start > ty.start ? tx.start : ty.start;
916
+ result.stop = tx.stop < ty.stop ? tx.stop : ty.stop;
917
+ if (tx.start > ty.stop || ty.start > tx.stop) {
918
+ return void 0;
919
+ }
920
+ if (result.start > tz.stop || tz.start > result.stop) {
921
+ return void 0;
922
+ }
923
+ if (tz.start > result.start) {
924
+ result.start = tz.start;
925
+ }
926
+ if (tz.stop < result.stop) {
927
+ result.stop = tz.stop;
928
+ }
929
+ return result;
930
+ };
931
+ function rayIntervalAlongAABBAxis(origin, direction, min, max, result) {
932
+ result.start = (min - origin) / direction;
933
+ result.stop = (max - origin) / direction;
934
+ if (result.stop < result.start) {
935
+ const tmp = result.stop;
936
+ result.stop = result.start;
937
+ result.start = tmp;
938
+ }
939
+ return result;
940
+ }
941
+ function addWithCancellationCheck2(left, right, tolerance) {
942
+ const difference = left + right;
943
+ if (Math_default.sign(left) !== Math_default.sign(right) && Math.abs(difference / Math.max(Math.abs(left), Math.abs(right))) < tolerance) {
944
+ return 0;
945
+ }
946
+ return difference;
947
+ }
948
+ IntersectionTests.quadraticVectorExpression = function(A, b, c, x, w) {
949
+ const xSquared = x * x;
950
+ const wSquared = w * w;
951
+ const l2 = (A[Matrix3_default.COLUMN1ROW1] - A[Matrix3_default.COLUMN2ROW2]) * wSquared;
952
+ const l1 = w * (x * addWithCancellationCheck2(
953
+ A[Matrix3_default.COLUMN1ROW0],
954
+ A[Matrix3_default.COLUMN0ROW1],
955
+ Math_default.EPSILON15
956
+ ) + b.y);
957
+ const l0 = A[Matrix3_default.COLUMN0ROW0] * xSquared + A[Matrix3_default.COLUMN2ROW2] * wSquared + x * b.x + c;
958
+ const r1 = wSquared * addWithCancellationCheck2(
959
+ A[Matrix3_default.COLUMN2ROW1],
960
+ A[Matrix3_default.COLUMN1ROW2],
961
+ Math_default.EPSILON15
962
+ );
963
+ const r0 = w * (x * addWithCancellationCheck2(A[Matrix3_default.COLUMN2ROW0], A[Matrix3_default.COLUMN0ROW2]) + b.z);
964
+ let cosines;
965
+ const solutions = [];
966
+ if (r0 === 0 && r1 === 0) {
967
+ cosines = QuadraticRealPolynomial_default.computeRealRoots(l2, l1, l0);
968
+ if (cosines.length === 0) {
969
+ return solutions;
970
+ }
971
+ const cosine0 = cosines[0];
972
+ const sine0 = Math.sqrt(Math.max(1 - cosine0 * cosine0, 0));
973
+ solutions.push(new Cartesian3_default(x, w * cosine0, w * -sine0));
974
+ solutions.push(new Cartesian3_default(x, w * cosine0, w * sine0));
975
+ if (cosines.length === 2) {
976
+ const cosine1 = cosines[1];
977
+ const sine1 = Math.sqrt(Math.max(1 - cosine1 * cosine1, 0));
978
+ solutions.push(new Cartesian3_default(x, w * cosine1, w * -sine1));
979
+ solutions.push(new Cartesian3_default(x, w * cosine1, w * sine1));
980
+ }
981
+ return solutions;
982
+ }
983
+ const r0Squared = r0 * r0;
984
+ const r1Squared = r1 * r1;
985
+ const l2Squared = l2 * l2;
986
+ const r0r1 = r0 * r1;
987
+ const c4 = l2Squared + r1Squared;
988
+ const c3 = 2 * (l1 * l2 + r0r1);
989
+ const c2 = 2 * l0 * l2 + l1 * l1 - r1Squared + r0Squared;
990
+ const c1 = 2 * (l0 * l1 - r0r1);
991
+ const c0 = l0 * l0 - r0Squared;
992
+ if (c4 === 0 && c3 === 0 && c2 === 0 && c1 === 0) {
993
+ return solutions;
994
+ }
995
+ cosines = QuarticRealPolynomial_default.computeRealRoots(c4, c3, c2, c1, c0);
996
+ const length = cosines.length;
997
+ if (length === 0) {
998
+ return solutions;
999
+ }
1000
+ for (let i = 0; i < length; ++i) {
1001
+ const cosine = cosines[i];
1002
+ const cosineSquared = cosine * cosine;
1003
+ const sineSquared = Math.max(1 - cosineSquared, 0);
1004
+ const sine = Math.sqrt(sineSquared);
1005
+ let left;
1006
+ if (Math_default.sign(l2) === Math_default.sign(l0)) {
1007
+ left = addWithCancellationCheck2(
1008
+ l2 * cosineSquared + l0,
1009
+ l1 * cosine,
1010
+ Math_default.EPSILON12
1011
+ );
1012
+ } else if (Math_default.sign(l0) === Math_default.sign(l1 * cosine)) {
1013
+ left = addWithCancellationCheck2(
1014
+ l2 * cosineSquared,
1015
+ l1 * cosine + l0,
1016
+ Math_default.EPSILON12
1017
+ );
1018
+ } else {
1019
+ left = addWithCancellationCheck2(
1020
+ l2 * cosineSquared + l1 * cosine,
1021
+ l0,
1022
+ Math_default.EPSILON12
1023
+ );
1024
+ }
1025
+ const right = addWithCancellationCheck2(
1026
+ r1 * cosine,
1027
+ r0,
1028
+ Math_default.EPSILON15
1029
+ );
1030
+ const product = left * right;
1031
+ if (product < 0) {
1032
+ solutions.push(new Cartesian3_default(x, w * cosine, w * sine));
1033
+ } else if (product > 0) {
1034
+ solutions.push(new Cartesian3_default(x, w * cosine, w * -sine));
1035
+ } else if (sine !== 0) {
1036
+ solutions.push(new Cartesian3_default(x, w * cosine, w * -sine));
1037
+ solutions.push(new Cartesian3_default(x, w * cosine, w * sine));
1038
+ ++i;
1039
+ } else {
1040
+ solutions.push(new Cartesian3_default(x, w * cosine, w * sine));
1041
+ }
1042
+ }
1043
+ return solutions;
1044
+ };
1045
+ var firstAxisScratch = new Cartesian3_default();
1046
+ var secondAxisScratch = new Cartesian3_default();
1047
+ var thirdAxisScratch = new Cartesian3_default();
1048
+ var referenceScratch = new Cartesian3_default();
1049
+ var bCart = new Cartesian3_default();
1050
+ var bScratch = new Matrix3_default();
1051
+ var btScratch = new Matrix3_default();
1052
+ var diScratch = new Matrix3_default();
1053
+ var dScratch = new Matrix3_default();
1054
+ var cScratch = new Matrix3_default();
1055
+ var tempMatrix = new Matrix3_default();
1056
+ var aScratch = new Matrix3_default();
1057
+ var sScratch = new Cartesian3_default();
1058
+ var closestScratch = new Cartesian3_default();
1059
+ var surfPointScratch = new Cartographic_default();
1060
+ IntersectionTests.grazingAltitudeLocation = function(ray, ellipsoid) {
1061
+ if (!defined_default(ray)) {
1062
+ throw new DeveloperError_default("ray is required.");
1063
+ }
1064
+ if (!defined_default(ellipsoid)) {
1065
+ throw new DeveloperError_default("ellipsoid is required.");
1066
+ }
1067
+ const position = ray.origin;
1068
+ const direction = ray.direction;
1069
+ if (!Cartesian3_default.equals(position, Cartesian3_default.ZERO)) {
1070
+ const normal = ellipsoid.geodeticSurfaceNormal(position, firstAxisScratch);
1071
+ if (Cartesian3_default.dot(direction, normal) >= 0) {
1072
+ return position;
1073
+ }
1074
+ }
1075
+ const intersects = defined_default(this.rayEllipsoid(ray, ellipsoid));
1076
+ const f = ellipsoid.transformPositionToScaledSpace(
1077
+ direction,
1078
+ firstAxisScratch
1079
+ );
1080
+ const firstAxis = Cartesian3_default.normalize(f, f);
1081
+ const reference = Cartesian3_default.mostOrthogonalAxis(f, referenceScratch);
1082
+ const secondAxis = Cartesian3_default.normalize(
1083
+ Cartesian3_default.cross(reference, firstAxis, secondAxisScratch),
1084
+ secondAxisScratch
1085
+ );
1086
+ const thirdAxis = Cartesian3_default.normalize(
1087
+ Cartesian3_default.cross(firstAxis, secondAxis, thirdAxisScratch),
1088
+ thirdAxisScratch
1089
+ );
1090
+ const B = bScratch;
1091
+ B[0] = firstAxis.x;
1092
+ B[1] = firstAxis.y;
1093
+ B[2] = firstAxis.z;
1094
+ B[3] = secondAxis.x;
1095
+ B[4] = secondAxis.y;
1096
+ B[5] = secondAxis.z;
1097
+ B[6] = thirdAxis.x;
1098
+ B[7] = thirdAxis.y;
1099
+ B[8] = thirdAxis.z;
1100
+ const B_T = Matrix3_default.transpose(B, btScratch);
1101
+ const D_I = Matrix3_default.fromScale(ellipsoid.radii, diScratch);
1102
+ const D = Matrix3_default.fromScale(ellipsoid.oneOverRadii, dScratch);
1103
+ const C = cScratch;
1104
+ C[0] = 0;
1105
+ C[1] = -direction.z;
1106
+ C[2] = direction.y;
1107
+ C[3] = direction.z;
1108
+ C[4] = 0;
1109
+ C[5] = -direction.x;
1110
+ C[6] = -direction.y;
1111
+ C[7] = direction.x;
1112
+ C[8] = 0;
1113
+ const temp = Matrix3_default.multiply(
1114
+ Matrix3_default.multiply(B_T, D, tempMatrix),
1115
+ C,
1116
+ tempMatrix
1117
+ );
1118
+ const A = Matrix3_default.multiply(
1119
+ Matrix3_default.multiply(temp, D_I, aScratch),
1120
+ B,
1121
+ aScratch
1122
+ );
1123
+ const b = Matrix3_default.multiplyByVector(temp, position, bCart);
1124
+ const solutions = IntersectionTests.quadraticVectorExpression(
1125
+ A,
1126
+ Cartesian3_default.negate(b, firstAxisScratch),
1127
+ 0,
1128
+ 0,
1129
+ 1
1130
+ );
1131
+ let s;
1132
+ let altitude;
1133
+ const length = solutions.length;
1134
+ if (length > 0) {
1135
+ let closest = Cartesian3_default.clone(Cartesian3_default.ZERO, closestScratch);
1136
+ let maximumValue = Number.NEGATIVE_INFINITY;
1137
+ for (let i = 0; i < length; ++i) {
1138
+ s = Matrix3_default.multiplyByVector(
1139
+ D_I,
1140
+ Matrix3_default.multiplyByVector(B, solutions[i], sScratch),
1141
+ sScratch
1142
+ );
1143
+ const v = Cartesian3_default.normalize(
1144
+ Cartesian3_default.subtract(s, position, referenceScratch),
1145
+ referenceScratch
1146
+ );
1147
+ const dotProduct = Cartesian3_default.dot(v, direction);
1148
+ if (dotProduct > maximumValue) {
1149
+ maximumValue = dotProduct;
1150
+ closest = Cartesian3_default.clone(s, closest);
1151
+ }
1152
+ }
1153
+ const surfacePoint = ellipsoid.cartesianToCartographic(
1154
+ closest,
1155
+ surfPointScratch
1156
+ );
1157
+ maximumValue = Math_default.clamp(maximumValue, 0, 1);
1158
+ altitude = Cartesian3_default.magnitude(
1159
+ Cartesian3_default.subtract(closest, position, referenceScratch)
1160
+ ) * Math.sqrt(1 - maximumValue * maximumValue);
1161
+ altitude = intersects ? -altitude : altitude;
1162
+ surfacePoint.height = altitude;
1163
+ return ellipsoid.cartographicToCartesian(surfacePoint, new Cartesian3_default());
1164
+ }
1165
+ return void 0;
1166
+ };
1167
+ var lineSegmentPlaneDifference = new Cartesian3_default();
1168
+ IntersectionTests.lineSegmentPlane = function(endPoint0, endPoint1, plane, result) {
1169
+ if (!defined_default(endPoint0)) {
1170
+ throw new DeveloperError_default("endPoint0 is required.");
1171
+ }
1172
+ if (!defined_default(endPoint1)) {
1173
+ throw new DeveloperError_default("endPoint1 is required.");
1174
+ }
1175
+ if (!defined_default(plane)) {
1176
+ throw new DeveloperError_default("plane is required.");
1177
+ }
1178
+ if (!defined_default(result)) {
1179
+ result = new Cartesian3_default();
1180
+ }
1181
+ const difference = Cartesian3_default.subtract(
1182
+ endPoint1,
1183
+ endPoint0,
1184
+ lineSegmentPlaneDifference
1185
+ );
1186
+ const normal = plane.normal;
1187
+ const nDotDiff = Cartesian3_default.dot(normal, difference);
1188
+ if (Math.abs(nDotDiff) < Math_default.EPSILON6) {
1189
+ return void 0;
1190
+ }
1191
+ const nDotP0 = Cartesian3_default.dot(normal, endPoint0);
1192
+ const t = -(plane.distance + nDotP0) / nDotDiff;
1193
+ if (t < 0 || t > 1) {
1194
+ return void 0;
1195
+ }
1196
+ Cartesian3_default.multiplyByScalar(difference, t, result);
1197
+ Cartesian3_default.add(endPoint0, result, result);
1198
+ return result;
1199
+ };
1200
+ IntersectionTests.trianglePlaneIntersection = function(p0, p1, p2, plane) {
1201
+ if (!defined_default(p0) || !defined_default(p1) || !defined_default(p2) || !defined_default(plane)) {
1202
+ throw new DeveloperError_default("p0, p1, p2, and plane are required.");
1203
+ }
1204
+ const planeNormal = plane.normal;
1205
+ const planeD = plane.distance;
1206
+ const p0Behind = Cartesian3_default.dot(planeNormal, p0) + planeD < 0;
1207
+ const p1Behind = Cartesian3_default.dot(planeNormal, p1) + planeD < 0;
1208
+ const p2Behind = Cartesian3_default.dot(planeNormal, p2) + planeD < 0;
1209
+ let numBehind = 0;
1210
+ numBehind += p0Behind ? 1 : 0;
1211
+ numBehind += p1Behind ? 1 : 0;
1212
+ numBehind += p2Behind ? 1 : 0;
1213
+ let u1, u2;
1214
+ if (numBehind === 1 || numBehind === 2) {
1215
+ u1 = new Cartesian3_default();
1216
+ u2 = new Cartesian3_default();
1217
+ }
1218
+ if (numBehind === 1) {
1219
+ if (p0Behind) {
1220
+ IntersectionTests.lineSegmentPlane(p0, p1, plane, u1);
1221
+ IntersectionTests.lineSegmentPlane(p0, p2, plane, u2);
1222
+ return {
1223
+ positions: [p0, p1, p2, u1, u2],
1224
+ indices: [
1225
+ // Behind
1226
+ 0,
1227
+ 3,
1228
+ 4,
1229
+ // In front
1230
+ 1,
1231
+ 2,
1232
+ 4,
1233
+ 1,
1234
+ 4,
1235
+ 3
1236
+ ]
1237
+ };
1238
+ } else if (p1Behind) {
1239
+ IntersectionTests.lineSegmentPlane(p1, p2, plane, u1);
1240
+ IntersectionTests.lineSegmentPlane(p1, p0, plane, u2);
1241
+ return {
1242
+ positions: [p0, p1, p2, u1, u2],
1243
+ indices: [
1244
+ // Behind
1245
+ 1,
1246
+ 3,
1247
+ 4,
1248
+ // In front
1249
+ 2,
1250
+ 0,
1251
+ 4,
1252
+ 2,
1253
+ 4,
1254
+ 3
1255
+ ]
1256
+ };
1257
+ } else if (p2Behind) {
1258
+ IntersectionTests.lineSegmentPlane(p2, p0, plane, u1);
1259
+ IntersectionTests.lineSegmentPlane(p2, p1, plane, u2);
1260
+ return {
1261
+ positions: [p0, p1, p2, u1, u2],
1262
+ indices: [
1263
+ // Behind
1264
+ 2,
1265
+ 3,
1266
+ 4,
1267
+ // In front
1268
+ 0,
1269
+ 1,
1270
+ 4,
1271
+ 0,
1272
+ 4,
1273
+ 3
1274
+ ]
1275
+ };
1276
+ }
1277
+ } else if (numBehind === 2) {
1278
+ if (!p0Behind) {
1279
+ IntersectionTests.lineSegmentPlane(p1, p0, plane, u1);
1280
+ IntersectionTests.lineSegmentPlane(p2, p0, plane, u2);
1281
+ return {
1282
+ positions: [p0, p1, p2, u1, u2],
1283
+ indices: [
1284
+ // Behind
1285
+ 1,
1286
+ 2,
1287
+ 4,
1288
+ 1,
1289
+ 4,
1290
+ 3,
1291
+ // In front
1292
+ 0,
1293
+ 3,
1294
+ 4
1295
+ ]
1296
+ };
1297
+ } else if (!p1Behind) {
1298
+ IntersectionTests.lineSegmentPlane(p2, p1, plane, u1);
1299
+ IntersectionTests.lineSegmentPlane(p0, p1, plane, u2);
1300
+ return {
1301
+ positions: [p0, p1, p2, u1, u2],
1302
+ indices: [
1303
+ // Behind
1304
+ 2,
1305
+ 0,
1306
+ 4,
1307
+ 2,
1308
+ 4,
1309
+ 3,
1310
+ // In front
1311
+ 1,
1312
+ 3,
1313
+ 4
1314
+ ]
1315
+ };
1316
+ } else if (!p2Behind) {
1317
+ IntersectionTests.lineSegmentPlane(p0, p2, plane, u1);
1318
+ IntersectionTests.lineSegmentPlane(p1, p2, plane, u2);
1319
+ return {
1320
+ positions: [p0, p1, p2, u1, u2],
1321
+ indices: [
1322
+ // Behind
1323
+ 0,
1324
+ 1,
1325
+ 4,
1326
+ 0,
1327
+ 4,
1328
+ 3,
1329
+ // In front
1330
+ 2,
1331
+ 3,
1332
+ 4
1333
+ ]
1334
+ };
1335
+ }
1336
+ }
1337
+ return void 0;
1338
+ };
1339
+ var IntersectionTests_default = IntersectionTests;
1340
+
1341
+ export {
1342
+ Ray_default,
1343
+ IntersectionTests_default
1344
+ };