# Model

#### internal constructor new Cesium.Model()
engine/Source/Scene/Model/Model.js 162

To construct a Model, call `Model.fromGltf`. Do not call the constructor directly.
A 3D model based on glTF, the runtime asset format for WebGL, OpenGL ES, and OpenGL.

Cesium supports glTF assets with the following extensions:

- AGI_articulations
- CESIUM_primitive_outline
- CESIUM_RTC
- EXT_instance_features
- EXT_mesh_features
- EXT_mesh_gpu_instancing
- EXT_meshopt_compression
- EXT_structural_metadata
- EXT_texture_webp
- KHR_draco_mesh_compression
- KHR_techniques_webgl
- KHR_materials_common
- KHR_materials_pbrSpecularGlossiness
- KHR_materials_unlit
- KHR_mesh_quantization
- KHR_texture_basisu
- KHR_texture_transform
- WEB3D_quantized_attributes

Note: for models with compressed textures using the KHR_texture_basisu extension, we recommend power of 2 textures in both dimensions for maximum compatibility. This is because some samplers require power of 2 textures (Using textures in WebGL) and KHR_texture_basisu requires multiple of 4 dimensions (KHR_texture_basisu additional requirements).

##### Demo:

- Cesium Sandcastle Models Demo

##### See:

- Model.fromGltf

### Members

#### readonly activeAnimations : ModelAnimationCollection
engine/Source/Scene/Model/Model.js 742

The currently playing glTF animations.

#### backFaceCulling : boolean
engine/Source/Scene/Model/Model.js 1418

Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if `Model#color` is translucent or `Model#silhouetteSize` is greater than 0.0.

Default Value: `true`

#### readonly boundingSphere : BoundingSphere
engine/Source/Scene/Model/Model.js 1153

Gets the model's bounding sphere in world space. This does not take into account glTF animations, skins, or morph targets. It also does not account for `Model#minimumPixelSize`.

#### clampAnimations : boolean
engine/Source/Scene/Model/Model.js 756

Determines if the model's animations should hold a pose over frames where no keyframes are specified.

Default Value: `true`

#### readonly classificationType : ClassificationType
engine/Source/Scene/Model/Model.js 1618

Gets the model's classification type. This determines whether terrain, 3D Tiles, or both will be classified by this model.

Additionally, there are a few requirements/limitations:

- The glTF cannot contain morph targets, skins, or animations.
- The glTF cannot contain the `EXT_mesh_gpu_instancing` extension.
- Only meshes with TRIANGLES can be used to classify other assets.
- The position attribute is required.
- If feature IDs and an index buffer are both present, all indices with the same feature id must occupy contiguous sections of the index buffer.
- If feature IDs are present without an index buffer, all positions with the same feature id must occupy contiguous sections of the position buffer.

Default Value: `undefined`

##### Experimental

This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

#### clippingPlanes : ClippingPlaneCollection
engine/Source/Scene/Model/Model.js 1337

The `ClippingPlaneCollection` used to selectively disable rendering the model.

#### color : Color
engine/Source/Scene/Model/Model.js 1042

The color to blend with the model's rendered color.

Default Value: `undefined`

#### colorBlendAmount : number
engine/Source/Scene/Model/Model.js 1081

Value used to determine the color strength when the `colorBlendMode` is `MIX`. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.

Default Value: `0.5`

#### colorBlendMode : Cesium3DTileColorBlendMode|ColorBlendMode
engine/Source/Scene/Model/Model.js 1063

Defines how the color blends with the model.

Default Value: `ColorBlendMode.HIGHLIGHT`

#### readonly credit : Credit
engine/Source/Scene/Model/Model.js 1545

Gets the credit that will be displayed for the model.

#### customShader : CustomShader
engine/Source/Scene/Model/Model.js 831

The model's custom shader, if it exists. Using custom shaders with a `Cesium3DTileStyle` may lead to undefined behavior.

##### Experimental

This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

#### debugShowBoundingVolume : boolean
engine/Source/Scene/Model/Model.js 1184

This property is for debugging only; it is not for production use nor is it optimized.

Draws the bounding sphere for each draw command in the model.

Default Value: `false`

#### debugWireframe : boolean
engine/Source/Scene/Model/Model.js 1208

This property is for debugging only; it is not for production use nor is it optimized.

Draws the model in wireframe.

Default Value: `false`

#### distanceDisplayCondition : DistanceDisplayCondition
engine/Source/Scene/Model/Model.js 906

Gets or sets the distance display condition, which specifies at what distance from the camera this model will be displayed.

Default Value: `undefined`

#### featureIdLabel : string
engine/Source/Scene/Model/Model.js 1272

Label of the feature ID set to use for picking and styling.

