@cesium/engine 12.0.1 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/Workers/{chunk-7D6T2WYT.js → chunk-2ONAV62A.js} +14 -47
- package/Build/Workers/{chunk-MV7YO647.js → chunk-2SRHVCFD.js} +6 -6
- package/Build/Workers/{chunk-ZPTNVB3S.js → chunk-3SCCWLZS.js} +34 -8
- package/Build/Workers/{chunk-7CKQ7PVJ.js → chunk-54I6VSRP.js} +6 -6
- package/Build/Workers/{chunk-XDJ7V4NZ.js → chunk-5I3LPAS7.js} +5 -5
- package/Build/Workers/{chunk-GSJ6LWIS.js → chunk-5ICYLS6B.js} +35 -21
- package/Build/Workers/{chunk-BH5M522L.js → chunk-5JY4LYO3.js} +7 -7
- package/Build/Workers/{chunk-DR56WFYZ.js → chunk-APCS5YJI.js} +7 -7
- package/Build/Workers/{chunk-COHL4R3G.js → chunk-AXYZUG4N.js} +1 -1
- package/Build/Workers/{chunk-2IJZVFHY.js → chunk-B34JXFHF.js} +5 -5
- package/Build/Workers/{chunk-54NYY4U4.js → chunk-B6IJY6AN.js} +7 -7
- package/Build/Workers/{chunk-H3RMGG7L.js → chunk-BMFWWTD7.js} +5 -5
- package/Build/Workers/{chunk-PJHRB4YJ.js → chunk-CBE4HRBH.js} +7 -7
- package/Build/Workers/{chunk-U7SH6OK7.js → chunk-CNPP6TQ2.js} +4 -4
- package/Build/Workers/{chunk-2XOUWNPN.js → chunk-DWIKWWEE.js} +5 -5
- package/Build/Workers/{chunk-PNA47CR7.js → chunk-EHGQQA7C.js} +1 -1
- package/Build/Workers/{chunk-7EBHNJTG.js → chunk-EJ5DT5BP.js} +1 -1
- package/Build/Workers/{chunk-3Y4UGAYI.js → chunk-EYZFEJX3.js} +6 -6
- package/Build/Workers/{chunk-EMCXAVSG.js → chunk-FNCXBBCF.js} +2 -2
- package/Build/Workers/{chunk-NL73INJS.js → chunk-GIOZHX7U.js} +2 -2
- package/Build/Workers/{chunk-VHGI7D3P.js → chunk-GSLKQJM2.js} +10 -10
- package/Build/Workers/{chunk-647NL6VU.js → chunk-HI73PIPQ.js} +2 -2
- package/Build/Workers/{chunk-GRQQHWMD.js → chunk-IP7F2MVW.js} +7 -7
- package/Build/Workers/{chunk-LBNGHEJY.js → chunk-IXNXKVOB.js} +4 -4
- package/Build/Workers/{chunk-2F42VIW6.js → chunk-J7BMSSY7.js} +13 -13
- package/Build/Workers/{chunk-PH3T7LNP.js → chunk-K62EHZFT.js} +15 -15
- package/Build/Workers/{chunk-GBPW65E3.js → chunk-K6SQV4IS.js} +6 -6
- package/Build/Workers/{chunk-WMHJAREU.js → chunk-KO232FLP.js} +2 -2
- package/Build/Workers/{chunk-AER5CLXD.js → chunk-KRVALCCI.js} +5 -5
- package/Build/Workers/{chunk-22FZ334F.js → chunk-LFUFGHL3.js} +10 -10
- package/Build/Workers/{chunk-AGYO4ZSF.js → chunk-LQT2ZK7D.js} +17 -17
- package/Build/Workers/{chunk-KJ65M35B.js → chunk-M2AA2ARJ.js} +11 -11
- package/Build/Workers/{chunk-YT5PQMSP.js → chunk-MGABCOOH.js} +6 -6
- package/Build/Workers/{chunk-JPNFQRN7.js → chunk-NQDKNE7V.js} +13 -13
- package/Build/Workers/{chunk-IJWXYSFC.js → chunk-OARMSJUU.js} +2 -2
- package/Build/Workers/{chunk-K7QC3WDT.js → chunk-OGRXNUR2.js} +1 -1
- package/Build/Workers/{chunk-KKMH4BKN.js → chunk-OZTFRHA2.js} +6 -6
- package/Build/Workers/{chunk-DJ7K7EYK.js → chunk-PBJQFLKS.js} +11 -11
- package/Build/Workers/{chunk-ETXXXGMP.js → chunk-PM76TX2X.js} +6 -6
- package/Build/Workers/{chunk-PISTPJXS.js → chunk-PTFIVVLX.js} +12 -12
- package/Build/Workers/{chunk-VXVQITFC.js → chunk-R2KGFZBA.js} +13 -13
- package/Build/Workers/{chunk-VO4SXJXT.js → chunk-S3UM4OKP.js} +7 -7
- package/Build/Workers/{chunk-NELAPOO6.js → chunk-SAKQO5NX.js} +2 -2
- package/Build/Workers/{chunk-ENARO52I.js → chunk-T34EOLFR.js} +14 -14
- package/Build/Workers/{chunk-X6YBZOOA.js → chunk-THDHWSEJ.js} +4 -4
- package/Build/Workers/{chunk-LVHHB5T6.js → chunk-TOHDFUJM.js} +4 -4
- package/Build/Workers/{chunk-Q7IIOKAT.js → chunk-UBAHTE4Q.js} +1 -1
- package/Build/Workers/{chunk-IAX6MIST.js → chunk-WAJNX74N.js} +17 -17
- package/Build/Workers/{chunk-76KRKKEF.js → chunk-WE4KF4AM.js} +9 -9
- package/Build/Workers/{chunk-JAKTB6CE.js → chunk-WUIDEXAN.js} +7 -7
- package/Build/Workers/{chunk-IVCFTVYW.js → chunk-YVGU235V.js} +4 -4
- package/Build/Workers/{chunk-ZCCI55EY.js → chunk-ZWSWJYJP.js} +13 -13
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -32
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +20 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/BingMapsGeocoderService.js +2 -0
- package/Source/Core/Check.d.ts +2 -1
- package/Source/Core/GoogleGeocoderService.js +110 -0
- package/Source/Core/ITwinPlatform.js +324 -0
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocodeProviderType.js +33 -0
- package/Source/Core/IonGeocoderService.js +72 -0
- package/Source/Core/JulianDate.js +14 -7
- package/Source/Core/Rectangle.js +0 -20
- package/Source/Core/TrackingReferenceFrame.js +45 -0
- package/Source/Core/defined.d.ts +11 -0
- package/Source/DataSources/Entity.js +15 -1
- package/Source/DataSources/EntityView.js +55 -4
- package/Source/DataSources/ModelGraphics.js +23 -1
- package/Source/DataSources/ModelVisualizer.js +22 -1
- package/Source/DataSources/SampledProperty.js +24 -0
- package/Source/Renderer/ContextLimits.js +1 -1
- package/Source/Renderer/Texture.js +104 -92
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Cesium3DTileset.js +1 -1
- package/Source/Scene/Cesium3DTilesetStatistics.js +109 -42
- package/Source/Scene/DerivedCommand.js +109 -16
- package/Source/Scene/DynamicEnvironmentMapManager.js +202 -65
- package/Source/Scene/GltfTextureLoader.js +16 -1
- package/Source/Scene/ITwinData.js +208 -0
- package/Source/Scene/Label.js +17 -3
- package/Source/Scene/MetadataClassProperty.js +26 -0
- package/Source/Scene/MetadataPicking.js +108 -17
- package/Source/Scene/MetadataType.js +20 -0
- package/Source/Scene/Model/Extensions/Gpm/GltfMeshPrimitiveGpmLoader.js +6 -11
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/Model3DTileContent.js +23 -1
- package/Source/Scene/Model/ModelStatistics.js +33 -5
- package/Source/Scene/Model/PointCloudStylingPipelineStage.js +2 -1
- package/Source/Scene/PickedMetadataInfo.js +21 -3
- package/Source/Scene/Picking.js +7 -1
- package/Source/Scene/PostProcessStage.js +14 -17
- package/Source/Scene/PostProcessStageCollection.js +4 -16
- package/Source/Scene/PostProcessStageLibrary.js +13 -51
- package/Source/Scene/PropertyAttributeProperty.js +15 -3
- package/Source/Scene/PropertyTextureProperty.js +12 -0
- package/Source/Scene/Scene.js +17 -2
- package/Source/Scene/SkyBox.js +23 -4
- package/Source/Scene/UrlTemplateImageryProvider.js +5 -5
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +55 -16
- package/Source/Scene/getMetadataProperty.js +48 -0
- package/Source/Shaders/Builtin/Functions/reverseLogDepth.glsl +1 -1
- package/Source/Shaders/Builtin/Functions/reverseLogDepth.js +1 -1
- package/Source/Shaders/ConvolveSpecularMapFS.glsl +1 -1
- package/Source/Shaders/ConvolveSpecularMapFS.js +1 -1
- package/Source/Shaders/DepthPlaneVS.glsl +1 -1
- package/Source/Shaders/DepthPlaneVS.js +1 -1
- package/Source/Shaders/Model/ModelFS.glsl +7 -0
- package/Source/Shaders/Model/ModelFS.js +7 -0
- package/Source/Shaders/Model/ModelVS.glsl +9 -1
- package/Source/Shaders/Model/ModelVS.js +9 -1
- package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +66 -37
- package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +66 -37
- package/index.d.ts +295 -42
- package/index.js +67 -61
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import defined from "../Core/defined.js";
|
|
2
|
+
import Model3DTileContent from "./Model/Model3DTileContent.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @private
|
|
@@ -29,6 +30,7 @@ function Cesium3DTilesetStatistics() {
|
|
|
29
30
|
// Memory statistics
|
|
30
31
|
this.geometryByteLength = 0;
|
|
31
32
|
this.texturesByteLength = 0;
|
|
33
|
+
this.texturesReferenceCounterById = {};
|
|
32
34
|
this.batchTableByteLength = 0; // batch textures and any binary metadata properties not otherwise accounted for
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -45,61 +47,123 @@ Cesium3DTilesetStatistics.prototype.clear = function () {
|
|
|
45
47
|
this.numberOfTilesCulledWithChildrenUnion = 0;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Increment the counters for the points, triangles, and features
|
|
52
|
+
* that are currently selected for rendering.
|
|
53
|
+
*
|
|
54
|
+
* This will be called recursively for the given content and
|
|
55
|
+
* all its inner contents
|
|
56
|
+
*
|
|
57
|
+
* @param {Cesium3DTileContent} content
|
|
58
|
+
*/
|
|
59
|
+
Cesium3DTilesetStatistics.prototype.incrementSelectionCounts = function (
|
|
60
|
+
content,
|
|
61
|
+
) {
|
|
62
|
+
this.numberOfFeaturesSelected += content.featuresLength;
|
|
63
|
+
this.numberOfPointsSelected += content.pointsLength;
|
|
64
|
+
this.numberOfTrianglesSelected += content.trianglesLength;
|
|
65
|
+
|
|
66
|
+
// Recursive calls on all inner contents
|
|
49
67
|
const contents = content.innerContents;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
if (defined(contents)) {
|
|
69
|
+
const length = contents.length;
|
|
70
|
+
for (let i = 0; i < length; ++i) {
|
|
71
|
+
this.incrementSelectionCounts(contents[i]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
56
75
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Increment the counters for the number of features and points that
|
|
78
|
+
* are currently loaded, and the lengths (size in bytes) of the
|
|
79
|
+
* occupied memory.
|
|
80
|
+
*
|
|
81
|
+
* This will be called recursively for the given content and
|
|
82
|
+
* all its inner contents
|
|
83
|
+
*
|
|
84
|
+
* @param {Cesium3DTileContent} content
|
|
85
|
+
*/
|
|
86
|
+
Cesium3DTilesetStatistics.prototype.incrementLoadCounts = function (content) {
|
|
87
|
+
this.numberOfFeaturesLoaded += content.featuresLength;
|
|
88
|
+
this.numberOfPointsLoaded += content.pointsLength;
|
|
89
|
+
this.geometryByteLength += content.geometryByteLength;
|
|
90
|
+
this.batchTableByteLength += content.batchTableByteLength;
|
|
91
|
+
|
|
92
|
+
// When the content is not a `Model3DTileContent`, then its
|
|
93
|
+
// textures byte length is added directly
|
|
94
|
+
if (!(content instanceof Model3DTileContent)) {
|
|
95
|
+
this.texturesByteLength += content.texturesByteLength;
|
|
71
96
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
// When the content is a `Model3DTileContent`, then increment the
|
|
98
|
+
// reference counter for all its textures. The byte length of any
|
|
99
|
+
// newly tracked texture to the total textures byte length
|
|
100
|
+
const textureIds = content.getTextureIds();
|
|
101
|
+
for (const textureId of textureIds) {
|
|
102
|
+
const referenceCounter =
|
|
103
|
+
this.texturesReferenceCounterById[textureId] ?? 0;
|
|
104
|
+
if (referenceCounter === 0) {
|
|
105
|
+
const textureByteLength = content.getTextureByteLengthById(textureId);
|
|
106
|
+
this.texturesByteLength += textureByteLength;
|
|
107
|
+
}
|
|
108
|
+
this.texturesReferenceCounterById[textureId] = referenceCounter + 1;
|
|
109
|
+
}
|
|
81
110
|
}
|
|
82
111
|
|
|
112
|
+
// Recursive calls on all inner contents
|
|
113
|
+
const contents = content.innerContents;
|
|
83
114
|
if (defined(contents)) {
|
|
84
115
|
const length = contents.length;
|
|
85
116
|
for (let i = 0; i < length; ++i) {
|
|
86
|
-
|
|
117
|
+
this.incrementLoadCounts(contents[i]);
|
|
87
118
|
}
|
|
88
119
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
Cesium3DTilesetStatistics.prototype.incrementSelectionCounts = function (
|
|
92
|
-
content,
|
|
93
|
-
) {
|
|
94
|
-
updatePointAndFeatureCounts(this, content, false, false);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
Cesium3DTilesetStatistics.prototype.incrementLoadCounts = function (content) {
|
|
98
|
-
updatePointAndFeatureCounts(this, content, false, true);
|
|
99
120
|
};
|
|
100
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Decrement the counters for the number of features and points that
|
|
124
|
+
* are currently loaded, and the lengths (size in bytes) of the
|
|
125
|
+
* occupied memory.
|
|
126
|
+
*
|
|
127
|
+
* This will be called recursively for the given content and
|
|
128
|
+
* all its inner contents
|
|
129
|
+
*
|
|
130
|
+
* @param {Cesium3DTileContent} content
|
|
131
|
+
*/
|
|
101
132
|
Cesium3DTilesetStatistics.prototype.decrementLoadCounts = function (content) {
|
|
102
|
-
|
|
133
|
+
this.numberOfFeaturesLoaded -= content.featuresLength;
|
|
134
|
+
this.numberOfPointsLoaded -= content.pointsLength;
|
|
135
|
+
this.geometryByteLength -= content.geometryByteLength;
|
|
136
|
+
this.batchTableByteLength -= content.batchTableByteLength;
|
|
137
|
+
|
|
138
|
+
// When the content is not a `Model3DTileContent`, then its
|
|
139
|
+
// textures byte length is subtracted directly
|
|
140
|
+
if (!(content instanceof Model3DTileContent)) {
|
|
141
|
+
this.texturesByteLength -= content.texturesByteLength;
|
|
142
|
+
} else {
|
|
143
|
+
// When the content is a `Model3DTileContent`, then decrement the
|
|
144
|
+
// reference counter for all its textures. The byte length of any
|
|
145
|
+
// texture that is no longer references is subtracted from the
|
|
146
|
+
// total textures byte length
|
|
147
|
+
const textureIds = content.getTextureIds();
|
|
148
|
+
for (const textureId of textureIds) {
|
|
149
|
+
const referenceCounter = this.texturesReferenceCounterById[textureId];
|
|
150
|
+
if (referenceCounter === 1) {
|
|
151
|
+
delete this.texturesReferenceCounterById[textureId];
|
|
152
|
+
const textureByteLength = content.getTextureByteLengthById(textureId);
|
|
153
|
+
this.texturesByteLength -= textureByteLength;
|
|
154
|
+
} else {
|
|
155
|
+
this.texturesReferenceCounterById[textureId] = referenceCounter - 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Recursive calls on all inner contents
|
|
160
|
+
const contents = content.innerContents;
|
|
161
|
+
if (defined(contents)) {
|
|
162
|
+
const length = contents.length;
|
|
163
|
+
for (let i = 0; i < length; ++i) {
|
|
164
|
+
this.decrementLoadCounts(contents[i]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
103
167
|
};
|
|
104
168
|
|
|
105
169
|
Cesium3DTilesetStatistics.clone = function (statistics, result) {
|
|
@@ -124,6 +188,9 @@ Cesium3DTilesetStatistics.clone = function (statistics, result) {
|
|
|
124
188
|
statistics.numberOfTilesCulledWithChildrenUnion;
|
|
125
189
|
result.geometryByteLength = statistics.geometryByteLength;
|
|
126
190
|
result.texturesByteLength = statistics.texturesByteLength;
|
|
191
|
+
result.texturesReferenceCounterById = {
|
|
192
|
+
...statistics.texturesReferenceCounterById,
|
|
193
|
+
};
|
|
127
194
|
result.batchTableByteLength = statistics.batchTableByteLength;
|
|
128
195
|
};
|
|
129
196
|
export default Cesium3DTilesetStatistics;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MetadataComponentType } from "@cesium/engine";
|
|
1
2
|
import defined from "../Core/defined.js";
|
|
2
3
|
import DrawCommand from "../Renderer/DrawCommand.js";
|
|
3
4
|
import RenderState from "../Renderer/RenderState.js";
|
|
@@ -416,6 +417,98 @@ function getGlslType(classProperty) {
|
|
|
416
417
|
return `ivec${componentCount}`;
|
|
417
418
|
}
|
|
418
419
|
|
|
420
|
+
/**
|
|
421
|
+
* Returns a shader statement that applies the inverse of the
|
|
422
|
+
* value transform to the given value, based on the given offset
|
|
423
|
+
* and scale.
|
|
424
|
+
*
|
|
425
|
+
* @param {string} input The input value
|
|
426
|
+
* @param {string} offset The offset
|
|
427
|
+
* @param {string} scale The scale
|
|
428
|
+
* @returns {string} The statement
|
|
429
|
+
*/
|
|
430
|
+
function unapplyValueTransform(input, offset, scale) {
|
|
431
|
+
return `((${input} - float(${offset})) / float(${scale}))`;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Returns a shader statement that applies the inverse of the
|
|
436
|
+
* normalization, based on the given component type
|
|
437
|
+
*
|
|
438
|
+
* @param {string} input The input value
|
|
439
|
+
* @param {string} componentType The component type
|
|
440
|
+
* @returns {string} The statement
|
|
441
|
+
*/
|
|
442
|
+
function unnormalize(input, componentType) {
|
|
443
|
+
const max = MetadataComponentType.getMaximum(componentType);
|
|
444
|
+
return `(${input}) / float(${max})`;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Creates a shader statement that returns the value of the specified
|
|
449
|
+
* property, normalized to the range [0, 1].
|
|
450
|
+
*
|
|
451
|
+
* @param {MetadataClassProperty} classProperty The class property
|
|
452
|
+
* @param {object} metadataProperty The metadata property, either
|
|
453
|
+
* a `PropertyTextureProperty` or a `PropertyAttributeProperty`
|
|
454
|
+
* @returns {string} The string
|
|
455
|
+
*/
|
|
456
|
+
function getSourceValueStringScalar(classProperty, metadataProperty) {
|
|
457
|
+
let result = `float(value)`;
|
|
458
|
+
|
|
459
|
+
// The 'hasValueTransform' indicates whether the property
|
|
460
|
+
// (or its class property) did define an 'offset' or 'scale'.
|
|
461
|
+
// Even when they had not been defined in the JSON, they are
|
|
462
|
+
// defined in the object, with default values.
|
|
463
|
+
if (metadataProperty.hasValueTransform) {
|
|
464
|
+
const offset = metadataProperty.offset;
|
|
465
|
+
const scale = metadataProperty.scale;
|
|
466
|
+
result = unapplyValueTransform(result, offset, scale);
|
|
467
|
+
}
|
|
468
|
+
if (!classProperty.normalized) {
|
|
469
|
+
result = unnormalize(result, classProperty.componentType);
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Creates a shader statement that returns the value of the specified
|
|
476
|
+
* component of the given property, normalized to the range [0, 1].
|
|
477
|
+
*
|
|
478
|
+
* @param {MetadataClassProperty} classProperty The class property
|
|
479
|
+
* @param {object} metadataProperty The metadata property, either
|
|
480
|
+
* a `PropertyTextureProperty` or a `PropertyAttributeProperty`
|
|
481
|
+
* @param {string} componentName The name, in ["x", "y", "z", "w"]
|
|
482
|
+
* @returns {string} The string
|
|
483
|
+
*/
|
|
484
|
+
function getSourceValueStringComponent(
|
|
485
|
+
classProperty,
|
|
486
|
+
metadataProperty,
|
|
487
|
+
componentName,
|
|
488
|
+
) {
|
|
489
|
+
const valueString = `value.${componentName}`;
|
|
490
|
+
let result = `float(${valueString})`;
|
|
491
|
+
|
|
492
|
+
// The 'hasValueTransform' indicates whether the property
|
|
493
|
+
// (or its class property) did define an 'offset' or 'scale'.
|
|
494
|
+
// Even when they had not been defined in the JSON, they are
|
|
495
|
+
// defined in the object, with default values
|
|
496
|
+
// Note that in the 'PropertyTextureProperty' and the
|
|
497
|
+
// 'PropertyAttributeProperty', these values are
|
|
498
|
+
// stored as "object types" (like 'Cartesian2'), whereas
|
|
499
|
+
// in the 'MetadataClassProperty', they are stored as
|
|
500
|
+
// "array types", e.g. a `[number, number]`
|
|
501
|
+
if (metadataProperty.hasValueTransform) {
|
|
502
|
+
const offset = metadataProperty.offset[componentName];
|
|
503
|
+
const scale = metadataProperty.scale[componentName];
|
|
504
|
+
result = unapplyValueTransform(result, offset, scale);
|
|
505
|
+
}
|
|
506
|
+
if (!classProperty.normalized) {
|
|
507
|
+
result = unnormalize(result, classProperty.componentType);
|
|
508
|
+
}
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
|
|
419
512
|
/**
|
|
420
513
|
* Creates a new `ShaderProgram` from the given input that renders metadata
|
|
421
514
|
* values into the frame buffer, according to the given picked metadata info.
|
|
@@ -452,34 +545,34 @@ function getPickMetadataShaderProgram(
|
|
|
452
545
|
return shader;
|
|
453
546
|
}
|
|
454
547
|
|
|
548
|
+
const metadataProperty = pickedMetadataInfo.metadataProperty;
|
|
455
549
|
const classProperty = pickedMetadataInfo.classProperty;
|
|
456
550
|
const glslType = getGlslType(classProperty);
|
|
457
551
|
|
|
458
552
|
// Define the components that will go into the output `metadataValues`.
|
|
553
|
+
// This will be the 'color' that is written into the frame buffer,
|
|
554
|
+
// meaning that the values should be in [0.0, 1.0], and will become
|
|
555
|
+
// values in [0, 255] in the frame buffer.
|
|
459
556
|
// By default, all of them are 0.0.
|
|
460
557
|
const sourceValueStrings = ["0.0", "0.0", "0.0", "0.0"];
|
|
461
558
|
const componentCount = getComponentCount(classProperty);
|
|
462
559
|
if (componentCount === 1) {
|
|
463
|
-
// When the property is a scalar, store
|
|
464
|
-
// in `metadataValues.x`
|
|
465
|
-
sourceValueStrings[0] =
|
|
560
|
+
// When the property is a scalar, store the source value
|
|
561
|
+
// string directly in `metadataValues.x`
|
|
562
|
+
sourceValueStrings[0] = getSourceValueStringScalar(
|
|
563
|
+
classProperty,
|
|
564
|
+
metadataProperty,
|
|
565
|
+
);
|
|
466
566
|
} else {
|
|
467
567
|
// When the property is an array, store the array elements
|
|
468
568
|
// in `metadataValues.x/y/z/w`
|
|
469
|
-
const
|
|
470
|
-
for (let i = 0; i < componentCount; i++) {
|
|
471
|
-
const component = components[i];
|
|
472
|
-
const valueString = `value.${component}`;
|
|
473
|
-
sourceValueStrings[i] = `float(${valueString})`;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// Make sure that the `metadataValues` components are all in
|
|
478
|
-
// the range [0, 1] (which will result in RGBA components
|
|
479
|
-
// in [0, 255] during rendering)
|
|
480
|
-
if (!classProperty.normalized) {
|
|
569
|
+
const componentNames = ["x", "y", "z", "w"];
|
|
481
570
|
for (let i = 0; i < componentCount; i++) {
|
|
482
|
-
sourceValueStrings[i]
|
|
571
|
+
sourceValueStrings[i] = getSourceValueStringComponent(
|
|
572
|
+
classProperty,
|
|
573
|
+
metadataProperty,
|
|
574
|
+
componentNames[i],
|
|
575
|
+
);
|
|
483
576
|
}
|
|
484
577
|
}
|
|
485
578
|
|