@cesium/engine 11.1.0 → 12.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/Build/Workers/{chunk-U72QNFOJ.js → chunk-22FZ334F.js} +10 -10
  2. package/Build/Workers/{chunk-GNBFYG7F.js → chunk-2F42VIW6.js} +13 -13
  3. package/Build/Workers/{chunk-K4GQUNB5.js → chunk-2IJZVFHY.js} +5 -5
  4. package/Build/Workers/{chunk-7KTQP4VB.js → chunk-2XOUWNPN.js} +5 -5
  5. package/Build/Workers/{chunk-IBLIYJZR.js → chunk-3Y4UGAYI.js} +6 -6
  6. package/Build/Workers/{chunk-VJZB3WAV.js → chunk-54NYY4U4.js} +7 -7
  7. package/Build/Workers/{chunk-DHYHSFFJ.js → chunk-647NL6VU.js} +2 -2
  8. package/Build/Workers/{chunk-CKY7HOHV.js → chunk-76KRKKEF.js} +9 -9
  9. package/Build/Workers/{chunk-BHQJ2NT7.js → chunk-7CKQ7PVJ.js} +6 -6
  10. package/Build/Workers/{chunk-5PTXS2GO.js → chunk-7D6T2WYT.js} +7 -7
  11. package/Build/Workers/{chunk-PRGYLLJT.js → chunk-7EBHNJTG.js} +1 -1
  12. package/Build/Workers/{chunk-YFXQECWV.js → chunk-AER5CLXD.js} +5 -5
  13. package/Build/Workers/{chunk-N5KJGGCM.js → chunk-AGYO4ZSF.js} +17 -17
  14. package/Build/Workers/{chunk-VU2MNO7L.js → chunk-BH5M522L.js} +7 -7
  15. package/Build/Workers/{chunk-MXIZJAPH.js → chunk-COHL4R3G.js} +1 -1
  16. package/Build/Workers/{chunk-FIGIZHAQ.js → chunk-DJ7K7EYK.js} +11 -11
  17. package/Build/Workers/{chunk-3Q2L65QU.js → chunk-DR56WFYZ.js} +7 -7
  18. package/Build/Workers/{chunk-AD63PIY6.js → chunk-EMCXAVSG.js} +2 -2
  19. package/Build/Workers/{chunk-YSGTGQQO.js → chunk-ENARO52I.js} +14 -14
  20. package/Build/Workers/{chunk-5OOFQLKF.js → chunk-ETXXXGMP.js} +7 -7
  21. package/Build/Workers/{chunk-E27BLMDD.js → chunk-GBPW65E3.js} +6 -6
  22. package/Build/Workers/{chunk-NGPPMXRM.js → chunk-GRQQHWMD.js} +7 -7
  23. package/Build/Workers/{chunk-SMDOP47J.js → chunk-GSJ6LWIS.js} +10 -10
  24. package/Build/Workers/{chunk-26GA3JAM.js → chunk-H3RMGG7L.js} +5 -5
  25. package/Build/Workers/{chunk-PGRPDNHG.js → chunk-IAX6MIST.js} +17 -17
  26. package/Build/Workers/{chunk-5ODQSF26.js → chunk-IJWXYSFC.js} +2 -2
  27. package/Build/Workers/{chunk-C6YYBQXW.js → chunk-IVCFTVYW.js} +4 -4
  28. package/Build/Workers/{chunk-JW4FOI6M.js → chunk-JAKTB6CE.js} +11 -11
  29. package/Build/Workers/{chunk-TKVT5GQM.js → chunk-JPNFQRN7.js} +13 -13
  30. package/Build/Workers/{chunk-E63IIM5T.js → chunk-K7QC3WDT.js} +1 -1
  31. package/Build/Workers/{chunk-TGONEMZO.js → chunk-KJ65M35B.js} +11 -11
  32. package/Build/Workers/{chunk-2ZGOQXYU.js → chunk-KKMH4BKN.js} +6 -6
  33. package/Build/Workers/{chunk-76BYBWHP.js → chunk-LBNGHEJY.js} +4 -4
  34. package/Build/Workers/{chunk-XY4BATBS.js → chunk-LVHHB5T6.js} +4 -4
  35. package/Build/Workers/{chunk-S6MRMMQU.js → chunk-MV7YO647.js} +6 -6
  36. package/Build/Workers/{chunk-6CHGCNMW.js → chunk-NELAPOO6.js} +2 -2
  37. package/Build/Workers/{chunk-GESF4OXQ.js → chunk-NL73INJS.js} +2 -2
  38. package/Build/Workers/{chunk-GGZJN2TI.js → chunk-PH3T7LNP.js} +15 -15
  39. package/Build/Workers/{chunk-YZ733KKS.js → chunk-PISTPJXS.js} +12 -12
  40. package/Build/Workers/{chunk-GWCFU2SA.js → chunk-PJHRB4YJ.js} +7 -7
  41. package/Build/Workers/{chunk-I2ITFFPX.js → chunk-PNA47CR7.js} +1 -1
  42. package/Build/Workers/{chunk-7JO7GPJN.js → chunk-Q7IIOKAT.js} +1 -1
  43. package/Build/Workers/{chunk-27HUZ7SA.js → chunk-U7SH6OK7.js} +4 -4
  44. package/Build/Workers/{chunk-M3GMB5OP.js → chunk-VHGI7D3P.js} +10 -10
  45. package/Build/Workers/{chunk-FDOV2LBJ.js → chunk-VO4SXJXT.js} +7 -7
  46. package/Build/Workers/{chunk-7BMOHCPM.js → chunk-VXVQITFC.js} +13 -13
  47. package/Build/Workers/{chunk-DI5NGJUP.js → chunk-WMHJAREU.js} +2 -2
  48. package/Build/Workers/{chunk-EJZTDTUH.js → chunk-X6YBZOOA.js} +4 -4
  49. package/Build/Workers/{chunk-472HQ3EH.js → chunk-XDJ7V4NZ.js} +5 -5
  50. package/Build/Workers/{chunk-E6V6SQZW.js → chunk-YT5PQMSP.js} +6 -6
  51. package/Build/Workers/{chunk-O3E4OAOE.js → chunk-ZCCI55EY.js} +13 -13
  52. package/Build/Workers/{chunk-7O373FFS.js → chunk-ZPTNVB3S.js} +8 -8
  53. package/Build/Workers/combineGeometry.js +22 -22
  54. package/Build/Workers/createBoxGeometry.js +16 -16
  55. package/Build/Workers/createBoxOutlineGeometry.js +14 -14
  56. package/Build/Workers/createCircleGeometry.js +24 -24
  57. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  60. package/Build/Workers/createCorridorGeometry.js +27 -27
  61. package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
  62. package/Build/Workers/createCylinderGeometry.js +18 -18
  63. package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
  64. package/Build/Workers/createEllipseGeometry.js +24 -24
  65. package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipsoidGeometry.js +17 -17
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
  68. package/Build/Workers/createFrustumGeometry.js +16 -16
  69. package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
  70. package/Build/Workers/createGeometry.js +22 -22
  71. package/Build/Workers/createGroundPolylineGeometry.js +20 -20
  72. package/Build/Workers/createPlaneGeometry.js +14 -14
  73. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  74. package/Build/Workers/createPolygonGeometry.js +30 -30
  75. package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
  76. package/Build/Workers/createPolylineGeometry.js +23 -23
  77. package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
  79. package/Build/Workers/createRectangleGeometry.js +25 -25
  80. package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
  81. package/Build/Workers/createSimplePolylineGeometry.js +21 -21
  82. package/Build/Workers/createSphereGeometry.js +17 -17
  83. package/Build/Workers/createSphereOutlineGeometry.js +16 -16
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
  86. package/Build/Workers/createVectorTileGeometries.js +22 -22
  87. package/Build/Workers/createVectorTilePoints.js +12 -12
  88. package/Build/Workers/createVectorTilePolygons.js +20 -20
  89. package/Build/Workers/createVectorTilePolylines.js +13 -13
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
  91. package/Build/Workers/createVerticesFromHeightmap.js +20 -20
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  93. package/Build/Workers/createWallGeometry.js +22 -22
  94. package/Build/Workers/createWallOutlineGeometry.js +21 -21
  95. package/Build/Workers/decodeDraco.js +11 -11
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +10 -10
  98. package/Build/Workers/transcodeKTX2.js +7 -7
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  101. package/Source/Core/BoundingSphere.js +1 -1
  102. package/Source/Core/Color.js +1 -1
  103. package/Source/Core/CorridorGeometryLibrary.js +4 -4
  104. package/Source/Core/EllipseGeometry.js +1 -1
  105. package/Source/Core/EllipsoidGeodesic.js +1 -1
  106. package/Source/Core/FrustumGeometry.js +1 -1
  107. package/Source/Core/Ion.js +1 -1
  108. package/Source/Core/Math.js +2 -0
  109. package/Source/Core/PolylineVolumeGeometryLibrary.js +2 -2
  110. package/Source/Core/decodeGoogleEarthEnterpriseData.js +1 -1
  111. package/Source/DataSources/DataSourceDisplay.js +1 -1
  112. package/Source/DataSources/ModelGraphics.js +1 -0
  113. package/Source/Renderer/AutomaticUniforms.js +13 -0
  114. package/Source/Renderer/CubeMap.js +89 -12
  115. package/Source/Renderer/CubeMapFace.js +90 -13
  116. package/Source/Renderer/UniformState.js +13 -0
  117. package/Source/Scene/ArcGisMapService.js +1 -1
  118. package/Source/Scene/Atmosphere.js +22 -0
  119. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  120. package/Source/Scene/Cesium3DTileset.js +39 -0
  121. package/Source/Scene/DynamicEnvironmentMapManager.js +894 -0
  122. package/Source/Scene/Fog.js +75 -82
  123. package/Source/Scene/FrameState.js +5 -3
  124. package/Source/Scene/ImageBasedLighting.js +7 -64
  125. package/Source/Scene/Model/AtmospherePipelineStage.js +10 -5
  126. package/Source/Scene/Model/ImageBasedLightingPipelineStage.js +43 -21
  127. package/Source/Scene/Model/Model.js +98 -25
  128. package/Source/Scene/Model/Model3DTileContent.js +5 -0
  129. package/Source/Scene/Model/ModelSceneGraph.js +1 -0
  130. package/Source/Scene/ScreenSpaceCameraController.js +20 -1
  131. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
  132. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +44 -0
  133. package/Source/Shaders/Builtin/Functions/computeScattering.glsl +0 -1
  134. package/Source/Shaders/Builtin/Functions/computeScattering.js +0 -1
  135. package/Source/Shaders/Builtin/Functions/sphericalHarmonics.glsl +3 -1
  136. package/Source/Shaders/Builtin/Functions/sphericalHarmonics.js +3 -1
  137. package/Source/Shaders/ComputeIrradianceFS.glsl +103 -0
  138. package/Source/Shaders/ComputeIrradianceFS.js +105 -0
  139. package/Source/Shaders/ComputeRadianceMapFS.glsl +107 -0
  140. package/Source/Shaders/ComputeRadianceMapFS.js +109 -0
  141. package/Source/Shaders/ConvolveSpecularMapFS.glsl +70 -0
  142. package/Source/Shaders/ConvolveSpecularMapFS.js +72 -0
  143. package/Source/Shaders/ConvolveSpecularMapVS.glsl +24 -0
  144. package/Source/Shaders/ConvolveSpecularMapVS.js +26 -0
  145. package/Source/Shaders/GlobeFS.glsl +1 -2
  146. package/Source/Shaders/GlobeFS.js +1 -2
  147. package/Source/Shaders/Model/AtmosphereStageFS.glsl +1 -4
  148. package/Source/Shaders/Model/AtmosphereStageFS.js +1 -4
  149. package/Source/Shaders/Model/ImageBasedLightingStageFS.glsl +2 -155
  150. package/Source/Shaders/Model/ImageBasedLightingStageFS.js +3 -156
  151. package/Source/Shaders/Model/LightingStageFS.glsl +3 -22
  152. package/Source/Shaders/Model/LightingStageFS.js +3 -22
  153. package/Source/Shaders/SkyBoxVS.glsl +0 -1
  154. package/Source/Shaders/SkyBoxVS.js +0 -1
  155. package/Source/Widget/CesiumWidget.js +776 -1
  156. package/Source/Workers/decodeGoogleEarthEnterprisePacket.js +1 -1
  157. package/index.d.ts +281 -12
  158. package/index.js +62 -57
  159. package/package.json +2 -2
