@cesium/engine 17.0.0 → 18.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 +1 -1
- package/Build/Workers/{chunk-4TIR5UPL.js → chunk-2AXPWBJG.js} +1 -1
- package/Build/Workers/{chunk-CAKU6ZPR.js → chunk-2CAYUY2B.js} +8 -8
- package/Build/Workers/{chunk-PS3OKVOQ.js → chunk-2NKHPWDY.js} +12 -12
- package/Build/Workers/{chunk-VXAKU6EV.js → chunk-2QNKQVUT.js} +5 -5
- package/Build/Workers/{chunk-ZTBZMRQT.js → chunk-3RKVDGRF.js} +8 -8
- package/Build/Workers/{chunk-J2HTPGC7.js → chunk-4DSTDGY3.js} +2 -2
- package/Build/Workers/{chunk-P2N5IDWU.js → chunk-4MIY63FM.js} +13 -13
- package/Build/Workers/{chunk-XYGBWBD5.js → chunk-5OL6XFNS.js} +1 -1
- package/Build/Workers/{chunk-E7SMO47Q.js → chunk-5WVF4BK7.js} +5 -5
- package/Build/Workers/{chunk-SQKTLDSD.js → chunk-AEGAQ6FD.js} +12 -12
- package/Build/Workers/{chunk-4BGKMM7J.js → chunk-CES6DHHV.js} +1 -1
- package/Build/Workers/{chunk-MAIKDIBS.js → chunk-DINSLSJD.js} +6 -6
- package/Build/Workers/{chunk-G6JUXZUO.js → chunk-EHB2OCQX.js} +4 -4
- package/Build/Workers/{chunk-SSLK4U3V.js → chunk-EXEZHW3P.js} +4 -4
- package/Build/Workers/{chunk-236N6BJN.js → chunk-F4ZAKN4V.js} +2 -2
- package/Build/Workers/{chunk-HBNWBMAM.js → chunk-FPYBD2P5.js} +1 -1
- package/Build/Workers/{chunk-5PC577K7.js → chunk-GAUF4F5A.js} +16 -16
- package/Build/Workers/{chunk-YE6MDFDA.js → chunk-GM55YFOB.js} +14 -14
- package/Build/Workers/{chunk-HGEGZ67N.js → chunk-GS55WTRX.js} +6 -6
- package/Build/Workers/{chunk-LPGOAMYH.js → chunk-HQE7KSR4.js} +2 -2
- package/Build/Workers/{chunk-IFIS4CVK.js → chunk-HS76VTVY.js} +2 -2
- package/Build/Workers/{chunk-7IIMO7ZZ.js → chunk-I3BAKR4S.js} +16 -16
- package/Build/Workers/{chunk-PM4Q36WX.js → chunk-IWGMVQGG.js} +9 -9
- package/Build/Workers/{chunk-UFV3YUIN.js → chunk-IWZK2AIH.js} +5 -5
- package/Build/Workers/{chunk-QJTIOB2Z.js → chunk-J4MAVE6J.js} +6 -6
- package/Build/Workers/{chunk-RX65FA7X.js → chunk-JF4IYQYC.js} +7 -7
- package/Build/Workers/{chunk-7PHT4JHA.js → chunk-KGXTCGX3.js} +12 -12
- package/Build/Workers/{chunk-K5JTWJPE.js → chunk-KNA65INJ.js} +4 -4
- package/Build/Workers/{chunk-CBFJVM6I.js → chunk-LIPZUYNR.js} +11 -11
- package/Build/Workers/{chunk-C5DCX2YQ.js → chunk-LWJWWCZ4.js} +6 -6
- package/Build/Workers/{chunk-KE45DUDH.js → chunk-LZFUG3GO.js} +10 -10
- package/Build/Workers/{chunk-P57PR3WM.js → chunk-MFGVMUN3.js} +5 -5
- package/Build/Workers/{chunk-QUFN3GEO.js → chunk-NR7KSD56.js} +3 -3
- package/Build/Workers/{chunk-MS5NWDHH.js → chunk-NVJ5JRIM.js} +2 -2
- package/Build/Workers/{chunk-CQMXZF4A.js → chunk-NWSAYFZG.js} +6 -6
- package/Build/Workers/{chunk-5YEFZMMM.js → chunk-OATG6PKE.js} +12 -12
- package/Build/Workers/{chunk-UX5JWAC7.js → chunk-OIHAAHBK.js} +10 -10
- package/Build/Workers/{chunk-DRMXU674.js → chunk-QN7JEOQV.js} +5 -5
- package/Build/Workers/{chunk-77MDEA47.js → chunk-QUSP3NWA.js} +5 -5
- package/Build/Workers/{chunk-GO3RZX2R.js → chunk-RWFYLWSF.js} +9 -9
- package/Build/Workers/{chunk-UZ6KXWCA.js → chunk-SIOVJ4L5.js} +4 -4
- package/Build/Workers/{chunk-OBHLT34A.js → chunk-T6B6H3GR.js} +7 -7
- package/Build/Workers/{chunk-IKDQX7DY.js → chunk-UK33ZN4K.js} +4 -4
- package/Build/Workers/{chunk-2BJXFXD7.js → chunk-VGJSKEIB.js} +4 -4
- package/Build/Workers/{chunk-5RPUEFSA.js → chunk-W6CPO62M.js} +6 -6
- package/Build/Workers/{chunk-37PA7GZW.js → chunk-WGHUCZMX.js} +7 -7
- package/Build/Workers/{chunk-UC7KH56Y.js → chunk-WTFZHPUW.js} +5 -5
- package/Build/Workers/{chunk-NZSBSY5K.js → chunk-WYCR5DWQ.js} +2 -2
- package/Build/Workers/{chunk-WP3IJYLC.js → chunk-YV37YFUM.js} +9 -9
- package/Build/Workers/{chunk-LVGYWPEX.js → chunk-ZADJ6FRX.js} +4 -4
- package/Build/Workers/{chunk-CC2WKHIW.js → chunk-ZIP27IX6.js} +6 -6
- package/Build/Workers/combineGeometry.js +21 -21
- package/Build/Workers/createBoxGeometry.js +15 -15
- package/Build/Workers/createBoxOutlineGeometry.js +13 -13
- package/Build/Workers/createCircleGeometry.js +23 -23
- package/Build/Workers/createCircleOutlineGeometry.js +16 -16
- package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createCorridorGeometry.js +26 -26
- package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
- package/Build/Workers/createCylinderGeometry.js +17 -17
- package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
- package/Build/Workers/createEllipseGeometry.js +23 -23
- package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipsoidGeometry.js +16 -16
- package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
- package/Build/Workers/createFrustumGeometry.js +15 -15
- package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
- package/Build/Workers/createGeometry.js +21 -21
- package/Build/Workers/createGroundPolylineGeometry.js +19 -19
- package/Build/Workers/createPlaneGeometry.js +13 -13
- package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
- package/Build/Workers/createPolygonGeometry.js +29 -29
- package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
- package/Build/Workers/createPolylineGeometry.js +22 -22
- package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
- package/Build/Workers/createRectangleGeometry.js +24 -24
- package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
- package/Build/Workers/createSimplePolylineGeometry.js +20 -20
- package/Build/Workers/createSphereGeometry.js +16 -16
- package/Build/Workers/createSphereOutlineGeometry.js +15 -15
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
- package/Build/Workers/createVectorTileGeometries.js +21 -21
- package/Build/Workers/createVectorTilePoints.js +11 -11
- package/Build/Workers/createVectorTilePolygons.js +19 -19
- package/Build/Workers/createVectorTilePolylines.js +12 -12
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
- package/Build/Workers/createVerticesFromHeightmap.js +19 -19
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
- package/Build/Workers/createWallGeometry.js +21 -21
- package/Build/Workers/createWallOutlineGeometry.js +20 -20
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +25 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +36 -0
- package/Source/Renderer/Texture3D.js +568 -0
- package/Source/Renderer/createUniform.js +1 -0
- package/Source/Renderer/createUniformArray.js +1 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Cesium3DTileset.js +138 -0
- package/Source/Scene/GlobeSurfaceShaderSet.js +4 -5
- package/Source/Scene/ImageryLayer.js +19 -4
- package/Source/Scene/ImageryLayerCollection.js +3 -2
- package/Source/Scene/Model/CartesianRectangle.js +108 -0
- package/Source/Scene/Model/ImageryConfiguration.js +25 -0
- package/Source/Scene/Model/ImageryCoverage.js +488 -0
- package/Source/Scene/Model/ImageryFlags.js +31 -0
- package/Source/Scene/Model/ImageryInput.js +60 -0
- package/Source/Scene/Model/ImageryPipelineStage.js +1040 -0
- package/Source/Scene/Model/MappedPositions.js +84 -0
- package/Source/Scene/Model/Model.js +38 -0
- package/Source/Scene/Model/ModelImagery.js +403 -0
- package/Source/Scene/Model/ModelImageryMapping.js +489 -0
- package/Source/Scene/Model/ModelPrimitiveImagery.js +972 -0
- package/Source/Scene/Model/ModelReader.js +810 -0
- package/Source/Scene/Model/ModelRenderResources.js +13 -0
- package/Source/Scene/Model/ModelRuntimePrimitive.js +19 -0
- package/Source/Scene/Model/ModelSceneGraph.js +133 -27
- package/Source/Scene/Model/NodeRenderResources.js +10 -0
- package/Source/Scene/ModelComponents.js +10 -0
- package/Source/Scene/VoxelPrimitive.js +22 -37
- package/Source/Scene/VoxelRenderResources.js +1 -1
- package/Source/Scene/processVoxelProperties.js +41 -100
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.glsl +0 -1
- package/Source/Shaders/Builtin/Functions/windowToEyeCoordinates.js +0 -1
- package/Source/Shaders/GlobeFS.glsl +22 -0
- package/Source/Shaders/GlobeFS.js +22 -0
- package/Source/Shaders/Model/MaterialStageFS.glsl +4 -0
- package/Source/Shaders/Model/MaterialStageFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/Voxels/IntersectDepth.glsl +10 -3
- package/Source/Shaders/Voxels/IntersectDepth.js +10 -3
- package/Source/Shaders/Voxels/Intersection.glsl +1 -3
- package/Source/Shaders/Voxels/Intersection.js +1 -3
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -0
- package/Source/Shaders/Voxels/IntersectionUtils.js +1 -0
- package/Source/Shaders/Voxels/VoxelFS.glsl +37 -24
- package/Source/Shaders/Voxels/VoxelFS.js +37 -24
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/index.d.ts +50 -2
- package/index.js +100 -88
- package/package.json +3 -3
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import defined from "../../Core/defined.js";
|
|
2
|
+
import Rectangle from "../../Core/Rectangle.js";
|
|
3
|
+
|
|
4
|
+
import CartesianRectangle from "./CartesianRectangle.js";
|
|
5
|
+
|
|
6
|
+
const imageryBoundsScratch = new Rectangle();
|
|
7
|
+
const overlappedRectangleScratch = new Rectangle();
|
|
8
|
+
const clippedRectangleScratch = new Rectangle();
|
|
9
|
+
const nativeInputRectangleScratch = new Rectangle();
|
|
10
|
+
const nativeImageryBoundsScratch = new Rectangle();
|
|
11
|
+
const nativeClippedImageryBoundsScratch = new Rectangle();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A class containing information about a piece of imagery.
|
|
15
|
+
*
|
|
16
|
+
* This represents the result of computing the imagery tiles that
|
|
17
|
+
* are covered by a given <code>Rectangle</code> (and which part
|
|
18
|
+
* of that imagery is covered, in terms of texture coordinates).
|
|
19
|
+
*
|
|
20
|
+
* This class represents a plain structure, without member functions.
|
|
21
|
+
* Instances are created with the <code>createImageryCoverages</code>
|
|
22
|
+
* function.
|
|
23
|
+
*
|
|
24
|
+
* The instances are used by the <code>ModelPrimitiveImagery</code>, to
|
|
25
|
+
* represent the imagery tiles that are covered by the cartographic
|
|
26
|
+
* bounding rectangle of the primitive positions.
|
|
27
|
+
*
|
|
28
|
+
* Implementation note for ImageryCoverage:
|
|
29
|
+
*
|
|
30
|
+
* Some of the static functions in this class have been extracted from
|
|
31
|
+
* <code>ImageryLayer.prototype._createTileImagerySkeletons</code>
|
|
32
|
+
* See https://github.com/CesiumGS/cesium/blob/5eaa2280f495d8f300d9e1f0497118c97aec54c8/packages/engine/Source/Scene/ImageryLayer.js#L700
|
|
33
|
+
* An instance of this class roughly corresponds to the <code>TileImagery</code>
|
|
34
|
+
* that is created there.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
class ImageryCoverage {
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new instance.
|
|
41
|
+
*
|
|
42
|
+
* @param {number} x x-coordinate of the imagery tile
|
|
43
|
+
* @param {number} y y-coordinate of the imagery tile
|
|
44
|
+
* @param {number} level level of the imagery tile
|
|
45
|
+
* @param {CartesianRectangle} textureCoordinateRectangle The texture coordinate
|
|
46
|
+
* rectangle from the imagery tile that is covered
|
|
47
|
+
* @param {Imagery} imagery The imagery
|
|
48
|
+
*/
|
|
49
|
+
constructor(x, y, level, textureCoordinateRectangle, imagery) {
|
|
50
|
+
this._x = x;
|
|
51
|
+
this._y = y;
|
|
52
|
+
this._level = level;
|
|
53
|
+
this._textureCoordinateRectangle = textureCoordinateRectangle;
|
|
54
|
+
this._imagery = imagery;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The x-coordinate of the imagery tile, typically correlated with longitude
|
|
59
|
+
*
|
|
60
|
+
* @type {number}
|
|
61
|
+
* @readonly
|
|
62
|
+
*/
|
|
63
|
+
get x() {
|
|
64
|
+
return this._x;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The y-coordinate of the imagery tile, typically correlated with latitude
|
|
69
|
+
*
|
|
70
|
+
* @type {number}
|
|
71
|
+
* @readonly
|
|
72
|
+
*/
|
|
73
|
+
get y() {
|
|
74
|
+
return this._y;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The level of the imagery tile
|
|
79
|
+
*
|
|
80
|
+
* @type {number}
|
|
81
|
+
* @readonly
|
|
82
|
+
*/
|
|
83
|
+
get level() {
|
|
84
|
+
return this._level;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The texture coordinate range that is covered from the
|
|
89
|
+
* imagery tile.
|
|
90
|
+
*
|
|
91
|
+
* This is a <code>CartesianRectangle</code> that contains the
|
|
92
|
+
* (minU, minV, maxU, maxV) coordinate range.
|
|
93
|
+
*
|
|
94
|
+
* Clients may not modify the returned instance.
|
|
95
|
+
*
|
|
96
|
+
* @type {CartesianRectangle}
|
|
97
|
+
* @readonly
|
|
98
|
+
*/
|
|
99
|
+
get textureCoordinateRectangle() {
|
|
100
|
+
return this._textureCoordinateRectangle;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the imagery
|
|
105
|
+
*
|
|
106
|
+
* @type {Imagery}
|
|
107
|
+
* @readonly
|
|
108
|
+
*/
|
|
109
|
+
get imagery() {
|
|
110
|
+
return this._imagery;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Computes the <code>ImageryCoverage</code> objects that describe the imagery
|
|
115
|
+
* tiles and the respective texture coordinates that are covered by the given
|
|
116
|
+
* input rectangle in the given imagery data.
|
|
117
|
+
*
|
|
118
|
+
* The given imagery level will be clamped if necessary, to be in the valid
|
|
119
|
+
* range for the imagery provider of the given imagery layer.
|
|
120
|
+
*
|
|
121
|
+
* @param {Rectangle} inputRectangle The input rectangle (e.g. tile bounds)
|
|
122
|
+
* @param {ImageryLayer} imageryLayer The imagery layer
|
|
123
|
+
* @param {number} inputImageryLevel The level for which the imagery coverage
|
|
124
|
+
* should be computed.
|
|
125
|
+
* @returns {ImageryCoverage[]} The objects describing the covered imagery
|
|
126
|
+
* and the respective texture coordinates
|
|
127
|
+
*/
|
|
128
|
+
static createImageryCoverages(
|
|
129
|
+
inputRectangle,
|
|
130
|
+
imageryLayer,
|
|
131
|
+
inputImageryLevel,
|
|
132
|
+
) {
|
|
133
|
+
if (!imageryLayer.show) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const imageryProvider = imageryLayer.imageryProvider;
|
|
138
|
+
const imageryLevel = ImageryCoverage._clampImageryLevel(
|
|
139
|
+
imageryProvider,
|
|
140
|
+
inputImageryLevel,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// Compute the range, in integer coordinates, of imagery
|
|
144
|
+
// tiles that are covered by the input rectangle
|
|
145
|
+
const imageryBounds = Rectangle.intersection(
|
|
146
|
+
imageryProvider.rectangle,
|
|
147
|
+
imageryLayer.rectangle,
|
|
148
|
+
imageryBoundsScratch,
|
|
149
|
+
);
|
|
150
|
+
const imageryTilingScheme = imageryProvider.tilingScheme;
|
|
151
|
+
const imageryRange = ImageryCoverage._computeImageryRange(
|
|
152
|
+
inputRectangle,
|
|
153
|
+
imageryBounds,
|
|
154
|
+
imageryTilingScheme,
|
|
155
|
+
imageryLevel,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// Convert the input rectangle and the imagery bounds into
|
|
159
|
+
// the native coordinate system of the tiling scheme
|
|
160
|
+
const nativeInputRectangle = nativeInputRectangleScratch;
|
|
161
|
+
imageryTilingScheme.rectangleToNativeRectangle(
|
|
162
|
+
inputRectangle,
|
|
163
|
+
nativeInputRectangle,
|
|
164
|
+
);
|
|
165
|
+
const nativeImageryBounds = nativeImageryBoundsScratch;
|
|
166
|
+
imageryTilingScheme.rectangleToNativeRectangle(
|
|
167
|
+
imageryBounds,
|
|
168
|
+
nativeImageryBounds,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
// A function that returns an imagery rectangle, based on (x, y, level),
|
|
172
|
+
// clipped to the imagery bounds (or undefined if there is no intersection
|
|
173
|
+
// between the imagery rectangle and the bounds)
|
|
174
|
+
const computeClippedImageryRectangle = (x, y, level) => {
|
|
175
|
+
const localImageryRectangle = imageryTilingScheme.tileXYToRectangle(
|
|
176
|
+
x,
|
|
177
|
+
y,
|
|
178
|
+
level,
|
|
179
|
+
);
|
|
180
|
+
const localClippedImageryRectangle = Rectangle.intersection(
|
|
181
|
+
localImageryRectangle,
|
|
182
|
+
imageryBounds,
|
|
183
|
+
clippedRectangleScratch,
|
|
184
|
+
);
|
|
185
|
+
if (!defined(localClippedImageryRectangle)) {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
const nativeClippedImageryBounds = nativeClippedImageryBoundsScratch;
|
|
189
|
+
imageryTilingScheme.rectangleToNativeRectangle(
|
|
190
|
+
localClippedImageryRectangle,
|
|
191
|
+
nativeClippedImageryBounds,
|
|
192
|
+
);
|
|
193
|
+
return nativeClippedImageryBounds;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const imageryCoverages = ImageryCoverage._computeImageryCoverages(
|
|
197
|
+
imageryLayer,
|
|
198
|
+
imageryRange,
|
|
199
|
+
imageryLevel,
|
|
200
|
+
nativeInputRectangle,
|
|
201
|
+
computeClippedImageryRectangle,
|
|
202
|
+
);
|
|
203
|
+
return imageryCoverages;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Validate the given imagery level against the constraints of the
|
|
208
|
+
* given imagery provider.
|
|
209
|
+
*
|
|
210
|
+
* This will clamp the given level to be in the range
|
|
211
|
+
* <code>[minimumLevel, maximumLevel)</code> that is
|
|
212
|
+
* defined by the given imagery provider (and cut off
|
|
213
|
+
* any fractional part that the input may have)
|
|
214
|
+
*
|
|
215
|
+
* @param {ImageryProvider} imageryProvider The imagery provider
|
|
216
|
+
* @param {number} imageryLevel The imagery level
|
|
217
|
+
* @returns {number} The validated level
|
|
218
|
+
*/
|
|
219
|
+
static _clampImageryLevel(imageryProvider, imageryLevel) {
|
|
220
|
+
const minimumLevel = imageryProvider.minimumLevel ?? 0;
|
|
221
|
+
const maximumLevel =
|
|
222
|
+
imageryProvider.maximumLevel ?? Number.POSITIVE_INFINITY;
|
|
223
|
+
const clampedImageryLevel = Math.min(
|
|
224
|
+
maximumLevel - 1,
|
|
225
|
+
Math.max(minimumLevel, imageryLevel),
|
|
226
|
+
);
|
|
227
|
+
const validImageryLevel = Math.floor(clampedImageryLevel);
|
|
228
|
+
return validImageryLevel;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Compute the rectangle describing the range of imagery that is covered
|
|
233
|
+
* with the given rectangle.
|
|
234
|
+
*
|
|
235
|
+
* This will compute a rectangle with integer coordinates that describe
|
|
236
|
+
* the X/Y coordinates of the imagery that is overlapped by the given
|
|
237
|
+
* input rectangle, based on the given imagery rectangle.
|
|
238
|
+
*
|
|
239
|
+
* Extracted from _createTileImagerySkeletons.
|
|
240
|
+
*
|
|
241
|
+
* @param {Rectangle} inputRectangle The input rectangle
|
|
242
|
+
* @param {Rectangle} imageryBounds The imagery bounds
|
|
243
|
+
* @param {TilingScheme} imageryTilingScheme The tiling scheme
|
|
244
|
+
* @param {number} imageryLevel The imagery level
|
|
245
|
+
* @returns {CartesianRectangle} The rectangle
|
|
246
|
+
*/
|
|
247
|
+
static _computeImageryRange(
|
|
248
|
+
inputRectangle,
|
|
249
|
+
imageryBounds,
|
|
250
|
+
imageryTilingScheme,
|
|
251
|
+
imageryLevel,
|
|
252
|
+
) {
|
|
253
|
+
const overlappedRectangle = ImageryCoverage._computeOverlappedRectangle(
|
|
254
|
+
inputRectangle,
|
|
255
|
+
imageryBounds,
|
|
256
|
+
);
|
|
257
|
+
const northwestTileCoordinates = imageryTilingScheme.positionToTileXY(
|
|
258
|
+
Rectangle.northwest(overlappedRectangle),
|
|
259
|
+
imageryLevel,
|
|
260
|
+
);
|
|
261
|
+
const southeastTileCoordinates = imageryTilingScheme.positionToTileXY(
|
|
262
|
+
Rectangle.southeast(overlappedRectangle),
|
|
263
|
+
imageryLevel,
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const result = new CartesianRectangle();
|
|
267
|
+
result.minX = northwestTileCoordinates.x;
|
|
268
|
+
result.minY = northwestTileCoordinates.y;
|
|
269
|
+
result.maxX = southeastTileCoordinates.x;
|
|
270
|
+
result.maxY = southeastTileCoordinates.y;
|
|
271
|
+
|
|
272
|
+
// As extracted from _createTileImagerySkeletons:
|
|
273
|
+
// If the southeast corner of the rectangle lies very close to the north or west side
|
|
274
|
+
// of the southeast tile, we don't actually need the southernmost or easternmost
|
|
275
|
+
// tiles.
|
|
276
|
+
// Similarly, if the northwest corner of the rectangle lies very close to the south or east side
|
|
277
|
+
// of the northwest tile, we don't actually need the northernmost or westernmost tiles.
|
|
278
|
+
// We define "very close" as being within 1/512 of the width of the tile.
|
|
279
|
+
const veryCloseX = inputRectangle.width / 512.0;
|
|
280
|
+
const veryCloseY = inputRectangle.height / 512.0;
|
|
281
|
+
|
|
282
|
+
const northwestTileRectangle = imageryTilingScheme.tileXYToRectangle(
|
|
283
|
+
result.minX,
|
|
284
|
+
result.minY,
|
|
285
|
+
imageryLevel,
|
|
286
|
+
);
|
|
287
|
+
const deltaNorth = Math.abs(
|
|
288
|
+
northwestTileRectangle.south - inputRectangle.north,
|
|
289
|
+
);
|
|
290
|
+
if (deltaNorth < veryCloseY && result.minY < result.maxY) {
|
|
291
|
+
++result.minY;
|
|
292
|
+
}
|
|
293
|
+
const deltaWest = Math.abs(
|
|
294
|
+
northwestTileRectangle.east - inputRectangle.west,
|
|
295
|
+
);
|
|
296
|
+
if (deltaWest < veryCloseX && result.minX < result.maxX) {
|
|
297
|
+
++result.minX;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const southeastTileRectangle = imageryTilingScheme.tileXYToRectangle(
|
|
301
|
+
result.maxX,
|
|
302
|
+
result.maxY,
|
|
303
|
+
imageryLevel,
|
|
304
|
+
);
|
|
305
|
+
const deltaSouth = Math.abs(
|
|
306
|
+
southeastTileRectangle.north - inputRectangle.south,
|
|
307
|
+
);
|
|
308
|
+
if (deltaSouth < veryCloseY && result.maxY > result.minY) {
|
|
309
|
+
--result.maxY;
|
|
310
|
+
}
|
|
311
|
+
const deltaEast = Math.abs(
|
|
312
|
+
southeastTileRectangle.west - inputRectangle.east,
|
|
313
|
+
);
|
|
314
|
+
if (deltaEast < veryCloseX && result.maxX > result.minX) {
|
|
315
|
+
--result.maxX;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Clamp the given input rectangle to the given clamp rectangle.
|
|
323
|
+
*
|
|
324
|
+
* If the input rectangle is completely above/below or left/right
|
|
325
|
+
* of the clamp rectangle, then the north/south or east/east
|
|
326
|
+
* if the clamp rectangle will be used in the result.
|
|
327
|
+
*
|
|
328
|
+
* @param {Rectangle} input The input rectangle
|
|
329
|
+
* @param {Rectangle} clamp The clamping rectangle
|
|
330
|
+
* @param {Rectangle} [result] The result
|
|
331
|
+
* @returns {Rectangle} The result
|
|
332
|
+
*/
|
|
333
|
+
static _clampRectangle(input, clamp, result) {
|
|
334
|
+
if (!defined(result)) {
|
|
335
|
+
result = new Rectangle();
|
|
336
|
+
}
|
|
337
|
+
if (input.south >= clamp.north) {
|
|
338
|
+
result.north = result.south = clamp.north;
|
|
339
|
+
} else if (input.north <= clamp.south) {
|
|
340
|
+
result.north = result.south = clamp.south;
|
|
341
|
+
} else {
|
|
342
|
+
result.south = Math.max(input.south, clamp.south);
|
|
343
|
+
result.north = Math.min(input.north, clamp.north);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (input.west >= clamp.east) {
|
|
347
|
+
result.west = result.east = clamp.east;
|
|
348
|
+
} else if (input.east <= clamp.west) {
|
|
349
|
+
result.west = result.east = clamp.west;
|
|
350
|
+
} else {
|
|
351
|
+
result.west = Math.max(input.west, clamp.west);
|
|
352
|
+
result.east = Math.min(input.east, clamp.east);
|
|
353
|
+
}
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Compute overlap between the given input rectangle, and the given
|
|
359
|
+
* bounds that have been obtained from the imagery provider.
|
|
360
|
+
*
|
|
361
|
+
* @param {Rectangle} inputRectangle The input
|
|
362
|
+
* @param {Rectangle} imageryBounds The imagery bounds
|
|
363
|
+
* @returns {Rectangle} The rectangle
|
|
364
|
+
*/
|
|
365
|
+
static _computeOverlappedRectangle(inputRectangle, imageryBounds) {
|
|
366
|
+
const overlappedRectangle = Rectangle.intersection(
|
|
367
|
+
inputRectangle,
|
|
368
|
+
imageryBounds,
|
|
369
|
+
overlappedRectangleScratch,
|
|
370
|
+
);
|
|
371
|
+
if (defined(overlappedRectangle)) {
|
|
372
|
+
return overlappedRectangle;
|
|
373
|
+
}
|
|
374
|
+
return ImageryCoverage._clampRectangle(
|
|
375
|
+
inputRectangle,
|
|
376
|
+
imageryBounds,
|
|
377
|
+
overlappedRectangleScratch,
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Computes the <code>ImageryCoverage</code> objects that describe the imagery and
|
|
383
|
+
* the texture coordinates that are contained in the given range of
|
|
384
|
+
* imagery tile coordinates, referring to the given input rectangle.
|
|
385
|
+
*
|
|
386
|
+
* @param {ImageryLayer} imageryLayer The imagery layer
|
|
387
|
+
* @param {CartesianRectangle} imageryRange The range of imagery tile coordinates
|
|
388
|
+
* @param {number} imageryLevel The imagery level
|
|
389
|
+
* @param {Rectangle} nativeInputRectangle The input rectangle, in coordinates
|
|
390
|
+
* that are native for the tiling scheme
|
|
391
|
+
* @param {Function} computeClippedImageryRectangle A function that returns
|
|
392
|
+
* an imagery rectangle, based on (x, y, level), clipped to the imagery bounds
|
|
393
|
+
* (or undefined if there is no intersection between the imagery rectangle
|
|
394
|
+
* and the bounds)
|
|
395
|
+
* @returns {ImageryCoverage[]} The objects describing the covered imagery
|
|
396
|
+
* and the respective texture coordinates
|
|
397
|
+
*/
|
|
398
|
+
static _computeImageryCoverages(
|
|
399
|
+
imageryLayer,
|
|
400
|
+
imageryRange,
|
|
401
|
+
imageryLevel,
|
|
402
|
+
nativeInputRectangle,
|
|
403
|
+
computeClippedImageryRectangle,
|
|
404
|
+
) {
|
|
405
|
+
const imageryCoverages = [];
|
|
406
|
+
|
|
407
|
+
for (let i = imageryRange.minX; i <= imageryRange.maxX; i++) {
|
|
408
|
+
const clippedImageryRectangleU = computeClippedImageryRectangle(
|
|
409
|
+
i,
|
|
410
|
+
imageryRange.maxY,
|
|
411
|
+
imageryLevel,
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
if (!defined(clippedImageryRectangleU)) {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
for (let j = imageryRange.minY; j <= imageryRange.maxY; j++) {
|
|
419
|
+
const clippedImageryRectangleV = computeClippedImageryRectangle(
|
|
420
|
+
i,
|
|
421
|
+
j,
|
|
422
|
+
imageryLevel,
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
if (!defined(clippedImageryRectangleV)) {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const textureCoordinateRectangle =
|
|
430
|
+
ImageryCoverage._localizeToCartesianRectangle(
|
|
431
|
+
clippedImageryRectangleV,
|
|
432
|
+
nativeInputRectangle,
|
|
433
|
+
undefined,
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
// Note: The getImageryFromCache function will create the whole "chain"
|
|
437
|
+
// of ancestor imageries, up to the root, and increases the reference
|
|
438
|
+
// counter for each of them, even though it is not called
|
|
439
|
+
// getImageryFromCacheAndCreateAllAncestorsAndAddReferences.
|
|
440
|
+
// There is currently no way to have a single imagery, because
|
|
441
|
+
// somewhere in TileImagery, the parent is assumed to be present.
|
|
442
|
+
const imagery = imageryLayer.getImageryFromCache(i, j, imageryLevel);
|
|
443
|
+
const imageryCoverage = new ImageryCoverage(
|
|
444
|
+
i,
|
|
445
|
+
j,
|
|
446
|
+
imageryLevel,
|
|
447
|
+
textureCoordinateRectangle,
|
|
448
|
+
imagery,
|
|
449
|
+
);
|
|
450
|
+
imageryCoverages.push(imageryCoverage);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return imageryCoverages;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Compute the coordinates of the first rectangle relative to the
|
|
458
|
+
* second rectangle.
|
|
459
|
+
*
|
|
460
|
+
* The result will describe the bounds of the first rectangle
|
|
461
|
+
* in coordinates that are relative to the (south,west) and
|
|
462
|
+
* (width, height) of the second rectangle. This is suitable
|
|
463
|
+
* for describing the texture coordinates of the first
|
|
464
|
+
* rectangle within the second one.
|
|
465
|
+
*
|
|
466
|
+
* The result will be stored in the given result parameter, or
|
|
467
|
+
* in a new rectangle if the result was undefined.
|
|
468
|
+
*
|
|
469
|
+
* @param {Rectangle} rectangleA The first rectangle
|
|
470
|
+
* @param {Rectangle} rectangleB The second rectangle
|
|
471
|
+
* @param {CartesianRectangle} [result] The result
|
|
472
|
+
* @returns {CartesianRectangle} The result
|
|
473
|
+
*/
|
|
474
|
+
static _localizeToCartesianRectangle(rectangleA, rectangleB, result) {
|
|
475
|
+
if (!defined(result)) {
|
|
476
|
+
result = new CartesianRectangle();
|
|
477
|
+
}
|
|
478
|
+
const invX = 1.0 / rectangleB.width;
|
|
479
|
+
const invY = 1.0 / rectangleB.height;
|
|
480
|
+
result.minX = (rectangleA.west - rectangleB.west) * invX;
|
|
481
|
+
result.minY = (rectangleA.south - rectangleB.south) * invY;
|
|
482
|
+
result.maxX = (rectangleA.east - rectangleB.west) * invX;
|
|
483
|
+
result.maxY = (rectangleA.north - rectangleB.south) * invY;
|
|
484
|
+
return result;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export default ImageryCoverage;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class containing a set of flags indicating which parts of an
|
|
3
|
+
* <code>ImageryLayer</code> need to be processed.
|
|
4
|
+
*
|
|
5
|
+
* This is used in the <code>ImageryPipelineStage</code> to decide the
|
|
6
|
+
* structure of the function that blends the imagery texture information
|
|
7
|
+
* with the previous pixels.
|
|
8
|
+
*
|
|
9
|
+
* Each flag indicates that at least one of the <code>ImageryLayer</code> objects
|
|
10
|
+
* that are part of the input did <b>not</b> have the default value that
|
|
11
|
+
* was defined via the corresponding <code>ImageryLayer.DEFAULT_...</code>>.
|
|
12
|
+
*
|
|
13
|
+
* Note that the type of the flags can be <code>boolean</code> or
|
|
14
|
+
* <code>number</code>. Users should check for these flags having
|
|
15
|
+
* a 'truthy' or 'falsy' value.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
class ImageryFlags {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.alpha = false;
|
|
22
|
+
this.brightness = false;
|
|
23
|
+
this.contrast = false;
|
|
24
|
+
this.hue = false;
|
|
25
|
+
this.saturation = false;
|
|
26
|
+
this.gamma = false;
|
|
27
|
+
this.colorToAlpha = false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default ImageryFlags;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A structure summarizing the input for the shader that is draping imagery
|
|
3
|
+
* over 3D Tiles, as part of the <code>ImageryPipelineStage</code>.
|
|
4
|
+
*
|
|
5
|
+
* The <code>ImageryPipelineStage</code> receives the primitive, and their
|
|
6
|
+
* <code>ModelPrimitiveImagery</code> objects. These objects provide the
|
|
7
|
+
* <code>ImageryCoverage</code> information, indicating the set of imagery
|
|
8
|
+
* tiles that are covered by the primitive.
|
|
9
|
+
*
|
|
10
|
+
* The <code>ImageryPipelineStage</code> uses the <code>ImageryCoverage</code>
|
|
11
|
+
* to fetch the <code>Imagery</code> object and its texture for the (x, y, level)
|
|
12
|
+
* of each coverage, computes the texture translation and scale, and the covered
|
|
13
|
+
* texture coordinate rectangle of that imagery texture.
|
|
14
|
+
*
|
|
15
|
+
* This information is summarized in an instance of this class, to later
|
|
16
|
+
* be passed to the shader via uniforms.
|
|
17
|
+
*
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
class ImageryInput {
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new instance
|
|
23
|
+
*
|
|
24
|
+
* @param {ImageryLayer} imageryLayer The imagery layer
|
|
25
|
+
* @param {Texture} texture The texture from the imagery
|
|
26
|
+
* @param {Cartesian4} textureTranslationAndScale The translation
|
|
27
|
+
* and scale that have to be applied to the texture, to properly
|
|
28
|
+
* be draped on the primitive. This is stored as a Cartesian4
|
|
29
|
+
* with (x,y) being the translation and (z,w) being the scale.
|
|
30
|
+
* It could be cleaner and clearer to store this as separate
|
|
31
|
+
* Cartesian2 objects, but using a single Cartesian4 probably
|
|
32
|
+
* was a design choice that was originally made in GlobeFS.glsl,
|
|
33
|
+
* with the goal to have fewer uniforms
|
|
34
|
+
* @param {Cartesian4} textureCoordinateRectangle The bounding
|
|
35
|
+
* rectangle (in texture coordinates). This directly corresponds
|
|
36
|
+
* to the <code>ImageryCoverage.textureCoordinateRectangle</code>,
|
|
37
|
+
* but converted into a Cartesian4 for the consumption in the
|
|
38
|
+
* shader
|
|
39
|
+
* @param {number} imageryTexCoordAttributeSetIndex The "set index"
|
|
40
|
+
* of the texture coordinate attribute that should be used. This
|
|
41
|
+
* will be used to access the texture coordinate attribute
|
|
42
|
+
* <code>a_imagery_texCoord_${imageryTexCoordAttributeSetIndex}</code>
|
|
43
|
+
* in the shader.
|
|
44
|
+
*/
|
|
45
|
+
constructor(
|
|
46
|
+
imageryLayer,
|
|
47
|
+
texture,
|
|
48
|
+
textureTranslationAndScale,
|
|
49
|
+
textureCoordinateRectangle,
|
|
50
|
+
imageryTexCoordAttributeSetIndex,
|
|
51
|
+
) {
|
|
52
|
+
this.imageryLayer = imageryLayer;
|
|
53
|
+
this.texture = texture;
|
|
54
|
+
this.textureTranslationAndScale = textureTranslationAndScale;
|
|
55
|
+
this.textureCoordinateRectangle = textureCoordinateRectangle;
|
|
56
|
+
this.imageryTexCoordAttributeSetIndex = imageryTexCoordAttributeSetIndex;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default ImageryInput;
|