场景:
目前是v2和v3的两个相机视角的不同格式,在Mars3d的V2的旧数据想可以快速迁移到V3版本。
V2版本的数据:
{"camera": {"fov": 1.0471975511965976,"dis": 20,"stRotation": 0,"showFrustum": true,"aspectRatio": 1.6022099447513811,"camera": {"position": {"x": -2177820.3029543245,"y": 4388724.089003264,"z": 4070105.7812721003},"direction": {"x": 0.64574289308262001,"y": 0.56956514491665855,"z": -0.50853875145297822},"up": {"x": -0.24582927592774592,"y": 0.78563308172943203,"z": 0.56775754331330175},"right": {"x": 0.72289977391760774,"y": -0.2416116855377268,"z": 0.64733276626592173}}}
}
迁移示例地址:V3的示例:
http://mars3d.cn/editor-vue.html?key=ex_7_10_4&id=graphic/video/video2D
迁移代码参考:
function addDemoGraphic1() {const video2D = new mars3d.graphic.Video2D({position: [117.205459, 31.842988, 64.3],style: oldStyle2New({camera: {"position": {"x": -2177820.3029543245, "y": 4388724.089003264, "z": 4070105.7812721003},direction: { x: -0.20300781957546601, y: 0.3881445982693198, z: -0.8989613985180693 },up: { x: -0.41112481743883666, y: 0.7994469141644973, z: 0.43801942413407347 },right: { x: 0.8886867894129509, y: 0.4585067090754624, z: -0.0027180978075245542 }},dis: 70,fov: 52,aspectRatio: 3,stRotationDegree: 0})})graphicLayer.addGraphic(video2D)
}// 历史参数转为当前最新版本的参数
function oldStyle2New(oldStyle) {const camera = new Cesium.Camera(map.scene)camera.position = oldStyle.camera.positioncamera.direction = oldStyle.camera.directioncamera.up = oldStyle.camera.upcamera.right = oldStyle.camera.rightconst angle = Cesium.Math.toDegrees(oldStyle.fov/ 2)return {distance: oldStyle.dis,angle: angle,angle2: angle / oldStyle.aspectRatio,heading: Cesium.Math.toDegrees(camera.heading) - 90,pitch: Cesium.Math.toRadians(camera.pitch),roll: Cesium.Math.toRadians(camera.roll)}
}