@cesium/engine 26.0.0 → 26.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-EF2QYXGA.js → chunk-2EFYUSUY.js} +14 -14
- package/Build/Workers/{chunk-KFSTQKNM.js → chunk-5LSOO2KD.js} +7 -7
- package/Build/Workers/{chunk-VQYETPWC.js → chunk-6HK6IXK2.js} +4 -4
- package/Build/Workers/{chunk-AYKR4VBR.js → chunk-6YR6JBMY.js} +2 -2
- package/Build/Workers/{chunk-DOBXCNC3.js → chunk-76FDC45O.js} +13 -13
- package/Build/Workers/{chunk-54I6Y66F.js → chunk-7D2HZKH7.js} +6 -6
- package/Build/Workers/{chunk-4MGMYHOO.js → chunk-7KVKHY7O.js} +6 -6
- package/Build/Workers/{chunk-IRBKFCEJ.js → chunk-A3O6EDBK.js} +2 -2
- package/Build/Workers/{chunk-V7VQKN6N.js → chunk-A6X24AZI.js} +5 -5
- package/Build/Workers/{chunk-ZP7JMQV4.js → chunk-AHWAZRBV.js} +6 -2
- package/Build/Workers/{chunk-YLY7NKAB.js → chunk-B4CQSLZJ.js} +4 -4
- package/Build/Workers/{chunk-J6BWOHUF.js → chunk-C7JQVRLM.js} +3 -3
- package/Build/Workers/{chunk-KSSWJIZW.js → chunk-CDJDJ5LK.js} +2 -2
- package/Build/Workers/{chunk-G7PXZRVF.js → chunk-CEEZE3YZ.js} +7 -7
- package/Build/Workers/{chunk-INUEEEQA.js → chunk-CLCTQVVL.js} +8 -8
- package/Build/Workers/{chunk-O3EA5HS7.js → chunk-DBD5WWG2.js} +10 -10
- package/Build/Workers/{chunk-E7VQ76KE.js → chunk-DIGUUD6G.js} +6 -6
- package/Build/Workers/{chunk-424RNO3D.js → chunk-E7NZJOK7.js} +196 -22
- package/Build/Workers/{chunk-ACXQXN46.js → chunk-EHTS2YPT.js} +16 -16
- package/Build/Workers/{chunk-VWV2IJRB.js → chunk-ENNFMWDW.js} +11 -11
- package/Build/Workers/{chunk-FRQZECAO.js → chunk-FCP2QY4G.js} +5 -5
- package/Build/Workers/{chunk-ZZ46LWL6.js → chunk-FDK4K5IA.js} +1 -1
- package/Build/Workers/{chunk-C6KNZ7T4.js → chunk-FGQFQHN5.js} +17 -17
- package/Build/Workers/{chunk-MYP774IS.js → chunk-GSWMAFTE.js} +8 -8
- package/Build/Workers/{chunk-Y5BF6AFU.js → chunk-GXWQZBAI.js} +2 -2
- package/Build/Workers/{chunk-DDWSZVMY.js → chunk-HHV3MCGV.js} +5 -5
- package/Build/Workers/{chunk-52JDLOEM.js → chunk-HS6AD4P2.js} +14 -14
- package/Build/Workers/{chunk-Q3PY526V.js → chunk-IGAZBTFZ.js} +6 -6
- package/Build/Workers/{chunk-EBSIOBXY.js → chunk-ILME5BXA.js} +8 -8
- package/Build/Workers/{chunk-C6J67V5A.js → chunk-JKXV6PG5.js} +1 -1
- package/Build/Workers/{chunk-SMQZZOW6.js → chunk-JW6OZT4R.js} +10 -10
- package/Build/Workers/{chunk-F6QDY6HU.js → chunk-KGXSYGBG.js} +13 -13
- package/Build/Workers/{chunk-UOOIQ3KX.js → chunk-LD64RPYV.js} +12 -12
- package/Build/Workers/{chunk-CFQP6LYM.js → chunk-LGNDTZVX.js} +4 -4
- package/Build/Workers/{chunk-U3ZA64U7.js → chunk-LNSQVXFH.js} +2 -2
- package/Build/Workers/{chunk-TKKIREQ6.js → chunk-N7CCOFLX.js} +1 -1
- package/Build/Workers/{chunk-UA25D5MX.js → chunk-NIWITKQK.js} +10 -10
- package/Build/Workers/{chunk-KKOSKAZB.js → chunk-OBEU25PI.js} +17 -17
- package/Build/Workers/{chunk-M3B5JKSM.js → chunk-QVLAFFJY.js} +1 -1
- package/Build/Workers/{chunk-6YEE6JDR.js → chunk-R4FPNAZ2.js} +6 -6
- package/Build/Workers/{chunk-7J2HKPRH.js → chunk-RG4F5R57.js} +9 -9
- package/Build/Workers/{chunk-CXOYE2WM.js → chunk-SF6K72D7.js} +5 -5
- package/Build/Workers/{chunk-CZEYZU4N.js → chunk-SGRGNDOD.js} +10 -10
- package/Build/Workers/{chunk-DBOEKL43.js → chunk-SM2CDCYF.js} +7 -7
- package/Build/Workers/{chunk-Y57HREW5.js → chunk-SS5ABQGY.js} +4 -4
- package/Build/Workers/{chunk-QRWGUWI6.js → chunk-T5QBPLE3.js} +11 -11
- package/Build/Workers/{chunk-ZK3CF7ZD.js → chunk-TVZD72WJ.js} +12 -12
- package/Build/Workers/{chunk-IYOUHCZB.js → chunk-UEY73NRN.js} +1 -1
- package/Build/Workers/{chunk-7WM2PX4V.js → chunk-UVO6COT2.js} +5 -5
- package/Build/Workers/{chunk-P3CK7MCY.js → chunk-VAL7DYNR.js} +4 -4
- package/Build/Workers/{chunk-EPYXRCDB.js → chunk-WBSY7HDY.js} +12 -12
- package/Build/Workers/{chunk-4S7IE3LB.js → chunk-XDWCTQCZ.js} +2 -2
- package/Build/Workers/{chunk-QN67VG36.js → chunk-XLXSDIP5.js} +6 -6
- package/Build/Workers/{chunk-S4MCOY6I.js → chunk-XQ3SKCMM.js} +5 -5
- package/Build/Workers/{chunk-XZMBNNDX.js → chunk-YKU2Q3A2.js} +9 -9
- package/Build/Workers/{chunk-3VFEWOBI.js → chunk-ZMBHFYOX.js} +7 -7
- package/Build/Workers/{chunk-MPZHGZU6.js → chunk-ZSGUV73H.js} +4 -4
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +987 -2320
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/BoundingRectangle.js +6 -8
- package/Source/Core/Color.js +1 -0
- package/Source/Core/InterpolationAlgorithm.js +57 -50
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/TerrainMesh.js +3 -3
- package/Source/Core/TerrainPicker.js +1 -0
- package/Source/Core/writeTextToCanvas.js +1 -0
- package/Source/DataSources/CzmlDataSource.js +12 -0
- package/Source/DataSources/KmlDataSource.js +528 -555
- package/Source/DataSources/PathGraphics.js +8 -1
- package/Source/DataSources/PathMode.js +27 -0
- package/Source/DataSources/PathVisualizer.js +298 -1
- package/Source/Renderer/Texture.js +1 -1
- package/Source/Renderer/VertexArray.js +1 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/BillboardTexture.js +5 -3
- package/Source/Scene/Cesium3DTileOptimizations.js +4 -6
- package/Source/Scene/ClippingPlaneCollection.js +2 -2
- package/Source/Scene/ClippingPolygon.js +2 -0
- package/Source/Scene/ClippingPolygonCollection.js +2 -2
- package/Source/Scene/DerivedCommand.js +4 -0
- package/Source/Scene/Expression.js +6 -8
- package/Source/Scene/GlobeSurfaceShaderSet.js +501 -409
- package/Source/Scene/GlobeSurfaceTile.js +540 -401
- package/Source/Scene/GlobeSurfaceTileProvider.js +1259 -1146
- package/Source/Scene/GltfBufferViewLoader.js +3 -3
- package/Source/Scene/GltfLoader.js +1 -0
- package/Source/Scene/GltfLoaderUtil.js +20 -4
- package/Source/Scene/GltfPipeline/forEachTextureInMaterial.js +10 -0
- package/Source/Scene/GltfPipeline/removeUnusedElements.js +21 -11
- package/Source/Scene/ImageryLayer.js +2 -2
- package/Source/Scene/ImageryLayerCollection.js +2 -2
- package/Source/Scene/Material.js +1 -0
- package/Source/Scene/Model/Extensions/Gpm/GltfGpmLoader.js +4 -0
- package/Source/Scene/Model/Model.js +3 -0
- package/Source/Scene/Model/ModelUtility.js +1 -0
- package/Source/Scene/Picking.js +5 -0
- package/Source/Scene/PntsParser.js +1 -0
- package/Source/Scene/QuadtreePrimitive.js +3 -2
- package/Source/Scene/ResourceCacheKey.js +5 -5
- package/Source/Scene/Scene.js +1 -0
- package/Source/Scene/findMeshoptExtension.js +23 -0
- package/Source/Scene/renderBufferPointCollection.js +13 -8
- package/Source/Scene/renderBufferPolygonCollection.js +9 -13
- package/Source/Scene/renderBufferPolylineCollection.js +120 -192
- package/Source/Workers/decodeGoogleEarthEnterprisePacket.js +2 -2
- package/Source/Workers/incrementallyBuildTerrainPicker.js +2 -0
- package/index.d.ts +59 -254
- package/index.js +155 -153
- package/package.json +4 -4
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import defined from "../Core/defined.js";
|
|
2
4
|
import destroyObject from "../Core/destroyObject.js";
|
|
3
5
|
import TerrainQuantization from "../Core/TerrainQuantization.js";
|
|
@@ -5,37 +7,501 @@ import ShaderProgram from "../Renderer/ShaderProgram.js";
|
|
|
5
7
|
import getClippingFunction from "./getClippingFunction.js";
|
|
6
8
|
import SceneMode from "./SceneMode.js";
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
/** @import ClippingPlaneCollection from "./ClippingPlaneCollection.js"; */
|
|
11
|
+
/** @import ClippingPolygonCollection from "./ClippingPolygonCollection.js"; */
|
|
12
|
+
/** @import Context from "../Renderer/Context.js"; */
|
|
13
|
+
/** @import FrameState from "./FrameState.js"; */
|
|
14
|
+
/** @import GlobeSurfaceTile from "./GlobeSurfaceTile.js"; */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @ignore
|
|
18
|
+
*/
|
|
19
|
+
class GlobeSurfaceShader {
|
|
20
|
+
/**
|
|
21
|
+
* @param {number} numberOfDayTextures
|
|
22
|
+
* @param {number} flags
|
|
23
|
+
* @param {*} material
|
|
24
|
+
* @param {ShaderProgram} shaderProgram
|
|
25
|
+
* @param {number} clippingShaderState
|
|
26
|
+
* @param {number} clippingPolygonShaderState
|
|
27
|
+
*/
|
|
28
|
+
constructor(
|
|
29
|
+
numberOfDayTextures,
|
|
30
|
+
flags,
|
|
31
|
+
material,
|
|
32
|
+
shaderProgram,
|
|
33
|
+
clippingShaderState,
|
|
34
|
+
clippingPolygonShaderState,
|
|
35
|
+
) {
|
|
36
|
+
/** @type {number} */
|
|
37
|
+
this.numberOfDayTextures = numberOfDayTextures;
|
|
38
|
+
this.flags = flags;
|
|
39
|
+
this.material = material;
|
|
40
|
+
/** @type {ShaderProgram} */
|
|
41
|
+
this.shaderProgram = shaderProgram;
|
|
42
|
+
this.clippingShaderState = clippingShaderState;
|
|
43
|
+
this.clippingPolygonShaderState = clippingPolygonShaderState;
|
|
44
|
+
}
|
|
22
45
|
}
|
|
23
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {object} GlobeSurfaceShaderSetOptions
|
|
49
|
+
* @property {FrameState} [frameState]
|
|
50
|
+
* @property {GlobeSurfaceTile} [surfaceTile]
|
|
51
|
+
* @property {number} [numberOfDayTextures]
|
|
52
|
+
* @property {boolean} [applyBrightness]
|
|
53
|
+
* @property {boolean} [applyContrast]
|
|
54
|
+
* @property {boolean} [applyHue]
|
|
55
|
+
* @property {boolean} [applySaturation]
|
|
56
|
+
* @property {boolean} [applyGamma]
|
|
57
|
+
* @property {boolean} [applyAlpha]
|
|
58
|
+
* @property {boolean} [applyDayNightAlpha]
|
|
59
|
+
* @property {boolean} [applySplit]
|
|
60
|
+
* @property {boolean} [hasWaterMask]
|
|
61
|
+
* @property {boolean} [showReflectiveOcean]
|
|
62
|
+
* @property {boolean} [showOceanWaves]
|
|
63
|
+
* @property {boolean} [enableLighting]
|
|
64
|
+
* @property {boolean} [dynamicAtmosphereLighting]
|
|
65
|
+
* @property {boolean} [dynamicAtmosphereLightingFromSun]
|
|
66
|
+
* @property {boolean} [showGroundAtmosphere]
|
|
67
|
+
* @property {boolean} [perFragmentGroundAtmosphere]
|
|
68
|
+
* @property {boolean} [hasVertexNormals]
|
|
69
|
+
* @property {boolean} [useWebMercatorProjection]
|
|
70
|
+
* @property {boolean} [enableFog]
|
|
71
|
+
* @property {boolean} [enableClippingPlanes]
|
|
72
|
+
* @property {ClippingPlaneCollection} [clippingPlanes]
|
|
73
|
+
* @property {boolean} [enableClippingPolygons]
|
|
74
|
+
* @property {ClippingPolygonCollection} [clippingPolygons]
|
|
75
|
+
* @property {boolean} [clippedByBoundaries]
|
|
76
|
+
* @property {boolean} [hasImageryLayerCutout]
|
|
77
|
+
* @property {boolean} [colorCorrect]
|
|
78
|
+
* @property {boolean} [highlightFillTile]
|
|
79
|
+
* @property {boolean} [colorToAlpha]
|
|
80
|
+
* @property {boolean} [hasGeodeticSurfaceNormals]
|
|
81
|
+
* @property {boolean} [hasExaggeration]
|
|
82
|
+
* @property {boolean} [showUndergroundColor]
|
|
83
|
+
* @property {boolean} [translucent]
|
|
84
|
+
* @ignore
|
|
85
|
+
*/
|
|
86
|
+
|
|
24
87
|
/**
|
|
25
88
|
* Manages the shaders used to shade the surface of a {@link Globe}.
|
|
26
89
|
*
|
|
27
|
-
* @alias GlobeSurfaceShaderSet
|
|
28
90
|
* @private
|
|
29
91
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
92
|
+
class GlobeSurfaceShaderSet {
|
|
93
|
+
constructor() {
|
|
94
|
+
this.baseVertexShaderSource = undefined;
|
|
95
|
+
this.baseFragmentShaderSource = undefined;
|
|
33
96
|
|
|
34
|
-
|
|
97
|
+
/** @type {GlobeSurfaceShader[][]} */
|
|
98
|
+
this._shadersByTexturesFlags = [];
|
|
99
|
+
|
|
100
|
+
this.material = undefined;
|
|
101
|
+
}
|
|
35
102
|
|
|
36
|
-
|
|
103
|
+
/** @param {GlobeSurfaceShaderSetOptions} options */
|
|
104
|
+
getShaderProgram(options) {
|
|
105
|
+
const frameState = options.frameState;
|
|
106
|
+
const surfaceTile = options.surfaceTile;
|
|
107
|
+
const numberOfDayTextures = options.numberOfDayTextures;
|
|
108
|
+
const applyBrightness = options.applyBrightness;
|
|
109
|
+
const applyContrast = options.applyContrast;
|
|
110
|
+
const applyHue = options.applyHue;
|
|
111
|
+
const applySaturation = options.applySaturation;
|
|
112
|
+
const applyGamma = options.applyGamma;
|
|
113
|
+
const applyAlpha = options.applyAlpha;
|
|
114
|
+
const applyDayNightAlpha = options.applyDayNightAlpha;
|
|
115
|
+
const applySplit = options.applySplit;
|
|
116
|
+
const hasWaterMask = options.hasWaterMask;
|
|
117
|
+
const showReflectiveOcean = options.showReflectiveOcean;
|
|
118
|
+
const showOceanWaves = options.showOceanWaves;
|
|
119
|
+
const enableLighting = options.enableLighting;
|
|
120
|
+
const dynamicAtmosphereLighting = options.dynamicAtmosphereLighting;
|
|
121
|
+
const dynamicAtmosphereLightingFromSun =
|
|
122
|
+
options.dynamicAtmosphereLightingFromSun;
|
|
123
|
+
const showGroundAtmosphere = options.showGroundAtmosphere;
|
|
124
|
+
const perFragmentGroundAtmosphere = options.perFragmentGroundAtmosphere;
|
|
125
|
+
const hasVertexNormals = options.hasVertexNormals;
|
|
126
|
+
const useWebMercatorProjection = options.useWebMercatorProjection;
|
|
127
|
+
const enableFog = options.enableFog;
|
|
128
|
+
const enableClippingPlanes = options.enableClippingPlanes;
|
|
129
|
+
const clippingPlanes = options.clippingPlanes;
|
|
130
|
+
const enableClippingPolygons = options.enableClippingPolygons;
|
|
131
|
+
const clippingPolygons = options.clippingPolygons;
|
|
132
|
+
const clippedByBoundaries = options.clippedByBoundaries;
|
|
133
|
+
const hasImageryLayerCutout = options.hasImageryLayerCutout;
|
|
134
|
+
const colorCorrect = options.colorCorrect;
|
|
135
|
+
const highlightFillTile = options.highlightFillTile;
|
|
136
|
+
const colorToAlpha = options.colorToAlpha;
|
|
137
|
+
const hasGeodeticSurfaceNormals = options.hasGeodeticSurfaceNormals;
|
|
138
|
+
const hasExaggeration = options.hasExaggeration;
|
|
139
|
+
const showUndergroundColor = options.showUndergroundColor;
|
|
140
|
+
const translucent = options.translucent;
|
|
141
|
+
|
|
142
|
+
let quantization = 0;
|
|
143
|
+
let quantizationDefine = "";
|
|
144
|
+
|
|
145
|
+
const mesh = surfaceTile.renderedMesh;
|
|
146
|
+
const terrainEncoding = mesh.encoding;
|
|
147
|
+
const quantizationMode = terrainEncoding.quantization;
|
|
148
|
+
if (quantizationMode === TerrainQuantization.BITS12) {
|
|
149
|
+
quantization = 1;
|
|
150
|
+
quantizationDefine = "QUANTIZATION_BITS12";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let cartographicLimitRectangleFlag = 0;
|
|
154
|
+
let cartographicLimitRectangleDefine = "";
|
|
155
|
+
if (clippedByBoundaries) {
|
|
156
|
+
cartographicLimitRectangleFlag = 1;
|
|
157
|
+
cartographicLimitRectangleDefine = "TILE_LIMIT_RECTANGLE";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let imageryCutoutFlag = 0;
|
|
161
|
+
let imageryCutoutDefine = "";
|
|
162
|
+
if (hasImageryLayerCutout) {
|
|
163
|
+
imageryCutoutFlag = 1;
|
|
164
|
+
imageryCutoutDefine = "APPLY_IMAGERY_CUTOUT";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const sceneMode = frameState.mode;
|
|
168
|
+
// Bitwise OR uses 32-bit integers; bits 0-31 are packed below.
|
|
169
|
+
// Flags beyond bit 31 use arithmetic to avoid silent wrap-around
|
|
170
|
+
// (x << 32 === x << 0 in JavaScript).
|
|
171
|
+
const flags =
|
|
172
|
+
((sceneMode |
|
|
173
|
+
(+applyBrightness << 2) |
|
|
174
|
+
(+applyContrast << 3) |
|
|
175
|
+
(+applyHue << 4) |
|
|
176
|
+
(+applySaturation << 5) |
|
|
177
|
+
(+applyGamma << 6) |
|
|
178
|
+
(+applyAlpha << 7) |
|
|
179
|
+
(+hasWaterMask << 8) |
|
|
180
|
+
(+showReflectiveOcean << 9) |
|
|
181
|
+
(+showOceanWaves << 10) |
|
|
182
|
+
(+enableLighting << 11) |
|
|
183
|
+
(+dynamicAtmosphereLighting << 12) |
|
|
184
|
+
(+dynamicAtmosphereLightingFromSun << 13) |
|
|
185
|
+
(+showGroundAtmosphere << 14) |
|
|
186
|
+
(+perFragmentGroundAtmosphere << 15) |
|
|
187
|
+
(+hasVertexNormals << 16) |
|
|
188
|
+
(+useWebMercatorProjection << 17) |
|
|
189
|
+
(+enableFog << 18) |
|
|
190
|
+
(quantization << 19) |
|
|
191
|
+
(+applySplit << 20) |
|
|
192
|
+
(+enableClippingPlanes << 21) |
|
|
193
|
+
(+enableClippingPolygons << 22) |
|
|
194
|
+
(cartographicLimitRectangleFlag << 23) |
|
|
195
|
+
(imageryCutoutFlag << 24) |
|
|
196
|
+
(+colorCorrect << 25) |
|
|
197
|
+
(+highlightFillTile << 26) |
|
|
198
|
+
(+colorToAlpha << 27) |
|
|
199
|
+
(+hasGeodeticSurfaceNormals << 28) |
|
|
200
|
+
(+hasExaggeration << 29) |
|
|
201
|
+
(+showUndergroundColor << 30) |
|
|
202
|
+
(+translucent << 31)) >>>
|
|
203
|
+
0) +
|
|
204
|
+
(applyDayNightAlpha ? 0x100000000 : 0);
|
|
205
|
+
|
|
206
|
+
let currentClippingShaderState = 0;
|
|
207
|
+
// @ts-expect-error Missing types.
|
|
208
|
+
if (defined(clippingPlanes) && clippingPlanes.length > 0) {
|
|
209
|
+
currentClippingShaderState = enableClippingPlanes
|
|
210
|
+
? // @ts-expect-error Missing types.
|
|
211
|
+
clippingPlanes.clippingPlanesState
|
|
212
|
+
: 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let currentClippingPolygonsShaderState = 0;
|
|
216
|
+
// @ts-expect-error Missing types.
|
|
217
|
+
if (defined(clippingPolygons) && clippingPolygons.length > 0) {
|
|
218
|
+
currentClippingPolygonsShaderState = enableClippingPolygons
|
|
219
|
+
? // @ts-expect-error Missing types.
|
|
220
|
+
clippingPolygons.clippingPolygonsState
|
|
221
|
+
: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
let surfaceShader = surfaceTile.surfaceShader;
|
|
225
|
+
if (
|
|
226
|
+
defined(surfaceShader) &&
|
|
227
|
+
surfaceShader.numberOfDayTextures === numberOfDayTextures &&
|
|
228
|
+
surfaceShader.flags === flags &&
|
|
229
|
+
surfaceShader.material === this.material &&
|
|
230
|
+
surfaceShader.clippingShaderState === currentClippingShaderState &&
|
|
231
|
+
surfaceShader.clippingPolygonShaderState ===
|
|
232
|
+
currentClippingPolygonsShaderState
|
|
233
|
+
) {
|
|
234
|
+
return surfaceShader.shaderProgram;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// New tile, or tile changed number of textures, flags, or clipping planes
|
|
238
|
+
let shadersByFlags = this._shadersByTexturesFlags[numberOfDayTextures];
|
|
239
|
+
if (!defined(shadersByFlags)) {
|
|
240
|
+
shadersByFlags = this._shadersByTexturesFlags[numberOfDayTextures] = [];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
surfaceShader = shadersByFlags[flags];
|
|
244
|
+
if (
|
|
245
|
+
!defined(surfaceShader) ||
|
|
246
|
+
surfaceShader.material !== this.material ||
|
|
247
|
+
surfaceShader.clippingShaderState !== currentClippingShaderState ||
|
|
248
|
+
surfaceShader.clippingPolygonShaderState !==
|
|
249
|
+
currentClippingPolygonsShaderState
|
|
250
|
+
) {
|
|
251
|
+
// Cache miss - we've never seen this combination of numberOfDayTextures and flags before.
|
|
252
|
+
const vs = this.baseVertexShaderSource.clone();
|
|
253
|
+
const fs = this.baseFragmentShaderSource.clone();
|
|
254
|
+
|
|
255
|
+
// Need to go before GlobeFS
|
|
256
|
+
if (currentClippingShaderState !== 0) {
|
|
257
|
+
fs.sources.unshift(
|
|
258
|
+
getClippingFunction(clippingPlanes, frameState.context),
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Need to go before GlobeFS
|
|
263
|
+
if (currentClippingPolygonsShaderState !== 0) {
|
|
264
|
+
fs.sources.unshift(getPolygonClippingFunction(frameState.context));
|
|
265
|
+
vs.sources.unshift(getUnpackClippingFunction(frameState.context));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
vs.defines.push(quantizationDefine);
|
|
269
|
+
fs.defines.push(
|
|
270
|
+
`TEXTURE_UNITS ${numberOfDayTextures}`,
|
|
271
|
+
cartographicLimitRectangleDefine,
|
|
272
|
+
imageryCutoutDefine,
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
if (applyBrightness) {
|
|
276
|
+
fs.defines.push("APPLY_BRIGHTNESS");
|
|
277
|
+
}
|
|
278
|
+
if (applyContrast) {
|
|
279
|
+
fs.defines.push("APPLY_CONTRAST");
|
|
280
|
+
}
|
|
281
|
+
if (applyHue) {
|
|
282
|
+
fs.defines.push("APPLY_HUE");
|
|
283
|
+
}
|
|
284
|
+
if (applySaturation) {
|
|
285
|
+
fs.defines.push("APPLY_SATURATION");
|
|
286
|
+
}
|
|
287
|
+
if (applyGamma) {
|
|
288
|
+
fs.defines.push("APPLY_GAMMA");
|
|
289
|
+
}
|
|
290
|
+
if (applyAlpha) {
|
|
291
|
+
fs.defines.push("APPLY_ALPHA");
|
|
292
|
+
}
|
|
293
|
+
if (applyDayNightAlpha) {
|
|
294
|
+
fs.defines.push("APPLY_DAY_NIGHT_ALPHA");
|
|
295
|
+
}
|
|
296
|
+
if (hasWaterMask) {
|
|
297
|
+
fs.defines.push("HAS_WATER_MASK");
|
|
298
|
+
}
|
|
299
|
+
if (showReflectiveOcean) {
|
|
300
|
+
fs.defines.push("SHOW_REFLECTIVE_OCEAN");
|
|
301
|
+
vs.defines.push("SHOW_REFLECTIVE_OCEAN");
|
|
302
|
+
}
|
|
303
|
+
if (showOceanWaves) {
|
|
304
|
+
fs.defines.push("SHOW_OCEAN_WAVES");
|
|
305
|
+
}
|
|
306
|
+
if (colorToAlpha) {
|
|
307
|
+
fs.defines.push("APPLY_COLOR_TO_ALPHA");
|
|
308
|
+
}
|
|
309
|
+
if (showUndergroundColor) {
|
|
310
|
+
vs.defines.push("UNDERGROUND_COLOR");
|
|
311
|
+
fs.defines.push("UNDERGROUND_COLOR");
|
|
312
|
+
}
|
|
313
|
+
if (translucent) {
|
|
314
|
+
vs.defines.push("TRANSLUCENT");
|
|
315
|
+
fs.defines.push("TRANSLUCENT");
|
|
316
|
+
}
|
|
317
|
+
if (enableLighting) {
|
|
318
|
+
if (hasVertexNormals) {
|
|
319
|
+
vs.defines.push("ENABLE_VERTEX_LIGHTING");
|
|
320
|
+
fs.defines.push("ENABLE_VERTEX_LIGHTING");
|
|
321
|
+
} else {
|
|
322
|
+
vs.defines.push("ENABLE_DAYNIGHT_SHADING");
|
|
323
|
+
fs.defines.push("ENABLE_DAYNIGHT_SHADING");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (dynamicAtmosphereLighting) {
|
|
328
|
+
vs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING");
|
|
329
|
+
fs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING");
|
|
330
|
+
if (dynamicAtmosphereLightingFromSun) {
|
|
331
|
+
vs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN");
|
|
332
|
+
fs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN");
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (showGroundAtmosphere) {
|
|
337
|
+
vs.defines.push("GROUND_ATMOSPHERE");
|
|
338
|
+
fs.defines.push("GROUND_ATMOSPHERE");
|
|
339
|
+
if (perFragmentGroundAtmosphere) {
|
|
340
|
+
vs.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE");
|
|
341
|
+
fs.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE");
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
vs.defines.push("INCLUDE_WEB_MERCATOR_Y");
|
|
346
|
+
fs.defines.push("INCLUDE_WEB_MERCATOR_Y");
|
|
347
|
+
|
|
348
|
+
if (enableFog) {
|
|
349
|
+
vs.defines.push("FOG");
|
|
350
|
+
fs.defines.push("FOG");
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (applySplit) {
|
|
354
|
+
fs.defines.push("APPLY_SPLIT");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (enableClippingPlanes) {
|
|
358
|
+
fs.defines.push("ENABLE_CLIPPING_PLANES");
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (enableClippingPolygons) {
|
|
362
|
+
fs.defines.push("ENABLE_CLIPPING_POLYGONS");
|
|
363
|
+
vs.defines.push("ENABLE_CLIPPING_POLYGONS");
|
|
364
|
+
|
|
365
|
+
if (clippingPolygons.inverse) {
|
|
366
|
+
fs.defines.push("CLIPPING_INVERSE");
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
fs.defines.push(
|
|
370
|
+
// @ts-expect-error Missing types.
|
|
371
|
+
`CLIPPING_POLYGON_REGIONS_LENGTH ${clippingPolygons.extentsCount}`,
|
|
372
|
+
);
|
|
373
|
+
vs.defines.push(
|
|
374
|
+
// @ts-expect-error Missing types.
|
|
375
|
+
`CLIPPING_POLYGON_REGIONS_LENGTH ${clippingPolygons.extentsCount}`,
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (colorCorrect) {
|
|
380
|
+
fs.defines.push("COLOR_CORRECT");
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (highlightFillTile) {
|
|
384
|
+
fs.defines.push("HIGHLIGHT_FILL_TILE");
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (hasGeodeticSurfaceNormals) {
|
|
388
|
+
vs.defines.push("GEODETIC_SURFACE_NORMALS");
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (hasExaggeration) {
|
|
392
|
+
vs.defines.push("EXAGGERATION");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let computeDayColor =
|
|
396
|
+
"\
|
|
397
|
+
vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates, float nightBlend)\n\
|
|
398
|
+
{\n\
|
|
399
|
+
vec4 color = initialColor;\n";
|
|
400
|
+
|
|
401
|
+
if (hasImageryLayerCutout) {
|
|
402
|
+
computeDayColor +=
|
|
403
|
+
"\
|
|
404
|
+
vec4 cutoutAndColorResult;\n\
|
|
405
|
+
bool texelUnclipped;\n";
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
for (let i = 0; i < numberOfDayTextures; ++i) {
|
|
409
|
+
if (hasImageryLayerCutout) {
|
|
410
|
+
computeDayColor += `\
|
|
411
|
+
cutoutAndColorResult = u_dayTextureCutoutRectangles[${i}];\n\
|
|
412
|
+
texelUnclipped = v_textureCoordinates.x < cutoutAndColorResult.x || cutoutAndColorResult.z < v_textureCoordinates.x || v_textureCoordinates.y < cutoutAndColorResult.y || cutoutAndColorResult.w < v_textureCoordinates.y;\n\
|
|
413
|
+
cutoutAndColorResult = sampleAndBlend(\n`;
|
|
414
|
+
} else {
|
|
415
|
+
computeDayColor +=
|
|
416
|
+
"\
|
|
417
|
+
color = sampleAndBlend(\n";
|
|
418
|
+
}
|
|
419
|
+
computeDayColor += `\
|
|
420
|
+
color,\n\
|
|
421
|
+
u_dayTextures[${i}],\n\
|
|
422
|
+
u_dayTextureUseWebMercatorT[${i}] ? textureCoordinates.xz : textureCoordinates.xy,\n\
|
|
423
|
+
u_dayTextureTexCoordsRectangle[${i}],\n\
|
|
424
|
+
u_dayTextureTranslationAndScale[${i}],\n\
|
|
425
|
+
${applyAlpha ? `u_dayTextureAlpha[${i}]` : "1.0"},\n\
|
|
426
|
+
${applyDayNightAlpha ? `u_dayTextureNightAlpha[${i}]` : "1.0"},\n\
|
|
427
|
+
${applyDayNightAlpha ? `u_dayTextureDayAlpha[${i}]` : "1.0"},\n\
|
|
428
|
+
${applyBrightness ? `u_dayTextureBrightness[${i}]` : "0.0"},\n\
|
|
429
|
+
${applyContrast ? `u_dayTextureContrast[${i}]` : "0.0"},\n\
|
|
430
|
+
${applyHue ? `u_dayTextureHue[${i}]` : "0.0"},\n\
|
|
431
|
+
${applySaturation ? `u_dayTextureSaturation[${i}]` : "0.0"},\n\
|
|
432
|
+
${applyGamma ? `u_dayTextureOneOverGamma[${i}]` : "0.0"},\n\
|
|
433
|
+
${applySplit ? `u_dayTextureSplit[${i}]` : "0.0"},\n\
|
|
434
|
+
${colorToAlpha ? `u_colorsToAlpha[${i}]` : "vec4(0.0)"},\n\
|
|
435
|
+
nightBlend\);\n`;
|
|
436
|
+
if (hasImageryLayerCutout) {
|
|
437
|
+
computeDayColor +=
|
|
438
|
+
"\
|
|
439
|
+
color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);\n";
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
computeDayColor +=
|
|
444
|
+
"\
|
|
445
|
+
return color;\n\
|
|
446
|
+
}";
|
|
447
|
+
|
|
448
|
+
fs.sources.push(computeDayColor);
|
|
449
|
+
|
|
450
|
+
vs.sources.push(getPositionMode(sceneMode));
|
|
451
|
+
vs.sources.push(get2DYPositionFraction(useWebMercatorProjection));
|
|
452
|
+
|
|
453
|
+
const shader = ShaderProgram.fromCache({
|
|
454
|
+
context: frameState.context,
|
|
455
|
+
vertexShaderSource: vs,
|
|
456
|
+
fragmentShaderSource: fs,
|
|
457
|
+
attributeLocations: terrainEncoding.getAttributeLocations(),
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
surfaceShader = shadersByFlags[flags] = new GlobeSurfaceShader(
|
|
461
|
+
numberOfDayTextures,
|
|
462
|
+
flags,
|
|
463
|
+
this.material,
|
|
464
|
+
shader,
|
|
465
|
+
currentClippingShaderState,
|
|
466
|
+
currentClippingPolygonsShaderState,
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
surfaceTile.surfaceShader = surfaceShader;
|
|
471
|
+
return surfaceShader.shaderProgram;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
destroy() {
|
|
475
|
+
let flags;
|
|
476
|
+
let shader;
|
|
477
|
+
|
|
478
|
+
const shadersByTexturesFlags = this._shadersByTexturesFlags;
|
|
479
|
+
for (const textureCount in shadersByTexturesFlags) {
|
|
480
|
+
if (shadersByTexturesFlags.hasOwnProperty(textureCount)) {
|
|
481
|
+
const shadersByFlags = shadersByTexturesFlags[textureCount];
|
|
482
|
+
if (!defined(shadersByFlags)) {
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
for (flags in shadersByFlags) {
|
|
487
|
+
if (shadersByFlags.hasOwnProperty(flags)) {
|
|
488
|
+
shader = shadersByFlags[flags];
|
|
489
|
+
if (defined(shader)) {
|
|
490
|
+
shader.shaderProgram.destroy();
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return destroyObject(this);
|
|
498
|
+
}
|
|
37
499
|
}
|
|
38
500
|
|
|
501
|
+
/**
|
|
502
|
+
* @param {SceneMode} sceneMode
|
|
503
|
+
* @ignore
|
|
504
|
+
*/
|
|
39
505
|
function getPositionMode(sceneMode) {
|
|
40
506
|
const getPosition3DMode =
|
|
41
507
|
"vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPosition3DMode(position, height, textureCoordinates); }";
|
|
@@ -62,8 +528,13 @@ function getPositionMode(sceneMode) {
|
|
|
62
528
|
return positionMode;
|
|
63
529
|
}
|
|
64
530
|
|
|
531
|
+
/**
|
|
532
|
+
* @param {Context} context
|
|
533
|
+
* @ignore
|
|
534
|
+
*/
|
|
65
535
|
function getPolygonClippingFunction(context) {
|
|
66
536
|
// return a noop for webgl1
|
|
537
|
+
// @ts-expect-error Missing types.
|
|
67
538
|
if (!context.webgl2) {
|
|
68
539
|
return `void clipPolygons(highp sampler2D clippingDistance, int regionsLength, vec2 clippingPosition, int regionIndex) {
|
|
69
540
|
}`;
|
|
@@ -74,8 +545,13 @@ function getPolygonClippingFunction(context) {
|
|
|
74
545
|
}`;
|
|
75
546
|
}
|
|
76
547
|
|
|
548
|
+
/**
|
|
549
|
+
* @param {Context} context
|
|
550
|
+
* @ignore
|
|
551
|
+
*/
|
|
77
552
|
function getUnpackClippingFunction(context) {
|
|
78
553
|
// return a noop for webgl1
|
|
554
|
+
// @ts-expect-error Missing types.
|
|
79
555
|
if (!context.webgl2) {
|
|
80
556
|
return `vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) {
|
|
81
557
|
return vec4();
|
|
@@ -87,6 +563,11 @@ function getUnpackClippingFunction(context) {
|
|
|
87
563
|
}`;
|
|
88
564
|
}
|
|
89
565
|
|
|
566
|
+
/**
|
|
567
|
+
* @param {boolean} useWebMercatorProjection
|
|
568
|
+
* @returns {string}
|
|
569
|
+
* @ignore
|
|
570
|
+
*/
|
|
90
571
|
function get2DYPositionFraction(useWebMercatorProjection) {
|
|
91
572
|
const get2DYPositionFractionGeographicProjection =
|
|
92
573
|
"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }";
|
|
@@ -97,393 +578,4 @@ function get2DYPositionFraction(useWebMercatorProjection) {
|
|
|
97
578
|
: get2DYPositionFractionGeographicProjection;
|
|
98
579
|
}
|
|
99
580
|
|
|
100
|
-
GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
|
|
101
|
-
const frameState = options.frameState;
|
|
102
|
-
const surfaceTile = options.surfaceTile;
|
|
103
|
-
const numberOfDayTextures = options.numberOfDayTextures;
|
|
104
|
-
const applyBrightness = options.applyBrightness;
|
|
105
|
-
const applyContrast = options.applyContrast;
|
|
106
|
-
const applyHue = options.applyHue;
|
|
107
|
-
const applySaturation = options.applySaturation;
|
|
108
|
-
const applyGamma = options.applyGamma;
|
|
109
|
-
const applyAlpha = options.applyAlpha;
|
|
110
|
-
const applyDayNightAlpha = options.applyDayNightAlpha;
|
|
111
|
-
const applySplit = options.applySplit;
|
|
112
|
-
const hasWaterMask = options.hasWaterMask;
|
|
113
|
-
const showReflectiveOcean = options.showReflectiveOcean;
|
|
114
|
-
const showOceanWaves = options.showOceanWaves;
|
|
115
|
-
const enableLighting = options.enableLighting;
|
|
116
|
-
const dynamicAtmosphereLighting = options.dynamicAtmosphereLighting;
|
|
117
|
-
const dynamicAtmosphereLightingFromSun =
|
|
118
|
-
options.dynamicAtmosphereLightingFromSun;
|
|
119
|
-
const showGroundAtmosphere = options.showGroundAtmosphere;
|
|
120
|
-
const perFragmentGroundAtmosphere = options.perFragmentGroundAtmosphere;
|
|
121
|
-
const hasVertexNormals = options.hasVertexNormals;
|
|
122
|
-
const useWebMercatorProjection = options.useWebMercatorProjection;
|
|
123
|
-
const enableFog = options.enableFog;
|
|
124
|
-
const enableClippingPlanes = options.enableClippingPlanes;
|
|
125
|
-
const clippingPlanes = options.clippingPlanes;
|
|
126
|
-
const enableClippingPolygons = options.enableClippingPolygons;
|
|
127
|
-
const clippingPolygons = options.clippingPolygons;
|
|
128
|
-
const clippedByBoundaries = options.clippedByBoundaries;
|
|
129
|
-
const hasImageryLayerCutout = options.hasImageryLayerCutout;
|
|
130
|
-
const colorCorrect = options.colorCorrect;
|
|
131
|
-
const highlightFillTile = options.highlightFillTile;
|
|
132
|
-
const colorToAlpha = options.colorToAlpha;
|
|
133
|
-
const hasGeodeticSurfaceNormals = options.hasGeodeticSurfaceNormals;
|
|
134
|
-
const hasExaggeration = options.hasExaggeration;
|
|
135
|
-
const showUndergroundColor = options.showUndergroundColor;
|
|
136
|
-
const translucent = options.translucent;
|
|
137
|
-
|
|
138
|
-
let quantization = 0;
|
|
139
|
-
let quantizationDefine = "";
|
|
140
|
-
|
|
141
|
-
const mesh = surfaceTile.renderedMesh;
|
|
142
|
-
const terrainEncoding = mesh.encoding;
|
|
143
|
-
const quantizationMode = terrainEncoding.quantization;
|
|
144
|
-
if (quantizationMode === TerrainQuantization.BITS12) {
|
|
145
|
-
quantization = 1;
|
|
146
|
-
quantizationDefine = "QUANTIZATION_BITS12";
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
let cartographicLimitRectangleFlag = 0;
|
|
150
|
-
let cartographicLimitRectangleDefine = "";
|
|
151
|
-
if (clippedByBoundaries) {
|
|
152
|
-
cartographicLimitRectangleFlag = 1;
|
|
153
|
-
cartographicLimitRectangleDefine = "TILE_LIMIT_RECTANGLE";
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
let imageryCutoutFlag = 0;
|
|
157
|
-
let imageryCutoutDefine = "";
|
|
158
|
-
if (hasImageryLayerCutout) {
|
|
159
|
-
imageryCutoutFlag = 1;
|
|
160
|
-
imageryCutoutDefine = "APPLY_IMAGERY_CUTOUT";
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const sceneMode = frameState.mode;
|
|
164
|
-
// Bitwise OR uses 32-bit integers; bits 0-31 are packed below.
|
|
165
|
-
// Flags beyond bit 31 use arithmetic to avoid silent wrap-around
|
|
166
|
-
// (x << 32 === x << 0 in JavaScript).
|
|
167
|
-
const flags =
|
|
168
|
-
((sceneMode |
|
|
169
|
-
(applyBrightness << 2) |
|
|
170
|
-
(applyContrast << 3) |
|
|
171
|
-
(applyHue << 4) |
|
|
172
|
-
(applySaturation << 5) |
|
|
173
|
-
(applyGamma << 6) |
|
|
174
|
-
(applyAlpha << 7) |
|
|
175
|
-
(hasWaterMask << 8) |
|
|
176
|
-
(showReflectiveOcean << 9) |
|
|
177
|
-
(showOceanWaves << 10) |
|
|
178
|
-
(enableLighting << 11) |
|
|
179
|
-
(dynamicAtmosphereLighting << 12) |
|
|
180
|
-
(dynamicAtmosphereLightingFromSun << 13) |
|
|
181
|
-
(showGroundAtmosphere << 14) |
|
|
182
|
-
(perFragmentGroundAtmosphere << 15) |
|
|
183
|
-
(hasVertexNormals << 16) |
|
|
184
|
-
(useWebMercatorProjection << 17) |
|
|
185
|
-
(enableFog << 18) |
|
|
186
|
-
(quantization << 19) |
|
|
187
|
-
(applySplit << 20) |
|
|
188
|
-
(enableClippingPlanes << 21) |
|
|
189
|
-
(enableClippingPolygons << 22) |
|
|
190
|
-
(cartographicLimitRectangleFlag << 23) |
|
|
191
|
-
(imageryCutoutFlag << 24) |
|
|
192
|
-
(colorCorrect << 25) |
|
|
193
|
-
(highlightFillTile << 26) |
|
|
194
|
-
(colorToAlpha << 27) |
|
|
195
|
-
(hasGeodeticSurfaceNormals << 28) |
|
|
196
|
-
(hasExaggeration << 29) |
|
|
197
|
-
(showUndergroundColor << 30) |
|
|
198
|
-
(translucent << 31)) >>>
|
|
199
|
-
0) +
|
|
200
|
-
(applyDayNightAlpha ? 0x100000000 : 0);
|
|
201
|
-
|
|
202
|
-
let currentClippingShaderState = 0;
|
|
203
|
-
if (defined(clippingPlanes) && clippingPlanes.length > 0) {
|
|
204
|
-
currentClippingShaderState = enableClippingPlanes
|
|
205
|
-
? clippingPlanes.clippingPlanesState
|
|
206
|
-
: 0;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
let currentClippingPolygonsShaderState = 0;
|
|
210
|
-
if (defined(clippingPolygons) && clippingPolygons.length > 0) {
|
|
211
|
-
currentClippingPolygonsShaderState = enableClippingPolygons
|
|
212
|
-
? clippingPolygons.clippingPolygonsState
|
|
213
|
-
: 0;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
let surfaceShader = surfaceTile.surfaceShader;
|
|
217
|
-
if (
|
|
218
|
-
defined(surfaceShader) &&
|
|
219
|
-
surfaceShader.numberOfDayTextures === numberOfDayTextures &&
|
|
220
|
-
surfaceShader.flags === flags &&
|
|
221
|
-
surfaceShader.material === this.material &&
|
|
222
|
-
surfaceShader.clippingShaderState === currentClippingShaderState &&
|
|
223
|
-
surfaceShader.clippingPolygonShaderState ===
|
|
224
|
-
currentClippingPolygonsShaderState
|
|
225
|
-
) {
|
|
226
|
-
return surfaceShader.shaderProgram;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// New tile, or tile changed number of textures, flags, or clipping planes
|
|
230
|
-
let shadersByFlags = this._shadersByTexturesFlags[numberOfDayTextures];
|
|
231
|
-
if (!defined(shadersByFlags)) {
|
|
232
|
-
shadersByFlags = this._shadersByTexturesFlags[numberOfDayTextures] = [];
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
surfaceShader = shadersByFlags[flags];
|
|
236
|
-
if (
|
|
237
|
-
!defined(surfaceShader) ||
|
|
238
|
-
surfaceShader.material !== this.material ||
|
|
239
|
-
surfaceShader.clippingShaderState !== currentClippingShaderState ||
|
|
240
|
-
surfaceShader.clippingPolygonShaderState !==
|
|
241
|
-
currentClippingPolygonsShaderState
|
|
242
|
-
) {
|
|
243
|
-
// Cache miss - we've never seen this combination of numberOfDayTextures and flags before.
|
|
244
|
-
const vs = this.baseVertexShaderSource.clone();
|
|
245
|
-
const fs = this.baseFragmentShaderSource.clone();
|
|
246
|
-
|
|
247
|
-
// Need to go before GlobeFS
|
|
248
|
-
if (currentClippingShaderState !== 0) {
|
|
249
|
-
fs.sources.unshift(
|
|
250
|
-
getClippingFunction(clippingPlanes, frameState.context),
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Need to go before GlobeFS
|
|
255
|
-
if (currentClippingPolygonsShaderState !== 0) {
|
|
256
|
-
fs.sources.unshift(getPolygonClippingFunction(frameState.context));
|
|
257
|
-
vs.sources.unshift(getUnpackClippingFunction(frameState.context));
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
vs.defines.push(quantizationDefine);
|
|
261
|
-
fs.defines.push(
|
|
262
|
-
`TEXTURE_UNITS ${numberOfDayTextures}`,
|
|
263
|
-
cartographicLimitRectangleDefine,
|
|
264
|
-
imageryCutoutDefine,
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
if (applyBrightness) {
|
|
268
|
-
fs.defines.push("APPLY_BRIGHTNESS");
|
|
269
|
-
}
|
|
270
|
-
if (applyContrast) {
|
|
271
|
-
fs.defines.push("APPLY_CONTRAST");
|
|
272
|
-
}
|
|
273
|
-
if (applyHue) {
|
|
274
|
-
fs.defines.push("APPLY_HUE");
|
|
275
|
-
}
|
|
276
|
-
if (applySaturation) {
|
|
277
|
-
fs.defines.push("APPLY_SATURATION");
|
|
278
|
-
}
|
|
279
|
-
if (applyGamma) {
|
|
280
|
-
fs.defines.push("APPLY_GAMMA");
|
|
281
|
-
}
|
|
282
|
-
if (applyAlpha) {
|
|
283
|
-
fs.defines.push("APPLY_ALPHA");
|
|
284
|
-
}
|
|
285
|
-
if (applyDayNightAlpha) {
|
|
286
|
-
fs.defines.push("APPLY_DAY_NIGHT_ALPHA");
|
|
287
|
-
}
|
|
288
|
-
if (hasWaterMask) {
|
|
289
|
-
fs.defines.push("HAS_WATER_MASK");
|
|
290
|
-
}
|
|
291
|
-
if (showReflectiveOcean) {
|
|
292
|
-
fs.defines.push("SHOW_REFLECTIVE_OCEAN");
|
|
293
|
-
vs.defines.push("SHOW_REFLECTIVE_OCEAN");
|
|
294
|
-
}
|
|
295
|
-
if (showOceanWaves) {
|
|
296
|
-
fs.defines.push("SHOW_OCEAN_WAVES");
|
|
297
|
-
}
|
|
298
|
-
if (colorToAlpha) {
|
|
299
|
-
fs.defines.push("APPLY_COLOR_TO_ALPHA");
|
|
300
|
-
}
|
|
301
|
-
if (showUndergroundColor) {
|
|
302
|
-
vs.defines.push("UNDERGROUND_COLOR");
|
|
303
|
-
fs.defines.push("UNDERGROUND_COLOR");
|
|
304
|
-
}
|
|
305
|
-
if (translucent) {
|
|
306
|
-
vs.defines.push("TRANSLUCENT");
|
|
307
|
-
fs.defines.push("TRANSLUCENT");
|
|
308
|
-
}
|
|
309
|
-
if (enableLighting) {
|
|
310
|
-
if (hasVertexNormals) {
|
|
311
|
-
vs.defines.push("ENABLE_VERTEX_LIGHTING");
|
|
312
|
-
fs.defines.push("ENABLE_VERTEX_LIGHTING");
|
|
313
|
-
} else {
|
|
314
|
-
vs.defines.push("ENABLE_DAYNIGHT_SHADING");
|
|
315
|
-
fs.defines.push("ENABLE_DAYNIGHT_SHADING");
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (dynamicAtmosphereLighting) {
|
|
320
|
-
vs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING");
|
|
321
|
-
fs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING");
|
|
322
|
-
if (dynamicAtmosphereLightingFromSun) {
|
|
323
|
-
vs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN");
|
|
324
|
-
fs.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN");
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (showGroundAtmosphere) {
|
|
329
|
-
vs.defines.push("GROUND_ATMOSPHERE");
|
|
330
|
-
fs.defines.push("GROUND_ATMOSPHERE");
|
|
331
|
-
if (perFragmentGroundAtmosphere) {
|
|
332
|
-
vs.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE");
|
|
333
|
-
fs.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE");
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
vs.defines.push("INCLUDE_WEB_MERCATOR_Y");
|
|
338
|
-
fs.defines.push("INCLUDE_WEB_MERCATOR_Y");
|
|
339
|
-
|
|
340
|
-
if (enableFog) {
|
|
341
|
-
vs.defines.push("FOG");
|
|
342
|
-
fs.defines.push("FOG");
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (applySplit) {
|
|
346
|
-
fs.defines.push("APPLY_SPLIT");
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (enableClippingPlanes) {
|
|
350
|
-
fs.defines.push("ENABLE_CLIPPING_PLANES");
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (enableClippingPolygons) {
|
|
354
|
-
fs.defines.push("ENABLE_CLIPPING_POLYGONS");
|
|
355
|
-
vs.defines.push("ENABLE_CLIPPING_POLYGONS");
|
|
356
|
-
|
|
357
|
-
if (clippingPolygons.inverse) {
|
|
358
|
-
fs.defines.push("CLIPPING_INVERSE");
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
fs.defines.push(
|
|
362
|
-
`CLIPPING_POLYGON_REGIONS_LENGTH ${clippingPolygons.extentsCount}`,
|
|
363
|
-
);
|
|
364
|
-
vs.defines.push(
|
|
365
|
-
`CLIPPING_POLYGON_REGIONS_LENGTH ${clippingPolygons.extentsCount}`,
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (colorCorrect) {
|
|
370
|
-
fs.defines.push("COLOR_CORRECT");
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if (highlightFillTile) {
|
|
374
|
-
fs.defines.push("HIGHLIGHT_FILL_TILE");
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (hasGeodeticSurfaceNormals) {
|
|
378
|
-
vs.defines.push("GEODETIC_SURFACE_NORMALS");
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (hasExaggeration) {
|
|
382
|
-
vs.defines.push("EXAGGERATION");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
let computeDayColor =
|
|
386
|
-
"\
|
|
387
|
-
vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates, float nightBlend)\n\
|
|
388
|
-
{\n\
|
|
389
|
-
vec4 color = initialColor;\n";
|
|
390
|
-
|
|
391
|
-
if (hasImageryLayerCutout) {
|
|
392
|
-
computeDayColor +=
|
|
393
|
-
"\
|
|
394
|
-
vec4 cutoutAndColorResult;\n\
|
|
395
|
-
bool texelUnclipped;\n";
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
for (let i = 0; i < numberOfDayTextures; ++i) {
|
|
399
|
-
if (hasImageryLayerCutout) {
|
|
400
|
-
computeDayColor += `\
|
|
401
|
-
cutoutAndColorResult = u_dayTextureCutoutRectangles[${i}];\n\
|
|
402
|
-
texelUnclipped = v_textureCoordinates.x < cutoutAndColorResult.x || cutoutAndColorResult.z < v_textureCoordinates.x || v_textureCoordinates.y < cutoutAndColorResult.y || cutoutAndColorResult.w < v_textureCoordinates.y;\n\
|
|
403
|
-
cutoutAndColorResult = sampleAndBlend(\n`;
|
|
404
|
-
} else {
|
|
405
|
-
computeDayColor +=
|
|
406
|
-
"\
|
|
407
|
-
color = sampleAndBlend(\n";
|
|
408
|
-
}
|
|
409
|
-
computeDayColor += `\
|
|
410
|
-
color,\n\
|
|
411
|
-
u_dayTextures[${i}],\n\
|
|
412
|
-
u_dayTextureUseWebMercatorT[${i}] ? textureCoordinates.xz : textureCoordinates.xy,\n\
|
|
413
|
-
u_dayTextureTexCoordsRectangle[${i}],\n\
|
|
414
|
-
u_dayTextureTranslationAndScale[${i}],\n\
|
|
415
|
-
${applyAlpha ? `u_dayTextureAlpha[${i}]` : "1.0"},\n\
|
|
416
|
-
${applyDayNightAlpha ? `u_dayTextureNightAlpha[${i}]` : "1.0"},\n\
|
|
417
|
-
${applyDayNightAlpha ? `u_dayTextureDayAlpha[${i}]` : "1.0"},\n\
|
|
418
|
-
${applyBrightness ? `u_dayTextureBrightness[${i}]` : "0.0"},\n\
|
|
419
|
-
${applyContrast ? `u_dayTextureContrast[${i}]` : "0.0"},\n\
|
|
420
|
-
${applyHue ? `u_dayTextureHue[${i}]` : "0.0"},\n\
|
|
421
|
-
${applySaturation ? `u_dayTextureSaturation[${i}]` : "0.0"},\n\
|
|
422
|
-
${applyGamma ? `u_dayTextureOneOverGamma[${i}]` : "0.0"},\n\
|
|
423
|
-
${applySplit ? `u_dayTextureSplit[${i}]` : "0.0"},\n\
|
|
424
|
-
${colorToAlpha ? `u_colorsToAlpha[${i}]` : "vec4(0.0)"},\n\
|
|
425
|
-
nightBlend\);\n`;
|
|
426
|
-
if (hasImageryLayerCutout) {
|
|
427
|
-
computeDayColor +=
|
|
428
|
-
"\
|
|
429
|
-
color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);\n";
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
computeDayColor +=
|
|
434
|
-
"\
|
|
435
|
-
return color;\n\
|
|
436
|
-
}";
|
|
437
|
-
|
|
438
|
-
fs.sources.push(computeDayColor);
|
|
439
|
-
|
|
440
|
-
vs.sources.push(getPositionMode(sceneMode));
|
|
441
|
-
vs.sources.push(get2DYPositionFraction(useWebMercatorProjection));
|
|
442
|
-
|
|
443
|
-
const shader = ShaderProgram.fromCache({
|
|
444
|
-
context: frameState.context,
|
|
445
|
-
vertexShaderSource: vs,
|
|
446
|
-
fragmentShaderSource: fs,
|
|
447
|
-
attributeLocations: terrainEncoding.getAttributeLocations(),
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
surfaceShader = shadersByFlags[flags] = new GlobeSurfaceShader(
|
|
451
|
-
numberOfDayTextures,
|
|
452
|
-
flags,
|
|
453
|
-
this.material,
|
|
454
|
-
shader,
|
|
455
|
-
currentClippingShaderState,
|
|
456
|
-
currentClippingPolygonsShaderState,
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
surfaceTile.surfaceShader = surfaceShader;
|
|
461
|
-
return surfaceShader.shaderProgram;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
GlobeSurfaceShaderSet.prototype.destroy = function () {
|
|
465
|
-
let flags;
|
|
466
|
-
let shader;
|
|
467
|
-
|
|
468
|
-
const shadersByTexturesFlags = this._shadersByTexturesFlags;
|
|
469
|
-
for (const textureCount in shadersByTexturesFlags) {
|
|
470
|
-
if (shadersByTexturesFlags.hasOwnProperty(textureCount)) {
|
|
471
|
-
const shadersByFlags = shadersByTexturesFlags[textureCount];
|
|
472
|
-
if (!defined(shadersByFlags)) {
|
|
473
|
-
continue;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
for (flags in shadersByFlags) {
|
|
477
|
-
if (shadersByFlags.hasOwnProperty(flags)) {
|
|
478
|
-
shader = shadersByFlags[flags];
|
|
479
|
-
if (defined(shader)) {
|
|
480
|
-
shader.shaderProgram.destroy();
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
return destroyObject(this);
|
|
488
|
-
};
|
|
489
581
|
export default GlobeSurfaceShaderSet;
|