FontLoader.html 3.0 KB
Newer Older
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>
		<h1>[name]</h1>

		<div class="desc">
		Class for loading a font in JSON format. Returns a [page:Font Font], which is an
L
looeee 已提交
15 16
		array of [page:Shape Shape]s representing the font.
		This uses the [page:FileLoader] internally for loading files. <br /><br />
17 18 19 20 21 22 23

		You can convert fonts online using [link:https://gero3.github.io/facetype.js/ facetype.js]
		</div>

		<h2>Examples</h2>

		<div>
P
Paul Booker 已提交
24
		[example:webgl_geometry_text_shapes geometry / text / shapes ]<br/>
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
		[example:webgl_geometry_text geometry / text ]<br />
		[example:webgl_geometry_text_earcut geometry / text / earcut]<br />
		[example:webgl_geometry_text_pnltri geometry / text / pnltri]<br />
		</div>

		<code>
		var loader = new THREE.FontLoader();
		var font = loader.load(
			// resource URL
			'fonts/helvetiker_bold.typeface.json'
			// Function when resource is loaded
			function ( font ) {
				// do something with the font
				scene.add( font );
			},
			// Function called when download progresses
			function ( xhr ) {
				console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
			},
			// Function called when download errors
			function ( xhr ) {
				console.log( 'An error happened' );
			}
		);
		</code>

		<h2>Constructor</h2>

		<h3>[name]( [page:LoadingManager manager] )</h3>
		<div>
L
looeee 已提交
55 56
		[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
		Creates a new [name].
57
		</div>
L
looeee 已提交
58 59 60 61

		<h2>Properties</h2>

		<h3>[property:LoadingManager manager]</h3>
62
		<div>
L
looeee 已提交
63
			The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
64 65
		</div>

L
looeee 已提交
66

67 68 69 70
		<h2>Methods</h2>

		<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
		<div>
L
looeee 已提交
71 72
		[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 />
73
		[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
P
paulmasson 已提交
74
		[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 />
L
looeee 已提交
75 76 77
		[page:Function onError] — Will be called when load errors.<br /><br />

		Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
78
		</div>
L
looeee 已提交
79 80

		<h3>[method:Font parse]( [page:Object json] )</h3>
81
		<div>
L
looeee 已提交
82 83
		[page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
		Parse a <em>JSON</em> structure and return a [page:Font].
84 85 86 87 88 89 90
		</div>

		<h2>Source</h2>

		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
	</body>
</html>