@hztxi/cesium-engine 25.0.4 → 25.0.7

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 (202) hide show
  1. package/Build/Workers/chunk-247MLVK2.js +124 -0
  2. package/Build/Workers/chunk-26I7TIAE.js +58 -0
  3. package/Build/Workers/chunk-26OYTC24.js +38 -0
  4. package/Build/Workers/chunk-2GJAWJJT.js +1344 -0
  5. package/Build/Workers/chunk-2IMOZG7R.js +973 -0
  6. package/Build/Workers/chunk-2J2VS5RI.js +288 -0
  7. package/Build/Workers/chunk-2L6JGSYJ.js +57 -0
  8. package/Build/Workers/chunk-32N2SB76.js +56 -0
  9. package/Build/Workers/chunk-375SHKGW.js +44 -0
  10. package/Build/Workers/chunk-37WL527K.js +1287 -0
  11. package/Build/Workers/chunk-3IGH46TC.js +1054 -0
  12. package/Build/Workers/chunk-47BSFGJC.js +837 -0
  13. package/Build/Workers/chunk-4J7PL5AM.js +454 -0
  14. package/Build/Workers/chunk-4UMO63VY.js +76 -0
  15. package/Build/Workers/chunk-5FYUSABU.js +945 -0
  16. package/Build/Workers/chunk-5WU37CUJ.js +630 -0
  17. package/Build/Workers/chunk-5YI3TQQC.js +778 -0
  18. package/Build/Workers/chunk-6EBDN5WS.js +97 -0
  19. package/Build/Workers/chunk-75HIWCEV.js +301 -0
  20. package/Build/Workers/chunk-7AMVPXZY.js +1992 -0
  21. package/Build/Workers/chunk-7BMDD6SM.js +124 -0
  22. package/Build/Workers/chunk-7OME2OKM.js +171 -0
  23. package/Build/Workers/chunk-A2BROW3D.js +352 -0
  24. package/Build/Workers/chunk-AEZQ2UWS.js +288 -0
  25. package/Build/Workers/chunk-AXE2ZIEG.js +219 -0
  26. package/Build/Workers/chunk-B4XOVZGA.js +476 -0
  27. package/Build/Workers/chunk-BDR7GL3E.js +1067 -0
  28. package/Build/Workers/chunk-C342XITR.js +44 -0
  29. package/Build/Workers/chunk-CDLPLYLV.js +1287 -0
  30. package/Build/Workers/chunk-CEKCKPFN.js +368 -0
  31. package/Build/Workers/chunk-CHMDKP5L.js +2342 -0
  32. package/Build/Workers/chunk-CWAUXQRF.js +754 -0
  33. package/Build/Workers/chunk-CWGB3D4Z.js +257 -0
  34. package/Build/Workers/chunk-DQEUGBGA.js +2719 -0
  35. package/Build/Workers/chunk-DUBE5G2H.js +497 -0
  36. package/Build/Workers/chunk-E4PBNWWK.js +58 -0
  37. package/Build/Workers/chunk-E5F7LDEP.js +3201 -0
  38. package/Build/Workers/chunk-E5MWOMVC.js +57 -0
  39. package/Build/Workers/chunk-EE3XBOQI.js +1483 -0
  40. package/Build/Workers/chunk-EHA2ZDPZ.js +415 -0
  41. package/Build/Workers/chunk-EKEKPAJF.js +454 -0
  42. package/Build/Workers/chunk-EOHKUXPX.js +198 -0
  43. package/Build/Workers/chunk-ERENMHG2.js +754 -0
  44. package/Build/Workers/chunk-ESQGFRLZ.js +163 -0
  45. package/Build/Workers/chunk-FAKYMBUA.js +1046 -0
  46. package/Build/Workers/chunk-FSK4OZOO.js +352 -0
  47. package/Build/Workers/chunk-FSLRYNZ6.js +682 -0
  48. package/Build/Workers/chunk-FV4OWDV4.js +9230 -0
  49. package/Build/Workers/chunk-FYRNNQSL.js +280 -0
  50. package/Build/Workers/chunk-GMDOGAXK.js +2719 -0
  51. package/Build/Workers/chunk-GRAFCIPA.js +455 -0
  52. package/Build/Workers/chunk-HEY4IOS3.js +140 -0
  53. package/Build/Workers/chunk-HRWFO57T.js +301 -0
  54. package/Build/Workers/chunk-HTCLVUBZ.js +82 -0
  55. package/Build/Workers/chunk-I2Q7XDRA.js +630 -0
  56. package/Build/Workers/chunk-ILPH3NF7.js +3794 -0
  57. package/Build/Workers/chunk-JMF4ATAS.js +3794 -0
  58. package/Build/Workers/chunk-JZUUODN6.js +97 -0
  59. package/Build/Workers/chunk-KEJKMITY.js +82 -0
  60. package/Build/Workers/chunk-KW2QZDUS.js +147 -0
  61. package/Build/Workers/chunk-KWVB54J6.js +241 -0
  62. package/Build/Workers/chunk-L6B5XPBL.js +73 -0
  63. package/Build/Workers/chunk-LGJXN2VP.js +352 -0
  64. package/Build/Workers/chunk-LY2UG3HV.js +38 -0
  65. package/Build/Workers/chunk-M3B3ZUU2.js +476 -0
  66. package/Build/Workers/chunk-MKR6YCMG.js +497 -0
  67. package/Build/Workers/chunk-MROMS2RL.js +162 -0
  68. package/Build/Workers/chunk-MUNAUSK7.js +280 -0
  69. package/Build/Workers/chunk-NCPJBP24.js +140 -0
  70. package/Build/Workers/chunk-NFY5V6MR.js +102 -0
  71. package/Build/Workers/chunk-NHU5JEPP.js +1344 -0
  72. package/Build/Workers/chunk-OODXPB45.js +73 -0
  73. package/Build/Workers/chunk-OXZ5J3JW.js +368 -0
  74. package/Build/Workers/chunk-OYPSUED3.js +1067 -0
  75. package/Build/Workers/chunk-QBSWSTHY.js +257 -0
  76. package/Build/Workers/chunk-QDJYG7QL.js +352 -0
  77. package/Build/Workers/chunk-QIOOTLWN.js +56 -0
  78. package/Build/Workers/chunk-QUPRALOD.js +101 -0
  79. package/Build/Workers/chunk-RBEVHHXK.js +3201 -0
  80. package/Build/Workers/chunk-RHO5HV52.js +305 -0
  81. package/Build/Workers/chunk-RX3U2BBW.js +1483 -0
  82. package/Build/Workers/chunk-S3XHL7GO.js +1992 -0
  83. package/Build/Workers/chunk-SBIC4OGS.js +171 -0
  84. package/Build/Workers/chunk-SVCZUP5R.js +837 -0
  85. package/Build/Workers/chunk-T4CYNROE.js +102 -0
  86. package/Build/Workers/chunk-T5VLPB4H.js +414 -0
  87. package/Build/Workers/chunk-TBHW5UME.js +973 -0
  88. package/Build/Workers/chunk-TPOX6IOR.js +1054 -0
  89. package/Build/Workers/chunk-TX763OWB.js +387 -0
  90. package/Build/Workers/chunk-ULNBTI6R.js +138 -0
  91. package/Build/Workers/chunk-UMUS2AQQ.js +398 -0
  92. package/Build/Workers/chunk-UTAWMCSE.js +163 -0
  93. package/Build/Workers/chunk-UZ7GTP2L.js +162 -0
  94. package/Build/Workers/chunk-VETQOADR.js +2342 -0
  95. package/Build/Workers/chunk-VXRWOM3T.js +101 -0
  96. package/Build/Workers/chunk-W3C7OHXF.js +387 -0
  97. package/Build/Workers/chunk-WB5GWYDP.js +455 -0
  98. package/Build/Workers/chunk-WN6MAL25.js +682 -0
  99. package/Build/Workers/chunk-WTR7KMQA.js +693 -0
  100. package/Build/Workers/chunk-WTTFMU3P.js +241 -0
  101. package/Build/Workers/chunk-WULONJZC.js +1800 -0
  102. package/Build/Workers/chunk-WVVFCMYF.js +147 -0
  103. package/Build/Workers/chunk-WZPMAVTV.js +511 -0
  104. package/Build/Workers/chunk-XAVNBZQ6.js +56 -0
  105. package/Build/Workers/chunk-XDSDR62Y.js +1800 -0
  106. package/Build/Workers/chunk-XDZCVNIZ.js +198 -0
  107. package/Build/Workers/chunk-XNLCW2OI.js +138 -0
  108. package/Build/Workers/chunk-XNQ2BTJD.js +693 -0
  109. package/Build/Workers/chunk-XZYBDSFP.js +305 -0
  110. package/Build/Workers/chunk-Y7KVUJEB.js +219 -0
  111. package/Build/Workers/chunk-YDYN3RPI.js +398 -0
  112. package/Build/Workers/chunk-YMMEQBEW.js +511 -0
  113. package/Build/Workers/chunk-YQFOQAXD.js +9230 -0
  114. package/Build/Workers/chunk-Z6JV4DZG.js +1046 -0
  115. package/Build/Workers/chunk-ZTK5EBUI.js +76 -0
  116. package/Build/Workers/chunk-ZZPDORJK.js +56 -0
  117. package/Build/Workers/combineGeometry.js +24 -24
  118. package/Build/Workers/createBoxGeometry.js +18 -18
  119. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  120. package/Build/Workers/createCircleGeometry.js +26 -26
  121. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  122. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  123. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  124. package/Build/Workers/createCorridorGeometry.js +29 -29
  125. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  126. package/Build/Workers/createCylinderGeometry.js +20 -20
  127. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  128. package/Build/Workers/createEllipseGeometry.js +26 -26
  129. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  130. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  131. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  132. package/Build/Workers/createFrustumGeometry.js +18 -18
  133. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  134. package/Build/Workers/createGeometry.js +24 -24
  135. package/Build/Workers/createGroundPolylineGeometry.js +95 -31
  136. package/Build/Workers/createPlaneGeometry.js +16 -16
  137. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  138. package/Build/Workers/createPolygonGeometry.js +32 -32
  139. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  140. package/Build/Workers/createPolylineGeometry.js +25 -25
  141. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  142. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  143. package/Build/Workers/createRectangleGeometry.js +27 -27
  144. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  145. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  146. package/Build/Workers/createSphereGeometry.js +19 -19
  147. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  148. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  149. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  150. package/Build/Workers/createVectorTileGeometries.js +24 -24
  151. package/Build/Workers/createVectorTilePoints.js +13 -13
  152. package/Build/Workers/createVectorTilePolygons.js +22 -22
  153. package/Build/Workers/createVectorTilePolylines.js +14 -14
  154. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +26 -26
  155. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -23
  156. package/Build/Workers/createVerticesFromHeightmap.js +23 -23
  157. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +21 -21
  158. package/Build/Workers/createWallGeometry.js +24 -24
  159. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  160. package/Build/Workers/decodeDraco.js +10 -10
  161. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  162. package/Build/Workers/decodeI3S.js +10 -10
  163. package/Build/Workers/gaussianSplatSorter.js +4 -4
  164. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  165. package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
  166. package/Build/Workers/transcodeKTX2.js +6 -6
  167. package/Build/Workers/transferTypedArrayTest.js +1 -1
  168. package/Build/Workers/upsampleQuantizedTerrainMesh.js +23 -23
  169. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +26 -26
  170. package/Source/Core/GroundPolylineGeometry.js +99 -4
  171. package/Source/Core/PolylinePipeline.js +9 -2
  172. package/Source/DataSources/PolylineGeometryUpdater.js +125 -7
  173. package/Source/Scene/Camera.js +56 -3
  174. package/Source/Scene/CameraFlightPath.js +14 -0
  175. package/Source/Scene/ClassificationPrimitive.js +63 -3
  176. package/Source/Scene/ColumbusWorlds.js +190 -0
  177. package/Source/Scene/FrameState.js +10 -0
  178. package/Source/Scene/Globe.js +89 -22
  179. package/Source/Scene/GlobeDepth.js +216 -5
  180. package/Source/Scene/GlobeSurfaceTileProvider.js +897 -678
  181. package/Source/Scene/GroundPolylinePrimitive.js +2 -1
  182. package/Source/Scene/Polyline.js +32 -5
  183. package/Source/Scene/PolylineCollection.js +41 -2
  184. package/Source/Scene/Primitive.js +12 -13
  185. package/Source/Scene/PrimitivePipeline.js +158 -28
  186. package/Source/Scene/Scene.js +428 -5
  187. package/Source/Scene/SceneTransforms.js +17 -0
  188. package/Source/Scene/ScreenSpaceCameraController.js +12 -3
  189. package/Source/Shaders/PolylineShadowVolumeFS.glsl +14 -0
  190. package/Source/Shaders/PolylineShadowVolumeFS.js +14 -0
  191. package/Source/Shaders/PolylineShadowVolumeMorphVS.glsl +14 -1
  192. package/Source/Shaders/PolylineShadowVolumeMorphVS.js +14 -1
  193. package/Source/Shaders/PolylineShadowVolumeVS.glsl +7 -0
  194. package/Source/Shaders/PolylineShadowVolumeVS.js +7 -0
  195. package/Source/Shaders/PolylineVS.glsl +16 -6
  196. package/Source/Shaders/PolylineVS.js +16 -6
  197. package/Source/Shaders/RestoreDepth.glsl +8 -0
  198. package/Source/Shaders/RestoreDepth.js +10 -0
  199. package/Source/ThirdParty/zip-module.wasm +0 -0
  200. package/index.d.ts +535 -1393
  201. package/index.js +267 -265
  202. package/package.json +10 -10
