mars3d的V2版本的Video2D与V3版本的Video2D实现数据快速迁移

场景:

目前是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.position
  camera.direction = oldStyle.camera.direction
  camera.up = oldStyle.camera.up
  camera.right = oldStyle.camera.right

  const 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)
  }
}
相关推荐
这里有鱼汤15 分钟前
miniQMT下载历史行情数据太慢怎么办?一招提速10倍!
前端·python
用户214118326360243 分钟前
dify案例分享-免费玩转 AI 绘图!Dify 整合 Qwen-Image,文生图 图生图一步到位
前端
IT_陈寒1 小时前
Redis 性能翻倍的 7 个冷门技巧,第 5 个大多数人都不知道!
前端·人工智能·后端
mCell8 小时前
GSAP ScrollTrigger 详解
前端·javascript·动效
gnip8 小时前
Node.js 子进程:child_process
前端·javascript
excel11 小时前
为什么在 Three.js 中平面能产生“起伏效果”?
前端
excel12 小时前
Node.js 断言与测试框架示例对比
前端
天蓝色的鱼鱼13 小时前
前端开发者的组件设计之痛:为什么我的组件总是难以维护?
前端·react.js
codingandsleeping13 小时前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
石金龙14 小时前
[译] Composition in CSS
前端·css