Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Vector3

Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z), which can be used to represent a number of things, such as: A point in 3D space. A direction and length in 3D space. In three.js the length will always be the Euclidean distancee (straight-line distance) from (0, 0, 0) to (x, y, z) and the direction is also measured from (0, 0, 0) towards (x, y, z). Any arbitrary ordered triplet of numbers. There are other things a 3D vector can be used to represent, such as momentum vectors and so on, however these are the most common uses in three.js. Iterating through a Vector3 instance will yield its components (x, y, z) in the corresponding order. See the ngx3js docs page for details.

Examples

css3d / molecules | css3d / orthographic | games / fps | misc / animation / keys | physics / ammo / break

Code Example

const a = new THREE.Vector3( 0, 1, 0 );
// no arguments; will be initialised to (0, 0, 0)
const b = new THREE.Vector3( );
const d = a.distanceTo( b );

Hierarchy

Index

Constructors

constructor

Properties

Readonly isVector3

isVector3: true

x

x: number

the x value of this vector. Default is 0.

default

0

y

y: number

the y value of this vector. Default is 0.

default

0

z

z: number

the z value of this vector. Default is 0.

default

0

Methods

add

addScalar

addScaledVector

addVectors

angleTo

applyAxisAngle

applyEuler

applyMatrix3

applyMatrix4

applyNormalMatrix

applyQuaternion

ceil

clamp

  • If this vector's x, y or z value is less than the min vector's x, y or z value, it is replaced by the corresponding value.

    Parameters

    • min: I3JS.Vector3

      The minimum .x, .y and .z values.

    • max: I3JS.Vector3

      The maximum .x, .y and .z values in the desired range If this vector's x, y or z value is greater than the max vector's x, y or z value, it is replaced by the corresponding value.

    Returns I3JS.Vector3

clampLength

  • If this vector's length is less than the min value, the vector will be scaled up so its length is the min value.

    Parameters

    • min: number

      The minimum value the length will be clamped to

    • max: number

      The maximum value the length will be clamped to If this vector's length is greater than the max value, the vector will be scaled down so its length is the max value.

    Returns I3JS.Vector3

clampScalar

  • If this vector's x, y or z values are less than the min value, they are replaced by the min value.

    Parameters

    • min: number

      The minimum value the components will be clamped to

    • max: number

      The maximum value the components will be clamped to If this vector's x, y or z values are greater than the max value, they are replaced by the max value.

    Returns I3JS.Vector3

clone

copy

cross

crossVectors

distanceTo

distanceToSquared

divide

divideScalar

dot

equals

floor

fromArray

  • fromArray(array: ArrayLike<number> | number[], offset?: number): I3JS.Vector3
  • Sets this vector's .x value to be array[ offset + 0 ], .y value to be array[ offset + 1 ] and .z value to be array[ offset + 2 ].

    Parameters

    • array: ArrayLike<number> | number[]

      The source array.

    • Optional offset: number

      ( optional) offset into the array. Default is 0.

    Returns I3JS.Vector3

fromBufferAttribute

getComponent

  • getComponent(index: number): number

length

  • length(): number

lengthSq

  • lengthSq(): number

lerp

lerpVectors

manhattanDistanceTo

manhattanLength

  • manhattanLength(): number

max

min

multiply

multiplyScalar

multiplyVectors

negate

normalize

project

projectOnPlane

projectOnVector

random

randomDirection

reflect

round

roundToZero

set

setComponent

  • setComponent(index: number, value: number): I3JS.Vector3

setFromCylindrical

setFromCylindricalCoords

  • setFromCylindricalCoords(radius: number, theta: number, y: number): I3JS.Vector3

setFromMatrix3Column

setFromMatrixColumn

setFromMatrixPosition

setFromMatrixScale

setFromSpherical

setFromSphericalCoords

  • setFromSphericalCoords(r: number, phi: number, theta: number): I3JS.Vector3

setLength

setScalar

setX

setY

setZ

sub

subScalar

subVectors

toArray

  • toArray(array?: ArrayLike<number> | number[], offset?: number): number[]
  • Parameters

    • Optional array: ArrayLike<number> | number[]

      array to store this vector to. If this is not provided a new array will be created.

    • Optional offset: number

      optional offset into the array.

    Returns number[]

    Returns an array [x, y, z], or copies x, y and z into the provided array.

transformDirection

unproject

Generated using TypeDoc