FontLoader.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Loader] &rarr;
  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 Shapes] 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>Code Example</h2>
  19. <code>
  20. const loader = new THREE.FontLoader();
  21. const font = loader.load(
  22. // resource URL
  23. 'fonts/helvetiker_bold.typeface.json',
  24. // onLoad callback
  25. function ( font ) {
  26. // do something with the font
  27. scene.add( font );
  28. },
  29. // onProgress callback
  30. function ( xhr ) {
  31. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  32. },
  33. // onError callback
  34. function ( err ) {
  35. console.log( 'An error happened' );
  36. }
  37. );
  38. </code>
  39. <h2>Examples</h2>
  40. <p>
  41. [example:webgl_geometry_text_shapes geometry / text / shapes ]<br/>
  42. [example:webgl_geometry_text geometry / text ]
  43. </p>
  44. <h2>Constructor</h2>
  45. <h3>[name]( [param:LoadingManager manager] )</h3>
  46. <p>
  47. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  48. Creates a new [name].
  49. </p>
  50. <h2>Properties</h2>
  51. <p>See the base [page:Loader] class for common properties.</p>
  52. <h2>Methods</h2>
  53. <p>See the base [page:Loader] class for common methods.</p>
  54. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  55. <p>
  56. [page:String url] — the path or URL to the file. This can also be a
  57. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  58. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Font font].<br />
  59. [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 />
  60. [page:Function onError] — Will be called when load errors.<br /><br />
  61. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  62. </p>
  63. <h3>[method:Font parse]( [param:Object json] )</h3>
  64. <p>
  65. [page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
  66. Parse a <em>JSON</em> structure and return a [page:Font].
  67. </p>
  68. <h2>Source</h2>
  69. <p>
  70. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  71. </p>
  72. </body>
  73. </html>