Giter Club home page Giter Club logo

gcode-preview's Introduction

GCode Preview npm version MIT license

A simple G-code parser & viewer with 3D printing in mind. Written in Typescript.

3D WebGL + pan/zoom/rotate controls

Demo Animation

New in v2.2.0: build volume

The build volume will be rendered if the buildVolume parameter is passed. It has the following type:

buildVolume: { 
  x: number; 
  y: number; 
  z: number
}

example:

Demo

Go try the interactive demo.

Installation

npm version

npm install gcode-preview

or

yarn add gcode-preview

Quick start

Html

  <div id="gcode-preview">

Javascript

  const gcode = 'G0 X0 Y0 Z0.2\nG1 X42 Y42'; // draw a diagonal line
  const preview = new WebGLPreview({
      targetId: 'gcode-preview',
  });
  
  preview.processGCode(gcode);
  preview.render();

Vue.js integration

There's a Vue.js example that has a Vue component to wrap the library.

Known issues

Preview doesn't render in Brave

This is caused by the device recognition shield in Brave. By changing the setting for "Device Recognition" in Shield settings to "Allow all device recognition attemps" or "Only block cross-site device recognition attemps" you should not get this error. mrdoob/three.js#16904

Notice: deprecation of Canvas2D

In favor of WebGL, I'm deprecating the Canvas 2Drendering. My reasons for this are:

  • WebGL (via THREE.js) gives me more options, like rotating the model
  • WebGL renders faster
  • I don't want to maintain 2 rendering methods due to time constraints

This means that as of version 2.1.0 only WebGL will be supported. I you really want to use Canvas 2D, stay at the 2.0.x version branch and/or consider forking.

Sponsors

A big thanks to these sponsors for their contributions.

Q42

Duet3D

Contributing

If you want to help out, consider any of the following:

  • test the GCode Preview with a variety of gcode files, from different slicers
  • report any bugs you find and add as much detail as possible, or even better, a screenshot
  • even better yet: send in a pull request :-)
  • apart from the the code code, lots of improvements can still be made in:
  • documentation
  • unit tests
  • demos, especially in combination with frameworks like React, Svelte etc

Donate

If you want to show gratitude you can always buy me beer/coffee/filament via a Paypal donation ^_^

Changelog

Jump to the CHANGELOG

gcode-preview's People

Contributors

dependabot[bot] avatar remcoder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.