SceneUtils.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html lang="en">
  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">A class containing useful utility functions for scene manipulation.</p>
  12. <h2>Methods</h2>
  13. <h3>[method:Group createMeshesFromInstancedMesh]( [param:InstancedMesh instancedMesh] )</h3>
  14. <p>
  15. instancedMesh -- The instanced mesh.
  16. </p>
  17. <p>
  18. Creates a new group object that contains a new mesh for each instance of the given instanced mesh.
  19. </p>
  20. <h3>[method:Group createMeshesFromMultiMaterialMesh]( [param:Mesh mesh] )</h3>
  21. <p>
  22. mesh -- A mesh with multiple materials.
  23. </p>
  24. <p>
  25. Converts the given multi-material mesh into an instance of [page:Group] holding for each material a separate mesh.
  26. </p>
  27. <h3>[method:Group createMultiMaterialObject]( [param:BufferGeometry geometry], [param:Array materials] )</h3>
  28. <p>
  29. geometry -- The geometry for the set of materials. <br />
  30. materials -- The materials for the object.
  31. </p>
  32. <p>
  33. Creates a new Group that contains a new mesh for each material defined in materials. Beware that this is not the same as an array of materials which defines multiple materials for 1 mesh.<br />
  34. This is mostly useful for objects that need both a material and a wireframe implementation.
  35. </p>
  36. <h3>[method:T reduceVertices]( [param:Object3D object], [param:function func], [param:T initialValue] )</h3>
  37. <p>
  38. object -- The object to traverse (uses [page:Object3D.traverseVisible traverseVisible] internally). <br />
  39. func -- The binary function applied for the reduction. Must have the signature: (value: T, vertex: Vector3): T. <br />
  40. initialValue -- The value to initialize the reduction with. This is required
  41. as it also sets the reduction type, which is not required to be Vector3.
  42. </p>
  43. <p>
  44. Akin to Array.prototype.reduce(), but operating on the vertices of all the
  45. visible descendant objects, in world space. Additionally, it can operate as a
  46. transform-reduce, returning a different type T than the Vector3 input. This
  47. can be useful for e.g. fitting a viewing frustum to the scene.
  48. </p>
  49. <h3>[method:undefined sortInstancedMesh]( [param:InstancedMesh mesh], [param:Function compareFn] )</h3>
  50. <p>
  51. mesh -- InstancedMesh in which instances will be sorted. <br />
  52. compareFn -- Comparator function defining the sort order.
  53. </p>
  54. <p>
  55. Sorts the instances within an [page:InstancedMesh], according to a user-defined
  56. callback. The callback will be provided with two arguments, <i>indexA</i>
  57. and <i>indexB</i>, and must return a numerical value. See
  58. [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description Array.prototype.sort]
  59. for more information on sorting callbacks and their return values.
  60. </p>
  61. <p>
  62. Because of the high performance cost, three.js does not sort
  63. [page:InstancedMesh] instances automatically. Manually sorting may be
  64. helpful to improve display of alpha blended materials (back to front),
  65. and to reduce overdraw in opaque materials (front to back).
  66. </p>
  67. <h2>Source</h2>
  68. <p>
  69. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SceneUtils.js examples/jsm/utils/SceneUtils.js]
  70. </p>
  71. </body>
  72. </html>