bigemap-gl包括对几何图形和材质,glTF动画和glTF蒙皮的支持。另外,单个glTF节点可以用Scene#pick
拾取,可以用Model#getNode
动画。目前不支持glTF相机和灯光。
用Model.fromGltf
创建了一个外部glTF资源。 glTF JSON也可以在运行时创建,并传递给此构造函数。无论哪种情况,当模型准备渲染时,即下载外部二进制文件,图像和着色器文件并创建WebGL资源时,Model#readyPromise
都会解析。
bigemap-gl支持带有以下扩展名的glTF资源:
- 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
对于高精度渲染,bigemap-gl支持扩展,它引入了BMGL_RTC_MODELVIEW参数语义,该语义表示节点在WGS84坐标中相对于当地血统。
Parameters:
(Object)
Name | Description |
---|---|
options.gltf
(Object | ArrayBuffer | Uint8Array)
|
gltf json对象或二进制gltf缓冲区。 |
options.basePath
(Resource | String)
default ''
|
gltf json中的路径相对于的基本路径。 |
options.show
Boolean
default true
|
确定是否显示模型基元。 |
options.modelMatrix
Matrix4
default Matrix4.IDENTITY
|
将模型从模型转换为世界坐标的4x4转换矩阵。 |
options.scale
Number
default 1.0
|
应用于此模型的统一比例。 |
options.minimumPixelSize
Number
default 0.0
|
模型的近似最小像素大小,与缩放无关。 |
options.maximumScale
Number
|
模型的最大比例大小。最小像素化的上限。 |
options.id
Object
|
使用Scene#pick 选取模型时要返回的用户定义对象。
|
options.allowPicking
Boolean
default true
|
当true 时,每个GLTF网格和基本体都可以用Scene#pick 拾取。
|
options.incrementallyLoadTextures
Boolean
default true
|
确定加载模型后纹理是否可以继续流入。 |
options.asynchronous
Boolean
default true
|
确定在加载完所有GLTF文件后,模型WebGL资源创建是否将分布在多个帧或块上,直到完成。 |
options.clampAnimations
Boolean
default true
|
确定模型的动画是否应在未指定关键帧的帧上保持姿势。 |
options.shadows
ShadowMode
default ShadowMode.ENABLED
|
确定模型是投射还是接收来自光源的阴影。 |
options.debugShowBoundingVolume
Boolean
default false
|
仅用于调试。为模型中的每个绘制命令绘制边界球体。 |
options.debugWireframe
Boolean
default false
|
仅用于调试。在线框中绘制模型。 |
options.heightReference
HeightReference
default HeightReference.NONE
|
确定模型相对于地形的绘制方式。 |
options.scene
Scene
|
对于使用高度引用属性的模型,必须传入。 |
options.distanceDisplayCondition
DistanceDisplayCondition
|
指定将显示此模型的相机距离的条件。 |
options.color
Color
default Color.WHITE
|
与模型的渲染颜色混合的颜色。 |
options.colorBlendMode
ColorBlendMode
default ColorBlendMode.HIGHLIGHT
|
定义颜色与模型的混合方式。 |
options.colorBlendAmount
Number
default 0.5
|
当colorBlendMode 为MIX 时用于确定颜色强度的值。值为0.0将生成模型的渲染颜色,值为1.0将生成纯色,两者之间的任何值都将导致二者的混合。
|
options.silhouetteColor
Color
default Color.RED
|
轮廓颜色。如果超过256个模型启用了轮廓,重叠的模型很可能会有较小的瑕疵。 |
options.silhouetteSize
Number
default 0.0
|
轮廓的像素大小。 |
options.clippingPlanes
ClippingPlaneCollection
|
ClippingPlaneCollection 用于选择性地禁用渲染模型。
|
options.dequantizeInShader
Boolean
default true
|
确定是否在GPU上对Draco编码的模型进行量化。这减少了编码模型的总内存使用量。 |
options.imageBasedLightingFactor
Cartesian2
default Cartesian2(1.0, 1.0)
|
从地球、天空、大气和星空盒缩放基于漫反射和镜面反射的图像照明。 |
options.lightColor
Cartesian3
|
为模型着色时的浅色。当undefined 使用场景的灯光颜色。
|
options.luminanceAtZenith
Number
default 0.2
|
太阳在天顶的亮度,单位为千克烛光每平方米,用于此模型的程序环境地图。 |
options.sphericalHarmonicCoefficients
Array.<Cartesian3>
|
三阶球面谐波系数用于图像光的漫反射颜色。 |
options.specularEnvironmentMaps
String
|
KTX文件的一个URL,其中包含镜面照明和卷积镜面mipmap的立方体映射。 |
options.credit
(Credit | String)
|
数据源的信用,显示在画布上。 |
See:
Members
activeAnimations : ModelAnimationCollection
(readonly) allowPicking : Boolean
-
Default Value:
true
(readonly) asynchronous : Boolean
-
Default Value:
true
(readonly) basePath : String
''
,则使用应用程序的基本路径。
-
Default Value:
''
(readonly) boundingSphere : BoundingSphere
Model#minimumPixelSize
。
-
Default Value:
undefined
Example:
// Center in WGS84 coordinates
var center = bmgl.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new bmgl.Cartesian3());
clampAnimations : Boolean
clippingPlanes : ClippingPlaneCollection
ClippingPlaneCollection
用于选择性地禁用渲染模型。
color : Color
-
Default Value:
Color.WHITE
colorBlendAmount : Number
colorBlendMode
为MIX
时用于确定颜色强度的值。值为0.0将生成模型的渲染颜色,值为1.0将生成纯色,两者之间的任何值都将导致二者的混合。
-
Default Value:
0.5
colorBlendMode : ColorBlendMode
-
Default Value:
ColorBlendMode.HIGHLIGHT
credit : Credit
debugShowBoundingVolume : Boolean
为模型中的每个绘制命令绘制边界球体。gltf原语对应于一个draw命令。一个gltf网格有一个基元数组,通常是长度为1的。
-
Default Value:
false
debugWireframe : Boolean
在线框中绘制模型。
-
Default Value:
false
distanceDisplayCondition : DistanceDisplayCondition
-
Default Value:
undefined
(readonly) gltf : Object
-
Default Value:
undefined
heightReference : HeightReference
-
Default Value:
HeightReference.NONE
id : Object
-
Default Value:
undefined
See:
imageBasedLightingFactor : Cartesian2
-
Default Value:
Cartesian2(1.0, 1.0)
(readonly) incrementallyLoadTextures : Boolean
-
Default Value:
true
lightColor : Cartesian3
undefined
使用场景的灯光颜色。例如,通过设置model.imageBasedLightingFactor = new bmgl.Cartesian2(0.0, 0.0)
禁用其他光源将使模型更暗。在这里,增加光源的强度将使模型更亮。
-
Default Value:
undefined
luminanceAtZenith : Number
Model#specularEnvironmentMaps
和Model#sphericalHarmonicCoefficients
时使用。
-
Default Value:
0.2
maximumScale : Number
Model#minimumPixelSize
设定一个上限,确保模型永远不会是不合理的规模。
minimumPixelSize : Number
0.0
时,不强制使用最小尺寸。
-
Default Value:
0.0
modelMatrix : Matrix4
Transforms.eastNorthUpToFixedFrame
返回的转换矩阵。
-
Default Value:
Matrix4.IDENTITY
Example:
var origin = bmgl.Cartesian3.fromDegrees(-95.0, 40.0, 200000.0);
m.modelMatrix = bmgl.Transforms.eastNorthUpToFixedFrame(origin);
(readonly) pendingTextureLoads : Number
(readonly) ready : Boolean
-
Default Value:
false
(readonly) readyPromise : Promise.<Model>
此承诺在模型呈现的第一帧之前在帧的末尾解决。
See:
Example:
// Play all animations at half-speed when the model is ready to render
bmgl.when(model.readyPromise).then(function(model) {
model.activeAnimations.addAll({
multiplier : 0.5
});
}).otherwise(function(error){
window.alert(error);
});
scale : Number
-
Default Value:
1.0
shadows : ShadowMode
-
Default Value:
ShadowMode.ENABLED
show : Boolean
-
Default Value:
true
silhouetteColor : Color
-
Default Value:
Color.RED
silhouetteSize : Number
-
Default Value:
0.0
specularEnvironmentMaps : String
sphericalHarmonicCoefficients : Array.<Cartesian3>
undefined
时,使用根据大气颜色计算的漫反射辐照度。有九个Cartesian3
系数。系数的顺序为:L00,L1-1,L10,L11,L2-2,L2-1,L20,L21,L{22
cmgen
工具预处理环境地图获得。这还将生成一个可以提供给Model#specularEnvironmentMaps
的KTX文件。
Methods
(static) fromGltf(options) → {Model}从glTF资源创建模型。 当模型准备渲染时,即下载外部二进制文件,图像和着色器文件并创建WebGL资源时,解析Model#readyPromise
。
模型可以是扩展名为.gltf的传统glTF资源,也可以是扩展名为.glb的Binary glTF。
bigemap-gl支持具有以下扩展名的glTF资源:
- 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
对于高精度渲染,bigemap-gl支持,它引入了BMGL_RTC_MODELVIEW参数语义,该语义表示节点在WGS84坐标中相对于本地坐标转换 起源。
Parameters:
(Object)
Name | Description |
---|---|
options.url
(Resource | String)
|
.gltf文件的URL。 |
options.basePath
(Resource | String)
|
gltf json中的路径相对于的基本路径。 |
options.show
Boolean
default true
|
确定是否显示模型基元。 |
options.modelMatrix
Matrix4
default Matrix4.IDENTITY
|
将模型从模型转换为世界坐标的4x4转换矩阵。 |
options.scale
Number
default 1.0
|
应用于此模型的统一比例。 |
options.minimumPixelSize
Number
default 0.0
|
模型的近似最小像素大小,与缩放无关。 |
options.maximumScale
Number
|
模型的最大比例。 |
options.id
Object
|
使用Scene#pick 选取模型时要返回的用户定义对象。
|
options.allowPicking
Boolean
default true
|
当true 时,每个GLTF网格和基本体都可以用Scene#pick 拾取。
|
options.incrementallyLoadTextures
Boolean
default true
|
确定加载模型后纹理是否可以继续流入。 |
options.asynchronous
Boolean
default true
|
确定在加载完所有GLTF文件后,模型WebGL资源创建是否将分布在多个帧或块上,直到完成。 |
options.clampAnimations
Boolean
default true
|
确定模型的动画是否应在未指定关键帧的帧上保持姿势。 |
options.shadows
ShadowMode
default ShadowMode.ENABLED
|
确定模型是投射还是接收来自光源的阴影。 |
options.debugShowBoundingVolume
Boolean
default false
|
仅用于调试。为模型中的每个绘制命令绘制边界球体。 |
options.debugWireframe
Boolean
default false
|
仅用于调试。在线框中绘制模型。 |
options.heightReference
HeightReference
default HeightReference.NONE
|
确定模型相对于地形的绘制方式。 |
options.scene
Scene
|
对于使用高度引用属性的模型,必须传入。 |
options.distanceDisplayCondition
DistanceDisplayCondition
|
指定将显示此模型的相机距离的条件。 |
options.color
Color
default Color.WHITE
|
与模型的渲染颜色混合的颜色。 |
options.colorBlendMode
ColorBlendMode
default ColorBlendMode.HIGHLIGHT
|
定义颜色与模型的混合方式。 |
options.colorBlendAmount
Number
default 0.5
|
当colorBlendMode 为MIX 时用于确定颜色强度的值。值为0.0将生成模型的渲染颜色,值为1.0将生成纯色,两者之间的任何值都将导致二者的混合。
|
options.silhouetteColor
Color
default Color.RED
|
轮廓颜色。如果超过256个模型启用了轮廓,重叠的模型很可能会有较小的瑕疵。 |
options.silhouetteSize
Number
default 0.0
|
轮廓的像素大小。 |
options.clippingPlanes
ClippingPlaneCollection
|
ClippingPlaneCollection 用于选择性地禁用渲染模型。
|
options.dequantizeInShader
Boolean
default true
|
确定是否在GPU上对Draco编码的模型进行量化。这减少了编码模型的总内存使用量。 |
options.credit
(Credit | String)
|
模型的学分,显示在画布上。 |
Examples
// Example 1. Create a model from a glTF asset
var model = scene.primitives.add(bmgl.Model.fromGltf({
url : './duck/duck.gltf'
}));
// Example 2. Create model and provide all properties and events
var origin = bmgl.Cartesian3.fromDegrees(-95.0, 40.0, 200000.0);
var modelMatrix = bmgl.Transforms.eastNorthUpToFixedFrame(origin);
var model = scene.primitives.add(bmgl.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();
});
Parameters:
Throws
-
DeveloperError : 模型未加载。使用model.readyPromise或等待model.ready为true。
一旦对象被破坏,就不应使用它;调用除
isDestroyed
以外的任何函数都将导致DeveloperError
异常。因此,将返回值(undefined
)赋给对象,如示例中所述。
Throws
-
DeveloperError : 此对象已被销毁,即调用destroy()。
See:
name
属性的GLTF材质。
Parameters:
(String)
物料的GLTF名称。
Throws
-
DeveloperError : 模型未加载。使用model.readyPromise或等待model.ready为true。
name
属性的gltf网格。
Parameters:
(String)
网格的gltf名称。
Throws
-
DeveloperError : 模型未加载。使用model.readyPromise或等待model.ready为true。
name
属性的GLTF节点。这用于修改GLTF动画之外的动画节点的转换。
Parameters:
(String)
节点的GLTF名称。
Example
// Apply non-uniform scale to node LOD3sp
var node = model.getNode('LOD3sp');
node.matrix = bmgl.Matrix4.fromScale(new bmgl.Cartesian3(5.0, 1.0, 1.0), node.matrix);
Throws
-
DeveloperError : 模型未加载。使用model.readyPromise或等待model.ready为true。
See:
Parameters:
(String)
发音的名称、空格和舞台的名称。
(Number)
这个阶段的发音的数值。
Throws
-
DeveloperError : 模型未加载。使用model.readyPromise或等待model.ready为true。
Throws
-
RuntimeError : 未能加载外部引用。