1/* 2 * Copyright (c) 2026 CNCKitchen (Stefan Hermann) and contributors 3 * SPDX-License-Identifier: AGPL-3.0-only 4 */ 5 6/** 7 * threeCompat.js â single resolution point for the three.js dependency of the 8 * mesh-processing pipeline modules (subdivision, regularize, displacement, 9 * decimation, meshRepair, exportPipeline). 10 * 11 * Why this exists: those modules must run in THREE contexts â 12 * 1. the page (resolves bare 'three' via the import map in index.html), 13 * 2. Node test/bench scripts (resolves 'three' from node_modules), 14 * 3. the export Web Worker (workers IGNORE the page's import map per the 15 * HTML spec, so a bare 'three' import throws there). 16 * The try/catch below uses the bare specifier wherever it resolves (page, 17 * Node â same module instance as the rest of the app, so instanceof checks 18 * hold) and falls back to the CDN URL only inside workers. 19 * 20 * KEEP THE URL IN SYNC with the import map in index.html. The page will 21 * usually have the file in HTTP cache already, so the worker fetch is cheap. 22 */ 23const CDN_THREE = 'https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js'; 24 25let THREE; 26try { 27 THREE = await import('three'); 28} catch { 29 THREE = await import(CDN_THREE); 30} 31 32export { THREE };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.