ModelExplosion

new Cesium.ModelExplosion(viewer)

M3D爆炸工具(仅支持M3D 2.0/2.1)
Name Type Description
viewer Viewer 场景视图对象

Methods

explosionByField(tilesets, options)

根据图层的属性,进行模型爆炸
Name Type Description
tilesets Array.<MapGISM3DSet> M3DSet
options Object 附加参数
Name Type Default Description
moveDirection Cartesian3 new Cartesian3(1, 0, 0) optional 爆炸方向,可以任意设置
field String 'OID' optional 过滤字段名,默认oid
valueGroups Object [] optional 爆炸过滤参数
type String unique optional 过滤方式,unique:单值,range:分段,contain:包含
duration Number 0 optional 爆炸动画的持续时间(单位毫秒),默认值为0,即无爆炸动画
enableContinuousExplosion Number false optional 是否持续执行模型爆炸操作。当该值为false时,仅会执行一次模型爆炸操作,当该值为true时,会监听模型的动态加载,每当触发模型加载事件后,则会再次执行一次模型爆炸操作;对于LOD模型建议将该参数设置为true
Example:
// 1. 单方向爆炸:moveDirection
const valueGroups = [
  {
    value: 1,
    distance: 1100,
  },
  {
    value: 2,
    distance: 900,
  },
  {
    value: 3,
    distance: 750,
  },
  {
    value: 4,
    distance: 600,
  },
];
modelExplosion.explosionByField([tileset], {
  valueGroups: valueGroups,
  moveDirection: new Cesium.Cartesian3(0, 1, 0),
  type: "unique",
  field: tileset._version === "2.1" ? "tid" : "OID",
  duration: 1000,
});

// 2. 多方向爆炸
const valueGroups = [
  {
    value: 0,
    direction: new Cesium.Cartesian3(1000, 0, 0),
  },
  {
    value: 1,
    direction: new Cesium.Cartesian3(0, 0, 1000),
  },
  {
    value: 3,
    direction: new Cesium.Cartesian3(-1000, 0, 0),
  },
];
modelExplosion.explosionByField([tileset], {
  valueGroups: valueGroups,
  type: "unique",
  field: tileset._version === "2.1" ? "tid" : "OID",,
  duration: 1000,
});

resetExplosionByField(tilesets)

还原爆炸
Name Type Description
tilesets Array.<MapGISM3DSet>