Three layers
How the core, the WebGL2 renderer and the UI are separated.
Core: the scene, tools, selection and undo, in JavaScript with no rendering code. It can be tested without a browser canvas.
Renderer: a WebGL2 module with the camera, grid, picking and thumbnails.
UI: the editor panels, content browser, units and admin area, which talk to the core through an event bus.
Every frame, the renderer reads the scene and the selection from the core. Tools edit the model and never call WebGL.
This separation let me build the tools before the renderer. The first version ran against a 2D debug wireframe, and I could test tools and undo on it. The viewport now runs on WebGL2; the remaining renderer work is listed in the renderer section.