Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vec3

三维向量。

Hierarchy

Index

Constructors

constructor

  • newVec3(v: Vec3): Vec3
  • newVec3(x?: undefined | number, y?: undefined | number, z?: undefined | number): Vec3

Properties

x

x: number

x 分量。

y

y: number

y 分量。

z

z: number

z 分量。

Static FORWARD

FORWARD: {} = Object.freeze(new Vec3(0, 0, -1))

Type declaration

Static NEGONE

NEGONE: {} = Object.freeze(new Vec3(-1, -1, -1))

Type declaration

Static ONE

ONE: {} = Object.freeze(new Vec3(1, 1, 1))

Type declaration

Static RIGHT

RIGHT: {} = Object.freeze(new Vec3(1, 0, 0))

Type declaration

Static UNITX

UNITX: {} = Object.freeze(new Vec3(1, 0, 0))

Type declaration

Static UNITY

UNITY: {} = Object.freeze(new Vec3(0, 1, 0))

Type declaration

Static UNITZ

UNITZ: {} = Object.freeze(new Vec3(0, 0, 1))

Type declaration

Static UP

UP: {} = Object.freeze(new Vec3(0, 1, 0))

Type declaration

Static ZERO

ZERO: {} = Object.freeze(new Vec3(0, 0, 0))

Type declaration

Methods

add

  • add(other: Vec3): this

add3f

  • add3f(x: number, y: number, z: number): this
  • 向量加法。将当前向量与指定分量的向量相加

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    Returns this

clampf

  • clampf(minInclusive: Vec3, maxInclusive: Vec3): this
  • 设置当前向量的值,使其各个分量都处于指定的范围内。

    Parameters

    • minInclusive: Vec3

      Minimum value allowed

    • maxInclusive: Vec3

      Maximum value allowed

    Returns this

    this

clone

cross

  • cross(other: Vec3): this

divide

  • divide(other: Vec3): this
  • 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。

    Parameters

    • other: Vec3

      specified vector

    Returns this

divide3f

  • divide3f(x: number, y: number, z: number): this
  • 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    Returns this

dot

  • dot(other: Vec3): number
  • 向量点乘。

    Parameters

    • other: Vec3

      specified vector

    Returns number

    The result of calculates the dot product with another vector

equals

  • equals(other: Vec3, epsilon?: number): boolean
  • 判断当前向量是否在误差范围内与指定向量相等。

    Parameters

    • other: Vec3

      Specified vector

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

equals3f

  • equals3f(x: number, y: number, z: number, epsilon?: number): boolean
  • 判断当前向量是否在误差范围内与指定分量的向量相等。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

length

  • length(): number

lengthSqr

  • lengthSqr(): number

lerp

  • lerp(to: Vec3, ratio: number): this
  • 根据指定的插值比率,从当前向量到目标向量之间做插值。

    Parameters

    • to: Vec3

      Target vector

    • ratio: number

      The interpolation coefficient.The range is [0,1].

    Returns this

multiply

  • multiply(other: Vec3): this
  • 向量乘法。将当前向量乘以与指定向量的结果赋值给当前向量。

    Parameters

    • other: Vec3

      specified vector

    Returns this

multiply3f

  • multiply3f(x: number, y: number, z: number): this
  • 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    Returns this

multiplyScalar

  • multiplyScalar(scalar: number): this
  • 向量数乘。将当前向量数乘指定标量

    Parameters

    • scalar: number

      scalar number

    Returns this

negative

  • negative(): this

normalize

  • normalize(): this

set

  • set(other: Vec3): any
  • set(x?: undefined | number, y?: undefined | number, z?: undefined | number): any
  • 设置当前向量使其与指定向量相等。

    Parameters

    • other: Vec3

      Specified vector

    Returns any

    this

  • 设置当前向量的具体分量值。

    Parameters

    • Optional x: undefined | number

      x value

    • Optional y: undefined | number

      y value

    • Optional z: undefined | number

      z value

    Returns any

    this

strictEquals

  • strictEquals(other: Vec3): boolean
  • 判断当前向量是否与指定向量相等。

    Parameters

    • other: Vec3

      specified vector

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

strictEquals3f

  • strictEquals3f(x: number, y: number, z: number): boolean
  • 判断当前向量是否与指定分量的向量相等。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

subtract

  • subtract(other: Vec3): this

subtract3f

  • subtract3f(x: number, y: number, z: number): this
  • 向量减法。将当前向量减去指定分量的向量

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    Returns this

toString

  • toString(): string

transformMat4

  • transformMat4(matrix: Mat4): this
  • 将当前向量视为 w 分量为 1 的四维向量,应用四维矩阵变换到当前矩阵

    Parameters

    • matrix: Mat4

      matrix to transform with

    Returns this

Static add

Static angle

Static ceil

Static clone

  • clone<Out>(a: Out): Vec3

Static copy

  • copy<Out, Vec3Like>(out: Out, a: Vec3Like): Out

Static cross

Static distance

Static divide

Static dot

Static equals

Static floor

Static fromArray

  • fromArray<Out>(out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out
  • 数组转向量

    Type parameters

    Parameters

    • out: Out
    • arr: IWritableArrayLike<number>
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static invert

Static invertSafe

  • invertSafe<Out>(out: Out, a: IVec3Like): Out

Static len

Static lengthSqr

Static lerp

Static max

Static min

Static multiply

Static multiplyScalar

  • multiplyScalar<Out, Vec3Like>(out: Out, a: Vec3Like, b: number): Out

Static negate

Static normalize

  • normalize<Out>(out: Out, a: IVec3Like): Out

Static project

Static projectOnPlane

Static random

  • random<Out>(out: Out, scale?: undefined | number): Out
  • 生成一个在单位球体上均匀分布的随机向量

    Type parameters

    Parameters

    • out: Out
    • Optional scale: undefined | number

      vector length

    Returns Out

Static rotateX

Static rotateY

Static rotateZ

Static round

Static scaleAndAdd

Static set

  • set<Out>(out: Out, x: number, y: number, z: number): Out

Static squaredDistance

Static strictEquals

Static subtract

Static toArray

  • toArray<Out>(out: Out, v: IVec3Like, ofs?: number): Out
  • 向量转数组

    Type parameters

    • Out: IWritableArrayLike<number>

    Parameters

    • out: Out
    • v: IVec3Like
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static transformAffine

Static transformInverseRTS

Static transformMat3

Static transformMat4

Static transformMat4Normal

Static transformQuat

Static transformRTS

Static zero

  • zero<Out>(out: Out): Out

Generated using TypeDoc