refactor: replace webgl-layer-framework with webgl-layer module

- Removed the webgl-layer-framework module and its associated tests.
- Introduced a new webgl-layer module to handle WebGL2 layer management.
- Updated references throughout the codebase to use the new webgl-layer module.
- Adjusted layer registration and rendering logic to align with the new structure.
- Ensured compatibility with existing functionality while improving modularity.
This commit is contained in:
Azgaar 2026-03-12 19:15:49 +01:00
parent d1d31da864
commit 9e00d69843
37 changed files with 380 additions and 7187 deletions

View file

@ -41,25 +41,6 @@ viewbox.on("zoom.webgl", handler);
(window as any).scale(globalThis as any).viewX;
```
The only exception is a Node/test-env guard where the global may genuinely not exist:
```ts
if (typeof viewbox === "undefined") return; // guard for Node test env
viewbox.on("zoom.webgl", handler); // then use directly
```
In `webgl-layer-framework.ts` the `syncTransform()` method correctly reads:
```ts
buildCameraBounds(viewX, viewY, scale, graphWidth, graphHeight);
```
### Why this matters for new WebGL/canvas overlays
Any canvas or WebGL overlay that must stay pixel-aligned with the SVG viewbox **must**
read `scale`, `viewX`, `viewY` at render time — these are live globals updated on every
D3 zoom event. Do not cache them at module load time.
### Other public/modules globals of note
`toggleRelief`, `drawRelief`, `undrawRelief`, `rerenderReliefIcons`, `layerIsOn`,
@ -72,8 +53,3 @@ functions defined in public JS files and available globally.
2. `src/utils/index.ts`, `src/modules/index.ts`, `src/renderers/index.ts` — ES modules
(bundled by Vite); these run **before** the deferred legacy scripts
3. `public/main.js` and `public/modules/**/*.js` — deferred plain scripts
**Implication:** ES modules in `src/` that call `WebGL2LayerFramework.register()` at
module load time are safe because the framework class is instantiated at the bottom of
`webgl-layer-framework.ts` (an ES module), which runs before the deferred `main.js`.
`main.js` then calls `WebGL2LayerFramework.init()` inside `generateMapOnLoad()`.