@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
@@ -0,0 +1,894 @@
1
+ import Cartesian2 from "../Core/Cartesian2.js";
2
+ import Cartesian3 from "../Core/Cartesian3.js";
3
+ import Cartesian4 from "../Core/Cartesian4.js";
4
+ import Color from "../Core/Color.js";
5
+ import defaultValue from "../Core/defaultValue.js";
6
+ import defined from "../Core/defined.js";
7
+ import destroyObject from "../Core/destroyObject.js";
8
+ import DeveloperError from "../Core/DeveloperError.js";
9
+ import JulianDate from "../Core/JulianDate.js";
10
+ import Matrix4 from "../Core/Matrix4.js";
11
+ import PixelFormat from "../Core/PixelFormat.js";
12
+ import SceneMode from "./SceneMode.js";
13
+ import Transforms from "../Core/Transforms.js";
14
+ import ComputeCommand from "../Renderer/ComputeCommand.js";
15
+ import CubeMap from "../Renderer/CubeMap.js";
16
+ import Framebuffer from "../Renderer/Framebuffer.js";
17
+ import Texture from "../Renderer/Texture.js";
18
+ import PixelDatatype from "../Renderer/PixelDatatype.js";
19
+ import Sampler from "../Renderer/Sampler.js";
20
+ import ShaderProgram from "../Renderer/ShaderProgram.js";
21
+ import ShaderSource from "../Renderer/ShaderSource.js";
22
+ import TextureMinificationFilter from "../Renderer/TextureMinificationFilter.js";
23
+ import Atmosphere from "./Atmosphere.js";
24
+ import DynamicAtmosphereLightingType from "./DynamicAtmosphereLightingType.js";
25
+ import AtmosphereCommon from "../Shaders/AtmosphereCommon.js";
26
+ import ComputeIrradianceFS from "../Shaders/ComputeIrradianceFS.js";
27
+ import ComputeRadianceMapFS from "../Shaders/ComputeRadianceMapFS.js";
28
+ import ConvolveSpecularMapFS from "../Shaders/ConvolveSpecularMapFS.js";
29
+ import ConvolveSpecularMapVS from "../Shaders/ConvolveSpecularMapVS.js";
30
+
31
+ /**
32
+ * @typedef {object} DynamicEnvironmentMapManager.ConstructorOptions
33
+ * Options for the DynamicEnvironmentMapManager constructor
34
+ * @property {boolean} [enabled=true] If true, the environment map and related properties will continue to update.
35
+ * @property {number} [mipmapLevels=10] The number of mipmap levels to generate for specular maps. More mipmap levels will produce a higher resolution specular reflection.
36
+ * @property {number} [maximumSecondsDifference=3600] The maximum amount of elapsed seconds before a new environment map is created.
37
+ * @property {number} [maximumPositionEpsilon=1000] The maximum difference in position before a new environment map is created, in meters. Small differences in position will not visibly affect results.
38
+ * @property {number} [atmosphereScatteringIntensity=2.0] The intensity of the scattered light emitted from the atmosphere. This should be adjusted relative to the value of {@link Scene.light} intensity.
39
+ * @property {number} [gamma=1.0] The gamma correction to apply to the range of light emitted from the environment. 1.0 uses the unmodified emitted light color.
40
+ * @property {number} [brightness=1.0] The brightness of light emitted from the environment. 1.0 uses the unmodified emitted environment color. Less than 1.0 makes the light darker while greater than 1.0 makes it brighter.
41
+ * @property {number} [saturation=1.0] The saturation of the light emitted from the environment. 1.0 uses the unmodified emitted environment color. Less than 1.0 reduces the saturation while greater than 1.0 increases it.
42
+ * @property {Color} [groundColor=DynamicEnvironmentMapManager.AVERAGE_EARTH_GROUND_COLOR] Solid color used to represent the ground.
43
+ * @property {number} [groundAlbedo=0.31] The percentage of light reflected from the ground. The average earth albedo is 0.31.
44
+ */
45
+
46
+ /**
47
+ * Generates an environment map at the given position based on scene's current lighting conditions. From this, it produces multiple levels of specular maps and spherical harmonic coefficients than can be used with {@link ImageBasedLighting} for models or tilesets.
48
+ * @alias DynamicEnvironmentMapManager
49
+ * @constructor
50
+ * @param {DynamicEnvironmentMapManager.ConstructorOptions} [options] An object describing initialization options.
51
+ *
52
+ * @example
53
+ * // Enable time-of-day environment mapping in a scene
54
+ * scene.atmosphere.dynamicLighting = Cesium.DynamicAtmosphereLightingType.SUNLIGHT;
55
+ *
56
+ * // Decrease the directional lighting contribution
57
+ * scene.light.intensity = 0.5
58
+ *
59
+ * // Increase the intensity of of the environment map lighting contribution
60
+ * const environmentMapManager = tileset.environmentMapManager;
61
+ * environmentMapManager.atmosphereScatteringIntensity = 3.0;
62
+ *
63
+ * @example
64
+ * // Change the ground color used for a model's environment map to a forest green
65
+ * const environmentMapManager = model.environmentMapManager;
66
+ * environmentMapManager.groundColor = Cesium.Color.fromCssColorString("#203b34");
67
+ */
68
+ function DynamicEnvironmentMapManager(options) {
69
+ this._position = undefined;
70
+
71
+ this._radianceMapDirty = false;
72
+ this._radianceCommandsDirty = false;
73
+ this._convolutionsCommandsDirty = false;
74
+ this._irradianceCommandDirty = false;
75
+ this._irradianceTextureDirty = false;
76
+ this._sphericalHarmonicCoefficientsDirty = false;
77
+
78
+ this._shouldRegenerateShaders = false;
79
+
80
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
81
+
82
+ const mipmapLevels = defaultValue(options.mipmapLevels, 10);
83
+ this._mipmapLevels = mipmapLevels;
84
+ this._radianceMapComputeCommands = new Array(6);
85
+ this._convolutionComputeCommands = new Array((mipmapLevels - 1) * 6);
86
+ this._irradianceComputeCommand = undefined;
87
+
88
+ this._radianceMapFS = undefined;
89
+ this._irradianceMapFS = undefined;
90
+ this._convolveSP = undefined;
91
+ this._va = undefined;
92
+
93
+ this._radianceMapTextures = new Array(6);
94
+ this._specularMapTextures = new Array((mipmapLevels - 1) * 6);
95
+ this._radianceCubeMap = undefined;
96
+ this._irradianceMapTexture = undefined;
97
+
98
+ this._sphericalHarmonicCoefficients =
99
+ DynamicEnvironmentMapManager.DEFAULT_SPHERICAL_HARMONIC_COEFFICIENTS.slice();
100
+
101
+ this._lastTime = new JulianDate();
102
+ const width = Math.pow(2, mipmapLevels - 1);
103
+ this._textureDimensions = new Cartesian2(width, width);
104
+
105
+ this._radiiAndDynamicAtmosphereColor = new Cartesian3();
106
+ this._sceneEnvironmentMap = undefined;
107
+ this._backgroundColor = undefined;
108
+
109
+ // If this DynamicEnvironmentMapManager has an owner, only its owner should update or destroy it.
110
+ // This is because in a Cesium3DTileset multiple models may reference one tileset's DynamicEnvironmentMapManager.
111
+ this._owner = undefined;
112
+
113
+ /**
114
+ * If true, the environment map and related properties will continue to update.
115
+ * @type {boolean}
116
+ * @default true
117
+ */
118
+ this.enabled = defaultValue(options.enabled, true);
119
+
120
+ /**
121
+ * Disables updates. For internal use.
122
+ * @private
123
+ * @default true
124
+ */
125
+ this.shouldUpdate = true;
126
+
127
+ /**
128
+ * The maximum amount of elapsed seconds before a new environment map is created.
129
+ * @type {number}
130
+ * @default 3600
131
+ */
132
+ this.maximumSecondsDifference = defaultValue(
133
+ options.maximumSecondsDifference,
134
+ 60 * 60,
135
+ );
136
+
137
+ /**
138
+ * The maximum difference in position before a new environment map is created, in meters. Small differences in position will not visibly affect results.
139
+ * @type {number}
140
+ * @default 1000
141
+ */
142
+ this.maximumPositionEpsilon = defaultValue(
143
+ options.maximumPositionEpsilon,
144
+ 1000.0,
145
+ );
146
+
147
+ /**
148
+ * The intensity of the scattered light emitted from the atmosphere. This should be adjusted relative to the value of {@link Scene.light} intensity.
149
+ * @type {number}
150
+ * @default 2.0
151
+ * @see DirectionalLight.intensity
152
+ * @see SunLight.intensity
153
+ */
154
+ this.atmosphereScatteringIntensity = defaultValue(
155
+ options.atmosphereScatteringIntensity,
156
+ 2.0,
157
+ );
158
+
159
+ /**
160
+ * The gamma correction to apply to the range of light emitted from the environment. 1.0 uses the unmodified incoming light color.
161
+ * @type {number}
162
+ * @default 1.0
163
+ */
164
+ this.gamma = defaultValue(options.gamma, 1.0);
165
+
166
+ /**
167
+ * The brightness of light emitted from the environment. 1.0 uses the unmodified emitted environment color. Less than 1.0
168
+ * makes the light darker while greater than 1.0 makes it brighter.
169
+ * @type {number}
170
+ * @default 1.0
171
+ */
172
+ this.brightness = defaultValue(options.brightness, 1.0);
173
+
174
+ /**
175
+ * The saturation of the light emitted from the environment. 1.0 uses the unmodified emitted environment color. Less than 1.0 reduces the
176
+ * saturation while greater than 1.0 increases it.
177
+ * @type {number}
178
+ * @default 1.0
179
+ */
180
+ this.saturation = defaultValue(options.saturation, 1.0);
181
+
182
+ /**
183
+ * Solid color used to represent the ground.
184
+ * @type {Color}
185
+ * @default DynamicEnvironmentMapManager.AVERAGE_EARTH_GROUND_COLOR
186
+ */
187
+ this.groundColor = defaultValue(
188
+ options.groundColor,
189
+ DynamicEnvironmentMapManager.AVERAGE_EARTH_GROUND_COLOR,
190
+ );
191
+
192
+ /**
193
+ * The percentage of light reflected from the ground. The average earth albedo is 0.31.
194
+ * @type {number}
195
+ * @default 0.31
196
+ */
197
+ this.groundAlbedo = defaultValue(options.groundAlbedo, 0.31);
198
+ }
199
+
200
+ Object.defineProperties(DynamicEnvironmentMapManager.prototype, {
201
+ /**
202
+ * A reference to the DynamicEnvironmentMapManager's owner, if any.
203
+ * @memberof DynamicEnvironmentMapManager.prototype
204
+ * @type {object|undefined}
205
+ * @readonly
206
+ * @private
207
+ */
208
+ owner: {
209
+ get: function () {
210
+ return this._owner;
211
+ },
212
+ },
213
+
214
+ /**
215
+ * True if model shaders need to be regenerated to account for updates.
216
+ * @memberof DynamicEnvironmentMapManager.prototype
217
+ * @type {boolean}
218
+ * @readonly
219
+ * @private
220
+ */
221
+ shouldRegenerateShaders: {
222
+ get: function () {
223
+ return this._shouldRegenerateShaders;
224
+ },
225
+ },
226
+
227
+ /**
228
+ * The position around which the environment map is generated.
229
+ * @memberof DynamicEnvironmentMapManager.prototype
230
+ * @type {Cartesian3|undefined}
231
+ */
232
+ position: {
233
+ get: function () {
234
+ return this._position;
235
+ },
236
+ set: function (value) {
237
+ if (
238
+ Cartesian3.equalsEpsilon(
239
+ value,
240
+ this._position,
241
+ 0.0,
242
+ this.maximumPositionEpsilon,
243
+ )
244
+ ) {
245
+ return;
246
+ }
247
+
248
+ this._position = Cartesian3.clone(value, this._position);
249
+ this.reset();
250
+ },
251
+ },
252
+
253
+ /**
254
+ * The computed radiance map, or <code>undefined</code> if it has not yet been created.
255
+ * @memberof DynamicEnvironmentMapManager.prototype
256
+ * @type {CubeMap|undefined}
257
+ * @readonly
258
+ * @private
259
+ */
260
+ radianceCubeMap: {
261
+ get: function () {
262
+ return this._radianceCubeMap;
263
+ },
264
+ },
265
+
266
+ /**
267
+ * The maximum number of mip levels available in the radiance cubemap.
268
+ * @memberof DynamicEnvironmentMapManager.prototype
269
+ * @type {number}
270
+ * @readonly
271
+ * @private
272
+ */
273
+ maximumMipmapLevel: {
274
+ get: function () {
275
+ return this._mipmapLevels;
276
+ },
277
+ },
278
+
279
+ /**
280
+ * The third order spherical harmonic coefficients used for the diffuse color of image-based lighting.
281
+ * <p>
282
+ * There are nine <code>Cartesian3</code> coefficients.
283
+ * The order of the coefficients is: L<sub>0,0</sub>, L<sub>1,-1</sub>, L<sub>1,0</sub>, L<sub>1,1</sub>, L<sub>2,-2</sub>, L<sub>2,-1</sub>, L<sub>2,0</sub>, L<sub>2,1</sub>, L<sub>2,2</sub>
284
+ * </p>
285
+ * @memberof DynamicEnvironmentMapManager.prototype
286
+ * @readonly
287
+ * @type {Cartesian3[]}
288
+ * @see {@link https://graphics.stanford.edu/papers/envmap/envmap.pdf|An Efficient Representation for Irradiance Environment Maps}
289
+ * @private
290
+ */
291
+ sphericalHarmonicCoefficients: {
292
+ get: function () {
293
+ return this._sphericalHarmonicCoefficients;
294
+ },
295
+ },
296
+ });
297
+
298
+ /**
299
+ * Sets the owner for the input DynamicEnvironmentMapManager if there wasn't another owner.
300
+ * Destroys the owner's previous DynamicEnvironmentMapManager if setting is successful.
301
+ * @param {DynamicEnvironmentMapManager} [environmentMapManager] A DynamicEnvironmentMapManager (or undefined) being attached to an object
302
+ * @param {object} owner An Object that should receive the new DynamicEnvironmentMapManager
303
+ * @param {string} key The Key for the Object to reference the DynamicEnvironmentMapManager
304
+ * @private
305
+ */
306
+ DynamicEnvironmentMapManager.setOwner = function (
307
+ environmentMapManager,
308
+ owner,
309
+ key,
310
+ ) {
311
+ // Don't destroy the DynamicEnvironmentMapManager if it's already owned by newOwner
312
+ if (environmentMapManager === owner[key]) {
313
+ return;
314
+ }
315
+ // Destroy the existing DynamicEnvironmentMapManager, if any
316
+ owner[key] = owner[key] && owner[key].destroy();
317
+ if (defined(environmentMapManager)) {
318
+ //>>includeStart('debug', pragmas.debug);
319
+ if (defined(environmentMapManager._owner)) {
320
+ throw new DeveloperError(
321
+ "DynamicEnvironmentMapManager should only be assigned to one object",
322
+ );
323
+ }
324
+ //>>includeEnd('debug');
325
+ environmentMapManager._owner = owner;
326
+ owner[key] = environmentMapManager;
327
+ }
328
+ };
329
+
330
+ /**
331
+ * Cancels any in-progress commands and marks the environment map as dirty.
332
+ * @private
333
+ */
334
+ DynamicEnvironmentMapManager.prototype.reset = function () {
335
+ let length = this._radianceMapComputeCommands.length;
336
+ for (let i = 0; i < length; ++i) {
337
+ this._radianceMapComputeCommands[i] = undefined;
338
+ }
339
+
340
+ length = this._convolutionComputeCommands.length;
341
+ for (let i = 0; i < length; ++i) {
342
+ this._convolutionComputeCommands[i] = undefined;
343
+ }
344
+
345
+ if (defined(this._irradianceComputeCommand)) {
346
+ this._irradianceComputeCommand = undefined;
347
+ }
348
+
349
+ this._radianceMapDirty = true;
350
+ this._radianceCommandsDirty = true;
351
+ };
352
+
353
+ const scratchPackedAtmosphere = new Cartesian3();
354
+ const scratchSurfacePosition = new Cartesian3();
355
+
356
+ /**
357
+ * Update atmosphere properties and returns true if the environment map needs to be regenerated.
358
+ * @param {DynamicEnvironmentMapManager} manager this manager
359
+ * @param {FrameState} frameState the current frameState
360
+ * @returns {boolean} true if the environment map needs to be regenerated.
361
+ * @private
362
+ */
363
+ function atmosphereNeedsUpdate(manager, frameState) {
364
+ const position = manager._position;
365
+ const atmosphere = frameState.atmosphere;
366
+
367
+ const ellipsoid = frameState.mapProjection.ellipsoid;
368
+ const surfacePosition = ellipsoid.scaleToGeodeticSurface(
369
+ position,
370
+ scratchSurfacePosition,
371
+ );
372
+ const outerEllipsoidScale = 1.025;
373
+
374
+ // Pack outer radius, inner radius, and dynamic atmosphere flag
375
+ const radiiAndDynamicAtmosphereColor = scratchPackedAtmosphere;
376
+ const radius = defined(surfacePosition)
377
+ ? Cartesian3.magnitude(surfacePosition)
378
+ : ellipsoid.maximumRadius;
379
+ radiiAndDynamicAtmosphereColor.x = radius * outerEllipsoidScale;
380
+ radiiAndDynamicAtmosphereColor.y = radius;
381
+ radiiAndDynamicAtmosphereColor.z = atmosphere.dynamicLighting;
382
+
383
+ if (
384
+ !Cartesian3.equalsEpsilon(
385
+ manager._radiiAndDynamicAtmosphereColor,
386
+ radiiAndDynamicAtmosphereColor,
387
+ ) ||
388
+ frameState.environmentMap !== manager._sceneEnvironmentMap ||
389
+ frameState.backgroundColor !== manager._backgroundColor
390
+ ) {
391
+ Cartesian3.clone(
392
+ radiiAndDynamicAtmosphereColor,
393
+ manager._radiiAndDynamicAtmosphereColor,
394
+ );
395
+ manager._sceneEnvironmentMap = frameState.environmentMap;
396
+ manager._backgroundColor = frameState.backgroundColor;
397
+ return true;
398
+ }
399
+
400
+ return false;
401
+ }
402
+
403
+ const scratchCartesian = new Cartesian3();
404
+ const scratchMatrix = new Matrix4();
405
+ const scratchAdjustments = new Cartesian4();
406
+ const scratchColor = new Color();
407
+
408
+ /**
409
+ * Renders the highest resolution specular map by creating compute commands for each cube face
410
+ * @param {DynamicEnvironmentMapManager} manager this manager
411
+ * @param {FrameState} frameState the current frameState
412
+ * @private
413
+ */
414
+ function updateRadianceMap(manager, frameState) {
415
+ const context = frameState.context;
416
+ const textureDimensions = manager._textureDimensions;
417
+
418
+ if (!defined(manager._radianceCubeMap)) {
419
+ manager._radianceCubeMap = new CubeMap({
420
+ context: context,
421
+ width: textureDimensions.x,
422
+ height: textureDimensions.y,
423
+ pixelDatatype: PixelDatatype.UNSIGNED_BYTE,
424
+ pixelFormat: PixelFormat.RGBA,
425
+ });
426
+ }
427
+
428
+ if (manager._radianceCommandsDirty) {
429
+ let fs = manager._radianceMapFS;
430
+ if (!defined(fs)) {
431
+ fs = new ShaderSource({
432
+ sources: [AtmosphereCommon, ComputeRadianceMapFS],
433
+ });
434
+ manager._radianceMapFS = fs;
435
+ }
436
+
437
+ if (Atmosphere.requiresColorCorrect(frameState.atmosphere)) {
438
+ fs.defines.push("ATMOSPHERE_COLOR_CORRECT");
439
+ }
440
+
441
+ const position = manager._position;
442
+ const radiiAndDynamicAtmosphereColor =
443
+ manager._radiiAndDynamicAtmosphereColor;
444
+
445
+ const ellipsoid = frameState.mapProjection.ellipsoid;
446
+ const enuToFixedFrame = Transforms.eastNorthUpToFixedFrame(
447
+ position,
448
+ ellipsoid,
449
+ scratchMatrix,
450
+ );
451
+
452
+ const adjustments = scratchAdjustments;
453
+
454
+ adjustments.x = manager.brightness;
455
+ adjustments.y = manager.saturation;
456
+ adjustments.z = manager.gamma;
457
+ adjustments.w = manager.atmosphereScatteringIntensity;
458
+
459
+ if (
460
+ manager.brightness !== 1.0 ||
461
+ manager.saturation !== 1.0 ||
462
+ manager.gamma !== 1.0
463
+ ) {
464
+ fs.defines.push("ENVIRONMENT_COLOR_CORRECT");
465
+ }
466
+
467
+ let i = 0;
468
+ for (const face of CubeMap.faceNames()) {
469
+ let texture = manager._radianceMapTextures[i];
470
+ if (defined(texture)) {
471
+ texture.destroy();
472
+ }
473
+
474
+ texture = new Texture({
475
+ context: context,
476
+ width: textureDimensions.x,
477
+ height: textureDimensions.y,
478
+ pixelDatatype: PixelDatatype.UNSIGNED_BYTE,
479
+ pixelFormat: PixelFormat.RGBA,
480
+ });
481
+ manager._radianceMapTextures[i] = texture;
482
+
483
+ const index = i;
484
+ const command = new ComputeCommand({
485
+ fragmentShaderSource: fs,
486
+ outputTexture: texture,
487
+ uniformMap: {
488
+ u_radiiAndDynamicAtmosphereColor: () =>
489
+ radiiAndDynamicAtmosphereColor,
490
+ u_enuToFixedFrame: () => enuToFixedFrame,
491
+ u_faceDirection: () => CubeMap.getDirection(face, scratchCartesian),
492
+ u_positionWC: () => position,
493
+ u_brightnessSaturationGammaIntensity: () => adjustments,
494
+ u_groundColor: () => {
495
+ return manager.groundColor.withAlpha(
496
+ manager.groundAlbedo,
497
+ scratchColor,
498
+ );
499
+ },
500
+ },
501
+ persists: true,
502
+ owner: manager,
503
+ postExecute: () => {
504
+ const commands = manager._radianceMapComputeCommands;
505
+ if (!defined(commands[index])) {
506
+ // This command was cancelled
507
+ return;
508
+ }
509
+ commands[index] = undefined;
510
+
511
+ const framebuffer = new Framebuffer({
512
+ context: context,
513
+ colorTextures: [manager._radianceMapTextures[index]],
514
+ destroyAttachments: false,
515
+ });
516
+
517
+ // Copy the output texture into the corresponding cubemap face
518
+ framebuffer._bind();
519
+ manager._radianceCubeMap[face].copyFromFramebuffer();
520
+ framebuffer._unBind();
521
+ framebuffer.destroy();
522
+
523
+ if (!commands.some(defined)) {
524
+ manager._convolutionsCommandsDirty = true;
525
+ manager._shouldRegenerateShaders = true;
526
+ }
527
+ },
528
+ });
529
+ frameState.commandList.push(command);
530
+ manager._radianceMapComputeCommands[i] = command;
531
+ i++;
532
+ }
533
+ manager._radianceCommandsDirty = false;
534
+ }
535
+ }
536
+
537
+ /**
538
+ * Creates a mipmap chain for the cubemap by convolving the environment map for each roughness level
539
+ * @param {DynamicEnvironmentMapManager} manager this manager
540
+ * @param {FrameState} frameState the current frameState
541
+ * @private
542
+ */
543
+ function updateSpecularMaps(manager, frameState) {
544
+ const radianceCubeMap = manager._radianceCubeMap;
545
+ radianceCubeMap.generateMipmap();
546
+
547
+ const mipmapLevels = manager._mipmapLevels;
548
+ const textureDimensions = manager._textureDimensions;
549
+ let width = textureDimensions.x / 2;
550
+ let height = textureDimensions.y / 2;
551
+ const context = frameState.context;
552
+
553
+ let facesCopied = 0;
554
+ const getPostExecute = (index, texture, face, level) => () => {
555
+ // Copy output texture to corresponding face and mipmap level
556
+ const commands = manager._convolutionComputeCommands;
557
+ if (!defined(commands[index])) {
558
+ // This command was cancelled
559
+ return;
560
+ }
561
+ commands[index] = undefined;
562
+
563
+ radianceCubeMap.copyFace(frameState, texture, face, level);
564
+ facesCopied++;
565
+
566
+ // All faces and levels have been copied
567
+ if (facesCopied === manager._specularMapTextures.length) {
568
+ manager._irradianceCommandDirty = true;
569
+ radianceCubeMap.sampler = new Sampler({
570
+ minificationFilter: TextureMinificationFilter.LINEAR_MIPMAP_LINEAR,
571
+ });
572
+ manager._shouldRegenerateShaders = true;
573
+ }
574
+ };
575
+
576
+ let index = 0;
577
+ for (let level = 1; level < mipmapLevels; ++level) {
578
+ for (const face of CubeMap.faceNames()) {
579
+ const texture = (manager._specularMapTextures[index] = new Texture({
580
+ context: context,
581
+ width: width,
582
+ height: height,
583
+ pixelDatatype: PixelDatatype.UNSIGNED_BYTE,
584
+ pixelFormat: PixelFormat.RGBA,
585
+ }));
586
+
587
+ let vertexArray = manager._va;
588
+ if (!defined(vertexArray)) {
589
+ vertexArray = CubeMap.createVertexArray(context, face);
590
+ manager._va = vertexArray;
591
+ }
592
+
593
+ let shaderProgram = manager._convolveSP;
594
+ if (!defined(shaderProgram)) {
595
+ shaderProgram = ShaderProgram.fromCache({
596
+ context: context,
597
+ vertexShaderSource: ConvolveSpecularMapVS,
598
+ fragmentShaderSource: ConvolveSpecularMapFS,
599
+ attributeLocations: {
600
+ positions: 0,
601
+ },
602
+ });
603
+ manager._convolveSP = shaderProgram;
604
+ }
605
+
606
+ const command = new ComputeCommand({
607
+ shaderProgram: shaderProgram,
608
+ vertexArray: vertexArray,
609
+ outputTexture: texture,
610
+ persists: true,
611
+ owner: manager,
612
+ uniformMap: {
613
+ u_roughness: () => level / (mipmapLevels - 1),
614
+ u_radianceTexture: () => radianceCubeMap,
615
+ u_faceDirection: () => {
616
+ return CubeMap.getDirection(face, scratchCartesian);
617
+ },
618
+ },
619
+ postExecute: getPostExecute(index, texture, face, level),
620
+ });
621
+ manager._convolutionComputeCommands[index] = command;
622
+ frameState.commandList.push(command);
623
+ ++index;
624
+ }
625
+
626
+ width /= 2;
627
+ height /= 2;
628
+ }
629
+ }
630
+
631
+ const irradianceTextureDimensions = new Cartesian2(3, 3); // 9 coefficients
632
+
633
+ /**
634
+ * Computes spherical harmonic coefficients by convolving the environment map.
635
+ * @param {DynamicEnvironmentMapManager} manager this manager
636
+ * @param {FrameState} frameState the current frameState
637
+ * @private
638
+ */
639
+ function updateIrradianceResources(manager, frameState) {
640
+ const context = frameState.context;
641
+ const dimensions = irradianceTextureDimensions;
642
+
643
+ let texture = manager._irradianceMapTexture;
644
+ if (!defined(texture)) {
645
+ texture = new Texture({
646
+ context: context,
647
+ width: dimensions.x,
648
+ height: dimensions.y,
649
+ pixelDatatype: PixelDatatype.FLOAT,
650
+ pixelFormat: PixelFormat.RGBA,
651
+ });
652
+ manager._irradianceMapTexture = texture;
653
+ }
654
+
655
+ let fs = manager._irradianceMapFS;
656
+ if (!defined(fs)) {
657
+ fs = new ShaderSource({
658
+ sources: [ComputeIrradianceFS],
659
+ });
660
+ manager._irradianceMapFS = fs;
661
+ }
662
+
663
+ const command = new ComputeCommand({
664
+ fragmentShaderSource: fs,
665
+ outputTexture: texture,
666
+ uniformMap: {
667
+ u_radianceMap: () => manager._radianceCubeMap,
668
+ },
669
+ postExecute: () => {
670
+ if (!defined(manager._irradianceComputeCommand)) {
671
+ // This command was cancelled
672
+ return;
673
+ }
674
+ manager._irradianceTextureDirty = false;
675
+ manager._irradianceComputeCommand = undefined;
676
+ manager._sphericalHarmonicCoefficientsDirty = true;
677
+ },
678
+ });
679
+ manager._irradianceComputeCommand = command;
680
+ frameState.commandList.push(command);
681
+ manager._irradianceTextureDirty = true;
682
+ }
683
+
684
+ /**
685
+ * Copies coefficients from the output texture using readPixels.
686
+ * @param {DynamicEnvironmentMapManager} manager this manager
687
+ * @param {FrameState} frameState the current frameState
688
+ * @private
689
+ */
690
+ function updateSphericalHarmonicCoefficients(manager, frameState) {
691
+ const context = frameState.context;
692
+
693
+ const framebuffer = new Framebuffer({
694
+ context: context,
695
+ colorTextures: [manager._irradianceMapTexture],
696
+ destroyAttachments: false,
697
+ });
698
+
699
+ const dimensions = irradianceTextureDimensions;
700
+ const data = context.readPixels({
701
+ x: 0,
702
+ y: 0,
703
+ width: dimensions.x,
704
+ height: dimensions.y,
705
+ framebuffer: framebuffer,
706
+ });
707
+
708
+ for (let i = 0; i < 9; ++i) {
709
+ manager._sphericalHarmonicCoefficients[i] = Cartesian3.unpack(data, i * 4);
710
+ Cartesian3.multiplyByScalar(
711
+ manager._sphericalHarmonicCoefficients[i],
712
+ manager.atmosphereScatteringIntensity,
713
+ manager._sphericalHarmonicCoefficients[i],
714
+ );
715
+ }
716
+
717
+ framebuffer.destroy();
718
+ manager._shouldRegenerateShaders = true;
719
+ }
720
+
721
+ /**
722
+ * Called when {@link Viewer} or {@link CesiumWidget} render the scene to
723
+ * build the resources for the environment maps.
724
+ * <p>
725
+ * Do not call this function directly.
726
+ * </p>
727
+ * @private
728
+ */
729
+ DynamicEnvironmentMapManager.prototype.update = function (frameState) {
730
+ const mode = frameState.mode;
731
+ const isSupported =
732
+ // A FrameState type works here because the function only references the context parameter.
733
+ // @ts-ignore
734
+ DynamicEnvironmentMapManager.isDynamicUpdateSupported(frameState);
735
+
736
+ if (
737
+ !isSupported ||
738
+ !this.enabled ||
739
+ !this.shouldUpdate ||
740
+ !defined(this._position) ||
741
+ mode === SceneMode.MORPHING
742
+ ) {
743
+ this._shouldRegenerateShaders = false;
744
+ return;
745
+ }
746
+
747
+ const dynamicLighting = frameState.atmosphere.dynamicLighting;
748
+ const regenerateEnvironmentMap =
749
+ atmosphereNeedsUpdate(this, frameState) ||
750
+ (dynamicLighting === DynamicAtmosphereLightingType.SUNLIGHT &&
751
+ !JulianDate.equalsEpsilon(
752
+ frameState.time,
753
+ this._lastTime,
754
+ this.maximumSecondsDifference,
755
+ ));
756
+
757
+ if (regenerateEnvironmentMap) {
758
+ this.reset();
759
+ this._lastTime = JulianDate.clone(frameState.time, this._lastTime);
760
+ }
761
+
762
+ if (this._radianceMapDirty) {
763
+ updateRadianceMap(this, frameState);
764
+ this._radianceMapDirty = false;
765
+ }
766
+
767
+ if (this._convolutionsCommandsDirty) {
768
+ updateSpecularMaps(this, frameState);
769
+ this._convolutionsCommandsDirty = false;
770
+ }
771
+
772
+ if (this._irradianceCommandDirty) {
773
+ updateIrradianceResources(this, frameState);
774
+ this._irradianceCommandDirty = false;
775
+ }
776
+
777
+ if (this._irradianceTextureDirty) {
778
+ this._shouldRegenerateShaders = false;
779
+ return;
780
+ }
781
+
782
+ if (this._sphericalHarmonicCoefficientsDirty) {
783
+ updateSphericalHarmonicCoefficients(this, frameState);
784
+ this._sphericalHarmonicCoefficientsDirty = false;
785
+ return;
786
+ }
787
+
788
+ this._shouldRegenerateShaders = false;
789
+ };
790
+
791
+ /**
792
+ * Returns true if this object was destroyed; otherwise, false.
793
+ * <br /><br />
794
+ * If this object was destroyed, it should not be used; calling any function other than
795
+ * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
796
+ * @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
797
+ * @see DynamicEnvironmentMapManager#destroy
798
+ */
799
+ DynamicEnvironmentMapManager.prototype.isDestroyed = function () {
800
+ return false;
801
+ };
802
+
803
+ /**
804
+ * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
805
+ * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
806
+ * <br /><br />
807
+ * Once an object is destroyed, it should not be used; calling any function other than
808
+ * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
809
+ * assign the return value (<code>undefined</code>) to the object as done in the example.
810
+ * @throws {DeveloperError} This object was destroyed, i.e., destroy() was called.
811
+ * @example
812
+ * mapManager = mapManager && mapManager.destroy();
813
+ * @see DynamicEnvironmentMapManager#isDestroyed
814
+ */
815
+ DynamicEnvironmentMapManager.prototype.destroy = function () {
816
+ // Cancel in-progress commands
817
+ let length = this._radianceMapComputeCommands.length;
818
+ for (let i = 0; i < length; ++i) {
819
+ this._radianceMapComputeCommands[i] = undefined;
820
+ }
821
+
822
+ length = this._convolutionComputeCommands.length;
823
+ for (let i = 0; i < length; ++i) {
824
+ this._convolutionComputeCommands[i] = undefined;
825
+ }
826
+
827
+ this._irradianceMapComputeCommand = undefined;
828
+
829
+ // Destroy all textures
830
+ length = this._radianceMapTextures.length;
831
+ for (let i = 0; i < length; ++i) {
832
+ this._radianceMapTextures[i] =
833
+ this._radianceMapTextures[i] && this._radianceMapTextures[i].destroy();
834
+ }
835
+
836
+ length = this._specularMapTextures.length;
837
+ for (let i = 0; i < length; ++i) {
838
+ this._specularMapTextures[i] =
839
+ this._specularMapTextures[i] && this._specularMapTextures[i].destroy();
840
+ }
841
+
842
+ this._radianceCubeMap =
843
+ this._radianceCubeMap && this._radianceCubeMap.destroy();
844
+ this._irradianceMapTexture =
845
+ this._irradianceMapTexture && this._irradianceMapTexture.destroy();
846
+
847
+ return destroyObject(this);
848
+ };
849
+
850
+ /**
851
+ * Returns <code>true</code> if dynamic updates are supported in the current WebGL rendering context.
852
+ * Dynamic updates requires the EXT_color_buffer_float or EXT_color_buffer_half_float extension.
853
+ *
854
+ * @param {Scene} scene The object containing the rendering context
855
+ * @returns {boolean} true if supported
856
+ */
857
+ DynamicEnvironmentMapManager.isDynamicUpdateSupported = function (scene) {
858
+ const context = scene.context;
859
+ return context.halfFloatingPointTexture || context.colorBufferFloat;
860
+ };
861
+
862
+ /**
863
+ * Average hue of ground color on earth, a warm green-gray.
864
+ * @type {Color}
865
+ * @readonly
866
+ */
867
+ DynamicEnvironmentMapManager.AVERAGE_EARTH_GROUND_COLOR = Object.freeze(
868
+ Color.fromCssColorString("#717145"),
869
+ );
870
+
871
+ /**
872
+ * The default third order spherical harmonic coefficients used for the diffuse color of image-based lighting, a white ambient light with low intensity.
873
+ * <p>
874
+ * There are nine <code>Cartesian3</code> coefficients.
875
+ * The order of the coefficients is: L<sub>0,0</sub>, L<sub>1,-1</sub>, L<sub>1,0</sub>, L<sub>1,1</sub>, L<sub>2,-2</sub>, L<sub>2,-1</sub>, L<sub>2,0</sub>, L<sub>2,1</sub>, L<sub>2,2</sub>
876
+ * </p>
877
+ * @readonly
878
+ * @type {Cartesian3[]}
879
+ * @see {@link https://graphics.stanford.edu/papers/envmap/envmap.pdf|An Efficient Representation for Irradiance Environment Maps}
880
+ */
881
+ DynamicEnvironmentMapManager.DEFAULT_SPHERICAL_HARMONIC_COEFFICIENTS =
882
+ Object.freeze([
883
+ Object.freeze(new Cartesian3(0.35449, 0.35449, 0.35449)),
884
+ Cartesian3.ZERO,
885
+ Cartesian3.ZERO,
886
+ Cartesian3.ZERO,
887
+ Cartesian3.ZERO,
888
+ Cartesian3.ZERO,
889
+ Cartesian3.ZERO,
890
+ Cartesian3.ZERO,
891
+ Cartesian3.ZERO,
892
+ ]);
893
+
894
+ export default DynamicEnvironmentMapManager;