occt-gltf-addon 0.1.1 → 0.1.2
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/README.md +11 -8
- package/index.js +4 -3
- package/package.json +2 -2
- package/scripts/install.js +13 -2
package/README.md
CHANGED
|
@@ -2,22 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Node.js N-API 原生扩展:使用 OpenCascade (OCCT) 将 **STEP (.step/.stp)** 转换为 **glTF 2.0 (GLB)**。
|
|
4
4
|
|
|
5
|
-
####
|
|
5
|
+
#### 安装
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **Linux x64(Ubuntu 等)**:默认会安装预编译包 `occt-gltf-addon-linux-x64`(包含 OCCT runtime),一般 **不需要系统安装 OCCT**。
|
|
8
|
+
- **macOS / 其他平台**:默认会在 `npm install` 时本地编译(`cmake-js`),需要 OCCT 开发文件(headers + libs)。
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
- **CMake + C++ 编译器 + Python3**
|
|
11
|
-
- **OCCT 安装**(共享库 + headers)
|
|
12
|
-
|
|
13
|
-
通过环境变量指定 OCCT 安装前缀:
|
|
10
|
+
本地编译时通过环境变量指定 OCCT 安装前缀:
|
|
14
11
|
|
|
15
12
|
```bash
|
|
16
13
|
export OCCT_ROOT=/path/to/occt/prefix
|
|
17
14
|
npm i occt-gltf-addon
|
|
18
15
|
```
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
如需在 linux-x64 **强制源码编译**(不推荐,且需要你自己装 OCCT):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
OCCT_GLTF_ADDON_FORCE_BUILD=1 OCCT_ROOT=/path/to/occt/prefix npm i occt-gltf-addon
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
可选(仅在 **源码编译** 时用于启用 Draco 支持,需要开发包):
|
|
21
24
|
- `brew install draco` / `apt-get install libdraco-dev`
|
|
22
25
|
|
|
23
26
|
如需跳过编译(不推荐,运行时会找不到 `.node`):
|
package/index.js
CHANGED
|
@@ -40,9 +40,10 @@ const msg = [
|
|
|
40
40
|
'[occt-gltf-addon] Failed to load native addon (.node).',
|
|
41
41
|
`Tried: ${candidates.map((p) => JSON.stringify(p)).join(', ')}`,
|
|
42
42
|
'',
|
|
43
|
-
'If you installed from npm
|
|
44
|
-
'-
|
|
45
|
-
|
|
43
|
+
'If you installed from npm:',
|
|
44
|
+
'- On linux-x64: you should get the prebuilt optional dependency `occt-gltf-addon-linux-x64` (no system OCCT required).',
|
|
45
|
+
' Ensure optional deps are enabled (do NOT use `--no-optional`).',
|
|
46
|
+
'- Otherwise / if building from source: ensure CMake + C++ toolchain are installed, and OCCT_ROOT points to your OCCT install prefix',
|
|
46
47
|
'',
|
|
47
48
|
"You can try: 'npm rebuild occt-gltf-addon' (with OCCT_ROOT exported).",
|
|
48
49
|
].join('\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occt-gltf-addon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "STEP (.step/.stp) to glTF (GLB) converter using OpenCascade (OCCT) via a Node.js N-API addon",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"docker:image:linux-amd64:nocache": "docker buildx build --no-cache --platform linux/amd64 -f docker/Dockerfile.linux-amd64 -t occt-addon-build:linux-amd64 ../.."
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
|
66
|
-
"occt-gltf-addon-linux-x64": "0.1.
|
|
66
|
+
"occt-gltf-addon-linux-x64": "0.1.2"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"cmake-js": "^7.3.1",
|
package/scripts/install.js
CHANGED
|
@@ -43,8 +43,19 @@ function main() {
|
|
|
43
43
|
note(`Using prebuilt binary from ${prebuiltName}; skipping local build.`);
|
|
44
44
|
return;
|
|
45
45
|
} catch (e) {
|
|
46
|
-
// Prebuilt missing or not loadable (e.g. GLIBC mismatch).
|
|
47
|
-
|
|
46
|
+
// Prebuilt missing or not loadable (e.g. GLIBC mismatch).
|
|
47
|
+
// On Linux, the default expectation is to use the prebuilt package (no system OCCT required).
|
|
48
|
+
// Only fall back to local build when the user explicitly opts in.
|
|
49
|
+
const canBuildFromSource =
|
|
50
|
+
process.env.OCCT_GLTF_ADDON_FORCE_BUILD === '1' || !!process.env.OCCT_ROOT;
|
|
51
|
+
if (!canBuildFromSource) {
|
|
52
|
+
note(`Prebuilt package ${prebuiltName} not usable, and OCCT_ROOT is not set.`);
|
|
53
|
+
note('This package is intended to work on Linux via the prebuilt optional dependency.');
|
|
54
|
+
note('Fix: ensure optional dependencies are installed (do NOT use --no-optional).');
|
|
55
|
+
note('Or: set OCCT_ROOT and re-install to build from source (or set OCCT_GLTF_ADDON_FORCE_BUILD=1).');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
note(`Prebuilt package ${prebuiltName} not usable; attempting local build from source...`);
|
|
48
59
|
}
|
|
49
60
|
}
|
|
50
61
|
|