Hello, World! | Op
enCascade.js
cnpm install opencascade.js
cnpm install vite-plugin-wasm --save-dev
当你不知道文件写哪的时候trae还是有点用的
‘’‘
import { defineConfig } from 'vite';
import wasm from 'vite-plugin-wasm';
import rollupWasm from '@rollup/plugin-wasm';export default defineConfig({plugins: [wasm(), // Handles Wasm ESM integrationrollupWasm() // Provides Rollup-level Wasm support],// Optional: If you need to adjust Wasm loading behavioroptimizeDeps: {exclude: ['opencascade.js'] // Prevent Vite from pre-bundling the Wasm module}
});
’‘’
c++的瓶子教程Open CASCADE Technology: Tutorial
any
重装另一个
pnpm install opencascade.js@beta
配置您的 Bundler | OpenCascade.js --- Configuring Your Bundler | OpenCascade.js
initOpenCascade().then(oc => {// Initialize with explicit WASM file path configuration// Use the initialized oc object to create the boxconst box = oc.BRepPrimAPI_MakeBox(new oc.gp_Pnt_3(ox, oy, oz), // Note: Fixed typo `oc.gp_Pnt_3` → `oc.gp_Pnt`width,height,depth).Shape();// 创建 STEP 写入器const writer = new oc.STEPControl_Writer();// 设置 STEP 协议版本(AP203:仅几何数据;AP214:含机械属性)oc.Interface_Static_1("write.step.schema", "AP203");
有了
import initOpenCascade from "opencascade.js/dist/opencascade.full.js";
import initOpenCascade from "opencascade.js/dist/opencascade.full.wasm?init";
太酷了,和我的问题一模一样
无法使用 Vite 绑定库 · 问题 #268 · donalffons/opencascade.js --- Cannot bind the library with Vite · Issue #268 · donalffons/opencascade.js
卡住了
https://github.com/donalffons/opencascade.js/pull/287
git clone -b start-template-vite-react https://github.com/kcrlee/opencascade.js.git
搞不定,放着了
-----------------------------------------------------