A VS Code extension bringing ManifoldCAD functionality to VS Code. It allows creation of .mfc and .manifoldcad files, containing scripts compatible with manifoldcad.org. It also adds a 3D preview panel for previewing the resulting mesh inside VS Code. The preview panel should support all features of manifoldcad.org, such as coloring and animations.
Both desktop VS Code and vscode.dev (any web version) are supported.
This extension has been developed with support from Cookiecad.
- Open or create a
.mfcor.manifoldcadfile in VS Code. - A triple slash typescript import should automatically be added to the top of the file. This is what provides the TypeScript definitions for the Manifold API.
- Run the
Manifold: Open 3D Viewercommand from the Command Palette (Ctrl+Shift+P). - Edit your code and save the file. See the results update live in the viewer.
Manifold is a high-performance library for creating and manipulating manifold triangle meshes. Manifold meshes represent solid objects and are essential for CAD, 3D printing, and advanced modeling workflows. The library guarantees robust mesh operations, supports mesh Booleans, smoothing, and arbitrary vertex properties, and is available for C++, TypeScript/JavaScript, and Python.
-
3D Model Visualization: Instantly preview 3D meshes generated by your code in an interactive viewer.
-
Animation Support: Visualize and scrub through mesh animations and transformations.
-
Live Editing: See changes reflected in real time as you edit your code.
-
Configurable File Extensions This extension allows you to configure which file extensions are treated as ManifoldCAD scripts. By default, files ending with
.manifoldcador.mfcare recognized, but you can change this in your VS Code settings undermanifold-vscode-extension.fileExtensions.
For example, to also use regular .ts or .js files as ManifoldCAD scripts, set the extension setting to:
.manifoldcad, .mfc, .ts, .js
- Type Injection File Extensions: Control which file extensions receive automatic type injection (the triple-slash reference to Manifold types) using the
manifold-vscode-extension.typeInjectionFileExtensionssetting. If not set, it defaults to the value offileExtensions. This allows you to preview.tsor.jsfiles without injecting the triple-slash reference, if desired.
The extension provides a custom viewer for .mfc and .manifoldcad files, opening a webview panel that renders your 3D models and animations. The webview is built with React and Vite, and leverages the Manifold WASM bindings for mesh generation.
- Clone this repository and run
pnpm installin the root directory. - Now build the manifold library and copy the
manifold.jsandmanifold.wasmfiles into thesrc/webview/src/wasm/directory. - Build the webview by navigating to
src/webview/and running:
pnpm install
pnpm build- Build the extension:
pnpm compile-
Launch the extension in a VS Code Extension Development Host. A
launch.jsonconfiguration is provided, so inside VS Code, open the Debug panel, select "Launch Extension", and hit the green play button. A new VS Code window will open with the extension loaded. -
Or: build the .vsix package for distribution:
npx vsce packageSee the package.json scripts for more commands.
Opening multiple .mfc files causes type errors to appear in the opened file due to the triple slash type import. This is because the same context is shared between the opened files, and the typescript compiler sees multiple variables with the same name.
The solution is to only open one .mfc file at a time.
