parse-pc2
v1.0.1
Published
Parse .PC2 vertex animation files
Downloads
7
Maintainers
Readme
parse-pc2
Parse .PC2 vertex animation files. Demo.
Installation
Blocking API
var pc2Parser = require('parse-pc2')
var parsed = pc2Parser.toObject(fs.readFileSync('/path/to/animation.pc2'))
Stream API
var pc2Parser = require('parse-pc2')
var parser = new pc2Parser.StreamingParser()
parser.on('readable', function () {
var parsed = parser.read()
if (parsed) {
// Use parsed data
}
})
parser.write(buf)
Object Structure
The following object structure is returned by both parsing APIs:
{
numPoints, // Number of points per sample
startFrame, // First sampled frame
sampleRate, // How frequently to sample (or skip) the frames
numSamples, // How many samples are stored in this file
frames: [
// An array per frame
// Each containing "numPoints" vertex coordinates
[ [x, y, z], [x, y, z] ]
]
}
Example
An example using stack.gl modules to play an animation exported from Blender:
$ npm run demo
Development
Unit Tests
$ npm run test
Coding style
standardjs.com and jshint, as enforced by:
$ npm run lint
License
MIT