create-ifc-lite 1.14.7 → 1.14.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -0
- package/dist/templates/threejs.js +13 -2
- package/package.json +1 -1
- package/dist/utils/download.d.ts +0 -7
- package/dist/utils/download.js +0 -63
package/dist/index.js
CHANGED
|
@@ -71,6 +71,18 @@ async function main() {
|
|
|
71
71
|
projectName = arg;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
// Reject path separators, '..', and names that would yield an invalid npm
|
|
75
|
+
// `name`, so join(process.cwd(), projectName) stays under cwd and the
|
|
76
|
+
// generated package.json is valid. Mirrors config-fixers.ts VALID_PACKAGE_NAME.
|
|
77
|
+
const VALID_PROJECT_NAME = /^(?:@[\w.-]+\/)?[\w.-]+$/;
|
|
78
|
+
// A scoped name like `@scope/..` passes the char regex but its last segment
|
|
79
|
+
// is a dot-segment that `join(cwd, name)` resolves outside the intended dir,
|
|
80
|
+
// so reject any `.`/`..` segment (scoped or not), not just a bare projectName.
|
|
81
|
+
const hasDotSegment = projectName.split('/').some((seg) => seg === '.' || seg === '..');
|
|
82
|
+
if (!VALID_PROJECT_NAME.test(projectName) || hasDotSegment) {
|
|
83
|
+
console.error(`Invalid project name "${projectName}". Use letters, digits, '.', '-' or '_' (no path separators).`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
74
86
|
const targetDir = join(process.cwd(), projectName);
|
|
75
87
|
if (existsSync(targetDir)) {
|
|
76
88
|
console.error(`Directory "${projectName}" already exists.`);
|
|
@@ -49,6 +49,11 @@ export function createThreejsTemplate(targetDir, projectName) {
|
|
|
49
49
|
writeFileSync(join(targetDir, 'vite.config.ts'), `import { defineConfig } from 'vite';
|
|
50
50
|
|
|
51
51
|
export default defineConfig({
|
|
52
|
+
// @ifc-lite ships ES-module geometry workers; emit them as ESM so a
|
|
53
|
+
// production build never trips over Rollup's IIFE worker default.
|
|
54
|
+
worker: {
|
|
55
|
+
format: 'es',
|
|
56
|
+
},
|
|
52
57
|
optimizeDeps: {
|
|
53
58
|
exclude: ['@ifc-lite/wasm'],
|
|
54
59
|
},
|
|
@@ -132,7 +137,10 @@ export function meshDataToThree(mesh: MeshData): THREE.Mesh {
|
|
|
132
137
|
color: new THREE.Color(r, g, b),
|
|
133
138
|
transparent: a < 1,
|
|
134
139
|
opacity: a,
|
|
135
|
-
|
|
140
|
+
// DoubleSide even for opaque: IFC triangle winding isn't reliably outward,
|
|
141
|
+
// and culling one side of two coincident coplanar walls (a facing wall flush
|
|
142
|
+
// on a thicker one) leaves the survivors z-fighting into a comb along the seam.
|
|
143
|
+
side: THREE.DoubleSide,
|
|
136
144
|
depthWrite: a >= 1,
|
|
137
145
|
});
|
|
138
146
|
|
|
@@ -155,7 +163,10 @@ if (!canvas || !fileInput || !status) {
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
// Three.js setup
|
|
158
|
-
|
|
166
|
+
// logarithmicDepthBuffer spreads depth precision across the scene so the
|
|
167
|
+
// near-coplanar surfaces common in IFC (a roof slab on a gable wall, stacked
|
|
168
|
+
// wall layers) far from the origin don't z-fight into stair-stepped seams.
|
|
169
|
+
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, logarithmicDepthBuffer: true });
|
|
159
170
|
renderer.setPixelRatio(window.devicePixelRatio);
|
|
160
171
|
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
161
172
|
|
package/package.json
CHANGED
package/dist/utils/download.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Download the viewer application from the ifc-lite GitHub repository.
|
|
3
|
-
*
|
|
4
|
-
* Tries `npx degit` first (fastest path). Falls back to a git sparse
|
|
5
|
-
* checkout when degit is unavailable or fails.
|
|
6
|
-
*/
|
|
7
|
-
export declare function downloadViewer(targetDir: string, _projectName: string): Promise<boolean>;
|
package/dist/utils/download.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
-
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
-
import { rmSync } from 'fs';
|
|
5
|
-
import { join, dirname } from 'path';
|
|
6
|
-
import { execSync } from 'child_process';
|
|
7
|
-
const REPO_URL = 'https://github.com/LTplus-AG/ifc-lite';
|
|
8
|
-
const VIEWER_PATH = 'apps/viewer';
|
|
9
|
-
/**
|
|
10
|
-
* Run a shell command silently. Returns true on success, false on failure.
|
|
11
|
-
*/
|
|
12
|
-
function runCommand(cmd, cwd) {
|
|
13
|
-
try {
|
|
14
|
-
execSync(cmd, { cwd, stdio: 'pipe' });
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Download the viewer application from the ifc-lite GitHub repository.
|
|
23
|
-
*
|
|
24
|
-
* Tries `npx degit` first (fastest path). Falls back to a git sparse
|
|
25
|
-
* checkout when degit is unavailable or fails.
|
|
26
|
-
*/
|
|
27
|
-
export async function downloadViewer(targetDir, _projectName) {
|
|
28
|
-
// Try degit first (fastest)
|
|
29
|
-
if (runCommand('npx --version')) {
|
|
30
|
-
console.log(' Downloading viewer template...');
|
|
31
|
-
try {
|
|
32
|
-
execSync(`npx degit ${REPO_URL}/${VIEWER_PATH} "${targetDir}"`, {
|
|
33
|
-
stdio: 'pipe',
|
|
34
|
-
timeout: 60000
|
|
35
|
-
});
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// degit failed, try git sparse checkout
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Fallback: git sparse checkout
|
|
43
|
-
if (runCommand('git --version')) {
|
|
44
|
-
console.log(' Downloading via git...');
|
|
45
|
-
const tempDir = join(dirname(targetDir), `.temp-${Date.now()}`);
|
|
46
|
-
try {
|
|
47
|
-
execSync(`git clone --filter=blob:none --sparse "${REPO_URL}.git" "${tempDir}"`, {
|
|
48
|
-
stdio: 'pipe',
|
|
49
|
-
timeout: 120000
|
|
50
|
-
});
|
|
51
|
-
execSync(`git sparse-checkout set ${VIEWER_PATH}`, { cwd: tempDir, stdio: 'pipe' });
|
|
52
|
-
// Move viewer to target
|
|
53
|
-
const viewerSrc = join(tempDir, VIEWER_PATH);
|
|
54
|
-
execSync(`mv "${viewerSrc}" "${targetDir}"`, { stdio: 'pipe' });
|
|
55
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|