代码
import {DynamicSky, Engine} from '@baidumap/mapv-three';
import {BoxGeometry, Color, Mesh, MeshBasicMaterial, SphereGeometry} from 'three';

const container = document.getElementById('map');
const aspect = container.clientWidth / container.clientHeight;
const engine = new Engine(container, {
  map: {
    provider: null,
    center: [0, 0, 3],
    range: 108 / Math.min(1, aspect),
    pitch: 74,
    heading: 8,
  },
  rendering: {
    sky: null,
    enableAnimationLoop: true,
    features: {
      bloom: {
        enabled: true,
        strength: 0.45,
        threshold: 1,
      },
    },
  },
  clock: {
    currentTime: new Date(2026, 5, 21, 19, 12),
  },
});
engine.add(new DynamicSky());

const deck = new Mesh(new BoxGeometry(62, 19, 3), new MeshBasicMaterial({color: '#344861'}));
deck.position.z = -1.5;
engine.add(deck);

const housing = new BoxGeometry(4, 4, 7);
const lamp = new SphereGeometry(2.8, 32, 16);
for (const [x, brightness] of [
  [-16, 5],
  [16, 0.65],
]) {
  const mast = new Mesh(housing, new MeshBasicMaterial({color: '#7b97ae'}));
  mast.position.set(x, 0, 3.5);
  engine.add(mast);

  const beacon = new Mesh(
    lamp,
    new MeshBasicMaterial({color: new Color(brightness, brightness * 0.46, 0.09)}),
  );
  beacon.position.set(x, 0, 9);
  engine.add(beacon);
}

const control = document.getElementById('bloom');
control.addEventListener('click', () => {
  const enabled = control.getAttribute('aria-pressed') !== 'true';
  engine.rendering.bloom.enabled = enabled;
  control.setAttribute('aria-pressed', String(enabled));
  engine.requestRender();
});

用码头上高亮与低亮的航标比较泛光阈值,关闭泛光可直接观察亮度与光晕的区别。

预览