@cesium/engine 2.1.0 → 2.2.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/{AxisAlignedBoundingBox-a6f9f0e5.js → AxisAlignedBoundingBox-379015ef.js} +1 -1
- package/Build/Workers/{BoundingRectangle-b0a68595.js → BoundingRectangle-57f2b24f.js} +1 -1
- package/Build/Workers/{BoxGeometry-baedd794.js → BoxGeometry-ecabfc78.js} +1 -1
- package/Build/Workers/{Color-f85df1be.js → Color-14d1a36d.js} +1 -1
- package/Build/Workers/{CoplanarPolygonGeometryLibrary-30516950.js → CoplanarPolygonGeometryLibrary-048c3c14.js} +1 -1
- package/Build/Workers/{CorridorGeometryLibrary-5d5d3b3a.js → CorridorGeometryLibrary-520c8619.js} +1 -1
- package/Build/Workers/{CylinderGeometry-d899ae26.js → CylinderGeometry-119068b8.js} +1 -1
- package/Build/Workers/{EllipseGeometry-a49f8449.js → EllipseGeometry-2dfc3523.js} +1 -1
- package/Build/Workers/{EllipseGeometryLibrary-cba7edde.js → EllipseGeometryLibrary-0a1e0170.js} +1 -1
- package/Build/Workers/{EllipseOutlineGeometry-8095c8cb.js → EllipseOutlineGeometry-c5251669.js} +1 -1
- package/Build/Workers/{EllipsoidGeometry-ed93f571.js → EllipsoidGeometry-d10a5221.js} +1 -1
- package/Build/Workers/{EllipsoidOutlineGeometry-e4854854.js → EllipsoidOutlineGeometry-7039a0ae.js} +1 -1
- package/Build/Workers/{EllipsoidTangentPlane-7ae1aa9a.js → EllipsoidTangentPlane-857186be.js} +1 -1
- package/Build/Workers/{FrustumGeometry-b62db3e3.js → FrustumGeometry-400fa1b7.js} +2 -2
- package/Build/Workers/{GeometryAttribute-780af4fa.js → GeometryAttribute-7a2de5c6.js} +1 -1
- package/Build/Workers/{GeometryPipeline-36b61c99.js → GeometryPipeline-916636fa.js} +1 -1
- package/Build/Workers/{IntersectionTests-e889fcf0.js → IntersectionTests-b4d02d4d.js} +1 -1
- package/Build/Workers/{OrientedBoundingBox-43478ac8.js → OrientedBoundingBox-96fe1752.js} +5 -3
- package/Build/Workers/{PolygonGeometryLibrary-38a98276.js → PolygonGeometryLibrary-931f1ec6.js} +1 -1
- package/Build/Workers/{PolygonPipeline-d31ff61c.js → PolygonPipeline-32fc92cc.js} +1 -1
- package/Build/Workers/{PolylinePipeline-30e4cec9.js → PolylinePipeline-6d5c63e5.js} +1 -1
- package/Build/Workers/{PolylineVolumeGeometryLibrary-90551d26.js → PolylineVolumeGeometryLibrary-f068c1fb.js} +1 -1
- package/Build/Workers/{PrimitivePipeline-558d9cb0.js → PrimitivePipeline-879f996a.js} +1 -1
- package/Build/Workers/{RectangleGeometryLibrary-815c68df.js → RectangleGeometryLibrary-2d6f36f3.js} +1 -1
- package/Build/Workers/{TerrainEncoding-341ead52.js → TerrainEncoding-82882059.js} +1 -1
- package/Build/Workers/{Transforms-9e9df299.js → Transforms-9052372a.js} +6 -5
- package/Build/Workers/{WallGeometryLibrary-ccf90976.js → WallGeometryLibrary-db7a64fb.js} +1 -1
- package/Build/Workers/cesiumWorkerBootstrapper.js +1 -1
- package/Build/Workers/combineGeometry.js +1 -1
- package/Build/Workers/createBoxGeometry.js +1 -1
- package/Build/Workers/createBoxOutlineGeometry.js +1 -1
- package/Build/Workers/createCircleGeometry.js +1 -1
- package/Build/Workers/createCircleOutlineGeometry.js +1 -1
- package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
- package/Build/Workers/createCorridorGeometry.js +1 -1
- package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
- package/Build/Workers/createCylinderGeometry.js +1 -1
- package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
- package/Build/Workers/createEllipseGeometry.js +1 -1
- package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
- package/Build/Workers/createEllipsoidGeometry.js +1 -1
- package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
- package/Build/Workers/createFrustumGeometry.js +1 -1
- package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
- package/Build/Workers/createGeometry.js +1 -1
- package/Build/Workers/createGroundPolylineGeometry.js +1 -1
- package/Build/Workers/createPlaneGeometry.js +1 -1
- package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
- package/Build/Workers/createPolygonGeometry.js +1 -1
- package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
- package/Build/Workers/createPolylineGeometry.js +1 -1
- package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
- package/Build/Workers/createRectangleGeometry.js +1 -1
- package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
- package/Build/Workers/createSimplePolylineGeometry.js +1 -1
- package/Build/Workers/createSphereGeometry.js +1 -1
- package/Build/Workers/createSphereOutlineGeometry.js +1 -1
- package/Build/Workers/createVectorTileGeometries.js +1 -1
- package/Build/Workers/createVectorTilePolygons.js +1 -1
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
- package/Build/Workers/createVerticesFromHeightmap.js +1 -1
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +10 -15
- package/Build/Workers/createWallGeometry.js +1 -1
- package/Build/Workers/createWallOutlineGeometry.js +1 -1
- package/Build/Workers/package.js +1 -1
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
- package/Source/Core/ArcGISTiledElevationTerrainProvider.js +291 -191
- package/Source/Core/CesiumTerrainProvider.js +571 -434
- package/Source/Core/CustomHeightmapTerrainProvider.js +12 -0
- package/Source/Core/EllipsoidTerrainProvider.js +17 -10
- package/Source/Core/FrustumGeometry.js +1 -1
- package/Source/Core/GoogleEarthEnterpriseMetadata.js +86 -34
- package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +119 -82
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonResource.js +14 -3
- package/Source/Core/OrientedBoundingBox.js +4 -2
- package/Source/Core/RequestScheduler.js +1 -1
- package/Source/Core/Resource.js +2 -2
- package/Source/Core/TerrainProvider.js +9 -14
- package/Source/Core/TileProviderError.js +8 -8
- package/Source/Core/VRTheWorldTerrainProvider.js +193 -124
- package/Source/Core/buildModuleUrl.js +4 -3
- package/Source/Core/createWorldTerrain.js +20 -2
- package/Source/Core/createWorldTerrainAsync.js +48 -0
- package/Source/Core/sampleTerrain.js +9 -10
- package/Source/Core/sampleTerrainMostDetailed.js +66 -72
- package/Source/DataSources/Cesium3DTilesetVisualizer.js +37 -26
- package/Source/DataSources/Entity.js +6 -1
- package/Source/DataSources/ModelVisualizer.js +99 -31
- package/Source/DataSources/PolygonGraphics.js +1 -1
- package/Source/Scene/ArcGisMapServerImageryProvider.js +552 -376
- package/Source/Scene/BingMapsImageryProvider.js +511 -305
- package/Source/Scene/BufferLoader.js +29 -34
- package/Source/Scene/Cesium3DTile.js +388 -251
- package/Source/Scene/Cesium3DTileBatchTable.js +2 -2
- package/Source/Scene/Cesium3DTileContent.js +16 -0
- package/Source/Scene/Cesium3DTileContentFactory.js +4 -4
- package/Source/Scene/Cesium3DTilePass.js +8 -11
- package/Source/Scene/Cesium3DTileStyleEngine.js +1 -1
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +225 -117
- package/Source/Scene/Cesium3DTileset.js +755 -481
- package/Source/Scene/Cesium3DTilesetBaseTraversal.js +301 -0
- package/Source/Scene/Cesium3DTilesetMostDetailedTraversal.js +33 -46
- package/Source/Scene/Cesium3DTilesetSkipTraversal.js +421 -0
- package/Source/Scene/Cesium3DTilesetTraversal.js +219 -671
- package/Source/Scene/ClassificationPrimitive.js +7 -0
- package/Source/Scene/Composite3DTileContent.js +69 -26
- package/Source/Scene/CreditDisplay.js +20 -4
- package/Source/Scene/DepthPlane.js +1 -1
- package/Source/Scene/Empty3DTileContent.js +31 -1
- package/Source/Scene/Geometry3DTileContent.js +47 -7
- package/Source/Scene/Globe.js +5 -1
- package/Source/Scene/GlobeSurfaceTile.js +2 -1
- package/Source/Scene/GlobeSurfaceTileProvider.js +50 -27
- package/Source/Scene/GltfBufferViewLoader.js +47 -91
- package/Source/Scene/GltfDracoLoader.js +110 -112
- package/Source/Scene/GltfImageLoader.js +71 -78
- package/Source/Scene/GltfIndexBufferLoader.js +108 -121
- package/Source/Scene/GltfJsonLoader.js +75 -74
- package/Source/Scene/GltfLoader.js +392 -280
- package/Source/Scene/GltfStructuralMetadataLoader.js +109 -110
- package/Source/Scene/GltfTextureLoader.js +97 -96
- package/Source/Scene/GltfVertexBufferLoader.js +128 -133
- package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +353 -225
- package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +491 -331
- package/Source/Scene/GridImageryProvider.js +267 -104
- package/Source/Scene/GroundPolylinePrimitive.js +12 -1
- package/Source/Scene/GroundPrimitive.js +8 -1
- package/Source/Scene/I3SDataProvider.js +214 -113
- package/Source/Scene/I3SFeature.js +7 -6
- package/Source/Scene/I3SLayer.js +26 -37
- package/Source/Scene/I3SNode.js +59 -66
- package/Source/Scene/Imagery.js +6 -1
- package/Source/Scene/ImageryLayer.js +299 -48
- package/Source/Scene/ImageryLayerCollection.js +26 -0
- package/Source/Scene/ImageryProvider.js +129 -111
- package/Source/Scene/Implicit3DTileContent.js +72 -23
- package/Source/Scene/ImplicitSubtree.js +66 -45
- package/Source/Scene/IonImageryProvider.js +471 -264
- package/Source/Scene/MapboxImageryProvider.js +272 -112
- package/Source/Scene/MapboxStyleImageryProvider.js +270 -111
- package/Source/Scene/MetadataSchemaLoader.js +26 -36
- package/Source/Scene/Model/B3dmLoader.js +42 -46
- package/Source/Scene/Model/GeoJsonLoader.js +8 -32
- package/Source/Scene/Model/I3dmLoader.js +48 -74
- package/Source/Scene/Model/Model.js +470 -132
- package/Source/Scene/Model/Model3DTileContent.js +83 -31
- package/Source/Scene/Model/ModelAnimationCollection.js +3 -3
- package/Source/Scene/Model/ModelDrawCommand.js +15 -26
- package/Source/Scene/Model/ModelUtility.js +16 -16
- package/Source/Scene/Model/PntsLoader.js +27 -32
- package/Source/Scene/Multiple3DTileContent.js +134 -115
- package/Source/Scene/PointCloud.js +11 -19
- package/Source/Scene/Primitive.js +20 -0
- package/Source/Scene/QuadtreePrimitive.js +2 -0
- package/Source/Scene/QuadtreeTileProvider.js +4 -8
- package/Source/Scene/ResourceCache.js +47 -105
- package/Source/Scene/ResourceCacheStatistics.js +24 -58
- package/Source/Scene/ResourceLoader.js +5 -17
- package/Source/Scene/ResourceLoaderState.js +12 -4
- package/Source/Scene/Scene.js +65 -0
- package/Source/Scene/ScreenSpaceCameraController.js +1 -1
- package/Source/Scene/SingleTileImageryProvider.js +382 -209
- package/Source/Scene/Terrain.js +196 -0
- package/Source/Scene/TileCoordinatesImageryProvider.js +267 -104
- package/Source/Scene/TileMapServiceImageryProvider.js +177 -85
- package/Source/Scene/Tileset3DTileContent.js +47 -5
- package/Source/Scene/TimeDynamicPointCloud.js +15 -2
- package/Source/Scene/UrlTemplateImageryProvider.js +343 -215
- package/Source/Scene/Vector3DTileClampedPolylines.js +96 -84
- package/Source/Scene/Vector3DTileContent.js +47 -22
- package/Source/Scene/Vector3DTileGeometry.js +57 -52
- package/Source/Scene/Vector3DTilePoints.js +72 -68
- package/Source/Scene/Vector3DTilePolygons.js +118 -117
- package/Source/Scene/Vector3DTilePolylines.js +86 -82
- package/Source/Scene/Vector3DTilePrimitive.js +0 -1
- package/Source/Scene/VoxelContent.js +61 -63
- package/Source/Scene/VoxelPrimitive.js +39 -91
- package/Source/Scene/VoxelProvider.js +2 -2
- package/Source/Scene/WebMapServiceImageryProvider.js +272 -111
- package/Source/Scene/WebMapTileServiceImageryProvider.js +270 -107
- package/Source/Scene/computeFlyToLocationForRectangle.js +33 -37
- package/Source/Scene/createOsmBuildings.js +6 -0
- package/Source/Scene/createOsmBuildingsAsync.js +82 -0
- package/Source/Scene/createWorldImagery.js +14 -5
- package/Source/Scene/createWorldImageryAsync.js +39 -0
- package/Source/Widget/CesiumWidget.js +55 -27
- package/index.d.ts +2158 -1395
- package/index.js +58 -51
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CesiumTerrainProvider from "./CesiumTerrainProvider.js";
|
|
2
2
|
import defaultValue from "./defaultValue.js";
|
|
3
|
+
import deprecationWarning from "./deprecationWarning.js";
|
|
3
4
|
import IonResource from "./IonResource.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -31,12 +32,29 @@ import IonResource from "./IonResource.js";
|
|
|
31
32
|
*
|
|
32
33
|
*/
|
|
33
34
|
function createWorldTerrain(options) {
|
|
35
|
+
deprecationWarning(
|
|
36
|
+
"createWorldTerrain",
|
|
37
|
+
"createWorldTerrain was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use createWorldTerrainAsync instead."
|
|
38
|
+
);
|
|
39
|
+
|
|
34
40
|
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
url: IonResource.fromAssetId(1),
|
|
42
|
+
const provider = new CesiumTerrainProvider({
|
|
38
43
|
requestVertexNormals: defaultValue(options.requestVertexNormals, false),
|
|
39
44
|
requestWaterMask: defaultValue(options.requestWaterMask, false),
|
|
40
45
|
});
|
|
46
|
+
|
|
47
|
+
// This is here in order to avoid throwing a second deprecation error
|
|
48
|
+
// by using the deprecated url parameter in the constructor above
|
|
49
|
+
provider._readyPromise = CesiumTerrainProvider._initializeReadyPromise(
|
|
50
|
+
{
|
|
51
|
+
url: IonResource.fromAssetId(1),
|
|
52
|
+
requestVertexNormals: defaultValue(options.requestVertexNormals, false),
|
|
53
|
+
requestWaterMask: defaultValue(options.requestWaterMask, false),
|
|
54
|
+
},
|
|
55
|
+
provider
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return provider;
|
|
41
59
|
}
|
|
42
60
|
export default createWorldTerrain;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import CesiumTerrainProvider from "./CesiumTerrainProvider.js";
|
|
2
|
+
import defaultValue from "./defaultValue.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a {@link CesiumTerrainProvider} instance for the {@link https://cesium.com/content/#cesium-world-terrain|Cesium World Terrain}.
|
|
6
|
+
*
|
|
7
|
+
* @function
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} [options] Object with the following properties:
|
|
10
|
+
* @param {Boolean} [options.requestVertexNormals=false] Flag that indicates if the client should request additional lighting information from the server if available.
|
|
11
|
+
* @param {Boolean} [options.requestWaterMask=false] Flag that indicates if the client should request per tile water masks from the server if available.
|
|
12
|
+
* @returns {Promise<CesiumTerrainProvider>} A promise that resolves to the created CesiumTerrainProvider
|
|
13
|
+
*
|
|
14
|
+
* @see Ion
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Create Cesium World Terrain with default settings
|
|
18
|
+
* try {
|
|
19
|
+
* const viewer = new Cesium.Viewer("cesiumContainer", {
|
|
20
|
+
* terrainProvider: await Cesium.createWorldTerrainAsync();
|
|
21
|
+
* });
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* console.log(error);
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Create Cesium World Terrain with water and normals.
|
|
28
|
+
* try {
|
|
29
|
+
* const viewer1 = new Cesium.Viewer("cesiumContainer", {
|
|
30
|
+
* terrainProvider: await Cesium.createWorldTerrainAsync({
|
|
31
|
+
* requestWaterMask: true,
|
|
32
|
+
* requestVertexNormals: true
|
|
33
|
+
* });
|
|
34
|
+
* });
|
|
35
|
+
* } catch (error) {
|
|
36
|
+
* console.log(error);
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
function createWorldTerrainAsync(options) {
|
|
41
|
+
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
|
|
42
|
+
|
|
43
|
+
return CesiumTerrainProvider.fromIonAssetId(1, {
|
|
44
|
+
requestVertexNormals: defaultValue(options.requestVertexNormals, false),
|
|
45
|
+
requestWaterMask: defaultValue(options.requestWaterMask, false),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export default createWorldTerrainAsync;
|
|
@@ -26,27 +26,26 @@ import defined from "./defined.js";
|
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* // Query the terrain height of two Cartographic positions
|
|
29
|
-
* const terrainProvider = Cesium.
|
|
29
|
+
* const terrainProvider = await Cesium.createWorldTerrainAsync();
|
|
30
30
|
* const positions = [
|
|
31
31
|
* Cesium.Cartographic.fromDegrees(86.925145, 27.988257),
|
|
32
32
|
* Cesium.Cartographic.fromDegrees(87.0, 28.0)
|
|
33
33
|
* ];
|
|
34
|
-
* const
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* // updatedPositions is just a reference to positions.
|
|
38
|
-
* });
|
|
34
|
+
* const updatedPositions = await Cesium.sampleTerrain(terrainProvider, 11, positions);
|
|
35
|
+
* // positions[0].height and positions[1].height have been updated.
|
|
36
|
+
* // updatedPositions is just a reference to positions.
|
|
39
37
|
*/
|
|
40
|
-
function sampleTerrain(terrainProvider, level, positions) {
|
|
38
|
+
async function sampleTerrain(terrainProvider, level, positions) {
|
|
41
39
|
//>>includeStart('debug', pragmas.debug);
|
|
42
40
|
Check.typeOf.object("terrainProvider", terrainProvider);
|
|
43
41
|
Check.typeOf.number("level", level);
|
|
44
42
|
Check.defined("positions", positions);
|
|
45
43
|
//>>includeEnd('debug');
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
// readyPromise has been deprecated; This is here for backwards compatibility
|
|
46
|
+
await terrainProvider._readyPromise;
|
|
47
|
+
|
|
48
|
+
return doSampling(terrainProvider, level, positions);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
@@ -17,18 +17,16 @@ const scratchCartesian2 = new Cartesian2();
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* // Query the terrain height of two Cartographic positions
|
|
20
|
-
* const terrainProvider = Cesium.
|
|
20
|
+
* const terrainProvider = await Cesium.createWorldTerrainAsync();
|
|
21
21
|
* const positions = [
|
|
22
22
|
* Cesium.Cartographic.fromDegrees(86.925145, 27.988257),
|
|
23
23
|
* Cesium.Cartographic.fromDegrees(87.0, 28.0)
|
|
24
24
|
* ];
|
|
25
|
-
* const
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* // updatedPositions is just a reference to positions.
|
|
29
|
-
* });
|
|
25
|
+
* const updatedPositions = await Cesium.sampleTerrainMostDetailed(terrainProvider, positions);
|
|
26
|
+
* // positions[0].height and positions[1].height have been updated.
|
|
27
|
+
* // updatedPositions is just a reference to positions.
|
|
30
28
|
*/
|
|
31
|
-
function sampleTerrainMostDetailed(terrainProvider, positions) {
|
|
29
|
+
async function sampleTerrainMostDetailed(terrainProvider, positions) {
|
|
32
30
|
//>>includeStart('debug', pragmas.debug);
|
|
33
31
|
if (!defined(terrainProvider)) {
|
|
34
32
|
throw new DeveloperError("terrainProvider is required.");
|
|
@@ -38,80 +36,76 @@ function sampleTerrainMostDetailed(terrainProvider, positions) {
|
|
|
38
36
|
}
|
|
39
37
|
//>>includeEnd('debug');
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const maxLevels = [];
|
|
39
|
+
const byLevel = [];
|
|
40
|
+
const maxLevels = [];
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
// readyPromise has been deprecated; This is here for backwards compatibility
|
|
43
|
+
await terrainProvider._readyPromise;
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const availability = terrainProvider.availability;
|
|
46
|
+
|
|
47
|
+
//>>includeStart('debug', pragmas.debug);
|
|
48
|
+
if (!defined(availability)) {
|
|
49
|
+
throw new DeveloperError(
|
|
50
|
+
"sampleTerrainMostDetailed requires a terrain provider that has tile availability."
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
//>>includeEnd('debug');
|
|
54
|
+
|
|
55
|
+
const promises = [];
|
|
56
|
+
for (let i = 0; i < positions.length; ++i) {
|
|
57
|
+
const position = positions[i];
|
|
58
|
+
const maxLevel = availability.computeMaximumLevelAtPosition(position);
|
|
59
|
+
maxLevels[i] = maxLevel;
|
|
60
|
+
if (maxLevel === 0) {
|
|
61
|
+
// This is a special case where we have a parent terrain and we are requesting
|
|
62
|
+
// heights from an area that isn't covered by the top level terrain at all.
|
|
63
|
+
// This will essentially trigger the loading of the parent terrains root tile
|
|
64
|
+
terrainProvider.tilingScheme.positionToTileXY(
|
|
65
|
+
position,
|
|
66
|
+
1,
|
|
67
|
+
scratchCartesian2
|
|
68
|
+
);
|
|
69
|
+
const promise = terrainProvider.loadTileDataAvailability(
|
|
70
|
+
scratchCartesian2.x,
|
|
71
|
+
scratchCartesian2.y,
|
|
72
|
+
1
|
|
51
73
|
);
|
|
74
|
+
if (defined(promise)) {
|
|
75
|
+
promises.push(promise);
|
|
76
|
+
}
|
|
52
77
|
}
|
|
53
|
-
//>>includeEnd('debug');
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// This is a special case where we have a parent terrain and we are requesting
|
|
62
|
-
// heights from an area that isn't covered by the top level terrain at all.
|
|
63
|
-
// This will essentially trigger the loading of the parent terrains root tile
|
|
64
|
-
terrainProvider.tilingScheme.positionToTileXY(
|
|
65
|
-
position,
|
|
66
|
-
1,
|
|
67
|
-
scratchCartesian2
|
|
68
|
-
);
|
|
69
|
-
const promise = terrainProvider.loadTileDataAvailability(
|
|
70
|
-
scratchCartesian2.x,
|
|
71
|
-
scratchCartesian2.y,
|
|
72
|
-
1
|
|
73
|
-
);
|
|
74
|
-
if (defined(promise)) {
|
|
75
|
-
promises.push(promise);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
79
|
+
let atLevel = byLevel[maxLevel];
|
|
80
|
+
if (!defined(atLevel)) {
|
|
81
|
+
byLevel[maxLevel] = atLevel = [];
|
|
82
|
+
}
|
|
83
|
+
atLevel.push(position);
|
|
84
|
+
}
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
await Promise.all(promises);
|
|
87
|
+
await Promise.all(
|
|
88
|
+
byLevel.map(function (positionsAtLevel, index) {
|
|
89
|
+
if (defined(positionsAtLevel)) {
|
|
90
|
+
return sampleTerrain(terrainProvider, index, positionsAtLevel);
|
|
82
91
|
}
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
const changedPositions = [];
|
|
95
|
+
for (let i = 0; i < positions.length; ++i) {
|
|
96
|
+
const position = positions[i];
|
|
97
|
+
const maxLevel = availability.computeMaximumLevelAtPosition(position);
|
|
85
98
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return sampleTerrain(terrainProvider, index, positionsAtLevel);
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
})
|
|
96
|
-
.then(function () {
|
|
97
|
-
const changedPositions = [];
|
|
98
|
-
for (let i = 0; i < positions.length; ++i) {
|
|
99
|
-
const position = positions[i];
|
|
100
|
-
const maxLevel = availability.computeMaximumLevelAtPosition(position);
|
|
99
|
+
if (maxLevel !== maxLevels[i]) {
|
|
100
|
+
// Now that we loaded the max availability, a higher level has become available
|
|
101
|
+
changedPositions.push(position);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
101
104
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
105
|
+
if (changedPositions.length > 0) {
|
|
106
|
+
await sampleTerrainMostDetailed(terrainProvider, changedPositions);
|
|
107
|
+
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
return sampleTerrainMostDetailed(terrainProvider, changedPositions);
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
.then(function () {
|
|
113
|
-
return positions;
|
|
114
|
-
});
|
|
115
|
-
});
|
|
109
|
+
return positions;
|
|
116
110
|
}
|
|
117
111
|
export default sampleTerrainMostDetailed;
|
|
@@ -65,7 +65,7 @@ Cesium3DTilesetVisualizer.prototype.update = function (time) {
|
|
|
65
65
|
const tilesetGraphics = entity._tileset;
|
|
66
66
|
|
|
67
67
|
let resource;
|
|
68
|
-
|
|
68
|
+
const tilesetData = tilesetHash[entity.id];
|
|
69
69
|
const show =
|
|
70
70
|
entity.isShowing &&
|
|
71
71
|
entity.isAvailable(time) &&
|
|
@@ -86,28 +86,21 @@ Cesium3DTilesetVisualizer.prototype.update = function (time) {
|
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
const tileset = defined(tilesetData)
|
|
90
90
|
? tilesetData.tilesetPrimitive
|
|
91
91
|
: undefined;
|
|
92
|
-
if (!defined(
|
|
92
|
+
if (!defined(tilesetData) || resource.url !== tilesetData.url) {
|
|
93
93
|
if (defined(tileset)) {
|
|
94
94
|
primitives.removeAndDestroy(tileset);
|
|
95
|
-
delete tilesetHash[entity.id];
|
|
96
95
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
url: resource.url,
|
|
106
|
-
loadFail: false,
|
|
107
|
-
};
|
|
108
|
-
tilesetHash[entity.id] = tilesetData;
|
|
109
|
-
|
|
110
|
-
checkLoad(tileset, entity, tilesetHash);
|
|
96
|
+
|
|
97
|
+
delete tilesetHash[entity.id];
|
|
98
|
+
|
|
99
|
+
createTileset(resource, tilesetHash, entity, primitives);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!defined(tileset)) {
|
|
103
|
+
continue;
|
|
111
104
|
}
|
|
112
105
|
|
|
113
106
|
tileset.show = true;
|
|
@@ -180,12 +173,12 @@ Cesium3DTilesetVisualizer.prototype.getBoundingSphere = function (
|
|
|
180
173
|
}
|
|
181
174
|
|
|
182
175
|
const primitive = tilesetData.tilesetPrimitive;
|
|
183
|
-
if (!defined(primitive)
|
|
184
|
-
return BoundingSphereState.
|
|
176
|
+
if (!defined(primitive)) {
|
|
177
|
+
return BoundingSphereState.PENDING;
|
|
185
178
|
}
|
|
186
179
|
|
|
187
|
-
if (!primitive.
|
|
188
|
-
return BoundingSphereState.
|
|
180
|
+
if (!primitive.show) {
|
|
181
|
+
return BoundingSphereState.FAILED;
|
|
189
182
|
}
|
|
190
183
|
|
|
191
184
|
BoundingSphere.clone(primitive.boundingSphere, result);
|
|
@@ -235,15 +228,33 @@ Cesium3DTilesetVisualizer.prototype._onCollectionChanged = function (
|
|
|
235
228
|
function removeTileset(visualizer, entity, tilesetHash, primitives) {
|
|
236
229
|
const tilesetData = tilesetHash[entity.id];
|
|
237
230
|
if (defined(tilesetData)) {
|
|
238
|
-
|
|
231
|
+
if (defined(tilesetData.tilesetPrimitive)) {
|
|
232
|
+
primitives.removeAndDestroy(tilesetData.tilesetPrimitive);
|
|
233
|
+
}
|
|
239
234
|
delete tilesetHash[entity.id];
|
|
240
235
|
}
|
|
241
236
|
}
|
|
242
237
|
|
|
243
|
-
function
|
|
244
|
-
|
|
238
|
+
async function createTileset(resource, tilesetHash, entity, primitives) {
|
|
239
|
+
tilesetHash[entity.id] = {
|
|
240
|
+
url: resource.url,
|
|
241
|
+
loadFail: false,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
const tileset = await Cesium3DTileset.fromUrl(resource);
|
|
246
|
+
tileset.id = entity;
|
|
247
|
+
primitives.add(tileset);
|
|
248
|
+
|
|
249
|
+
if (!defined(tilesetHash[entity.id])) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
tilesetHash[entity.id].tilesetPrimitive = tileset;
|
|
254
|
+
} catch (error) {
|
|
245
255
|
console.error(error);
|
|
246
256
|
tilesetHash[entity.id].loadFail = true;
|
|
247
|
-
}
|
|
257
|
+
}
|
|
248
258
|
}
|
|
259
|
+
|
|
249
260
|
export default Cesium3DTilesetVisualizer;
|
|
@@ -597,7 +597,12 @@ Entity.prototype.merge = function (source) {
|
|
|
597
597
|
//While source is required by the API to be an Entity, we internally call this method from the
|
|
598
598
|
//constructor with an options object to configure initial custom properties.
|
|
599
599
|
//So we need to ignore reserved-non-property.
|
|
600
|
-
if (
|
|
600
|
+
if (
|
|
601
|
+
name === "parent" ||
|
|
602
|
+
name === "name" ||
|
|
603
|
+
name === "availability" ||
|
|
604
|
+
name === "children"
|
|
605
|
+
) {
|
|
601
606
|
continue;
|
|
602
607
|
}
|
|
603
608
|
|
|
@@ -36,6 +36,9 @@ const modelMatrixScratch = new Matrix4();
|
|
|
36
36
|
const nodeMatrixScratch = new Matrix4();
|
|
37
37
|
|
|
38
38
|
const scratchColor = new Color();
|
|
39
|
+
const scratchArray = new Array(4);
|
|
40
|
+
const scratchCartesian = new Cartesian3();
|
|
41
|
+
|
|
39
42
|
/**
|
|
40
43
|
* A {@link Visualizer} which maps {@link Entity#model} to a {@link Model}.
|
|
41
44
|
* @alias ModelVisualizer
|
|
@@ -63,6 +66,52 @@ function ModelVisualizer(scene, entityCollection) {
|
|
|
63
66
|
this._onCollectionChanged(entityCollection, entityCollection.values, [], []);
|
|
64
67
|
}
|
|
65
68
|
|
|
69
|
+
async function createModelPrimitive(
|
|
70
|
+
visualizer,
|
|
71
|
+
entity,
|
|
72
|
+
resource,
|
|
73
|
+
incrementallyLoadTextures
|
|
74
|
+
) {
|
|
75
|
+
const primitives = visualizer._primitives;
|
|
76
|
+
const modelHash = visualizer._modelHash;
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const model = await Model.fromGltfAsync({
|
|
80
|
+
url: resource,
|
|
81
|
+
incrementallyLoadTextures: incrementallyLoadTextures,
|
|
82
|
+
scene: visualizer._scene,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (visualizer.isDestroyed() || !defined(modelHash[entity.id])) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
model.id = entity;
|
|
90
|
+
primitives.add(model);
|
|
91
|
+
modelHash[entity.id].modelPrimitive = model;
|
|
92
|
+
model.errorEvent.addEventListener((error) => {
|
|
93
|
+
if (!defined(modelHash[entity.id])) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
console.log(error);
|
|
98
|
+
|
|
99
|
+
// Texture failures when incrementallyLoadTextures
|
|
100
|
+
// will not affect the ability to compute the bounding sphere
|
|
101
|
+
if (error.name !== "TextureError" && model.incrementallyLoadTextures) {
|
|
102
|
+
modelHash[entity.id].loadFailed = true;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (visualizer.isDestroyed() || !defined(modelHash[entity.id])) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log(error);
|
|
111
|
+
modelHash[entity.id].loadFailed = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
66
115
|
/**
|
|
67
116
|
* Updates models created this visualizer to match their
|
|
68
117
|
* Entity counterpart at the given time.
|
|
@@ -102,45 +151,44 @@ ModelVisualizer.prototype.update = function (time) {
|
|
|
102
151
|
}
|
|
103
152
|
|
|
104
153
|
if (!show) {
|
|
105
|
-
if (defined(modelData)) {
|
|
154
|
+
if (defined(modelData) && modelData.modelPrimitive) {
|
|
106
155
|
modelData.modelPrimitive.show = false;
|
|
107
156
|
}
|
|
108
157
|
continue;
|
|
109
158
|
}
|
|
110
159
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
primitives.removeAndDestroy(model);
|
|
160
|
+
if (!defined(modelData) || resource.url !== modelData.url) {
|
|
161
|
+
if (defined(modelData?.modelPrimitive)) {
|
|
162
|
+
primitives.removeAndDestroy(modelData.modelPrimitive);
|
|
115
163
|
delete modelHash[entity.id];
|
|
116
164
|
}
|
|
117
165
|
|
|
118
|
-
model = Model.fromGltf({
|
|
119
|
-
url: resource,
|
|
120
|
-
incrementallyLoadTextures: Property.getValueOrDefault(
|
|
121
|
-
modelGraphics._incrementallyLoadTextures,
|
|
122
|
-
time,
|
|
123
|
-
defaultIncrementallyLoadTextures
|
|
124
|
-
),
|
|
125
|
-
scene: this._scene,
|
|
126
|
-
});
|
|
127
|
-
model.id = entity;
|
|
128
|
-
primitives.add(model);
|
|
129
|
-
|
|
130
166
|
modelData = {
|
|
131
|
-
modelPrimitive:
|
|
167
|
+
modelPrimitive: undefined,
|
|
132
168
|
url: resource.url,
|
|
133
169
|
animationsRunning: false,
|
|
134
170
|
nodeTransformationsScratch: {},
|
|
135
171
|
articulationsScratch: {},
|
|
136
|
-
|
|
172
|
+
loadFailed: false,
|
|
173
|
+
modelUpdated: false,
|
|
137
174
|
awaitingSampleTerrain: false,
|
|
138
175
|
clampedBoundingSphere: undefined,
|
|
139
176
|
sampleTerrainFailed: false,
|
|
140
177
|
};
|
|
141
178
|
modelHash[entity.id] = modelData;
|
|
142
179
|
|
|
143
|
-
|
|
180
|
+
const incrementallyLoadTextures = Property.getValueOrDefault(
|
|
181
|
+
modelGraphics._incrementallyLoadTextures,
|
|
182
|
+
time,
|
|
183
|
+
defaultIncrementallyLoadTextures
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
createModelPrimitive(this, entity, resource, incrementallyLoadTextures);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const model = modelData.modelPrimitive;
|
|
190
|
+
if (!defined(model)) {
|
|
191
|
+
continue;
|
|
144
192
|
}
|
|
145
193
|
|
|
146
194
|
model.show = true;
|
|
@@ -214,15 +262,27 @@ ModelVisualizer.prototype.update = function (time) {
|
|
|
214
262
|
time,
|
|
215
263
|
defaultImageBasedLightingFactor
|
|
216
264
|
);
|
|
217
|
-
|
|
265
|
+
let lightColor = Property.getValueOrUndefined(
|
|
218
266
|
modelGraphics._lightColor,
|
|
219
267
|
time
|
|
220
268
|
);
|
|
269
|
+
|
|
270
|
+
// Convert from Color to Cartesian3
|
|
271
|
+
if (defined(lightColor)) {
|
|
272
|
+
Color.pack(lightColor, scratchArray, 0);
|
|
273
|
+
lightColor = Cartesian3.unpack(scratchArray, 0, scratchCartesian);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
model.lightColor = lightColor;
|
|
221
277
|
model.customShader = Property.getValueOrUndefined(
|
|
222
278
|
modelGraphics._customShader,
|
|
223
279
|
time
|
|
224
280
|
);
|
|
225
281
|
|
|
282
|
+
// It's possible for getBoundingSphere to run before
|
|
283
|
+
// model becomes ready and these properties are updated
|
|
284
|
+
modelHash[entity.id].modelUpdated = true;
|
|
285
|
+
|
|
226
286
|
if (model.ready) {
|
|
227
287
|
const runAnimations = Property.getValueOrDefault(
|
|
228
288
|
modelGraphics._runAnimations,
|
|
@@ -365,18 +425,23 @@ ModelVisualizer.prototype.getBoundingSphere = function (entity, result) {
|
|
|
365
425
|
//>>includeEnd('debug');
|
|
366
426
|
|
|
367
427
|
const modelData = this._modelHash[entity.id];
|
|
368
|
-
if (!defined(modelData)
|
|
428
|
+
if (!defined(modelData)) {
|
|
429
|
+
return BoundingSphereState.FAILED;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (modelData.loadFailed) {
|
|
369
433
|
return BoundingSphereState.FAILED;
|
|
370
434
|
}
|
|
371
435
|
|
|
372
436
|
const model = modelData.modelPrimitive;
|
|
373
437
|
if (!defined(model) || !model.show) {
|
|
374
|
-
return BoundingSphereState.
|
|
438
|
+
return BoundingSphereState.PENDING;
|
|
375
439
|
}
|
|
376
440
|
|
|
377
|
-
if (!model.ready) {
|
|
441
|
+
if (!model.ready || !modelData.modelUpdated) {
|
|
378
442
|
return BoundingSphereState.PENDING;
|
|
379
443
|
}
|
|
444
|
+
|
|
380
445
|
const scene = this._scene;
|
|
381
446
|
const globe = scene.globe;
|
|
382
447
|
const ellipsoid = globe.ellipsoid;
|
|
@@ -386,7 +451,8 @@ ModelVisualizer.prototype.getBoundingSphere = function (entity, result) {
|
|
|
386
451
|
if (hasHeightReference) {
|
|
387
452
|
// We cannot query the availability of the terrain provider till its ready, so the
|
|
388
453
|
// bounding sphere state will remain pending till the terrain provider is ready.
|
|
389
|
-
|
|
454
|
+
// ready is deprecated. This is here for backwards compatibility
|
|
455
|
+
if (!terrainProvider._ready) {
|
|
390
456
|
return BoundingSphereState.PENDING;
|
|
391
457
|
}
|
|
392
458
|
|
|
@@ -441,6 +507,10 @@ ModelVisualizer.prototype.getBoundingSphere = function (entity, result) {
|
|
|
441
507
|
scratchCartographic,
|
|
442
508
|
])
|
|
443
509
|
.then((result) => {
|
|
510
|
+
if (this.isDestroyed()) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
|
|
444
514
|
this._modelHash[entity.id].awaitingSampleTerrain = false;
|
|
445
515
|
|
|
446
516
|
const updatedCartographic = result[0];
|
|
@@ -463,6 +533,10 @@ ModelVisualizer.prototype.getBoundingSphere = function (entity, result) {
|
|
|
463
533
|
);
|
|
464
534
|
})
|
|
465
535
|
.catch((e) => {
|
|
536
|
+
if (this.isDestroyed()) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
466
540
|
this._modelHash[entity.id].sampleTerrainFailed = true;
|
|
467
541
|
this._modelHash[entity.id].awaitingSampleTerrain = false;
|
|
468
542
|
});
|
|
@@ -539,10 +613,4 @@ function clearNodeTransformationsArticulationsScratch(entity, modelHash) {
|
|
|
539
613
|
}
|
|
540
614
|
}
|
|
541
615
|
|
|
542
|
-
function checkModelLoad(model, entity, modelHash) {
|
|
543
|
-
model.readyPromise.catch(function (error) {
|
|
544
|
-
console.error(error);
|
|
545
|
-
modelHash[entity.id].loadFail = true;
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
616
|
export default ModelVisualizer;
|
|
@@ -21,7 +21,7 @@ function createPolygonHierarchyProperty(value) {
|
|
|
21
21
|
* Initialization options for the PolygonGraphics constructor
|
|
22
22
|
*
|
|
23
23
|
* @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the polygon.
|
|
24
|
-
* @property {Property | PolygonHierarchy} [hierarchy] A Property specifying the {@link PolygonHierarchy}.
|
|
24
|
+
* @property {Property | PolygonHierarchy | Cartesian3[]} [hierarchy] A Property specifying the {@link PolygonHierarchy}.
|
|
25
25
|
* @property {Property | number} [height=0] A numeric Property specifying the altitude of the polygon relative to the ellipsoid surface.
|
|
26
26
|
* @property {Property | HeightReference} [heightReference=HeightReference.NONE] A Property specifying what the height is relative to.
|
|
27
27
|
* @property {Property | number} [extrudedHeight] A numeric Property specifying the altitude of the polygon's extruded face relative to the ellipsoid surface.
|