A loader for loading objects in JSON format. This uses the FileLoader internally for loading files.


WebGL / loader / json

// instantiate a loader var loader = new v3d.JSONLoader(); // load a resource loader.load( // resource URL 'models/animated/monster/monster.js', // onLoad callback function(geometry, materials) { var material = materials[0]; var object = new v3d.Mesh(geometry, material); scene.add(object); }, // onProgress callback function(xhr) { console.log((xhr.loaded / xhr.total * 100) + '% loaded'); }, // onError callback function(err) { console.log('An error happened'); } );


JSONLoader(manager : LoadingManager)

manager — The loadingManager for the loader to use. Default is v3d.DefaultLoadingManager.

Creates a new JSONLoader.


.crossOrigin : String

If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load. Default is "anonymous".

.manager : LoadingManager

The loadingManager the loader is using. Default is DefaultLoadingManager.

.withCredentials : String

Whether the XMLHttpRequest uses credentials. Default is false.


.load (url : String, onLoad : Function, onProgress : Function, onError : Function) : null

url — the path or URL to the file. This can also be a Data URI..
onLoad — Will be called when load completes. The argument will be the loaded text response.
onProgress — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .total and .loaded bytes.
onError — Will be called when load errors.

Begin loading from url and pass the JSON to onLoad.

.parse (json : Object, path : String) : Object3D

json — JSON object to parse.
path — Base path for resources if no resource path is defined.

Parse a JSON structure and return an object containing the parsed geometry and materials.

.setCrossOrigin (value : String) : JSONLoader

Set the .crossOrigin attribute.

.setPath (value : String) : JSONLoader

Set the base path for the original file.

.setResourcePath (value : String) : JSONLoader

Set the base path for dependent resources like textures.


For more info on how to obtain the source code of this module see this page.