波纹环位于地图的背面而不是正面

发布于 2025-01-11 18:08:28 字数 1671 浏览 5 评论 0原文

的前面

我正在尝试使用 Globe,但波纹环总是出现在地图的背面,而不是我正在使用 https://github.com/vasturiano/globe.gl/blob/master/example/random-rings/index.html 作为源 我已经尝试了 BackSide 的波纹环

还有无论如何可以禁用鼠标旋转或禁用鼠标单击或拖动

    const N = 2;
    const gData = [...Array(N).keys()].map(() => ({
        lat: 35.6892,
        lng: 51.3890,
        maxR: Math.random() * 20 + 10,
        propagationSpeed: 2,
        repeatPeriod:1000
    }));

    const colorInterpolator = t => `rgba(255,100,50,${Math.sqrt(1-t)})`;
    
    const world = Globe()
        (document.getElementById('globeViz'))
        .ringsData(gData)
        .ringColor(() => colorInterpolator)
        .ringMaxRadius('maxR')
        .ringPropagationSpeed('propagationSpeed')
        .ringRepeatPeriod('repeatPeriod')
        // .backgroundColor('rgba(0,0,0,0)')
        .showGlobe(false)
        .showAtmosphere(false);

    fetch('https://unpkg.com/world-atlas/land-110m.json').then(res => res.json())
    .then(landTopo => {
        world
            .polygonsData(topojson.feature(landTopo, landTopo.objects.land).features)
            .polygonCapMaterial(new THREE.MeshLambertMaterial({
                color: '#282828',
                side: THREE.DoubleSide
            }))
            .polygonSideColor(() => 'rgba(0,0,0,0)');
    });

    // Add auto-rotation
    world.controls().autoRotate = true;
    world.controls().autoRotateSpeed = 0.9;

预览: https://i.ibb.co/JyjwPL7/s.png

I'm trying to work with Globe but Ripple rings always going on the backside of the map, not in front of it

I'm using https://github.com/vasturiano/globe.gl/blob/master/example/random-rings/index.html as source
and already I tried BackSide for ripple rings

Also is there anyway to disable rotate with mouse or disable mouseclick or drag

    const N = 2;
    const gData = [...Array(N).keys()].map(() => ({
        lat: 35.6892,
        lng: 51.3890,
        maxR: Math.random() * 20 + 10,
        propagationSpeed: 2,
        repeatPeriod:1000
    }));

    const colorInterpolator = t => `rgba(255,100,50,${Math.sqrt(1-t)})`;
    
    const world = Globe()
        (document.getElementById('globeViz'))
        .ringsData(gData)
        .ringColor(() => colorInterpolator)
        .ringMaxRadius('maxR')
        .ringPropagationSpeed('propagationSpeed')
        .ringRepeatPeriod('repeatPeriod')
        // .backgroundColor('rgba(0,0,0,0)')
        .showGlobe(false)
        .showAtmosphere(false);

    fetch('https://unpkg.com/world-atlas/land-110m.json').then(res => res.json())
    .then(landTopo => {
        world
            .polygonsData(topojson.feature(landTopo, landTopo.objects.land).features)
            .polygonCapMaterial(new THREE.MeshLambertMaterial({
                color: '#282828',
                side: THREE.DoubleSide
            }))
            .polygonSideColor(() => 'rgba(0,0,0,0)');
    });

    // Add auto-rotation
    world.controls().autoRotate = true;
    world.controls().autoRotateSpeed = 0.9;

Preview : https://i.ibb.co/JyjwPL7/s.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷迭香的记忆 2025-01-18 18:08:28

根据文档,默认的 ringAltitude0.0015,而默认的 polygonAltitude0.01。如果将ringAltitude 设置为大于polygonAltitude,则环将出现在地形上。运行下面的代码片段以查看其实际效果。

const N = 2
const gData = [...Array(N).keys()].map(() => ({
  lat: 35.6892,
  lng: 51.389,
  maxR: Math.random() * 20 + 10,
  propagationSpeed: 2,
  repeatPeriod: 1000,
}))

const colorInterpolator = t => `rgba(255,100,50,${Math.sqrt(1 - t)})`

const world = Globe()(document.getElementById('globeViz'))
  .ringsData(gData)
  .ringColor(() => colorInterpolator)
  .ringMaxRadius('maxR')
  .ringPropagationSpeed('propagationSpeed')
  .ringRepeatPeriod('repeatPeriod')
  .ringAltitude(0.015) // <--- change of interest.

fetch('https://unpkg.com/world-atlas/land-110m.json')
  .then(res => res.json())
  .then(landTopo => {
    world
      .polygonsData(topojson.feature(landTopo, landTopo.objects.land).features)
      .polygonCapMaterial(
        new THREE.MeshLambertMaterial({
          color: '#282828',
          side: THREE.DoubleSide,
        }),
      )
      .polygonSideColor(() => 'rgba(0,0,0,0)')
  })

// Add auto-rotation
world.controls().autoRotate = true
world.controls().autoRotateSpeed = -0.9
<div id="globeViz"></div>
<script src="//unpkg.com/globe.gl"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.min.js"></script>

According to the documentation, the default ringAltitude is 0.0015, whereas the default polygonAltitude is 0.01. If you set the ringAltitude to be greater than polygonAltitude, the rings will appear over the land shapes. Run the snippet below to see it in action.

const N = 2
const gData = [...Array(N).keys()].map(() => ({
  lat: 35.6892,
  lng: 51.389,
  maxR: Math.random() * 20 + 10,
  propagationSpeed: 2,
  repeatPeriod: 1000,
}))

const colorInterpolator = t => `rgba(255,100,50,${Math.sqrt(1 - t)})`

const world = Globe()(document.getElementById('globeViz'))
  .ringsData(gData)
  .ringColor(() => colorInterpolator)
  .ringMaxRadius('maxR')
  .ringPropagationSpeed('propagationSpeed')
  .ringRepeatPeriod('repeatPeriod')
  .ringAltitude(0.015) // <--- change of interest.

fetch('https://unpkg.com/world-atlas/land-110m.json')
  .then(res => res.json())
  .then(landTopo => {
    world
      .polygonsData(topojson.feature(landTopo, landTopo.objects.land).features)
      .polygonCapMaterial(
        new THREE.MeshLambertMaterial({
          color: '#282828',
          side: THREE.DoubleSide,
        }),
      )
      .polygonSideColor(() => 'rgba(0,0,0,0)')
  })

// Add auto-rotation
world.controls().autoRotate = true
world.controls().autoRotateSpeed = -0.9
<div id="globeViz"></div>
<script src="//unpkg.com/globe.gl"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.min.js"></script>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文