SceneUtils

A class containing useful utility functions for scene manipulation.

Methods

.assignDefaultControls(camera : Camera, sceneBox : Box3)

camera — default scene camera.
sceneBox — bounding box which includes all objects located on the scene.

Assigns default control settings on the camera based on the given sceneBox param.

.calcSceneBox(scene : Scene) → Box3

scene — current scene.

Calculates scene bounding box.

.checkActionIsUsed(scene : Object3D, action : AnimationAction) → Boolean

scene — the scene to check if the action is used with one of the scene objects.
action — the action to check.

Checks if the given action is used with one of the scene objects, i.e. the action's target node exists on the scene.

.createDefaultCamera(sceneBox : Box3, aspect : Float) → Camera

sceneBox — scene box.
aspect — camera aspect ratio.

Creates default PerspectiveCamera which looks to the center of the scene bounding box.

.createMeshesFromMultiMaterialMesh(mesh : Mesh) → Group

mesh — a mesh with multiple materials.

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

.createMultiMaterialObject(geometry : Geometry, materials : Array) → Group

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.

.getAnimationActionByName(scope : App, animClipName : String) → AnimationAction

scope — the instance of application class.
animClipName — the name of the animation clip.

Search for animation action by its clip name.

.getMaterialByName(appInstance : App, matName : String) → Material

appInstance — application to search for the material.
matName — material name.

Find material by the given name. If not found, returns null.

.getMaterialsByName(appInstance : App, matName : String) → Material

appInstance — application to search for the materials.
matName — material name.

Find materials by the given name. If not found, returns [].

.reduceVertices(object : Object3D, func : Function, initialValue : T) → T

object — the object to traverse (uses traverseVisible internally).
func — the binary function applied for the reduction. Must have the signature: (value: T, vertex: Vector3) → T.
initialValue — the value to initialize the reduction with. This is required as it also sets the reduction type, which is not required to be Vector3.

Akin to Array.prototype.reduce(), but operating on the vertices of all the visible descendant objects, in world space. Additionally, it can operate as a transform-reduce, returning a different type T than the Vector3 input. This can be useful for e.g. fitting a viewing frustum to the scene.

Source

For more info on how to obtain the source code of this module see this page.