GLTFExporter.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>GLTF导出器([name])</h1>
  11. <p class="desc">
  12. 一个用于 glTF 2.0 的导出器。
  13. <br /><br />
  14. [link:https://www.khronos.org/gltf glTF] (GL Transmission Format) 是一个用于高效传输和加载3D内容的
  15. [link:https://github.com/KhronosGroup/glTF/tree/master/specification/2.0 开放格式规范]。
  16. 资源可以以 JSON (.gltf) 或二进制 (.glb) 格式提供。外部文件存储纹理 (.jpg, .png) 和额外的二进制数据 (.bin)。一个 glTF
  17. 资产可以包含一个或多个场景,包括网格、材质、纹理、蒙皮、骨骼、变形目标、动画、灯光和/或相机。
  18. </p>
  19. <h2>导入</h2>
  20. <p>
  21. [name] 是一个附加组件,必须显式导入。请参阅 [link:#manual/introduction/Installation Installation / Addons]。
  22. </p>
  23. <code>
  24. import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
  25. </code>
  26. <h2>扩展</h2>
  27. <p>
  28. [name] 支持以下 [link:https://github.com/KhronosGroup/glTF/tree/master/extensions/ glTF 2.0 扩展]:
  29. </p>
  30. <ul>
  31. <li>KHR_lights_punctual</li>
  32. <li>KHR_materials_clearcoat</li>
  33. <li>KHR_materials_dispersion</li>
  34. <li>KHR_materials_emissive_strength</li>
  35. <li>KHR_materials_ior</li>
  36. <li>KHR_materials_iridescence</li>
  37. <li>KHR_materials_specular</li>
  38. <li>KHR_materials_sheen</li>
  39. <li>KHR_materials_transmission</li>
  40. <li>KHR_materials_unlit</li>
  41. <li>KHR_materials_volume</li>
  42. <li>KHR_mesh_quantization</li>
  43. <li>KHR_texture_transform</li>
  44. <li>EXT_materials_bump</li>
  45. <li>EXT_mesh_gpu_instancing</li>
  46. </ul>
  47. <p>
  48. 以下 glTF 2.0 扩展由外部用户插件支持
  49. </p>
  50. <ul>
  51. <li>[link:https://github.com/takahirox/three-gltf-extensions KHR_materials_variants]</li>
  52. </ul>
  53. <h2>代码示例</h2>
  54. <code>
  55. // Instantiate a exporter
  56. const exporter = new GLTFExporter();
  57. // Parse the input and generate the glTF output
  58. exporter.parse(
  59. scene,
  60. // called when the gltf has been generated
  61. function ( gltf ) {
  62. console.log( gltf );
  63. downloadJSON( gltf );
  64. },
  65. // called when there is an error in the generation
  66. function ( error ) {
  67. console.log( 'An error happened' );
  68. },
  69. options
  70. );
  71. </code>
  72. <h2>例子</h2>
  73. <p>
  74. [example:misc_exporter_gltf]
  75. </p>
  76. <h2>构造函数</h2>
  77. <h3>[name]()</h3>
  78. <p>
  79. </p>
  80. <p>
  81. 创建一个新的 [name] 实例。
  82. </p>
  83. <h2>方法</h2>
  84. <h3>[method:undefined parse]( [param:Object3D input], [param:Function onCompleted], [param:Function onError],
  85. [param:Object options] )</h3>
  86. <p>
  87. [page:Object input] — 要导出的场景或对象。有效选项:<br />
  88. <ul>
  89. <li>
  90. 导出场景
  91. <code>
  92. exporter.parse( scene1, ... )
  93. exporter.parse( [ scene1, scene2 ], ... )
  94. </code>
  95. </li>
  96. <li>
  97. 导出对象(它将创建一个新场景来保存所有对象)
  98. <code>
  99. exporter.parse( object1, ... )
  100. exporter.parse( [ object1, object2 ], ... )
  101. </code>
  102. </li>
  103. <li>
  104. 混合场景和对象(它将像平常一样导出场景,但会创建一个新场景来保存所有单个对象)。
  105. <code>
  106. exporter.parse( [ scene1, object1, object2, scene2 ], ... )
  107. </code>
  108. </li>
  109. </ul>
  110. [page:Function onCompleted] — 导出完成时将被调用。参数将是生成的 glTF JSON 或二进制 ArrayBuffer。<br />
  111. [page:Function onError] — 如果在 gltf 生成过程中出现任何错误,将被调用。<br />
  112. [page:Options options] — 导出选项<br />
  113. <ul>
  114. <li>trs - bool. 导出每个节点的位置、旋转和缩放而不是矩阵。默认为 false。</li>
  115. <li>onlyVisible - bool. 仅导出可见对象。默认为 true。</li>
  116. <li>binary - bool. 以二进制 (.glb) 格式导出,返回 ArrayBuffer。默认为 false。</li>
  117. <li>maxTextureSize - int. 将图像最大尺寸(宽度和高度)限制为给定值。默认为无穷大。</li>
  118. <li>animations - Array<[page:AnimationClip AnimationClip]>. 要包含在导出中的动画列表。</li>
  119. <li>includeCustomExtensions - bool. 导出在对象属性上定义的自定义 glTF 扩展(`userData.gltfExtensions`)。默认为 false。</li>
  120. </ul>
  121. </p>
  122. <p>
  123. 从输入(场景或对象)生成一个 .gltf(JSON)或 .glb(二进制)输出。
  124. </p>
  125. <h2>源代码</h2>
  126. <p>
  127. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/GLTFExporter.js examples/jsm/exporters/GLTFExporter.js]
  128. </p>
  129. </body>
  130. </html>
粤ICP备19079148号