@cesium/engine 12.0.1 → 13.1.0
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.
- package/Build/Workers/{chunk-7D6T2WYT.js → chunk-2ONAV62A.js} +14 -47
- package/Build/Workers/{chunk-MV7YO647.js → chunk-2SRHVCFD.js} +6 -6
- package/Build/Workers/{chunk-ZPTNVB3S.js → chunk-3SCCWLZS.js} +34 -8
- package/Build/Workers/{chunk-7CKQ7PVJ.js → chunk-54I6VSRP.js} +6 -6
- package/Build/Workers/{chunk-XDJ7V4NZ.js → chunk-5I3LPAS7.js} +5 -5
- package/Build/Workers/{chunk-GSJ6LWIS.js → chunk-5ICYLS6B.js} +35 -21
- package/Build/Workers/{chunk-BH5M522L.js → chunk-5JY4LYO3.js} +7 -7
- package/Build/Workers/{chunk-DR56WFYZ.js → chunk-APCS5YJI.js} +7 -7
- package/Build/Workers/{chunk-COHL4R3G.js → chunk-AXYZUG4N.js} +1 -1
- package/Build/Workers/{chunk-2IJZVFHY.js → chunk-B34JXFHF.js} +5 -5
- package/Build/Workers/{chunk-54NYY4U4.js → chunk-B6IJY6AN.js} +7 -7
- package/Build/Workers/{chunk-H3RMGG7L.js → chunk-BMFWWTD7.js} +5 -5
- package/Build/Workers/{chunk-PJHRB4YJ.js → chunk-CBE4HRBH.js} +7 -7
- package/Build/Workers/{chunk-U7SH6OK7.js → chunk-CNPP6TQ2.js} +4 -4
- package/Build/Workers/{chunk-2XOUWNPN.js → chunk-DWIKWWEE.js} +5 -5
- package/Build/Workers/{chunk-PNA47CR7.js → chunk-EHGQQA7C.js} +1 -1
- package/Build/Workers/{chunk-7EBHNJTG.js → chunk-EJ5DT5BP.js} +1 -1
- package/Build/Workers/{chunk-3Y4UGAYI.js → chunk-EYZFEJX3.js} +6 -6
- package/Build/Workers/{chunk-EMCXAVSG.js → chunk-FNCXBBCF.js} +2 -2
- package/Build/Workers/{chunk-NL73INJS.js → chunk-GIOZHX7U.js} +2 -2
- package/Build/Workers/{chunk-VHGI7D3P.js → chunk-GSLKQJM2.js} +10 -10
- package/Build/Workers/{chunk-647NL6VU.js → chunk-HI73PIPQ.js} +2 -2
- package/Build/Workers/{chunk-GRQQHWMD.js → chunk-IP7F2MVW.js} +7 -7
- package/Build/Workers/{chunk-LBNGHEJY.js → chunk-IXNXKVOB.js} +4 -4
- package/Build/Workers/{chunk-2F42VIW6.js → chunk-J7BMSSY7.js} +13 -13
- package/Build/Workers/{chunk-PH3T7LNP.js → chunk-K62EHZFT.js} +15 -15
- package/Build/Workers/{chunk-GBPW65E3.js → chunk-K6SQV4IS.js} +6 -6
- package/Build/Workers/{chunk-WMHJAREU.js → chunk-KO232FLP.js} +2 -2
- package/Build/Workers/{chunk-AER5CLXD.js → chunk-KRVALCCI.js} +5 -5
- package/Build/Workers/{chunk-22FZ334F.js → chunk-LFUFGHL3.js} +10 -10
- package/Build/Workers/{chunk-AGYO4ZSF.js → chunk-LQT2ZK7D.js} +17 -17
- package/Build/Workers/{chunk-KJ65M35B.js → chunk-M2AA2ARJ.js} +11 -11
- package/Build/Workers/{chunk-YT5PQMSP.js → chunk-MGABCOOH.js} +6 -6
- package/Build/Workers/{chunk-JPNFQRN7.js → chunk-NQDKNE7V.js} +13 -13
- package/Build/Workers/{chunk-IJWXYSFC.js → chunk-OARMSJUU.js} +2 -2
- package/Build/Workers/{chunk-K7QC3WDT.js → chunk-OGRXNUR2.js} +1 -1
- package/Build/Workers/{chunk-KKMH4BKN.js → chunk-OZTFRHA2.js} +6 -6
- package/Build/Workers/{chunk-DJ7K7EYK.js → chunk-PBJQFLKS.js} +11 -11
- package/Build/Workers/{chunk-ETXXXGMP.js → chunk-PM76TX2X.js} +6 -6
- package/Build/Workers/{chunk-PISTPJXS.js → chunk-PTFIVVLX.js} +12 -12
- package/Build/Workers/{chunk-VXVQITFC.js → chunk-R2KGFZBA.js} +13 -13
- package/Build/Workers/{chunk-VO4SXJXT.js → chunk-S3UM4OKP.js} +7 -7
- package/Build/Workers/{chunk-NELAPOO6.js → chunk-SAKQO5NX.js} +2 -2
- package/Build/Workers/{chunk-ENARO52I.js → chunk-T34EOLFR.js} +14 -14
- package/Build/Workers/{chunk-X6YBZOOA.js → chunk-THDHWSEJ.js} +4 -4
- package/Build/Workers/{chunk-LVHHB5T6.js → chunk-TOHDFUJM.js} +4 -4
- package/Build/Workers/{chunk-Q7IIOKAT.js → chunk-UBAHTE4Q.js} +1 -1
- package/Build/Workers/{chunk-IAX6MIST.js → chunk-WAJNX74N.js} +17 -17
- package/Build/Workers/{chunk-76KRKKEF.js → chunk-WE4KF4AM.js} +9 -9
- package/Build/Workers/{chunk-JAKTB6CE.js → chunk-WUIDEXAN.js} +7 -7
- package/Build/Workers/{chunk-IVCFTVYW.js → chunk-YVGU235V.js} +4 -4
- package/Build/Workers/{chunk-ZCCI55EY.js → chunk-ZWSWJYJP.js} +13 -13
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -32
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +20 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/BingMapsGeocoderService.js +2 -0
- package/Source/Core/Check.d.ts +2 -1
- package/Source/Core/GoogleGeocoderService.js +110 -0
- package/Source/Core/ITwinPlatform.js +324 -0
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocodeProviderType.js +33 -0
- package/Source/Core/IonGeocoderService.js +72 -0
- package/Source/Core/JulianDate.js +14 -7
- package/Source/Core/Rectangle.js +0 -20
- package/Source/Core/TrackingReferenceFrame.js +45 -0
- package/Source/Core/defined.d.ts +11 -0
- package/Source/DataSources/Entity.js +15 -1
- package/Source/DataSources/EntityView.js +55 -4
- package/Source/DataSources/ModelGraphics.js +23 -1
- package/Source/DataSources/ModelVisualizer.js +22 -1
- package/Source/DataSources/SampledProperty.js +24 -0
- package/Source/Renderer/ContextLimits.js +1 -1
- package/Source/Renderer/Texture.js +104 -92
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/Cesium3DTilesetStatistics.js +109 -42
- package/Source/Scene/DerivedCommand.js +109 -16
- package/Source/Scene/DynamicEnvironmentMapManager.js +202 -65
- package/Source/Scene/GltfTextureLoader.js +16 -1
- package/Source/Scene/ITwinData.js +208 -0
- package/Source/Scene/Label.js +17 -3
- package/Source/Scene/MetadataClassProperty.js +26 -0
- package/Source/Scene/MetadataPicking.js +108 -17
- package/Source/Scene/MetadataType.js +20 -0
- package/Source/Scene/Model/Extensions/Gpm/GltfMeshPrimitiveGpmLoader.js +6 -11
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/Model3DTileContent.js +23 -1
- package/Source/Scene/Model/ModelStatistics.js +33 -5
- package/Source/Scene/Model/PointCloudStylingPipelineStage.js +2 -1
- package/Source/Scene/PickedMetadataInfo.js +21 -3
- package/Source/Scene/Picking.js +7 -1
- package/Source/Scene/PostProcessStage.js +14 -17
- package/Source/Scene/PostProcessStageCollection.js +4 -16
- package/Source/Scene/PostProcessStageLibrary.js +13 -51
- package/Source/Scene/PropertyAttributeProperty.js +15 -3
- package/Source/Scene/PropertyTextureProperty.js +12 -0
- package/Source/Scene/Scene.js +17 -2
- package/Source/Scene/SkyBox.js +23 -4
- package/Source/Scene/UrlTemplateImageryProvider.js +5 -5
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +55 -16
- package/Source/Scene/getMetadataProperty.js +48 -0
- package/Source/Shaders/Builtin/Functions/reverseLogDepth.glsl +1 -1
- package/Source/Shaders/Builtin/Functions/reverseLogDepth.js +1 -1
- package/Source/Shaders/ConvolveSpecularMapFS.glsl +1 -1
- package/Source/Shaders/ConvolveSpecularMapFS.js +1 -1
- package/Source/Shaders/DepthPlaneVS.glsl +1 -1
- package/Source/Shaders/DepthPlaneVS.js +1 -1
- package/Source/Shaders/Model/ModelFS.glsl +7 -0
- package/Source/Shaders/Model/ModelFS.js +7 -0
- package/Source/Shaders/Model/ModelVS.glsl +9 -1
- package/Source/Shaders/Model/ModelVS.js +9 -1
- package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +66 -37
- package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +66 -37
- package/index.d.ts +295 -42
- package/index.js +67 -61
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ import PixelFormat from "../Core/PixelFormat.js";
|
|
|
12
12
|
import SceneMode from "./SceneMode.js";
|
|
13
13
|
import Transforms from "../Core/Transforms.js";
|
|
14
14
|
import ComputeCommand from "../Renderer/ComputeCommand.js";
|
|
15
|
+
import ContextLimits from "../Renderer/ContextLimits.js";
|
|
15
16
|
import CubeMap from "../Renderer/CubeMap.js";
|
|
16
17
|
import Framebuffer from "../Renderer/Framebuffer.js";
|
|
17
18
|
import Texture from "../Renderer/Texture.js";
|
|
@@ -32,7 +33,7 @@ import ConvolveSpecularMapVS from "../Shaders/ConvolveSpecularMapVS.js";
|
|
|
32
33
|
* @typedef {object} DynamicEnvironmentMapManager.ConstructorOptions
|
|
33
34
|
* Options for the DynamicEnvironmentMapManager constructor
|
|
34
35
|
* @property {boolean} [enabled=true] If true, the environment map and related properties will continue to update.
|
|
35
|
-
* @property {number} [mipmapLevels=
|
|
36
|
+
* @property {number} [mipmapLevels=7] The number of mipmap levels to generate for specular maps. More mipmap levels will produce a higher resolution specular reflection.
|
|
36
37
|
* @property {number} [maximumSecondsDifference=3600] The maximum amount of elapsed seconds before a new environment map is created.
|
|
37
38
|
* @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
39
|
* @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.
|
|
@@ -76,10 +77,15 @@ function DynamicEnvironmentMapManager(options) {
|
|
|
76
77
|
this._sphericalHarmonicCoefficientsDirty = false;
|
|
77
78
|
|
|
78
79
|
this._shouldRegenerateShaders = false;
|
|
80
|
+
this._shouldReset = false;
|
|
79
81
|
|
|
80
82
|
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
|
|
81
83
|
|
|
82
|
-
const mipmapLevels =
|
|
84
|
+
const mipmapLevels = Math.min(
|
|
85
|
+
defaultValue(options.mipmapLevels, 7),
|
|
86
|
+
Math.log2(ContextLimits.maximumCubeMapSize),
|
|
87
|
+
);
|
|
88
|
+
|
|
83
89
|
this._mipmapLevels = mipmapLevels;
|
|
84
90
|
this._radianceMapComputeCommands = new Array(6);
|
|
85
91
|
this._convolutionComputeCommands = new Array((mipmapLevels - 1) * 6);
|
|
@@ -246,7 +252,7 @@ Object.defineProperties(DynamicEnvironmentMapManager.prototype, {
|
|
|
246
252
|
}
|
|
247
253
|
|
|
248
254
|
this._position = Cartesian3.clone(value, this._position);
|
|
249
|
-
this.
|
|
255
|
+
this._shouldReset = true;
|
|
250
256
|
},
|
|
251
257
|
},
|
|
252
258
|
|
|
@@ -295,6 +301,67 @@ Object.defineProperties(DynamicEnvironmentMapManager.prototype, {
|
|
|
295
301
|
},
|
|
296
302
|
});
|
|
297
303
|
|
|
304
|
+
// Internally manage a queue of commands across all instances to prevent too many commands from being added in a single frame and using too much memory at once.
|
|
305
|
+
DynamicEnvironmentMapManager._maximumComputeCommandCount = 8; // This value is updated once a context is created.
|
|
306
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount = 0;
|
|
307
|
+
DynamicEnvironmentMapManager._nextFrameCommandQueue = [];
|
|
308
|
+
/**
|
|
309
|
+
* Add a command to the queue. If possible, it will be added to the list of commands for the next frame. Otherwise, it will be added to a backlog
|
|
310
|
+
* and attempted next frame.
|
|
311
|
+
* @private
|
|
312
|
+
* @param {ComputeCommand} command The created command
|
|
313
|
+
* @param {FrameState} frameState The current frame state
|
|
314
|
+
*/
|
|
315
|
+
DynamicEnvironmentMapManager._queueCommand = (command, frameState) => {
|
|
316
|
+
if (
|
|
317
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount >=
|
|
318
|
+
DynamicEnvironmentMapManager._maximumComputeCommandCount
|
|
319
|
+
) {
|
|
320
|
+
// Command will instead be scheduled next frame
|
|
321
|
+
DynamicEnvironmentMapManager._nextFrameCommandQueue.push(command);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
frameState.commandList.push(command);
|
|
326
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount++;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* If there are any backlogged commands, queue up as many as possible for the next frame.
|
|
330
|
+
* @private
|
|
331
|
+
* @param {FrameState} frameState The current frame state
|
|
332
|
+
*/
|
|
333
|
+
DynamicEnvironmentMapManager._updateCommandQueue = (frameState) => {
|
|
334
|
+
DynamicEnvironmentMapManager._maximumComputeCommandCount = Math.log2(
|
|
335
|
+
ContextLimits.maximumCubeMapSize,
|
|
336
|
+
); // Scale relative to GPU resources available
|
|
337
|
+
|
|
338
|
+
if (
|
|
339
|
+
DynamicEnvironmentMapManager._nextFrameCommandQueue.length > 0 &&
|
|
340
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount <
|
|
341
|
+
DynamicEnvironmentMapManager._maximumComputeCommandCount
|
|
342
|
+
) {
|
|
343
|
+
let command = DynamicEnvironmentMapManager._nextFrameCommandQueue.shift();
|
|
344
|
+
while (
|
|
345
|
+
defined(command) &&
|
|
346
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount <
|
|
347
|
+
DynamicEnvironmentMapManager._maximumComputeCommandCount
|
|
348
|
+
) {
|
|
349
|
+
if (command.owner.isDestroyed() || command.canceled) {
|
|
350
|
+
command = DynamicEnvironmentMapManager._nextFrameCommandQueue.shift();
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
frameState.commandList.push(command);
|
|
355
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount++;
|
|
356
|
+
command = DynamicEnvironmentMapManager._nextFrameCommandQueue.shift();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (defined(command)) {
|
|
360
|
+
DynamicEnvironmentMapManager._nextFrameCommandQueue.push(command);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
298
365
|
/**
|
|
299
366
|
* Sets the owner for the input DynamicEnvironmentMapManager if there wasn't another owner.
|
|
300
367
|
* Destroys the owner's previous DynamicEnvironmentMapManager if setting is successful.
|
|
@@ -334,20 +401,29 @@ DynamicEnvironmentMapManager.setOwner = function (
|
|
|
334
401
|
DynamicEnvironmentMapManager.prototype.reset = function () {
|
|
335
402
|
let length = this._radianceMapComputeCommands.length;
|
|
336
403
|
for (let i = 0; i < length; ++i) {
|
|
404
|
+
if (defined(this._radianceMapComputeCommands[i])) {
|
|
405
|
+
this._radianceMapComputeCommands[i].canceled = true;
|
|
406
|
+
}
|
|
337
407
|
this._radianceMapComputeCommands[i] = undefined;
|
|
338
408
|
}
|
|
339
409
|
|
|
340
410
|
length = this._convolutionComputeCommands.length;
|
|
341
411
|
for (let i = 0; i < length; ++i) {
|
|
412
|
+
if (defined(this._convolutionComputeCommands[i])) {
|
|
413
|
+
this._convolutionComputeCommands[i].canceled = true;
|
|
414
|
+
}
|
|
342
415
|
this._convolutionComputeCommands[i] = undefined;
|
|
343
416
|
}
|
|
344
417
|
|
|
345
418
|
if (defined(this._irradianceComputeCommand)) {
|
|
419
|
+
this._irradianceComputeCommand.canceled = true;
|
|
346
420
|
this._irradianceComputeCommand = undefined;
|
|
347
421
|
}
|
|
348
422
|
|
|
349
423
|
this._radianceMapDirty = true;
|
|
350
424
|
this._radianceCommandsDirty = true;
|
|
425
|
+
this._convolutionsCommandsDirty = false;
|
|
426
|
+
this._irradianceCommandDirty = false;
|
|
351
427
|
};
|
|
352
428
|
|
|
353
429
|
const scratchPackedAtmosphere = new Cartesian3();
|
|
@@ -467,7 +543,8 @@ function updateRadianceMap(manager, frameState) {
|
|
|
467
543
|
let i = 0;
|
|
468
544
|
for (const face of CubeMap.faceNames()) {
|
|
469
545
|
let texture = manager._radianceMapTextures[i];
|
|
470
|
-
|
|
546
|
+
// Destroy any existing textures that have no yet been cleaned up
|
|
547
|
+
if (defined(texture) && !texture.isDestroyed()) {
|
|
471
548
|
texture.destroy();
|
|
472
549
|
}
|
|
473
550
|
|
|
@@ -498,36 +575,38 @@ function updateRadianceMap(manager, frameState) {
|
|
|
498
575
|
);
|
|
499
576
|
},
|
|
500
577
|
},
|
|
501
|
-
persists: true,
|
|
502
578
|
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
579
|
});
|
|
529
|
-
|
|
580
|
+
command.postExecute = () => {
|
|
581
|
+
if (manager.isDestroyed() || command.canceled) {
|
|
582
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount--;
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const commands = manager._radianceMapComputeCommands;
|
|
587
|
+
commands[index] = undefined;
|
|
588
|
+
|
|
589
|
+
const framebuffer = new Framebuffer({
|
|
590
|
+
context: context,
|
|
591
|
+
colorTextures: [manager._radianceMapTextures[index]],
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// Copy the output texture into the corresponding cubemap face
|
|
595
|
+
framebuffer._bind();
|
|
596
|
+
manager._radianceCubeMap[face].copyFromFramebuffer();
|
|
597
|
+
framebuffer._unBind();
|
|
598
|
+
framebuffer.destroy();
|
|
599
|
+
|
|
600
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount--;
|
|
601
|
+
|
|
602
|
+
if (!commands.some(defined)) {
|
|
603
|
+
manager._convolutionsCommandsDirty = true;
|
|
604
|
+
manager._shouldRegenerateShaders = true;
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
|
|
530
608
|
manager._radianceMapComputeCommands[i] = command;
|
|
609
|
+
DynamicEnvironmentMapManager._queueCommand(command, frameState);
|
|
531
610
|
i++;
|
|
532
611
|
}
|
|
533
612
|
manager._radianceCommandsDirty = false;
|
|
@@ -551,31 +630,48 @@ function updateSpecularMaps(manager, frameState) {
|
|
|
551
630
|
const context = frameState.context;
|
|
552
631
|
|
|
553
632
|
let facesCopied = 0;
|
|
554
|
-
const getPostExecute = (index, texture, face, level) => () => {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
if (!defined(commands[index])) {
|
|
558
|
-
// This command was cancelled
|
|
633
|
+
const getPostExecute = (command, index, texture, face, level) => () => {
|
|
634
|
+
if (manager.isDestroyed() || command.canceled) {
|
|
635
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount--;
|
|
559
636
|
return;
|
|
560
637
|
}
|
|
638
|
+
|
|
639
|
+
// Copy output texture to corresponding face and mipmap level
|
|
640
|
+
const commands = manager._convolutionComputeCommands;
|
|
561
641
|
commands[index] = undefined;
|
|
562
642
|
|
|
563
643
|
radianceCubeMap.copyFace(frameState, texture, face, level);
|
|
564
644
|
facesCopied++;
|
|
645
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount--;
|
|
646
|
+
|
|
647
|
+
texture.destroy();
|
|
648
|
+
manager._specularMapTextures[index] = undefined;
|
|
565
649
|
|
|
566
|
-
// All faces
|
|
567
|
-
|
|
650
|
+
// All faces for each mipmap level have been copied
|
|
651
|
+
const length = manager._specularMapTextures.length;
|
|
652
|
+
if (facesCopied >= length) {
|
|
568
653
|
manager._irradianceCommandDirty = true;
|
|
569
654
|
radianceCubeMap.sampler = new Sampler({
|
|
570
655
|
minificationFilter: TextureMinificationFilter.LINEAR_MIPMAP_LINEAR,
|
|
571
656
|
});
|
|
657
|
+
|
|
572
658
|
manager._shouldRegenerateShaders = true;
|
|
659
|
+
|
|
660
|
+
// Cleanup shared resources
|
|
661
|
+
manager._va.destroy();
|
|
662
|
+
manager._va = undefined;
|
|
663
|
+
manager._convolveSP.destroy();
|
|
664
|
+
manager._convolveSP = undefined;
|
|
573
665
|
}
|
|
574
666
|
};
|
|
575
667
|
|
|
576
668
|
let index = 0;
|
|
577
669
|
for (let level = 1; level < mipmapLevels; ++level) {
|
|
578
670
|
for (const face of CubeMap.faceNames()) {
|
|
671
|
+
if (defined(manager._specularMapTextures[index])) {
|
|
672
|
+
manager._specularMapTextures[index].destroy();
|
|
673
|
+
}
|
|
674
|
+
|
|
579
675
|
const texture = (manager._specularMapTextures[index] = new Texture({
|
|
580
676
|
context: context,
|
|
581
677
|
width: width,
|
|
@@ -607,19 +703,27 @@ function updateSpecularMaps(manager, frameState) {
|
|
|
607
703
|
shaderProgram: shaderProgram,
|
|
608
704
|
vertexArray: vertexArray,
|
|
609
705
|
outputTexture: texture,
|
|
706
|
+
// Persist so we can use a shared shader progam and vertex array across all commands
|
|
707
|
+
// Shared resources are instead destroyed in postExecute
|
|
610
708
|
persists: true,
|
|
611
709
|
owner: manager,
|
|
612
710
|
uniformMap: {
|
|
613
711
|
u_roughness: () => level / (mipmapLevels - 1),
|
|
614
|
-
u_radianceTexture: () => radianceCubeMap,
|
|
712
|
+
u_radianceTexture: () => radianceCubeMap ?? context.defaultTexture,
|
|
615
713
|
u_faceDirection: () => {
|
|
616
714
|
return CubeMap.getDirection(face, scratchCartesian);
|
|
617
715
|
},
|
|
618
716
|
},
|
|
619
|
-
postExecute: getPostExecute(index, texture, face, level),
|
|
620
717
|
});
|
|
718
|
+
command.postExecute = getPostExecute(
|
|
719
|
+
command,
|
|
720
|
+
index,
|
|
721
|
+
texture,
|
|
722
|
+
face,
|
|
723
|
+
level,
|
|
724
|
+
);
|
|
621
725
|
manager._convolutionComputeCommands[index] = command;
|
|
622
|
-
|
|
726
|
+
DynamicEnvironmentMapManager._queueCommand(command, frameState);
|
|
623
727
|
++index;
|
|
624
728
|
}
|
|
625
729
|
|
|
@@ -641,17 +745,19 @@ function updateIrradianceResources(manager, frameState) {
|
|
|
641
745
|
const dimensions = irradianceTextureDimensions;
|
|
642
746
|
|
|
643
747
|
let texture = manager._irradianceMapTexture;
|
|
644
|
-
if (
|
|
645
|
-
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;
|
|
748
|
+
if (defined(texture) && !texture.isDestroyed()) {
|
|
749
|
+
texture.destroy();
|
|
653
750
|
}
|
|
654
751
|
|
|
752
|
+
texture = new Texture({
|
|
753
|
+
context: context,
|
|
754
|
+
width: dimensions.x,
|
|
755
|
+
height: dimensions.y,
|
|
756
|
+
pixelDatatype: PixelDatatype.FLOAT,
|
|
757
|
+
pixelFormat: PixelFormat.RGBA,
|
|
758
|
+
});
|
|
759
|
+
manager._irradianceMapTexture = texture;
|
|
760
|
+
|
|
655
761
|
let fs = manager._irradianceMapFS;
|
|
656
762
|
if (!defined(fs)) {
|
|
657
763
|
fs = new ShaderSource({
|
|
@@ -663,21 +769,27 @@ function updateIrradianceResources(manager, frameState) {
|
|
|
663
769
|
const command = new ComputeCommand({
|
|
664
770
|
fragmentShaderSource: fs,
|
|
665
771
|
outputTexture: texture,
|
|
772
|
+
owner: manager,
|
|
666
773
|
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;
|
|
774
|
+
u_radianceMap: () => manager._radianceCubeMap ?? context.defaultTexture,
|
|
677
775
|
},
|
|
678
776
|
});
|
|
777
|
+
|
|
778
|
+
command.postExecute = () => {
|
|
779
|
+
if (manager.isDestroyed() || command.canceled) {
|
|
780
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount--;
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
manager._irradianceTextureDirty = false;
|
|
784
|
+
manager._irradianceComputeCommand = undefined;
|
|
785
|
+
manager._sphericalHarmonicCoefficientsDirty = true;
|
|
786
|
+
manager._irradianceMapFS = undefined;
|
|
787
|
+
|
|
788
|
+
DynamicEnvironmentMapManager._activeComputeCommandCount--;
|
|
789
|
+
};
|
|
790
|
+
|
|
679
791
|
manager._irradianceComputeCommand = command;
|
|
680
|
-
|
|
792
|
+
DynamicEnvironmentMapManager._queueCommand(command, frameState);
|
|
681
793
|
manager._irradianceTextureDirty = true;
|
|
682
794
|
}
|
|
683
795
|
|
|
@@ -690,6 +802,11 @@ function updateIrradianceResources(manager, frameState) {
|
|
|
690
802
|
function updateSphericalHarmonicCoefficients(manager, frameState) {
|
|
691
803
|
const context = frameState.context;
|
|
692
804
|
|
|
805
|
+
if (!defined(manager._irradianceMapTexture)) {
|
|
806
|
+
// Operation was canceled
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
|
|
693
810
|
const framebuffer = new Framebuffer({
|
|
694
811
|
context: context,
|
|
695
812
|
colorTextures: [manager._irradianceMapTexture],
|
|
@@ -715,6 +832,8 @@ function updateSphericalHarmonicCoefficients(manager, frameState) {
|
|
|
715
832
|
}
|
|
716
833
|
|
|
717
834
|
framebuffer.destroy();
|
|
835
|
+
manager._irradianceMapTexture.destroy();
|
|
836
|
+
manager._irradianceMapTexture = undefined;
|
|
718
837
|
manager._shouldRegenerateShaders = true;
|
|
719
838
|
}
|
|
720
839
|
|
|
@@ -744,6 +863,8 @@ DynamicEnvironmentMapManager.prototype.update = function (frameState) {
|
|
|
744
863
|
return;
|
|
745
864
|
}
|
|
746
865
|
|
|
866
|
+
DynamicEnvironmentMapManager._updateCommandQueue(frameState);
|
|
867
|
+
|
|
747
868
|
const dynamicLighting = frameState.atmosphere.dynamicLighting;
|
|
748
869
|
const regenerateEnvironmentMap =
|
|
749
870
|
atmosphereNeedsUpdate(this, frameState) ||
|
|
@@ -754,9 +875,11 @@ DynamicEnvironmentMapManager.prototype.update = function (frameState) {
|
|
|
754
875
|
this.maximumSecondsDifference,
|
|
755
876
|
));
|
|
756
877
|
|
|
757
|
-
if (regenerateEnvironmentMap) {
|
|
878
|
+
if (this._shouldReset || regenerateEnvironmentMap) {
|
|
758
879
|
this.reset();
|
|
880
|
+
this._shouldReset = false;
|
|
759
881
|
this._lastTime = JulianDate.clone(frameState.time, this._lastTime);
|
|
882
|
+
return;
|
|
760
883
|
}
|
|
761
884
|
|
|
762
885
|
if (this._radianceMapDirty) {
|
|
@@ -830,19 +953,33 @@ DynamicEnvironmentMapManager.prototype.destroy = function () {
|
|
|
830
953
|
length = this._radianceMapTextures.length;
|
|
831
954
|
for (let i = 0; i < length; ++i) {
|
|
832
955
|
this._radianceMapTextures[i] =
|
|
833
|
-
this._radianceMapTextures[i] &&
|
|
956
|
+
this._radianceMapTextures[i] &&
|
|
957
|
+
!this._radianceMapTextures[i].isDestroyed() &&
|
|
958
|
+
this._radianceMapTextures[i].destroy();
|
|
834
959
|
}
|
|
835
960
|
|
|
836
961
|
length = this._specularMapTextures.length;
|
|
837
962
|
for (let i = 0; i < length; ++i) {
|
|
838
963
|
this._specularMapTextures[i] =
|
|
839
|
-
this._specularMapTextures[i] &&
|
|
964
|
+
this._specularMapTextures[i] &&
|
|
965
|
+
!this._specularMapTextures[i].isDestroyed() &&
|
|
966
|
+
this._specularMapTextures[i].destroy();
|
|
840
967
|
}
|
|
841
968
|
|
|
842
969
|
this._radianceCubeMap =
|
|
843
970
|
this._radianceCubeMap && this._radianceCubeMap.destroy();
|
|
844
971
|
this._irradianceMapTexture =
|
|
845
|
-
this._irradianceMapTexture &&
|
|
972
|
+
this._irradianceMapTexture &&
|
|
973
|
+
!this._irradianceMapTexture.isDestroyed() &&
|
|
974
|
+
this._irradianceMapTexture.destroy();
|
|
975
|
+
|
|
976
|
+
if (defined(this._va)) {
|
|
977
|
+
this._va.destroy();
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
if (defined(this._convolveSP)) {
|
|
981
|
+
this._convolveSP.destroy();
|
|
982
|
+
}
|
|
846
983
|
|
|
847
984
|
return destroyObject(this);
|
|
848
985
|
};
|
|
@@ -170,6 +170,7 @@ GltfTextureLoader.prototype.load = async function () {
|
|
|
170
170
|
function CreateTextureJob() {
|
|
171
171
|
this.gltf = undefined;
|
|
172
172
|
this.textureInfo = undefined;
|
|
173
|
+
this.textureId = undefined;
|
|
173
174
|
this.image = undefined;
|
|
174
175
|
this.context = undefined;
|
|
175
176
|
this.texture = undefined;
|
|
@@ -178,12 +179,14 @@ function CreateTextureJob() {
|
|
|
178
179
|
CreateTextureJob.prototype.set = function (
|
|
179
180
|
gltf,
|
|
180
181
|
textureInfo,
|
|
182
|
+
textureId,
|
|
181
183
|
image,
|
|
182
184
|
mipLevels,
|
|
183
185
|
context,
|
|
184
186
|
) {
|
|
185
187
|
this.gltf = gltf;
|
|
186
188
|
this.textureInfo = textureInfo;
|
|
189
|
+
this.textureId = textureId;
|
|
187
190
|
this.image = image;
|
|
188
191
|
this.mipLevels = mipLevels;
|
|
189
192
|
this.context = context;
|
|
@@ -193,13 +196,21 @@ CreateTextureJob.prototype.execute = function () {
|
|
|
193
196
|
this.texture = createTexture(
|
|
194
197
|
this.gltf,
|
|
195
198
|
this.textureInfo,
|
|
199
|
+
this.textureId,
|
|
196
200
|
this.image,
|
|
197
201
|
this.mipLevels,
|
|
198
202
|
this.context,
|
|
199
203
|
);
|
|
200
204
|
};
|
|
201
205
|
|
|
202
|
-
function createTexture(
|
|
206
|
+
function createTexture(
|
|
207
|
+
gltf,
|
|
208
|
+
textureInfo,
|
|
209
|
+
textureId,
|
|
210
|
+
image,
|
|
211
|
+
mipLevels,
|
|
212
|
+
context,
|
|
213
|
+
) {
|
|
203
214
|
// internalFormat is only defined for CompressedTextureBuffer
|
|
204
215
|
const internalFormat = image.internalFormat;
|
|
205
216
|
|
|
@@ -261,6 +272,7 @@ function createTexture(gltf, textureInfo, image, mipLevels, context) {
|
|
|
261
272
|
}
|
|
262
273
|
|
|
263
274
|
texture = Texture.create({
|
|
275
|
+
id: textureId,
|
|
264
276
|
context: context,
|
|
265
277
|
source: {
|
|
266
278
|
arrayBufferView: image.bufferView, // Only defined for CompressedTextureBuffer
|
|
@@ -276,6 +288,7 @@ function createTexture(gltf, textureInfo, image, mipLevels, context) {
|
|
|
276
288
|
image = resizeImageToNextPowerOfTwo(image);
|
|
277
289
|
}
|
|
278
290
|
texture = Texture.create({
|
|
291
|
+
id: textureId,
|
|
279
292
|
context: context,
|
|
280
293
|
source: image,
|
|
281
294
|
sampler: sampler,
|
|
@@ -332,6 +345,7 @@ GltfTextureLoader.prototype.process = function (frameState) {
|
|
|
332
345
|
textureJob.set(
|
|
333
346
|
this._gltf,
|
|
334
347
|
this._textureInfo,
|
|
348
|
+
this._cacheKey,
|
|
335
349
|
this._image,
|
|
336
350
|
this._mipLevels,
|
|
337
351
|
frameState.context,
|
|
@@ -346,6 +360,7 @@ GltfTextureLoader.prototype.process = function (frameState) {
|
|
|
346
360
|
texture = createTexture(
|
|
347
361
|
this._gltf,
|
|
348
362
|
this._textureInfo,
|
|
363
|
+
this._cacheKey,
|
|
349
364
|
this._image,
|
|
350
365
|
this._mipLevels,
|
|
351
366
|
frameState.context,
|