picogl-prwm-loader
v1.1.1
Published
PRWM loader for PicoGL.js
Downloads
4
Readme
picogl-prwm-loader
A PRWM loader for PicoGL.js
Packed Raw WebGL Model is a binary file format for nD geometries specifically designed for JavaScript and WebGL with a strong focus on fast parsing (from 1ms to 0.1ms in Chrome 59 on a MBP Late 2013). More information on this here.
Installing
With npm do:
npm install picogl-prwm-loader --save
Example
var PRWMLoader = require('picogl-prwm-loader'),
PicoGL = require('picogl');
var app = PicoGL.createApp(document.getElementById('canvas'));
var loader = new PRWMLoader(PicoGL, app).setVerbosity(true);
loader.load(
'./models/mymodel.prwm',
{
position: 0,
normal: 1,
uv: 2
},
function onComplete (vertexArray) {
console.log(vertexArray)
}
);
API
new PRWMLoader(picoGL, app)
Instantiate a loader for PRWM files.
Arguments
- picoGL : The PicoGL namespace.
- app : The PicoGL App instance.
loader.setVerbosity(verbose)
Set the verbosity of the loader.
Arguments
- verbose : Whether the loader should be verbose (true) or silent (false).
loader.parse(arrayBuffer, attributeMapping, offset)
Parse a PRWM file passed as an ArrayBuffer and directly return an instance of PicoGL's VertexArray.
Arguments
- arrayBuffer: ArrayBuffer containing the PRWM data.
- attributeMapping: Literal object with attribute name => attribute index mapping.
- offset: Offset (in bytes) at which the PRWM file content is located in the ArrayBuffer. Must be a multiple of 4.
loader.load(url, attributeMapping, onSuccess)
Parse a remote PRWM file and return an instance of PicoGL's VertexArray (through a callback)
Arguments
- url: Url of the PRWM file.
- attributeMapping: Literal object with attribute name => attribute index mapping.
- onSuccess: Callback called with the VertexArray on success.
PRWMLoader.isBigEndianPlatform()
Return true if the endianness of the platform is Big Endian.
Changelog
1.1.1 (2017.12.26) :
- Add
offset
argument inparse()
.
1.1.0 (2017.08.19) :
- Use new methods from PicoGL 0.6.6 to fully support all attributes types.
1.0.0 (2017.08.15) :
- First release.
License
MIT