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
|
用來給模型加陰影的陽光的顏色和強度。 |
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
例如,通過設置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
Model#modelMatrix
之前應用于此模型的統一比例。大于1.0
的值增加模型的大?。恍∮?code>1.0的值減少。
-
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 : 未能加載外部引用。