Skip to content

Commit e373fea

Browse files
authored
Create README.md
1 parent 6925cd2 commit e373fea

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# ThreeJS-export-STL
2+
STL exporter for [three.js](https://github.com/mrdoob/three.js)
3+
4+
Can create both `binary` and `ascii` STL's.
5+
6+
# Example
7+
8+
```javascript
9+
import 'three.js';
10+
import { saveAs } from 'file-saver';
11+
import * as exportSTL from 'Doodle3D/ThreeJS-export-STL';
12+
13+
const geometry = new THREE.BoxGeometry(1, 1, 1);
14+
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
15+
const mesh = new THREE.Mesh(geometry, material);
16+
17+
mesh.position.y = 0.5;
18+
19+
const buffer = exportSTL.fromMesh(mesh);
20+
const blob = new Blob([buffer], { type: exportSTL.mimeType });
21+
22+
saveAs(blob, 'cube.stl');
23+
```
24+
25+
# Installation
26+
27+
### Using JSPM (ECMAScript / ES6 Module)
28+
29+
Install the library.
30+
31+
```
32+
jspm install github:Doodle3D/ThreeJS-export-STL
33+
```
34+
35+
Include the library.
36+
37+
```javascript
38+
import * as exportSTL from 'Doodle3D/ThreeJS-export-STL';
39+
```
40+
41+
### Using NPM (CommonJS module)
42+
43+
Install the library.
44+
45+
```
46+
npm install threejs-export-stl --save
47+
```
48+
49+
Include the library.
50+
51+
```javascript
52+
const exportSTL = require('threejs-export-stl');
53+
```
54+
55+
# API
56+
57+
**exportSTL.fromMesh**
58+
59+
```javascript
60+
data: String || Buffer = exportSTL.fromMesh( mesh: THREE.Mesh, [ binary: Boolean = true ] )
61+
```
62+
63+
Creates a .STL from `THREE.Mesh`. When binary is set to `true` result will be a `Buffer` Object, when set to false result will be an ASCII string. The transformation on the `THREE.Mesh` will be applied to the STL geometry.
64+
65+
**exportSTL.fromGeometry**
66+
67+
```javascript
68+
data: String || Buffer = exportSTL.fromGeometry( geometry: THREE.Geometry || THREE.BufferGeometry, [ matrix: THREE.Matrix4, binary: Boolean = true ] )
69+
```
70+
71+
Creates a .STL from `THREE.Geometry`. When binary is set to `true` result will be a `Buffer` Object, when set to false result will be an ASCII string. The transformation from the optional `matrix` argument will be applied to the STL geometry.
72+
73+
**exportSTL.mimeType**
74+
75+
```javascript
76+
mimeType: String = exportSTL.mimeType
77+
```
78+
79+
A constant with the mime type of STL (`application/vnd.ms-pki.stl`).

0 commit comments

Comments
 (0)