@@ -20,6 +20,7 @@ import GlobeFS from "../Shaders/GlobeFS.js";
20
20
  import GlobeVS from "../Shaders/GlobeVS.js";
21
21
  import AtmosphereCommon from "../Shaders/AtmosphereCommon.js";
22
22
  import GroundAtmosphere from "../Shaders/GroundAtmosphere.js";
23
+ import ColumbusWorlds from "./ColumbusWorlds.js";
23
24
  import GlobeSurfaceShaderSet from "./GlobeSurfaceShaderSet.js";
24
25
  import GlobeSurfaceTileProvider from "./GlobeSurfaceTileProvider.js";
25
26
  import GlobeTranslucency from "./GlobeTranslucency.js";
@@ -724,24 +725,28 @@ function makeShadersDirty(globe) {
724
725
 
725
726
  function createComparePickTileFunction(rayOrigin) {
726
727
  return function (a, b) {
727
- const aDist = BoundingSphere.distanceSquaredTo(
728
- a.pickBoundingSphere,
729
- rayOrigin,
730
- );
731
- const bDist = BoundingSphere.distanceSquaredTo(
732
- b.pickBoundingSphere,
733
- rayOrigin,
734
- );
728
+ const aDist = BoundingSphere.distanceSquaredTo(a.sphere, rayOrigin);
729
+ const bDist = BoundingSphere.distanceSquaredTo(b.sphere, rayOrigin);
735
730
 
736
731
  return aDist - bDist;
737
732
  };
738
733
  }
739
734
 
735
+ // Columbus repeat worlds: how many translated world copies to test on either
736
+ // side of the pick ray's own world when repeat worlds are enabled.
737
+ const GLOBE_COLUMBUS_MAX_EXTRA_WORLDS = 2;
738
+
739
+ function getGlobeColumbusWorldWidth(projection) {
740
+ return ColumbusWorlds.getWorldWidth(projection);
741
+ }
742
+
740
743
  const scratchArray = [];
741
744
  const scratchSphereIntersectionResult = {
742
745
  start: 0.0,
743
746
  stop: 0.0,
744
747
  };
748
+ const scratchPickOffsetSphere = new BoundingSphere();
749
+ const scratchColumbusPickRay = new Ray();
745
750
 
746
751
  /**
747
752
  * Find an intersection between a ray and the globe surface that was rendered. The ray must be given in world coordinates.
@@ -774,6 +779,12 @@ Globe.prototype.pickWorldCoordinates = function (
774
779
  const mode = scene.mode;
775
780
  const projection = scene.mapProjection;
776
781
 
782
+ const repeatWorlds =
783
+ scene.columbusRepeatWorlds === true && mode === SceneMode.COLUMBUS_VIEW;
784
+ const worldWidth = repeatWorlds
785
+ ? getGlobeColumbusWorldWidth(projection)
786
+ : 0.0;
787
+
777
788
  const sphereIntersections = scratchArray;
778
789
  sphereIntersections.length = 0;
779
790
 
@@ -810,13 +821,48 @@ Globe.prototype.pickWorldCoordinates = function (
810
821
  continue;
811
822
  }
812
823
 
813
- const boundingSphereIntersection = IntersectionTests.raySphere(
814
- ray,
815
- boundingVolume,
816
- scratchSphereIntersectionResult,
817
- );
818
- if (defined(boundingSphereIntersection)) {
819
- sphereIntersections.push(surfaceTile);
824
+ if (!repeatWorlds) {
825
+ const boundingSphereIntersection = IntersectionTests.raySphere(
826
+ ray,
827
+ boundingVolume,
828
+ scratchSphereIntersectionResult,
829
+ );
830
+ if (defined(boundingSphereIntersection)) {
831
+ sphereIntersections.push({
832
+ surfaceTile,
833
+ sphere: boundingVolume,
834
+ offset: 0.0,
835
+ });
836
+ }
837
+ continue;
838
+ }
839
+
840
+ // Columbus repeat worlds: a translated copy of this tile may be hit even
841
+ // when the primary sphere is not. Test the copies around the ray's own
842
+ // world so points beyond the ±180° meridian pick correctly.
843
+ const rayWorld = Math.round(ray.origin.y / worldWidth);
844
+ for (
845
+ let w = rayWorld - GLOBE_COLUMBUS_MAX_EXTRA_WORLDS;
846
+ w <= rayWorld + GLOBE_COLUMBUS_MAX_EXTRA_WORLDS;
847
+ ++w
848
+ ) {
849
+ const offset = w * worldWidth;
850
+ const offsetSphere = scratchPickOffsetSphere;
851
+ Cartesian3.clone(boundingVolume.center, offsetSphere.center);
852
+ offsetSphere.center.y += offset;
853
+ offsetSphere.radius = boundingVolume.radius;
854
+ const boundingSphereIntersection = IntersectionTests.raySphere(
855
+ ray,
856
+ offsetSphere,
857
+ scratchSphereIntersectionResult,
858
+ );
859
+ if (defined(boundingSphereIntersection)) {
860
+ sphereIntersections.push({
861
+ surfaceTile,
862
+ sphere: BoundingSphere.clone(offsetSphere, new BoundingSphere()),
863
+ offset,
864
+ });
865
+ }
820
866
  }
821
867
  }
822
868
 
@@ -825,13 +871,34 @@ Globe.prototype.pickWorldCoordinates = function (
825
871
  let intersection;
826
872
  const length = sphereIntersections.length;
827
873
  for (let i = 0; i < length; ++i) {
828
- intersection = sphereIntersections[i].pick(
829
- ray,
830
- scene.mode,
831
- scene.mapProjection,
832
- cullBackFaces,
833
- result,
834
- );
874
+ const candidate = sphereIntersections[i];
875
+ const offset = candidate.offset;
876
+ if (offset === 0.0) {
877
+ intersection = candidate.surfaceTile.pick(
878
+ ray,
879
+ scene.mode,
880
+ scene.mapProjection,
881
+ cullBackFaces,
882
+ result,
883
+ );
884
+ } else {
885
+ // Pick against the copy by shifting the ray into the primary world,
886
+ // then shifting the hit point back onto the copy.
887
+ const pickRay = scratchColumbusPickRay;
888
+ Cartesian3.clone(ray.origin, pickRay.origin);
889
+ pickRay.origin.y -= offset;
890
+ Cartesian3.clone(ray.direction, pickRay.direction);
891
+ intersection = candidate.surfaceTile.pick(
892
+ pickRay,
893
+ scene.mode,
894
+ scene.mapProjection,
895
+ cullBackFaces,
896
+ result,
897
+ );
898
+ if (defined(intersection)) {
899
+ intersection.y += offset;
900
+ }
901
+ }
835
902
  if (defined(intersection)) {
836
903
  break;
837
904
  }
@@ -8,7 +8,9 @@ import PixelDatatype from "../Renderer/PixelDatatype.js";
8
8
  import RenderState from "../Renderer/RenderState.js";
9
9
  import PassThrough from "../Shaders/PostProcessStages/PassThrough.js";
10
10
  import PassThroughDepth from "../Shaders/PostProcessStages/PassThroughDepth.js";
11
+ import RestoreDepth from "../Shaders/RestoreDepth.js";
11
12
  import BlendingState from "./BlendingState.js";
13
+ import DepthFunction from "./DepthFunction.js";
12
14
  import StencilConstants from "./StencilConstants.js";
13
15
  import StencilFunction from "./StencilFunction.js";
14
16
  import StencilOperation from "./StencilOperation.js";
@@ -33,6 +35,12 @@ function GlobeDepth() {
33
35
  supportsDepthTexture: true,
34
36
  });
35
37
  this._copyDepthFramebuffer = new FramebufferManager();
38
+ // Extra globe depth copies for frustum 1..n. Each frustum packs depth
39
+ // against its own near/far, so a single shared copy cannot be decoded
40
+ // correctly by the other frustums (e.g. a Columbus world copy pass).
41
+ this._copyDepthFramebuffers = [];
42
+ this._copyDepthCommands = [];
43
+ this._restoreDepthCommands = [];
36
44
  this._tempCopyDepthFramebuffer = new FramebufferManager();
37
45
  this._updateDepthFramebuffer = new FramebufferManager({
38
46
  createColorAttachments: false,
@@ -50,6 +58,7 @@ function GlobeDepth() {
50
58
  this._rs = undefined;
51
59
  this._rsBlend = undefined;
52
60
  this._rsUpdate = undefined;
61
+ this._rsRestoreDepth = undefined;
53
62
 
54
63
  this._useScissorTest = false;
55
64
  this._scissorRectangle = undefined;
@@ -149,6 +158,29 @@ function updateCopyCommands(globeDepth, context, width, height, passState) {
149
158
  mask: StencilConstants.CESIUM_3D_TILE_MASK,
150
159
  },
151
160
  });
161
+
162
+ // Writes a depth copy back into the depth buffer. Color writes are off and
163
+ // the quad's fragment depth comes from the sampled texture. The depth test
164
+ // must stay enabled (ALWAYS): a disabled depth test discards the write, so
165
+ // the quad would only paint color and never restore the buffer.
166
+ globeDepth._rsRestoreDepth = RenderState.fromCache({
167
+ viewport: viewport,
168
+ scissorTest: {
169
+ enabled: globeDepth._useScissorTest,
170
+ rectangle: globeDepth._scissorRectangle,
171
+ },
172
+ colorMask: {
173
+ red: false,
174
+ green: false,
175
+ blue: false,
176
+ alpha: false,
177
+ },
178
+ depthTest: {
179
+ enabled: true,
180
+ func: DepthFunction.ALWAYS,
181
+ },
182
+ depthMask: true,
183
+ });
152
184
  }
153
185
 
154
186
  if (!defined(globeDepth._copyDepthCommand)) {
@@ -272,6 +304,12 @@ GlobeDepth.prototype.update = function (
272
304
  );
273
305
  }
274
306
  this._copyDepthFramebuffer.update(context, width, height);
307
+ for (let i = 0; i < this._copyDepthFramebuffers.length; i++) {
308
+ const framebuffer = this._copyDepthFramebuffers[i];
309
+ if (defined(framebuffer)) {
310
+ framebuffer.update(context, width, height);
311
+ }
312
+ }
275
313
  updateCopyCommands(this, context, width, height, passState);
276
314
  context.uniformState.globeDepthTexture = undefined;
277
315
 
@@ -292,13 +330,165 @@ GlobeDepth.prototype.prepareColorTextures = function (context, blitStencil) {
292
330
  }
293
331
  };
294
332
 
295
- GlobeDepth.prototype.executeCopyDepth = function (context, passState) {
296
- if (defined(this._copyDepthCommand)) {
333
+ /**
334
+ * Returns the copy depth framebuffer for a frustum, creating it on demand.
335
+ *
336
+ * @param {Context} context The context used for rendering.
337
+ * @param {number} frustumIndex The index of the frustum.
338
+ * @returns {FramebufferManager|undefined} The framebuffer manager, or
339
+ * <code>undefined</code> for frustum 0 (the shared copy).
340
+ *
341
+ * @private
342
+ */
343
+ GlobeDepth.prototype._getFrustumCopyDepthFramebuffer = function (
344
+ context,
345
+ frustumIndex,
346
+ ) {
347
+ if (frustumIndex === 0) {
348
+ return this._copyDepthFramebuffer;
349
+ }
350
+ let framebuffer = this._copyDepthFramebuffers[frustumIndex];
351
+ if (!defined(framebuffer)) {
352
+ framebuffer = this._copyDepthFramebuffers[frustumIndex] =
353
+ new FramebufferManager();
354
+ const mainColorTexture = this._copyDepthFramebuffer.getColorTexture();
355
+ if (defined(mainColorTexture)) {
356
+ framebuffer.update(
357
+ context,
358
+ mainColorTexture.width,
359
+ mainColorTexture.height,
360
+ );
361
+ }
362
+ }
363
+ return framebuffer;
364
+ };
365
+
366
+ /**
367
+ * Returns the copy depth command for a frustum, creating it on demand.
368
+ *
369
+ * @param {Context} context The context used for rendering.
370
+ * @param {number} frustumIndex The index of the frustum.
371
+ * @returns {ViewportQuadCommand|undefined} The command, or <code>undefined</code>.
372
+ *
373
+ * @private
374
+ */
375
+ GlobeDepth.prototype._getFrustumCopyDepthCommand = function (
376
+ context,
377
+ frustumIndex,
378
+ ) {
379
+ if (frustumIndex === 0) {
380
+ return this._copyDepthCommand;
381
+ }
382
+ let command = this._copyDepthCommands[frustumIndex];
383
+ if (!defined(command)) {
384
+ const globeDepth = this;
385
+ command = this._copyDepthCommands[frustumIndex] =
386
+ context.createViewportQuadCommand(PassThroughDepth, {
387
+ uniformMap: {
388
+ u_depthTexture: function () {
389
+ return globeDepth.colorFramebufferManager.getDepthStencilTexture();
390
+ },
391
+ },
392
+ owner: globeDepth,
393
+ });
394
+ }
395
+ command.renderState = this._rs;
396
+ command.framebuffer = this._getFrustumCopyDepthFramebuffer(
397
+ context,
398
+ frustumIndex,
399
+ ).framebuffer;
400
+ return command;
401
+ };
402
+
403
+ /**
404
+ * Copy the current globe depth into the copy depth texture of a frustum and
405
+ * make it the active <code>czm_globeDepthTexture</code>.
406
+ *
407
+ * @param {Context} context The context used for rendering.
408
+ * @param {PassState} passState Render state for subsequent rendering passes.
409
+ * @param {number} [frustumIndex=0] The index of the frustum being rendered.
410
+ *
411
+ * @private
412
+ */
413
+ GlobeDepth.prototype.executeCopyDepth = function (
414
+ context,
415
+ passState,
416
+ frustumIndex,
417
+ ) {
418
+ const index = defined(frustumIndex) ? frustumIndex : 0;
419
+ const framebuffer = this._getFrustumCopyDepthFramebuffer(context, index);
420
+ const command = this._getFrustumCopyDepthCommand(context, index);
421
+ if (defined(command)) {
297
422
  this.prepareColorTextures(context);
298
- this._copyDepthCommand.execute(context, passState);
299
- context.uniformState.globeDepthTexture =
300
- this._copyDepthFramebuffer.getColorTexture();
423
+ command.execute(context, passState);
424
+ context.uniformState.globeDepthTexture = framebuffer.getColorTexture();
425
+ }
426
+ };
427
+
428
+ /**
429
+ * Make an already copied globe depth texture the active
430
+ * <code>czm_globeDepthTexture</code>. Used by the Columbus world copy pass,
431
+ * which re-executes the classification commands of a primary frustum and must
432
+ * therefore read the depth copy produced for that same frustum.
433
+ *
434
+ * @param {Context} context The context used for rendering.
435
+ * @param {number} [frustumIndex=0] The index of the frustum.
436
+ *
437
+ * @private
438
+ */
439
+ GlobeDepth.prototype.useCopyDepth = function (context, frustumIndex) {
440
+ const index = defined(frustumIndex) ? frustumIndex : 0;
441
+ let framebuffer = index > 0 ? this._copyDepthFramebuffers[index] : undefined;
442
+ if (!defined(framebuffer) || !defined(framebuffer.framebuffer)) {
443
+ // The requested frustum never produced a copy (e.g. the primary pass was
444
+ // skipped this frame); keep the shared copy so the uniform stays defined.
445
+ framebuffer = this._copyDepthFramebuffer;
446
+ }
447
+ context.uniformState.globeDepthTexture = framebuffer.getColorTexture();
448
+ };
449
+
450
+ /**
451
+ * Writes an already copied globe depth back into the depth buffer, so terrain
452
+ * classification can be re-executed after the primary pass finished. Ground
453
+ * classification needs the terrain depth in the buffer (its stencil pass depth
454
+ * tests the shadow volume against it), but the scene clears the globe depth
455
+ * after the primary classification pass whenever
456
+ * {@link Globe#depthTestAgainstTerrain} is off - the walkthrough used by the
457
+ * Columbus world copy pass then classifies against an empty buffer and draws
458
+ * nothing.
459
+ *
460
+ * @param {Context} context The context used for rendering.
461
+ * @param {PassState} passState The render pass state, whose framebuffer must be the one that receives the depth.
462
+ * @param {number} [frustumIndex=0] The index of the frustum whose copy should be restored.
463
+ *
464
+ * @private
465
+ */
466
+ GlobeDepth.prototype.executeRestoreDepth = function (
467
+ context,
468
+ passState,
469
+ frustumIndex,
470
+ ) {
471
+ const index = defined(frustumIndex) ? frustumIndex : 0;
472
+ const framebuffer = this._getFrustumCopyDepthFramebuffer(context, index);
473
+ const renderState = this._rsRestoreDepth;
474
+ if (!defined(framebuffer.getColorTexture()) || !defined(renderState)) {
475
+ return;
476
+ }
477
+
478
+ let command = this._restoreDepthCommands[index];
479
+ if (!defined(command)) {
480
+ command = this._restoreDepthCommands[index] =
481
+ context.createViewportQuadCommand(RestoreDepth, {
482
+ uniformMap: {
483
+ u_depthTexture: function () {
484
+ return framebuffer.getColorTexture();
485
+ },
486
+ },
487
+ owner: this,
488
+ });
301
489
  }
490
+ command.renderState = renderState;
491
+ command.execute(context, passState);
302
492
  };
303
493
 
304
494
  /**
@@ -379,6 +569,27 @@ GlobeDepth.prototype.destroy = function () {
379
569
  this._pickColorFramebuffer.destroy();
380
570
  this._outputFramebuffer.destroy();
381
571
  this._copyDepthFramebuffer.destroy();
572
+ for (let i = 0; i < this._copyDepthFramebuffers.length; i++) {
573
+ const framebuffer = this._copyDepthFramebuffers[i];
574
+ if (defined(framebuffer)) {
575
+ framebuffer.destroy();
576
+ }
577
+ }
578
+ this._copyDepthFramebuffers.length = 0;
579
+ for (let i = 0; i < this._copyDepthCommands.length; i++) {
580
+ const command = this._copyDepthCommands[i];
581
+ if (defined(command) && defined(command.shaderProgram)) {
582
+ command.shaderProgram = command.shaderProgram.destroy();
583
+ }
584
+ }
585
+ this._copyDepthCommands.length = 0;
586
+ for (let i = 0; i < this._restoreDepthCommands.length; i++) {
587
+ const command = this._restoreDepthCommands[i];
588
+ if (defined(command) && defined(command.shaderProgram)) {
589
+ command.shaderProgram = command.shaderProgram.destroy();
590
+ }
591
+ }
592
+ this._restoreDepthCommands.length = 0;
382
593
  this._tempCopyDepthFramebuffer.destroy();
383
594
  this._updateDepthFramebuffer.destroy();
384
595