For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures.

If featureIdLabel is set to an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.

##### Experimental

This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

#### heightReference : HeightReference
engine/Source/Scene/Model/Model.js 883

The height reference of the model, which determines how the model is drawn relative to terrain.

Default Value: `{HeightReference.NONE}`

#### id : object
engine/Source/Scene/Model/Model.js 987

A user-defined object that is returned when the model is picked.

Default Value: `undefined`

##### See:

- Scene#pick

#### imageBasedLighting : ImageBasedLighting
engine/Source/Scene/Model/Model.js 1383

The properties for managing image-based lighting on this model.

#### instanceFeatureIdLabel : string
engine/Source/Scene/Model/Model.js 1308

Label of the instance feature ID set used for picking and styling.

If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.

##### Experimental

This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

#### lightColor : Cartesian3
engine/Source/Scene/Model/Model.js 1363

The light color when shading the model. When `undefined` the scene's light color is used instead.

Disabling additional light sources by setting `model.imageBasedLighting.imageBasedLightingFactor = new Cartesian2(0.0, 0.0)` will make the model much darker. Here, increasing the intensity of the light source will make the model brighter.

Default Value: `undefined`

#### maximumScale : number
engine/Source/Scene/Model/Model.js 1503

The maximum scale size for a model. This can be used to give an upper limit to the `Model#minimumPixelSize`, ensuring that the model is never an unreasonable scale.

#### minimumPixelSize : number
engine/Source/Scene/Model/Model.js 1482

The approximate minimum pixel size of the model regardless of zoom. This can be used to ensure that a model is visible even when the viewer zooms out. When `0.0`, no minimum size is enforced.

Default Value: `0.0`

#### modelMatrix : Matrix4
engine/Source/Scene/Model/Model.js 203

The 4x4 transformation matrix that transforms the model from model to world coordinates. When this is the identity matrix, the model is drawn in world coordinates, i.e., Earth's Cartesian WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by `Transforms.eastNorthUpToFixedFrame`.

Default Value: ``Matrix4.IDENTITY``

##### Example:

    const origin = Cesium.Cartesian3.fromDegrees(-95.0, 40.0, 200000.0);
    m.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);

#### outlineColor : Color
engine/Source/Scene/Model/Model.js 446

The color to use when rendering outlines.

Default Value: `Color.BLACK`

#### pointCloudShading : PointCloudShading
engine/Source/Scene/Model/Model.js 807

Point cloud shading settings for controlling point cloud attenuation and lighting. For 3D Tiles, this is inherited from the `Cesium3DTileset`.

#### readonly ready : boolean
engine/Source/Scene/Model/Model.js 667

When `true`, this model is ready to render, i.e., the external binary, image, and shader files were downloaded and the WebGL resources were created. This is set to `true` right before `Model#readyPromise` is resolved.

Default Value: `false`

#### readonly readyPromise : Promise.<Model>
engine/Source/Scene/Model/Model.js 685

Gets the promise that will be resolved when this model is ready to render, i.e. when the external resources have been downloaded and the WebGL resources are created.

This promise is resolved at the end of the frame before the first frame the model is rendered in.

#### scale : number
engine/Source/Scene/Model/Model.js 1442

A uniform scale applied to this model before the `Model#modelMatrix`. Values greater than `1.0` increase the size of the model; values less than `1.0` decrease.

Default Value: `1.0`

#### shadows : ShadowMode
engine/Source/Scene/Model/Model.js 1524

Determines whether the model casts or receives shadows from light sources.

Default Value: `ShadowMode.ENABLED`

#### show : boolean
engine/Source/Scene/Model/Model.js 1241

Whether or not to render the model.

Default Value: `true`

#### showCreditsOnScreen : boolean
engine/Source/Scene/Model/Model.js 1561

Gets or sets whether the credits of the model will be displayed on the screen.

Default Value: `false`

#### showOutline : boolean
engine/Source/Scene/Model/Model.js 437

Whether to display the outline for models using the CESIUM_primitive_outline extension. When true, outlines are displayed. When false, outlines are not displayed.

Default Value: `true`

#### silhouetteColor : Color
engine/Source/Scene/Model/Model.js 1099

The silhouette color.

Default Value: `Color.RED`

#### silhouetteSize : number
engine/Source/Scene/Model/Model.js 1122

The size of the silhouette in pixels.

Default Value: `0.0`

#### splitDirection : SplitDirection
engine/Source/Scene/Model/Model.js 1583

The `SplitDirection` to apply to this model.

Default Value: ``SplitDirection.NONE``

#### style : Cesium3DTileStyle
engine/Source/Scene/Model/Model.js 1023

