@cesium/engine 9.0.0 → 9.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/ThirdParty/Workers/z-worker-pako.js +6 -5
- package/Build/Workers/{chunk-ZNVSKMQ2.js → chunk-2CSEEWHN.js} +6 -6
- package/Build/Workers/{chunk-2ZBL3MVO.js → chunk-34DGOKCO.js} +10 -12
- package/Build/Workers/{chunk-QKBGRKKG.js → chunk-3RZK5NNV.js} +4 -4
- package/Build/Workers/{chunk-RV7ZOSS6.js → chunk-3S2MFY4B.js} +13 -13
- package/Build/Workers/{chunk-5TIV3L26.js → chunk-4AJGCQFX.js} +13 -13
- package/Build/Workers/{chunk-YV4H2Y7M.js → chunk-4KIUON73.js} +4 -4
- package/Build/Workers/{chunk-QCQUZGXI.js → chunk-4PHPQRSH.js} +4 -4
- package/Build/Workers/{chunk-HBQPB6IH.js → chunk-66E3H2KU.js} +12 -12
- package/Build/Workers/{chunk-TJBU6GML.js → chunk-6HCAQOVK.js} +6 -6
- package/Build/Workers/{chunk-VR5RBW52.js → chunk-7LPEGKOF.js} +7 -7
- package/Build/Workers/{chunk-MWV7IZK4.js → chunk-7VZNXIKG.js} +7 -7
- package/Build/Workers/{chunk-SE4PXOEA.js → chunk-A6NCZSL3.js} +19 -19
- package/Build/Workers/{chunk-Z7FQLK6N.js → chunk-AOFMPKUB.js} +4 -4
- package/Build/Workers/{chunk-73FKKY52.js → chunk-AOIKO5Y7.js} +5 -5
- package/Build/Workers/{chunk-YDVSBWEO.js → chunk-BDUJXBVF.js} +1 -1
- package/Build/Workers/{chunk-ADOVHYWO.js → chunk-C5CE4OG6.js} +469 -6
- package/Build/Workers/{chunk-LQJ5FFFR.js → chunk-CE6GTZ4I.js} +11 -13
- package/Build/Workers/{chunk-DGDUKCJJ.js → chunk-CYAJYEKW.js} +6 -6
- package/Build/Workers/{chunk-NP2GYYE5.js → chunk-FOZQIHZK.js} +6 -6
- package/Build/Workers/{chunk-L4BW3RUA.js → chunk-G7CJQKKD.js} +7 -7
- package/Build/Workers/{chunk-CO35JNNE.js → chunk-GIFJ77E4.js} +4 -4
- package/Build/Workers/{chunk-7COR472O.js → chunk-I5TDPPC4.js} +7197 -5096
- package/Build/Workers/{chunk-RMOEYCZW.js → chunk-IBXGK4WV.js} +2 -2
- package/Build/Workers/{chunk-GFA4SMXV.js → chunk-JI2445T5.js} +11 -11
- package/Build/Workers/{chunk-5R6VWLMH.js → chunk-KPY4F4BW.js} +6 -6
- package/Build/Workers/{chunk-C3XBUYBO.js → chunk-LVJCR7DH.js} +17 -17
- package/Build/Workers/{chunk-X2F6BEPY.js → chunk-LW7WGHEU.js} +16 -16
- package/Build/Workers/{chunk-BCU2LH5T.js → chunk-MWYZ64MH.js} +10 -10
- package/Build/Workers/chunk-NI2R52QD.js +961 -0
- package/Build/Workers/{chunk-I37B3MZ2.js → chunk-PEABJLCK.js} +1 -1
- package/Build/Workers/{chunk-P2YAAMT2.js → chunk-PK7TEP3J.js} +15 -15
- package/Build/Workers/{chunk-3NCVAGDA.js → chunk-POLFRINT.js} +14 -14
- package/Build/Workers/{chunk-E6WXPSJS.js → chunk-PS6AEMBR.js} +7 -7
- package/Build/Workers/{chunk-M2AYBTNH.js → chunk-PWF3YJJ5.js} +13 -13
- package/Build/Workers/{chunk-2632RVPI.js → chunk-QKF7XXEQ.js} +7 -7
- package/Build/Workers/{chunk-EOXYZ34O.js → chunk-RL73GOEF.js} +2 -2
- package/Build/Workers/{chunk-6WF3KIF5.js → chunk-RR7EOKGZ.js} +10 -10
- package/Build/Workers/{chunk-GXUXEOE2.js → chunk-S4XDCPKD.js} +1 -1
- package/Build/Workers/{chunk-NZWNZA6S.js → chunk-TMMOULW3.js} +5 -5
- package/Build/Workers/{chunk-SS4ESNE3.js → chunk-U4IMCOF5.js} +2 -2
- package/Build/Workers/{chunk-PXB7T27O.js → chunk-UAJEGIWA.js} +6 -6
- package/Build/Workers/{chunk-TZORKRNK.js → chunk-UCPPWV64.js} +1 -1
- package/Build/Workers/{chunk-EPKE7GE3.js → chunk-V7JB576Q.js} +5 -5
- package/Build/Workers/{chunk-DPUSFA7S.js → chunk-WEGCQ5DY.js} +6 -6
- package/Build/Workers/{chunk-N4KXMWQU.js → chunk-WFICTTOE.js} +2 -2
- package/Build/Workers/{chunk-P4XKB3QZ.js → chunk-WWP3I7R5.js} +5 -5
- package/Build/Workers/{chunk-WHUSTDIB.js → chunk-XHLDDE65.js} +10 -10
- package/Build/Workers/{chunk-24YTYWNB.js → chunk-XWML5Y7N.js} +11 -13
- package/Build/Workers/{chunk-C6OI26DR.js → chunk-YLZTCEBJ.js} +1 -1
- package/Build/Workers/{chunk-LAQP3SCC.js → chunk-ZC4AGBZK.js} +2 -2
- package/Build/Workers/{chunk-RSJXEO2A.js → chunk-ZDP32RQI.js} +2 -2
- package/Build/Workers/{chunk-ZYPTP7GS.js → chunk-ZWPIM77Q.js} +11 -11
- package/Build/Workers/combineGeometry.js +22 -24
- package/Build/Workers/createBoxGeometry.js +16 -18
- package/Build/Workers/createBoxOutlineGeometry.js +14 -16
- package/Build/Workers/createCircleGeometry.js +24 -26
- package/Build/Workers/createCircleOutlineGeometry.js +17 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -31
- package/Build/Workers/createCorridorGeometry.js +27 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -28
- package/Build/Workers/createCylinderGeometry.js +18 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -18
- package/Build/Workers/createEllipseGeometry.js +24 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -19
- package/Build/Workers/createEllipsoidGeometry.js +17 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -18
- package/Build/Workers/createFrustumGeometry.js +16 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -19
- package/Build/Workers/createGeometry.js +22 -24
- package/Build/Workers/createGroundPolylineGeometry.js +23 -25
- package/Build/Workers/createPlaneGeometry.js +14 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -15
- package/Build/Workers/createPolygonGeometry.js +32 -34
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -30
- package/Build/Workers/createPolylineGeometry.js +23 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -27
- package/Build/Workers/createRectangleGeometry.js +27 -29
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -20
- package/Build/Workers/createSimplePolylineGeometry.js +21 -23
- package/Build/Workers/createSphereGeometry.js +17 -19
- package/Build/Workers/createSphereOutlineGeometry.js +16 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -16
- package/Build/Workers/createVectorTileGeometries.js +22 -24
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -16
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -25
- package/Build/Workers/createVerticesFromHeightmap.js +23 -25
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -22
- package/Build/Workers/createWallGeometry.js +22 -24
- package/Build/Workers/createWallOutlineGeometry.js +21 -23
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -11
- package/Build/Workers/transcodeKTX2.js +8 -8
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -22
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +1 -0
- package/Source/Core/Rectangle.js +89 -0
- package/Source/DataSources/DataSourceDisplay.js +5 -0
- package/Source/Renderer/ShaderBuilder.js +6 -3
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +5 -3
- package/Source/Scene/Cesium3DTile.js +65 -0
- package/Source/Scene/Cesium3DTileset.js +48 -1
- package/Source/Scene/ClippingPolygon.js +212 -0
- package/Source/Scene/ClippingPolygonCollection.js +968 -0
- package/Source/Scene/Globe.js +14 -0
- package/Source/Scene/GlobeSurfaceShaderSet.js +81 -15
- package/Source/Scene/GlobeSurfaceTileProvider.js +81 -1
- package/Source/Scene/Model/Model.js +83 -0
- package/Source/Scene/Model/Model3DTileContent.js +21 -0
- package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +92 -0
- package/Source/Scene/Model/ModelSceneGraph.js +5 -0
- package/Source/Scene/Terrain.js +2 -2
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +37 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.js +39 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +14 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +15 -0
- package/Source/Shaders/GlobeFS.glsl +12 -0
- package/Source/Shaders/GlobeFS.js +12 -0
- package/Source/Shaders/GlobeVS.glsl +32 -0
- package/Source/Shaders/GlobeVS.js +32 -0
- package/Source/Shaders/Model/GeometryStageVS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageVS.js +1 -1
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +6 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +8 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +27 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +29 -0
- package/Source/Shaders/Model/ModelFS.glsl +6 -0
- package/Source/Shaders/Model/ModelFS.js +7 -1
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/PolygonSignedDistanceFS.glsl +100 -0
- package/Source/Shaders/PolygonSignedDistanceFS.js +101 -0
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/index.d.ts +227 -1
- package/index.js +34 -26
- package/package.json +1 -1
- package/Build/Workers/chunk-2KACWKS4.js +0 -501
- package/Build/Workers/chunk-2XPLH3JY.js +0 -2977
- package/Build/Workers/chunk-X6XOMPWL.js +0 -73
|
@@ -411,6 +411,16 @@ function Cesium3DTile(tileset, baseResource, header, parent) {
|
|
|
411
411
|
*/
|
|
412
412
|
this.clippingPlanesDirty = false;
|
|
413
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Tracks if the tile's relationship with a ClippingPolygonCollection has changed with regards
|
|
416
|
+
* to the ClippingPolygonCollection's state.
|
|
417
|
+
*
|
|
418
|
+
* @type {boolean}
|
|
419
|
+
*
|
|
420
|
+
* @private
|
|
421
|
+
*/
|
|
422
|
+
this.clippingPolygonsDirty = false;
|
|
423
|
+
|
|
414
424
|
/**
|
|
415
425
|
* Tracks if the tile's request should be deferred until all non-deferred
|
|
416
426
|
* tiles load.
|
|
@@ -481,7 +491,9 @@ function Cesium3DTile(tileset, baseResource, header, parent) {
|
|
|
481
491
|
this._refines = false;
|
|
482
492
|
this._shouldSelect = false;
|
|
483
493
|
this._isClipped = true;
|
|
494
|
+
this._isClippedByPolygon = false;
|
|
484
495
|
this._clippingPlanesState = 0; // encapsulates (_isClipped, clippingPlanes.enabled) and number/function
|
|
496
|
+
this._clippingPolygonsState = 0; // encapsulates (_isClipped, clippingPolygons.enabled) and number/function
|
|
485
497
|
this._debugBoundingVolume = undefined;
|
|
486
498
|
this._debugContentBoundingVolume = undefined;
|
|
487
499
|
this._debugViewerRequestVolume = undefined;
|
|
@@ -1418,6 +1430,8 @@ Cesium3DTile.prototype.unloadContent = function () {
|
|
|
1418
1430
|
this.lastStyleTime = 0.0;
|
|
1419
1431
|
this.clippingPlanesDirty = this._clippingPlanesState === 0;
|
|
1420
1432
|
this._clippingPlanesState = 0;
|
|
1433
|
+
this.clippingPolygonsDirty = this._clippingPolygonsState === 0;
|
|
1434
|
+
this._clippingPolygonsState = 0;
|
|
1421
1435
|
|
|
1422
1436
|
this._debugColorizeTiles = false;
|
|
1423
1437
|
|
|
@@ -1516,6 +1530,17 @@ Cesium3DTile.prototype.visibility = function (
|
|
|
1516
1530
|
}
|
|
1517
1531
|
}
|
|
1518
1532
|
|
|
1533
|
+
const clippingPolygons = tileset.clippingPolygons;
|
|
1534
|
+
if (defined(clippingPolygons) && clippingPolygons.enabled) {
|
|
1535
|
+
const intersection = clippingPolygons.computeIntersectionWithBoundingVolume(
|
|
1536
|
+
boundingVolume
|
|
1537
|
+
);
|
|
1538
|
+
|
|
1539
|
+
this._isClippedByPolygon = intersection !== Intersect.OUTSIDE;
|
|
1540
|
+
// Polygon clipping intersections are determined by outer rectangles, therefore we cannot
|
|
1541
|
+
// preemptively determine if a tile is completely clipped or not here.
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1519
1544
|
return cullingVolume.computeVisibilityWithPlaneMask(
|
|
1520
1545
|
boundingVolume,
|
|
1521
1546
|
parentVisibilityPlaneMask
|
|
@@ -1562,6 +1587,17 @@ Cesium3DTile.prototype.contentVisibility = function (frameState) {
|
|
|
1562
1587
|
}
|
|
1563
1588
|
}
|
|
1564
1589
|
|
|
1590
|
+
const clippingPolygons = tileset.clippingPolygons;
|
|
1591
|
+
if (defined(clippingPolygons) && clippingPolygons.enabled) {
|
|
1592
|
+
const intersection = clippingPolygons.computeIntersectionWithBoundingVolume(
|
|
1593
|
+
boundingVolume
|
|
1594
|
+
);
|
|
1595
|
+
this._isClippedByPolygon = intersection !== Intersect.OUTSIDE;
|
|
1596
|
+
if (intersection === Intersect.INSIDE) {
|
|
1597
|
+
return Intersect.OUTSIDE;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1565
1601
|
return cullingVolume.computeVisibility(boundingVolume);
|
|
1566
1602
|
};
|
|
1567
1603
|
|
|
@@ -2150,6 +2186,33 @@ function updateClippingPlanes(tile, tileset) {
|
|
|
2150
2186
|
}
|
|
2151
2187
|
}
|
|
2152
2188
|
|
|
2189
|
+
/**
|
|
2190
|
+
* Compute and compare ClippingPolygons state:
|
|
2191
|
+
* - enabled-ness - are clipping polygons enabled? is this tile clipped?
|
|
2192
|
+
* - clipping polygon count & position count
|
|
2193
|
+
* - clipping function (inverse)
|
|
2194
|
+
|
|
2195
|
+
* @private
|
|
2196
|
+
* @param {Cesium3DTile} tile
|
|
2197
|
+
* @param {Cesium3DTileset} tileset
|
|
2198
|
+
*/
|
|
2199
|
+
function updateClippingPolygons(tile, tileset) {
|
|
2200
|
+
const clippingPolygons = tileset.clippingPolygons;
|
|
2201
|
+
let currentClippingPolygonsState = 0;
|
|
2202
|
+
if (
|
|
2203
|
+
defined(clippingPolygons) &&
|
|
2204
|
+
tile._isClippedByPolygon &&
|
|
2205
|
+
clippingPolygons.enabled
|
|
2206
|
+
) {
|
|
2207
|
+
currentClippingPolygonsState = clippingPolygons.clippingPolygonsState;
|
|
2208
|
+
}
|
|
2209
|
+
// If clippingPolygonState for tile changed, mark clippingPolygonsDirty so content can update
|
|
2210
|
+
if (currentClippingPolygonsState !== tile._clippingPolygonsState) {
|
|
2211
|
+
tile._clippingPolygonsState = currentClippingPolygonsState;
|
|
2212
|
+
tile.clippingPolygonsDirty = true;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2153
2216
|
/**
|
|
2154
2217
|
* Get the draw commands needed to render this tile.
|
|
2155
2218
|
*
|
|
@@ -2163,6 +2226,7 @@ Cesium3DTile.prototype.update = function (tileset, frameState, passOptions) {
|
|
|
2163
2226
|
const commandStart = commandList.length;
|
|
2164
2227
|
|
|
2165
2228
|
updateClippingPlanes(this, tileset);
|
|
2229
|
+
updateClippingPolygons(this, tileset);
|
|
2166
2230
|
applyDebugSettings(this, tileset, frameState, passOptions);
|
|
2167
2231
|
updateContent(this, tileset, frameState);
|
|
2168
2232
|
|
|
@@ -2176,6 +2240,7 @@ Cesium3DTile.prototype.update = function (tileset, frameState, passOptions) {
|
|
|
2176
2240
|
}
|
|
2177
2241
|
|
|
2178
2242
|
this.clippingPlanesDirty = false; // reset after content update
|
|
2243
|
+
this.clippingPolygonsDirty = false;
|
|
2179
2244
|
};
|
|
2180
2245
|
|
|
2181
2246
|
const scratchCommandList = [];
|
|
@@ -41,6 +41,7 @@ import Cesium3DTilesetHeatmap from "./Cesium3DTilesetHeatmap.js";
|
|
|
41
41
|
import Cesium3DTilesetStatistics from "./Cesium3DTilesetStatistics.js";
|
|
42
42
|
import Cesium3DTileStyleEngine from "./Cesium3DTileStyleEngine.js";
|
|
43
43
|
import ClippingPlaneCollection from "./ClippingPlaneCollection.js";
|
|
44
|
+
import ClippingPolygonCollection from "./ClippingPolygonCollection.js";
|
|
44
45
|
import hasExtension from "./hasExtension.js";
|
|
45
46
|
import ImplicitTileset from "./ImplicitTileset.js";
|
|
46
47
|
import ImplicitTileCoordinates from "./ImplicitTileCoordinates.js";
|
|
@@ -97,6 +98,7 @@ import Ray from "../Core/Ray.js";
|
|
|
97
98
|
* @property {boolean} [immediatelyLoadDesiredLevelOfDetail=false] When <code>skipLevelOfDetail</code> is <code>true</code>, only tiles that meet the maximum screen space error will ever be downloaded. Skipping factors are ignored and just the desired tiles are loaded.
|
|
98
99
|
* @property {boolean} [loadSiblings=false] When <code>skipLevelOfDetail</code> is <code>true</code>, determines whether siblings of visible tiles are always downloaded during traversal.
|
|
99
100
|
* @property {ClippingPlaneCollection} [clippingPlanes] The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset.
|
|
101
|
+
* @property {ClippingPolygonCollection} [clippingPolygons] The {@link ClippingPolygonCollection} used to selectively disable rendering the tileset.
|
|
100
102
|
* @property {ClassificationType} [classificationType] Determines whether terrain, 3D Tiles or both will be classified by this tileset. See {@link Cesium3DTileset#classificationType} for details about restrictions and limitations.
|
|
101
103
|
* @property {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid determining the size and shape of the globe.
|
|
102
104
|
* @property {object} [pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
|
|
@@ -800,7 +802,22 @@ function Cesium3DTileset(options) {
|
|
|
800
802
|
this.loadSiblings = defaultValue(options.loadSiblings, false);
|
|
801
803
|
|
|
802
804
|
this._clippingPlanes = undefined;
|
|
803
|
-
|
|
805
|
+
if (defined(options.clippingPlanes)) {
|
|
806
|
+
ClippingPlaneCollection.setOwner(
|
|
807
|
+
options.clippingPlanes,
|
|
808
|
+
this,
|
|
809
|
+
"_clippingPlanes"
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
this._clippingPolygons = undefined;
|
|
814
|
+
if (defined(options.clippingPolygons)) {
|
|
815
|
+
ClippingPolygonCollection.setOwner(
|
|
816
|
+
options.clippingPolygons,
|
|
817
|
+
this,
|
|
818
|
+
"_clippingPolygons"
|
|
819
|
+
);
|
|
820
|
+
}
|
|
804
821
|
|
|
805
822
|
if (defined(options.imageBasedLighting)) {
|
|
806
823
|
this._imageBasedLighting = options.imageBasedLighting;
|
|
@@ -1120,6 +1137,22 @@ Object.defineProperties(Cesium3DTileset.prototype, {
|
|
|
1120
1137
|
},
|
|
1121
1138
|
},
|
|
1122
1139
|
|
|
1140
|
+
/**
|
|
1141
|
+
* The {@link ClippingPolygonCollection} used to selectively disable rendering the tileset.
|
|
1142
|
+
*
|
|
1143
|
+
* @memberof Cesium3DTileset.prototype
|
|
1144
|
+
*
|
|
1145
|
+
* @type {ClippingPolygonCollection}
|
|
1146
|
+
*/
|
|
1147
|
+
clippingPolygons: {
|
|
1148
|
+
get: function () {
|
|
1149
|
+
return this._clippingPolygons;
|
|
1150
|
+
},
|
|
1151
|
+
set: function (value) {
|
|
1152
|
+
ClippingPolygonCollection.setOwner(value, this, "_clippingPolygons");
|
|
1153
|
+
},
|
|
1154
|
+
},
|
|
1155
|
+
|
|
1123
1156
|
/**
|
|
1124
1157
|
* Gets the tileset's properties dictionary object, which contains metadata about per-feature properties.
|
|
1125
1158
|
* <p>
|
|
@@ -2519,6 +2552,12 @@ Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
|
|
|
2519
2552
|
clippingPlanes.update(frameState);
|
|
2520
2553
|
}
|
|
2521
2554
|
|
|
2555
|
+
// Update clipping polygons
|
|
2556
|
+
const clippingPolygons = this._clippingPolygons;
|
|
2557
|
+
if (defined(clippingPolygons) && clippingPolygons.enabled) {
|
|
2558
|
+
clippingPolygons.update(frameState);
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2522
2561
|
if (!defined(this._loadTimestamp)) {
|
|
2523
2562
|
this._loadTimestamp = JulianDate.clone(frameState.time);
|
|
2524
2563
|
}
|
|
@@ -3372,6 +3411,12 @@ Cesium3DTileset.prototype.updateForPass = function (
|
|
|
3372
3411
|
originalCullingVolume
|
|
3373
3412
|
);
|
|
3374
3413
|
|
|
3414
|
+
// Update clipping polygons
|
|
3415
|
+
const clippingPolygons = this._clippingPolygons;
|
|
3416
|
+
if (defined(clippingPolygons) && clippingPolygons.enabled) {
|
|
3417
|
+
clippingPolygons.queueCommands(frameState);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3375
3420
|
const passStatistics = this._statisticsPerPass[pass];
|
|
3376
3421
|
|
|
3377
3422
|
if (this.show || ignoreCommands) {
|
|
@@ -3440,6 +3485,8 @@ Cesium3DTileset.prototype.destroy = function () {
|
|
|
3440
3485
|
this._tileDebugLabels =
|
|
3441
3486
|
this._tileDebugLabels && this._tileDebugLabels.destroy();
|
|
3442
3487
|
this._clippingPlanes = this._clippingPlanes && this._clippingPlanes.destroy();
|
|
3488
|
+
this._clippingPolygons =
|
|
3489
|
+
this._clippingPolygons && this._clippingPolygons.destroy();
|
|
3443
3490
|
|
|
3444
3491
|
// Traverse the tree and destroy all tiles
|
|
3445
3492
|
if (defined(this._root)) {
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import Check from "../Core/Check.js";
|
|
2
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
3
|
+
import Cartographic from "../Core/Cartographic.js";
|
|
4
|
+
import defaultValue from "../Core/defaultValue.js";
|
|
5
|
+
import defined from "../Core/defined.js";
|
|
6
|
+
import Ellipsoid from "../Core/Ellipsoid.js";
|
|
7
|
+
import CesiumMath from "../Core/Math.js";
|
|
8
|
+
import PolygonGeometry from "../Core/PolygonGeometry.js";
|
|
9
|
+
import Rectangle from "../Core/Rectangle.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A geodesic polygon to be used with {@link ClippingPlaneCollection} for selectively hiding regions in a model, a 3D tileset, or the globe.
|
|
13
|
+
* @alias ClippingPolygon
|
|
14
|
+
* @constructor
|
|
15
|
+
*
|
|
16
|
+
* @param {object} options Object with the following properties:
|
|
17
|
+
* @param {Cartesian3[]} options.positions A list of three or more Cartesian coordinates defining the outer ring of the clipping polygon.
|
|
18
|
+
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84]
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const positions = Cesium.Cartesian3.fromRadiansArray([
|
|
22
|
+
* -1.3194369277314022,
|
|
23
|
+
* 0.6988062530900625,
|
|
24
|
+
* -1.31941,
|
|
25
|
+
* 0.69879,
|
|
26
|
+
* -1.3193955980204217,
|
|
27
|
+
* 0.6988091578771254,
|
|
28
|
+
* -1.3193931220959367,
|
|
29
|
+
* 0.698743632490865,
|
|
30
|
+
* -1.3194358224045408,
|
|
31
|
+
* 0.6987471965556998,
|
|
32
|
+
* ]);
|
|
33
|
+
*
|
|
34
|
+
* const polygon = new Cesium.ClippingPolygon({
|
|
35
|
+
* positions: positions
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
function ClippingPolygon(options) {
|
|
39
|
+
//>>includeStart('debug', pragmas.debug);
|
|
40
|
+
Check.typeOf.object("options", options);
|
|
41
|
+
Check.typeOf.object("options.positions", options.positions);
|
|
42
|
+
Check.typeOf.number.greaterThanOrEquals(
|
|
43
|
+
"options.positions.length",
|
|
44
|
+
options.positions.length,
|
|
45
|
+
3
|
|
46
|
+
);
|
|
47
|
+
//>>includeEnd('debug');
|
|
48
|
+
|
|
49
|
+
this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
|
|
50
|
+
this._positions = [...options.positions];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Object.defineProperties(ClippingPolygon.prototype, {
|
|
54
|
+
/**
|
|
55
|
+
* Returns the total number of positions in the polygon, include any holes.
|
|
56
|
+
*
|
|
57
|
+
* @memberof ClippingPolygon.prototype
|
|
58
|
+
* @type {number}
|
|
59
|
+
* @readonly
|
|
60
|
+
*/
|
|
61
|
+
length: {
|
|
62
|
+
get: function () {
|
|
63
|
+
return this._positions.length;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Returns the outer ring of positions.
|
|
68
|
+
*
|
|
69
|
+
* @memberof ClippingPolygon.prototype
|
|
70
|
+
* @type {Cartesian3[]}
|
|
71
|
+
* @readonly
|
|
72
|
+
*/
|
|
73
|
+
positions: {
|
|
74
|
+
get: function () {
|
|
75
|
+
return this._positions;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* Returns the ellipsoid used to project the polygon onto surfaces when clipping.
|
|
80
|
+
*
|
|
81
|
+
* @memberof ClippingPolygon.prototype
|
|
82
|
+
* @type {Ellipsoid}
|
|
83
|
+
* @readonly
|
|
84
|
+
*/
|
|
85
|
+
ellipsoid: {
|
|
86
|
+
get: function () {
|
|
87
|
+
return this._ellipsoid;
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Clones the ClippingPolygon without setting its ownership.
|
|
94
|
+
* @param {ClippingPolygon} polygon The ClippingPolygon to be cloned
|
|
95
|
+
* @param {ClippingPolygon} [result] The object on which to store the cloned parameters.
|
|
96
|
+
* @returns {ClippingPolygon} a clone of the input ClippingPolygon
|
|
97
|
+
*/
|
|
98
|
+
ClippingPolygon.clone = function (polygon, result) {
|
|
99
|
+
//>>includeStart('debug', pragmas.debug);
|
|
100
|
+
Check.typeOf.object("polygon", polygon);
|
|
101
|
+
//>>includeEnd('debug');
|
|
102
|
+
|
|
103
|
+
if (!defined(result)) {
|
|
104
|
+
return new ClippingPolygon({
|
|
105
|
+
positions: polygon.positions,
|
|
106
|
+
ellipsoid: polygon.ellipsoid,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
result._ellipsoid = polygon.ellipsoid;
|
|
111
|
+
result._positions.length = 0;
|
|
112
|
+
result._positions.push(...polygon.positions);
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Compares the provided ClippingPolygons and returns
|
|
118
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
119
|
+
*
|
|
120
|
+
* @param {Plane} left The first polygon.
|
|
121
|
+
* @param {Plane} right The second polygon.
|
|
122
|
+
* @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
123
|
+
*/
|
|
124
|
+
ClippingPolygon.equals = function (left, right) {
|
|
125
|
+
//>>includeStart('debug', pragmas.debug);
|
|
126
|
+
Check.typeOf.object("left", left);
|
|
127
|
+
Check.typeOf.object("right", right);
|
|
128
|
+
//>>includeEnd('debug');
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
left.ellipsoid.equals(right.ellipsoid) && left.positions === right.positions
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Computes a cartographic rectangle which encloses the polygon defined by the list of positions, including cases over the international date line and the poles.
|
|
137
|
+
*
|
|
138
|
+
* @param {Rectangle} [result] An object in which to store the result.
|
|
139
|
+
* @returns {Rectangle} The result rectangle
|
|
140
|
+
*/
|
|
141
|
+
ClippingPolygon.prototype.computeRectangle = function (result) {
|
|
142
|
+
return PolygonGeometry.computeRectangleFromPositions(
|
|
143
|
+
this.positions,
|
|
144
|
+
this.ellipsoid,
|
|
145
|
+
undefined,
|
|
146
|
+
result
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const scratchRectangle = new Rectangle();
|
|
151
|
+
const spherePointScratch = new Cartesian3();
|
|
152
|
+
/**
|
|
153
|
+
* Computes a rectangle with the spherical extents that encloses the polygon defined by the list of positions, including cases over the international date line and the poles.
|
|
154
|
+
*
|
|
155
|
+
* @private
|
|
156
|
+
*
|
|
157
|
+
* @param {Rectangle} [result] An object in which to store the result.
|
|
158
|
+
* @returns {Rectangle} The result rectangle with spherical extents.
|
|
159
|
+
*/
|
|
160
|
+
ClippingPolygon.prototype.computeSphericalExtents = function (result) {
|
|
161
|
+
if (!defined(result)) {
|
|
162
|
+
result = new Rectangle();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const rectangle = this.computeRectangle(scratchRectangle);
|
|
166
|
+
|
|
167
|
+
let spherePoint = Cartographic.toCartesian(
|
|
168
|
+
Rectangle.southwest(rectangle),
|
|
169
|
+
this.ellipsoid,
|
|
170
|
+
spherePointScratch
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// Project into plane with vertical for latitude
|
|
174
|
+
let magXY = Math.sqrt(
|
|
175
|
+
spherePoint.x * spherePoint.x + spherePoint.y * spherePoint.y
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// Use fastApproximateAtan2 for alignment with shader
|
|
179
|
+
let sphereLatitude = CesiumMath.fastApproximateAtan2(magXY, spherePoint.z);
|
|
180
|
+
let sphereLongitude = CesiumMath.fastApproximateAtan2(
|
|
181
|
+
spherePoint.x,
|
|
182
|
+
spherePoint.y
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
result.south = sphereLatitude;
|
|
186
|
+
result.west = sphereLongitude;
|
|
187
|
+
|
|
188
|
+
spherePoint = Cartographic.toCartesian(
|
|
189
|
+
Rectangle.northeast(rectangle),
|
|
190
|
+
this.ellipsoid,
|
|
191
|
+
spherePointScratch
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
// Project into plane with vertical for latitude
|
|
195
|
+
magXY = Math.sqrt(
|
|
196
|
+
spherePoint.x * spherePoint.x + spherePoint.y * spherePoint.y
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Use fastApproximateAtan2 for alignment with shader
|
|
200
|
+
sphereLatitude = CesiumMath.fastApproximateAtan2(magXY, spherePoint.z);
|
|
201
|
+
sphereLongitude = CesiumMath.fastApproximateAtan2(
|
|
202
|
+
spherePoint.x,
|
|
203
|
+
spherePoint.y
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
result.north = sphereLatitude;
|
|
207
|
+
result.east = sphereLongitude;
|
|
208
|
+
|
|
209
|
+
return result;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export default ClippingPolygon;
|