bigemap-gl包括對(duì)幾何圖形和材質(zhì),glTF動(dòng)畫(huà)和glTF蒙皮的支持。另外,單個(gè)glTF節(jié)點(diǎn)可以用Scene#pick
拾取,可以用Model#getNode
動(dòng)畫(huà)。目前不支持glTF相機(jī)和燈光。
用Model.fromGltf
創(chuàng)建了一個(gè)外部glTF資源。 glTF JSON也可以在運(yùn)行時(shí)創(chuàng)建,并傳遞給此構(gòu)造函數(shù)。無(wú)論哪種情況,當(dāng)模型準(zhǔn)備渲染時(shí),即下載外部二進(jìn)制文件,圖像和著色器文件并創(chuàng)建WebGL資源時(shí),Model#readyPromise
都會(huì)解析。
bigemap-gl支持帶有以下擴(kuò)展名的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
對(duì)于高精度渲染,bigemap-gl支持?jǐn)U展,它引入了BMGL_RTC_MODELVIEW參數(shù)語(yǔ)義,該語(yǔ)義表示節(jié)點(diǎn)在WGS84坐標(biāo)中相對(duì)于當(dāng)?shù)匮y(tǒng)。
Parameters:
(Object)
Name | Description |
---|---|
options.gltf
(Object | ArrayBuffer | Uint8Array)
|
gltf json對(duì)象或二進(jìn)制gltf緩沖區(qū)。 |
options.basePath
(Resource | String)
default ''
|
gltf json中的路徑相對(duì)于的基本路徑。 |
options.show
Boolean
default true
|
確定是否顯示模型基元。 |
options.modelMatrix
Matrix4
default Matrix4.IDENTITY
|
將模型從模型轉(zhuǎn)換為世界坐標(biāo)的4x4轉(zhuǎn)換矩陣。 |
options.scale
Number
default 1.0
|
應(yīng)用于此模型的統(tǒng)一比例。 |
options.minimumPixelSize
Number
default 0.0
|
模型的近似最小像素大小,與縮放無(wú)關(guān)。 |
options.maximumScale
Number
|
模型的最大比例大小。最小像素化的上限。 |
options.id
Object
|
使用Scene#pick 選取模型時(shí)要返回的用戶定義對(duì)象。
|
options.allowPicking
Boolean
default true
|
當(dāng)true 時(shí),每個(gè)GLTF網(wǎng)格和基本體都可以用Scene#pick 拾取。
|
options.incrementallyLoadTextures
Boolean
default true
|
確定加載模型后紋理是否可以繼續(xù)流入。 |
options.asynchronous
Boolean
default true
|
確定在加載完所有GLTF文件后,模型WebGL資源創(chuàng)建是否將分布在多個(gè)幀或塊上,直到完成。 |
options.clampAnimations
Boolean
default true
|
確定模型的動(dòng)畫(huà)是否應(yīng)在未指定關(guān)鍵幀的幀上保持姿勢(shì)。 |
options.shadows
ShadowMode
default ShadowMode.ENABLED
|
確定模型是投射還是接收來(lái)自每個(gè)光源的陰影。 |
options.debugShowBoundingVolume
Boolean
default false
|
僅用于調(diào)試。為模型中的每個(gè)繪制命令繪制邊界球體。 |
options.debugWireframe
Boolean
default false
|
僅用于調(diào)試。在線框中繪制模型。 |
options.heightReference
HeightReference
default HeightReference.NONE
|
確定模型相對(duì)于地形的繪制方式。 |
options.scene
Scene
|
對(duì)于使用高度引用屬性的模型,必須傳入。 |
options.distanceDisplayCondition
DistanceDisplayCondition
|
指定將顯示此模型的相機(jī)距離的條件。 |
options.color
Color
default Color.WHITE
|
與模型的渲染顏色混合的顏色。 |
options.colorBlendMode
ColorBlendMode
default ColorBlendMode.HIGHLIGHT
|
定義顏色與模型的混合方式。 |
options.colorBlendAmount
Number
default 0.5
|
當(dāng)colorBlendMode 為MIX 時(shí)用于確定顏色強(qiáng)度的值。值為0.0將生成模型的渲染顏色,值為1.0將生成純色,兩者之間的任何值都將導(dǎo)致二者的混合。
|
options.silhouetteColor
Color
default Color.RED
|
輪廓顏色。如果超過(guò)256個(gè)模型啟用了輪廓,重疊的模型很可能會(huì)有較小的瑕疵。 |
options.silhouetteSize
Number
default 0.0
|
輪廓的像素大小。 |
options.clippingPlanes
ClippingPlaneCollection
|
ClippingPlaneCollection 用于選擇性地禁用渲染模型。
|
options.dequantizeInShader
Boolean
default true
|
確定是否在GPU上對(duì)Draco編碼的模型進(jìn)行量化。這減少了編碼模型的總內(nèi)存使用量。 |
options.imageBasedLightingFactor
Cartesian2
default Cartesian2(1.0, 1.0)
|
從地球、天空、大氣和星空盒縮放基于漫反射和鏡面反射的圖像照明。 |
options.lightColor
Cartesian3
|
用來(lái)給模型加陰影的陽(yáng)光的顏色和強(qiáng)度。 |
options.luminanceAtZenith
Number
default 0.2
|
太陽(yáng)在天頂?shù)牧炼龋瑔挝粸榍Э藸T光每平方米,用于此模型的程序環(huán)境地圖。 |
options.sphericalHarmonicCoefficients
Array.<Cartesian3>
|
三階球面諧波系數(shù)用于圖像光的漫反射顏色。 |
options.specularEnvironmentMaps
String
|
KTX文件的一個(gè)URL,其中包含鏡面照明和卷積鏡面mipmap的立方體映射。 |
options.credit
(Credit | String)
|
數(shù)據(jù)源的信用,顯示在畫(huà)布上。 |
See:
Members
activeAnimations : ModelAnimationCollection
(readonly) allowPicking : Boolean
-
Default Value:
true
(readonly) asynchronous : Boolean
-
Default Value:
true
(readonly) basePath : String
''
,則使用應(yīng)用程序的基本路徑。
-
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
時(shí)用于確定顏色強(qiáng)度的值。值為0.0將生成模型的渲染顏色,值為1.0將生成純色,兩者之間的任何值都將導(dǎo)致二者的混合。
-
Default Value:
0.5
colorBlendMode : ColorBlendMode
-
Default Value:
ColorBlendMode.HIGHLIGHT
credit : Credit
debugShowBoundingVolume : Boolean
為模型中的每個(gè)繪制命令繪制邊界球體。gltf原語(yǔ)對(duì)應(yīng)于一個(gè)draw命令。一個(gè)gltf網(wǎng)格有一個(gè)基元數(shù)組,通常是長(zhǎng)度為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
例如,通過(guò)設(shè)置model.imageBasedLightingFactor = new bmgl.Cartesian2(0.0, 0.0)
禁用其他光源將使模型更暗。在這里,增加光源的強(qiáng)度將使模型更亮。
-
Default Value:
undefined
luminanceAtZenith : Number
Model#specularEnvironmentMaps
和Model#sphericalHarmonicCoefficients
時(shí)使用。
-
Default Value:
0.2
maximumScale : Number
Model#minimumPixelSize
設(shè)定一個(gè)上限,確保模型永遠(yuǎn)不會(huì)是不合理的規(guī)模。
minimumPixelSize : Number
0.0
時(shí),不強(qiáng)制使用最小尺寸。
-
Default Value:
0.0
modelMatrix : Matrix4
Transforms.eastNorthUpToFixedFrame
返回的轉(zhuǎn)換矩陣。
-
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
true
時(shí),此模型已準(zhǔn)備好渲染,即下載了外部二進(jìn)制文件、圖像和明暗器文件,并創(chuàng)建了WebGL資源。這將設(shè)置為true
在Model#readyPromise
解決之前。
-
Default Value:
false
(readonly) readyPromise : Promise.<Model>
此承諾在模型呈現(xiàn)的第一幀之前在幀的末尾解決。
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
時(shí),使用根據(jù)大氣顏色計(jì)算的漫反射輻照度。有九個(gè)Cartesian3
系數(shù)。系數(shù)的順序?yàn)椋篖00,L1-1,L10,L11,L2-2,L2-1,L20,L21,L{22
cmgen
工具預(yù)處理環(huán)境地圖獲得。這還將生成一個(gè)可以提供給Model#specularEnvironmentMaps
的KTX文件。
Methods
(static) fromGltf(options) → {Model}從glTF資源創(chuàng)建模型。 當(dāng)模型準(zhǔn)備渲染時(shí),即下載外部二進(jìn)制文件,圖像和著色器文件并創(chuàng)建WebGL資源時(shí),解析Model#readyPromise
。
模型可以是擴(kuò)展名為.gltf的傳統(tǒng)glTF資源,也可以是擴(kuò)展名為.glb的Binary glTF。
bigemap-gl支持具有以下擴(kuò)展名的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
對(duì)于高精度渲染,bigemap-gl支持,它引入了BMGL_RTC_MODELVIEW參數(shù)語(yǔ)義,該語(yǔ)義表示節(jié)點(diǎn)在WGS84坐標(biāo)中相對(duì)于本地坐標(biāo)轉(zhuǎn)換 起源。
Parameters:
(Object)
Name | Description |
---|---|
options.url
(Resource | String)
|
.gltf文件的URL。 |
options.basePath
(Resource | String)
|
gltf json中的路徑相對(duì)于的基本路徑。 |
options.show
Boolean
default true
|
確定是否顯示模型基元。 |
options.modelMatrix
Matrix4
default Matrix4.IDENTITY
|
將模型從模型轉(zhuǎn)換為世界坐標(biāo)的4x4轉(zhuǎn)換矩陣。 |
options.scale
Number
default 1.0
|
應(yīng)用于此模型的統(tǒng)一比例。 |
options.minimumPixelSize
Number
default 0.0
|
模型的近似最小像素大小,與縮放無(wú)關(guān)。 |
options.maximumScale
Number
|
模型的最大比例。 |
options.id
Object
|
使用Scene#pick 選取模型時(shí)要返回的用戶定義對(duì)象。
|
options.allowPicking
Boolean
default true
|
當(dāng)true 時(shí),每個(gè)GLTF網(wǎng)格和基本體都可以用Scene#pick 拾取。
|
options.incrementallyLoadTextures
Boolean
default true
|
確定加載模型后紋理是否可以繼續(xù)流入。 |
options.asynchronous
Boolean
default true
|
確定在加載完所有GLTF文件后,模型WebGL資源創(chuàng)建是否將分布在多個(gè)幀或塊上,直到完成。 |
options.clampAnimations
Boolean
default true
|
確定模型的動(dòng)畫(huà)是否應(yīng)在未指定關(guān)鍵幀的幀上保持姿勢(shì)。 |
options.shadows
ShadowMode
default ShadowMode.ENABLED
|
確定模型是投射還是接收來(lái)自每個(gè)光源的陰影。 |
options.debugShowBoundingVolume
Boolean
default false
|
僅用于調(diào)試。為模型中的每個(gè)繪制命令繪制邊界球體。 |
options.debugWireframe
Boolean
default false
|
僅用于調(diào)試。在線框中繪制模型。 |
options.heightReference
HeightReference
default HeightReference.NONE
|
確定模型相對(duì)于地形的繪制方式。 |
options.scene
Scene
|
對(duì)于使用高度引用屬性的模型,必須傳入。 |
options.distanceDisplayCondition
DistanceDisplayCondition
|
指定將顯示此模型的相機(jī)距離的條件。 |
options.color
Color
default Color.WHITE
|
與模型的渲染顏色混合的顏色。 |
options.colorBlendMode
ColorBlendMode
default ColorBlendMode.HIGHLIGHT
|
定義顏色與模型的混合方式。 |
options.colorBlendAmount
Number
default 0.5
|
當(dāng)colorBlendMode 為MIX 時(shí)用于確定顏色強(qiáng)度的值。值為0.0將生成模型的渲染顏色,值為1.0將生成純色,兩者之間的任何值都將導(dǎo)致二者的混合。
|
options.silhouetteColor
Color
default Color.RED
|
輪廓顏色。如果超過(guò)256個(gè)模型啟用了輪廓,重疊的模型很可能會(huì)有較小的瑕疵。 |
options.silhouetteSize
Number
default 0.0
|
輪廓的像素大小。 |
options.clippingPlanes
ClippingPlaneCollection
|
ClippingPlaneCollection 用于選擇性地禁用渲染模型。
|
options.dequantizeInShader
Boolean
default true
|
確定是否在GPU上對(duì)Draco編碼的模型進(jìn)行量化。這減少了編碼模型的總內(nèi)存使用量。 |
options.credit
(Credit | String)
|
模型的學(xué)分,顯示在畫(huà)布上。 |
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。
一旦對(duì)象被破壞,就不應(yīng)使用它;調(diào)用除
isDestroyed
以外的任何函數(shù)都將導(dǎo)致DeveloperError
異常。因此,將返回值(undefined
)賦給對(duì)象,如示例中所述。
Throws
-
DeveloperError : 此對(duì)象已被銷毀,即調(diào)用destroy()。
See:
name
屬性的GLTF材質(zhì)。
Parameters:
(String)
物料的GLTF名稱。
Throws
-
DeveloperError : 模型未加載。使用model.readyPromise或等待model.ready為true。
name
屬性的gltf網(wǎng)格。
Parameters:
(String)
網(wǎng)格的gltf名稱。
Throws
-
DeveloperError : 模型未加載。使用model.readyPromise或等待model.ready為true。
name
屬性的GLTF節(jié)點(diǎn)。這用于修改GLTF動(dòng)畫(huà)之外的動(dòng)畫(huà)節(jié)點(diǎn)的轉(zhuǎn)換。
Parameters:
(String)
節(jié)點(diǎn)的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。
如果此對(duì)象被破壞,則不應(yīng)使用它;調(diào)用除
isDestroyed
以外的任何函數(shù)將導(dǎo)致DeveloperError
異常。
See:
Parameters:
(String)
發(fā)音的名稱、空格和舞臺(tái)的名稱。
(Number)
這個(gè)階段的發(fā)音的數(shù)值。
Throws
-
DeveloperError : 模型未加載。使用model.readyPromise或等待model.ready為true。
Viewer
或BMWidget
渲染場(chǎng)景以獲取渲染此原語(yǔ)所需的繪制命令時(shí)調(diào)用。不要直接調(diào)用此函數(shù)。這只是為了列出渲染場(chǎng)景時(shí)可能傳播的異常:
Throws
-
RuntimeError : 未能加載外部引用。