The style to apply to the features in the model. Cannot be applied if a `CustomShader` is also applied.

### Methods

#### static Cesium.Model.fromGltf(options) → Model
engine/Source/Scene/Model/Model.js 2637

Creates a model from a glTF asset. When the model is ready to render, i.e., when the external binary, image, and shader files are downloaded and the WebGL resources are created, the `Model#readyPromise` is resolved.

The model can be a traditional glTF asset with a .gltf extension or a Binary glTF using the .glb extension.

Name | Type | Description
--- | --- | ---
`options` | object | Object with the following properties:
Name | Type | Default | Description
--- | --- | --- | ---
`url` | string | Resource |  | The url to the .gltf or .glb file.
`basePath` | string | Resource | `''` | optional The base path that paths in the glTF JSON are relative to.
`show` | boolean | `true` | optional Whether or not to render the model.
`modelMatrix` | Matrix4 | `Matrix4.IDENTITY` | optional The 4x4 transformation matrix that transforms the model from model to world coordinates.
`scale` | number | `1.0` | optional A uniform scale applied to this model.
`minimumPixelSize` | number | `0.0` | optional The approximate minimum pixel size of the model regardless of zoom.
`maximumScale` | number |  | optional The maximum scale size of a model. An upper limit for minimumPixelSize.
`id` | object |  | optional A user-defined object to return when the model is picked with `Scene#pick`.
`allowPicking` | boolean | `true` | optional When `true`, each primitive is pickable with `Scene#pick`.
`incrementallyLoadTextures` | boolean | `true` | optional Determine if textures may continue to stream in after the model is loaded.
`asynchronous` | boolean | `true` | optional Determines if model WebGL resource creation will be spread out over several frames or block until completion once all glTF files are loaded.
`clampAnimations` | boolean | `true` | optional Determines if the model's animations should hold a pose over frames where no keyframes are specified.
`shadows` | ShadowMode | `ShadowMode.ENABLED` | optional Determines whether the model casts or receives shadows from light sources.
`releaseGltfJson` | boolean | `false` | optional When true, the glTF JSON is released once the glTF is loaded. This is is especially useful for cases like 3D Tiles, where each .gltf model is unique and caching the glTF JSON is not effective.
`debugShowBoundingVolume` | boolean | `false` | optional For debugging only. Draws the bounding sphere for each draw command in the model.
`enableDebugWireframe` | boolean | `false` | optional For debugging only. This must be set to true for debugWireframe to work in WebGL1. This cannot be set after the model has loaded.
`debugWireframe` | boolean | `false` | optional For debugging only. Draws the model in wireframe. Will only work for WebGL1 if enableDebugWireframe is set to true.
`cull` | boolean | `true` | optional Whether or not to cull the model using frustum/horizon culling. If the model is part of a 3D Tiles tileset, this property will always be false, since the 3D Tiles culling system is used.
`opaquePass` | boolean | `Pass.OPAQUE` | optional The pass to use in the `DrawCommand` for the opaque portions of the model.
`upAxis` | Axis | `Axis.Y` | optional The up-axis of the glTF model.
`forwardAxis` | Axis | `Axis.Z` | optional The forward-axis of the glTF model.
`customShader` | CustomShader |  | optional A custom shader. This will add user-defined GLSL code to the vertex and fragment shaders. Using custom shaders with a `Cesium3DTileStyle` may lead to undefined behavior.
`content` | Cesium3DTileContent |  | optional The tile content this model belongs to. This property will be undefined if model is not loaded as part of a tileset.
`heightReference` | HeightReference | `HeightReference.NONE` | optional Determines how the model is drawn relative to terrain.
`scene` | Scene |  | optional Must be passed in for models that use the height reference property.
`distanceDisplayCondition` | DistanceDisplayCondition |  | optional The condition specifying at what distance from the camera that this model will be displayed.
`color` | Color |  | optional A color that blends with the model's rendered color.
`colorBlendMode` | ColorBlendMode | `ColorBlendMode.HIGHLIGHT` | optional Defines how the color blends with the model.
`colorBlendAmount` | number | `0.5` | optional Value used to determine the color strength when the `colorBlendMode` is `MIX`. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
`silhouetteColor` | Color | `Color.RED` | optional The silhouette color. If more than 256 models have silhouettes enabled, there is a small chance that overlapping models will have minor artifacts.
`silhouetteSize` | number | `0.0` | optional The size of the silhouette in pixels.
`enableShowOutline` | boolean | `true` | optional Whether to enable outlines for models using the CESIUM_primitive_outline extension. This can be set false to avoid post-processing geometry at load time. When false, the showOutlines and outlineColor options are ignored.
`showOutline` | boolean | `true` | optional Whether to display the outline for models using the CESIUM_primitive_outline extension. When true, outlines are displayed. When false, outlines are not displayed.
`outlineColor` | Color | `Color.BLACK` | optional The color to use when rendering outlines.
`clippingPlanes` | ClippingPlaneCollection |  | optional The `ClippingPlaneCollection` used to selectively disable rendering the model.
`lightColor` | Cartesian3 |  | optional The light color when shading the model. When `undefined` the scene's light color is used instead.
`imageBasedLighting` | ImageBasedLighting |  | optional The properties for managing image-based lighting on this model.
`backFaceCulling` | boolean | `true` | optional Whether to cull back-facing geometry. When true, back face culling is determined by the material's doubleSided property; when false, back face culling is disabled. Back faces are not culled if the model's color is translucent.
`credit` | Credit | string |  | optional A credit for the data source, which is displayed on the canvas.
`showCreditsOnScreen` | boolean | `false` | optional Whether to display the credits of this model on screen.
`splitDirection` | SplitDirection | `SplitDirection.NONE` | optional The `SplitDirection` split to apply to this model.
`projectTo2D` | boolean | `false` | optional Whether to accurately project the model's positions in 2D. If this is true, the model will be projected accurately to 2D, but it will use more memory to do so. If this is false, the model will use less memory and will still render in 2D / CV mode, but its positions may be inaccurate. This disables minimumPixelSize and prevents future modification to the model matrix. This also cannot be set after the model has loaded.
`featureIdLabel` | string | number | `"featureId_0"` | optional Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
`instanceFeatureIdLabel` | string | number | `"instanceFeatureId_0"` | optional Label of the instance feature ID set used for picking and styling. If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
`pointCloudShading` | object |  | optional Options for constructing a `PointCloudShading` object to control point attenuation and lighting.
`classificationType` | ClassificationType |  | optional Determines whether terrain, 3D Tiles or both will be classified by this model. This cannot be set after the model has loaded.

