internal constructor new Cesium.Model()

To construct a Model, call Model.fromGltfAsync. Do not call the constructor directly.
基于glTF的3D模式,运行时间资产格式为 NT 0 ,OpenGL ES,以及OpenGL.

NT 0 支持 glTF 资产,扩展如下:

注意:对于使用 KHR texture basisu 扩展的压缩纹理的模型,我们推荐两个维度的纹理功率 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:
See:

Members

readonly activeAnimations : ModelAnimationCollection

目前播放的glTF动画.

backFaceCulling : boolean

是否要弯曲反向几何. 当真实, 背面的叫声是 由材料的双斜面属性决定; 假时, 背面 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

获得模型在世界空间的极限球体. 这没有考虑到 glTF动画,皮肤,或变形目标. 也没有说明 Model#minimumPixelSize.

clampAnimations : boolean

确定模型的动画是否应该在没有指定密钥框的帧上摆姿势.
Default Value: true

readonly classificationType : ClassificationType

获得模型的分类类型. 这决定了地形, 3D梯,或两者都将被这个模型分类.

此外,还有一些要求/限制:

  • 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 meshes must be watertight.
  • 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.

接受分类的3D梯或地形必须不透明.

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

The ClippingPlaneCollection used to selectively disable rendering the model.

clippingPolygons : ClippingPolygonCollection

The ClippingPolygonCollection used to selectively disable rendering the model.

color : Color

和模型混合的颜色 变成了颜色.
Default Value: undefined

colorBlendAmount : number

当 NT 0 colorBlendMode NT 1 为 NT 2 MI NT 3 时,用于确定颜色强度的值. 0.0的值导致模型的渲染色,1.0的值则导致固体的颜色,任何值在二者之间产生混合.
Default Value: 0.5
定义颜色与模型的混合方式.
Default Value: ColorBlendMode.HIGHLIGHT

readonly credit : Credit

获得将为模型显示的功劳 .

customShader : CustomShader

The model's custom shader, if it exists. Using custom shaders with a Cesium3DTileStyle 可能导致未定义的行为.
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

此属性仅用于调试;不用于生产,也不优化.

绘制模型中每个绘图命令的边框.

Default Value: false

debugWireframe : boolean

此属性仅用于调试;不用于生产,也不优化.

在线框中绘制模型.

Default Value: false

distanceDisplayCondition : DistanceDisplayCondition

获取或设置距离显示条件, 指定距离 从相机上显示此模型 .
Default Value: undefined

enableVerticalExaggeration : boolean

If true, the model is exaggerated along the ellipsoid normal when Scene.verticalExaggeration is set to a value other than 1.0.
Default Value: true
Example:
// Exaggerate terrain by a factor of 2, but prevent model exaggeration
scene.verticalExaggeration = 2.0;
model.enableVerticalExaggeration = false;

readonly environmentMapManager : DynamicEnvironmentMapManager

在这个模型上管理动态环境图的属性. 影响照明.
Example:
// Change the ground color used for a model's environment map to a forest green
const environmentMapManager = model.environmentMapManager;
environmentMapManager.groundColor = Cesium.Color.fromCssColorString("#203b34");

readonly errorEvent : Event

获得当模型遇到同步渲染错误时被提起的事件 。 通过签名 对事件,您将被通知错误,并有可能从中恢复。 活动听众 are passed an instance of ModelError.

featureIdLabel : string

用于采样和造型的特性ID集的标签 .

对于EXT mesh features,这是特性ID的标签属性,或 “ featureId N”(其中N是特性Ids阵列中的索引) 当不是时 页:1 EXT feature metadata 没有标签字段, 因此 特性 ID 集总是标注“ featureId N ” ,其中 N 是索引 全部特性ID的列表,其中特性 ID 属性在前面列出 特性标识纹理.

如果特性IdLabel设定为整数 N,则转换为 字符串“ featureId N” 自动。 如果两者兼有 存在 per-instance 特征 ID , 实例 特征 ID 使用 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

模型的高度参考,决定模型如何绘制 相对地形而言.
Default Value: {HeightReference.NONE}

id : object

选择模型时返回的自定义对象.
Default Value: undefined
See:

imageBasedLighting : ImageBasedLighting

在这个模型上管理基于图像的照明的属性.

instanceFeatureIdLabel : string

用于采摘和造型的示例特征标识集的标签 .

如果实例FeatureIdLabel设定为整数 N,则转换为 字符串“ InstanceFeatureId N” 自动. 如果有每个原始特征的识别码和普通特征的识别码,则 实例特征标识优先.

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

阴影模型时的方向光色. 当 NT 0 未定义 NT 1 取而代之的是场景的浅色.

通过设置使额外光源失效 model.imageBasedLighting.imageBasedLightingFactor = new Cartesian2(0.0, 0.0) 这会让模型变得更加黑暗。 在这里,增加光源的强度将使模型更亮.

Default Value: undefined

maximumScale : number

模型的最大缩放大小 。 这个可以用来给 an upper limit to the Model#minimumPixelSize, ensuring that the model 绝不是一个不合理的尺度.