@@ -18,6 +18,7 @@ import RuntimeError from "../../Core/RuntimeError.js";
18
18
  import Pass from "../../Renderer/Pass.js";
19
19
  import ClippingPlaneCollection from "../ClippingPlaneCollection.js";
20
20
  import ClippingPolygonCollection from "../ClippingPolygonCollection.js";
21
+ import DynamicEnvironmentMapManager from "../DynamicEnvironmentMapManager.js";
21
22
  import ColorBlendMode from "../ColorBlendMode.js";
22
23
  import GltfLoader from "../GltfLoader.js";
23
24
  import HeightReference, {
@@ -155,6 +156,7 @@ import pickModel from "./pickModel.js";
155
156
  * @privateParam {ClippingPolygonCollection} [options.clippingPolygons] The {@link ClippingPolygonCollection} used to selectively disable rendering the model.
156
157
  * @privateParam {Cartesian3} [options.lightColor] The light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
157
158
  * @privateParam {ImageBasedLighting} [options.imageBasedLighting] The properties for managing image-based lighting on this model.
159
+ * @privateParam {DynamicEnvironmentMapManager.ConstructorOptions} [options.environmentMapOptions] The properties for managing dynamic environment maps on this model. Affects lighting.
158
160
  * @privateParam {boolean} [options.backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if the model's color is translucent.
159
161
  * @privateParam {Credit|string} [options.credit] A credit for the data source, which is displayed on the canvas.
160
162
  * @privateParam {boolean} [options.showCreditsOnScreen=false] Whether to display the credits of this model on screen.
@@ -400,6 +402,16 @@ function Model(options) {
400
402
  : new ImageBasedLighting();
401
403
  this._shouldDestroyImageBasedLighting = !defined(options.imageBasedLighting);
402
404
 
405
+ this._environmentMapManager = undefined;
406
+ const environmentMapManager = new DynamicEnvironmentMapManager(
407
+ options.environmentMapOptions,
408
+ );
409
+ DynamicEnvironmentMapManager.setOwner(
410
+ environmentMapManager,
411
+ this,
412
+ "_environmentMapManager",
413
+ );
414
+
403
415
  this._backFaceCulling = defaultValue(options.backFaceCulling, true);
404
416
  this._backFaceCullingDirty = false;
405
417
 
@@ -1386,7 +1398,7 @@ Object.defineProperties(Model.prototype, {
1386
1398
  },
1387
1399
 
1388
1400
  /**
1389
- * The light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
1401
+ * The directional light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
1390
1402
  * <p>
1391
1403
  * Disabling additional light sources by setting
1392
1404
  * <code>model.imageBasedLighting.imageBasedLightingFactor = new Cartesian2(0.0, 0.0)</code>
@@ -1424,7 +1436,7 @@ Object.defineProperties(Model.prototype, {
1424
1436
  },
1425
1437
  set: function (value) {
1426
1438
  //>>includeStart('debug', pragmas.debug);
1427
- Check.typeOf.object("imageBasedLighting", this._imageBasedLighting);
1439
+ Check.typeOf.object("imageBasedLighting", value);
1428
1440
  //>>includeEnd('debug');
1429
1441
 
1430
1442
  if (value !== this._imageBasedLighting) {
@@ -1441,6 +1453,38 @@ Object.defineProperties(Model.prototype, {
1441
1453
  },
1442
1454
  },
1443
1455
 
1456
+ /**
1457
+ * The properties for managing dynamic environment maps on this model. Affects lighting.
1458
+ * @memberof Model.prototype
1459
+ * @readonly
1460
+ *
1461
+ * @example
1462
+ * // Change the ground color used for a model's environment map to a forest green
1463
+ * const environmentMapManager = model.environmentMapManager;
1464
+ * environmentMapManager.groundColor = Cesium.Color.fromCssColorString("#203b34");
1465
+ *
1466
+ * @type {DynamicEnvironmentMapManager}
1467
+ */
1468
+ environmentMapManager: {
1469
+ get: function () {
1470
+ return this._environmentMapManager;
1471
+ },
1472
+ set: function (value) {
1473
+ //>>includeStart('debug', pragmas.debug);
1474
+ Check.typeOf.object("environmentMapManager", value);
1475
+ //>>includeEnd('debug');
1476
+
1477
+ if (value !== this.environmentMapManager) {
1478
+ DynamicEnvironmentMapManager.setOwner(
1479
+ value,
1480
+ this,
1481
+ "_environmentMapManager",
1482
+ );
1483
+ this.resetDrawCommands();
1484
+ }
1485
+ },
1486
+ },
1487
+
1444
1488
  /**
1445
1489
  * Whether to cull back-facing geometry. When true, back face culling is
1446
1490
  * determined by the material's doubleSided property; when false, back face
@@ -1858,6 +1902,9 @@ Model.prototype.update = function (frameState) {
1858
1902
  // A custom shader may have to load texture uniforms.
1859
1903
  updateCustomShader(this, frameState);
1860
1904
 
1905
+ // Environment maps, specular maps, and spherical harmonics may need to be updated or regenerated
1906
+ updateEnvironmentMap(this, frameState);
1907
+
1861
1908
  // The image-based lighting may have to load texture uniforms
1862
1909
  // for specular maps.
1863
1910
  updateImageBasedLighting(this, frameState);
@@ -1982,6 +2029,23 @@ function updateCustomShader(model, frameState) {
1982
2029
  }
1983
2030
  }
1984
2031
 
2032
+ function updateEnvironmentMap(model, frameState) {
2033
+ const environmentMapManager = model._environmentMapManager;
2034
+ const picking = frameState.passes.pick || frameState.passes.pickVoxel;
2035
+ if (model._ready && environmentMapManager.owner === model && !picking) {
2036
+ environmentMapManager.position = model._boundingSphere.center;
2037
+ environmentMapManager.shouldUpdate =
2038
+ !defined(model._imageBasedLighting.sphericalHarmonicCoefficients) ||
2039
+ !defined(model._imageBasedLighting.specularEnvironmentMaps);
2040
+
2041
+ environmentMapManager.update(frameState);
2042
+
2043
+ if (environmentMapManager.shouldRegenerateShaders) {
2044
+ model.resetDrawCommands();
2045
+ }
2046
+ }
2047
+ }
2048
+
1985
2049
  function updateImageBasedLighting(model, frameState) {
1986
2050
  model._imageBasedLighting.update(frameState);
1987
2051
  if (model._imageBasedLighting.shouldRegenerateShaders) {
@@ -2338,30 +2402,27 @@ function updateReferenceMatrices(model, frameState) {
2338
2402
  const referenceMatrix = defaultValue(model.referenceMatrix, modelMatrix);
2339
2403
  const context = frameState.context;
2340
2404
 
2341
- const ibl = model._imageBasedLighting;
2342
- if (ibl.useSphericalHarmonicCoefficients || ibl.useSpecularEnvironmentMaps) {
2343
- let iblReferenceFrameMatrix3 = scratchIBLReferenceFrameMatrix3;
2344
- let iblReferenceFrameMatrix4 = scratchIBLReferenceFrameMatrix4;
2405
+ let iblReferenceFrameMatrix3 = scratchIBLReferenceFrameMatrix3;
2406
+ let iblReferenceFrameMatrix4 = scratchIBLReferenceFrameMatrix4;
2345
2407
 
2346
- iblReferenceFrameMatrix4 = Matrix4.multiply(
2347
- context.uniformState.view3D,
2348
- referenceMatrix,
2349
- iblReferenceFrameMatrix4,
2350
- );
2351
- iblReferenceFrameMatrix3 = Matrix4.getRotation(
2352
- iblReferenceFrameMatrix4,
2353
- iblReferenceFrameMatrix3,
2354
- );
2355
- iblReferenceFrameMatrix3 = Matrix3.transpose(
2356
- iblReferenceFrameMatrix3,
2357
- iblReferenceFrameMatrix3,
2358
- );
2359
- model._iblReferenceFrameMatrix = Matrix3.multiply(
2360
- yUpToZUp,
2361
- iblReferenceFrameMatrix3,
2362
- model._iblReferenceFrameMatrix,
2363
- );
2364
- }
2408
+ iblReferenceFrameMatrix4 = Matrix4.multiply(
2409
+ context.uniformState.view3D,
2410
+ referenceMatrix,
2411
+ iblReferenceFrameMatrix4,
2412
+ );
2413
+ iblReferenceFrameMatrix3 = Matrix4.getRotation(
2414
+ iblReferenceFrameMatrix4,
2415
+ iblReferenceFrameMatrix3,
2416
+ );
2417
+ iblReferenceFrameMatrix3 = Matrix3.transpose(
2418
+ iblReferenceFrameMatrix3,
2419
+ iblReferenceFrameMatrix3,
2420
+ );
2421
+ model._iblReferenceFrameMatrix = Matrix3.multiply(
2422
+ yUpToZUp,
2423
+ iblReferenceFrameMatrix3,
2424
+ model._iblReferenceFrameMatrix,
2425
+ );
2365
2426
 
2366
2427
  if (model.isClippingEnabled()) {
2367
2428
  let clippingPlanesMatrix = scratchClippingPlanesMatrix;
@@ -2782,6 +2843,16 @@ Model.prototype.destroy = function () {
2782
2843
  }
2783
2844
  this._imageBasedLighting = undefined;
2784
2845
 
2846
+ // Only destroy the environment map manager if this is the owner.
2847
+ const environmentMapManager = this._environmentMapManager;
2848
+ if (
2849
+ !environmentMapManager.isDestroyed() &&
2850
+ environmentMapManager.owner === this
2851
+ ) {
2852
+ environmentMapManager.destroy();
2853
+ }
2854
+ this._environmentMapManager = undefined;
2855
+
2785
2856
  destroyObject(this);
2786
2857
  };
2787
2858
 
@@ -2860,6 +2931,7 @@ Model.prototype.destroyModelResources = function () {
2860
2931
  * @param {ClippingPolygonCollection} [options.clippingPolygons] The {@link ClippingPolygonCollection} used to selectively disable rendering the model.
2861
2932
  * @param {Cartesian3} [options.lightColor] The light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
2862
2933
  * @param {ImageBasedLighting} [options.imageBasedLighting] The properties for managing image-based lighting on this model.
2934
+ * @param {DynamicEnvironmentMapManager.ConstructorOptions} [options.environmentMapOptions] The properties for managing dynamic environment maps on this model.
2863
2935
  * @param {boolean} [options.backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if the model's color is translucent.
2864
2936
  * @param {Credit|string} [options.credit] A credit for the data source, which is displayed on the canvas.
2865
2937
  * @param {boolean} [options.showCreditsOnScreen=false] Whether to display the credits of this model on screen.
@@ -2990,6 +3062,7 @@ Model.fromGltfAsync = async function (options) {
2990
3062
 
2991
3063
  const modelOptions = makeModelOptions(loader, type, options);
2992
3064
  modelOptions.resource = resource;
3065
+ modelOptions.environmentMapOptions = options.environmentMapOptions;
2993
3066
 
2994
3067
  try {
2995
3068
  // This load the gltf JSON and ensures the gltf is valid
@@ -263,6 +263,11 @@ Model3DTileContent.prototype.update = function (tileset, frameState) {
263
263
  : undefined;
264
264
  }
265
265
 
266
+ const tilesetEnvironmentMapManager = tileset.environmentMapManager;
267
+ if (model.environmentMapManager !== tilesetClippingPlanes) {
268
+ model._environmentMapManager = tilesetEnvironmentMapManager;
269
+ }
270
+
266
271
  // If the model references a different ClippingPlaneCollection from the tileset,
267
272
  // update the model to use the new ClippingPlaneCollection.
268
273
  if (
@@ -601,6 +601,7 @@ ModelSceneGraph.prototype.buildDrawCommands = function (frameState) {
601
601
  * this method again to ensure the correct sequence of pipeline stages are
602
602
  * used.
603
603
  *
604
+ * @param {FrameState} frameState
604
605
  * @private
605
606
  */
606
607
  ModelSceneGraph.prototype.configurePipeline = function (frameState) {
@@ -271,6 +271,16 @@ function ScreenSpaceCameraController(scene) {
271
271
  * @default true
272
272
  */
273
273
  this.enableCollisionDetection = true;
274
+ /**
275
+ * The angle, relative to the ellipsoid normal, restricting the maximum amount that the user can tilt the camera. If <code>undefined</code>, the angle of the camera tilt is unrestricted.
276
+ * @type {number|undefined}
277
+ * @default undefined
278
+ *
279
+ * @example
280
+ * // Prevent the camera from tilting below the ellipsoid surface
281
+ * viewer.scene.screenSpaceCameraController.maximumTiltAngle = Math.PI / 2.0;
282
+ */
283
+ this.maximumTiltAngle = undefined;
274
284
 
275
285
  this._scene = scene;
276
286
  this._globe = undefined;
@@ -2063,7 +2073,16 @@ function rotate3D(
2063
2073
  );
2064
2074
 
2065
2075
  const deltaPhi = rotateRate * phiWindowRatio * Math.PI * 2.0;
2066
- const deltaTheta = rotateRate * thetaWindowRatio * Math.PI;
2076
+ let deltaTheta = rotateRate * thetaWindowRatio * Math.PI;
2077
+
2078
+ if (defined(constrainedAxis) && defined(controller.maximumTiltAngle)) {
2079
+ const maximumTiltAngle = controller.maximumTiltAngle;
2080
+ const dotProduct = Cartesian3.dot(camera.direction, constrainedAxis);
2081
+ const tilt = Math.PI - Math.acos(dotProduct) + deltaTheta;
2082
+ if (tilt > maximumTiltAngle) {
2083
+ deltaTheta -= tilt - maximumTiltAngle;
2084
+ }
2085
+ }
2067
2086
 
2068
2087
  if (!rotateOnlyVertical) {
2069
2088
  camera.rotateRight(deltaPhi);
@@ -42,3 +42,47 @@ vec4 czm_computeAtmosphereColor(
42
42
 
43
43
  return vec4(color, opacity);
44
44
  }
45
+
46
+ /**
47
+ * Compute the atmosphere color, applying Rayleigh and Mie scattering. This
48
+ * builtin uses automatic uniforms so the atmophere settings are synced with the
49
+ * state of the Scene, even in other contexts like Model.
50
+ *
51
+ * @name czm_computeAtmosphereColor
52
+ * @glslFunction
53
+ *
54
+ * @param {czm_ray} primaryRay Ray from the origin to sky fragment to in world coords (low precision)
55
+ * @param {vec3} lightDirection Light direction from the sun or other light source.
56
+ * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
57
+ * @param {vec3} mieColor The Mie scattering color computed by a scattering function
58
+ * @param {float} opacity The opacity computed by a scattering function.
59
+ */
60
+ vec4 czm_computeAtmosphereColor(
61
+ czm_ray primaryRay,
62
+ vec3 lightDirection,
63
+ vec3 rayleighColor,
64
+ vec3 mieColor,
65
+ float opacity
66
+ ) {
67
+ vec3 direction = normalize(primaryRay.direction);
68
+
69
+ float cosAngle = dot(direction, lightDirection);
70
+ float cosAngleSq = cosAngle * cosAngle;
71
+
72
+ float G = czm_atmosphereMieAnisotropy;
73
+ float GSq = G * G;
74
+
75
+ // The Rayleigh phase function.
76
+ float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
77
+ // The Mie phase function.
78
+ float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));
79
+
80
+ // The final color is generated by combining the effects of the Rayleigh and Mie scattering.
81
+ vec3 rayleigh = rayleighPhase * rayleighColor;
82
+ vec3 mie = miePhase * mieColor;
83
+
84
+ vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
85
+
86
+ return vec4(color, opacity);
87
+ }
88
+
@@ -43,4 +43,48 @@ vec4 czm_computeAtmosphereColor(\n\
43
43
  \n\
44
44
  return vec4(color, opacity);\n\
45
45
  }\n\
46
+ \n\
47
+ /**\n\
48
+ * Compute the atmosphere color, applying Rayleigh and Mie scattering. This\n\
49
+ * builtin uses automatic uniforms so the atmophere settings are synced with the\n\
50
+ * state of the Scene, even in other contexts like Model.\n\
51
+ *\n\
52
+ * @name czm_computeAtmosphereColor\n\
53
+ * @glslFunction\n\
54
+ *\n\
55
+ * @param {czm_ray} primaryRay Ray from the origin to sky fragment to in world coords (low precision)\n\
56
+ * @param {vec3} lightDirection Light direction from the sun or other light source.\n\
57
+ * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function\n\
58
+ * @param {vec3} mieColor The Mie scattering color computed by a scattering function\n\
59
+ * @param {float} opacity The opacity computed by a scattering function.\n\
60
+ */\n\
61
+ vec4 czm_computeAtmosphereColor(\n\
62
+ czm_ray primaryRay,\n\
63
+ vec3 lightDirection,\n\
64
+ vec3 rayleighColor,\n\
65
+ vec3 mieColor,\n\
66
+ float opacity\n\
67
+ ) {\n\
68
+ vec3 direction = normalize(primaryRay.direction);\n\
69
+ \n\
70
+ float cosAngle = dot(direction, lightDirection);\n\
71
+ float cosAngleSq = cosAngle * cosAngle;\n\
72
+ \n\
73
+ float G = czm_atmosphereMieAnisotropy;\n\
74
+ float GSq = G * G;\n\
75
+ \n\
76
+ // The Rayleigh phase function.\n\
77
+ float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);\n\
78
+ // The Mie phase function.\n\
79
+ float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));\n\
80
+ \n\
81
+ // The final color is generated by combining the effects of the Rayleigh and Mie scattering.\n\
82
+ vec3 rayleigh = rayleighPhase * rayleighColor;\n\
83
+ vec3 mie = miePhase * mieColor;\n\
84
+ \n\
85
+ vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;\n\
86
+ \n\
87
+ return vec4(color, opacity);\n\
88
+ }\n\
89
+ \n\
46
90
  ";
@@ -40,7 +40,6 @@ void czm_computeScattering(
40
40
 
41
41
  // Return empty colors if no intersection with the atmosphere geometry.
42
42
  if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
43
- rayleighColor = vec3(1.0, 0.0, 1.0);
44
43
  return;
45
44
  }
46
45
 
@@ -41,7 +41,6 @@ void czm_computeScattering(\n\
41
41
  \n\
42
42
  // Return empty colors if no intersection with the atmosphere geometry.\n\
43
43
  if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {\n\
44
- rayleighColor = vec3(1.0, 0.0, 1.0);\n\
45
44
  return;\n\
46
45
  }\n\
47
46
  \n\
@@ -29,7 +29,7 @@ vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])
29
29
  float y = normal.y;
30
30
  float z = normal.z;
31
31
 
32
- return
32
+ vec3 L =
33
33
  L00
34
34
  + L1_1 * y
35
35
  + L10 * z
@@ -39,4 +39,6 @@ vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])
39
39
  + L20 * (3.0 * z * z - 1.0)
