首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react mapbox-具有三个js意外排序的gl自定义图层

react mapbox-具有三个js意外排序的gl自定义图层
EN

Stack Overflow用户
提问于 2020-04-30 01:57:09
回答 1查看 782关注 0票数 1

我正在mapbox gl上工作,以显示使用自定义图层的gltf建筑物,我还显示了mapbox提供的默认3d-buildings,如下所示:

代码语言:javascript
复制
  export default {
  id: '3d-buildings',
  source: 'composite',
  'source-layer': 'building',

  filter: [
    'all',
    ['!=', ['id'], 59],
    ['!=', ['id'], 88],
    ['!=', ['id'], 79],
    ['!=', ['id'], 78],
    ['!=', ['id'], 80],
    ['!=', ['id'], 32],
    ['!=', ['id'], 8],
    ['!=', ['id'], 2],
    ['!=', ['id'], 4],
    ['!=', ['id'], 22],
    ['!=', ['id'], 3],
    ['!=', ['id'], 5],
    ['!=', ['id'], 60]
  ],
  type: 'fill-extrusion',
  minzoom: 1,
  paint: {
    'fill-extrusion-color': '#aaa',
    'fill-extrusion-height': ['interpolate', ['linear'], ['zoom'], 15, 0, 15.05, ['get', 'height']],
    'fill-extrusion-base': ['interpolate', ['linear'], ['zoom'], 15, 0, 15.05, ['get', 'min_height']],
    'fill-extrusion-opacity': 1
  }
};

我正在使用过滤器从地图上删除一些建筑物。下面是我如何使用threebox显示自定义图层

代码语言:javascript
复制
import Threebox from '../../../../../threebox/Threebox';

export default (buildings) => {
  return {
    id: '3d-layer',
    type: 'custom',
    renderingMode: '3d',
    onAdd: function(map, gl) {
      map.moveLayer('3d-buildings', '3d-layer');
      this.tb = new Threebox(map, gl);
      let allBuildings = buildings;
      this.tb.defaultLights();
      for (let i = 0; i < allBuildings.length; i++) {
        this.tb.loadObj({obj: allBuildings[i].url, scale: 0.08, rotation: allBuildings[i].rotation, building: allBuildings[i].id}, obj => {
          obj.setCoords(allBuildings[i].coordinates);
          this.tb.add(obj);
        });
      }
    },
    render: function(map, gl) {
      map.clear(map.DEPTH_BUFFER_BIT);
      this.tb.update();
    }
  };
};

下面是渲染层时的外观:

如您所见,建筑物显示在3d-buildings层的顶部。我已经在网上搜索过了,想解决这个问题,但没有结果。如果有人能帮我解决这个问题,我将不胜感激。谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-07-06 05:40:36

我已经在我的[Threebox fork]上解决了这个问题,对CameraSync对象进行了微调,更改了最近和最远的计算。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61508469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档