GLTFExporter.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. </ul>
  45. <p>
  46. 以下 glTF 2.0 扩展由外部用户插件支持
  47. </p>
  48. <ul>
  49. <li>[link:https://github.com/takahirox/three-gltf-extensions KHR_materials_variants]</li>
  50. </ul>
  51. <h2>代码示例</h2>
  52. <code>
  53. // Instantiate a exporter
  54. const exporter = new GLTFExporter();
  55. // Parse the input and generate the glTF output
  56. exporter.parse(
  57. scene,
  58. // called when the gltf has been generated
  59. function ( gltf ) {
  60. console.log( gltf );
  61. downloadJSON( gltf );
  62. },
  63. // called when there is an error in the generation
  64. function ( error ) {
  65. console.log( 'An error happened' );
  66. },
  67. options
  68. );
  69. </code>
  70. <h2>例子</h2>
  71. <p>
  72. [example:misc_exporter_gltf]
  73. </p>
  74. <h2>构造函数</h2>
  75. <h3>[name]()</h3>
  76. <p>
  77. </p>
  78. <p>
  79. 创建一个新的 [name] 实例。
  80. </p>
  81. <h2>方法</h2>
  82. <h3>[method:undefined parse]( [param:Object3D input], [param:Function onCompleted], [param:Function onError],
  83. [param:Object options] )</h3>
  84. <p>
  85. [page:Object input] — 要导出的场景或对象。有效选项:<br />
  86. <ul>
  87. <li>
  88. 导出场景
  89. <code>
  90. exporter.parse( scene1, ... )
  91. exporter.parse( [ scene1, scene2 ], ... )
  92. </code>
  93. </li>
  94. <li>
  95. 导出对象(它将创建一个新场景来保存所有对象)
  96. <code>
  97. exporter.parse( object1, ... )
  98. exporter.parse( [ object1, object2 ], ... )
  99. </code>
  100. </li>
  101. <li>
  102. 混合场景和对象(它将像平常一样导出场景,但会创建一个新场景来保存所有单个对象)。
  103. <code>
  104. exporter.parse( [ scene1, object1, object2, scene2 ], ... )
  105. </code>
  106. </li>
  107. </ul>
  108. [page:Function onCompleted] — 导出完成时将被调用。参数将是生成的 glTF JSON 或二进制 ArrayBuffer。<br />
  109. [page:Function onError] — 如果在 gltf 生成过程中出现任何错误,将被调用。<br />
  110. [page:Options options] — 导出选项<br />
  111. <ul>
  112. <li>trs - bool. 导出每个节点的位置、旋转和缩放而不是矩阵。默认为 false。</li>
  113. <li>onlyVisible - bool. 仅导出可见对象。默认为 true。</li>
  114. <li>binary - bool. 以二进制 (.glb) 格式导出,返回 ArrayBuffer。默认为 false。</li>
  115. <li>maxTextureSize - int. 将图像最大尺寸(宽度和高度)限制为给定值。默认为无穷大。</li>
  116. <li>animations - Array<[page:AnimationClip AnimationClip]>. 要包含在导出中的动画列表。</li>
  117. <li>includeCustomExtensions - bool. 导出在对象属性上定义的自定义 glTF 扩展(`userData.gltfExtensions`)。默认为 false。</li>
  118. </ul>
  119. </p>
  120. <p>
  121. 从输入(场景或对象)生成一个 .gltf(JSON)或 .glb(二进制)输出。
  122. </p>
  123. <h2>源代码</h2>
  124. <p>
  125. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/GLTFExporter.js examples/jsm/exporters/GLTFExporter.js]
  126. </p>
  127. </body>
  128. </html>