FontLoader.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. [page:Loader] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. Class for loading a font in JSON format. Returns a [page:Font Font], which is an
  15. array of [page:Shape Shapes] representing the font.
  16. This uses the [page:FileLoader] internally for loading files. <br /><br />
  17. You can convert fonts online using [link:https://gero3.github.io/facetype.js/ facetype.js]
  18. </p>
  19. <h2>Code Example</h2>
  20. <code>
  21. var loader = new THREE.FontLoader();
  22. var font = loader.load(
  23. // resource URL
  24. 'fonts/helvetiker_bold.typeface.json',
  25. // onLoad callback
  26. function ( font ) {
  27. // do something with the font
  28. scene.add( font );
  29. },
  30. // onProgress callback
  31. function ( xhr ) {
  32. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  33. },
  34. // onError callback
  35. function ( err ) {
  36. console.log( 'An error happened' );
  37. }
  38. );
  39. </code>
  40. <h2>Examples</h2>
  41. <p>
  42. [example:webgl_geometry_text_shapes geometry / text / shapes ]<br/>
  43. [example:webgl_geometry_text geometry / text ]
  44. </p>
  45. <h2>Constructor</h2>
  46. <h3>[name]( [param:LoadingManager manager] )</h3>
  47. <p>
  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. </p>
  51. <h2>Properties</h2>
  52. <p>See the base [page:Loader] class for common properties.</p>
  53. <h2>Methods</h2>
  54. <p>See the base [page:Loader] class for common methods.</p>
  55. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  56. <p>
  57. [page:String url] — the path or URL to the file. This can also be a
  58. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  59. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Font font].<br />
  60. [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 />
  61. [page:Function onError] — Will be called when load errors.<br /><br />
  62. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  63. </p>
  64. <h3>[method:Font parse]( [param:Object json] )</h3>
  65. <p>
  66. [page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
  67. Parse a <em>JSON</em> structure and return a [page:Font].
  68. </p>
  69. <h2>Source</h2>
  70. <p>
  71. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  72. </p>
  73. </body>
  74. </html>