Three.js viewer supporting glb/gltf/obj/fbx/dae/ifc/ply via both server (SSR) and drag&drop (CSR) paths. - Streaming OBJ parser (src/viewer/objStream.ts) for files past the V8 max string length (>~1GB text) that OBJLoader can't handle; indexed geometry, per-vertex color from MTL Kd, float64 recenter baked in. - In-viewer float64 recenter (objRecenter.ts) for huge CAD/survey coordinates (~1e8) so float32 vertex buffers keep precision (no cracked faces). - Z-up right-handed world; Y-up formats rotated on load. - OBJ+MTL+texture drag&drop (LoadingManager URL-modifier maps dropped images). - OrbitControls ground-plane panning (road/rail alignment workflow). - UI: Zoom Fit, perspective/orthographic toggle, feature-edge outline. - DoubleSide for CAD OBJ; PLY mesh + point-cloud support. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
899 B
TypeScript
36 lines
899 B
TypeScript
// SSR -> CSR hydration gate. Fades the WebP placeholder to the Three.js canvas
|
|
// ONLY after BOTH the WebGL context is ready AND the model is loaded.
|
|
// Firing on just one condition = empty-canvas flash (race). Idempotent.
|
|
|
|
export interface HydrationGate {
|
|
markWebGLReady(): void;
|
|
markModelLoaded(): void;
|
|
}
|
|
|
|
export function createHydrationGate(preview: HTMLImageElement): HydrationGate {
|
|
let webglReady = false;
|
|
let modelLoaded = false;
|
|
let fired = false;
|
|
|
|
function maybeFire(): void {
|
|
if (fired || !(webglReady && modelLoaded)) return;
|
|
fired = true;
|
|
preview.style.opacity = '0';
|
|
window.setTimeout(() => {
|
|
preview.classList.add('hidden');
|
|
preview.style.display = 'none';
|
|
}, 500);
|
|
}
|
|
|
|
return {
|
|
markWebGLReady() {
|
|
webglReady = true;
|
|
maybeFire();
|
|
},
|
|
markModelLoaded() {
|
|
modelLoaded = true;
|
|
maybeFire();
|
|
},
|
|
};
|
|
}
|