[name]

A class containing useful utility functions for scene manipulation.

Methods

[method:Group createMeshesFromInstancedMesh]( [param:InstancedMesh instancedMesh] )

instancedMesh -- The instanced mesh.

Creates a new group object that contains a new mesh for each instance of the given instanced mesh.

[method:Group createMeshesFromMultiMaterialMesh]( [param:Mesh mesh] )

mesh -- A mesh with multiple materials.

Converts the given multi-material mesh into an instance of [page:Group] holding for each material a separate mesh.

[method:Group createMultiMaterialObject]( [param:BufferGeometry geometry], [param:Array materials] )

geometry -- The geometry for the set of materials.
materials -- The materials for the object.

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.
This is mostly useful for objects that need both a material and a wireframe implementation.

[method:undefined sortInstancedMesh]( [param:InstancedMesh mesh], [param:Function compareFn] )

mesh -- InstancedMesh in which instances will be sorted.
compareFn -- Comparator function defining the sort order.

Sorts the instances within an [page:InstancedMesh], according to a user-defined callback. The callback will be provided with two arguments, indexA and indexB, and must return a numerical value. See [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description Array.prototype.sort] for more information on sorting callbacks and their return values.

Because of the high performance cost, three.js does not sort [page:InstancedMesh] instances automatically. Manually sorting may be helpful to improve display of alpha blended materials (back to front), and to reduce overdraw in opaque materials (front to back).

Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SceneUtils.js examples/jsm/utils/SceneUtils.js]