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,1483 @@
1
+ /**
2
+ * @license
3
+ * Cesium - https://github.com/CesiumGS/cesium
4
+ * Version 0.1.4
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
+ VertexFormat_default
28
+ } from "./chunk-OZ3CQDO3.js";
29
+ import {
30
+ Plane_default
31
+ } from "./chunk-KOTWWQN7.js";
32
+ import {
33
+ GeometryAttributes_default
34
+ } from "./chunk-OMMRNMXF.js";
35
+ import {
36
+ GeometryAttribute_default,
37
+ Geometry_default,
38
+ PrimitiveType_default
39
+ } from "./chunk-7AMRE57Q.js";
40
+ import {
41
+ BoundingSphere_default
42
+ } from "./chunk-ODZYB26X.js";
43
+ import {
44
+ Intersect_default
45
+ } from "./chunk-ANOA7E7F.js";
46
+ import {
47
+ Quaternion_default
48
+ } from "./chunk-BR3BPM64.js";
49
+ import {
50
+ Cartesian4_default,
51
+ Matrix4_default
52
+ } from "./chunk-OEHJY463.js";
53
+ import {
54
+ ComponentDatatype_default
55
+ } from "./chunk-C5BO2JCG.js";
56
+ import {
57
+ Cartesian3_default,
58
+ Frozen_default,
59
+ Matrix3_default
60
+ } from "./chunk-J4PISUNT.js";
61
+ import {
62
+ Math_default
63
+ } from "./chunk-VQH2YXO2.js";
64
+ import {
65
+ Check_default,
66
+ DeveloperError_default
67
+ } from "./chunk-KWV6ZTF4.js";
68
+ import {
69
+ defined_default
70
+ } from "./chunk-MRMNELAH.js";
71
+
72
+ // packages/engine/Source/Core/CullingVolume.js
73
+ function CullingVolume(planes) {
74
+ this.planes = planes ?? [];
75
+ }
76
+ var faces = [new Cartesian3_default(), new Cartesian3_default(), new Cartesian3_default()];
77
+ Cartesian3_default.clone(Cartesian3_default.UNIT_X, faces[0]);
78
+ Cartesian3_default.clone(Cartesian3_default.UNIT_Y, faces[1]);
79
+ Cartesian3_default.clone(Cartesian3_default.UNIT_Z, faces[2]);
80
+ var scratchPlaneCenter = new Cartesian3_default();
81
+ var scratchPlaneNormal = new Cartesian3_default();
82
+ var scratchPlane = new Plane_default(new Cartesian3_default(1, 0, 0), 0);
83
+ CullingVolume.fromBoundingSphere = function(boundingSphere, result) {
84
+ if (!defined_default(boundingSphere)) {
85
+ throw new DeveloperError_default("boundingSphere is required.");
86
+ }
87
+ if (!defined_default(result)) {
88
+ result = new CullingVolume();
89
+ }
90
+ const length = faces.length;
91
+ const planes = result.planes;
92
+ planes.length = 2 * length;
93
+ const center = boundingSphere.center;
94
+ const radius = boundingSphere.radius;
95
+ let planeIndex = 0;
96
+ for (let i = 0; i < length; ++i) {
97
+ const faceNormal = faces[i];
98
+ let plane0 = planes[planeIndex];
99
+ let plane1 = planes[planeIndex + 1];
100
+ if (!defined_default(plane0)) {
101
+ plane0 = planes[planeIndex] = new Cartesian4_default();
102
+ }
103
+ if (!defined_default(plane1)) {
104
+ plane1 = planes[planeIndex + 1] = new Cartesian4_default();
105
+ }
106
+ Cartesian3_default.multiplyByScalar(faceNormal, -radius, scratchPlaneCenter);
107
+ Cartesian3_default.add(center, scratchPlaneCenter, scratchPlaneCenter);
108
+ plane0.x = faceNormal.x;
109
+ plane0.y = faceNormal.y;
110
+ plane0.z = faceNormal.z;
111
+ plane0.w = -Cartesian3_default.dot(faceNormal, scratchPlaneCenter);
112
+ Cartesian3_default.multiplyByScalar(faceNormal, radius, scratchPlaneCenter);
113
+ Cartesian3_default.add(center, scratchPlaneCenter, scratchPlaneCenter);
114
+ plane1.x = -faceNormal.x;
115
+ plane1.y = -faceNormal.y;
116
+ plane1.z = -faceNormal.z;
117
+ plane1.w = -Cartesian3_default.dot(
118
+ Cartesian3_default.negate(faceNormal, scratchPlaneNormal),
119
+ scratchPlaneCenter
120
+ );
121
+ planeIndex += 2;
122
+ }
123
+ return result;
124
+ };
125
+ CullingVolume.prototype.computeVisibility = function(boundingVolume) {
126
+ if (!defined_default(boundingVolume)) {
127
+ throw new DeveloperError_default("boundingVolume is required.");
128
+ }
129
+ const planes = this.planes;
130
+ let intersecting = false;
131
+ for (let k = 0, len = planes.length; k < len; ++k) {
132
+ const result = boundingVolume.intersectPlane(
133
+ Plane_default.fromCartesian4(planes[k], scratchPlane)
134
+ );
135
+ if (result === Intersect_default.OUTSIDE) {
136
+ return Intersect_default.OUTSIDE;
137
+ } else if (result === Intersect_default.INTERSECTING) {
138
+ intersecting = true;
139
+ }
140
+ }
141
+ return intersecting ? Intersect_default.INTERSECTING : Intersect_default.INSIDE;
142
+ };
143
+ CullingVolume.prototype.computeVisibilityWithPlaneMask = function(boundingVolume, parentPlaneMask) {
144
+ if (!defined_default(boundingVolume)) {
145
+ throw new DeveloperError_default("boundingVolume is required.");
146
+ }
147
+ if (!defined_default(parentPlaneMask)) {
148
+ throw new DeveloperError_default("parentPlaneMask is required.");
149
+ }
150
+ if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
151
+ return parentPlaneMask;
152
+ }
153
+ let mask = CullingVolume.MASK_INSIDE;
154
+ const planes = this.planes;
155
+ for (let k = 0, len = planes.length; k < len; ++k) {
156
+ const flag = k < 31 ? 1 << k : 0;
157
+ if (k < 31 && (parentPlaneMask & flag) === 0) {
158
+ continue;
159
+ }
160
+ const result = boundingVolume.intersectPlane(
161
+ Plane_default.fromCartesian4(planes[k], scratchPlane)
162
+ );
163
+ if (result === Intersect_default.OUTSIDE) {
164
+ return CullingVolume.MASK_OUTSIDE;
165
+ } else if (result === Intersect_default.INTERSECTING) {
166
+ mask |= flag;
167
+ }
168
+ }
169
+ return mask;
170
+ };
171
+ CullingVolume.MASK_OUTSIDE = 4294967295;
172
+ CullingVolume.MASK_INSIDE = 0;
173
+ CullingVolume.MASK_INDETERMINATE = 2147483647;
174
+ var CullingVolume_default = CullingVolume;
175
+
176
+ // packages/engine/Source/Core/OrthographicOffCenterFrustum.js
177
+ function OrthographicOffCenterFrustum(options) {
178
+ options = options ?? Frozen_default.EMPTY_OBJECT;
179
+ this.left = options.left;
180
+ this._left = void 0;
181
+ this.right = options.right;
182
+ this._right = void 0;
183
+ this.top = options.top;
184
+ this._top = void 0;
185
+ this.bottom = options.bottom;
186
+ this._bottom = void 0;
187
+ this.near = options.near ?? 1;
188
+ this._near = this.near;
189
+ this.far = options.far ?? 5e8;
190
+ this._far = this.far;
191
+ this._cullingVolume = new CullingVolume_default();
192
+ this._orthographicMatrix = new Matrix4_default();
193
+ }
194
+ function update(frustum) {
195
+ if (!defined_default(frustum.right) || !defined_default(frustum.left) || !defined_default(frustum.top) || !defined_default(frustum.bottom) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
196
+ throw new DeveloperError_default(
197
+ "right, left, top, bottom, near, or far parameters are not set."
198
+ );
199
+ }
200
+ if (frustum.top !== frustum._top || frustum.bottom !== frustum._bottom || frustum.left !== frustum._left || frustum.right !== frustum._right || frustum.near !== frustum._near || frustum.far !== frustum._far) {
201
+ if (frustum.left > frustum.right) {
202
+ throw new DeveloperError_default("right must be greater than left.");
203
+ }
204
+ if (frustum.bottom > frustum.top) {
205
+ throw new DeveloperError_default("top must be greater than bottom.");
206
+ }
207
+ if (frustum.near <= 0 || frustum.near > frustum.far) {
208
+ throw new DeveloperError_default(
209
+ "near must be greater than zero and less than far."
210
+ );
211
+ }
212
+ frustum._left = frustum.left;
213
+ frustum._right = frustum.right;
214
+ frustum._top = frustum.top;
215
+ frustum._bottom = frustum.bottom;
216
+ frustum._near = frustum.near;
217
+ frustum._far = frustum.far;
218
+ frustum._orthographicMatrix = Matrix4_default.computeOrthographicOffCenter(
219
+ frustum.left,
220
+ frustum.right,
221
+ frustum.bottom,
222
+ frustum.top,
223
+ frustum.near,
224
+ frustum.far,
225
+ frustum._orthographicMatrix
226
+ );
227
+ }
228
+ }
229
+ Object.defineProperties(OrthographicOffCenterFrustum.prototype, {
230
+ /**
231
+ * Gets the orthographic projection matrix computed from the view frustum.
232
+ * @memberof OrthographicOffCenterFrustum.prototype
233
+ * @type {Matrix4}
234
+ * @readonly
235
+ */
236
+ projectionMatrix: {
237
+ get: function() {
238
+ update(this);
239
+ return this._orthographicMatrix;
240
+ }
241
+ }
242
+ });
243
+ var getPlanesRight = new Cartesian3_default();
244
+ var getPlanesNearCenter = new Cartesian3_default();
245
+ var getPlanesPoint = new Cartesian3_default();
246
+ var negateScratch = new Cartesian3_default();
247
+ OrthographicOffCenterFrustum.prototype.computeCullingVolume = function(position, direction, up) {
248
+ if (!defined_default(position)) {
249
+ throw new DeveloperError_default("position is required.");
250
+ }
251
+ if (!defined_default(direction)) {
252
+ throw new DeveloperError_default("direction is required.");
253
+ }
254
+ if (!defined_default(up)) {
255
+ throw new DeveloperError_default("up is required.");
256
+ }
257
+ const planes = this._cullingVolume.planes;
258
+ const t = this.top;
259
+ const b = this.bottom;
260
+ const r = this.right;
261
+ const l = this.left;
262
+ const n = this.near;
263
+ const f = this.far;
264
+ const right = Cartesian3_default.cross(direction, up, getPlanesRight);
265
+ Cartesian3_default.normalize(right, right);
266
+ const nearCenter = getPlanesNearCenter;
267
+ Cartesian3_default.multiplyByScalar(direction, n, nearCenter);
268
+ Cartesian3_default.add(position, nearCenter, nearCenter);
269
+ const point = getPlanesPoint;
270
+ Cartesian3_default.multiplyByScalar(right, l, point);
271
+ Cartesian3_default.add(nearCenter, point, point);
272
+ let plane = planes[0];
273
+ if (!defined_default(plane)) {
274
+ plane = planes[0] = new Cartesian4_default();
275
+ }
276
+ plane.x = right.x;
277
+ plane.y = right.y;
278
+ plane.z = right.z;
279
+ plane.w = -Cartesian3_default.dot(right, point);
280
+ Cartesian3_default.multiplyByScalar(right, r, point);
281
+ Cartesian3_default.add(nearCenter, point, point);
282
+ plane = planes[1];
283
+ if (!defined_default(plane)) {
284
+ plane = planes[1] = new Cartesian4_default();
285
+ }
286
+ plane.x = -right.x;
287
+ plane.y = -right.y;
288
+ plane.z = -right.z;
289
+ plane.w = -Cartesian3_default.dot(Cartesian3_default.negate(right, negateScratch), point);
290
+ Cartesian3_default.multiplyByScalar(up, b, point);
291
+ Cartesian3_default.add(nearCenter, point, point);
292
+ plane = planes[2];
293
+ if (!defined_default(plane)) {
294
+ plane = planes[2] = new Cartesian4_default();
295
+ }
296
+ plane.x = up.x;
297
+ plane.y = up.y;
298
+ plane.z = up.z;
299
+ plane.w = -Cartesian3_default.dot(up, point);
300
+ Cartesian3_default.multiplyByScalar(up, t, point);
301
+ Cartesian3_default.add(nearCenter, point, point);
302
+ plane = planes[3];
303
+ if (!defined_default(plane)) {
304
+ plane = planes[3] = new Cartesian4_default();
305
+ }
306
+ plane.x = -up.x;
307
+ plane.y = -up.y;
308
+ plane.z = -up.z;
309
+ plane.w = -Cartesian3_default.dot(Cartesian3_default.negate(up, negateScratch), point);
310
+ plane = planes[4];
311
+ if (!defined_default(plane)) {
312
+ plane = planes[4] = new Cartesian4_default();
313
+ }
314
+ plane.x = direction.x;
315
+ plane.y = direction.y;
316
+ plane.z = direction.z;
317
+ plane.w = -Cartesian3_default.dot(direction, nearCenter);
318
+ Cartesian3_default.multiplyByScalar(direction, f, point);
319
+ Cartesian3_default.add(position, point, point);
320
+ plane = planes[5];
321
+ if (!defined_default(plane)) {
322
+ plane = planes[5] = new Cartesian4_default();
323
+ }
324
+ plane.x = -direction.x;
325
+ plane.y = -direction.y;
326
+ plane.z = -direction.z;
327
+ plane.w = -Cartesian3_default.dot(Cartesian3_default.negate(direction, negateScratch), point);
328
+ return this._cullingVolume;
329
+ };
330
+ OrthographicOffCenterFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance, pixelRatio, result) {
331
+ update(this);
332
+ if (!defined_default(drawingBufferWidth) || !defined_default(drawingBufferHeight)) {
333
+ throw new DeveloperError_default(
334
+ "Both drawingBufferWidth and drawingBufferHeight are required."
335
+ );
336
+ }
337
+ if (drawingBufferWidth <= 0) {
338
+ throw new DeveloperError_default("drawingBufferWidth must be greater than zero.");
339
+ }
340
+ if (drawingBufferHeight <= 0) {
341
+ throw new DeveloperError_default("drawingBufferHeight must be greater than zero.");
342
+ }
343
+ if (!defined_default(distance)) {
344
+ throw new DeveloperError_default("distance is required.");
345
+ }
346
+ if (!defined_default(pixelRatio)) {
347
+ throw new DeveloperError_default("pixelRatio is required.");
348
+ }
349
+ if (pixelRatio <= 0) {
350
+ throw new DeveloperError_default("pixelRatio must be greater than zero.");
351
+ }
352
+ if (!defined_default(result)) {
353
+ throw new DeveloperError_default("A result object is required.");
354
+ }
355
+ const frustumWidth = this.right - this.left;
356
+ const frustumHeight = this.top - this.bottom;
357
+ const pixelWidth = pixelRatio * frustumWidth / drawingBufferWidth;
358
+ const pixelHeight = pixelRatio * frustumHeight / drawingBufferHeight;
359
+ result.x = pixelWidth;
360
+ result.y = pixelHeight;
361
+ return result;
362
+ };
363
+ OrthographicOffCenterFrustum.prototype.clone = function(result) {
364
+ if (!defined_default(result)) {
365
+ result = new OrthographicOffCenterFrustum();
366
+ }
367
+ result.left = this.left;
368
+ result.right = this.right;
369
+ result.top = this.top;
370
+ result.bottom = this.bottom;
371
+ result.near = this.near;
372
+ result.far = this.far;
373
+ result._left = void 0;
374
+ result._right = void 0;
375
+ result._top = void 0;
376
+ result._bottom = void 0;
377
+ result._near = void 0;
378
+ result._far = void 0;
379
+ return result;
380
+ };
381
+ OrthographicOffCenterFrustum.prototype.equals = function(other) {
382
+ return defined_default(other) && other instanceof OrthographicOffCenterFrustum && this.right === other.right && this.left === other.left && this.top === other.top && this.bottom === other.bottom && this.near === other.near && this.far === other.far;
383
+ };
384
+ OrthographicOffCenterFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
385
+ return other === this || defined_default(other) && other instanceof OrthographicOffCenterFrustum && Math_default.equalsEpsilon(
386
+ this.right,
387
+ other.right,
388
+ relativeEpsilon,
389
+ absoluteEpsilon
390
+ ) && Math_default.equalsEpsilon(
391
+ this.left,
392
+ other.left,
393
+ relativeEpsilon,
394
+ absoluteEpsilon
395
+ ) && Math_default.equalsEpsilon(
396
+ this.top,
397
+ other.top,
398
+ relativeEpsilon,
399
+ absoluteEpsilon
400
+ ) && Math_default.equalsEpsilon(
401
+ this.bottom,
402
+ other.bottom,
403
+ relativeEpsilon,
404
+ absoluteEpsilon
405
+ ) && Math_default.equalsEpsilon(
406
+ this.near,
407
+ other.near,
408
+ relativeEpsilon,
409
+ absoluteEpsilon
410
+ ) && Math_default.equalsEpsilon(
411
+ this.far,
412
+ other.far,
413
+ relativeEpsilon,
414
+ absoluteEpsilon
415
+ );
416
+ };
417
+ var OrthographicOffCenterFrustum_default = OrthographicOffCenterFrustum;
418
+
419
+ // packages/engine/Source/Core/OrthographicFrustum.js
420
+ function OrthographicFrustum(options) {
421
+ options = options ?? Frozen_default.EMPTY_OBJECT;
422
+ this._offCenterFrustum = new OrthographicOffCenterFrustum_default();
423
+ this.width = options.width;
424
+ this._width = void 0;
425
+ this.aspectRatio = options.aspectRatio;
426
+ this._aspectRatio = void 0;
427
+ this.near = options.near ?? 1;
428
+ this._near = this.near;
429
+ this.far = options.far ?? 5e8;
430
+ this._far = this.far;
431
+ }
432
+ OrthographicFrustum.packedLength = 4;
433
+ OrthographicFrustum.pack = function(value, array, startingIndex) {
434
+ Check_default.typeOf.object("value", value);
435
+ Check_default.defined("array", array);
436
+ startingIndex = startingIndex ?? 0;
437
+ array[startingIndex++] = value.width;
438
+ array[startingIndex++] = value.aspectRatio;
439
+ array[startingIndex++] = value.near;
440
+ array[startingIndex] = value.far;
441
+ return array;
442
+ };
443
+ OrthographicFrustum.unpack = function(array, startingIndex, result) {
444
+ Check_default.defined("array", array);
445
+ startingIndex = startingIndex ?? 0;
446
+ if (!defined_default(result)) {
447
+ result = new OrthographicFrustum();
448
+ }
449
+ result.width = array[startingIndex++];
450
+ result.aspectRatio = array[startingIndex++];
451
+ result.near = array[startingIndex++];
452
+ result.far = array[startingIndex];
453
+ return result;
454
+ };
455
+ function update2(frustum) {
456
+ if (!defined_default(frustum.width) || !defined_default(frustum.aspectRatio) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
457
+ throw new DeveloperError_default(
458
+ "width, aspectRatio, near, or far parameters are not set."
459
+ );
460
+ }
461
+ const f = frustum._offCenterFrustum;
462
+ if (frustum.width !== frustum._width || frustum.aspectRatio !== frustum._aspectRatio || frustum.near !== frustum._near || frustum.far !== frustum._far) {
463
+ if (frustum.aspectRatio < 0) {
464
+ throw new DeveloperError_default("aspectRatio must be positive.");
465
+ }
466
+ if (frustum.near < 0 || frustum.near > frustum.far) {
467
+ throw new DeveloperError_default(
468
+ "near must be greater than zero and less than far."
469
+ );
470
+ }
471
+ frustum._aspectRatio = frustum.aspectRatio;
472
+ frustum._width = frustum.width;
473
+ frustum._near = frustum.near;
474
+ frustum._far = frustum.far;
475
+ const ratio = 1 / frustum.aspectRatio;
476
+ f.right = frustum.width * 0.5;
477
+ f.left = -f.right;
478
+ f.top = ratio * f.right;
479
+ f.bottom = -f.top;
480
+ f.near = frustum.near;
481
+ f.far = frustum.far;
482
+ }
483
+ }
484
+ Object.defineProperties(OrthographicFrustum.prototype, {
485
+ /**
486
+ * Gets the orthographic projection matrix computed from the view frustum.
487
+ * @memberof OrthographicFrustum.prototype
488
+ * @type {Matrix4}
489
+ * @readonly
490
+ */
491
+ projectionMatrix: {
492
+ get: function() {
493
+ update2(this);
494
+ return this._offCenterFrustum.projectionMatrix;
495
+ }
496
+ },
497
+ /**
498
+ * Gets the orthographic projection matrix computed from the view frustum.
499
+ * @memberof OrthographicFrustum.prototype
500
+ * @type {OrthographicOffCenterFrustum}
501
+ * @readonly
502
+ * @private
503
+ */
504
+ offCenterFrustum: {
505
+ get: function() {
506
+ update2(this);
507
+ return this._offCenterFrustum;
508
+ }
509
+ }
510
+ });
511
+ OrthographicFrustum.prototype.computeCullingVolume = function(position, direction, up) {
512
+ update2(this);
513
+ return this._offCenterFrustum.computeCullingVolume(position, direction, up);
514
+ };
515
+ OrthographicFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance, pixelRatio, result) {
516
+ update2(this);
517
+ return this._offCenterFrustum.getPixelDimensions(
518
+ drawingBufferWidth,
519
+ drawingBufferHeight,
520
+ distance,
521
+ pixelRatio,
522
+ result
523
+ );
524
+ };
525
+ OrthographicFrustum.prototype.clone = function(result) {
526
+ if (!defined_default(result)) {
527
+ result = new OrthographicFrustum();
528
+ }
529
+ result.aspectRatio = this.aspectRatio;
530
+ result.width = this.width;
531
+ result.near = this.near;
532
+ result.far = this.far;
533
+ result._aspectRatio = void 0;
534
+ result._width = void 0;
535
+ result._near = void 0;
536
+ result._far = void 0;
537
+ this._offCenterFrustum.clone(result._offCenterFrustum);
538
+ return result;
539
+ };
540
+ OrthographicFrustum.prototype.equals = function(other) {
541
+ if (!defined_default(other) || !(other instanceof OrthographicFrustum)) {
542
+ return false;
543
+ }
544
+ update2(this);
545
+ update2(other);
546
+ return this.width === other.width && this.aspectRatio === other.aspectRatio && this._offCenterFrustum.equals(other._offCenterFrustum);
547
+ };
548
+ OrthographicFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
549
+ if (!defined_default(other) || !(other instanceof OrthographicFrustum)) {
550
+ return false;
551
+ }
552
+ update2(this);
553
+ update2(other);
554
+ return Math_default.equalsEpsilon(
555
+ this.width,
556
+ other.width,
557
+ relativeEpsilon,
558
+ absoluteEpsilon
559
+ ) && Math_default.equalsEpsilon(
560
+ this.aspectRatio,
561
+ other.aspectRatio,
562
+ relativeEpsilon,
563
+ absoluteEpsilon
564
+ ) && this._offCenterFrustum.equalsEpsilon(
565
+ other._offCenterFrustum,
566
+ relativeEpsilon,
567
+ absoluteEpsilon
568
+ );
569
+ };
570
+ var OrthographicFrustum_default = OrthographicFrustum;
571
+
572
+ // packages/engine/Source/Core/PerspectiveOffCenterFrustum.js
573
+ function PerspectiveOffCenterFrustum(options) {
574
+ options = options ?? Frozen_default.EMPTY_OBJECT;
575
+ this.left = options.left;
576
+ this._left = void 0;
577
+ this.right = options.right;
578
+ this._right = void 0;
579
+ this.top = options.top;
580
+ this._top = void 0;
581
+ this.bottom = options.bottom;
582
+ this._bottom = void 0;
583
+ this.near = options.near ?? 1;
584
+ this._near = this.near;
585
+ this.far = options.far ?? 5e8;
586
+ this._far = this.far;
587
+ this._cullingVolume = new CullingVolume_default();
588
+ this._perspectiveMatrix = new Matrix4_default();
589
+ this._infinitePerspective = new Matrix4_default();
590
+ }
591
+ function update3(frustum) {
592
+ if (!defined_default(frustum.right) || !defined_default(frustum.left) || !defined_default(frustum.top) || !defined_default(frustum.bottom) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
593
+ throw new DeveloperError_default(
594
+ "right, left, top, bottom, near, or far parameters are not set."
595
+ );
596
+ }
597
+ const { top, bottom, right, left, near, far } = frustum;
598
+ const changed = top !== frustum._top || bottom !== frustum._bottom || left !== frustum._left || right !== frustum._right || near !== frustum._near || far !== frustum._far;
599
+ if (!changed) {
600
+ return;
601
+ }
602
+ if (frustum.near <= 0 || frustum.near > frustum.far) {
603
+ throw new DeveloperError_default(
604
+ "near must be greater than zero and less than far."
605
+ );
606
+ }
607
+ frustum._left = left;
608
+ frustum._right = right;
609
+ frustum._top = top;
610
+ frustum._bottom = bottom;
611
+ frustum._near = near;
612
+ frustum._far = far;
613
+ frustum._perspectiveMatrix = Matrix4_default.computePerspectiveOffCenter(
614
+ left,
615
+ right,
616
+ bottom,
617
+ top,
618
+ near,
619
+ far,
620
+ frustum._perspectiveMatrix
621
+ );
622
+ frustum._infinitePerspective = Matrix4_default.computeInfinitePerspectiveOffCenter(
623
+ left,
624
+ right,
625
+ bottom,
626
+ top,
627
+ near,
628
+ frustum._infinitePerspective
629
+ );
630
+ }
631
+ Object.defineProperties(PerspectiveOffCenterFrustum.prototype, {
632
+ /**
633
+ * Gets the perspective projection matrix computed from the view frustum.
634
+ * The projection matrix will be recomputed if any frustum parameters have changed.
635
+ *
636
+ * @memberof PerspectiveOffCenterFrustum.prototype
637
+ * @type {Matrix4}
638
+ * @readonly
639
+ *
640
+ * @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix
641
+ */
642
+ projectionMatrix: {
643
+ get: function() {
644
+ update3(this);
645
+ return this._perspectiveMatrix;
646
+ }
647
+ },
648
+ /**
649
+ * Gets the perspective projection matrix computed from the view frustum with an infinite far plane.
650
+ * @memberof PerspectiveOffCenterFrustum.prototype
651
+ * @type {Matrix4}
652
+ * @readonly
653
+ *
654
+ * @see PerspectiveOffCenterFrustum#projectionMatrix
655
+ */
656
+ infiniteProjectionMatrix: {
657
+ get: function() {
658
+ update3(this);
659
+ return this._infinitePerspective;
660
+ }
661
+ }
662
+ });
663
+ var getPlanesRight2 = new Cartesian3_default();
664
+ var getPlanesNearCenter2 = new Cartesian3_default();
665
+ var getPlanesFarCenter = new Cartesian3_default();
666
+ var getPlanesNormal = new Cartesian3_default();
667
+ PerspectiveOffCenterFrustum.prototype.computeCullingVolume = function(position, direction, up) {
668
+ if (!defined_default(position)) {
669
+ throw new DeveloperError_default("position is required.");
670
+ }
671
+ if (!defined_default(direction)) {
672
+ throw new DeveloperError_default("direction is required.");
673
+ }
674
+ if (!defined_default(up)) {
675
+ throw new DeveloperError_default("up is required.");
676
+ }
677
+ const planes = this._cullingVolume.planes;
678
+ const t = this.top;
679
+ const b = this.bottom;
680
+ const r = this.right;
681
+ const l = this.left;
682
+ const n = this.near;
683
+ const f = this.far;
684
+ const right = Cartesian3_default.cross(direction, up, getPlanesRight2);
685
+ const nearCenter = getPlanesNearCenter2;
686
+ Cartesian3_default.multiplyByScalar(direction, n, nearCenter);
687
+ Cartesian3_default.add(position, nearCenter, nearCenter);
688
+ const farCenter = getPlanesFarCenter;
689
+ Cartesian3_default.multiplyByScalar(direction, f, farCenter);
690
+ Cartesian3_default.add(position, farCenter, farCenter);
691
+ const normal = getPlanesNormal;
692
+ Cartesian3_default.multiplyByScalar(right, l, normal);
693
+ Cartesian3_default.add(nearCenter, normal, normal);
694
+ Cartesian3_default.subtract(normal, position, normal);
695
+ Cartesian3_default.normalize(normal, normal);
696
+ Cartesian3_default.cross(normal, up, normal);
697
+ Cartesian3_default.normalize(normal, normal);
698
+ let plane = planes[0];
699
+ if (!defined_default(plane)) {
700
+ plane = planes[0] = new Cartesian4_default();
701
+ }
702
+ plane.x = normal.x;
703
+ plane.y = normal.y;
704
+ plane.z = normal.z;
705
+ plane.w = -Cartesian3_default.dot(normal, position);
706
+ Cartesian3_default.multiplyByScalar(right, r, normal);
707
+ Cartesian3_default.add(nearCenter, normal, normal);
708
+ Cartesian3_default.subtract(normal, position, normal);
709
+ Cartesian3_default.cross(up, normal, normal);
710
+ Cartesian3_default.normalize(normal, normal);
711
+ plane = planes[1];
712
+ if (!defined_default(plane)) {
713
+ plane = planes[1] = new Cartesian4_default();
714
+ }
715
+ plane.x = normal.x;
716
+ plane.y = normal.y;
717
+ plane.z = normal.z;
718
+ plane.w = -Cartesian3_default.dot(normal, position);
719
+ Cartesian3_default.multiplyByScalar(up, b, normal);
720
+ Cartesian3_default.add(nearCenter, normal, normal);
721
+ Cartesian3_default.subtract(normal, position, normal);
722
+ Cartesian3_default.cross(right, normal, normal);
723
+ Cartesian3_default.normalize(normal, normal);
724
+ plane = planes[2];
725
+ if (!defined_default(plane)) {
726
+ plane = planes[2] = new Cartesian4_default();
727
+ }
728
+ plane.x = normal.x;
729
+ plane.y = normal.y;
730
+ plane.z = normal.z;
731
+ plane.w = -Cartesian3_default.dot(normal, position);
732
+ Cartesian3_default.multiplyByScalar(up, t, normal);
733
+ Cartesian3_default.add(nearCenter, normal, normal);
734
+ Cartesian3_default.subtract(normal, position, normal);
735
+ Cartesian3_default.cross(normal, right, normal);
736
+ Cartesian3_default.normalize(normal, normal);
737
+ plane = planes[3];
738
+ if (!defined_default(plane)) {
739
+ plane = planes[3] = new Cartesian4_default();
740
+ }
741
+ plane.x = normal.x;
742
+ plane.y = normal.y;
743
+ plane.z = normal.z;
744
+ plane.w = -Cartesian3_default.dot(normal, position);
745
+ plane = planes[4];
746
+ if (!defined_default(plane)) {
747
+ plane = planes[4] = new Cartesian4_default();
748
+ }
749
+ plane.x = direction.x;
750
+ plane.y = direction.y;
751
+ plane.z = direction.z;
752
+ plane.w = -Cartesian3_default.dot(direction, nearCenter);
753
+ Cartesian3_default.negate(direction, normal);
754
+ plane = planes[5];
755
+ if (!defined_default(plane)) {
756
+ plane = planes[5] = new Cartesian4_default();
757
+ }
758
+ plane.x = normal.x;
759
+ plane.y = normal.y;
760
+ plane.z = normal.z;
761
+ plane.w = -Cartesian3_default.dot(normal, farCenter);
762
+ return this._cullingVolume;
763
+ };
764
+ PerspectiveOffCenterFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance, pixelRatio, result) {
765
+ update3(this);
766
+ if (!defined_default(drawingBufferWidth) || !defined_default(drawingBufferHeight)) {
767
+ throw new DeveloperError_default(
768
+ "Both drawingBufferWidth and drawingBufferHeight are required."
769
+ );
770
+ }
771
+ if (drawingBufferWidth <= 0) {
772
+ throw new DeveloperError_default("drawingBufferWidth must be greater than zero.");
773
+ }
774
+ if (drawingBufferHeight <= 0) {
775
+ throw new DeveloperError_default("drawingBufferHeight must be greater than zero.");
776
+ }
777
+ if (!defined_default(distance)) {
778
+ throw new DeveloperError_default("distance is required.");
779
+ }
780
+ if (!defined_default(pixelRatio)) {
781
+ throw new DeveloperError_default("pixelRatio is required");
782
+ }
783
+ if (pixelRatio <= 0) {
784
+ throw new DeveloperError_default("pixelRatio must be greater than zero.");
785
+ }
786
+ if (!defined_default(result)) {
787
+ throw new DeveloperError_default("A result object is required.");
788
+ }
789
+ const inverseNear = 1 / this.near;
790
+ let tanTheta = this.top * inverseNear;
791
+ const pixelHeight = 2 * pixelRatio * distance * tanTheta / drawingBufferHeight;
792
+ tanTheta = this.right * inverseNear;
793
+ const pixelWidth = 2 * pixelRatio * distance * tanTheta / drawingBufferWidth;
794
+ result.x = pixelWidth;
795
+ result.y = pixelHeight;
796
+ return result;
797
+ };
798
+ PerspectiveOffCenterFrustum.prototype.clone = function(result) {
799
+ if (!defined_default(result)) {
800
+ result = new PerspectiveOffCenterFrustum();
801
+ }
802
+ result.right = this.right;
803
+ result.left = this.left;
804
+ result.top = this.top;
805
+ result.bottom = this.bottom;
806
+ result.near = this.near;
807
+ result.far = this.far;
808
+ result._left = void 0;
809
+ result._right = void 0;
810
+ result._top = void 0;
811
+ result._bottom = void 0;
812
+ result._near = void 0;
813
+ result._far = void 0;
814
+ return result;
815
+ };
816
+ PerspectiveOffCenterFrustum.prototype.equals = function(other) {
817
+ return defined_default(other) && other instanceof PerspectiveOffCenterFrustum && this.right === other.right && this.left === other.left && this.top === other.top && this.bottom === other.bottom && this.near === other.near && this.far === other.far;
818
+ };
819
+ PerspectiveOffCenterFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
820
+ return other === this || defined_default(other) && other instanceof PerspectiveOffCenterFrustum && Math_default.equalsEpsilon(
821
+ this.right,
822
+ other.right,
823
+ relativeEpsilon,
824
+ absoluteEpsilon
825
+ ) && Math_default.equalsEpsilon(
826
+ this.left,
827
+ other.left,
828
+ relativeEpsilon,
829
+ absoluteEpsilon
830
+ ) && Math_default.equalsEpsilon(
831
+ this.top,
832
+ other.top,
833
+ relativeEpsilon,
834
+ absoluteEpsilon
835
+ ) && Math_default.equalsEpsilon(
836
+ this.bottom,
837
+ other.bottom,
838
+ relativeEpsilon,
839
+ absoluteEpsilon
840
+ ) && Math_default.equalsEpsilon(
841
+ this.near,
842
+ other.near,
843
+ relativeEpsilon,
844
+ absoluteEpsilon
845
+ ) && Math_default.equalsEpsilon(
846
+ this.far,
847
+ other.far,
848
+ relativeEpsilon,
849
+ absoluteEpsilon
850
+ );
851
+ };
852
+ var PerspectiveOffCenterFrustum_default = PerspectiveOffCenterFrustum;
853
+
854
+ // packages/engine/Source/Core/PerspectiveFrustum.js
855
+ function PerspectiveFrustum(options) {
856
+ options = options ?? Frozen_default.EMPTY_OBJECT;
857
+ this._offCenterFrustum = new PerspectiveOffCenterFrustum_default();
858
+ this.fov = options.fov;
859
+ this._fov = void 0;
860
+ this._fovy = void 0;
861
+ this._sseDenominator = void 0;
862
+ this.aspectRatio = options.aspectRatio;
863
+ this._aspectRatio = void 0;
864
+ this.near = options.near ?? 1;
865
+ this._near = this.near;
866
+ this.far = options.far ?? 5e8;
867
+ this._far = this.far;
868
+ this.xOffset = options.xOffset ?? 0;
869
+ this._xOffset = this.xOffset;
870
+ this.yOffset = options.yOffset ?? 0;
871
+ this._yOffset = this.yOffset;
872
+ }
873
+ PerspectiveFrustum.packedLength = 6;
874
+ PerspectiveFrustum.pack = function(value, array, startingIndex) {
875
+ Check_default.typeOf.object("value", value);
876
+ Check_default.defined("array", array);
877
+ startingIndex = startingIndex ?? 0;
878
+ array[startingIndex++] = value.fov;
879
+ array[startingIndex++] = value.aspectRatio;
880
+ array[startingIndex++] = value.near;
881
+ array[startingIndex++] = value.far;
882
+ array[startingIndex++] = value.xOffset;
883
+ array[startingIndex] = value.yOffset;
884
+ return array;
885
+ };
886
+ PerspectiveFrustum.unpack = function(array, startingIndex, result) {
887
+ Check_default.defined("array", array);
888
+ startingIndex = startingIndex ?? 0;
889
+ if (!defined_default(result)) {
890
+ result = new PerspectiveFrustum();
891
+ }
892
+ result.fov = array[startingIndex++];
893
+ result.aspectRatio = array[startingIndex++];
894
+ result.near = array[startingIndex++];
895
+ result.far = array[startingIndex++];
896
+ result.xOffset = array[startingIndex++];
897
+ result.yOffset = array[startingIndex];
898
+ return result;
899
+ };
900
+ function update4(frustum) {
901
+ if (!defined_default(frustum.fov) || !defined_default(frustum.aspectRatio) || !defined_default(frustum.near) || !defined_default(frustum.far)) {
902
+ throw new DeveloperError_default(
903
+ "fov, aspectRatio, near, or far parameters are not set."
904
+ );
905
+ }
906
+ const changed = frustum.fov !== frustum._fov || frustum.aspectRatio !== frustum._aspectRatio || frustum.near !== frustum._near || frustum.far !== frustum._far || frustum.xOffset !== frustum._xOffset || frustum.yOffset !== frustum._yOffset;
907
+ if (!changed) {
908
+ return;
909
+ }
910
+ Check_default.typeOf.number.greaterThanOrEquals("fov", frustum.fov, 0);
911
+ Check_default.typeOf.number.lessThan("fov", frustum.fov, Math.PI);
912
+ Check_default.typeOf.number.greaterThanOrEquals(
913
+ "aspectRatio",
914
+ frustum.aspectRatio,
915
+ 0
916
+ );
917
+ Check_default.typeOf.number.greaterThanOrEquals("near", frustum.near, 0);
918
+ if (frustum.near > frustum.far) {
919
+ throw new DeveloperError_default("near must be less than far.");
920
+ }
921
+ frustum._aspectRatio = frustum.aspectRatio;
922
+ frustum._fov = frustum.fov;
923
+ frustum._fovy = frustum.aspectRatio <= 1 ? frustum.fov : Math.atan(Math.tan(frustum.fov * 0.5) / frustum.aspectRatio) * 2;
924
+ frustum._near = frustum.near;
925
+ frustum._far = frustum.far;
926
+ frustum._sseDenominator = 2 * Math.tan(0.5 * frustum._fovy);
927
+ frustum._xOffset = frustum.xOffset;
928
+ frustum._yOffset = frustum.yOffset;
929
+ const f = frustum._offCenterFrustum;
930
+ f.top = frustum.near * Math.tan(0.5 * frustum._fovy);
931
+ f.bottom = -f.top;
932
+ f.right = frustum.aspectRatio * f.top;
933
+ f.left = -f.right;
934
+ f.near = frustum.near;
935
+ f.far = frustum.far;
936
+ f.right += frustum.xOffset;
937
+ f.left += frustum.xOffset;
938
+ f.top += frustum.yOffset;
939
+ f.bottom += frustum.yOffset;
940
+ }
941
+ Object.defineProperties(PerspectiveFrustum.prototype, {
942
+ /**
943
+ * Gets the perspective projection matrix computed from the view frustum.
944
+ * If necessary, the projection matrix will be recomputed.
945
+ *
946
+ * @memberof PerspectiveFrustum.prototype
947
+ * @type {Matrix4}
948
+ * @readonly
949
+ *
950
+ * @see PerspectiveOffCenterFrustum#projectionMatrix.
951
+ * @see PerspectiveFrustum#infiniteProjectionMatrix
952
+ */
953
+ projectionMatrix: {
954
+ get: function() {
955
+ update4(this);
956
+ return this._offCenterFrustum.projectionMatrix;
957
+ }
958
+ },
959
+ /**
960
+ * The perspective projection matrix computed from the view frustum with an infinite far plane.
961
+ * @memberof PerspectiveFrustum.prototype
962
+ * @type {Matrix4}
963
+ * @readonly
964
+ *
965
+ * @see PerspectiveFrustum#projectionMatrix
966
+ */
967
+ infiniteProjectionMatrix: {
968
+ get: function() {
969
+ update4(this);
970
+ return this._offCenterFrustum.infiniteProjectionMatrix;
971
+ }
972
+ },
973
+ /**
974
+ * Gets the angle of the vertical field of view, in radians.
975
+ * @memberof PerspectiveFrustum.prototype
976
+ * @type {number|undefined}
977
+ * @readonly
978
+ * @default undefined
979
+ */
980
+ fovy: {
981
+ get: function() {
982
+ update4(this);
983
+ return this._fovy;
984
+ }
985
+ },
986
+ /**
987
+ * @readonly
988
+ * @private
989
+ */
990
+ sseDenominator: {
991
+ get: function() {
992
+ update4(this);
993
+ return this._sseDenominator;
994
+ }
995
+ },
996
+ /**
997
+ * Gets the orthographic projection matrix computed from the view frustum.
998
+ * @memberof PerspectiveFrustum.prototype
999
+ * @type {PerspectiveOffCenterFrustum}
1000
+ * @readonly
1001
+ * @private
1002
+ */
1003
+ offCenterFrustum: {
1004
+ get: function() {
1005
+ update4(this);
1006
+ return this._offCenterFrustum;
1007
+ }
1008
+ }
1009
+ });
1010
+ PerspectiveFrustum.prototype.computeCullingVolume = function(position, direction, up) {
1011
+ update4(this);
1012
+ return this._offCenterFrustum.computeCullingVolume(position, direction, up);
1013
+ };
1014
+ PerspectiveFrustum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, distance, pixelRatio, result) {
1015
+ update4(this);
1016
+ return this._offCenterFrustum.getPixelDimensions(
1017
+ drawingBufferWidth,
1018
+ drawingBufferHeight,
1019
+ distance,
1020
+ pixelRatio,
1021
+ result
1022
+ );
1023
+ };
1024
+ PerspectiveFrustum.prototype.clone = function(result) {
1025
+ if (!defined_default(result)) {
1026
+ result = new PerspectiveFrustum();
1027
+ }
1028
+ result.aspectRatio = this.aspectRatio;
1029
+ result.fov = this.fov;
1030
+ result.near = this.near;
1031
+ result.far = this.far;
1032
+ result._aspectRatio = void 0;
1033
+ result._fov = void 0;
1034
+ result._near = void 0;
1035
+ result._far = void 0;
1036
+ this._offCenterFrustum.clone(result._offCenterFrustum);
1037
+ return result;
1038
+ };
1039
+ PerspectiveFrustum.prototype.equals = function(other) {
1040
+ if (!defined_default(other) || !(other instanceof PerspectiveFrustum)) {
1041
+ return false;
1042
+ }
1043
+ update4(this);
1044
+ update4(other);
1045
+ return this.fov === other.fov && this.aspectRatio === other.aspectRatio && this._offCenterFrustum.equals(other._offCenterFrustum);
1046
+ };
1047
+ PerspectiveFrustum.prototype.equalsEpsilon = function(other, relativeEpsilon, absoluteEpsilon) {
1048
+ if (!defined_default(other) || !(other instanceof PerspectiveFrustum)) {
1049
+ return false;
1050
+ }
1051
+ update4(this);
1052
+ update4(other);
1053
+ return Math_default.equalsEpsilon(
1054
+ this.fov,
1055
+ other.fov,
1056
+ relativeEpsilon,
1057
+ absoluteEpsilon
1058
+ ) && Math_default.equalsEpsilon(
1059
+ this.aspectRatio,
1060
+ other.aspectRatio,
1061
+ relativeEpsilon,
1062
+ absoluteEpsilon
1063
+ ) && this._offCenterFrustum.equalsEpsilon(
1064
+ other._offCenterFrustum,
1065
+ relativeEpsilon,
1066
+ absoluteEpsilon
1067
+ );
1068
+ };
1069
+ var PerspectiveFrustum_default = PerspectiveFrustum;
1070
+
1071
+ // packages/engine/Source/Core/FrustumGeometry.js
1072
+ var PERSPECTIVE = 0;
1073
+ var ORTHOGRAPHIC = 1;
1074
+ function FrustumGeometry(options) {
1075
+ Check_default.typeOf.object("options", options);
1076
+ Check_default.typeOf.object("options.frustum", options.frustum);
1077
+ Check_default.typeOf.object("options.origin", options.origin);
1078
+ Check_default.typeOf.object("options.orientation", options.orientation);
1079
+ const frustum = options.frustum;
1080
+ const orientation = options.orientation;
1081
+ const origin = options.origin;
1082
+ const vertexFormat = options.vertexFormat ?? VertexFormat_default.DEFAULT;
1083
+ const drawNearPlane = options._drawNearPlane ?? true;
1084
+ let frustumType;
1085
+ let frustumPackedLength;
1086
+ if (frustum instanceof PerspectiveFrustum_default) {
1087
+ frustumType = PERSPECTIVE;
1088
+ frustumPackedLength = PerspectiveFrustum_default.packedLength;
1089
+ } else if (frustum instanceof OrthographicFrustum_default) {
1090
+ frustumType = ORTHOGRAPHIC;
1091
+ frustumPackedLength = OrthographicFrustum_default.packedLength;
1092
+ }
1093
+ this._frustumType = frustumType;
1094
+ this._frustum = frustum.clone();
1095
+ this._origin = Cartesian3_default.clone(origin);
1096
+ this._orientation = Quaternion_default.clone(orientation);
1097
+ this._drawNearPlane = drawNearPlane;
1098
+ this._vertexFormat = vertexFormat;
1099
+ this._workerName = "createFrustumGeometry";
1100
+ this.packedLength = 2 + frustumPackedLength + Cartesian3_default.packedLength + Quaternion_default.packedLength + VertexFormat_default.packedLength;
1101
+ }
1102
+ FrustumGeometry.pack = function(value, array, startingIndex) {
1103
+ Check_default.typeOf.object("value", value);
1104
+ Check_default.defined("array", array);
1105
+ startingIndex = startingIndex ?? 0;
1106
+ const frustumType = value._frustumType;
1107
+ const frustum = value._frustum;
1108
+ array[startingIndex++] = frustumType;
1109
+ if (frustumType === PERSPECTIVE) {
1110
+ PerspectiveFrustum_default.pack(frustum, array, startingIndex);
1111
+ startingIndex += PerspectiveFrustum_default.packedLength;
1112
+ } else {
1113
+ OrthographicFrustum_default.pack(frustum, array, startingIndex);
1114
+ startingIndex += OrthographicFrustum_default.packedLength;
1115
+ }
1116
+ Cartesian3_default.pack(value._origin, array, startingIndex);
1117
+ startingIndex += Cartesian3_default.packedLength;
1118
+ Quaternion_default.pack(value._orientation, array, startingIndex);
1119
+ startingIndex += Quaternion_default.packedLength;
1120
+ VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
1121
+ startingIndex += VertexFormat_default.packedLength;
1122
+ array[startingIndex] = value._drawNearPlane ? 1 : 0;
1123
+ return array;
1124
+ };
1125
+ var scratchPackPerspective = new PerspectiveFrustum_default();
1126
+ var scratchPackOrthographic = new OrthographicFrustum_default();
1127
+ var scratchPackQuaternion = new Quaternion_default();
1128
+ var scratchPackorigin = new Cartesian3_default();
1129
+ var scratchVertexFormat = new VertexFormat_default();
1130
+ FrustumGeometry.unpack = function(array, startingIndex, result) {
1131
+ Check_default.defined("array", array);
1132
+ startingIndex = startingIndex ?? 0;
1133
+ const frustumType = array[startingIndex++];
1134
+ let frustum;
1135
+ if (frustumType === PERSPECTIVE) {
1136
+ frustum = PerspectiveFrustum_default.unpack(
1137
+ array,
1138
+ startingIndex,
1139
+ scratchPackPerspective
1140
+ );
1141
+ startingIndex += PerspectiveFrustum_default.packedLength;
1142
+ } else {
1143
+ frustum = OrthographicFrustum_default.unpack(
1144
+ array,
1145
+ startingIndex,
1146
+ scratchPackOrthographic
1147
+ );
1148
+ startingIndex += OrthographicFrustum_default.packedLength;
1149
+ }
1150
+ const origin = Cartesian3_default.unpack(array, startingIndex, scratchPackorigin);
1151
+ startingIndex += Cartesian3_default.packedLength;
1152
+ const orientation = Quaternion_default.unpack(
1153
+ array,
1154
+ startingIndex,
1155
+ scratchPackQuaternion
1156
+ );
1157
+ startingIndex += Quaternion_default.packedLength;
1158
+ const vertexFormat = VertexFormat_default.unpack(
1159
+ array,
1160
+ startingIndex,
1161
+ scratchVertexFormat
1162
+ );
1163
+ startingIndex += VertexFormat_default.packedLength;
1164
+ const drawNearPlane = array[startingIndex] === 1;
1165
+ if (!defined_default(result)) {
1166
+ return new FrustumGeometry({
1167
+ frustum,
1168
+ origin,
1169
+ orientation,
1170
+ vertexFormat,
1171
+ _drawNearPlane: drawNearPlane
1172
+ });
1173
+ }
1174
+ const frustumResult = frustumType === result._frustumType ? result._frustum : void 0;
1175
+ result._frustum = frustum.clone(frustumResult);
1176
+ result._frustumType = frustumType;
1177
+ result._origin = Cartesian3_default.clone(origin, result._origin);
1178
+ result._orientation = Quaternion_default.clone(orientation, result._orientation);
1179
+ result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
1180
+ result._drawNearPlane = drawNearPlane;
1181
+ return result;
1182
+ };
1183
+ function getAttributes(offset, normals, tangents, bitangents, st, normal, tangent, bitangent) {
1184
+ const stOffset = offset / 3 * 2;
1185
+ for (let i = 0; i < 4; ++i) {
1186
+ if (defined_default(normals)) {
1187
+ normals[offset] = normal.x;
1188
+ normals[offset + 1] = normal.y;
1189
+ normals[offset + 2] = normal.z;
1190
+ }
1191
+ if (defined_default(tangents)) {
1192
+ tangents[offset] = tangent.x;
1193
+ tangents[offset + 1] = tangent.y;
1194
+ tangents[offset + 2] = tangent.z;
1195
+ }
1196
+ if (defined_default(bitangents)) {
1197
+ bitangents[offset] = bitangent.x;
1198
+ bitangents[offset + 1] = bitangent.y;
1199
+ bitangents[offset + 2] = bitangent.z;
1200
+ }
1201
+ offset += 3;
1202
+ }
1203
+ st[stOffset] = 0;
1204
+ st[stOffset + 1] = 0;
1205
+ st[stOffset + 2] = 1;
1206
+ st[stOffset + 3] = 0;
1207
+ st[stOffset + 4] = 1;
1208
+ st[stOffset + 5] = 1;
1209
+ st[stOffset + 6] = 0;
1210
+ st[stOffset + 7] = 1;
1211
+ }
1212
+ var scratchRotationMatrix = new Matrix3_default();
1213
+ var scratchViewMatrix = new Matrix4_default();
1214
+ var scratchInverseMatrix = new Matrix4_default();
1215
+ var scratchXDirection = new Cartesian3_default();
1216
+ var scratchYDirection = new Cartesian3_default();
1217
+ var scratchZDirection = new Cartesian3_default();
1218
+ var scratchNegativeX = new Cartesian3_default();
1219
+ var scratchNegativeY = new Cartesian3_default();
1220
+ var scratchNegativeZ = new Cartesian3_default();
1221
+ var frustumSplits = new Array(3);
1222
+ var frustumCornersNDC = new Array(4);
1223
+ frustumCornersNDC[0] = new Cartesian4_default(-1, -1, 1, 1);
1224
+ frustumCornersNDC[1] = new Cartesian4_default(1, -1, 1, 1);
1225
+ frustumCornersNDC[2] = new Cartesian4_default(1, 1, 1, 1);
1226
+ frustumCornersNDC[3] = new Cartesian4_default(-1, 1, 1, 1);
1227
+ var scratchFrustumCorners = new Array(4);
1228
+ for (let i = 0; i < 4; ++i) {
1229
+ scratchFrustumCorners[i] = new Cartesian4_default();
1230
+ }
1231
+ FrustumGeometry._computeNearFarPlanes = function(origin, orientation, frustumType, frustum, positions, xDirection, yDirection, zDirection) {
1232
+ const rotationMatrix = Matrix3_default.fromQuaternion(
1233
+ orientation,
1234
+ scratchRotationMatrix
1235
+ );
1236
+ let x = xDirection ?? scratchXDirection;
1237
+ let y = yDirection ?? scratchYDirection;
1238
+ let z = zDirection ?? scratchZDirection;
1239
+ x = Matrix3_default.getColumn(rotationMatrix, 0, x);
1240
+ y = Matrix3_default.getColumn(rotationMatrix, 1, y);
1241
+ z = Matrix3_default.getColumn(rotationMatrix, 2, z);
1242
+ Cartesian3_default.normalize(x, x);
1243
+ Cartesian3_default.normalize(y, y);
1244
+ Cartesian3_default.normalize(z, z);
1245
+ Cartesian3_default.negate(x, x);
1246
+ const view = Matrix4_default.computeView(origin, z, y, x, scratchViewMatrix);
1247
+ let inverseView;
1248
+ let inverseViewProjection;
1249
+ const projection = frustum.projectionMatrix;
1250
+ if (frustumType === PERSPECTIVE) {
1251
+ const viewProjection = Matrix4_default.multiply(
1252
+ projection,
1253
+ view,
1254
+ scratchInverseMatrix
1255
+ );
1256
+ inverseViewProjection = Matrix4_default.inverse(
1257
+ viewProjection,
1258
+ scratchInverseMatrix
1259
+ );
1260
+ } else {
1261
+ inverseView = Matrix4_default.inverseTransformation(view, scratchInverseMatrix);
1262
+ }
1263
+ if (defined_default(inverseViewProjection)) {
1264
+ frustumSplits[0] = frustum.near;
1265
+ frustumSplits[1] = frustum.far;
1266
+ } else {
1267
+ frustumSplits[0] = 0;
1268
+ frustumSplits[1] = frustum.near;
1269
+ frustumSplits[2] = frustum.far;
1270
+ }
1271
+ for (let i = 0; i < 2; ++i) {
1272
+ for (let j = 0; j < 4; ++j) {
1273
+ let corner = Cartesian4_default.clone(
1274
+ frustumCornersNDC[j],
1275
+ scratchFrustumCorners[j]
1276
+ );
1277
+ if (!defined_default(inverseViewProjection)) {
1278
+ const offCenterFrustum = frustum.offCenterFrustum;
1279
+ if (defined_default(offCenterFrustum)) {
1280
+ frustum = offCenterFrustum;
1281
+ }
1282
+ const near = frustumSplits[i];
1283
+ const far = frustumSplits[i + 1];
1284
+ corner.x = (corner.x * (frustum.right - frustum.left) + frustum.left + frustum.right) * 0.5;
1285
+ corner.y = (corner.y * (frustum.top - frustum.bottom) + frustum.bottom + frustum.top) * 0.5;
1286
+ corner.z = (corner.z * (near - far) - near - far) * 0.5;
1287
+ corner.w = 1;
1288
+ Matrix4_default.multiplyByVector(inverseView, corner, corner);
1289
+ } else {
1290
+ corner = Matrix4_default.multiplyByVector(
1291
+ inverseViewProjection,
1292
+ corner,
1293
+ corner
1294
+ );
1295
+ const w = 1 / corner.w;
1296
+ Cartesian3_default.multiplyByScalar(corner, w, corner);
1297
+ Cartesian3_default.subtract(corner, origin, corner);
1298
+ Cartesian3_default.normalize(corner, corner);
1299
+ const fac = Cartesian3_default.dot(z, corner);
1300
+ Cartesian3_default.multiplyByScalar(corner, frustumSplits[i] / fac, corner);
1301
+ Cartesian3_default.add(corner, origin, corner);
1302
+ }
1303
+ positions[12 * i + j * 3] = corner.x;
1304
+ positions[12 * i + j * 3 + 1] = corner.y;
1305
+ positions[12 * i + j * 3 + 2] = corner.z;
1306
+ }
1307
+ }
1308
+ };
1309
+ FrustumGeometry.createGeometry = function(frustumGeometry) {
1310
+ const frustumType = frustumGeometry._frustumType;
1311
+ const frustum = frustumGeometry._frustum;
1312
+ const origin = frustumGeometry._origin;
1313
+ const orientation = frustumGeometry._orientation;
1314
+ const drawNearPlane = frustumGeometry._drawNearPlane;
1315
+ const vertexFormat = frustumGeometry._vertexFormat;
1316
+ const numberOfPlanes = drawNearPlane ? 6 : 5;
1317
+ let positions = new Float64Array(3 * 4 * 6);
1318
+ FrustumGeometry._computeNearFarPlanes(
1319
+ origin,
1320
+ orientation,
1321
+ frustumType,
1322
+ frustum,
1323
+ positions
1324
+ );
1325
+ let offset = 3 * 4 * 2;
1326
+ positions[offset] = positions[3 * 4];
1327
+ positions[offset + 1] = positions[3 * 4 + 1];
1328
+ positions[offset + 2] = positions[3 * 4 + 2];
1329
+ positions[offset + 3] = positions[0];
1330
+ positions[offset + 4] = positions[1];
1331
+ positions[offset + 5] = positions[2];
1332
+ positions[offset + 6] = positions[3 * 3];
1333
+ positions[offset + 7] = positions[3 * 3 + 1];
1334
+ positions[offset + 8] = positions[3 * 3 + 2];
1335
+ positions[offset + 9] = positions[3 * 7];
1336
+ positions[offset + 10] = positions[3 * 7 + 1];
1337
+ positions[offset + 11] = positions[3 * 7 + 2];
1338
+ offset += 3 * 4;
1339
+ positions[offset] = positions[3 * 5];
1340
+ positions[offset + 1] = positions[3 * 5 + 1];
1341
+ positions[offset + 2] = positions[3 * 5 + 2];
1342
+ positions[offset + 3] = positions[3];
1343
+ positions[offset + 4] = positions[3 + 1];
1344
+ positions[offset + 5] = positions[3 + 2];
1345
+ positions[offset + 6] = positions[0];
1346
+ positions[offset + 7] = positions[1];
1347
+ positions[offset + 8] = positions[2];
1348
+ positions[offset + 9] = positions[3 * 4];
1349
+ positions[offset + 10] = positions[3 * 4 + 1];
1350
+ positions[offset + 11] = positions[3 * 4 + 2];
1351
+ offset += 3 * 4;
1352
+ positions[offset] = positions[3];
1353
+ positions[offset + 1] = positions[3 + 1];
1354
+ positions[offset + 2] = positions[3 + 2];
1355
+ positions[offset + 3] = positions[3 * 5];
1356
+ positions[offset + 4] = positions[3 * 5 + 1];
1357
+ positions[offset + 5] = positions[3 * 5 + 2];
1358
+ positions[offset + 6] = positions[3 * 6];
1359
+ positions[offset + 7] = positions[3 * 6 + 1];
1360
+ positions[offset + 8] = positions[3 * 6 + 2];
1361
+ positions[offset + 9] = positions[3 * 2];
1362
+ positions[offset + 10] = positions[3 * 2 + 1];
1363
+ positions[offset + 11] = positions[3 * 2 + 2];
1364
+ offset += 3 * 4;
1365
+ positions[offset] = positions[3 * 2];
1366
+ positions[offset + 1] = positions[3 * 2 + 1];
1367
+ positions[offset + 2] = positions[3 * 2 + 2];
1368
+ positions[offset + 3] = positions[3 * 6];
1369
+ positions[offset + 4] = positions[3 * 6 + 1];
1370
+ positions[offset + 5] = positions[3 * 6 + 2];
1371
+ positions[offset + 6] = positions[3 * 7];
1372
+ positions[offset + 7] = positions[3 * 7 + 1];
1373
+ positions[offset + 8] = positions[3 * 7 + 2];
1374
+ positions[offset + 9] = positions[3 * 3];
1375
+ positions[offset + 10] = positions[3 * 3 + 1];
1376
+ positions[offset + 11] = positions[3 * 3 + 2];
1377
+ if (!drawNearPlane) {
1378
+ positions = positions.subarray(3 * 4);
1379
+ }
1380
+ const attributes = new GeometryAttributes_default({
1381
+ position: new GeometryAttribute_default({
1382
+ componentDatatype: ComponentDatatype_default.DOUBLE,
1383
+ componentsPerAttribute: 3,
1384
+ values: positions
1385
+ })
1386
+ });
1387
+ if (defined_default(vertexFormat.normal) || defined_default(vertexFormat.tangent) || defined_default(vertexFormat.bitangent) || defined_default(vertexFormat.st)) {
1388
+ const normals = defined_default(vertexFormat.normal) ? new Float32Array(3 * 4 * numberOfPlanes) : void 0;
1389
+ const tangents = defined_default(vertexFormat.tangent) ? new Float32Array(3 * 4 * numberOfPlanes) : void 0;
1390
+ const bitangents = defined_default(vertexFormat.bitangent) ? new Float32Array(3 * 4 * numberOfPlanes) : void 0;
1391
+ const st = defined_default(vertexFormat.st) ? new Float32Array(2 * 4 * numberOfPlanes) : void 0;
1392
+ const x = scratchXDirection;
1393
+ const y = scratchYDirection;
1394
+ const z = scratchZDirection;
1395
+ const negativeX = Cartesian3_default.negate(x, scratchNegativeX);
1396
+ const negativeY = Cartesian3_default.negate(y, scratchNegativeY);
1397
+ const negativeZ = Cartesian3_default.negate(z, scratchNegativeZ);
1398
+ offset = 0;
1399
+ if (drawNearPlane) {
1400
+ getAttributes(offset, normals, tangents, bitangents, st, negativeZ, x, y);
1401
+ offset += 3 * 4;
1402
+ }
1403
+ getAttributes(offset, normals, tangents, bitangents, st, z, negativeX, y);
1404
+ offset += 3 * 4;
1405
+ getAttributes(
1406
+ offset,
1407
+ normals,
1408
+ tangents,
1409
+ bitangents,
1410
+ st,
1411
+ negativeX,
1412
+ negativeZ,
1413
+ y
1414
+ );
1415
+ offset += 3 * 4;
1416
+ getAttributes(
1417
+ offset,
1418
+ normals,
1419
+ tangents,
1420
+ bitangents,
1421
+ st,
1422
+ negativeY,
1423
+ negativeZ,
1424
+ negativeX
1425
+ );
1426
+ offset += 3 * 4;
1427
+ getAttributes(offset, normals, tangents, bitangents, st, x, z, y);
1428
+ offset += 3 * 4;
1429
+ getAttributes(offset, normals, tangents, bitangents, st, y, z, negativeX);
1430
+ if (defined_default(normals)) {
1431
+ attributes.normal = new GeometryAttribute_default({
1432
+ componentDatatype: ComponentDatatype_default.FLOAT,
1433
+ componentsPerAttribute: 3,
1434
+ values: normals
1435
+ });
1436
+ }
1437
+ if (defined_default(tangents)) {
1438
+ attributes.tangent = new GeometryAttribute_default({
1439
+ componentDatatype: ComponentDatatype_default.FLOAT,
1440
+ componentsPerAttribute: 3,
1441
+ values: tangents
1442
+ });
1443
+ }
1444
+ if (defined_default(bitangents)) {
1445
+ attributes.bitangent = new GeometryAttribute_default({
1446
+ componentDatatype: ComponentDatatype_default.FLOAT,
1447
+ componentsPerAttribute: 3,
1448
+ values: bitangents
1449
+ });
1450
+ }
1451
+ if (defined_default(st)) {
1452
+ attributes.st = new GeometryAttribute_default({
1453
+ componentDatatype: ComponentDatatype_default.FLOAT,
1454
+ componentsPerAttribute: 2,
1455
+ values: st
1456
+ });
1457
+ }
1458
+ }
1459
+ const indices = new Uint16Array(6 * numberOfPlanes);
1460
+ for (let i = 0; i < numberOfPlanes; ++i) {
1461
+ const indexOffset = i * 6;
1462
+ const index = i * 4;
1463
+ indices[indexOffset] = index;
1464
+ indices[indexOffset + 1] = index + 1;
1465
+ indices[indexOffset + 2] = index + 2;
1466
+ indices[indexOffset + 3] = index;
1467
+ indices[indexOffset + 4] = index + 2;
1468
+ indices[indexOffset + 5] = index + 3;
1469
+ }
1470
+ return new Geometry_default({
1471
+ attributes,
1472
+ indices,
1473
+ primitiveType: PrimitiveType_default.TRIANGLES,
1474
+ boundingSphere: BoundingSphere_default.fromVertices(positions)
1475
+ });
1476
+ };
1477
+ var FrustumGeometry_default = FrustumGeometry;
1478
+
1479
+ export {
1480
+ OrthographicFrustum_default,
1481
+ PerspectiveFrustum_default,
1482
+ FrustumGeometry_default
1483
+ };