123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <p class="desc">
- A loader for loading a JSON resource. Unlike the [page:JSONLoader], this one make use of the
- <em>.type</em> attributes of objects to map them to their original classes.<br /><br />
- Note that this loader can't load [page:Geometries]. Use [page:JSONLoader] instead for that.<br /><br />
- This uses the [page:FileLoader] internally for loading files.
- </p>
- <h2>Example</h2>
- <p>
- [example:webgl_animation_scene WebGL / animation / scene]<br />
- [example:webgl_loader_json_claraio WebGL / loader / json / claraio]<br />
- [example:webgl_loader_msgpack WebGL / loader / msgpack]
- </p>
- <code>
- var loader = new THREE.ObjectLoader();
- loader.load(
- // resource URL
- "models/json/example.json",
- // onLoad callback
- // Here the loaded data is assumed to be an object
- function ( obj ) {
- // Add the loaded object to the scene
- scene.add( obj );
- },
- // onProgress callback
- function ( xhr ) {
- console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
- },
- // onError callback
- function ( err ) {
- console.error( 'An error happened' );
- }
- );
- // Alternatively, to parse a previously loaded JSON structure
- var object = loader.parse( a_json_object );
- scene.add( object );
- </code>
- <h2>Constructor</h2>
- <h3>[name]( [param:LoadingManager manager] )</h3>
- <p>
- [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
- Creates a new [name].
- </p>
- <h2>Properties</h2>
- <h3>[property:String crossOrigin]</h3>
- <p>
- If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
- attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
- </p>
- <h3>[property:LoadingManager manager]</h3>
- <p>
- The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
- </p>
- <h3>[property:String texturePath]</h3>
- <p>
- The base path or URL from which textures will be loaded. See [page:.setTexturePath].
- Default is the empty string.
- </p>
- <h2>Methods</h2>
- <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
- <p>
- [page:String url] — the path or URL to the file. This can also be a
- [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
- [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Object3D object].<br />
- [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 />
- [page:Function onError] — Will be called when load errors.<br />
- </p>
- <p>
- Begin loading from url and call onLoad with the parsed response content.
- </p>
- <h3>[method:Object3D parse]( [param:Object json], [param:Function onLoad] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- [page:Function onLoad] — Will be called when parsed completes. The argument will be the parsed [page:Object3D object].<br /><br />
- Parse a <em>JSON</em> structure and return a threejs object.
- This is used internally by [page:.load], but can also be used directly to parse
- a previously loaded JSON structure.
- </p>
- <h3>[method:Object3D parseGeometries]( [param:Object json] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- This is used [page:.parse] to parse any [page:Geometry geometries] or [page:BufferGeometry buffer geometries] in the JSON structure.
- Internally it uses [page:JSONLoader] for geometries and [page:BufferGeometryLoader] for buffer geometries.
- </p>
- <h3>[method:Object3D parseMaterials]( [param:Object json] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- This is used [page:.parse] to parse any materials in the JSON structure using [page:MaterialLoader].
- </p>
- <h3>[method:Object3D parseAnimations]( [param:Object json] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- This is used [page:.parse] to parse any animations in the JSON structure, using [page:AnimationClip.parse].
- </p>
- <h3>[method:Object3D parseImages]( [param:Object json] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- This is used [page:.parse] to parse any images in the JSON structure, using [page:ImageLoader].
- </p>
- <h3>[method:Object3D parseTextures]( [param:Object json] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- This is used [page:.parse] to parse any textures in the JSON structure.
- </p>
- <h3>[method:Object3D parseObject]( [param:Object json] )</h3>
- <p>
- [page:Object json] — required. The JSON source to parse.<br /><br />
- This is used [page:.parse] to parse any objects in the JSON structure.
- Objects can be of the following types:
- <ul>
- <li>
- [page:Scene]
- </li>
- <li>
- [page:PerspectiveCamera]
- </li>
- <li>
- [page:OrthographicCamera]
- </li>
- <li>
- [page:AmbientLight]
- </li>
- <li>
- [page:DirectionalLight]
- </li>
- <li>
- [page:PointLight]
- </li>
- <li>
- [page:SpotLight]
- </li>
- <li>
- [page:HemisphereLight]
- </li>
- <li>
- [page:Mesh]
- </li>
- <li>
- [page:LOD]
- </li>
- <li>
- [page:Line]
- </li>
- <li>
- [page:LineSegments]
- </li>
- <li>
- [page:Points]
- </li>
- <li>
- [page:Sprite]
- </li>
- <li>
- [page:Group]
- </li>
- <li>
- [page:Object3D]
- </li>
- </ul>
- </p>
- <h3>[method:ObjectLoader setCrossOrigin]( [param:String value] )</h3>
- <p>
- [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
- </p>
- <h3>[method:ObjectLoader setTexturePath]( [param:String value] )</h3>
- <p>
- [page:String value] — The base path or URL from which textures will be loaded.<br /><br />
- </p>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
- </html>
|