FontLoader.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. <h2>Methods</h2>
  57. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  58. <div>
  59. [page:String url] — the path or URL to the file. This can also be a
  60. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  61. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
  62. [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 />
  63. [page:Function onError] — Will be called when load errors.<br /><br />
  64. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  65. </div>
  66. <h3>[method:Font parse]( [page:Object json] )</h3>
  67. <div>
  68. [page:Object json] — The <em>JSON</em> structure to parse.<br /><br />
  69. Parse a <em>JSON</em> structure and return a [page:Font].
  70. </div>
  71. <h2>Source</h2>
  72. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  73. </body>
  74. </html>