调整模型位置及高度

1.数字模型

InitPoLiShuZiModel() {

let UrlsDMU = imageUrl.Model.Model20200420DMU;

ZhiYunGisProperty.PoLiShuZiModel = [];

UrlsDMU.forEach(item => {

// 经纬度高度

let longitude = 119.77247739757397;

let latitude = 35.69295362813212;

let height = 100;

let heading = 0;

let scale = 1;

let degrees = -2.036954362399994;

let tileset = new NF.Cesium3DTileset({

url: ImageUrl + item,

maximumScreenSpaceError: 2,

show: false,});

let ModelDMU =ZhiYunGisProperty.ZhiYunViewer.scene.primitives.add(tileset); ZhiYunGisProperty.PoLiShuZiModel.push(ModelDMU); tileset.readyPromise.then(function (argument) { ZhiYunGisProperty.changeModelTilesetPosition(tileset, longitude, latitude, height, heading, scale, degrees); }); }); console.log("初始化:==>数字孪生城市---规划"); },

 

// 转换矩阵

changeModelTilesetPosition(tileset, lon, lat, height, heading, scale, degree) {

let position = NF.Cartesian3.fromDegrees(lon, lat, height);

let mat = NF.Transforms.eastNorthUpToFixedFrame(position);

let rotationX = NF.Matrix4.fromRotationTranslation(NF.Matrix3.fromRotationZ(NF.Math.toRadians(heading)));

NF.Matrix4.multiply(mat, rotationX, mat);

let m = NF.Matrix4.fromUniformScale(scale);

NF.Matrix4.multiply(mat, m, mat);

tileset.root.transform = mat; },

2.倾斜模型

InitPoLiDSMModel() {

ZhiYunGisProperty.Model20200304DSM = [];

//4*4 转换矩阵

let matrix = NF.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,

1.0, 1.0, 1.0, 1.0 ]);

let tileset = new NF.Cesium3DTileset({

url: "Production_1302_3dTiles.json",

modelMatrix: matrix,

maximumScreenSpaceError: 2,

show: true, });

let dsmModel = ZhiYunGisProperty.ZhiYunViewer.scene.primitives.add(tileset) ZhiYunGisProperty.Model20200304DSM.push(dsmModel);

console.log("初始化:==>倾斜模型---规划"); },

你可能感兴趣的:(Cesiumjs)