FontLoader.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_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. <h3>[property:String path]</h3>
  56. <div>The base path from which fonts will be loaded. See [page:.setPath]. Default is *undefined*.</div>
  57. <h2>Methods</h2>
  58. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  59. <div>
  60. [page:String url] — the path or URL to the file. This can also be a
  61. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  62. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
  63. [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 />
  64. [page:Function onError] — Will be called when load errors.<br /><br />
  65. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  66. </div>
  67. <h3>[method:Font parse]( [page:Object json] )</h3>
  68. <div>
  69. [page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
  70. Parse a <em>JSON</em> structure and return a [page:Font].
  71. </div>
  72. <h3>[method:FontLoader setPath]( [page:String path] )</h3>
  73. <div>
  74. Set the base path or URL from which to load fonts. This can be useful if
  75. you are loading many fonts from the same directory.
  76. </div>
  77. <h2>Source</h2>
  78. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  79. </body>
  80. </html>