0.2.1 • Published 8 years ago

gltf-walker v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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.

:warning: 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)

0.2.1

8 years ago

0.2.0

8 years ago

0.0.1

8 years ago