Cesium includes support for geometry and materials, glTF animations, and glTF skinning.
In addition, individual glTF nodes are pickable with Scene#pick
and animatable
with Model#getNode
. glTF cameras and lights are not currently supported.
An external glTF asset is created with Model.fromGltf
. glTF JSON can also be
created at runtime and passed to this constructor function. In either case, the
Model#readyPromise
is resolved 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.
Cesium supports glTF assets with the following extensions:
- KHR_binary_glTF (glTF 1.0)
- KHR_materials_common (glTF 1.0)
- WEB3D_quantized_attributes (glTF 1.0)
- AGI_articulations
- KHR_blend (draft)
- KHR_draco_mesh_compression
- KHR_materials_pbrSpecularGlossiness
- KHR_materials_unlit
- KHR_techniques_webgl
- KHR_texture_transform
For high-precision rendering, Cesium supports the CESIUM_RTC extension, which introduces the CESIUM_RTC_MODELVIEW parameter semantic that says the node is in WGS84 coordinates translated relative to a local origin.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Demo:
See:
Members
activeAnimations : ModelAnimationCollection
-
Default Value:
true
-
Default Value:
true
Model#color
是,则不会剔除背面
半透明或Model#silhouetteSize
大于0.0。-
Default Value:
true
''
时,
应用程序的基本路径已使用。-
Default Value:
''
readonly boundingSphere : BoundingSphere
Model#minimumPixelSize
。-
Default Value:
undefined
Example:
// Center in WGS84 coordinates
var center = Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new Cesium.Cartesian3());
clippingPlanes : ClippingPlaneCollection
ClippingPlaneCollection
用于选择性地禁用对模型的渲染。color : Color
-
Default Value:
Color.WHITE
colorBlendMode
为MIX
时用于确定颜色强度的值。
值0.0将生成模型的渲染颜色,而值1.0将生成纯色,其中
介于两者之间的任何值都会导致两者的混合。-
Default Value:
0.5
colorBlendMode : ColorBlendMode
-
Default Value:
ColorBlendMode.HIGHLIGHT
credit : Credit
Draws the bounding sphere for each draw command in the model. A glTF primitive corresponds to one draw command. A glTF mesh has an array of primitives, often of length one.
-
Default Value:
false
Draws the model in wireframe.
-
Default Value:
false
distanceDisplayCondition : DistanceDisplayCondition
-
Default Value:
undefined
-
Default Value:
undefined
heightReference : HeightReference
-
Default Value:
HeightReference.NONE
-
Default Value:
undefined
See:
imageBasedLightingFactor : Cartesian2
-
Default Value:
Cartesian2(1.0, 1.0)
-
Default Value:
true
lightColor : Cartesian3
undefined
时,将使用场景的浅色。
For example, disabling additional light sources by setting model.imageBasedLightingFactor = new Cesium.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
Model#specularEnvironmentMaps
和Model#sphericalHarmonicCoefficients
时使用。-
Default Value:
0.2
Demo:
Model#minimumPixelSize
,确保模型
绝不是不合理的尺度。0.0
时,不强制最小大小。-
Default Value:
0.0
modelMatrix : Matrix4
Transforms.eastNorthUpToFixedFrame
。-
Default Value:
Matrix4.IDENTITY
Example:
var origin = Cesium.Cartesian3.fromDegrees(-95.0, 40.0, 200000.0);
m.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
-
Default Value:
false
readonly readyPromise : Promise.<Model>
This promise is resolved at the end of the frame before the first frame the model is rendered in.
Example:
// Play all animations at half-speed when the model is ready to render
Cesium.when(model.readyPromise).then(function(model) {
model.activeAnimations.addAll({
multiplier : 0.5
});
}).otherwise(function(error){
window.alert(error);
});
See:
-
Default Value:
1.0
shadows : ShadowMode
-
Default Value:
ShadowMode.ENABLED
-
Default Value:
true
silhouetteColor : Color
-
Default Value:
Color.RED
-
Default Value:
0.0
sphericalHarmonicCoefficients : Array.<Cartesian3>
undefined
时,漫射辐照度
根据大气颜色计算。
There are nine Cartesian3
coefficients.
The order of the coefficients is: L00, L1-1, L10, L11, L2-2, L2-1, L20, L21, L22
cmgen
工具对环境图进行预处理来获得
Google's Filament project这还将生成一个KTX文件,该文件可以
供应至Model#specularEnvironmentMaps
。Demo:
See:
Methods
static Cesium.Model.fromGltf(options) → Model
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.
Cesium supports glTF assets with the following extensions:
- KHR_binary_glTF (glTF 1.0)
- KHR_materials_common (glTF 1.0)
- WEB3D_quantized_attributes (glTF 1.0)
- AGI_articulations
- KHR_blend (draft)
- KHR_draco_mesh_compression
- KHR_materials_pbrSpecularGlossiness
- KHR_materials_unlit
- KHR_techniques_webgl
- KHR_texture_transform
For high-precision rendering, Cesium supports the CESIUM_RTC extension, which introduces the CESIUM_RTC_MODELVIEW parameter semantic that says the node is in WGS84 coordinates translated relative to a local origin.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | 具有以下属性的对象:
|
Returns:
Examples:
// Example 1. Create a model from a glTF asset
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : './duck/duck.gltf'
}));
// Example 2. Create model and provide all properties and events
var origin = Cesium.Cartesian3.fromDegrees(-95.0, 40.0, 200000.0);
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
var model = scene.primitives.add(Cesium.Model.fromGltf({
url : './duck/duck.gltf',
show : true, // default
modelMatrix : modelMatrix,
scale : 2.0, // double size
minimumPixelSize : 128, // never smaller than 128 pixels
maximumScale: 20000, // never larger than 20000 * model size (overrides minimumPixelSize)
allowPicking : false, // not pickable
debugShowBoundingVolume : false, // default
debugWireframe : false
}));
model.readyPromise.then(function(model) {
// Play all animations when the model is ready to render
model.activeAnimations.addAll();
});
Name | Type | Description |
---|---|---|
scene |
Scene | 现场。 |
Returns:
true
;否则,返回false
Throws:
-
DeveloperError :未加载模型。使用模型.readyPromise或者等待模型准备就绪说实话。
销毁此对象持有的WebGL资源。销毁一个对象允许确定性 释放WebGL资源,而不是依赖垃圾回收器销毁此对象。 一旦一个对象被销毁,就不应该使用它;调用除
isDestroyed
将导致DeveloperError
异常。因此,
如示例所示,将返回值(undefined
)分配给对象。Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
model = model && model.destroy();
See:
getMaterial(name) → ModelMaterial
name
属性的glTF材质。Name | Type | Description |
---|---|---|
name |
String | 材质的glTF名称。 |
Returns:
name
的材料,则为undefined
。Throws:
-
DeveloperError :未加载模型。使用模型.readyPromise或者等待模型准备就绪说实话。
getMesh(name) → ModelMesh
name
属性的glTF网格。Name | Type | Description |
---|---|---|
name |
String | 网格的glTF名称。 |
Returns:
name
的网格,则为undefined
。Throws:
-
DeveloperError :未加载模型。使用模型.readyPromise或者等待模型准备就绪说实话。
getNode(name) → ModelNode
name
属性的glTF节点。这是用来
为glTF动画之外的动画修改节点的变换。Name | Type | Description |
---|---|---|
name |
String | 节点的glTF名称。 |
Returns:
name
的节点,则为undefined
。Throws:
-
DeveloperError :未加载模型。使用模型.readyPromise或者等待模型准备就绪说实话。
Example:
// Apply non-uniform scale to node LOD3sp
var node = model.getNode('LOD3sp');
node.matrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(5.0, 1.0, 1.0), node.matrix);
Returns:
true
;否则为false
。See:
Name | Type | Description |
---|---|---|
articulationStageKey |
String | 连接的名称、空间和阶段的名称。 |
value |
Number | 这个阶段的数值。 |
Throws:
-
DeveloperError :未加载模型。使用模型.readyPromise或者等待模型准备就绪说实话。
Viewer
或CesiumWidget
将场景渲染到
获取渲染此基本体所需的draw命令。
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 :无法加载外部引用。