ModelTransformTool

new Cesium.ModelTransformTool(layer, callback)

模型变换工具集
Name Type Description
layer SceneLayer | MapGISM3DSet | Cesium3DTileset | undefined optional 模型对象
callback function optional 模型编辑工具编辑后的回调函数 模型对象为空时,需要在调用具体的变换接口时指定要变换的模型。 推荐在调用变换接口时指定模型。
Author:
  • 基础平台-杨琨
See:

Methods

activeRotationEditor(options)

可视化旋转工具
Name Type Description
options Object
Name Type Description
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要控制的模型

activeScaleEditor(options)

可视化缩放工具
Name Type Default Description
options Object {} optional 工具参数
Name Type Default Description
singleScale boolean false optional 是否单轴缩放,true:单轴缩放,false:三轴同时缩放
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要控制的模型

activeTranslationEditor(options)

可视化平移工具
Name Type Description
options Object
Name Type Description
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要控制的模型
取消激活可视化工具
销毁工具

getEulerFromTransform(transformInLocal, model, rotationPoint)

根据模型的tansform矩阵获取欧拉角
Name Type Description
transformInLocal Matrix4
model MapGISM3DSet | MapGISM3D | Cesium3DTileset optional 模型对象;
rotationPoint Cartesian3 optional 旋转中心;缺省时旋转中心默认为模型外包球中心

initModelEditor(viewer)

初始化可视化模型变换工具
Name Type Description
viewer Viewer Cesium的viewer对象
重置模型位置到初始状态,只会重置通过构造函数传入的模型。
控制模型在本地空间下做旋转变换
Name Type Description
options Object
Name Type Description
rotation Cartesian3 | HeadingPitchRoll optional 旋转角度; HeadingPitchRoll类型为弧度制,Cartesian3类型为角度制。
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要被旋转的模型; 置空时将从构造函数的layer中取M3D模型。不推荐置空。
rotationPoint Cartesian3 optional 旋转中心; 缺省时绕模型自身的原点旋转;旋转的是SceneLayer图层时,SceneLayer下的所有图层绕第一个MapGISM3DSet的boundingSphere.center旋转。
Example:
var modelTransformTool = new Cesium.ModelTransformTool();
// 从SceneLayer图层中获取MapGISM3DSet
var model = layer._m3dLayerMap.values()[0];
modelTransformTool.initModelEditor(viewer);
// 通过角度控制
modelTransformTool.rotateLocal({
    // 绕Z轴旋转90度
    rotation: new Cesium.Cartesian3(0, 0, 90),
    model: model,
    rotationPoint: model.boundingSphere.center
})
// 通过headingpitchroll控制
modelTransformTool.rotateLocal({
    // 绕Z轴旋转90度
    rotation: new Cesium.HeadingPitchRoll(CesiumMath.toRadians(90), 0, 0),
    model: model,
    rotationPoint: model.boundingSphere.center
})
设置模型缩放
Name Type Description
options Object
Name Type Description
size Cartesian3 optional 缩放矢量
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要被平移的模型, 置空时将从构造函数的layer中取M3D模型。不推荐置空。
Example:
var modelTransformTool = new Cesium.ModelTransformTool();
modelTransformTool.initModelEditor(viewer);
modelTransformTool.setLocalScala({
    size: new Cesium.Cartesian3(2, 2, 2),
    // 从SceneLayer图层中获取MapGISM3DSet
    model: layer._m3dLayerMap.values()[0]
})

setPositionWorld(options)

设置M3D模型在笛卡尔世界坐标系下位置
Name Type Description
options Object
Name Type Description
position Cartesian3 optional 位置 笛卡尔坐标系
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要被设置的模型, 置空时将从构造函数的layer中取M3D模型。不推荐置空。
Example:
var modelTransformTool = new Cesium.ModelTransformTool();
modelTransformTool.initModelEditor(viewer);
modelTransformTool.setPositionWorld({
    position: Cesium.Cartesian3.fromDegrees(113.0750, 30, 100),
    // 从SceneLayer图层中获取MapGISM3DSet
    model: layer._m3dLayerMap.values()[0]
})

setRotation(degree, axis)

模型旋转
Name Type Default Description
degree Number 0 optional 旋转角度,单位度
axis String 'Z' optional 旋转轴,X:X轴,Y:Y轴,Z:Z轴

deprecated setScala(x, y, z)

模型缩放
Name Type Default Description
x Number 1 optional x轴放大
y Number 1 optional y轴放大
z Number 1 optional z轴放大

Deprecated: 请使用ModelTransformTool#setLocalScala

setTranslation(longitude, latitude, height)

模型平移
Name Type Default Description
longitude Number 0 optional 经度
latitude Number 0 optional 纬度
height Number 0 optional 高度

translateWorld(options)

设置M3D模型在笛卡尔世界坐标系下平移
Name Type Description
options Object
Name Type Description
vector Cartesian3 optional 平移矢量 笛卡尔坐标系
model MapGISM3DSet | MapGISM3D | Cesium3DTileset | SceneLayer optional 要被平移的模型, 置空时将从构造函数的layer中取M3D模型。不推荐置空。
Example:
var modelTransformTool = new Cesium.ModelTransformTool();
modelTransformTool.initModelEditor(viewer);
modelTransformTool.translateWorld({
    vector: new Cesium.Cartesian3(5000, 0, 1000),
    // 从SceneLayer图层中获取MapGISM3DSet
    model: layer._m3dLayerMap.values()[0]
})