1.0.0 • Published 10 years ago
obj-mesh v1.0.0
obj-mesh
parse an obj file into the object format that mesh-viewer understands
The format that mesh-viewer understands is the same object format that the bunny and stanford-dragon packages use.
example
var xhr = require('xhr');
var objmesh = require('obj-mesh');
var through = require('through2');
var viewer = require('mesh-viewer');
var shell = viewer();
var meshes = [];
shell.on('gl-init', function () {
xhr('/teapot.obj', function (err, res, body) {
var obj = objmesh();
obj.pipe(through.obj(function (mesh, enc, next) {
meshes.push(shell.createMesh(mesh));
next();
}));
obj.end(body);
});
});
shell.on('gl-render', function () {
for (var i = 0; i < meshes.length; i++) {
meshes[i].draw();
}
});
methods
var objmesh = require('obj-mesh')
var stream = objmesh()
Return a transform stream
that expects to be written obj file contents and
outputs an object of the form that
mesh-viewer for each object group in
the input source file.
Each object has:
- row.positions - an array of
[x,y,z]
arrays for each point in the mesh - row.cells - an array of
[i,j,k,...]
point indexes for each point inrow.positions
install
With npm do:
npm install obj-mesh
license
MIT
1.0.0
10 years ago