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>
47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
// Copies Draco + KTX2/Basis decoder WASM from three.js into public/ so the
|
|
// runtime paths /draco/ and /basis/ resolve (version-matched to installed three).
|
|
// Also copies the web-ifc single-thread WASM to public/web-ifc/ for the IFC path.
|
|
// Runs automatically via `npm install` (postinstall). Safe to re-run.
|
|
import { cpSync, copyFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = resolve(__dirname, '..');
|
|
|
|
const libs = resolve(root, 'node_modules/three/examples/jsm/libs');
|
|
const targets = [
|
|
[resolve(libs, 'draco/gltf'), resolve(root, 'public/draco')],
|
|
[resolve(libs, 'basis'), resolve(root, 'public/basis')],
|
|
];
|
|
|
|
if (!existsSync(libs)) {
|
|
console.warn('[copy-decoders] three not installed yet — skipping (will run on next install).');
|
|
process.exit(0);
|
|
}
|
|
|
|
for (const [src, dest] of targets) {
|
|
if (!existsSync(src)) {
|
|
console.warn(`[copy-decoders] source missing: ${src}`);
|
|
continue;
|
|
}
|
|
mkdirSync(dest, { recursive: true });
|
|
cpSync(src, dest, { recursive: true });
|
|
console.log(`[copy-decoders] ${src} -> ${dest}`);
|
|
}
|
|
|
|
// web-ifc single-thread WASM (+ MT build if present) for the IFC load path.
|
|
const ifcSrcDir = resolve(root, 'node_modules/web-ifc');
|
|
const ifcDest = resolve(root, 'public/web-ifc');
|
|
if (existsSync(ifcSrcDir)) {
|
|
mkdirSync(ifcDest, { recursive: true });
|
|
for (const wasm of ['web-ifc.wasm', 'web-ifc-mt.wasm']) {
|
|
const src = resolve(ifcSrcDir, wasm);
|
|
if (!existsSync(src)) continue;
|
|
copyFileSync(src, resolve(ifcDest, wasm));
|
|
console.log(`[copy-decoders] ${src} -> ${resolve(ifcDest, wasm)}`);
|
|
}
|
|
} else {
|
|
console.warn('[copy-decoders] web-ifc not installed yet — skipping IFC wasm.');
|
|
}
|