All Projects → remcoder → gcode-preview

remcoder / gcode-preview

Licence: MIT License
A simple GCode parser & previewer with 3D printing in mind. Written in Typescript.

Programming Languages

G-code
73 projects

Projects that are alternatives of or similar to gcode-preview

octoscreen
A touchscreen client for Octoprint
Stars: ✭ 26 (-62.32%)
Mutual labels:  3d-printing
DArm
A desktop arm that can write and draw.
Stars: ✭ 45 (-34.78%)
Mutual labels:  3d-printing
smarterblinds
ESP8266 controller for Blinds-To-Go motorized blinds
Stars: ✭ 32 (-53.62%)
Mutual labels:  3d-printing
voron-ht
Klipper configuration for my Voron 2.4
Stars: ✭ 20 (-71.01%)
Mutual labels:  3d-printing
AutoBuildMarlin
Visual Studio Code extension to more easily build Marlin Firmware
Stars: ✭ 206 (+198.55%)
Mutual labels:  3d-printing
3D-printed-mirror-array
3D-printable hexagonal mirror array capable of reflecting sunlight into arbitrary patterns
Stars: ✭ 2,242 (+3149.28%)
Mutual labels:  3d-printing
Cura-SidebarGUIPlugin
Cura plugin that provides a more settings-centric GUI for those who prefer it
Stars: ✭ 31 (-55.07%)
Mutual labels:  3d-printing
DEMto3D-QGIS-Plugin
Extensión GIS para impresión 3D de MDE
Stars: ✭ 33 (-52.17%)
Mutual labels:  3d-printing
BodyParts3D
Clone of the BodyParts3D/Anatomography 3D model files
Stars: ✭ 32 (-53.62%)
Mutual labels:  3d-printing
fillygons
20% cooler hinged polygons.
Stars: ✭ 15 (-78.26%)
Mutual labels:  3d-printing
print4health
print4health.org
Stars: ✭ 11 (-84.06%)
Mutual labels:  3d-printing
ui
nanoDLP user interface
Stars: ✭ 21 (-69.57%)
Mutual labels:  3d-printing
BCN3DSigma-Electronics
6 Axis Open Source Electronics for BCN3D Sigma 3D Printer.
Stars: ✭ 40 (-42.03%)
Mutual labels:  3d-printing
fedora-loves-python-staffs
Fedora Loves Python 3D Printable Staffs
Stars: ✭ 12 (-82.61%)
Mutual labels:  3d-printing
FABlin
The FABtotum Personal Fabricator Firmware, a Marlin derivate made to support hybrid manufacturing and digital acquisition
Stars: ✭ 19 (-72.46%)
Mutual labels:  3d-printing
StlVault
3D object viewer and organizer
Stars: ✭ 104 (+50.72%)
Mutual labels:  3d-printing
OctoPrint-AstroPrint
Connect your OctoPrint device to the AstroPrint 3D Printing Cloud
Stars: ✭ 26 (-62.32%)
Mutual labels:  3d-printing
CameraSlider
3D printed and smartphone controlled camera slider
Stars: ✭ 16 (-76.81%)
Mutual labels:  3d-printing
TopOpt in PETSc wrapped in Python
Topology optimization using PETSc: a Python wrapper and extended functionality
Stars: ✭ 24 (-65.22%)
Mutual labels:  3d-printing
dometyl-keyboard
A parametric generator for designing split, concave, ergonomic keyboards written in ocaml.
Stars: ✭ 84 (+21.74%)
Mutual labels:  3d-printing

GCode Preview npm version MIT license

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

Features

3D WebGL + pan/zoom/rotate controls

Demo Animation

Thumbnail preview

Thumbnail previews as generated by PrusaSlicer are detected and parsed. In the gcode these are found in comments, enclosed between 'thumbnail begin' and 'thumbnail end'. The images are encoded as base64 strings but split over multiple lines. These are now parsed and patched back together, but still kept a base64. This allows easy use in the browser for us as data urls.

image

The thumbnails can be accessed like this: gcodePreview.parser.metadata.thumbnails['220x124']

Thumbnails have a .src property that will create a usable data url from the base64 string.

See an example in the demo source.

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

    <body>
      <canvas class="gcode-preview"></canvas>
      
      <script src="three/build/three.min.js"></script>
      <script src="three/examples/js/controls/OrbitControls.js"></script>
      <script src="gcode-preview.js"></script>

    </body>

Javascript

  const preview = new GCodePreview.init({
      document.querySelector('canvas'),
  });
  
  // draw a diagonal line
  const gcode = 'G0 X0 Y0 Z0.2\nG1 X42 Y42 E10';
  preview.processGCode(gcode);

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 have found a bug or if have an idea for a feature, don't hesitate to create an issue.

It would be great if you want to help out because I'm always short on time to do more testing and improving. So for instance, maybe you'd like to help out with:

  • testing GCode Preview with a variety of gcode files, from different slicers
  • reporting 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 main 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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].