GLTFLoader.html 3.4 KB
Newer Older
R
Rich Tibbett 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<!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] &rarr;
		<h1>[name]</h1>

		<div class="desc">
15
		A loader for loading a *gltf* resource in JSON format.
R
Rich Tibbett 已提交
16 17 18 19
		<br /><br />
		The <a href="https://www.khronos.org/gltf">glTF file format</a> is a JSON file format to enable rapid delivery and loading of 3D content.
		</div>

20 21 22 23 24 25 26 27 28 29 30
		<h2>Notes</h2>

		<div>
		When using custom shaders provided within a glTF file [page:THREE.GLTFLoader.Shaders] should be updated on each render loop. See [example:webgl_loader_gltf] demo source code for example usage.
		</div>

		<h2>Example</h2>

		<code>
		// instantiate a loader
		var loader = new THREE.GLTFLoader();
R
Rich Tibbett 已提交
31

32 33 34 35 36 37 38 39 40 41 42 43
		// load a glTF resource
		loader.load(
			// resource URL
			'models/gltf/duck/duck.json',
			// Function when resource is loaded
			function ( object ) {
				scene.add( object.scene );
			}
		);
		</code>

		[example:webgl_loader_gltf]
D
Don McCurdy 已提交
44

R
Rich Tibbett 已提交
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
		<h2>Constructor</h2>

		<h3>[name]( [page:LoadingManager manager] )</h3>
		<div>
		[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
		</div>
		<div>
		Creates a new [name].
		</div>

		<h2>Properties</h2>


		<h2>Methods</h2>

		<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
		<div>
		[page:String url] — required<br />
		[page:Function onLoad] — Will be called when load completes. The argument will be the loaded JSON response returned from [page:Function parse].<br />
		[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
		[page:Function onError] — Will be called when load errors.<br />
		</div>
		<div>
		Begin loading from url and call the callback function with the parsed response content.
		</div>

		<h3>[method:null setPath]( [page:String path] )</h3>
		<div>
		[page:String path] — Base path for loading additional resources e.g. textures, GLSL shaders, .bin data.
		</div>
		<div>
		Set the base path for additional resources.
		</div>

		<h3>[method:null setCrossOrigin]( [page:String value] )</h3>
		<div>
		[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
		</div>

		<h3>[method:null parse]( [page:Object json], [page:Function callBack], [page:String path] )</h3>
		<div>
		[page:Object json] — <em>JSON</em> object to parse.<br />
		[page:Function callBack] — Will be called when parse completes.<br />
		[page:String path] — The base path from which to find subsequent glTF resources such as textures, GLSL shaders and .bin data files.<br />
		</div>
		<div>
		Parse a glTF-based <em>JSON</em> structure and fire [page:Function callback] when complete. The argument to [page:Function callback] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array cameras], .[page:Array animations] and .[page:Array shaders]
		</div>

		<h2>Source</h2>

		[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js examples/js/loaders/GLTFLoader.js]
	</body>
</html>