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

Three.js - can't render cube on Mapbox GL JS custom WebGL layer

我正在尝试使用此示例渲染立方体:Add a 3D model

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

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

这里codepen重现问题。 (重新加载页面以查看立方体片刻)

我有同样的问题,但通过将 render() 函数中的 renderer.state.reset() 替换为 renderer.resetState() 来解决,renderer.resetState() 在 r124 中引入并在 r126 中得到改进。

Mapbox example 也已更新。