1.0.0 • Published 4 years ago

jonlo-threejs-utils v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

jonlo-threejs-utils

Contains utils to work with threejs.

  • Transform
  • Scene
  • Cartesian coordinate

Installation

npm install jonlo-threejs-utils

Functions

Classes

Functions

SceneUtils

Scene utils

Kind: global class

center()

centers the camera over all the scene3d objects

Kind: global function Example

SceneUtils.center(scene, camera, controls, 0, 1, 1);

Classes

Functions

TransformUtils

Transform utils

Kind: global class

rotateObject3dOnAxis(Object3d, Vector3, Number)

Rotates a Ojbect3d over a given axis

Kind: global function

ParamDescription
Object3dobject3d
Vector3axis
Numberradians

Example

TransformUtils.rotateObject3dOnAxis(object3d, new Vector3(1, 0, 0), Math.degToRad(90))

rotateObject3dAroundPivotOnAxis(Object3d, Matrix4, Vector3, Number)

Rotates a Ojbect3d around a pivot matrix over a given axis

Kind: global function

ParamDescription
Object3dobject3d
Matrix4pivotMatrix
Vector3axis
Numberradians

Example

TransformUtils.rotateObject3dAroundPivotOnAxis(object3d, pivotMatrix, new Vector3(1, 0, 0), Math.degToRad(90))

createPivotMatrix(Vector3, Quaternion, Vector3)

Creates a pivot matrix

Kind: global function

ParamDescription
Vector3position
Quaternionrotation
Vector3scale

Example

TransformUtils.createPivotMatrix(position, rotation, scale)

Classes

Functions

CartesianCoordinatesUtils

Cartesian coordinates utils

Kind: global class

getPointInBetweenByPerc(Vector3, Vector3, Number)

Get the point between two points given a percentage distance

Kind: global function

ParamDescription
Vector3startPoint
Vector3endPoint
Numberpercentage

Example

CartesianCoordinatesUtils.getPointInBetweenByPerc(new Vector3(1,0,0),new Vector3(2,0,0),50)

getDirBetweenPoints(Vector3, Vector3)

Get the direction vector b etween two points

Kind: global function

ParamDescription
Vector3startPoint
Vector3endPoint

Example

CartesianCoordinatesUtils.getDirBetweenPoints(new Vector3(1,0,0),new Vector3(2,0,0))

angleBetweenVectors(Vector3, Vector3)

Get the angle between two vectors

Kind: global function

ParamDescription
Vector3v2
Vector3v1

Example

CartesianCoordinatesUtils.angleBetweenVectors(new Vector3(1,0,0),new Vector3(2,0,0))