Module: utils

A collection of utilities.
Source:

Methods

(static) getCentroid(positions, target)

Sets the target to the centroid position between all passed in positions.
Parameters:
Name Type Description
positions Array.<THREE.Vector3>
target THREE.Vector3
Source:

(static) getWorldDistance(obj1, obj2) → {number}

Returns the distance between two objects.
Parameters:
Name Type Description
obj1 THREE.Object3D
obj2 THREE.Object3D
Source:
Returns:
Type
number

(static) getWorldPosition(object, target)

Returns the world position of object and sets it on target.
Parameters:
Name Type Description
object THREE.Object3D
target THREE.Vector3
Source:

(static) setQuaternionFromDirection(direction, up, target)

Takes a direction vector and an up vector and sets `target` quaternion to the rotation. Similar to THREE.Matrix4's `lookAt` function, except rather than taking two Vector3 points, we've already calculaeld the direction earlier so skip the first half.
Parameters:
Name Type Description
direction THREE.Vector3
up THREE.Vector3
target THREE.Quaternion
Source:

(static) transformPoint(vector, matrix, target)

Implementation of Unity's Transform.transformPoint, which is similar to three's Vector3.transformDirection, except we want to take scale into account, as we're not transforming a direction. Function taken from BabylonJS. From BabylonJS's `Vector3.transformCoordinates`: Sets the passed vector coordinates with the result of the transformation by the passed matrix of the passed vector. This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
Parameters:
Name Type Description
vector THREE.Vector3
matrix THREE.Matrix4
target THREE.Vector3
Source:
See: