mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-09-11 04:04:30 +00:00
refactor(h3d-carve-2): extract Three.js loader to src/three-loader.js
Move the D-section (~21 lines) from screen.js factory scope to its own module.
Exports:
- loadThree() — memoised import() with local-vendor→CDN fallback; same body verbatim
- T (live let-binding) — updated to the Three.js namespace on first resolution
screen.js gains: import { loadThree, T } from './src/three-loader.js'
screen.js loses: let T = null; let threeLoadPromise = null; function loadThree()
T and loadThree remain accessible to the IIFE via module-scope closure. The live
let-binding means the IIFE reads the populated T after loadThree() resolves
without any call-site changes.
Panel-controls vm test: strip regex extended to consume all consecutive import
lines; T: null + loadThree stubs added to sandbox context.
Class-killer tests (8 new — highway_3d_three_loader.test.js):
- loadThree exported (mutation: rename/remove → import fails)
- T exported as mutable let (mutation: const → T=mod throws TypeError)
- T=mod in both .then handlers (mutation: remove both → T stays null)
- memoisation guard !threeLoadPromise (mutation: remove → race + duplicate loads)
- CDN fallback .catch chain (mutation: remove → deploy failures unrecoverable)
- threeLoadPromise reset on failure (mutation: remove → no retry possible)
- screen.js imports loadThree+T (wiring confirmed)
- IIFE no longer declares local T or threeLoadPromise (shadow defeated)
All class-killer mutations confirmed distinguishable before commit.
Base run (5e401af): 180/180 pass.
Post-cut run: 188/188 pass.
Command: node --test tests/js/highway_3d*.test.js plugins/highway_3d/tests/*.test.js
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uZ169yfoFYArXz962g7KW
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
5e401afe87
commit
8ea123deaf
@@ -7,6 +7,7 @@
|
||||
// changes.
|
||||
|
||||
import { geoFretX, dZ, slideTrailEnd, camBaseDistU, camLowFretPullbackU, computeBPM, _makeGaussTex, RENDER_ORDER_LAYER_STACK, RENDER_ORDER_LAYER_INDEX, RENDER_ORDER_AT_Z_ZERO, RENDER_ORDER_FAR_CLAMP, renderOrderForLayerAtZ, _noteKey, lowerBoundT, hwyFirstRelevantFrettedTime, geoFretMid } from './src/geometry.js'; // h3d-carve-1b
|
||||
import { loadThree, T } from './src/three-loader.js'; // h3d-carve-2
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
@@ -1479,26 +1480,8 @@ import { geoFretX, dZ, slideTrailEnd, camBaseDistU, camLowFretPullbackU, compute
|
||||
|
||||
// computeBPM, _makeGaussTex — moved to src/geometry.js (h3d-carve-1).
|
||||
|
||||
/* ======================================================================
|
||||
* Three.js module — lazily loaded, memoized
|
||||
* ====================================================================== */
|
||||
|
||||
let T = null;
|
||||
let threeLoadPromise = null;
|
||||
function loadThree() {
|
||||
if (!threeLoadPromise) {
|
||||
threeLoadPromise = import(THREE_URL)
|
||||
.then(mod => { T = mod; return mod; })
|
||||
.catch(() => import(THREE_CDN)
|
||||
.then(mod => { T = mod; return mod; })
|
||||
.catch(e => {
|
||||
console.error('[3D-Hwy] Three.js load failed:', e);
|
||||
threeLoadPromise = null;
|
||||
throw e;
|
||||
}));
|
||||
}
|
||||
return threeLoadPromise;
|
||||
}
|
||||
// T, loadThree — moved to src/three-loader.js (h3d-carve-2).
|
||||
// T is a live-binding export; the IIFE reads the updated value after loadThree() resolves.
|
||||
|
||||
/* ======================================================================
|
||||
* Splitscreen helpers
|
||||
|
||||
Reference in New Issue
Block a user