├── src └── figure.js ├── test └── figure.js ├── .gitignore ├── .npmignore ├── .travis.yml ├── README.md ├── samples └── tetrahedron.stl ├── package.json └── bin └── figure /src/figure.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/figure.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.6 4 | - 0.8 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # figure 2 | 3 | `figure` terminal tool for 3D-object file conversion. 4 | 5 | ## Install 6 | 7 | `npm install -g figure` 8 | 9 | ## About 10 | 11 | Simple tool to change graphic formats. Based on open-source library 12 | `figment.js`. pleasefeeldeepthanks. 13 | 14 | # LICENSE 15 | 16 | MIT 17 | -------------------------------------------------------------------------------- /samples/tetrahedron.stl: -------------------------------------------------------------------------------- 1 | solid 2 | facet normal 0 0 0 3 | loop 4 | vertex -1 -1 0 5 | vertex 1 -1 0 6 | vertex 0 1 0 7 | endloop 8 | endfacet 9 | facet normal 0 0 0 10 | loop 11 | vertex -1 -1 0 12 | vertex 1 -1 0 13 | vertex 0 -1 -1 14 | endloop 15 | endfacet 16 | facet normal 0 0 0 17 | loop 18 | vertex -1 -1 0 19 | vertex 0 1 0 20 | vertex 0 -1 -1 21 | endloop 22 | endfacet 23 | facet normal 0 0 0 24 | loop 25 | vertex 1 -1 0 26 | vertex 0 1 0 27 | vertex 0 -1 -1 28 | endloop 29 | endfacet 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "figure", 3 | "version": "0.0.0", 4 | "description": "Command-line tool to convert between 3D Object formats via NodeJS", 5 | "main": "libs/InstagramStream.js", 6 | "dependencies": { 7 | "colors": "0.6.x", 8 | "minimist": "0.x.x" 9 | }, 10 | "devDependencies": { 11 | "mocha": "1.x.x" 12 | }, 13 | "scripts": { 14 | "start": "node examples/socket.io.js" 15 | }, 16 | "bin": { 17 | "figure": "bin/figure" 18 | }, 19 | "engines": { 20 | "node": ">=0.6" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/mattvvhat/figure.git" 25 | }, 26 | "keywords": [ 27 | "WebGL", 28 | "STL", 29 | "OBJ" 30 | ], 31 | "author": "Matt Razorblade Hammerstadt ", 32 | "license": "MIT", 33 | "readmeFilename": "README.md" 34 | } 35 | -------------------------------------------------------------------------------- /bin/figure: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Use colors for pretty warnings 4 | var colors = require('colors'); 5 | 6 | var argv = require('minimist')(process.argv.slice(2)); 7 | process.bin = process.title = 'figure'; 8 | 9 | var input = { file : '', type : '' }; 10 | var output = { file : '', type : '' }; 11 | 12 | if (argv._.length !== 2) { 13 | console.log('ERROR'.red + ': Must contain values for input and output'); 14 | process.exit(); 15 | } 16 | 17 | // :| 18 | input.file = argv._[0]; 19 | output.file = argv._[1]; 20 | 21 | // Get explicit input filetype or nah 22 | if ('in' in argv) 23 | input.type = argv['in']; 24 | else 25 | input.type = get_file_type(input.file); 26 | 27 | // Get explicit output filetype or nah 28 | if ('out' in argv) 29 | output.type = argv['out']; 30 | else 31 | output.type = get_file_type(output.file); 32 | 33 | // ... 34 | console.log(''); 35 | console.log('in file = ' + input.file); 36 | console.log('in type = ' + input.type); 37 | console.log('out file = ' + output.file); 38 | console.log('out type = ' + output.type); 39 | console.log(''); 40 | console.log('-_-'.yellow); 41 | 42 | /** 43 | * Try to Get the File-type from the Filename 44 | * Looks for the last '.' in the string, and returns every follow character. If 45 | * there are no instances of a '.', then return the empty string. 46 | * @param {string} str string, formatted like a file name 47 | * @return {string} the supposed filetype 48 | */ 49 | function get_file_type (str) { 50 | var i = str.lastIndexOf('.'); 51 | return i !== -1 ? str.substring(i+1) : ''; 52 | } 53 | 54 | 55 | --------------------------------------------------------------------------------