minimumPixelSize : number

模型的大致最小像素大小,不论缩放大小. 这可以用来确保一个模型即使在查看器时也能可见 缩放。 当 NT 0 0.0 NT 1 时,不执行最小尺寸.
Default Value: 0.0

modelMatrix : Matrix4

将模型从模型转化为世界坐标的4x4变换矩阵. 当这是身份矩阵时,该模型被绘制在世界坐标, i.e . 地球的笛卡尔 WGS84 坐标. 本地参考框架可以通过提供不同的变换矩阵来使用, 如返回的变换矩阵 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

渲染大纲时使用的颜色 .
Default Value: Color.BLACK

pointCloudShading : PointCloudShading

控制点云衰减的点云阴影设置 和照明。 对于3D 梯子,这是从 Cesium3DTileset.

readonly ready : boolean

当 NT 0 true NT 1 时,这个模型准备渲染, NT 2 . 外部二进制,图像, and shader files were downloaded and the WebGL resources were created.
Default Value: false

readonly readyEvent : Event

当模型装入并准备渲染时获得一个事件, 当外部资源时获得 NT% 0 have been downloaded and the WebGL resources are created. Event listeners are passed an instance of the Model.

If Model.incrementallyLoadTextures is true, this event will be raised before all textures are loaded and ready for rendering. Subscribe to Model.texturesReadyEvent to be notified when the textures are ready.

scale : number

A uniform scale applied to this model before the Model#modelMatrix. 大于 NT 0 1.0 NT 1 的值增加模型大小; 值 小于 NT 0 1.0 NT 1 减少.
Default Value: 1.0

shadows : ShadowMode

确定模型是投影还是接收来自光源的阴影.
Default Value: ShadowMode.ENABLED

show : boolean

是否制作模型.
Default Value: true

showCreditsOnScreen : boolean

获取或设定模型的信用是否显示 在屏幕上.
Default Value: false

showOutline : boolean

是否使用 CESIUM_primitive_outline extension. 当真实时, 显示大纲 。 当错误时, 大纲不显示 .
Default Value: true

silhouetteColor : Color

Il色.
Default Value: Color.RED

silhouetteSize : number

以像素表示的圆筒大小.
Default Value: 0.0

splitDirection : SplitDirection

适用于此型号的 SplitDirection .
Default Value: SplitDirection.NONE
The style to apply to the features in the model. Cannot be applied if a CustomShader is also applied.

readonly texturesReadyEvent : Event

Gets an event that, if Model.incrementallyLoadTextures is true, is raised when the model textures are loaded and ready for rendering, i.e. when the external resources have been downloaded and the WebGL resources are created. Event listeners are passed an instance of the Model.

Methods

static Cesium.Model.fromGltfAsync(options)Promise.<Model>

从 glTF 资产中同步创建模型 。 此函数返回一个承诺, 当模型准备好渲染时解析, NT % 0 . 当外部二进制, 图像, 和阴影文件被下载,并创建 WebGL 资源.

该模型可以是一个传统的glTF资产,具有.gltf扩展或使用.glb扩展的二进制glTF.

