JavaScript utility library for working with glTF models
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.
.settings
doc
test
.jshintrc
.project
LICENSE.md
README.md
gltfUtilities.js

README.md

glTF Utilities

JavaScript utility library for working with glTF models. This library provides a consistent API for loading various glTF resources, such as images, shaders, and buffers, from a remote URL (both same-origin and cross-origin) or embedded using a data URI.

How to use

Include gltfUtilities.js in your page. This creates a global variable gltfUtilities with the following functions:

loadImage(url, success, error)

This function will asynchronously load the given URL (or data URI) as an Image. In order to load cross-origin data, the server must have Cross-Origin Resource Sharing (CORS) enabled.

gltfUtilities.loadImage(imageUrl, function(image) {
  // The image loaded successfully
}, function(error) {
  // The image failed to load
});

loadText(url, success, error)

This function will asynchronously load the given URL (or data URI) as a String. If an error occurs, the error callback will be passed the XMLHttpRequest object used to make the request. In order to load cross-origin data, the server must have Cross-Origin Resource Sharing (CORS) enabled.

gltfUtilities.loadText(shaderUrl, function(text) {
  // The text loaded successfully
}, function(xhr) {
  // The text failed to load
});

loadArrayBuffer(url, success, error)

This function will asynchronously load the given URL (or data URI) as an ArrayBuffer. If an error occurs, the error callback will be passed the XMLHttpRequest object used to make the request. In order to load cross-origin data, the server must have Cross-Origin Resource Sharing (CORS) enabled.

gltfUtilities.loadArrayBuffer(bufferUrl, function(arrayBuffer) {
  // The ArrayBuffer loaded successfully
}, function(xhr) {
  // The ArrayBuffer failed to load
});

Developed by AGI, founders of the Cesium WebGL engine.