SceneUtils.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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>场景工具([name])</h1>
  11. <p class="desc">一个用于操控场景的实用类。</p>
  12. <h2>导入</h2>
  13. <p>
  14. [name] 是一个附加组件,必须显式导入。
  15. See [link:#manual/introduction/Installation Installation / Addons].
  16. </p>
  17. <code>
  18. import * as SceneUtils from 'three/addons/utils/SceneUtils.js';
  19. </code>
  20. <h2>方法</h2>
  21. <h3>[method:Group createMeshesFromInstancedMesh]( [param:InstancedMesh instancedMesh] )</h3>
  22. <p>
  23. instancedMesh -- 实例化网格。
  24. </p>
  25. <p>
  26. 为给定的实例化网格的每个实例,创建一个包含新网格的新物体组(Object Group)。
  27. </p>
  28. <h3>[method:Group createMeshesFromMultiMaterialMesh]( [param:Mesh mesh] )</h3>
  29. <p>
  30. mesh -- A mesh with multiple materials.
  31. </p>
  32. <p>
  33. Converts the given multi-material mesh into an instance of [page:Group] holding for each material a separate mesh.
  34. </p>
  35. <h3>[method:Group createMultiMaterialObject]( [param:BufferGeometry geometry], [param:Array materials] )</h3>
  36. <p>
  37. geometry -- 材料集的几何形状。 <br />
  38. materials -- 为物体准备的材料。
  39. </p>
  40. <p>
  41. 创建一个新组,囊括了在材质中定义的每种材质的新网格。请注意,这和为一个网格定义多种材质的材质数组不同。<br />
  42. 该方法对于同时需要材质和线框绘制的物体非常有用。
  43. </p>
  44. <h3>[method:undefined sortInstancedMesh]( [param:InstancedMesh mesh], [param:Function compareFn] )</h3>
  45. <p>
  46. mesh -- InstancedMesh in which instances will be sorted. <br />
  47. compareFn -- Comparator function defining the sort order.
  48. </p>
  49. <p>
  50. Sorts the instances within an [page:InstancedMesh], according to a user-defined
  51. callback. The callback will be provided with two arguments, <i>indexA</i>
  52. and <i>indexB</i>, and must return a numerical value. See
  53. [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description Array.prototype.sort]
  54. for more information on sorting callbacks and their return values.
  55. </p>
  56. <p>
  57. Because of the high performance cost, three.js does not sort
  58. [page:InstancedMesh] instances automatically. Manually sorting may be
  59. helpful to improve display of alpha blended materials (back to front),
  60. and to reduce overdraw in opaque materials (front to back).
  61. </p>
  62. <h3>[method:Generator traverseGenerator]( [param:Object3D object] )</h3>
  63. <p>
  64. object -- The 3D object to traverse.
  65. </p>
  66. <p>
  67. A generator based version of [page:Object3D.traverse]().
  68. </p>
  69. <h3>[method:Generator traverseVisibleGenerator]( [param:Object3D object] )</h3>
  70. <p>
  71. object -- The 3D object to traverse.
  72. </p>
  73. <p>
  74. A generator based version of [page:Object3D.traverseVisible]().
  75. </p>
  76. <h3>[method:Generator traverseAncestorsGenerator]( [param:Object3D object] )</h3>
  77. <p>
  78. object -- The 3D object to traverse.
  79. </p>
  80. <p>
  81. A generator based version of [page:Object3D.traverseAncestors]().
  82. </p>
  83. <h2>源代码</h2>
  84. <p>
  85. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SceneUtils.js examples/jsm/utils/SceneUtils.js]
  86. </p>
  87. </body>
  88. </html>