FontLoader.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. <div 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. </div>
  18. <h2>Examples</h2>
  19. <div>
  20. [example:webgl_geometry_text_shapes geometry / text / shapes ]<br/>
  21. [example:webgl_geometry_text geometry / text ]<br />
  22. [example:webgl_geometry_text_earcut geometry / text / earcut]<br />
  23. [example:webgl_geometry_text_pnltri geometry / text / pnltri]<br />
  24. </div>
  25. <code>
  26. var loader = new THREE.FontLoader();
  27. var font = loader.load(
  28. // resource URL
  29. 'fonts/helvetiker_bold.typeface.json'
  30. // Function when resource is loaded
  31. function ( font ) {
  32. // do something with the font
  33. scene.add( font );
  34. },
  35. // Function called when download progresses
  36. function ( xhr ) {
  37. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  38. },
  39. // Function called when download errors
  40. function ( xhr ) {
  41. console.log( 'An error happened' );
  42. }
  43. );
  44. </code>
  45. <h2>Constructor</h2>
  46. <h3>[name]( [page:LoadingManager manager] )</h3>
  47. <div>
  48. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  49. Creates a new [name].
  50. </div>
  51. <h2>Properties</h2>
  52. <h3>[property:LoadingManager manager]</h3>
  53. <div>
  54. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  55. </div>
  56. <h3>[property:String path]</h3>
  57. <div>The base path from which fonts will be loaded. See [page:.setPath]. Default is *undefined*.</div>
  58. <h2>Methods</h2>
  59. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  60. <div>
  61. [page:String url] — the path or URL to the file. This can also be a
  62. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  63. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
  64. [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 />
  65. [page:Function onError] — Will be called when load errors.<br /><br />
  66. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  67. </div>
  68. <h3>[method:Font parse]( [page:Object json] )</h3>
  69. <div>
  70. [page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
  71. Parse a <em>JSON</em> structure and return a [page:Font].
  72. </div>
  73. <h3>[method:FontLoader setPath]( [page:String path] )</h3>
  74. <div>
  75. Set the base path or URL from which to load fonts. This can be useful if
  76. you are loading many fonts from the same directory.
  77. </div>
  78. <h2>Source</h2>
  79. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  80. </body>
  81. </html>