0.0.3 • Published 5 months ago

cura-wasm-definitions-tkml v0.0.3

Weekly downloads
-
License
(MIT AND LGPL-3.0...
Repository
github
Last release
5 months ago

Cura WASM Definitions

npm tests last commit FOSSA Status

3D printer definitions for Cura WASM

Install

npm i cura-wasm-definitions-tkml

Usage

import {CuraWASM} from 'cura-wasm';
import {resolveDefinition} from 'cura-wasm-definitions-tkml';

const main = async () =>
{
  //Create a new slicer
  const slicer = new CuraWASM({
    /*
     * The 3D printer definition to slice for (See the src/definitions directory
     * or https://github.com/Ultimaker/Cura/tree/master/resources/definitions
     * for a list of built-in definitions)
     */
    definition: resolveDefinition('ultimaker2'),
  });

  //Load your STL as an ArrayBuffer
  const res = await fetch('/demo/benchy.stl');
  const stl = await res.arrayBuffer();

  //Progress logger (Ranges from 0 to 100)
  slicer.on('progress', percent =>
  {
    console.log(`Progress: ${percent}%`);
  });

  //Slice (This can take multiple minutes to resolve!)
  const gcode = await slicer.slice(stl, 'stl');

  //Do something with the GCODE (ArrayBuffer)

  //Dispose (Reccomended but not necessary to call/intended for SPAs)
  slicer.dispose();
}
main();

How it works

When you call the default-exported function (ResolveDefinition in the above example), the function examines what printer definitions the requested printer definition depends on (eg: ultimaker2 depends on ultimaker which depends on fdmprinter which depends on fdmextruder). The function then recurs upon those parent printer definitions. There's also some logic for not resolving fdmextruder and fdmprinter definitions because these are bundled in Cura WASM itself (Because most printer definitions depend on them). Once it has walked the dependency hierarchy, the function squashes them together using Lodash's merge function. The function also performs a similar process on extruder definitions. Finally, the function combines both the extruder and printer definitions and returns one combined definition.

What's the license?

Cura WASM Definitions relies on Cura (The upstream for 3D printer definitions) which which uses LGPL3+ hence the LGPL3+ license requirement. With that said, the LGPL3+ license only applies to tests/index.ts and all files in the src/definitions directory (Excluding src/definitions/index.ts). All other files use the MIT license.

License Obligations

Upstream Modifications

None - all definitions are used verbatim.

Source

The source is located at github.com/ultimaker/cura.

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago