代码
import {BaiduMapConfig, BaiduVectorTileProvider, DynamicSky, Engine} from '@baidumap/mapv-three';

BaiduMapConfig.ak = '您的密钥';

const container = document.getElementById('map');
const aspect = container.clientWidth / container.clientHeight;
const center = [121.5071, 31.2396, 140];
const overview = {
  range: Math.max(2_000, 1_900 / aspect),
  pitch: 55,
  heading: 35,
};
// 上海中心大厦经纬度来自百度地点检索,高度用于把塔身居中。
const tower = [121.511937, 31.239212, 265];
const engine = new Engine(container, {
  map: {
    center,
    ...overview,
    provider: new BaiduVectorTileProvider({
      displayOptions: {
        flat: false,
        building: true,
        poi: false,
      },
    }),
  },
  rendering: {
    sky: null,
    enableAnimationLoop: true,
  },
  clock: {
    currentTime: new Date(2026, 5, 21, 16),
  },
});
engine.add(new DynamicSky());

document.querySelector('#view').onclick = () =>
  engine.map.lookAt(tower, {
    range: Math.max(1_050, 990 / aspect),
    pitch: 48,
    heading: 315,
  });
document.querySelector('#reset').onclick = () => engine.map.lookAt(center, overview);

以陆家嘴为参照,用 lookAt 在城市全景与上海中心近景之间快速切换。

预览