GLTFExporter.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. <p class="desc">
  13. An exporter for *glTF* 2.0.
  14. <br /><br />
  15. <a href="https://www.khronos.org/gltf">glTF</a> (GL Transmission Format) is an
  16. <a href="https://github.com/KhronosGroup/glTF/tree/master/specification/2.0">open format specification</a>
  17. for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf)
  18. or binary (.glb) format. External files store textures (.jpg, .png) and additional binary
  19. data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials,
  20. textures, skins, skeletons, morph targets, animations, lights, and/or cameras.
  21. </p>
  22. <h2>Extensions</h2>
  23. <p>
  24. GLTFExporter supports the following
  25. [link:https://github.com/KhronosGroup/glTF/tree/master/extensions/ glTF 2.0 extensions]:
  26. </p>
  27. <ul>
  28. <li>KHR_lights_punctual</li>
  29. <li>KHR_materials_unlit</li>
  30. <li>KHR_texture_transform</li>
  31. </ul>
  32. <h2>Example</h2>
  33. <code>
  34. // Instantiate a exporter
  35. var exporter = new THREE.GLTFExporter();
  36. // Parse the input and generate the glTF output
  37. exporter.parse( scene, function ( gltf ) {
  38. console.log( gltf );
  39. downloadJSON( gltf );
  40. }, options );
  41. </code>
  42. [example:misc_exporter_gltf]
  43. <h2>Constructor</h2>
  44. <h3>[name]()</h3>
  45. <p>
  46. </p>
  47. <p>
  48. Creates a new [name].
  49. </p>
  50. <h2>Methods</h2>
  51. <h3>[method:null parse]( [param:Object3D input], [param:Function onCompleted], [param:Object options] )</h3>
  52. <p>
  53. [page:Object input] — Scenes or objects to export. Valid options:<br />
  54. <ul>
  55. <li>
  56. Export scenes
  57. <code>
  58. exporter.parse( scene1, ... )
  59. exporter.parse( [ scene1, scene2 ], ... )
  60. </code>
  61. </li>
  62. <li>
  63. Export objects (It will create a new Scene to hold all the objects)
  64. <code>
  65. exporter.parse( object1, ... )
  66. exporter.parse( [ object1, object2 ], ... )
  67. </code>
  68. </li>
  69. <li>
  70. Mix scenes and objects (It will export the scenes as usual but it will create a new scene to hold all the single objects).
  71. <code>
  72. exporter.parse( [ scene1, object1, object2, scene2 ], ... )
  73. </code>
  74. </li>
  75. </ul>
  76. [page:Function onCompleted] — Will be called when the export completes. The argument will be the generated glTF JSON or binary ArrayBuffer.<br />
  77. [page:Options options] — Export options<br />
  78. <ul>
  79. <li>trs - bool. Export position, rotation and scale instead of matrix per node. Default is false</li>
  80. <li>onlyVisible - bool. Export only visible objects. Default is true.</li>
  81. <li>truncateDrawRange - bool. Export just the attributes within the drawRange, if defined, instead of exporting the whole array. Default is true.</li>
  82. <li>binary - bool. Export in binary (.glb) format, returning an ArrayBuffer. Default is false.</li>
  83. <li>embedImages - bool. Export with images embedded into the glTF asset. Default is true.</li>
  84. <li>maxTextureSize - int. Restricts the image maximum size (both width and height) to the given value. This option works only if embedImages is true. Default is Infinity.</li>
  85. <li>animations - Array<[page:AnimationClip AnimationClip]>. List of animations to be included in the export.</li>
  86. <li>forceIndices - bool. Generate indices for non-index geometry and export with them. Default is false.</li>
  87. <li>forcePowerOfTwoTextures - bool. Export with images resized to POT size. This option works only if embedImages is true. Default is false.</li>
  88. <li>includeCustomExtensions - bool. Export custom glTF extensions defined on an object's <em>userData.gltfExtensions</em> property. Default is false.</li>
  89. </ul>
  90. </p>
  91. <p>
  92. Generates a .gltf (JSON) or .glb (binary) output from the input (Scenes or Objects)
  93. </p>
  94. <h2>Source</h2>
  95. <p>
  96. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/GLTFExporter.js examples/js/exporters/GLTFExporter.js]
  97. </p>
  98. </body>
  99. </html>