Socket
Book a DemoInstallSign in
Socket

@doodle3d/threejs-export-stl

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@doodle3d/threejs-export-stl

ThreeJS STL Exporter

latest
npmnpm
Version
0.0.5
Version published
Maintainers
2
Created
Source

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).

Keywords

three

FAQs

Package last updated on 06 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts