Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Vector4

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

Examples

webgl / buffergeometry / instancing | webgl / camera / array | webgl / geometry / nurbs | webgl / postprocessing / godrays | webgl / shadowmesh

Code Example

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

Hierarchy

Index

Constructors

constructor

Properties

height

height: number

Alias for .w.

Readonly isVector4

isVector4: true

w

w: number

the w value of this vector. Default is 0.

default

0

width

width: number

Alias for .z.

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

applyMatrix4

ceil

clamp

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

    Parameters

    • min: I3JS.Vector4

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

    • max: I3JS.Vector4

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

    Returns I3JS.Vector4

clampLength

  • If this vector's length is less than the min value, it is replaced by 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, it is replaced by the max value.

    Returns I3JS.Vector4

clampScalar

  • If this vector's x, y, z or w 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, z or w values are greater than the max value, they are replaced by the max value.

    Returns I3JS.Vector4

clone

copy

Optional distanceTo

Optional distanceToSquared

  • distanceToSquared(v: Vector): number

divideScalar

dot

equals

floor

fromArray

  • fromArray(array: number[], offset?: number): I3JS.Vector4
  • Sets this vector's .x value to be array[ offset + 0 ], .y value to be array[ offset + 1 ] .z value to be array[ offset + 2 ] and .w value to be array[ offset + 3 ].

    Parameters

    • array: number[]

      The source array.

    • Optional offset: number

      offset into the array. Default is 0.

    Returns I3JS.Vector4

fromBufferAttribute

getComponent

  • getComponent(index: number): number

length

  • length(): number

lengthSq

  • lengthSq(): number

lerp

lerpVectors

manhattanLength

  • manhattanLength(): number

max

min

multiply

multiplyScalar

negate

normalize

random

round

roundToZero

set

  • set(x: number, y: number, z: number, w: number): I3JS.Vector4

setAxisAngleFromQuaternion

setAxisAngleFromRotationMatrix

setComponent

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

setLength

setScalar

setW

setX

setY

setZ

sub

subScalar

subVectors

toArray

  • toArray(array?: number[], offset?: number): number[]
  • Parameters

    • Optional array: 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, w], or copies x, y, z and w into the provided array.

Generated using TypeDoc