Name Type Description
options object 下列属性的对象 :
Name Type Default Description
url string | Resource Url 到. gltf 或. glb 文件 .
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 本模型适用的统一比额表.
enableVerticalExaggeration boolean true optional If true, the model is exaggerated along the ellipsoid normal when Scene.verticalExaggeration is set to a value other than 1.0.
minimumPixelSize number 0.0 optional 模型的大约最小像素大小,而不论缩放大小.
maximumScale number optional 模型的最大缩放大小 。 最小像素Size的上限 .
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 风俗荫者. 这将在顶点和片段阴影上添加用户定义的 GLSL 代码. 使用带有 Cesium3DTileStyle 的自定义阴影器可能导致未定义的行为.
content Cesium3DTileContent optional 此模式所属的瓷砖内容. 如果模型没有作为砖块的一部分加载, 此属性将不被定义 .
heightReference HeightReference HeightReference.NONE optional Determines how the model is drawn relative to terrain.
scene Scene optional 使用高度参考属性的模型必须传递到其中.
distanceDisplayCondition DistanceDisplayCondition optional 指定此模型将显示于相机的距离的条件 .
color Color optional 一种和模型的颜色混合的颜色.
colorBlendMode ColorBlendMode ColorBlendMode.HIGHLIGHT optional Defines how the color blends with the model.
colorBlendAmount number 0.5 optional 值用于确定当 NT+0 colorBlendMode NT+1 为 NT+2 MI+NT+3 时的颜色强度. 0.0的值导致模型的渲染色,1.0的值则导致固体的颜色,任何值在二者之间产生混合.
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 以像素表示的圆筒大小.
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.
clippingPolygons ClippingPolygonCollection optional The ClippingPolygonCollection used to selectively disable rendering the model.
lightColor Cartesian3 optional 阴影模型时的光彩. 当 NT 0 未定义 NT 1 取而代之的是场景的浅色.
imageBasedLighting ImageBasedLighting optional 在这个模型上管理基于图像的照明的属性.
environmentMapOptions DynamicEnvironmentMapManager.ConstructorOptions optional 在这个模型上管理动态环境图的属性.
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 数据源的信用,在画布上显示.
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.
enablePick boolean false optional Whether to allow with CPU picking with pick when not using WebGL 2 or above. If using WebGL 2 or above, this option will be ignored. If using WebGL 1 and this is true, the pick operation will work correctly, but it will use more memory to do so. If running with WebGL 1 and this is false, the model will use less memory, but pick will always return undefined. This 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 用于构建控制点衰减和照明的 PointCloudShading 对象的选项 .
classificationType ClassificationType optional 确定地形,立体平面或两者是否会被本模型分类. 在模型装入后无法设置 .
gltfCallback Model.GltfCallback optional 一个在加载的 gltf 对象下调用的函数 .
Returns:
当人们准备做出承诺时, 就能对创造的模型做出承诺.
Throws:
Examples:
// Load a model and add it to the scene
try {
 const model = await Cesium.Model.fromGltfAsync({
   url: "../../SampleData/models/CesiumMan/Cesium_Man.glb"
 });
 viewer.scene.primitives.add(model);
} catch (error) {
 console.log(`Failed to load model. ${error}`);
}
// Position a model with modelMatrix and display it with a minimum size of 128 pixels
const position = Cesium.Cartesian3.fromDegrees(
  -123.0744619,
  44.0503706,
  5000.0
);
const headingPositionRoll = new Cesium.HeadingPitchRoll();
const fixedFrameTransform = Cesium.Transforms.localFrameToFixedFrameGenerator(
  "north",
  "west"
);
try {
 const model = await Cesium.Model.fromGltfAsync({
   url: "../../SampleData/models/CesiumAir/Cesium_Air.glb",
   modelMatrix: Cesium.Transforms.headingPitchRollToFixedFrame(
     position,
     headingPositionRoll,
     Cesium.Ellipsoid.WGS84,
     fixedFrameTransform
   ),
   minimumPixelSize: 128,
 });
 viewer.scene.primitives.add(model);
} catch (error) {
 console.log(`Failed to load model. ${error}`);
}
// Load a model and play the last animation at half speed
let animations;
try {
 const model = await Cesium.Model.fromGltfAsync({
   url: "../../SampleData/models/CesiumMan/Cesium_Man.glb",
   gltfCallback: gltf => {
     animations = gltf.animations
   }
 });
 viewer.scene.primitives.add(model);
 model.readyEvent.addEventListener(() => {
   model.activeAnimations.add({
     index: animations.length - 1,
     loop: Cesium.ModelAnimationLoop.REPEAT,
     multiplier: 0.5,
   });
 });
} catch (error) {
 console.log(`Failed to load model. ${error}`);
}

applyArticulations()

对每个节点的矩阵应用任何修改的表达式阶段 参与任何表述。 请注意, 这将覆盖任何节点 在参与节点上转换.
Throws:
  • DeveloperError : The model is not loaded. Use Model.readyEvent or wait for Model.ready to be true.

destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic 释放 WebGL 资源,而不是依赖垃圾收集器来摧毁此对象.

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:

getExtension(extensionName)object|undefined

返回为给定扩展创建的对象. 给定的名称可能是 glTF 扩展名, 如 `"EXT_example_extension"` . 如果指定的扩展存在于基础 glTF 资产的根中, 并且指定扩展的加载器已处理扩展数据,然后 这将返回扩展的模型代表.
Name Type Description
extensionName string 扩展名
Returns:
The object, or `undefined`
Throws:
  • DeveloperError : The model is not loaded. Use Model.readyEvent or wait for Model.ready to be true.
Experimental

This feature is not final and is subject to change without Cesium's standard deprecation policy.

getNode(name)ModelNode

Returns the node with the given name in the glTF. This is used to 修改用于用户定义的动画的节点转换.
Name Type Description
name string GlTF 中的节点名称 .
Returns:
节点,或 未定义 ,如果与 2 名称 存在节点.
Throws:
  • DeveloperError : The model is not loaded. Use Model.readyEvent 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

如果此对象被销毁, 返回真实; 否则, 错误 .

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:

makeStyleDirty()

标注该模型的 {NT}\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 以在下一个框架中重新评价样式.

setArticulationStage(articulationStageKey, value)

设置一个表达阶段的当前值。 设置一个或 multiple stage values, call Model.applyArticulations() to 使节点矩阵重新计算.
Name Type Description
articulationStageKey string 音标名称,一个空间,以及舞台名称.
value number 这一阶段的表达值.
Throws:
  • DeveloperError : The model is not loaded. Use Model.readyEvent 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:

update()

Called when Viewer or CesiumWidget render the scene to 获得使这个原始化所需的绘图命令.

不要直接调用此函数 。 记录下来的只是 列出场景拍摄时可能宣传的例外情况:

Throws:

Type Definitions

Cesium.Model.GltfCallback(gltf)

当加载 gltf 对象时调用函数的接口 .
Name Type Description
gltf object Gltf 对象
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.