瀏覽代碼

Improved doc for ObjectLoader

looeee 8 年之前
父節點
當前提交
fe5e509204
共有 1 個文件被更改,包括 167 次插入11 次删除
  1. 167 11
      docs/api/loaders/ObjectLoader.html

+ 167 - 11
docs/api/loaders/ObjectLoader.html

@@ -10,21 +10,55 @@
 	<body>
 	<body>
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
-		<div 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.</div>
+		<div 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.
+		</div>
 
 
 		<h2>Example</h2>
 		<h2>Example</h2>
 
 
+		<div>
+
+			[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]
+		</div>
+
 		<code>
 		<code>
-		// instantiate a loader
-		var loader = new THREE.ObjectLoader();
+var loader = new THREE.ObjectLoader();
 
 
-		// assuming we loaded a JSON structure from elsewhere
-		var object = loader.parse( a_json_object );
+loader.load(
+    // resource URL
+    "models/json/example.json"
 
 
-		scene.add( object );
-		</code>
+    // pass the loaded data to the onLoad function.
+		//Here it is assumed to be an object
+    function ( obj ) {
+				//add the loaded object to the scene
+        scene.add( obj );
+    },
+
+    // Function called when download progresses
+    function ( xhr ) {
+        console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
+    },
+
+    // Function called when download errors
+    function ( xhr ) {
+        console.error( 'An error happened' );
+    }
+);
+
+
+// Alternatively, to parse a previously loaded JSON structure
+var object = loader.parse( a_json_object );
 
 
-		[example:webgl_loader_msgpack]
+scene.add( object );
+		</code>
 
 
 
 
 
 
@@ -41,6 +75,23 @@
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>
 
 
+		<h3>[property:String crossOrigin]</h3>
+		<div>
+		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 *undefined*.
+		</div>
+
+		<h3>[property:LoadingManager manager]</h3>
+		<div>
+			The [page:LoadingManager loadingManager]  the loader is using. Default is [page:DefaultLoadingManager].
+		</div>
+
+		<h3>[property:String texturePath]</h3>
+		<div>
+			The base path or URL from which textures will be loaded. See [page:.setTexturePath].
+			Default is the empty string.
+		</div>
 
 
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 
 
@@ -56,12 +107,110 @@
 		</div>
 		</div>
 
 
 
 
-		<h3>[method:Object3D parse]( [page:Object json] )</h3>
+		<h3>[method:Object3D parse]( [page:Object json], [page:Function onLoad]  )</h3>
+		<div>
+		[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 />
+
+		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.
+		</div>
+
+		<h3>[method:Object3D parseGeometries]( [page:Object json] )</h3>
+		<div>
+		[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.
+		</div>
+
+		<h3>[method:Object3D parseMaterials]( [page:Object json] )</h3>
+		<div>
+		[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].
+		</div>
+
+		<h3>[method:Object3D parseAnimations]( [page:Object json] )</h3>
+		<div>
+		[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].
+		</div>
+
+		<h3>[method:Object3D parseImages]( [page:Object json] )</h3>
+		<div>
+		[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].
+		</div>
+
+		<h3>[method:Object3D parseTextures]( [page:Object json] )</h3>
 		<div>
 		<div>
-		[page:Object json] — required. The JSON source to parse<br />
+		[page:Object json] — required. The JSON source to parse.<br /><br />
+
+		This is used [page:.parse] to parse any textures in the JSON structure.
 		</div>
 		</div>
+
+		<h3>[method:Object3D parseObject]( [page:Object json] )</h3>
 		<div>
 		<div>
-		Parse a <em>JSON</em> content and return a threejs object.
+		[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>
 		</div>
 		</div>
 
 
 		<h3>[method:null setCrossOrigin]( [page:String value] )</h3>
 		<h3>[method:null setCrossOrigin]( [page:String value] )</h3>
@@ -69,6 +218,13 @@
 		[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
 		[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
 		</div>
 		</div>
 
 
+		<h3>[method:null setTexturePath]( [page:String value] )</h3>
+		<div>
+		[page:String value] — The base path or URL from which textures will be loaded.<br /><br />
+
+
+		</div>
+
 		<h2>Source</h2>
 		<h2>Source</h2>
 
 
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
 		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]