Cesium中模型的平移、旋转、缩放等操作很常见。
我在网上找了很多资料,应用到项目中却无法运行,因为版本不一致。
对于当前版本1.72,我的应用如下:
setScale() {
this.entity.model.scale = this.scale
},
setRotate() {
const origin = this.entity.position.getValue()
const heading = Cesium.Math.toRadians(this.rotateX)
const pitch = Cesium.Math.toRadians(this.rotateY)
const roll = Cesium.Math.toRadians(this.rotateZ)
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll)
const orientation = Cesium.Transforms.headingPitchRollQuaternion(origin, hpr)
this.entity.orientation = orientation
}
相对于网上给出的矩阵操作,是不是很简单?