Skip to content

A proof-of-concept plugin system for Fornjot

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE.md
MIT
LICENSE_MIT.md
Notifications You must be signed in to change notification settings

Michael-F-Bryan/fornjot-plugins

Repository files navigation

Fornjot Plugins

Continuous integration

(API Docs)

A proof-of-concept plugin system for Fornjot.

Getting Started

After you've installed the Rust compiler and cloned this repo, you can point the Fornjot app at the Cuboid model and use it directly.

$ fj-app --model ./models/cuboid

To load a model that was compiled to WebAssembly, first cross-compile your model to wasm32-unknown-unknown.

$ cargo build --package cuboid --target wasm32-unknown-unknown
$ ls target/wasm32-unknown-unknown/debug/*.wasm
target/wasm32-unknown-unknown/debug/cuboid.wasm

Next, point the $FJ_WASM_PLUGIN environment variable at our compiled WebAssembly module.

$ export FJ_WASM_PLUGIN=$PWD/target/wasm32-unknown-unknown/debug/cuboid.wasm

The plugin we compiled to WebAssembly can now be used via the wasm-shim model. This is a special crate that compiles to a normal *.so plugin, but whenever Fornjot asks it to generate geometry, the wasm-shim will delegate its implementation to the WebAssembly plugin it loaded.

$ fj-app --model crates/wasm-shim
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
2022-07-17T11:51:56.772937Z DEBUG fj_wasm_shim: Reading WebAssembly from disk path=/home/michael/Documents/fornjot-plugins/target/wasm32-unknown-unknown/debug/cuboid.wasm
2022-07-17T11:51:56.776027Z DEBUG fj_wasm_shim: Parsing the WebAssembly module
2022-07-17T11:51:58.246512Z DEBUG fj_wasm_shim: Instantiated the WebAssembly module
2022-07-17T11:51:58.246871Z DEBUG fj_wasm_shim: Initializing the plugin
2022-07-17T11:51:58.247076Z  INFO init: cuboid: Registered cuboid
2022-07-17T11:51:58.261879Z DEBUG shape: cuboid: Creating a cuboid model x=3.0 y=2.0 z=1.0

Consult the API docs for more detail on how the plugin system works.

License

This project is licensed under either of

at your option.

It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

The intent of this crate is to be free of soundness bugs. The developers will do their best to avoid them, and welcome help in analysing and fixing them.

About

A proof-of-concept plugin system for Fornjot

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE.md
MIT
LICENSE_MIT.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages