@loaders.gl/gltf
Version:
Framework-independent loader for the glTF format
36 lines • 1.26 kB
JavaScript
import { VERSION } from "./lib/utils/version.js";
import { parseGLTF } from "./lib/parsers/parse-gltf.js";
/**
* GLTF loader
*/
export const GLTFLoader = {
dataType: null,
batchType: null,
name: 'glTF',
id: 'gltf',
module: 'gltf',
version: VERSION,
extensions: ['gltf', 'glb'],
mimeTypes: ['model/gltf+json', 'model/gltf-binary'],
text: true,
binary: true,
tests: ['glTF'],
parse,
options: {
gltf: {
normalize: true, // Normalize glTF v1 to glTF v2 format (not yet stable)
loadBuffers: true, // Fetch any linked .BIN buffers, decode base64
loadImages: true, // Create image objects
decompressMeshes: true // Decompress Draco encoded meshes
}
}
};
export async function parse(arrayBuffer, options = {}, context) {
// Apps can call the parse method directly, we so apply default options here
const mergedOptions = { ...GLTFLoader.options, ...options };
mergedOptions.gltf = { ...GLTFLoader.options.gltf, ...mergedOptions.gltf };
const byteOffset = options?.glb?.byteOffset || 0;
const gltf = {};
return await parseGLTF(gltf, arrayBuffer, byteOffset, mergedOptions, context);
}
//# sourceMappingURL=gltf-loader.js.map