nanogl-gltf
Version:
26 lines (25 loc) • 905 B
JavaScript
import GltfTypes from '../types/GltfTypes';
import Assert from '../lib/assert';
/**
* The Buffer element contains raw binary data, used to store data about geometry, animations, skins or textures.
* Comes from an external file or is stored in the GLTF file as a base64 string.
*/
export default class Buffer {
constructor() {
this.gltftype = GltfTypes.BUFFER;
}
/**
* Parse the Buffer data, load the buffer data from the uri and store them in _bytes attribute.
*
* Is async as it needs to wait for the buffer data to be loaded.
* @param gltfLoader GLTFLoader to use
* @param data Data to parse
*/
async parse(gltfLoader, data) {
this.byteLength = data.byteLength;
this.uri = data.uri;
this._byteOffset = 0;
this._bytes = await gltfLoader.loadBufferUri(data.uri);
Assert.isTrue(this._bytes !== null);
}
}