EarthSDK Model

模型(gltf加载)

new Obj.Model()

Extends

Members

staticObj.Model.xbsjEnvirement

一个内置的环境贴图,可以设置给属性specularEnvironmentMaps。

allowPicking : boolean

When true, each glTF mesh and primitive is pickable with Scene#pick.
Default Value: true

asynchronous : boolean

Determines if model WebGL resource creation will be spread out over several frames or block until completion once all glTF files are loaded.
Default Value: true

attachedPathGuid : string

绑定的路径的guid
Default Value: ''

basePath : string

The base path that paths in the glTF JSON are relative to.
Default Value: ''

cameraAttachedOffsetPosition : Array.<number>

相机绑定后的位置偏移
Default Value: [0, 0, 0]

cameraAttachedOffsetRotation : Array.<number>

相机绑定后的姿态偏移
Default Value: [0, -Math.PI/3, 0]

clampAnimations : boolean

Determines if the model's animations should hold a pose over frames where no keyframes are specified.
Default Value: true

color : Array.<number>

颜色叠加
Default Value: [1, 1, 1, 1]

colorBlendAmount : number

Value used to determine the color strength when the colorBlendMode is MIX. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
Default Value: 0.5,

colorBlendMode : string

Defines how the color blends with the mode. mode: ColorBlendMode.HIGHLIGHT, ColorBlendMode.REPLACE, ColorBlendMode.MIX
Default Value: 'ColorBlendMode.HIGHLIGHT'

customProp : string

用来临时存储客户需要的一些信息,方便使用
Inherited From:
Default Value: ''

debugShowBoundingVolume : boolean

For debugging only. Draws the bounding sphere for each DrawCommand in the model.
Default Value: false

debugWireframe : boolean

For debugging only. Draws the model in wireframe.
Default Value: false

destroyEvalString : string

销毁时的执行语句,只有在对象销毁时才会执行,方便用来清理随该对象创建时附带创建的资源
有一个内置变量p,表示当前对象。 注意对象的销毁除了使用destroyEvalString,还可以使用 disposers 属性来销毁。
Inherited From:
Default Value: ''
See:

disposers

用来收集资源销毁函数,并在析构时自动调用!
Inherited From:
Example:
// 示例1:
myObject.disposers.push(() => {
    // 此处执行需要销毁的资源
});

// 示例2:
// XE.MVVM.bind的返回值是一个函数,作用是用来解除双向绑定,
// 把它的返回值放到disposer中,那么对象销毁时就会执行解绑操作。
myObject.disposers.push(XE.MVVM.bind(xxx));

// 示例3:
// XE.MVVM.watch的返回值是一个函数,作用是用来取消监视,
// 把它的返回值放到disposer中,那么对象销毁时就会执行取消监视的操作。
myObject.disposers.push(XE.MVVM.watch(xxx));

distanceDisplayCondition : Array.<number>|undefined

模型视距范围,两个元素的数组,分别表示near和far。形式如:[200.0, 3000.0]
Default Value: undefined

readonlyearth : Earth

返回该对象的所属earth实例
Inherited From:

enabled : boolean

是否启用
Inherited From:

evalString : string

设置执行语句,
内部有一个内置的变量p,用来指示当前对象。
注意evalString每次进行属性设置都会执行一遍,如果evalString中有创建资源,资源需要记录,避免再次执行后销毁不了。
Inherited From:
Default Value: ''
Example:
myObject.evalString = `
  // 技巧1:p是一个内置变量,可以直接使用
  if (p._div) { // 技巧2:evalString有可能执行多次,这个地方的判断是避免div重复创建!
      return;
  }
  // 创建div
  const div = document.createElement('div');
  p._div = div;

  // 技巧3:可以通过p.earth来获取earth变量
  const earth = p.earth;
  `;
See:

readonlyguid : string

对象的唯一标识符
注意,对象一旦创建,guid不可更改!
Inherited From:

heightReference : string

Determines how the model is drawn relative to terrain. 值如下:HeightReference.NONE, HeightReference.CLAMP_TO_GROUND, HeightReference.RELATIVE_TO_GROUND,
Default Value: 'HeightReference.NONE'

incrementallyLoadTextures : boolean

Determine if textures may continue to stream in after the model is loaded.
Default Value: true

luminanceAtZenith : number

材质底色 Cesium 1.61以后默认值为0.2,之前为0.5
Default Value: 0.2