##### Returns:

The newly created model.

#### applyArticulations()
engine/Source/Scene/Model/Model.js 1723

Applies any modified articulation stages to the matrix of each node that participates in any articulation. Note that this will overwrite any node transformations on participating nodes.

##### Throws:

- DeveloperError : The model is not loaded. Use Model.readyPromise or wait for Model.ready to be true.

#### destroy()
engine/Source/Scene/Model/Model.js 2501

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.
Once an object is destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception. Therefore, assign the return value (`undefined`) to the object as done in the example.

##### Throws:

- DeveloperError : This object was destroyed, i.e., destroy() was called.

##### Example:

    model = model && model.destroy();

##### See:

- Model#isDestroyed

#### getNode(name) → ModelNode
engine/Source/Scene/Model/Model.js 1674

Returns the node with the given `name` in the glTF. This is used to modify a node's transform for user-defined animation.

Name | Type | Description
--- | --- | ---
`name` | string | The name of the node in the glTF.

##### Returns:

The node, or `undefined` if no node with the `name` exists.

##### Throws:

- DeveloperError : The model is not loaded. Use Model.readyPromise or wait for Model.ready to be true.

##### Example:

    // Apply non-uniform scale to node "Hand"
    const node = model.getNode("Hand");
    node.matrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(5.0, 1.0, 1.0), node.matrix);

#### isDestroyed() → boolean
engine/Source/Scene/Model/Model.js 2481

Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception.

##### Returns:

`true` if this object was destroyed; otherwise, `false`.

##### See:

- Model#destroy

#### makeStyleDirty()
engine/Source/Scene/Model/Model.js 1739

Marks the model's `Model#style` as dirty, which forces all features to re-evaluate the style in the next frame the model is visible.

#### setArticulationStage(articulationStageKey, value)
engine/Source/Scene/Model/Model.js 1703

Sets the current value of an articulation stage. After setting one or multiple stage values, call Model.applyArticulations() to cause the node matrices to be recalculated.

Name | Type | Description
--- | --- | ---
`articulationStageKey` | string | The name of the articulation, a space, and the name of the stage.
`value` | number | The numeric value of this stage of the articulation.

##### Throws:

- DeveloperError : The model is not loaded. Use Model.readyPromise or wait for Model.ready to be true.

##### Example:

    // Sets the value of the stage named "MoveX" belonging to the articulation named "SampleArticulation"
    model.setArticulationStage("SampleArticulation MoveX", 50.0);

##### See:

- Model#applyArticulations

#### update()
engine/Source/Scene/Model/Model.js 1766

Called when `Viewer` or `CesiumWidget` render the scene to get the draw commands needed to render this primitive.

Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:

##### Throws:

- RuntimeError : Failed to load external reference.

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.