Convenience library to process Khronos glTF files.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

gltf-walker Build Status Build Status npm

This is a convenience library to support processing of Khronos glTF files. It is inspired by Fabrice Robinet's glTF-parser.js but provides some convenience functionality and is available as NPM package.

⚠️ The library is not yet complete and the API is likely to change

Installation

$ npm install gltf-walker

Functionality

  • Callbacks for all components in order of dependencies textures
  • Resolves named references in JSON to real object references in JavaScript
  • Buffers: Creates ArrayBuffer objects from data URLs
  • Shaders: Creates strings from data URLs
  • Resolve relative URIs (optional)

Usage

var walker = require("gltf-walker");
var json = JSON.parse(/* glTF file here */);

// Callbacks for all components, called in order of dependencies
walker(json, {
  buffers: function (buffer, id) {
    console.log(buffer._buffer); // Only set if buffer is defined as data URL 
    console.log(buffer._uri); // Only set if buffer is not a data URL and baseURL is defined
  },
  materials: function (material, id) {
  
  },
  images: function (image, id) {
  
  },
  ...
  default: function (desc, id) {
    // Callback for all categories that do not have a dedicated callback
  }
}, { 
  // Optional user context object.
  // Available as 'this' in callbacks
  context: null,
  // The library will resolve relative
  // URLs, if this (optional) base URL is defined
  baseURL: null
});  
  

TODO

  • Fetch external resources (optional)

License

MIT License (MIT)