FontLoader.html 2.9 KB

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