xeokit-sdk icon indicating copy to clipboard operation
xeokit-sdk copied to clipboard

WebGL Error and bad rendering with VBO rendering and Firefox on big models

Open Amoki opened this issue 3 months ago • 1 comments

Describe the bug

Image We only see edges. Error in console is: ` WebGL warning: drawElementsInstanced: Context's max indexCount is 30000000, but 44278101 requested. [webgl.max-vert-ids-per-draw]`

To Reproduce

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>xeokit Example</title>
</head>

<body>
  <input type="checkbox" id="info-button" />
  <label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label>
  <canvas id="myCanvas" width="1000" height="800"></canvas>
  <canvas id="myNavCubeCanvas"></canvas>
</body>

<script type="module">
  import { Viewer, FastNavPlugin, NavCubePlugin, XKTLoaderPlugin } from "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.min.es.js";


  const viewer = new Viewer({
    canvasId: "myCanvas",
    transparent: true,
    dtxEnabled: false,
    saoEnabled: true
  });

  viewer.camera.eye = [-23.68, 96.85, 30.65];
  viewer.camera.look = [60.59, 42.37, -25.39];
  viewer.camera.up = [0.39, 0.88, -0.26];

  const xktLoader = new XKTLoaderPlugin(viewer);

  const sceneModel = xktLoader.load({
    id: "myModel",
    src:
      "https://raw.githubusercontent.com/xeokit/xeokit-sdk/refs/heads/master/assets/models/xkt/v6/APHS/APHS.xkt",
    //metaModelSrc: "../../assets/models/xkt/v6/APHS/APHS.json", // Creates a MetaObject instances in scene.metaScene.metaObjects
    edges: true,
    saoEnabled: false
  });
</script>
</html>

The bug doesn't append on Chrome.

Desktop (please complete the following information):

  • OS: tested on Ubuntu and MacOS
  • Browser: Firefox
  • Version: latest

Amoki avatar Oct 02 '25 09:10 Amoki

I suspect this is fixable by limiting the size of batched geometry buffers to webgl.max-vert-ids-per-draw. We always try to build the biggest buffers possible for fewer draw calls, but we're not actually considering that limit.

xeolabs avatar Oct 02 '25 09:10 xeolabs