Three.js - 无法在 Mapbox GL JS 自定义 WebGL 层上渲染立方体

mic*_*ace 5 javascript three.js mapbox-gl-js

我正在尝试使用此示例渲染多维数据集:添加 3D 模型

示例在three.js 上工作到117 版本。由于 118 版本示例不起作用:多维数据集在页面刷新后立即消失。我研究了变更日志,最明显的变化是,自从 v118 Three.js 使用 WebGL2 作为默认渲染引擎。所以我更改了代码以使用 WebGL1,但立方体仍然消失。

  this.renderer = new THREE.WebGL1Renderer({
  canvas: map.getCanvas(),
  context: gl,
  antialias: true
});
Run Code Online (Sandbox Code Playgroud)

这是重现问题的代码笔。(重新加载页面以查看立方体片刻)

小智 2

我遇到了同样的问题,但通过替换r124 中引入并在 r126 中改进的函数renderer.state.reset()解决了这个问题。render()renderer.resetState()

Mapbox 示例也已更新。