40
40
  + L21 * (z * x)
41
41
  + L22 * (x * x - y * y);
42
+
43
+ return max(L, vec3(0.0));
42
44
  }
@@ -30,7 +30,7 @@ vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])\n\
30
30
  float y = normal.y;\n\
31
31
  float z = normal.z;\n\
32
32
  \n\
33
- return\n\
33
+ vec3 L =\n\
34
34
  L00\n\
35
35
  + L1_1 * y\n\
36
36
  + L10 * z\n\
@@ -40,5 +40,7 @@ vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])\n\
40
40
  + L20 * (3.0 * z * z - 1.0)\n\
41
41
  + L21 * (z * x)\n\
42
42
  + L22 * (x * x - y * y);\n\
43
+ \n\
44
+ return max(L, vec3(0.0));\n\
43
45
  }\n\
44
46
  ";
@@ -0,0 +1,103 @@
1
+ uniform samplerCube u_radianceMap;
2
+
3
+ in vec2 v_textureCoordinates;
4
+
5
+
6
+ const float twoSqrtPi = 2.0 * sqrt(czm_pi);
7
+
8
+ // Coutesy of https://www.ppsloan.org/publications/StupidSH36.pdf
9
+ float computeShBasis(int index, vec3 s) {
10
+ if (index == 0) { // l = 0, m = 0
11
+ return 1.0 / twoSqrtPi;
12
+ }
13
+
14
+ if (index == 1) { // l = 1, m = -1
15
+ return -sqrt(3.0) * s.y / twoSqrtPi;
16
+ }
17
+
18
+ if (index == 2) { // l = 1, m = 0
19
+ return sqrt(3.0) * s.z / twoSqrtPi;
20
+ }
21
+
22
+ if (index == 3) { // l = 1, m = 1
23
+ return -sqrt(3.0) * s.x / twoSqrtPi;
24
+ }
25
+
26
+ if (index == 4) { // l = 2, m = -2
27
+ return sqrt(15.0) * s.y * s.x / twoSqrtPi;
28
+ }
29
+
30
+ if (index == 5) { // l = 2, m = -1
31
+ return -sqrt(15.0) * s.y * s.z / twoSqrtPi;
32
+ }
33
+
34
+ if (index == 6) { // l = 2, m = 0
35
+ return sqrt(5.0) * (3.0 * s.z * s.z - 1.0) / 2.0 / twoSqrtPi;
36
+ }
37
+
38
+ if (index == 7) { // l = 2, m = 1
39
+ return -sqrt(15.0) * s.x * s.z / twoSqrtPi;
40
+ }
41
+
42
+ if (index == 8) { // l = 2, m = 2
43
+ return sqrt(15.0) * (s.x * s.x - s.y * s.y) / 2.0 / twoSqrtPi;
44
+ }
45
+
46
+ return 0.0;
47
+ }
48
+
49
+ float vdcRadicalInverse(int i)
50
+ {
51
+ float r;
52
+ float base = 2.0;
53
+ float value = 0.0;
54
+ float invBase = 1.0 / base;
55
+ float invBi = invBase;
56
+ for (int x = 0; x < 100; x++)
57
+ {
58
+ if (i <= 0)
59
+ {
60
+ break;
61
+ }
62
+ r = mod(float(i), base);
63
+ value += r * invBi;
64
+ invBi *= invBase;
65
+ i = int(float(i) * invBase);
66
+ }
67
+ return value;
68
+ }
69
+
70
+ vec2 hammersley2D(int i, int N)
71
+ {
72
+ return vec2(float(i) / float(N), vdcRadicalInverse(i));
73
+ }
74
+
75
+ // Sample count is relatively low for the sake of performance, but should still be enough to capture directionality needed for third-order harmonics
76
+ const int samples = 256;
77
+ const float solidAngle = 1.0 / float(samples);
78
+
79
+ void main() {
80
+ // Get the current coefficient based on the uv
81
+ vec2 uv = v_textureCoordinates.xy * 3.0;
82
+ int coefficientIndex = int(floor(uv.y) * 3.0 + floor(uv.x));
83
+
84
+ for (int i = 0; i < samples; ++i) {
85
+ vec2 xi = hammersley2D(i, samples);
86
+ float phi = czm_twoPi * xi.x;
87
+ float cosTheta = 1.0 - 2.0 * sqrt(1.0 - xi.y * xi.y);
88
+ float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
89
+ vec3 direction = normalize(vec3(sinTheta * cos(phi), cosTheta, sinTheta * sin(phi)));
90
+
91
+ // Generate the spherical harmonics basis from the direction
92
+ float Ylm = computeShBasis(coefficientIndex, direction);
93
+
94
+ vec3 lookupDirection = -direction.xyz;
95
+ lookupDirection.z = -lookupDirection.z;
96
+
97
+ vec4 color = czm_textureCube(u_radianceMap, lookupDirection, 0.0);
98
+
99
+ // Use the relevant function for this coefficient
100
+ out_FragColor += Ylm * color * solidAngle * sinTheta;
101
+ }
102
+
103
+ }
@@ -0,0 +1,105 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "uniform samplerCube u_radianceMap;\n\
3
+ \n\
4
+ in vec2 v_textureCoordinates;\n\
5
+ \n\
6
+ \n\
7
+ const float twoSqrtPi = 2.0 * sqrt(czm_pi);\n\
8
+ \n\
9
+ // Coutesy of https://www.ppsloan.org/publications/StupidSH36.pdf\n\
10
+ float computeShBasis(int index, vec3 s) {\n\
11
+ if (index == 0) { // l = 0, m = 0\n\
12
+ return 1.0 / twoSqrtPi;\n\
13
+ }\n\
14
+ \n\
15
+ if (index == 1) { // l = 1, m = -1\n\
16
+ return -sqrt(3.0) * s.y / twoSqrtPi;\n\
17
+ }\n\
18
+ \n\
19
+ if (index == 2) { // l = 1, m = 0\n\
20
+ return sqrt(3.0) * s.z / twoSqrtPi;\n\
21
+ }\n\
22
+ \n\
23
+ if (index == 3) { // l = 1, m = 1\n\
24
+ return -sqrt(3.0) * s.x / twoSqrtPi;\n\
25
+ }\n\
26
+ \n\
27
+ if (index == 4) { // l = 2, m = -2\n\
28
+ return sqrt(15.0) * s.y * s.x / twoSqrtPi;\n\
29
+ }\n\
30
+ \n\
31
+ if (index == 5) { // l = 2, m = -1\n\
32
+ return -sqrt(15.0) * s.y * s.z / twoSqrtPi;\n\
33
+ }\n\
34
+ \n\
35
+ if (index == 6) { // l = 2, m = 0\n\
36
+ return sqrt(5.0) * (3.0 * s.z * s.z - 1.0) / 2.0 / twoSqrtPi;\n\
37
+ }\n\
38
+ \n\
39
+ if (index == 7) { // l = 2, m = 1\n\
40
+ return -sqrt(15.0) * s.x * s.z / twoSqrtPi;\n\
41
+ }\n\
42
+ \n\
43
+ if (index == 8) { // l = 2, m = 2\n\
44
+ return sqrt(15.0) * (s.x * s.x - s.y * s.y) / 2.0 / twoSqrtPi;\n\
45
+ }\n\
46
+ \n\
47
+ return 0.0;\n\
48
+ }\n\
49
+ \n\
50
+ float vdcRadicalInverse(int i)\n\
51
+ {\n\
52
+ float r;\n\
53
+ float base = 2.0;\n\
54
+ float value = 0.0;\n\
55
+ float invBase = 1.0 / base;\n\
56
+ float invBi = invBase;\n\
57
+ for (int x = 0; x < 100; x++)\n\
58
+ {\n\
59
+ if (i <= 0)\n\
60
+ {\n\
61
+ break;\n\
62
+ }\n\
63
+ r = mod(float(i), base);\n\
64
+ value += r * invBi;\n\
65
+ invBi *= invBase;\n\
66
+ i = int(float(i) * invBase);\n\
67
+ }\n\
68
+ return value;\n\
69
+ }\n\
70
+ \n\
71
+ vec2 hammersley2D(int i, int N)\n\
72
+ {\n\
73
+ return vec2(float(i) / float(N), vdcRadicalInverse(i));\n\
74
+ }\n\
75
+ \n\
76
+ // Sample count is relatively low for the sake of performance, but should still be enough to capture directionality needed for third-order harmonics\n\
77
+ const int samples = 256; \n\
78
+ const float solidAngle = 1.0 / float(samples);\n\
79
+ \n\
80
+ void main() {\n\
81
+ // Get the current coefficient based on the uv\n\
82
+ vec2 uv = v_textureCoordinates.xy * 3.0;\n\
83
+ int coefficientIndex = int(floor(uv.y) * 3.0 + floor(uv.x));\n\
84
+ \n\
85
+ for (int i = 0; i < samples; ++i) {\n\
86
+ vec2 xi = hammersley2D(i, samples);\n\
87
+ float phi = czm_twoPi * xi.x;\n\
88
+ float cosTheta = 1.0 - 2.0 * sqrt(1.0 - xi.y * xi.y);\n\
89
+ float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n\
90
+ vec3 direction = normalize(vec3(sinTheta * cos(phi), cosTheta, sinTheta * sin(phi)));\n\
91
+ \n\
92
+ // Generate the spherical harmonics basis from the direction\n\
93
+ float Ylm = computeShBasis(coefficientIndex, direction);\n\
94
+ \n\
95
+ vec3 lookupDirection = -direction.xyz;\n\
96
+ lookupDirection.z = -lookupDirection.z;\n\
97
+ \n\
98
+ vec4 color = czm_textureCube(u_radianceMap, lookupDirection, 0.0);\n\
99
+ \n\
100
+ // Use the relevant function for this coefficient\n\
101
+ out_FragColor += Ylm * color * solidAngle * sinTheta;\n\
102
+ }\n\
103
+ \n\
104
+ }\n\
105
+ ";