Giter Site home page Giter Site logo

threejs-export-stl's Introduction

ThreeJS-export-STL

STL exporter for three.js

Can create both binary and ascii STL's.

Example

import * as THREE from 'three';
import { saveAs } from 'file-saver';
import * as exportSTL from 'Doodle3D/ThreeJS-export-STL';

const geometry = new THREE.BoxGeometry(1, 1, 1).clone();
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00, wireframe: true });
const mesh = new THREE.Mesh(geometry, material);

mesh.position.y = 0.5;

const buffer = exportSTL.fromMesh(mesh);
const blob = new Blob([buffer], { type: exportSTL.mimeType });

saveAs(blob, 'cube.stl');

Installation

Using JSPM (ECMAScript / ES6 Module)

Install the library.

jspm install github:Doodle3D/ThreeJS-export-STL

Include the library.

import * as exportSTL from 'Doodle3D/ThreeJS-export-STL';

Using NPM (CommonJS module)

Install the library.

npm install threejs-export-stl --save

Include the library.

const exportSTL = require('threejs-export-stl');

API

exportSTL.fromMesh

data: String || Buffer = exportSTL.fromMesh( mesh: THREE.Mesh, [ binary: Boolean = true ] )

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.

exportSTL.fromGeometry

data: String || Buffer = exportSTL.fromGeometry( geometry: THREE.Geometry || THREE.BufferGeometry, [ matrix: THREE.Matrix4, binary: Boolean = true ] )

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.

exportSTL.mimeType

mimeType: String = exportSTL.mimeType

A constant with the mime type of STL (application/vnd.ms-pki.stl).

threejs-export-stl's People

Contributors

casperlamboo avatar peteruithoven 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.