Gltf

Gltf

Khronos Group glTF模型的抽象描述,通过实例化该类,可以用来加载一个glTF模型

Constructor

new Gltf(options)

Parameters:

Name Type Description
options Gltf.ConstructorOptions

创建glTF/glb模型实例所需的初始参数选项

Members

(readonly) layer :string

Description:
  • 获取glTF模型所属图层的ID

获取glTF模型所属图层的ID

Type:
  • string

layer

Description:
  • 设置glTF模型所属图层的ID

设置glTF模型所属图层的ID

(readonly) type :SourceType

Description:
  • 获取当前矢量数据的类型

获取当前矢量数据的类型

Type:

Methods

data() → {m3d.Model}

Description:
  • 获取glTF模型数据

Returns:
m3d.Model -

返回模型glTF实例对象中的模型数据

getModel() → {m3d.Model}

Description:
  • 获取glTF模型数据

Returns:
m3d.Model -

返回模型glTF实例对象

hide()

Description:
  • 隐藏glTF模型

setColor(color)

Description:
  • 设置模型的颜色

Parameters:

Name Type Description
color Array.<number>

模型的颜色,RGBA格式

(async) setPosition(position)

Description:
  • 设置模型的位置

Parameters:

Name Type Description
position number

模型的位置,[lng, lat, height]格式的数组

show()

Description:
  • 显示glTF模型

Type Definitions

ConstructorOptions

Description:
  • 创建glTF/glb模型实例所需的初始参数选项,包含以下字段:

Properties:
Name Type Attributes Default Description
name string <optional>
''

模型名称

url string

glTF模型的地址

visible boolean <optional>
true

设置加载完glTF模型后,默认是否显示

style Object <optional>

模型渲染的偏好设置,包括以下属性字段:

Properties
Name Type Attributes Default Description
position Array.<number> <optional>

模型的位置,使用经纬度数组[lng, lat, height]定义模型要放置的位置

materials Array <optional>

模型材质设置,使用材质表达式数组,来描述模型构件及其所需要的材质

color Array.<number> | string <optional>

模型的颜色,RGBA格式,或16进制颜色字符串。当设置了“style.materials”时,该设置无效。

scale string <optional>
1.0

先对模型进行缩放,然后再加载到场景中,默认值为1.0,表示不进行缩放,保持模型原始的尺寸

minScale number <optional>
0.0

模型的最小缩放级别,缩放时,当模型的可见大小的尺寸(单位:像素)达到该阈值时,模型将不再被进一步缩小

maxScale number <optional>

模型的最大缩放级别,缩放时,当模型的可见大小的尺寸(单位:像素)达到该阈值时,将不再被进一步放大

创建glTF/glb模型实例所需的初始参数选项,包含以下字段:

Type:
  • Object