4 <meta charset="utf-8" />
6 <script src="list.js"></script>
7 <script src="page.js"></script>
8 <link type="text/css" rel="stylesheet" href="page.css" />
14 A loader for loading a JSON resource. Unlike the [page:JSONLoader], this one make use of the
15 <em>.type</em> attributes of objects to map them to their original classes.<br /><br />
17 Note that this loader can't load [page:Geometries]. Use [page:JSONLoader] instead for that.<br /><br />
19 This uses the [page:FileLoader] internally for loading files.
26 [example:webgl_animation_scene WebGL / animation / scene]<br />
27 [example:webgl_loader_json_claraio WebGL / loader / json / claraio]<br />
28 [example:webgl_loader_msgpack WebGL / loader / msgpack]
32 var loader = new THREE.ObjectLoader();
36 "models/json/example.json",
38 // pass the loaded data to the onLoad function.
39 //Here it is assumed to be an object
41 //add the loaded object to the scene
45 // Function called when download progresses
47 console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
50 // Function called when download errors
52 console.error( 'An error happened' );
57 // Alternatively, to parse a previously loaded JSON structure
58 var object = loader.parse( a_json_object );
67 <h3>[name]( [page:LoadingManager manager] )</h3>
69 [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
77 <h3>[property:String crossOrigin]</h3>
79 If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
80 attribute of the image to the value of *crossOrigin*,
81 prior to starting the load. Default is *undefined*.
84 <h3>[property:LoadingManager manager]</h3>
86 The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
89 <h3>[property:String texturePath]</h3>
91 The base path or URL from which textures will be loaded. See [page:.setTexturePath].
92 Default is the empty string.
97 <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
99 [page:String url] — the path or URL to the file. This can also be a
100 [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
101 [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Object3D object].<br />
102 [page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
103 [page:Function onError] — Will be called when load errors.<br />
106 Begin loading from url and call onLoad with the parsed response content.
110 <h3>[method:Object3D parse]( [page:Object json], [page:Function onLoad] )</h3>
112 [page:Object json] — required. The JSON source to parse.<br /><br />
113 [page:Function onLoad] — Will be called when parsed completes. The argument will be the parsed [page:Object3D object].<br />
115 Parse a <em>JSON</em> structure and return a threejs object.
116 This is used internally by [page:.load], but can also be used directly to parse
117 a previously loaded JSON structure.
120 <h3>[method:Object3D parseGeometries]( [page:Object json] )</h3>
122 [page:Object json] — required. The JSON source to parse.<br /><br />
124 This is used [page:.parse] to parse any [page:Geometry geometries] or [page:BufferGeometry buffer geometries] in the JSON structure.
125 Internally it uses [page:JSONLoader] for geometries and [page:BufferGeometryLoader] for buffer geometries.
128 <h3>[method:Object3D parseMaterials]( [page:Object json] )</h3>
130 [page:Object json] — required. The JSON source to parse.<br /><br />
132 This is used [page:.parse] to parse any materials in the JSON structure using [page:MaterialLoader].
135 <h3>[method:Object3D parseAnimations]( [page:Object json] )</h3>
137 [page:Object json] — required. The JSON source to parse.<br /><br />
139 This is used [page:.parse] to parse any animations in the JSON structure, using [page:AnimationClip.parse].
142 <h3>[method:Object3D parseImages]( [page:Object json] )</h3>
144 [page:Object json] — required. The JSON source to parse.<br /><br />
146 This is used [page:.parse] to parse any images in the JSON structure, using [page:ImageLoader].
149 <h3>[method:Object3D parseTextures]( [page:Object json] )</h3>
151 [page:Object json] — required. The JSON source to parse.<br /><br />
153 This is used [page:.parse] to parse any textures in the JSON structure.
156 <h3>[method:Object3D parseObject]( [page:Object json] )</h3>
158 [page:Object json] — required. The JSON source to parse.<br /><br />
160 This is used [page:.parse] to parse any objects in the JSON structure.
161 Objects can be of the following types:
168 [page:PerspectiveCamera]
171 [page:OrthographicCamera]
177 [page:DirectionalLight]
186 [page:HemisphereLight]
216 <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
218 [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
221 <h3>[method:null setTexturePath]( [page:String value] )</h3>
223 [page:String value] — The base path or URL from which textures will be loaded.<br /><br />
230 [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]