FontLoader.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.<br /><br />
  15. You can convert fonts online using [link:https://gero3.github.io/facetype.js/ facetype.js]
  16. </div>
  17. <h2>Examples</h2>
  18. <div>
  19. [example:webgl_geometry_text geometry / text ]<br />
  20. [example:webgl_geometry_text_earcut geometry / text / earcut]<br />
  21. [example:webgl_geometry_text_pnltri geometry / text / pnltri]<br />
  22. </div>
  23. <code>
  24. var loader = new THREE.FontLoader();
  25. var font = loader.load(
  26. // resource URL
  27. 'fonts/helvetiker_bold.typeface.json'
  28. // Function when resource is loaded
  29. function ( font ) {
  30. // do something with the font
  31. scene.add( font );
  32. },
  33. // Function called when download progresses
  34. function ( xhr ) {
  35. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  36. },
  37. // Function called when download errors
  38. function ( xhr ) {
  39. console.log( 'An error happened' );
  40. }
  41. );
  42. </code>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [page:LoadingManager manager] )</h3>
  45. <div>
  46. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  47. </div>
  48. <div>
  49. Creates a new [name].
  50. </div>
  51. <h2>Methods</h2>
  52. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  53. <div>
  54. [page:String url] — required<br />
  55. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
  56. [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 />
  57. [page:Function onError] — Will be called when load errors.<br />
  58. </div>
  59. <div>
  60. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  61. </div>
  62. <h2>Source</h2>
  63. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  64. </body>
  65. </html>