@cesium/engine 6.2.0 → 8.0.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/ThirdParty/Workers/z-worker-pako.js +568 -407
- package/Build/Workers/{chunk-RH4N2ONY.js → chunk-23UFSGND.js} +7 -7
- package/Build/Workers/{chunk-HPP4JLNH.js → chunk-2A75IWRS.js} +7 -7
- package/Build/Workers/{chunk-5IRLXUTA.js → chunk-2FRVPMCS.js} +10 -10
- package/Build/Workers/{chunk-ZQRZBHYI.js → chunk-2FWRMUTY.js} +4 -4
- package/Build/Workers/{chunk-Z2SIPUKB.js → chunk-2UPKWTMJ.js} +6 -6
- package/Build/Workers/{chunk-434ZTTFX.js → chunk-34FXV7D7.js} +2 -2
- package/Build/Workers/{chunk-MW3CJYLX.js → chunk-3VAZEH7M.js} +2 -2
- package/Build/Workers/{chunk-HUPNRBWW.js → chunk-4DO5W5XZ.js} +6 -6
- package/Build/Workers/{chunk-PIXK6KHB.js → chunk-4H7PY4U5.js} +2 -2
- package/Build/Workers/{chunk-BP467WX3.js → chunk-5QULIR53.js} +4 -4
- package/Build/Workers/{chunk-R3HUGXBH.js → chunk-7TC63SJW.js} +8 -8
- package/Build/Workers/{chunk-SQVTYRZY.js → chunk-7ZFGPDJA.js} +4 -4
- package/Build/Workers/{chunk-TIXXVKUY.js → chunk-A5DWLWCY.js} +10 -10
- package/Build/Workers/{chunk-CWJQGBWT.js → chunk-BBWDMCVU.js} +1 -1
- package/Build/Workers/{chunk-4KP73B43.js → chunk-BG4UCVXN.js} +3 -3
- package/Build/Workers/{chunk-Y4OJ4B23.js → chunk-BIKA3NRA.js} +5 -5
- package/Build/Workers/{chunk-DR5XZ6K5.js → chunk-BROJAZRZ.js} +13 -13
- package/Build/Workers/{chunk-FWGNCYP6.js → chunk-DDUQAJ4P.js} +7 -7
- package/Build/Workers/{chunk-QRBRVGZC.js → chunk-EERJKOAF.js} +4 -4
- package/Build/Workers/{chunk-52VSIKEA.js → chunk-EG6PTBY2.js} +15 -15
- package/Build/Workers/{chunk-O43GWBSF.js → chunk-EHWHNOEX.js} +1 -1
- package/Build/Workers/{chunk-MN34FIF5.js → chunk-F3YA3Y2Z.js} +1 -1
- package/Build/Workers/{chunk-GF5TNNKP.js → chunk-F4HFJMGM.js} +6 -6
- package/Build/Workers/{chunk-HOT2SNXP.js → chunk-FJKNFAKQ.js} +133 -553
- package/Build/Workers/{chunk-TMPVBFJQ.js → chunk-FNIRWHJB.js} +10 -10
- package/Build/Workers/{chunk-DMCSY5BU.js → chunk-FZRIVR7Y.js} +5 -5
- package/Build/Workers/{chunk-Z4JUBRHP.js → chunk-G43QFN4Q.js} +6 -6
- package/Build/Workers/{chunk-HPH5HSFE.js → chunk-GATZHF3K.js} +2 -2
- package/Build/Workers/{chunk-CSIZ3BGT.js → chunk-GRC2ZTAF.js} +14 -14
- package/Build/Workers/{chunk-NE4JNU6H.js → chunk-HU6N6EXB.js} +10 -10
- package/Build/Workers/{chunk-GVL5I7TC.js → chunk-I46ZRR5W.js} +17 -17
- package/Build/Workers/{chunk-5GDBZTHX.js → chunk-JURN7NPV.js} +17 -17
- package/Build/Workers/{chunk-H5DUXHCV.js → chunk-KKCR2YOP.js} +11 -11
- package/Build/Workers/{chunk-LX6XV4DK.js → chunk-LPR3YNP2.js} +5 -5
- package/Build/Workers/{chunk-HFKSAB5K.js → chunk-M7ERACJJ.js} +13 -13
- package/Build/Workers/{chunk-BUZDZBUH.js → chunk-MDWEGWPA.js} +10 -10
- package/Build/Workers/{chunk-LGJUI2CE.js → chunk-OGXZVPPM.js} +9 -5
- package/Build/Workers/{chunk-PZ2WJWUG.js → chunk-PGSJK77E.js} +6 -6
- package/Build/Workers/{chunk-ARPTYYKS.js → chunk-PPH7OFP3.js} +5 -5
- package/Build/Workers/{chunk-R4OZKBXH.js → chunk-SH5USDPI.js} +6 -6
- package/Build/Workers/{chunk-SV7DDPAC.js → chunk-SOWMRMWA.js} +1 -1
- package/Build/Workers/{chunk-RIDPF7PO.js → chunk-STW2DGFI.js} +2 -2
- package/Build/Workers/{chunk-CDGHUKQ4.js → chunk-T3XIFPYR.js} +13 -13
- package/Build/Workers/chunk-TTUZP4BO.js +501 -0
- package/Build/Workers/{chunk-QTZQZY2C.js → chunk-UEXTBDBE.js} +34 -10
- package/Build/Workers/{chunk-XUTVA4K5.js → chunk-VOXYEYJT.js} +11 -11
- package/Build/Workers/{chunk-AXFRNOVC.js → chunk-X4356LRH.js} +12 -12
- package/Build/Workers/{chunk-5HLGKKG3.js → chunk-XGI5BXZY.js} +2 -2
- package/Build/Workers/{chunk-SNN7WOC2.js → chunk-Y2ME2IJV.js} +13 -13
- package/Build/Workers/{chunk-LGL4P5KL.js → chunk-Y5UQJLYE.js} +6 -6
- package/Build/Workers/{chunk-3PW6ZBN4.js → chunk-YJEBABKH.js} +7 -7
- package/Build/Workers/{chunk-YBKFS53K.js → chunk-YWTJ2B4B.js} +1 -1
- package/Build/Workers/{chunk-5SK36PU4.js → chunk-Z3TIFFGF.js} +7 -7
- package/Build/Workers/{chunk-JGG36SQV.js → chunk-ZT7KWISZ.js} +4 -4
- package/Build/Workers/combineGeometry.js +24 -23
- package/Build/Workers/createBoxGeometry.js +18 -17
- package/Build/Workers/createBoxOutlineGeometry.js +16 -15
- package/Build/Workers/createCircleGeometry.js +26 -25
- package/Build/Workers/createCircleOutlineGeometry.js +19 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -17
- package/Build/Workers/createEllipseGeometry.js +26 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -18
- package/Build/Workers/createEllipsoidGeometry.js +19 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -17
- package/Build/Workers/createFrustumGeometry.js +18 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -17
- package/Build/Workers/createGeometry.js +54 -33
- package/Build/Workers/createGroundPolylineGeometry.js +22 -21
- package/Build/Workers/createPlaneGeometry.js +16 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -14
- package/Build/Workers/createPolygonGeometry.js +32 -166
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -29
- package/Build/Workers/createPolylineGeometry.js +25 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +32 -33
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -26
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -19
- package/Build/Workers/createSimplePolylineGeometry.js +23 -22
- package/Build/Workers/createSphereGeometry.js +19 -18
- package/Build/Workers/createSphereOutlineGeometry.js +18 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +22 -21
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
- package/Build/Workers/createVerticesFromHeightmap.js +22 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
- package/Build/Workers/createWallGeometry.js +24 -23
- package/Build/Workers/createWallOutlineGeometry.js +23 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +601 -92
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -21
- package/LICENSE.md +1 -1
- package/Source/Assets/approximateTerrainHeights.json +1 -1
- package/Source/Core/Ellipsoid.js +6 -0
- package/Source/Core/GregorianDate.js +85 -0
- package/Source/Core/HeadingPitchRange.js +2 -2
- package/Source/Core/IntersectionTests.js +6 -3
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +5 -0
- package/Source/Core/PolygonGeometry.js +0 -169
- package/Source/Core/Resource.js +30 -69
- package/Source/Core/Transforms.js +30 -18
- package/Source/Core/createWorldBathymetryAsync.js +45 -0
- package/Source/Core/srgbToLinear.js +32 -0
- package/Source/DataSources/CzmlDataSource.js +51 -23
- package/Source/DataSources/DataSourceDisplay.js +27 -0
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
- package/Source/DataSources/Entity.js +28 -7
- package/Source/DataSources/EntityCollection.js +1 -2
- package/Source/DataSources/GeometryUpdater.js +1 -2
- package/Source/DataSources/GeometryUpdaterSet.js +114 -0
- package/Source/DataSources/GeometryVisualizer.js +19 -83
- package/Source/DataSources/GroundGeometryUpdater.js +6 -3
- package/Source/DataSources/ModelVisualizer.js +19 -98
- package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
- package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
- package/Source/DataSources/TerrainOffsetProperty.js +15 -23
- package/Source/Renderer/AutomaticUniforms.js +121 -1
- package/Source/Renderer/Context.js +10 -0
- package/Source/Renderer/ContextLimits.js +2 -0
- package/Source/Renderer/UniformState.js +127 -0
- package/Source/Renderer/demodernizeShader.js +4 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +127 -0
- package/Source/Scene/Axis.js +12 -7
- package/Source/Scene/Billboard.js +29 -26
- package/Source/Scene/BillboardCollection.js +3 -3
- package/Source/Scene/Camera.js +47 -5
- package/Source/Scene/Cesium3DTile.js +1 -0
- package/Source/Scene/Cesium3DTileContent.js +14 -0
- package/Source/Scene/Cesium3DTileset.js +364 -45
- package/Source/Scene/Cesium3DTilesetBaseTraversal.js +2 -4
- package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
- package/Source/Scene/Composite3DTileContent.js +42 -0
- package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
- package/Source/Scene/Empty3DTileContent.js +4 -0
- package/Source/Scene/Fog.js +1 -0
- package/Source/Scene/FrameState.js +14 -1
- package/Source/Scene/Geometry3DTileContent.js +4 -0
- package/Source/Scene/Globe.js +3 -2
- package/Source/Scene/GlobeSurfaceTileProvider.js +3 -1
- package/Source/Scene/GlobeTranslucencyState.js +1 -1
- package/Source/Scene/GltfLoader.js +15 -5
- package/Source/Scene/GltfPipeline/updateVersion.js +69 -68
- package/Source/Scene/HeightReference.js +59 -2
- package/Source/Scene/I3SDataProvider.js +270 -53
- package/Source/Scene/I3SDecoder.js +8 -1
- package/Source/Scene/I3SFeature.js +2 -5
- package/Source/Scene/I3SField.js +136 -31
- package/Source/Scene/I3SGeometry.js +70 -2
- package/Source/Scene/I3SLayer.js +55 -10
- package/Source/Scene/I3SNode.js +175 -18
- package/Source/Scene/I3SStatistics.js +94 -0
- package/Source/Scene/I3SSublayer.js +176 -0
- package/Source/Scene/I3SSymbology.js +337 -0
- package/Source/Scene/Implicit3DTileContent.js +4 -0
- package/Source/Scene/KeyframeNode.js +1 -1
- package/Source/Scene/LabelCollection.js +2 -2
- package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
- package/Source/Scene/Model/B3dmLoader.js +4 -0
- package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
- package/Source/Scene/Model/I3dmLoader.js +4 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
- package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
- package/Source/Scene/Model/Model.js +82 -32
- package/Source/Scene/Model/Model3DTileContent.js +31 -0
- package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
- package/Source/Scene/Model/ModelSceneGraph.js +6 -0
- package/Source/Scene/Model/pickModel.js +426 -0
- package/Source/Scene/Multiple3DTileContent.js +42 -0
- package/Source/Scene/PickFramebuffer.js +37 -2
- package/Source/Scene/Picking.js +113 -39
- package/Source/Scene/Primitive.js +6 -2
- package/Source/Scene/QuadtreePrimitive.js +1 -1
- package/Source/Scene/Scene.js +312 -46
- package/Source/Scene/ScreenSpaceCameraController.js +23 -13
- package/Source/Scene/SensorVolumePortionToDisplay.js +69 -0
- package/Source/Scene/SkyAtmosphere.js +5 -6
- package/Source/Scene/SpatialNode.js +12 -19
- package/Source/Scene/StructuralMetadata.js +1 -1
- package/Source/Scene/Terrain.js +49 -0
- package/Source/Scene/TileBoundingS2Cell.js +2 -2
- package/Source/Scene/Tileset3DTileContent.js +4 -0
- package/Source/Scene/Vector3DTileContent.js +4 -0
- package/Source/Scene/VoxelBoxShape.js +76 -0
- package/Source/Scene/VoxelCell.js +273 -0
- package/Source/Scene/VoxelCylinderShape.js +114 -43
- package/Source/Scene/VoxelEllipsoidShape.js +158 -116
- package/Source/Scene/VoxelPrimitive.js +3 -1
- package/Source/Scene/VoxelRenderResources.js +3 -0
- package/Source/Scene/VoxelShape.js +13 -0
- package/Source/Scene/VoxelTraversal.js +76 -54
- package/Source/Scene/buildVoxelDrawCommands.js +23 -0
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -0
- package/Source/Scene/processVoxelProperties.js +2 -0
- package/Source/Shaders/AtmosphereCommon.glsl +3 -11
- package/Source/Shaders/AtmosphereCommon.js +3 -11
- package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
- package/Source/Shaders/GlobeFS.glsl +16 -25
- package/Source/Shaders/GlobeFS.js +16 -25
- package/Source/Shaders/GlobeVS.glsl +1 -1
- package/Source/Shaders/GlobeVS.js +1 -1
- package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
- package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
- package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
- package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
- package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageFS.js +1 -1
- package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
- package/Source/Shaders/Model/GeometryStageVS.js +4 -4
- package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
- package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +4 -0
- package/Source/Shaders/Model/ModelFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +9 -4
- package/Source/Shaders/Model/ModelVS.js +9 -4
- package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
- package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
- package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
- package/Source/Shaders/SkyAtmosphereFS.js +5 -10
- package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
- package/Source/Shaders/SkyAtmosphereVS.js +3 -2
- package/Source/Shaders/Voxels/IntersectCylinder.glsl +14 -111
- package/Source/Shaders/Voxels/IntersectCylinder.js +14 -111
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +32 -113
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +32 -113
- package/Source/Shaders/Voxels/IntersectLongitude.glsl +102 -0
- package/Source/Shaders/Voxels/IntersectLongitude.js +104 -0
- package/Source/Shaders/Voxels/VoxelFS.glsl +39 -1
- package/Source/Shaders/Voxels/VoxelFS.js +39 -1
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +19 -37
- package/Source/Shaders/Voxels/convertUvToCylinder.js +19 -37
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +24 -44
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +24 -44
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/Source/Workers/createGeometry.js +40 -11
- package/Source/Workers/decodeI3S.js +720 -94
- package/index.d.ts +574 -71
- package/index.js +217 -196
- package/package.json +3 -3
- package/Build/Workers/chunk-ATB2I7OS.js +0 -55
|
@@ -49,16 +49,14 @@ function VoxelTraversal(
|
|
|
49
49
|
*/
|
|
50
50
|
this._primitive = primitive;
|
|
51
51
|
|
|
52
|
-
const length = types.length;
|
|
53
|
-
|
|
54
52
|
/**
|
|
55
53
|
* @type {Megatexture[]}
|
|
56
54
|
* @readonly
|
|
57
55
|
*/
|
|
58
|
-
this.megatextures = new Array(length);
|
|
56
|
+
this.megatextures = new Array(types.length);
|
|
59
57
|
|
|
60
58
|
// TODO make sure to split the maximumTextureMemoryByteLength across all the megatextures
|
|
61
|
-
for (let i = 0; i < length; i++) {
|
|
59
|
+
for (let i = 0; i < types.length; i++) {
|
|
62
60
|
const type = types[i];
|
|
63
61
|
const componentCount = MetadataType.getComponentCount(type);
|
|
64
62
|
const componentType = componentTypes[i];
|
|
@@ -218,6 +216,18 @@ function VoxelTraversal(
|
|
|
218
216
|
this.leafNodeTexelSizeUv = new Cartesian2();
|
|
219
217
|
}
|
|
220
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Finds a keyframe node in the traversal
|
|
221
|
+
*
|
|
222
|
+
* @param {number} megatextureIndex
|
|
223
|
+
* @returns {KeyframeNode}
|
|
224
|
+
*/
|
|
225
|
+
VoxelTraversal.prototype.findKeyframeNode = function (megatextureIndex) {
|
|
226
|
+
return this._keyframeNodesInMegatexture.find(function (keyframeNode) {
|
|
227
|
+
return keyframeNode.megatextureIndex === megatextureIndex;
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
221
231
|
function binaryTreeWeightingRecursive(arr, start, end, depth) {
|
|
222
232
|
if (start > end) {
|
|
223
233
|
return;
|
|
@@ -382,10 +392,7 @@ VoxelTraversal.prototype.destroy = function () {
|
|
|
382
392
|
* @private
|
|
383
393
|
*/
|
|
384
394
|
function recomputeBoundingVolumesRecursive(that, node) {
|
|
385
|
-
|
|
386
|
-
const shape = primitive._shape;
|
|
387
|
-
const dimensions = primitive._provider.dimensions;
|
|
388
|
-
node.computeBoundingVolumes(shape, dimensions);
|
|
395
|
+
node.computeBoundingVolumes(that._primitive._shape);
|
|
389
396
|
if (defined(node.children)) {
|
|
390
397
|
for (let i = 0; i < 8; i++) {
|
|
391
398
|
const child = node.children[i];
|
|
@@ -410,12 +417,11 @@ function requestData(that, keyframeNode) {
|
|
|
410
417
|
return;
|
|
411
418
|
}
|
|
412
419
|
|
|
413
|
-
const
|
|
414
|
-
const provider = primitive._provider;
|
|
420
|
+
const provider = that._primitive._provider;
|
|
415
421
|
|
|
416
422
|
function postRequestSuccess(result) {
|
|
417
423
|
that._simultaneousRequestCount--;
|
|
418
|
-
const length =
|
|
424
|
+
const length = provider.types.length;
|
|
419
425
|
|
|
420
426
|
if (!defined(result)) {
|
|
421
427
|
keyframeNode.state = KeyframeNode.LoadState.UNAVAILABLE;
|
|
@@ -434,7 +440,7 @@ function requestData(that, keyframeNode) {
|
|
|
434
440
|
const data = result[i];
|
|
435
441
|
const expectedLength = tileVoxelCount * channelCount;
|
|
436
442
|
if (data.length === expectedLength) {
|
|
437
|
-
keyframeNode.
|
|
443
|
+
keyframeNode.metadata[i] = data;
|
|
438
444
|
// State is received only when all metadata requests have been received
|
|
439
445
|
keyframeNode.state = KeyframeNode.LoadState.RECEIVED;
|
|
440
446
|
} else {
|
|
@@ -492,42 +498,22 @@ function loadAndUnload(that, frameState) {
|
|
|
492
498
|
const frameNumber = that._frameNumber;
|
|
493
499
|
const primitive = that._primitive;
|
|
494
500
|
const shape = primitive._shape;
|
|
495
|
-
const { dimensions } = primitive;
|
|
496
501
|
const targetScreenSpaceError = primitive.screenSpaceError;
|
|
497
502
|
const priorityQueue = that._priorityQueue;
|
|
498
|
-
const keyframeLocation = that._keyframeLocation;
|
|
499
503
|
const keyframeCount = that._keyframeCount;
|
|
500
|
-
|
|
504
|
+
|
|
505
|
+
const previousKeyframe = CesiumMath.clamp(
|
|
506
|
+
Math.floor(that._keyframeLocation),
|
|
507
|
+
0,
|
|
508
|
+
keyframeCount - 2
|
|
509
|
+
);
|
|
510
|
+
const nextKeyframe = previousKeyframe + 1;
|
|
501
511
|
|
|
502
512
|
const { camera, context, pixelRatio } = frameState;
|
|
503
513
|
const { positionWC, frustum } = camera;
|
|
504
514
|
const screenHeight = context.drawingBufferHeight / pixelRatio;
|
|
505
515
|
const screenSpaceErrorMultiplier = screenHeight / frustum.sseDenominator;
|
|
506
516
|
|
|
507
|
-
function keyframePriority(previousKeyframe, keyframe, nextKeyframe) {
|
|
508
|
-
const keyframeDifference = Math.min(
|
|
509
|
-
Math.abs(keyframe - previousKeyframe),
|
|
510
|
-
Math.abs(keyframe - nextKeyframe)
|
|
511
|
-
);
|
|
512
|
-
const maxKeyframeDifference = Math.max(
|
|
513
|
-
previousKeyframe,
|
|
514
|
-
keyframeCount - nextKeyframe - 1,
|
|
515
|
-
1
|
|
516
|
-
);
|
|
517
|
-
const keyframeFactor = Math.pow(
|
|
518
|
-
1.0 - keyframeDifference / maxKeyframeDifference,
|
|
519
|
-
4.0
|
|
520
|
-
);
|
|
521
|
-
const binaryTreeFactor = Math.exp(
|
|
522
|
-
-that._binaryTreeKeyframeWeighting[keyframe]
|
|
523
|
-
);
|
|
524
|
-
return CesiumMath.lerp(
|
|
525
|
-
binaryTreeFactor,
|
|
526
|
-
keyframeFactor,
|
|
527
|
-
0.15 + 0.85 * keyframeFactor
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
517
|
/**
|
|
532
518
|
* @ignore
|
|
533
519
|
* @param {SpatialNode} spatialNode
|
|
@@ -545,13 +531,6 @@ function loadAndUnload(that, frameState) {
|
|
|
545
531
|
}
|
|
546
532
|
spatialNode.visitedFrameNumber = frameNumber;
|
|
547
533
|
|
|
548
|
-
const previousKeyframe = CesiumMath.clamp(
|
|
549
|
-
Math.floor(keyframeLocation),
|
|
550
|
-
0,
|
|
551
|
-
keyframeCount - 2
|
|
552
|
-
);
|
|
553
|
-
const nextKeyframe = previousKeyframe + 1;
|
|
554
|
-
|
|
555
534
|
// Create keyframe nodes at the playhead.
|
|
556
535
|
// If they already exist, nothing will be created.
|
|
557
536
|
if (keyframeCount === 1) {
|
|
@@ -561,16 +540,21 @@ function loadAndUnload(that, frameState) {
|
|
|
561
540
|
spatialNode.createKeyframeNode(k);
|
|
562
541
|
}
|
|
563
542
|
}
|
|
564
|
-
const
|
|
543
|
+
const { screenSpaceError, keyframeNodes } = spatialNode;
|
|
544
|
+
const ssePriority = mapInfiniteRangeToZeroOne(screenSpaceError);
|
|
565
545
|
|
|
566
546
|
let hasLoadedKeyframe = false;
|
|
567
|
-
const keyframeNodes = spatialNode.keyframeNodes;
|
|
568
547
|
for (let i = 0; i < keyframeNodes.length; i++) {
|
|
569
548
|
const keyframeNode = keyframeNodes[i];
|
|
570
549
|
|
|
571
550
|
keyframeNode.priority =
|
|
572
551
|
10.0 * ssePriority +
|
|
573
|
-
keyframePriority(
|
|
552
|
+
keyframePriority(
|
|
553
|
+
previousKeyframe,
|
|
554
|
+
keyframeNode.keyframe,
|
|
555
|
+
nextKeyframe,
|
|
556
|
+
that
|
|
557
|
+
);
|
|
574
558
|
|
|
575
559
|
if (
|
|
576
560
|
keyframeNode.state !== KeyframeNode.LoadState.UNAVAILABLE &&
|
|
@@ -584,16 +568,14 @@ function loadAndUnload(that, frameState) {
|
|
|
584
568
|
}
|
|
585
569
|
}
|
|
586
570
|
|
|
587
|
-
|
|
588
|
-
spatialNode.screenSpaceError < targetScreenSpaceError;
|
|
589
|
-
if (meetsScreenSpaceError || !hasLoadedKeyframe) {
|
|
571
|
+
if (screenSpaceError < targetScreenSpaceError || !hasLoadedKeyframe) {
|
|
590
572
|
// Free up memory
|
|
591
573
|
spatialNode.children = undefined;
|
|
592
574
|
return;
|
|
593
575
|
}
|
|
594
576
|
|
|
595
577
|
if (!defined(spatialNode.children)) {
|
|
596
|
-
spatialNode.constructChildNodes(shape
|
|
578
|
+
spatialNode.constructChildNodes(shape);
|
|
597
579
|
}
|
|
598
580
|
for (let childIndex = 0; childIndex < 8; childIndex++) {
|
|
599
581
|
const child = spatialNode.children[childIndex];
|
|
@@ -601,9 +583,11 @@ function loadAndUnload(that, frameState) {
|
|
|
601
583
|
}
|
|
602
584
|
}
|
|
603
585
|
|
|
586
|
+
// Add all the nodes to the queue, to sort them by priority.
|
|
604
587
|
priorityQueue.reset();
|
|
605
|
-
addToQueueRecursive(rootNode, CullingVolume.MASK_INDETERMINATE);
|
|
588
|
+
addToQueueRecursive(that.rootNode, CullingVolume.MASK_INDETERMINATE);
|
|
606
589
|
|
|
590
|
+
// Move the nodes from the queue to array of high priority nodes.
|
|
607
591
|
const highPriorityKeyframeNodes = that._highPriorityKeyframeNodes;
|
|
608
592
|
let highPriorityKeyframeNodeCount = 0;
|
|
609
593
|
let highPriorityKeyframeNode;
|
|
@@ -616,6 +600,8 @@ function loadAndUnload(that, frameState) {
|
|
|
616
600
|
highPriorityKeyframeNodeCount++;
|
|
617
601
|
}
|
|
618
602
|
|
|
603
|
+
// Sort the list of keyframe nodes in the megatexture by priority, so
|
|
604
|
+
// we can remove the lowest priority nodes if we need space.
|
|
619
605
|
const keyframeNodesInMegatexture = that._keyframeNodesInMegatexture;
|
|
620
606
|
// TODO: some of the megatexture state should be stored once, not duplicate for each megatexture
|
|
621
607
|
const megatexture = that.megatextures[0];
|
|
@@ -628,6 +614,8 @@ function loadAndUnload(that, frameState) {
|
|
|
628
614
|
return b.highPriorityFrameNumber - a.highPriorityFrameNumber;
|
|
629
615
|
});
|
|
630
616
|
|
|
617
|
+
// Add the high priority nodes to the megatexture,
|
|
618
|
+
// removing existing lower-priority nodes if necessary.
|
|
631
619
|
let destroyedCount = 0;
|
|
632
620
|
let addedCount = 0;
|
|
633
621
|
|
|
@@ -675,6 +663,40 @@ function loadAndUnload(that, frameState) {
|
|
|
675
663
|
}
|
|
676
664
|
}
|
|
677
665
|
|
|
666
|
+
/**
|
|
667
|
+
* Compute a priority for a keyframe node.
|
|
668
|
+
*
|
|
669
|
+
* @private
|
|
670
|
+
* @param {number} previousKeyframe
|
|
671
|
+
* @param {number} keyframe
|
|
672
|
+
* @param {number} nextKeyframe
|
|
673
|
+
* @param {VoxelTraversal} traversal
|
|
674
|
+
* @returns {number} The computed priority
|
|
675
|
+
*/
|
|
676
|
+
function keyframePriority(previousKeyframe, keyframe, nextKeyframe, traversal) {
|
|
677
|
+
const keyframeDifference = Math.min(
|
|
678
|
+
Math.abs(keyframe - previousKeyframe),
|
|
679
|
+
Math.abs(keyframe - nextKeyframe)
|
|
680
|
+
);
|
|
681
|
+
const maxKeyframeDifference = Math.max(
|
|
682
|
+
previousKeyframe,
|
|
683
|
+
traversal._keyframeCount - nextKeyframe - 1,
|
|
684
|
+
1
|
|
685
|
+
);
|
|
686
|
+
const keyframeFactor = Math.pow(
|
|
687
|
+
1.0 - keyframeDifference / maxKeyframeDifference,
|
|
688
|
+
4.0
|
|
689
|
+
);
|
|
690
|
+
const binaryTreeFactor = Math.exp(
|
|
691
|
+
-traversal._binaryTreeKeyframeWeighting[keyframe]
|
|
692
|
+
);
|
|
693
|
+
return CesiumMath.lerp(
|
|
694
|
+
binaryTreeFactor,
|
|
695
|
+
keyframeFactor,
|
|
696
|
+
0.15 + 0.85 * keyframeFactor
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
|
|
678
700
|
/**
|
|
679
701
|
* @function
|
|
680
702
|
*
|
|
@@ -58,8 +58,17 @@ function buildVoxelDrawCommands(primitive, context) {
|
|
|
58
58
|
// Compile shaders
|
|
59
59
|
const shaderBuilderPick = shaderBuilder.clone();
|
|
60
60
|
shaderBuilderPick.addDefine("PICKING", undefined, ShaderDestination.FRAGMENT);
|
|
61
|
+
const shaderBuilderPickVoxel = shaderBuilder.clone();
|
|
62
|
+
shaderBuilderPickVoxel.addDefine(
|
|
63
|
+
"PICKING_VOXEL",
|
|
64
|
+
undefined,
|
|
65
|
+
ShaderDestination.FRAGMENT
|
|
66
|
+
);
|
|
61
67
|
const shaderProgram = shaderBuilder.buildShaderProgram(context);
|
|
62
68
|
const shaderProgramPick = shaderBuilderPick.buildShaderProgram(context);
|
|
69
|
+
const shaderProgramPickVoxel = shaderBuilderPickVoxel.buildShaderProgram(
|
|
70
|
+
context
|
|
71
|
+
);
|
|
63
72
|
const renderState = RenderState.fromCache({
|
|
64
73
|
cull: {
|
|
65
74
|
enabled: true,
|
|
@@ -98,6 +107,14 @@ function buildVoxelDrawCommands(primitive, context) {
|
|
|
98
107
|
drawCommandPick.shaderProgram = shaderProgramPick;
|
|
99
108
|
drawCommandPick.pickOnly = true;
|
|
100
109
|
|
|
110
|
+
// Create the pick voxels draw command
|
|
111
|
+
const drawCommandPickVoxel = DrawCommand.shallowClone(
|
|
112
|
+
drawCommand,
|
|
113
|
+
new DrawCommand()
|
|
114
|
+
);
|
|
115
|
+
drawCommandPickVoxel.shaderProgram = shaderProgramPickVoxel;
|
|
116
|
+
drawCommandPickVoxel.pickOnly = true;
|
|
117
|
+
|
|
101
118
|
// Delete the old shader programs
|
|
102
119
|
if (defined(primitive._drawCommand)) {
|
|
103
120
|
const command = primitive._drawCommand;
|
|
@@ -109,9 +126,15 @@ function buildVoxelDrawCommands(primitive, context) {
|
|
|
109
126
|
command.shaderProgram =
|
|
110
127
|
command.shaderProgram && command.shaderProgram.destroy();
|
|
111
128
|
}
|
|
129
|
+
if (defined(primitive._drawCommandPickVoxel)) {
|
|
130
|
+
const command = primitive._drawCommandPickVoxel;
|
|
131
|
+
command.shaderProgram =
|
|
132
|
+
command.shaderProgram && command.shaderProgram.destroy();
|
|
133
|
+
}
|
|
112
134
|
|
|
113
135
|
primitive._drawCommand = drawCommand;
|
|
114
136
|
primitive._drawCommandPick = drawCommandPick;
|
|
137
|
+
primitive._drawCommandPickVoxel = drawCommandPickVoxel;
|
|
115
138
|
}
|
|
116
139
|
|
|
117
140
|
export default buildVoxelDrawCommands;
|
|
@@ -46,6 +46,7 @@ async function createGooglePhotorealistic3DTileset(key, options) {
|
|
|
46
46
|
options.maximumCacheOverflowBytes,
|
|
47
47
|
1024 * 1024 * 1024
|
|
48
48
|
);
|
|
49
|
+
options.enableCollision = defaultValue(options.enableCollision, true);
|
|
49
50
|
|
|
50
51
|
key = defaultValue(key, GoogleMaps.defaultApiKey);
|
|
51
52
|
if (!defined(key)) {
|
|
@@ -153,6 +153,8 @@ function processVoxelProperties(renderResources, primitive) {
|
|
|
153
153
|
shaderBuilder.addStructField(voxelStructId, "vec3", "viewDirWorld");
|
|
154
154
|
shaderBuilder.addStructField(voxelStructId, "vec3", "surfaceNormal");
|
|
155
155
|
shaderBuilder.addStructField(voxelStructId, "float", "travelDistance");
|
|
156
|
+
shaderBuilder.addStructField(voxelStructId, "int", "tileIndex");
|
|
157
|
+
shaderBuilder.addStructField(voxelStructId, "int", "sampleIndex");
|
|
156
158
|
|
|
157
159
|
// FragmentInput struct
|
|
158
160
|
const fragmentInputStructId = "FragmentInput";
|
|
@@ -11,14 +11,6 @@ const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in
|
|
|
11
11
|
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
|
|
12
12
|
const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Rational approximation to tanh(x)
|
|
16
|
-
*/
|
|
17
|
-
float approximateTanh(float x) {
|
|
18
|
-
float x2 = x * x;
|
|
19
|
-
return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
|
|
24
16
|
* the transmittance value for the ray.
|
|
@@ -65,8 +57,8 @@ void computeScattering(
|
|
|
65
57
|
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
|
|
66
58
|
// Value close to 0.0: close to the horizon
|
|
67
59
|
// Value close to 1.0: above in the sky
|
|
68
|
-
float w_stop_gt_lprl = 0.5 * (1.0 +
|
|
69
|
-
|
|
60
|
+
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
|
|
61
|
+
|
|
70
62
|
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
|
|
71
63
|
float start_0 = primaryRayAtmosphereIntersect.start;
|
|
72
64
|
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
|
|
@@ -77,7 +69,7 @@ void computeScattering(
|
|
|
77
69
|
// (1) from outer space we have to use more ray steps to get a realistic rendering
|
|
78
70
|
// (2) within atmosphere we need fewer steps for faster rendering
|
|
79
71
|
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
|
|
80
|
-
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 +
|
|
72
|
+
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));
|
|
81
73
|
int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
|
|
82
74
|
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
|
|
83
75
|
|
|
@@ -12,14 +12,6 @@ const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in
|
|
|
12
12
|
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.\n\
|
|
13
13
|
const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
|
|
14
14
|
\n\
|
|
15
|
-
/**\n\
|
|
16
|
-
* Rational approximation to tanh(x)\n\
|
|
17
|
-
*/\n\
|
|
18
|
-
float approximateTanh(float x) {\n\
|
|
19
|
-
float x2 = x * x;\n\
|
|
20
|
-
return max(-1.0, min(+1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));\n\
|
|
21
|
-
}\n\
|
|
22
|
-
\n\
|
|
23
15
|
/**\n\
|
|
24
16
|
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as\n\
|
|
25
17
|
* the transmittance value for the ray.\n\
|
|
@@ -66,8 +58,8 @@ void computeScattering(\n\
|
|
|
66
58
|
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);\n\
|
|
67
59
|
// Value close to 0.0: close to the horizon\n\
|
|
68
60
|
// Value close to 1.0: above in the sky\n\
|
|
69
|
-
float w_stop_gt_lprl = 0.5 * (1.0 +
|
|
70
|
-
|
|
61
|
+
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));\n\
|
|
62
|
+
\n\
|
|
71
63
|
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.\n\
|
|
72
64
|
float start_0 = primaryRayAtmosphereIntersect.start;\n\
|
|
73
65
|
primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);\n\
|
|
@@ -78,7 +70,7 @@ void computeScattering(\n\
|
|
|
78
70
|
// (1) from outer space we have to use more ray steps to get a realistic rendering\n\
|
|
79
71
|
// (2) within atmosphere we need fewer steps for faster rendering\n\
|
|
80
72
|
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters\n\
|
|
81
|
-
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 +
|
|
73
|
+
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));\n\
|
|
82
74
|
int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.\n\
|
|
83
75
|
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.\n\
|
|
84
76
|
\n\
|
|
@@ -55,7 +55,9 @@ import czm_XYZToRGB from './Functions/XYZToRGB.js'
|
|
|
55
55
|
import czm_acesTonemapping from './Functions/acesTonemapping.js'
|
|
56
56
|
import czm_alphaWeight from './Functions/alphaWeight.js'
|
|
57
57
|
import czm_antialias from './Functions/antialias.js'
|
|
58
|
+
import czm_applyHSBShift from './Functions/applyHSBShift.js'
|
|
58
59
|
import czm_approximateSphericalCoordinates from './Functions/approximateSphericalCoordinates.js'
|
|
60
|
+
import czm_approximateTanh from './Functions/approximateTanh.js'
|
|
59
61
|
import czm_backFacing from './Functions/backFacing.js'
|
|
60
62
|
import czm_branchFreeTernary from './Functions/branchFreeTernary.js'
|
|
61
63
|
import czm_cascadeColor from './Functions/cascadeColor.js'
|
|
@@ -63,7 +65,10 @@ import czm_cascadeDistance from './Functions/cascadeDistance.js'
|
|
|
63
65
|
import czm_cascadeMatrix from './Functions/cascadeMatrix.js'
|
|
64
66
|
import czm_cascadeWeights from './Functions/cascadeWeights.js'
|
|
65
67
|
import czm_columbusViewMorph from './Functions/columbusViewMorph.js'
|
|
68
|
+
import czm_computeAtmosphereColor from './Functions/computeAtmosphereColor.js'
|
|
69
|
+
import czm_computeGroundAtmosphereScattering from './Functions/computeGroundAtmosphereScattering.js'
|
|
66
70
|
import czm_computePosition from './Functions/computePosition.js'
|
|
71
|
+
import czm_computeScattering from './Functions/computeScattering.js'
|
|
67
72
|
import czm_cosineAndSine from './Functions/cosineAndSine.js'
|
|
68
73
|
import czm_decompressTextureCoordinates from './Functions/decompressTextureCoordinates.js'
|
|
69
74
|
import czm_defaultPbrMaterial from './Functions/defaultPbrMaterial.js'
|
|
@@ -79,6 +84,7 @@ import czm_fog from './Functions/fog.js'
|
|
|
79
84
|
import czm_gammaCorrect from './Functions/gammaCorrect.js'
|
|
80
85
|
import czm_geodeticSurfaceNormal from './Functions/geodeticSurfaceNormal.js'
|
|
81
86
|
import czm_getDefaultMaterial from './Functions/getDefaultMaterial.js'
|
|
87
|
+
import czm_getDynamicAtmosphereLightDirection from './Functions/getDynamicAtmosphereLightDirection.js'
|
|
82
88
|
import czm_getLambertDiffuse from './Functions/getLambertDiffuse.js'
|
|
83
89
|
import czm_getSpecular from './Functions/getSpecular.js'
|
|
84
90
|
import czm_getWaterNoise from './Functions/getWaterNoise.js'
|
|
@@ -188,7 +194,9 @@ export default {
|
|
|
188
194
|
czm_acesTonemapping : czm_acesTonemapping,
|
|
189
195
|
czm_alphaWeight : czm_alphaWeight,
|
|
190
196
|
czm_antialias : czm_antialias,
|
|
197
|
+
czm_applyHSBShift : czm_applyHSBShift,
|
|
191
198
|
czm_approximateSphericalCoordinates : czm_approximateSphericalCoordinates,
|
|
199
|
+
czm_approximateTanh : czm_approximateTanh,
|
|
192
200
|
czm_backFacing : czm_backFacing,
|
|
193
201
|
czm_branchFreeTernary : czm_branchFreeTernary,
|
|
194
202
|
czm_cascadeColor : czm_cascadeColor,
|
|
@@ -196,7 +204,10 @@ export default {
|
|
|
196
204
|
czm_cascadeMatrix : czm_cascadeMatrix,
|
|
197
205
|
czm_cascadeWeights : czm_cascadeWeights,
|
|
198
206
|
czm_columbusViewMorph : czm_columbusViewMorph,
|
|
207
|
+
czm_computeAtmosphereColor : czm_computeAtmosphereColor,
|
|
208
|
+
czm_computeGroundAtmosphereScattering : czm_computeGroundAtmosphereScattering,
|
|
199
209
|
czm_computePosition : czm_computePosition,
|
|
210
|
+
czm_computeScattering : czm_computeScattering,
|
|
200
211
|
czm_cosineAndSine : czm_cosineAndSine,
|
|
201
212
|
czm_decompressTextureCoordinates : czm_decompressTextureCoordinates,
|
|
202
213
|
czm_defaultPbrMaterial : czm_defaultPbrMaterial,
|
|
@@ -212,6 +223,7 @@ export default {
|
|
|
212
223
|
czm_gammaCorrect : czm_gammaCorrect,
|
|
213
224
|
czm_geodeticSurfaceNormal : czm_geodeticSurfaceNormal,
|
|
214
225
|
czm_getDefaultMaterial : czm_getDefaultMaterial,
|
|
226
|
+
czm_getDynamicAtmosphereLightDirection : czm_getDynamicAtmosphereLightDirection,
|
|
215
227
|
czm_getLambertDiffuse : czm_getLambertDiffuse,
|
|
216
228
|
czm_getSpecular : czm_getSpecular,
|
|
217
229
|
czm_getWaterNoise : czm_getWaterNoise,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a HSB color shift to an RGB color.
|
|
3
|
+
*
|
|
4
|
+
* @param {vec3} rgb The color in RGB space.
|
|
5
|
+
* @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment
|
|
6
|
+
* @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.
|
|
7
|
+
*
|
|
8
|
+
* @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.
|
|
9
|
+
*/
|
|
10
|
+
vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {
|
|
11
|
+
// Convert rgb color to hsb
|
|
12
|
+
vec3 hsb = czm_RGBToHSB(rgb);
|
|
13
|
+
|
|
14
|
+
// Perform hsb shift
|
|
15
|
+
// Hue cycles around so no clamp is needed.
|
|
16
|
+
hsb.x += hsbShift.x; // hue
|
|
17
|
+
hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation
|
|
18
|
+
|
|
19
|
+
// brightness
|
|
20
|
+
//
|
|
21
|
+
// Some shaders such as atmosphere-related effects need to leave black
|
|
22
|
+
// pixels unchanged
|
|
23
|
+
if (ignoreBlackPixels) {
|
|
24
|
+
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;
|
|
25
|
+
} else {
|
|
26
|
+
hsb.z = hsb.z + hsbShift.z;
|
|
27
|
+
}
|
|
28
|
+
hsb.z = clamp(hsb.z, 0.0, 1.0);
|
|
29
|
+
|
|
30
|
+
// Convert shifted hsb back to rgb
|
|
31
|
+
return czm_HSBToRGB(hsb);
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Apply a HSB color shift to an RGB color.\n\
|
|
4
|
+
*\n\
|
|
5
|
+
* @param {vec3} rgb The color in RGB space.\n\
|
|
6
|
+
* @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment\n\
|
|
7
|
+
* @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.\n\
|
|
8
|
+
*\n\
|
|
9
|
+
* @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.\n\
|
|
10
|
+
*/\n\
|
|
11
|
+
vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {\n\
|
|
12
|
+
// Convert rgb color to hsb\n\
|
|
13
|
+
vec3 hsb = czm_RGBToHSB(rgb);\n\
|
|
14
|
+
\n\
|
|
15
|
+
// Perform hsb shift\n\
|
|
16
|
+
// Hue cycles around so no clamp is needed.\n\
|
|
17
|
+
hsb.x += hsbShift.x; // hue\n\
|
|
18
|
+
hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation\n\
|
|
19
|
+
\n\
|
|
20
|
+
// brightness\n\
|
|
21
|
+
//\n\
|
|
22
|
+
// Some shaders such as atmosphere-related effects need to leave black\n\
|
|
23
|
+
// pixels unchanged\n\
|
|
24
|
+
if (ignoreBlackPixels) {\n\
|
|
25
|
+
hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;\n\
|
|
26
|
+
} else {\n\
|
|
27
|
+
hsb.z = hsb.z + hsbShift.z;\n\
|
|
28
|
+
}\n\
|
|
29
|
+
hsb.z = clamp(hsb.z, 0.0, 1.0);\n\
|
|
30
|
+
\n\
|
|
31
|
+
// Convert shifted hsb back to rgb\n\
|
|
32
|
+
return czm_HSBToRGB(hsb);\n\
|
|
33
|
+
}\n\
|
|
34
|
+
";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute a rational approximation to tanh(x)
|
|
3
|
+
*
|
|
4
|
+
* @param {float} x A real number input
|
|
5
|
+
* @returns {float} An approximation for tanh(x)
|
|
6
|
+
*/
|
|
7
|
+
float czm_approximateTanh(float x) {
|
|
8
|
+
float x2 = x * x;
|
|
9
|
+
return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Compute a rational approximation to tanh(x)\n\
|
|
4
|
+
*\n\
|
|
5
|
+
* @param {float} x A real number input\n\
|
|
6
|
+
* @returns {float} An approximation for tanh(x)\n\
|
|
7
|
+
*/\n\
|
|
8
|
+
float czm_approximateTanh(float x) {\n\
|
|
9
|
+
float x2 = x * x;\n\
|
|
10
|
+
return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));\n\
|
|
11
|
+
}\n\
|
|
12
|
+
";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the atmosphere color, applying Rayleigh and Mie scattering. This
|
|
3
|
+
* builtin uses automatic uniforms so the atmophere settings are synced with the
|
|
4
|
+
* state of the Scene, even in other contexts like Model.
|
|
5
|
+
*
|
|
6
|
+
* @name czm_computeAtmosphereColor
|
|
7
|
+
* @glslFunction
|
|
8
|
+
*
|
|
9
|
+
* @param {vec3} positionWC Position of the fragment in world coords (low precision)
|
|
10
|
+
* @param {vec3} lightDirection Light direction from the sun or other light source.
|
|
11
|
+
* @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
|
|
12
|
+
* @param {vec3} mieColor The Mie scattering color computed by a scattering function
|
|
13
|
+
* @param {float} opacity The opacity computed by a scattering function.
|
|
14
|
+
*/
|
|
15
|
+
vec4 czm_computeAtmosphereColor(
|
|
16
|
+
vec3 positionWC,
|
|
17
|
+
vec3 lightDirection,
|
|
18
|
+
vec3 rayleighColor,
|
|
19
|
+
vec3 mieColor,
|
|
20
|
+
float opacity
|
|
21
|
+
) {
|
|
22
|
+
// Setup the primary ray: from the camera position to the vertex position.
|
|
23
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
|
|
24
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
|
|
25
|
+
|
|
26
|
+
float cosAngle = dot(cameraToPositionWCDirection, lightDirection);
|
|
27
|
+
float cosAngleSq = cosAngle * cosAngle;
|
|
28
|
+
|
|
29
|
+
float G = czm_atmosphereMieAnisotropy;
|
|
30
|
+
float GSq = G * G;
|
|
31
|
+
|
|
32
|
+
// The Rayleigh phase function.
|
|
33
|
+
float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
|
|
34
|
+
// The Mie phase function.
|
|
35
|
+
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));
|
|
36
|
+
|
|
37
|
+
// The final color is generated by combining the effects of the Rayleigh and Mie scattering.
|
|
38
|
+
vec3 rayleigh = rayleighPhase * rayleighColor;
|
|
39
|
+
vec3 mie = miePhase * mieColor;
|
|
40
|
+
|
|
41
|
+
vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
|
|
42
|
+
|
|
43
|
+
return vec4(color, opacity);
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/**\n\
|
|
3
|
+
* Compute the atmosphere color, applying Rayleigh and Mie scattering. This\n\
|
|
4
|
+
* builtin uses automatic uniforms so the atmophere settings are synced with the\n\
|
|
5
|
+
* state of the Scene, even in other contexts like Model.\n\
|
|
6
|
+
*\n\
|
|
7
|
+
* @name czm_computeAtmosphereColor\n\
|
|
8
|
+
* @glslFunction\n\
|
|
9
|
+
*\n\
|
|
10
|
+
* @param {vec3} positionWC Position of the fragment in world coords (low precision)\n\
|
|
11
|
+
* @param {vec3} lightDirection Light direction from the sun or other light source.\n\
|
|
12
|
+
* @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function\n\
|
|
13
|
+
* @param {vec3} mieColor The Mie scattering color computed by a scattering function\n\
|
|
14
|
+
* @param {float} opacity The opacity computed by a scattering function.\n\
|
|
15
|
+
*/\n\
|
|
16
|
+
vec4 czm_computeAtmosphereColor(\n\
|
|
17
|
+
vec3 positionWC,\n\
|
|
18
|
+
vec3 lightDirection,\n\
|
|
19
|
+
vec3 rayleighColor,\n\
|
|
20
|
+
vec3 mieColor,\n\
|
|
21
|
+
float opacity\n\
|
|
22
|
+
) {\n\
|
|
23
|
+
// Setup the primary ray: from the camera position to the vertex position.\n\
|
|
24
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;\n\
|
|
25
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);\n\
|
|
26
|
+
\n\
|
|
27
|
+
float cosAngle = dot(cameraToPositionWCDirection, lightDirection);\n\
|
|
28
|
+
float cosAngleSq = cosAngle * cosAngle;\n\
|
|
29
|
+
\n\
|
|
30
|
+
float G = czm_atmosphereMieAnisotropy;\n\
|
|
31
|
+
float GSq = G * G;\n\
|
|
32
|
+
\n\
|
|
33
|
+
// The Rayleigh phase function.\n\
|
|
34
|
+
float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);\n\
|
|
35
|
+
// The Mie phase function.\n\
|
|
36
|
+
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\
|
|
37
|
+
\n\
|
|
38
|
+
// The final color is generated by combining the effects of the Rayleigh and Mie scattering.\n\
|
|
39
|
+
vec3 rayleigh = rayleighPhase * rayleighColor;\n\
|
|
40
|
+
vec3 mie = miePhase * mieColor;\n\
|
|
41
|
+
\n\
|
|
42
|
+
vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;\n\
|
|
43
|
+
\n\
|
|
44
|
+
return vec4(color, opacity);\n\
|
|
45
|
+
}\n\
|
|
46
|
+
";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute atmosphere scattering for the ground atmosphere and fog. This method
|
|
3
|
+
* uses automatic uniforms so it is always synced with the scene settings.
|
|
4
|
+
*
|
|
5
|
+
* @name czm_computeGroundAtmosphereScattering
|
|
6
|
+
* @glslfunction
|
|
7
|
+
*
|
|
8
|
+
* @param {vec3} positionWC The position of the fragment in world coordinates.
|
|
9
|
+
* @param {vec3} lightDirection The direction of the light to calculate the scattering from.
|
|
10
|
+
* @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
|
|
11
|
+
* @param {vec3} mieColor The variable the Mie scattering will be written to.
|
|
12
|
+
* @param {float} opacity The variable the transmittance will be written to.
|
|
13
|
+
*/
|
|
14
|
+
void czm_computeGroundAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {
|
|
15
|
+
vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
|
|
16
|
+
vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
|
|
17
|
+
czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
|
|
18
|
+
|
|
19
|
+
float atmosphereInnerRadius = length(positionWC);
|
|
20
|
+
|
|
21
|
+
czm_computeScattering(
|
|
22
|
+
primaryRay,
|
|
23
|
+
length(cameraToPositionWC),
|
|
24
|
+
lightDirection,
|
|
25
|
+
atmosphereInnerRadius,
|
|
26
|
+
rayleighColor,
|
|
27
|
+
mieColor,
|
|
28
|
+
opacity
|
|
29
|
+
);
|
|
30
|
+
}
|