new Cesium3DTileset(options)
A 3D Tile set for streaming large-scale heterogeneous 3D geospatial datasets.
Cesium3DTileset.fromUrl。
| Name | Type | Description |
|---|---|---|
options |
Cesium3DTileset.ConstructorOptions |
Object describing initialization options |
Throws:
-
The tile set must be 3D Tiles version 0.0 or 1.0.
- Type
- DeveloperError
Examples
try {
const tileset = await Cesium.Cesium3DTileset.fromUrl(
"Seattle/tileset.json"
);
scene.primitives.add(tileset);
} catch (error) {
console.error(`Error creating tileset: ${error}`);
}
// Enable collision detection between the camera and the tile set.
try {
const tileset = await Cesium.Cesium3DTileset.fromUrl(
"http://localhost:8002/tilesets/Seattle/tileset.json",
{ enableCollision: true }
);
scene.primitives.add(tileset);
} catch (error) {
console.error(`Error creating tileset: ${error}`);
}
// Common settings for skipLevelOfDetail optimization
const tileset = await Cesium.Cesium3DTileset.fromUrl(
"http://localhost:8002/tilesets/Seattle/tileset.json", {
skipLevelOfDetail: true,
baseScreenSpaceError: 1024,
skipScreenSpaceErrorFactor: 16,
skipLevels: 1,
immediatelyLoadDesiredLevelOfDetail: false,
loadSiblings: false,
cullWithChildrenBounds: true
});
scene.primitives.add(tileset);
// Common settings for dynamicScreenSpaceError optimization
const tileset = await Cesium.Cesium3DTileset.fromUrl(
"http://localhost:8002/tilesets/Seattle/tileset.json", {
dynamicScreenSpaceError: true,
dynamicScreenSpaceErrorDensity: 2.0e-4,
dynamicScreenSpaceErrorFactor: 24.0,
dynamicScreenSpaceErrorHeightFalloff: 0.25
});
scene.primitives.add(tileset);
Members
-
allTilesLoadedEvent
-
Used to indicate that all tiles in this frame that meet the screen space error have been loaded. At this point, the tile set has been fully loaded in this view.
This event is triggered at the end of the frame after rendering the scene.
- Default Value: new Event()
- See:
Example
tileset.allTilesLoaded.addEventListener(function() {
console.log('All tiles are loaded');
});
readonly assetobject
Retrieve the asset object properties of the tile set, which contain metadata about the tile set.
For a complete set of attributes, please refer to the asset mode reference in the 3D Tiles specification.
backFaceCullingboolean
Should we exclude the back geometry. When true, the backside removal is determined by the doubleSided attribute of the glTF material; When false, backside removal is disabled.
- Default Value: true
(deprecated, readonly) basePathstring
The relative base path of non absolute paths in the tile set JSON file.
baseScreenSpaceErrornumber
The screen space error that must be achieved before skipping levels of detail.
Only used when Cesium3DTileset # skipLevelOfDetail is true.
- Default Value: 1024
readonly boundingSphereBoundingSphere
The boundary sphere of the tile set.
Example
const tileset = await Cesium.Cesium3DTileset.fromUrl("http://localhost:8002/tilesets/Seattle/tileset.json");
viewer.scene.primitives.add(tileset);
// Set the camera to view a newly added tile set
viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));
cacheBytesnumber
The amount of GPU memory (in bytes) used for caching tiles. This memory usage is estimated based on the geometry, texture, and batch table texture of the loaded tiles. For point clouds, this value also includes metadata for each point.
Tiles that are not in the view will be unloaded to enforce this restriction.
If reducing this value results in unloading tiles, the tiles will be unloaded in the next frame.
If the current view requires tiles larger than the cache bytes size to meet the required screen space error determined by Cesium3DTileset # maximumScreenSpaceError, then the memory usage of the loaded tiles will exceed the maximum cache bytes of maximumCacheOverflow bytes. For example, if the cache bytes are 500000 but 600000 bytes of tiles are needed to meet the screen space error, then 600000 bytes of tiles may be loaded (if the maximum cache overflow bytes are at least 100000). When these tiles are removed from the view, they will be unloaded.
- Default Value: 536870912
readonly classificationTypeClassificationType
Determine whether terrain, 3D tiles, or both will be classified by this tile set.
This option is only applicable to tile sets that contain batch 3D models, glTF content, geometric data, or vector data. Even if undefined, vector and geometric data must be rendered as classification and will be rendered on terrain and other 3D Tile sets by default.
When enabling batch processing of 3D models and glTF tile sets, glTF has some requirements/limitations:
- glTF cannot contain morph targets, skins, or animations.
- glTF cannot contain the EXT_mesh_gpu_instancing extension.
- Only meshes with TRIANGLES can be used to classify other assets.
- The mesh must be watertight.
- POSITION semantics are required.
- If both _BATCHID and index buffer exist, all indices with the same batch ID must occupy a contiguous portion of the index buffer.
- If _BATCHID exists but no index buffer, all positions with the same batch ID must occupy a contiguous portion of the position buffer.
In addition, point or instantiated 3D models do not support classification.
The 3D tiles or terrain that receive classification must be opaque.
- Default Value: undefined
clippingPlanesClippingPlaneCollection
The ClippingPlaneCollection used to selectively disable rendering the tileset.
colorBlendAmountnumber
Define the value used for linear interpolation between source color and feature color when Cesium3DTileset # colorBlendMode is MIX. When the value is 0.0, the result is the source color, and when the value is 1.0, the result is the feature color. Any value in between will result in a mixture of the source color and the feature color.
- Default Value: 0.5
colorBlendModeCesium3DTileColorBlendMode
Define how the color of each feature set from Cesium API or declarative style blends with the source color of the original feature, such as the color of each point in glTF material or tile.
- Default Value: Cesium3DTileColorBlendMode.HIGHLIGHT
cullRequestsWhileMovingboolean
Optimize options. Do not request tiles that may not be used upon return due to camera movement. This optimization is only applicable to stationary tile sets.
- Default Value: true
cullRequestsWhileMovingMultipliernumber
Optimize options. The multiplier used to exclude requests during movement. The larger the value, the more actively it is eliminated; The smaller the value, the less proactive the exclusion.
- Default Value: 60.0
customShaderCustomShader undefined
A custom shader applied to all tiles in the tile set. Only for use with Model content. Using custom shaders with Cesium3DTileStyle may result in undefined behavior.
- Default Value: undefined
debugColorizeTilesboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, assign a random color to each tile. This is very useful for visualizing which features belong to which tiles, especially in additive refinement where the features of the parent tile may overlap with those of the child tile.
- Default Value: false
debugFreezeFrameboolean
This property is only for debugging purposes; It has not been optimized for production use.
Determine whether to render using only the tiles from the previous frame. This effectively freezes the tile set to the previous frame, allowing you to zoom out and view the rendered content.
- Default Value: false
debugShowBoundingVolumeboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, render the boundary volume of each visible tile. If the tile has a content boundary volume or is empty, the boundary volume is white; Otherwise, it will be red. The tiles that do not conform to the screen space error and are still being refined to their descendants are yellow.
- Default Value: false
debugShowContentBoundingVolumeboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, render the boundary volume of each visible tile content. If the tile has a content boundary volume, the boundary volume is blue; Otherwise, it will be red.
- Default Value: false
debugShowGeometricErrorboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, draw labels to indicate the geometric error of each tile.
- Default Value: false
debugShowMemoryUsageboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, draw labels to indicate the geometric and texture memory usage of each tile.
- Default Value: false
debugShowRenderingStatisticsboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, draw labels to indicate the number of commands, points, triangles, and features for each tile.
- Default Value: false
debugShowUrlboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, draw labels to indicate the URL of each tile.
- Default Value: false
debugShowViewerRequestVolumeboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, render the viewer request volume for each tile.
- Default Value: false
debugWireframeboolean
This property is only for debugging purposes; It has not been optimized for production use.
When true, render the content of each tile as a wireframe.
- Default Value: false
deprecated disableCollisionboolean
Whether to turn off camera collision or pickup collision detection. When this value is true, if ScreenSpaceComeraController # enableCollisionDetection is true, the camera will be allowed to enter or fall below the tile set surface.
- Default Value: true
dynamicScreenSpaceErrorboolean
Optimize options. For street level horizon views, use low resolution tiles that are further away from the camera. This reduces the amount of data loaded and improves the loading time of tile sets, while slightly reducing the visual quality in the distance.
When the camera is close to the ground plane of the tile set and looks towards the horizon, this optimization effect is strongest. In addition, for tightly fitted boundary volumes such as boxes and regions, the results are more accurate.
- Default Value: true
dynamicScreenSpaceErrorDensitynumber
Similar to Fog # density, this option controls the camera distance for Cesium3DTile set # dynamicScreenSpaceError optimization. The larger the value, the closer the tiles are to the camera will be affected. This value must be non negative.
This optimization works by reducing tile screen spatial error (SSE) with camera distance like a bell shaped curve. This has the effect of selecting low resolution tiles that are far away from the camera. Near the camera, no adjustments are made. For farther tiles, SSE can reduce Cesium3DTileset # dynamicScreenSpaceError Factor (in error pixels) at most.
Increasing density will narrow the bell shaped curve, thereby affecting tiles closer to the camera. This is similar to moving fog closer to a camera.
When the density is 0, optimization has no effect on the tile set.
- Default Value: 2.0e-4
dynamicScreenSpaceErrorFactornumber
Control the parameters for optimizing the strength of Cesium3DTileset # dynamicScreenSpaceError horizon tiles. The larger the value, the lower the resolution of the loaded tiles, thereby improving performance at the cost of slightly reducing visual quality. This value must be non negative.
More specifically, this parameter represents the maximum adjustment (in pixels) for the screen space error (SSE) of tiles that are far away from the camera. For more detailed information on how this optimization works, please refer to Cesium3DTile # dynamicScreenSpaceError Density.
When the SSE factor is set to 0, optimization has no effect on the tile set.
- Default Value: 24.0
dynamicScreenSpaceErrorHeightFalloffnumber
The ratio of tile set heights is used to determine the "street level" optimization for Cesium3DTileset # dynamicScreenSpaceError. When the camera is below this height, dynamic screen spatial error optimization will produce the maximum effect, and above this value, it will gradually weaken. The valid values are between 0.0 and 1.0.
- Default Value: 0.25
readonly ellipsoidEllipsoid
Obtain an ellipsoid that describes the shape of the Earth.
enableCollisionboolean
If true, allow camera collision or pickup collision detection. When this value is true and ScreenSpaceComeraController # enableCollisionDetection is true, the camera will be blocked from entering or falling below the tile set surface. If the tile set contains tiles with a large number of vertices, this may have an impact on performance.
- Default Value: false
examineVectorLinesFunctionfunction
A function used to check vector lines during streaming transmission.
readonly extensionsobject
Gets the tileset's extensions object property.
readonly extras*
Return the extras attribute at the top level of the tile set JSON, which contains application specific metadata. If extras do not exist, return undefined.
featureIdLabelstring
The label of the feature ID set used for picking and styling.
For EXT_stesh_features, this is the label attribute of the feature ID, or when not specified, it is "featureId-N" (where N is the index in the featureIds array). EXT_feature_stetadata does not have a label field, so this type of feature ID set is always marked as "featureId-N", where N is the index in the list of all feature IDs, and the feature ID attribute is listed before the feature ID texture.
If featureIdLabel is set to an integer N, it will automatically convert to the string 'featureId-N'. If both the feature ID of each element and the feature ID of each instance exist, the instance feature ID takes priority.
foveatedConeSizenumber
Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true to control the cone size used to determine which tiles are delayed loaded. The tiles inside this cone will be loaded immediately. The tiles outside the cone may be delayed in loading based on their distance from the cone, as well as Cesium3DTileset # foveatedInterpolationcallbacks and Cesium3DTileset # foveatedMinimumScreenSpaceError Correlation. Setting this value to 0.0 means that the cone will be a line formed by the camera position and its viewing direction. Setting this value to 1.0 means that the cone contains the entire field of view of the camera, effectively disabling this effect.
- Default Value: 0.3
foveatedInterpolationCallbackCesium3DTileset.foveatedInterpolationCallback
Get or set a callback function to control how to increase the screen space error of the foveated cone outer tile, interpolating between Cesium3DTileset # foveatedMinimumScreenSpaceError Correlation and Cesium3DTileset # maximumScreenSpaceError.
foveatedMinimumScreenSpaceErrorRelaxationnumber
Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true to control the initial screen space error relaxation value of the concave cone outer tile. Based on the provided Cesium3DTile set # hoveatedInterpolationcallbacks, the screen space error will increase from this value until Cesium3DTile set # maximumScreenSpaceError.
- Default Value: 0.0
foveatedScreenSpaceErrorboolean
Optimize options. Prioritize loading the central tile of the screen by temporarily increasing the screen space error of the edge tiles. Once all the tiles in the center of the screen (determined by Cesium3DTileset # hoveatedConseSize) are loaded, the screen space error will return to normal.
- Default Value: true
foveatedTimeDelaynumber
Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true, to control how long (in seconds) the camera waits after stopping to load delayed tiles. This time delay can prevent the camera from requesting tiles at the edge of the screen when it moves. Setting to 0.0 will immediately request all tiles in any given view.
- Default Value: 0.2
imageBasedLightingImageBasedLighting
Used to manage the properties of image-based lighting on this tile set.
readonly imageryLayersImageryLayerCollection
Provide a collection of ImageryLayer objects for 2D georeferenced image data, which will be rendered on top of the 3D Tiles dataset.
The image will be overlaid on the surface of tile content of glTF, B3DM, PNTS, or GeoJSON types
- See:
Example
var provider = new SuperMap3D.SuperMapImageryProvider({url : URL_CONFIG.ZF_IMG});
provider.readyPromise.then(function() {
tileset.imageryLayers.addImageryProvider(provider);
});
immediatelyLoadDesiredLevelOfDetailboolean
When true, only tiles that meet the maximum screen space error will be downloaded. The skip factor is ignored and only the required tiles are loaded.
Only used when Cesium3DTileset # skipLevelOfDetail is true.
- Default Value: false
initialTilesLoadedEvent
Used to indicate that all tiles in this frame that meet the screen space error have been loaded. This event is triggered once when all tiles in the initial view have completed loading.
This event is triggered at the end of the frame after rendering the scene.
- Default Value: new Event()
Example
tileset.initialTilesLoaded.addEventListener(function() {
console.log('Initial tiles are loaded');
});
instanceFeatureIdLabelstring
The label of the instance feature ID set used for picking and styling.
If instanceEigenIdLabel is set to an integer N, it will automatically be converted to the string 'instanceEigenId-N'. If both the feature ID of each element and the feature ID of each instance exist, the instance feature ID takes priority.
lightColorCartesian3
The color of the light source when coloring the model. When undefined, use the color of the scene's light source.
For example, disabling additional lighting by setting tileset. imageBasedLightingFactor=new Cartesian2 (0.0, 0.0) will make the tile set darker. Here, increasing the intensity of the light source will make the tile set brighter.
- Default Value: undefined
loadProgressEvent
An event used to indicate the progress of loading new tiles. This event is triggered when a new tile is requested, the requested tile download is completed, and the downloaded tile has been processed and ready for rendering.
The number of pending tile requests numbered OfPendingRequests and the number of tiles being processed numbered OfTilesProcessing will be passed to the event listener.
This event is triggered at the end of the frame after rendering the scene.
- Default Value: new Event()
Example
tileset.loadProgress.addEventListener(function(numberOfPendingRequests, numberOfTilesProcessing) {
if ((numberOfPendingRequests === 0) && (numberOfTilesProcessing === 0)) {
console.log('Stopped loading');
return;
}
console.log(`Loading: requests: ${numberOfPendingRequests}, processing: ${numberOfTilesProcessing}`);
});
loadSiblingsboolean
Determine whether the sibling tiles of visible tiles are always downloaded during traversal. This may be useful for ensuring that tiles are already available when the viewer rotates left/right.
Only used when Cesium3DTileset # skipLevelOfDetail is true.
- Default Value: false
maximumCacheOverflowBytesnumber
The maximum additional GPU memory amount (in bytes) to be used for caching tiles.
If the current view requires tiles that exceed the size of cached bytes plus maximumCacheOverflowbytes to meet the required screen space error determined by Cesium3DTile set # maximumScreenSpaceError, then Cesium3DTile set # memoryAdjustedScreenSpaceError will be adjusted until the required tile usage for the adjusted screen space error is less than cached bytes plus maximumCacheOverflowbytes.
- Default Value: 536870912
maximumScreenSpaceErrornumber
The maximum screen space error used to drive the refinement of detail levels. This value helps determine when tiles are refined to their sub level, thus playing an important role in balancing performance and visual quality.
The screen space error of tiles is roughly equivalent to the pixel width that would be drawn if a sphere with a radius equal to the geometric error of the tile were rendered at the tile position. If this value exceeds the maximumScreenSpaceError, the tile will be refined to its child level.
Depending on the tile set, it may be necessary to adjust the maximum Screen SpaceError to achieve the correct balance. The higher the value, the better the performance, but the lower the visual quality.
- Default Value: 16
modelMatrixMatrix4
A 4x4 transformation matrix used to transform the entire tile set.
- Default Value: Matrix4.IDENTITY
Example
// Adjust the height of the tile set relative to the Earth's surface.
const heightOffset = 20.0;
const boundingSphere = tileset.boundingSphere;
const cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
const surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
const offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
outlineColorColor
The color used when rendering the outline.
- Default Value: Color.BLACK
pointCloudShadingPointCloudShading
Options for controlling point size based on geometric errors and eye dome illumination.
preferLeavesboolean
Optimize options. Prioritize loading leaf tiles.
- Default Value: false
preloadFlightDestinationsboolean
Optimize options. Obtain tiles of the camera's flight destination while the camera is flying.
- Default Value: true
preloadWhenHiddenboolean
Preloading tiles when tileset.show is false. Load tiles as visible as a tile set, but do not render them.
- Default Value: false
progressiveResolutionHeightFractionnumber
Optimize options. If it is between (0.0, 0.5), priority will be given to loading tiles with screen space errors that reach or exceed progressiveResolutionWeightTraction * screenHeight and reduce screen resolution. This helps to quickly load a layer of tiles while continuing to load full resolution tiles.
- Default Value: 0.3
readonly propertiesobject
Retrieve the attribute dictionary object of the tile set, which contains metadata for each feature attribute.
For a complete set of attributes, please refer to the attribute mode reference in the 3D Tiles specification.
Example
console.log(`Maximum building height: ${tileset.properties.height.maximum}`);
console.log(`Minimum building height: ${tileset.properties.height.minimum}`);
readonly resourceResource
Resources for obtaining tile set JSON files
readonly rootCesium3DTile
Root tile.
shadowsShadowMode
Determine whether the tile set projects or receives shadows from the light source.
Enabling shadows can have an impact on performance. The tile set that casts shadows must be rendered twice, once from the camera's perspective and once from the light source's perspective.
Shadows will only be rendered when Viewer # shadows is true.
- Default Value: ShadowMode.ENABLED
showboolean
Decide whether to display the tile set.
- Default Value: true
showCreditsOnScreenboolean
Determine whether the copyright information of the tile set will be displayed on the screen
- Default Value: false
showOutlineboolean
Do you want to display the outline of the model using CESIUM_primitive_outline extension. When true, display the outline. When false, the outline is not displayed.
- Default Value: true
skipLevelOfDetailboolean
Optimize options. Determine whether detail level skipping should be applied during traversal.
The common strategy for replacement refinement traversal is to store all levels of the tree in memory and require all child levels to be loaded before the parent level can be refined. With this optimization, tree levels can be completely skipped, and child levels can be rendered together with the parent level. When using this optimization, the memory required for tile sets is significantly reduced.
- Default Value: false
skipLevelsnumber
A constant that defines the minimum number of layers skipped when loading tiles. When it is 0, no hierarchy is skipped. For example, if the tile is at level 1, only tiles with a level greater than 2 will be loaded.
Only used when Cesium3DTileset # skipLevelOfDetail is true.
- Default Value: 1
skipScreenSpaceErrorFactornumber
Define the multiplier for the minimum screen space error to be skipped. For example, if the screen space error of a tile is 100, no tiles will be loaded unless they are leaf tiles or the screen space error is less than or equal to 100/skipScreenSpace Error Factor.
Only used when Cesium3DTileset # skipLevelOfDetail is true.
- Default Value: 16
splitDirectionSplitDirection
Split Direction applied to this tile set.
- Default Value:
SplitDirection.NONEstyleCesium3DTileStyle undefined
Styles defined using the 3D Tiles style language are applied to each feature in the tile set.
Assign undefined to remove the style, which will restore the visual appearance of the tile set to its default state when the style is not applied.
The style is applied to tiles before the Cesium3DTileset # tileVisible event is triggered, so the code in tileVisible can manually set the properties of features (such as color and display) after the style is applied. When assigning a new style, any manually set attributes will be overwritten.
Use a condition that always remains' true 'to specify the color of all objects that are not covered by existing conditions. Otherwise, the default color Cesium.Color-White will be used. Similarly, use a condition that always remains' true 'to specify the show property for all objects that are not overridden by existing conditions. Otherwise, the default show value of true will be used.
- Default Value: undefined
Example
tileset.style = new Cesium.Cesium3DTileStyle({
color : {
conditions : [
['${Height} >= 100', 'color("purple", 0.5)'],
['${Height} >= 50', 'color("red")'],
['true', 'color("blue")']
]
},
show : '${Height} > 0',
meta : {
description : '"Building id ${id} has height ${Height}."'
}
});
tileFailedEvent
Used to indicate the event of tile content loading failure.
If there is no event listener, error messages will be logged to the console.
The error object passed to the listener contains two properties:
- url: The URL of the failed tile.
- message: The error message.
If there are multiple contents, this event will be triggered once for each internal content with errors.
- Default Value: new Event()
Example
tileset.tileFailed.addEventListener(function(error) {
console.log(`An error occurred loading tile: ${error.url}`);
console.log(`Error: ${error.message}`);
});
tileLoadEvent
An event used to indicate that tile content has been loaded.
The loaded Cesium3DTile will be passed to the event listener.
This event is triggered during the tile set traversal in the frame rendering process, so that updates to the tiles take effect in the same frame. Do not create or modify Cesium entities or primitives in the event listener.
- Default Value: new Event()
Example
tileset.tileLoad.addEventListener(function(tile) {
console.log('A tile was loaded.');
});
readonly tilesLoadedboolean
When true, all tiles that meet the current frame screen space error have been loaded. The tile set for this view has been fully loaded.
- Default Value: false
tileUnloadEvent
An event used to indicate that tile content has been uninstalled.
The uninstalled Cesium3DTile will be passed to the event listener.
This event is triggered immediately before the tile content is unloaded during frame rendering, so that the event listener can access the tile content. Do not create or modify Cesium entities or primitives in the event listener.
- Default Value: new Event()
Example
tileset.tileUnload.addEventListener(function(tile) {
console.log('A tile was unloaded from the cache.');
});
tileVisibleEvent
This event is triggered once for each visible tile in a frame. Can be used to manually set the style of tile sets.
The visible Cesium3DTile will be passed to the event listener.
This event is triggered during the tile set traversal in the frame rendering process, so that updates to the tiles take effect in the same frame. Do not create or modify Cesium entities or primitives in the event listener.
- Default Value: new Event()
Examples
tileset.tileVisible.addEventListener(function(tile) {
if (tile.content instanceof Cesium.Model3DTileContent) {
console.log('A 3D model tile is visible.');
}
});
// Apply the red style, then manually set a random color for every other feature when the tile becomes visible.
tileset.style = new Cesium.Cesium3DTileStyle({
color : 'color("red")'
});
tileset.tileVisible.addEventListener(function(tile) {
const content = tile.content;
const featuresLength = content.featuresLength;
for (let i = 0; i < featuresLength; i+=2) {
content.getFeature(i).color = Cesium.Color.fromRandom();
}
});
readonly timeSinceLoadnumber
Returns the time (in milliseconds) since the tile set was loaded and first updated.
readonly totalMemoryUsageInBytesnumber
The total amount of GPU memory in bytes used by the tileset. This value is estimated from geometry, texture, batch table textures, and binary metadata of loaded tiles.
vectorClassificationOnlyboolean
Indicate that only vector tiles from tile sets should be used for classification.
- Default Value: false
vectorKeepDecodedPositionsboolean
Should vector tiles retain the decoding position in memory. This is used in conjunction with Cesium3DTileFeature.golylinePositions.
- Default Value: false
Methods
-
static fromIonAssetId(assetId, options){Promise.<Cesium3DTileset>}
-
Create a 3D Tile set from Cesium ion asset ID for streaming large-scale heterogeneous 3D geospatial datasets.
Name Type Description assetIdnumber Cesium ion asset ID.
optionsCesium3DTileset.ConstructorOptions optional Object describing initialization options
- See:
-
- Cesium3DTileset#fromUrl
Throws:
-
When the tile set asset version is not 0.0, 1.0, or 1.1, or when the tile set contains unsupported necessary extensions.
- Type
- RuntimeError
Returns:
Type Description Promise.<Cesium3DTileset> Example
// Load Cesium3DTileset with Cesium ion asset ID 124624234 try { const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(124624234); scene.primitives.add(tileset); } catch (error) { console.error(`Error creating tileset: ${error}`); } -
static fromUrl(url, options){Promise.<Cesium3DTileset>}
-
Create a 3D Tile set for streaming large-scale heterogeneous 3D geospatial datasets.
Name Type Description urlResource | string The URL pointing to the tileset JSON file.
optionsCesium3DTileset.ConstructorOptions optional Object describing initialization options
- See:
-
- Cesium3DTileset#fromIonAssetId
Throws:
-
When the tile set asset version is not 0.0, 1.0, or 1.1, or when the tile set contains unsupported necessary extensions.
- Type
- RuntimeError
Returns:
Type Description Promise.<Cesium3DTileset> Examples
try { const tileset = await Cesium.Cesium3DTileset.fromUrl( "http://localhost:8002/tilesets/Seattle/tileset.json" ); scene.primitives.add(tileset); } catch (error) { console.error(`Error creating tileset: ${error}`); }// Common settings for skipLevelOfDetail optimization const tileset = await Cesium.Cesium3DTileset.fromUrl( "http://localhost:8002/tilesets/Seattle/tileset.json", { skipLevelOfDetail: true, baseScreenSpaceError: 1024, skipScreenSpaceErrorFactor: 16, skipLevels: 1, immediatelyLoadDesiredLevelOfDetail: false, loadSiblings: false, cullWithChildrenBounds: true }); scene.primitives.add(tileset);// Common settings for the dynamicScreenSpaceError optimization const tileset = await Cesium.Cesium3DTileset.fromUrl( "http://localhost:8002/tilesets/Seattle/tileset.json", { dynamicScreenSpaceError: true, dynamicScreenSpaceErrorDensity: 2.0e-4, dynamicScreenSpaceErrorFactor: 24.0, dynamicScreenSpaceErrorHeightFalloff: 0.25 }); scene.primitives.add(tileset); -
static loadJson(tilesetUrl){Promise.<object>}
-
Providing a hook to override the method for requesting tile set JSON is useful when retrieving tile sets from remote servers
Name Type Description tilesetUrlResource | string The URL of the JSON file to be obtained
Returns:
Type Description Promise.<object> Resolve the Promise to the obtained JSON data -
destroy()
-
Destroy the WebGL resources held by this object. Destroying objects allows for deterministic release of WebGL resources, rather than relying on garbage collectors to destroy the object. Once the object is destroyed, it should not be used; Calling any function other than isDestroyed will result in a Developer Error exception. Therefore, as shown in the example, assign the return value (undefined) to the object.
Throws:
-
This object has been destroyed, that is, destroy() has been called.
- Type
- DeveloperError
Example
tileset = tileset && tileset.destroy(); -
-
getHeight(cartographic, scene){number|undefined}
-
Obtain the loading surface height for the customized image location. This function only considers the grid of loaded tiles and may not be the most detailed tile available in the tile set. When sampling the laser point cloud, this function always returns undefined.
Name Type Description cartographicCartographic To search for the mapping location of the height.
sceneScene Visualize the scene that occurs.
Returns:
Type Description number | undefined The height of the mapping location is undefined if it cannot be found. Example
const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(124624234); scene.primitives.add(tileset); const height = tileset.getHeight(scene.camera.positionCartographic, scene); -
getTraversal(passOptions){function}
-
Obtain tile traversal strategy, skip based on channel type and whether detail level is enabled.
Name Type Description passOptionsobject Channel options
Returns:
Type Description function Tile traversal function -
hasExtension(extensionName){boolean}
-
If the tile set JSON file lists the extension in extendesUsed, then it is true; Otherwise, it is false.
Name Type Description extensionNamestring The name of the extension to be checked.
Returns:
Type Description boolean If the tile set JSON file lists the extension in extendesUsed, then it is true; Otherwise, it is false. -
isDestroyed(){boolean}
-
If this object has been destroyed, return true; Otherwise, return false. If this object has been destroyed, it should not be used; Calling any function other than isDestroyed will result in a Developer Error exception.
Returns:
Type Description boolean If this object has been destroyed, return true; Otherwise, return false. -
makeStyleDirty()
-
Marking the Cesium3DTile set # style as dirty will force all features to re evaluate the style the next time they are visible.
-
trimLoadedTiles()
-
Uninstall all tiles that were not selected in the previous frame. This can be used to explicitly manage tile caching and reduce the total number of loaded tiles to below Cesium3DTile set # cachebytes.
Tile unloading occurs in the next frame to keep all WebGL deletion calls within the rendering loop.
Type Definitions
-
ConstructorOptionsObject
-
Initialization options for Cesium3DTileset constructor
Properties:
Name Type Default Description showboolean true optional Decide whether to display tileset.
modelMatrixMatrix4 Matrix4.IDENTITY optional A 4x4 transformation matrix used to transform the root tiles of tiles.
modelUpAxisAxis Axis.Y optional When loading the tile content model, it is considered as an upward axis.
modelForwardAxisAxis Axis.X optional When loading the tile content model, it is considered as the forward axis.
shadowsShadowMode ShadowMode.ENABLED optional Decide whether tileset projects or receives shadows from light sources.
maximumScreenSpaceErrornumber 16 optional The maximum screen space error used to drive the refinement of detail levels.
cacheBytesnumber 536870912 optional If the cache contains tiles that are not needed by the current view, the tile cache will be cropped to a size in bytes.
maximumCacheOverflowBytesnumber 536870912 optional If the current view requires more tiles than Cesium3DTileset # cachebytes, the maximum allowed additional memory (in bytes).
cullWithChildrenBoundsboolean true optional Optimize options. Should we use the union of sub tile boundary volumes to remove tiles.
cullRequestsWhileMovingboolean true optional Optimize options. Do not request tiles that may not be used upon return due to camera movement. This optimization is only applicable to stationary tiles.
cullRequestsWhileMovingMultipliernumber 60.0 optional Optimize options. The multiplier used to exclude requests during movement. The larger the value, the more actively it is eliminated; The smaller the value, the less proactive the exclusion.
preloadWhenHiddenboolean false optional Preloading tiles when tileset.show is false. Load tiles as visible as tiles, but do not render them.
preloadFlightDestinationsboolean true optional Optimize options. Preload the tiles of the camera's flight destination during its flight.
preferLeavesboolean false optional Optimize options. Prioritize loading leaf tiles.
dynamicScreenSpaceErrorboolean true optional Optimize options. For street level horizon views, use low resolution tiles that are further away from the camera. This reduces the amount of data loaded and improves tile loading time, while slightly reducing the visual quality in the distance.
dynamicScreenSpaceErrorDensitynumber 2.0e-4 optional Similar to Fog # density, this option controls the camera distance for Cesium3DTile set # dynamicScreenSpaceError optimization. The larger the value, the closer the tiles are to the camera will be affected.
dynamicScreenSpaceErrorFactornumber 24.0 optional Control the parameters for optimizing the strength of Cesium3DTileset # dynamicScreenSpaceError horizon tiles. The larger the value, the lower the resolution of the loaded tiles, thereby improving performance at the cost of slightly reducing visual quality.
dynamicScreenSpaceErrorHeightFalloffnumber 0.25 optional The ratio of tileset height is used to determine the position of the "street level" camera view. When the camera is below this height, Cesium3DTileset # dynamicScreenSpaceError optimization will produce the maximum effect, and above this value, it will gradually weaken.
progressiveResolutionHeightFractionnumber 0.3 optional Optimize options. If it is between (0.0, 0.5), priority will be given to loading tiles with screen space errors that reach or exceed progressiveResolutionWeightTraction * screenHeight and reduce screen resolution. This helps to quickly load a layer of tiles while continuing to load full resolution tiles.
foveatedScreenSpaceErrorboolean true optional Optimize options. Prioritize loading the central tile of the screen by temporarily increasing the screen space error of the edge tiles. Once all the tiles in the center of the screen (determined by Cesium3DTileset # hoveatedConseSize) are loaded, the screen space error will return to normal.
foveatedConeSizenumber 0.1 optional Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true to control the cone size that determines which tiles are delayed loaded. The tiles inside the cone are immediately loaded. The tiles outside the cone may be delayed in loading due to their distance from the cone and screen space errors. This is controlled by Cesium3DTileset # foveatedInterpolationcallbacks and Cesium3DTileset # foveatedMinimumScreenSpaceError Correlation. Setting it to 0.0 means that the cone will be a straight line formed by the camera position and its view direction. Set to 1.0 to indicate that the cone contains the entire field of view of the camera, disable this effect.
foveatedMinimumScreenSpaceErrorRelaxationnumber 0.0 optional Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true to control the initial screen space error relaxation value of the cone-shaped outer tile. The screen space error will start from this value and increase to Cesium3DTileset # maximumScreenSpaceError based on the provided Cesium3DTileset # foveatedInterpolationcallbacks.
foveatedInterpolationCallbackCesium3DTileset.foveatedInterpolationCallback Math.lerp optional Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true to control the degree of increase in screen space error of the cone-shaped tiles. Interpolation is performed between Cesium3DTileset # foveatedMinimumScreenSpaceError Correlation and Cesium3DTileset # maximumScreenSpaceError
foveatedTimeDelaynumber 0.2 optional Optimize options. Used when Cesium3DTileset # foveatedScreenSpaceError is true, to control how long (in seconds) the camera waits after stopping to load delayed tiles. This time delay can prevent the camera from requesting tiles at the edge of the screen when it moves. Setting to 0.0 will immediately request all tiles in any given view.
skipLevelOfDetailboolean false optional Optimize options. Determine whether detail level skipping should be applied during traversal.
baseScreenSpaceErrornumber 1024 optional When skipLevelOfDetail is true, the screen space error that must be achieved before the detail level can be skipped.
skipScreenSpaceErrorFactornumber 16 optional When skipLevelOfDetail is true, define the multiplier for the minimum screen space error to be skipped. Use with skipLevels to determine which tiles to load.
skipLevelsnumber 1 optional When skipLevelOfDetail is true, define the minimum number of levels to skip when loading tiles. When it is 0, no level is skipped. Used in conjunction with skipScreenSpace Error Factor to determine which tiles to load.
immediatelyLoadDesiredLevelOfDetailboolean false optional When skipLevelOfDetail is true, only tiles that meet the maximum screen space error will be downloaded. Skip factors are ignored and only the required tiles are loaded.
loadSiblingsboolean false optional When skipLevelOfDetail is true, it determines whether the sibling tiles of visible tiles are always downloaded during traversal.
clippingPlanesClippingPlaneCollection optional ClippingPlaneCollection is used to selectively disable tile rendering.
classificationTypeClassificationType optional Determine whether this tile will classify terrain, 3D tiles, or both. For detailed information on restrictions and limitations, please refer to Cesium3DTile # classicType.
ellipsoidEllipsoid Ellipsoid.WGS84 optional An ellipsoid that determines the size and shape of the Earth.
pointCloudShadingobject optional Options for constructing PointCloudShading objects to control point decay based on geometric errors and lighting.
lightColorCartesian3 optional The color of the light source when coloring the model. When undefined, use the color of the scene's light source.
imageBasedLightingImageBasedLighting optional Used to manage the image-based lighting properties of this tile.
backFaceCullingboolean true optional Should we exclude the back geometry. When true, the backside removal is determined by the doubleSided attribute of the glTF material; When false, backside removal is disabled.
enableShowOutlineboolean true optional Whether to enable contouring for models using the CESIUM_primitive_outline extension. It can be set to false to avoid additional processing of geometry during loading. When false, the showOutlines and outlineColor options are ignored.
showOutlineboolean true optional Do you want to display the outline of the model using CESIUM_primitive_outline extension. When true, display the outline. When false, the outline is not displayed.
outlineColorColor Color.BLACK optional The color used when rendering the outline.
vectorClassificationOnlyboolean false optional Indicate that only tile vector tiles should be used for classification.
vectorKeepDecodedPositionsboolean false optional Should vector tiles retain the decoding position in memory. This is used in conjunction with Cesium3DTileFeature.golylinePositions.
featureIdLabelstring | number "featureId_0" optional The label of the feature ID set used for picking and styling. For EXT_cesh_features, this is the label attribute of the feature ID, which is "featureId-N" when not specified (where N is the index in the featureIds array). EXT_feature_stetadata does not have a label field, so this type of feature ID set is always marked as "featureId-N", where N is the index in the list of all feature IDs, and the feature ID attribute is listed before the feature ID texture. If featureIdLabel is an integer N, it will automatically convert to the string 'featureId-N'. If there are feature IDs for both each element and each instance, the instance feature ID takes precedence.
instanceFeatureIdLabelstring | number "instanceFeatureId_0" optional The label of the instance feature ID set used for picking and styling. If instanceEigenIdLabel is set to an integer N, it will automatically be converted to the string 'instanceEigenId-N'. If there are feature IDs for both each element and each instance, the instance feature ID takes precedence.
showCreditsOnScreenboolean false optional Whether to display the credits of this tile on the screen.
splitDirectionSplitDirection SplitDirection.NONE optional Split Direction segmentation applied to this tile.
enableCollisionboolean false optional When true, enable collision detection picked up by the camera or CPU. When this value is true and ScreenSpaceComeraController # enableCollisionDetection is true, the camera will be prevented from entering below the tilset surface.
disableCollisionboolean true optional Whether to turn off camera collision or pickup collision detection. When this value is true and ScreenSpaceComeraController # enableCollisionDetection is true, the camera will be allowed to enter or fall below the tile surface. Abandoned.
projectTo2Dboolean false optional Whether to accurately project tile set to 2D. If true, tile set will be accurately projected to 2D, but it will use more memory. If false, tileset will use less memory and still render in 2D/CV mode, but its projection position may not be accurate. This setting cannot be changed after tileset is created.
enablePickboolean false optional Is it allowed to use pick for collision and CPU picking when using WebGL 1. If using WebGL 2 or higher version, this option will be ignored. If WebGL 1 is used and this value is true, the pick operation will work properly, but it will use more memory. If WebGL 1 is used and this value is false, the model will use less memory, but pick will always return undefined. This setting cannot be changed after tiliset is loaded.
asynchronouslyLoadImageryboolean false optional Should the loading of images overlaid on tiles be done asynchronously. If true, the tile content will display its original texture until the image texture is loaded. If false, tile content will not be displayed until the image is ready.
debugHeatmapTilePropertyNamestring optional The tile variable to be colored as a heatmap. All rendered tiles will be colored based on each other's specified variable values.
debugFreezeFrameboolean false optional Only for debugging purposes. Determine whether to render using only the tiles from the previous frame.
debugColorizeTilesboolean false optional Only for debugging purposes. When true, assign a random color to each tile.
enableDebugWireframeboolean false optional Only for debugging purposes. In WebGL1, this value must be true for debugWireframe to work. This setting cannot be changed after tileset is created.
debugWireframeboolean false optional Only for debugging purposes. When true, render the content of each tile as a wireframe.
debugShowBoundingVolumeboolean false optional Only for debugging purposes. When true, render the boundary volume of each tile.
debugShowContentBoundingVolumeboolean false optional Only for debugging purposes. When true, render the boundary volume of each tile content.
debugShowViewerRequestVolumeboolean false optional Only for debugging purposes. When true, render the viewer request volume for each tile.
debugShowGeometricErrorboolean false optional Only for debugging purposes. When true, draw labels to indicate the geometric error of each tile.
debugShowRenderingStatisticsboolean false optional Only for debugging purposes. When true, draw labels to indicate the number of commands, points, triangles, and features for each tile.
debugShowMemoryUsageboolean false optional Only for debugging purposes. When true, draw labels to indicate the texture and geometric memory (in megabytes) used by each tile.
debugShowUrlboolean false optional Only for debugging purposes. When true, draw labels to indicate the URL of each tile.
-
foveatedInterpolationCallback(p, q, time){number}
-
Optimize options. When Cesium3DTileset # hoveatedScreenSpaceError is true, it is used as a callback to control how to improve the screen space error of the concave cone tiles. Interpolation is performed between Cesium3DTileset # hoveatedMinimumScreenSpaceError Correlation and Cesium3DTileset # maximumScreenSpaceError.
Name Type Description pnumber The starting value to be interpolated.
qnumber The end value to be interpolated.
timenumber The interpolation time is usually within the range of [0.0, 1.0].
- Default Value: Math.lerp
Returns:
| Type | Description |
|---|---|
| number | The interpolated value. |