Giter VIP home page Giter VIP logo

threejs-export-obj's Introduction

ThreeJS-export-OBJ

OBJ exporter for three.js

For a STL exporter see https://github.com/Doodle3D/ThreeJS-export-STL

Example

import 'mrdoob/three.js/three.js';
import { saveAs } from 'file-saver';
import * as exportOBJ from 'Doodle3D/ThreeJS-export-OBJ';

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

mesh.position.y = 0.5;

const buffer = exportOBJ.fromMesh(mesh).then(blob => {
  saveAs(blob, 'cube.obj');  
});

Installation

Using JSPM (ECMAScript / ES6 Module)

Install the library.

jspm install github:Doodle3D/ThreeJS-export-OBJ

Include the library.

import * as exportOBJ from 'Doodle3D/ThreeJS-export-OBJ';

Using NPM (CommonJS module) IS NOT YET PUBLISHED ON NPM

Install the library.

npm install threejs-export-obj --save

Include the library.

const exportOBJ = require('threejs-export-obj');

API

exportOBJ.fromMesh

data: Buffer = async exportOBJ.fromMesh( mesh: THREE.Mesh )

Creates a .ZIP from THREE.Mesh. The .ZIP contains a .obj file and a .mtl file. The transformation on the THREE.Mesh will be applied to the OBJ geometry.

exportOBJ.fromGeometry

data: Buffer = async exportOBJ.fromGeometry( geometry: THREE.Geometry || THREE.BufferGeometry, [ matrix: THREE.Matrix4, material: THREE.Material ] )

Creates a .ZIP from THREE.Geometry. The .ZIP contains a .obj file and optionally a .mtl file. The transformation from the optional matrix argument will be applied to the geometry.

threejs-export-obj's People

Contributors

casperlamboo avatar peteruithoven avatar

Watchers

James Cloos 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.