Skip to content

地图显示成球体

loading

此功能已提供内置插件,直接调用即可。

ts
// 填加伪球体
const frakeEarth = plugin.createFrakEarth(map);
map.add(frakeEarth);

下面简单说下原理:

three-tile 的地图不是球体,而是平面地图。不是做不到,而是没必要,徒增程序的复杂度。但有的同学因此认为 three-tile 是伪三维。好吧,写个简单的着色器满足你。

thee-tile 内置了一个 FakeEarth,给平面地图加个伪球体遮罩,让它看起来像个球:

ts
/**
 * 添加伪球体
 * @param viewer 视图
 * @param map  地图
 * @returns 地球遮罩模型
 */
function addFakeEarth(viewer, map) {
  const fakeEarth = new plugin.FakeEarth(viewer.scene.fog?.color || new Color(0));
  fakeEarth.name = "fakeearth";
  fakeEarth.applyMatrix4(map.rootTile.matrix);
  map.add(fakeEarth);
  return fakeEarth;
}
addFakeEarth(viewer, map);


Released under the MIT License.