1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
<!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>
[page:Loader] →
<h1>[name]</h1>
<p class="desc">
A loader for loading a JSON resource in the [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].<br /><br />
This uses the [page:FileLoader] internally for loading files.
</p>
<h2>Example</h2>
<p>
[example:webgl_loader_json_claraio WebGL / loader / json / claraio]<br />
[example:webgl_materials_lightmap WebGL / materials / lightmap]
</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>
<p>See the base [page:Loader] class for common properties.</p>
<h2>Methods</h2>
<p>See the base [page:Loader] class for common methods.</p>
<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.
</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>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</p>
</body>
</html>
|