Browse Source

Merge pull request #12058 from lukehorvat/FontLoader-setPath

Add setPath method to FontLoader
Mr.doob 8 years ago
parent
commit
08ae285051
2 changed files with 16 additions and 0 deletions
  1. 8 0
      docs/api/loaders/FontLoader.html
  2. 8 0
      src/loaders/FontLoader.js

+ 8 - 0
docs/api/loaders/FontLoader.html

@@ -63,6 +63,8 @@
 			The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
 			The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
 		</div>
 		</div>
 
 
+		<h3>[property:String path]</h3>
+		<div>The base path from which fonts will be loaded. See [page:.setPath]. Default is *undefined*.</div>
 
 
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 
 
@@ -83,6 +85,12 @@
 		Parse a <em>JSON</em> structure and return a [page:Font].
 		Parse a <em>JSON</em> structure and return a [page:Font].
 		</div>
 		</div>
 
 
+		<h3>[method:FontLoader setPath]( [page:String path] )</h3>
+		<div>
+			Set the base path or URL from which to load fonts. This can be useful if
+			you are loading many fonts from the same directory.
+		</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]

+ 8 - 0
src/loaders/FontLoader.js

@@ -19,6 +19,7 @@ Object.assign( FontLoader.prototype, {
 		var scope = this;
 		var scope = this;
 
 
 		var loader = new FileLoader( this.manager );
 		var loader = new FileLoader( this.manager );
+		loader.setPath( this.path );
 		loader.load( url, function ( text ) {
 		loader.load( url, function ( text ) {
 
 
 			var json;
 			var json;
@@ -46,6 +47,13 @@ Object.assign( FontLoader.prototype, {
 
 
 		return new Font( json );
 		return new Font( json );
 
 
+	},
+
+	setPath: function ( value ) {
+
+		this.path = value;
+		return this;
+
 	}
 	}
 
 
 } );
 } );