FontLoader.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Class for loading a font in JSON format. Returns a [page:Font Font], which is an
  14. array of [page:Shape Shape]s representing the font.
  15. This uses the [page:FileLoader] internally for loading files. <br /><br />
  16. You can convert fonts online using [link:https://gero3.github.io/facetype.js/ facetype.js]
  17. </p>
  18. <h2>Examples</h2>
  19. <p>
  20. [example:webgl_geometry_text_shapes geometry / text / shapes ]<br/>
  21. [example:webgl_geometry_text geometry / text ]
  22. </p>
  23. <code>
  24. var loader = new THREE.FontLoader();
  25. var font = loader.load(
  26. // resource URL
  27. 'fonts/helvetiker_bold.typeface.json',
  28. // onLoad callback
  29. function ( font ) {
  30. // do something with the font
  31. scene.add( font );
  32. },
  33. // onProgress callback
  34. function ( xhr ) {
  35. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  36. },
  37. // onError callback
  38. function ( err ) {
  39. console.log( 'An error happened' );
  40. }
  41. );
  42. </code>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:LoadingManager manager] )</h3>
  45. <p>
  46. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  47. Creates a new [name].
  48. </p>
  49. <h2>Properties</h2>
  50. <h3>[property:LoadingManager manager]</h3>
  51. <p>
  52. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  53. </p>
  54. <h3>[property:String path]</h3>
  55. <p>The base path from which fonts will be loaded. See [page:.setPath]. Default is *undefined*.</p>
  56. <h2>Methods</h2>
  57. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  58. <p>
  59. [page:String url] — the path or URL to the file. This can also be a
  60. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  61. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
  62. [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 />
  63. [page:Function onError] — Will be called when load errors.<br /><br />
  64. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  65. </p>
  66. <h3>[method:Font parse]( [param:Object json] )</h3>
  67. <p>
  68. [page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
  69. Parse a <em>JSON</em> structure and return a [page:Font].
  70. </p>
  71. <h3>[method:FontLoader setPath]( [param:String path] )</h3>
  72. <p>
  73. Set the base path or URL from which to load fonts. This can be useful if
  74. you are loading many fonts from the same directory.
  75. </p>
  76. <h2>Source</h2>
  77. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  78. </body>
  79. </html>