maximumScale : number|undefined

The maximum scale for the model.
Default Value: undefined

minimumPixelSize : number

The approximate minimum pixel size of the model regardless of zoom.
Default Value: 0.0

preUpdateEvalString : string

设置每帧执行语句,和evalString的作用类似
它有三个内置变量,分别是p, scene, time,分别表示当前对象,Cesium的场景对象scene,Cesium的当前帧的时间time 需要注意的是它会每帧执行一次。
Inherited From:
Default Value: ‘’
Example:
myObject.preUpdateEvalString = `
  // 技巧1:p是一个内置变量,可以直接使用,还有scene,time都可以直接使用
     p._angle += 1;
     if (p._angle > 360.0) {
         p._angle = 0.0;
     }
     const angle = p._angle;
     // drawCanvas时使用angle来改变图像内容
     // ...
 `;
See:

scale : boolean

A uniform scale applied to this model.
Default Value: 1.0

shadows : string

Determines whether the model casts or receives shadows from each light source. mode: ShadowMode.CAST_ONLY, ShadowMode.DISABLED, ShadowMode.ENABLED, ShadowMode.RECEIVE_ONLY
Default Value: 'ShadowMode.ENABLED'

show : boolean

是否在三维窗口中显示
Default Value: true

silhouetteColor : Array.<number>

The silhouette color. If more than 256 models have silhouettes enabled, there is a small chance that overlapping models will have minor artifacts.
Default Value: [1.0, 0.0, 0.0, 1.0]

silhouetteSize : number

The size of the silhouette in pixels.
Default Value: 0.0

specularEnvironmentMaps : string|undefined

环境贴图
Default Value: undefined

url : string

资源URL路径 The url to the .gltf file.
Default Value: ''

viewDistance : number

相机飞入时的视距设定,即调用flyTo后,相机距离物体多远处停下来
Default Value: 50.0

xbsjGuid : string|undefined

对象的唯一标识符
警告:该属性已废弃,请不要使用属性,且禁止修改此属性。
如果需要获取guid,请通过guid属性来获取。
Inherited From:

Deprecated: true

xbsjPosition : Array.<number>

位置数组 [经度、纬度、高度]
Default Value: [0, 0, 0]

xbsjRotation : Array.<number>

姿态数组 [偏航角、俯仰角、翻转角]
Default Value: [0, 0, 0]

xbsjScale : Array.<number>

缩放数组 [x向缩放、y向缩放、z向缩放]
Default Value: [1, 1, 1]

readonlyxbsjType : string

获取对象的类型信息
Inherited From:

Methods

destroy()undefined

销毁对象
警告:对象一旦销毁不可再次使用!
警告:挂在场景树上的对象禁止调用destroy方法,只要通过数组函数将其从场景树中移除,就会自动销毁!
Returns:
返回undefined
Inherited From:
Example:
// 使用范例
// 这样写的好处是,一旦对象销毁,会同时将引用该对象的变量同时置为undefined,防止再次使用。
this._myObject = this._myObject && this._myObject.destroy();

flyTo()

飞入该对象
Inherited From:

isDestroyed()boolean

检查对象是否已被销毁
警告:对象一旦销毁不可再次使用!仅此函数可以调用!
Returns:
对象是否已销毁
Inherited From:

nativeModel()

获取Cesium原始模型信息,注意有可能因获取不到而返回undefined

toAllJSON()object

数据整个JSOn对象,包括默认值
Returns:
创建的JSON数据对象
Inherited From:

toAllJSONStr()string

转化成JSON字符串,输出全部元素
Returns:
JSON格式化好的字符串
Inherited From:

toJSON()object

转化成一个JSON数据对象
注意:每次都会创建一个新对象!
Returns:
创建的JSON数据对象
Inherited From:

toJSONStr()string

转化成JSON字符串,默认元素不输出
Returns:
JSON格式化好的字符串
Inherited From:

xbsjFromJSON(jsonObject)

通过JSON数据对象来设置属性
Name Type Description
jsonObject *
Inherited From:
Example:
// 创建一个pin对象
const objConfig = {
    "name": 'Pin1',
    "xbsjType": "Pin",
    "position": [1.9017005694855162, 0.5972477268978722, 488.7695178987821],
    "near": 300,
    "show": false,
    evalString,
};
const pin = new XE.Obj.Pin(earth);  
pin.xbsjFromJSON(objConfig);