Cesium创建平移、旋转、缩放矩阵

  1. 创建平移矩阵 4x4
//创建平移矩阵方法一
const mat4 = Cesium.Matrix4.fromArray([
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
x, y, z, 1.0
]);

//创建平移矩阵方法二
const translation = Cesium.Cartesian3.fromArray([x, y, z]);
const mat4 = Cesium.Matrix4.fromTranslation(translation);
  1. 创建旋转矩阵 4x4
const mat3RoateX = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45))
const mat4 = Cesium.Matrix4.fromRotationTranslation(mat3RoateX)
  1. 创建旋转加平移矩阵 4x4
const translation = Cesium.Cartesian3.fromArray([x, y, z]);
const mat3RoateX = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45))
const mat4 = Cesium.Matrix4.fromRotationTranslation(mat3RoateX, translation)
  1. 创建一个缩放矩阵 4x4
// Creates
//   [7.0, 0.0, 0.0, 0.0]
//   [0.0, 8.0, 0.0, 0.0]
//   [0.0, 0.0, 9.0, 0.0]
//   [0.0, 0.0, 0.0, 1.0]
var mat4 = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));

你可能感兴趣的:(Cesium)