Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcoder committed May 6, 2020
2 parents 6056b0c + 0ae434d commit aaac975
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# GCode Preview
A simple GCode parser & viewer with 3D printing in mind. Written in Typescript.
# GCode Preview [![npm version](http://img.shields.io/npm/v/gcode-preview.svg?style=flat)](https://npmjs.org/package/gcode-preview "View this project on npm") [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
A simple [G-code](https://en.wikipedia.org/wiki/G-code) parser & viewer with 3D printing in mind. Written in Typescript.

See a [demo](https://gcode-preview.web.app/) here
## 3D WebGL + pan/zoom/rotate controls
![Demo Animation](../assets/benchy.gif?raw=true)

## WebGL 3D + pan/zoom/rotate controls
<img src="https://user-images.githubusercontent.com/461650/69015936-812bd080-0999-11ea-94fc-67c63bf128af.png" width=400 />
## Demo
Go try the [interactive demo](https://gcode-preview.web.app/).

## Canvas 2.5D (static perspective)
<img src="https://user-images.githubusercontent.com/461650/67150833-f9c93f80-f2bc-11e9-9887-3c721cf7bfa5.png" width=400 />

## Installation

Expand All @@ -17,32 +16,37 @@ or

`yarn add gcode-preview`

### Vue.js example
See [here](https://github.com/remcoder/gcode-preview-vue-demo) for an example with Vue.js

### Quick start

html:
#### Html
```
<div id="gcode-preview">
```

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

### Vue.js integration
There's also a [Vue.js example](https://github.com/remcoder/gcode-preview-vue-demo) that has a [Vue component](https://github.com/remcoder/gcode-preview-vue-demo/blob/master/src/components/GCodePreview.vue) 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.
https://github.com/mrdoob/three.js/issues/16904

## Sponsors

<img width=42 src="http://logo.q42.com/q42-logo.svg" />
A big thanks to these sponsors for their contributions.

[<img width=42 src="http://logo.q42.com/q42-logo.svg" /> Q42 ](http://q42.com)

[<img width=42 src="https://www.duet3d.com/image/catalog/logo/50_blue_wifi.png"> Duet3D](https://www.duet3d.com/)
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gcode-preview",
"version": "2.0.4",
"version": "2.0.5",
"description": "Render a 3d print model from a gcode file",
"author": "[email protected]",
"license": "MIT",
Expand All @@ -16,7 +16,7 @@
],
"types": "dist/gcode-preview.d.ts",
"devDependencies": {
"@types/jest": "^24.0.16",
"@types/jest": "^24.0.23",
"copyfiles": "^2.1.1",
"del-cli": "^1.1.0",
"install": "^0.12.2",
Expand All @@ -41,6 +41,7 @@
"deploy": "firebase deploy --only hosting"
},
"dependencies": {
"serialize-javascript": "^2.1.1",
"three": "^0.110.0",
"three-orbitcontrols": "^2.110.1"
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"noImplicitAny": true,
"outDir": "./dist",
"target": "es2015",
"esModuleInterop": true,
"module": "es2015",
"sourceMap": true,
"baseUrl": ".",
"paths": {
"three": ["node_modules/three/src/Three"]
},
"typeRoots" : ["types"]
"typeRoots" : ["types","node_modules/@types"]
},
"files": ["src/gcode-preview.ts"]
}
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,12 @@
"@types/istanbul-lib-coverage" "*"
"@types/istanbul-lib-report" "*"

"@types/jest-diff@*":
version "20.0.1"
resolved "https://registry.yarnpkg.com/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"
integrity sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==

"@types/jest@^24.0.16":
version "24.0.19"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.19.tgz#f7036058d2a5844fe922609187c0ad8be430aff5"
integrity sha512-YYiqfSjocv7lk5H/T+v5MjATYjaTMsUkbDnjGqSMoO88jWdtJXJV4ST/7DKZcoMHMBvB2SeSfyOzZfkxXHR5xg==
"@types/jest@^24.0.23":
version "24.0.23"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.23.tgz#046f8e2ade026fe831623e361a36b6fb9a4463e4"
integrity sha512-L7MBvwfNpe7yVPTXLn32df/EK+AMBFAFvZrRuArGs7npEWnlziUXK+5GMIUTI4NIuwok3XibsjXCs5HxviYXjg==
dependencies:
"@types/jest-diff" "*"
jest-diff "^24.3.0"

"@types/node@*":
version "12.12.8"
Expand Down Expand Up @@ -417,9 +412,9 @@ acorn-walk@^6.0.1:
integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==

acorn@^5.5.3:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
version "5.7.4"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==

acorn@^6.0.1:
version "6.3.0"
Expand Down Expand Up @@ -2314,7 +2309,7 @@ jest-config@^24.9.0:
pretty-format "^24.9.0"
realpath-native "^1.1.0"

jest-diff@^24.9.0:
jest-diff@^24.3.0, jest-diff@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.9.0.tgz#931b7d0d5778a1baf7452cb816e325e3724055da"
integrity sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ==
Expand Down Expand Up @@ -3980,6 +3975,11 @@ serialize-javascript@^1.6.1:
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.1.tgz#cfc200aef77b600c47da9bb8149c943e798c2fdb"
integrity sha512-0Vb/54WJ6k5v8sSWN09S0ora+Hnr+cX40r9F170nT+mSkaxltoE/7R3OrIdBSUv1OoiobH1QoWQbCnAO+e8J1A==

serialize-javascript@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61"
integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==

serve-index@^1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239"
Expand Down

0 comments on commit aaac975

Please sign in to comment.