Add OpenSCAD to JS with ManifoldCAD - #119
Open
codex826 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation of OpenSCAD-to-Manifold Compiler
Issue no: #117
Description
This PR introduces the first functional version of the OpenSCAD-to-Manifold Compiler, a tool designed to translate OpenSCAD source code (
.scad) into executable JavaScript optimized for the Manifold-3D geometry library.This compiler allows developers to utilize OpenSCAD's familiar declarative syntax while leveraging the performance and topologically robust geometry processing of Manifold in modern JavaScript/TypeScript environments (like Node.js or the browser).
Key Features
openscad-parserAST.RuntimeScope: Manages variable, module, and function scopes, supporting both global and nested definitions.cube,sphere,cylinder.translate,rotate,scale.union,difference,intersection.if-elsestatements andforloops (including ranges like[0:5:100]).sin,cos,sqrt, etc.).cli.ts) to easily compile files from the terminal.Technical Details
openscad-parser,manifold-3d,yargs.cube(size=10)are correctly mapped to{ size: 10 }in the target library.How to Test
1. Compile the tool
2. Run the test bench
npm testThis runs a comprehensive test case in
test-compiler.tsand verifies the output.3. Compile a SCAD file
Future Work
square,circle).polyhedronandhull.$childrenand more complex list comprehensions.Checklist