Documentation is work in progress and not completeEditor
3D System

3D Performance Guide

The dominant performance constraints in the 3D system are the browser WebGL context limit and texture memory — not polygon count. This guide covers both, plus the disposal discipline that keeps them under control.

WebGL Context Limit

Browsers enforce a hard limit on simultaneous WebGL contexts, typically 8 to 16. Because each ThreeDShapeElement creates its own renderer and therefore its own context, exceeding the limit causes the oldest context to be silently lost, leaving blank or corrupted viewports.

  • Always call dispose() when deleting a 3D shape. This is what actually releases the context.
  • Use pause() and resume() for shapes that go off-screen. Note that pauseLoop() stops rendering but does not release the context — only dispose() does that.
  • Keep simultaneous 3D shapes under 8 to stay safe across all browsers.

Texture Memory

Texture memory is usually the larger bottleneck compared with polygon count.

Texture SizeApproximate GPU Memory
2048 x 2048 RGBA~16 MB
4096 x 4096 RGBA~64 MB

Multiple maps on a single material multiply this cost. The texture cache in MaterialSystem avoids loading duplicates across objects.

Polygon Budget

  • Simple primitives — a box, or a sphere at 32 segments — are roughly 1K to 2K triangles. No concern.
  • Imported models above 100K triangles will degrade performance, especially with several shapes on the canvas.
  • ThreeDShapePreview creates temporary engines; ensure they are disposed when the picker closes.

Pixel Ratio Cap

this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));

On a 3x display, rendering at 3x means nine times the pixels of 1x. The visual difference between 2x and 3x is negligible while the GPU cost is not, so the ratio is capped at 2 for consistent performance across devices.

Disposal Checklist

ResourceCallReleases
Geometriesgeometry.dispose()Vertex buffer GPU memory
Materialsmaterial.dispose()Shader programs
Texturestexture.dispose()Texture GPU memory
Rendererrenderer.dispose()The WebGL context
SceneManager.removeObject() handles geometries and materials automatically by traversing the mesh. Textures must be released separately via disposeTextureByUrl(). The renderer is disposed by ThreeDEngine.dispose().