【Mars3d】openFlyAnimation执行开场动画前的视角效果设置

发布于:2024-12-18 ⋅ 阅读:(148) ⋅ 点赞:(0)

相关链接:

http://mars3d.cn/editor-vue.html?key=ex_1_3_1&id=map/fun/openFlyAnimation

问题说明:

openFlyAnimation执行开场动画前的视角如何设置,目前 scene: { center: 决定的执行后的视角

在cameraController中设置maximumZoomDistance是调整最远视距,只能说可以让地图最远到那个地方,但是默认地球开始转动时,最远视距默认不是maximumZoomDistance

实现代码:

import * as mars3d from "mars3d"

export const mapOptions = {
  scene: {
    center: { "lat": 37.530873, "lng": 102.784238, "alt": 50007057.2, "heading": 356.4, "pitch": -89.8 }
  }
}


export let map // mars3d.Map三维地图对象


/**
 * 初始化地图业务,生命周期钩子函数(必须)
 * 框架在地图初始化完成后自动调用该函数
 * @param {mars3d.Map} mapInstance 地图对象
 * @returns {void} 无
 */
export function onMounted(mapInstance) {
  map = mapInstance // 记录map

  setTimeout(() => {
    startAnimation()
  }, 1000)
}

/**
 * 释放当前地图业务的生命周期函数
 * @returns {void} 无
 */
export function onUnmounted() {
  map = null
}

export function startAnimation() {
  map.flyHome({ duration: 0 })

  // 开场动画
  map.openFlyAnimation({
    center: { "lat": 31.833795, "lng": 117.131291, "alt": 3152.6, "heading": 0, "pitch": -86.6 }
    // duration1:4,
    // easingFunction1: Cesium.EasingFunction.QUINTIC_IN_OUT,
  }).then(() => {
    // 动画播放完成后回调
  })
}

export function stopAnimation() {
  map.camera.cancelFlight()
}


网站公告

今日签到

点亮在社区的每一天
去签到