Migrate Replicad to OCCT v8 bindings#263
Conversation
Rebuilt both WASM variants against OCCT V8 with -O3 optimization: - replicad_single: compact build without exception support (18.96 MB) - replicad_with_exceptions: full build with native WASM exceptions (22.22 MB) Also includes replicad source updates for OCCT V8 API compatibility. Made-with: Cursor
…ollection equivalents
orts and add multi-threaded build
Reconciles upstream v0.21.1..v0.23.3 (mesh shape import/export, replicad evaluator + node CLI, sketch.revolve angle param, draft angle, projection approximation fixes, isShape3D chaining) with taucad fork customizations (OCCT V8 dual-WASM binding, suffix-free OCJS symbols, ESM sub-path exports, PBR/material density export, native C++ mesh extractors). Conflict resolutions: - packages/replicad/package.json: keep @taucad/replicad name + version 0.23.3-beta.0; replicad-opencascadejs stays a workspace dependency (not the upstream ^0.23.0 devDep). - packages/replicad-opencascadejs/*: keep fork dist/-based packaging, single+multi build configs; honor fork deletion of src/*.wasm/*.d.ts and custom_build_with_exceptions.yml. - src/lib2d/approximations.ts: adopt upstream bounded BSpline->Bezier conversion (handle, U1, U2, tol) via the fork's suffix-free Geom2dConvert_BSplineCurveToBezierCurve symbol. - src/shapes.ts: union of imports (asDir/makePln/makePlane/BRepAdaptor_Surface) in fork style. - src/sketches/CompoundSketch.ts: adopt upstream revolve() angle parameter. - peripheral packages (studio, replicad-app-example, pnpm-lock): keep fork. Co-authored-by: Cursor <cursoragent@cursor.com>
sgenoud
left a comment
There was a problem hiding this comment.
This is great!
I know this is still just a draft, but I wanted to have a look to guide your next step!
Thanks for the work
|
|
||
| // We import our model as a simple function | ||
| import { drawBox } from "./cad"; | ||
| import { drawBox } from './cad'; |
There was a problem hiding this comment.
Make sure you run prettier (with default config) to keep the same quotes than before.
| "replicad-opencascadejs": "^0.23.0", | ||
| "replicad-threejs-helper": "^0.23.0", | ||
| "replicad": "^0.21.0", | ||
| "replicad-opencascadejs": "workspace:@taucad/replicad-opencascadejs@^", |
| // same tolerance/angularTolerance budget as the face mesher. | ||
| // | ||
| // `seenEdges` deduplicates edges shared between adjacent faces so a single | ||
| // shared edge contributes exactly one polyline. |
There was a problem hiding this comment.
Is there a way this could be maintained in another repo?
| bindings: #@ data.values.bindings | ||
| emccFlags: #@ data.values.buildFlags | ||
|
|
||
| additionalCppFiles: |
There was a problem hiding this comment.
I really like that this is in files instead of inline. This could help making it more maintainable as well!
| - -msimd128 | ||
| - -O3 | ||
|
|
||
| # Legacy inline C++ kept for reference; wrapper .cpp files in build-config/wrappers/ are used instead. |
There was a problem hiding this comment.
The git history is here for reference, we can remove this entirely.
|
|
||
| return handle as T; | ||
| }; | ||
|
|
There was a problem hiding this comment.
Is there a reason to build this helper?
|
|
||
| if (curveType === "BEZIER_CURVE") { | ||
| const b = adaptor.Bezier().get(); | ||
| const b = adaptor.Bezier(); |
There was a problem hiding this comment.
Can you explain me how the dynamic pointers have changed with v8? We might need to do some additional memory management (with the previous way when a resource was using one of these it would be freed automatically I think).
| @@ -477,110 +433,34 @@ export class Shape<Type extends TopoDS_Shape> extends WrappingObj<Type> { | |||
| lines: number[]; | |||
| edgeGroups: { start: number; count: number; edgeId: number }[]; | |||
| } { | |||
There was a problem hiding this comment.
could we keep the js implementation as a fallback (in case we run in with a wasm that does not have the cpp implementation?)
| "version": "0.23.1", | ||
| "description": "The library to build browser based 3D models with code", | ||
| "name": "@taucad/replicad", | ||
| "version": "0.23.3-beta.1", |
| if (manifold?.Manifold) { | ||
| manifold.setup(); | ||
| replicad.setManifold(manifold); | ||
| export function runInContextAsOC(code, context = {}) { |
There was a problem hiding this comment.
There seem to be some rebase issue here, I have modified how this works in the mean time.
Summary
packages/replicad-opencascadejs/dist, with package exports for the default single build and the./multisubpath.Reviewer notes
taucad:mainbranch as requested, preserving the current commit stack rather than squashing or creating a new PR branch.@taucad/replicad,@taucad/replicad-opencascadejs) and Tau repository URLs. This likely needs maintainer discussion before the PR is marked ready for upstream.docs/occt-v8-migration.mdstill says the multi-threaded build was removed/deferred, but this branch addsreplicad_multi.*artifacts and./multiexports. That doc should be reconciled before final review.packages/replicad/src,packages/replicad-opencascadejs/build-source, and the package export/import changes.Test plan
pnpm install --frozen-lockfilepnpm --filter @taucad/replicad typecheckpnpm --filter @taucad/replicad test -- --run(4 files, 39 tests)pnpm --filter @taucad/replicad buildpnpm --filter replicad-cli buildpnpm --filter replicad-evaluator buildpnpm --filter studio build(passed with existing dependency/CSS/chunk-size warnings)pnpm --filter replicad-app-example build(initially failed on worker IIFE/code-splitting, fixed by building workers as ES modules)replicad-opencascadejsexport initializes and exposesBRepPrimAPI_MakeBoxplus exception helpersreplicad-opencascadejs/multiexport initializes and exposesBRepPrimAPI_MakeBoxplus exception helpersdist/replicad.jsinitializes OCJS and meshes a simple boxnpm pack --dry-run --jsoninpackages/replicad-opencascadejsnpm pack --dry-run --jsoninpackages/replicadRisks
AI Disclosure