Skip to content

@temporary-escape/mod-sdk / Vector3f

Class: Vector3f ​

Defined in: math/vector3f.ts:6

Constructors ​

Constructor ​

ts
new Vector3f(
   x?: number, 
   y?: number, 
   z?: number
): Vector3f;

Defined in: math/vector3f.ts:11

Parameters ​

ParameterTypeDefault value
xnumber0
ynumberx
znumberx

Returns ​

Vector3f

Properties ​

PropertyTypeDefined in
xnumbermath/vector3f.ts:7
ynumbermath/vector3f.ts:8
znumbermath/vector3f.ts:9

Accessors ​

UP ​

Get Signature ​

ts
get static UP(): Vector3f;

Defined in: math/vector3f.ts:54

Up direction vector (0, 1, 0).

Returns ​

Vector3f

Methods ​

get() ​

ts
get(i: number): number;

Defined in: math/vector3f.ts:32

Get an axis from the vector.

Parameters ​

ParameterTypeDescription
inumberAxis index in range [0, 2].

Returns ​

number


set() ​

ts
set(i: number, v: number): void;

Defined in: math/vector3f.ts:41

Set an axis value to the vector.

Parameters ​

ParameterTypeDescription
inumberAxis index in range [0, 2].
vnumberAxis value.

Returns ​

void


toString() ​

ts
toString(): string;

Defined in: math/vector3f.ts:17

Returns ​

string


xy() ​

ts
xy(): Vector2f;

Defined in: math/vector3f.ts:24

Returns a vector containing the x and y components of this vector.

Returns ​

Vector2f


abs() ​

ts
static abs(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:180

Returns x if x >= 0; otherwise, it returns -x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


acos() ​

ts
static acos(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:596

Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


acosh() ​

ts
static acosh(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:604

Arc hyperbolic cosine; returns the non-negative inverse of cosh. Results are undefined if x < 1.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


add() ​

ts
static add(a: Vector3f, b: Vector3f): Vector3f;

Defined in: math/vector3f.ts:124

Returns addition of two vectors.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

Vector3f


asin() ​

ts
static asin(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:614

Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


asinh() ​

ts
static asinh(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:622

Arc hyperbolic sine Returns the inverse of sinh.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


atan() ​

ts
static atan(y: Vector3f, x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:633

Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0.

Parameters ​

ParameterType
yVector3f
xVector3f

Returns ​

Vector3f


atan2() ​

ts
static atan2(y: Vector3f, x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:575

Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0.

Parameters ​

ParameterType
yVector3f
xVector3f

Returns ​

Vector3f


atanh() ​

ts
static atanh(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:641

Arc hyperbolic tangent; returns the inverse of tanh. Results are undefined if abs(x) >= 1.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


ceil() ​

ts
static ceil(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:195

Returns a value equal to the nearest integer that is greater than or equal to x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


clamp() ​

ts
static clamp(
   x: Vector3f, 
   minVal: Vector3f, 
   maxVal: Vector3f
): Vector3f;

Defined in: math/vector3f.ts:418

Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal.

Parameters ​

ParameterType
xVector3f
minValVector3f
maxValVector3f

Returns ​

Vector3f


cmpEqual() ​

ts
static cmpEqual(a: Vector3f, b: Vector3f): Vector3b;

Defined in: math/vector3f.ts:166

Component-wise comparison of two vectors.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

Vector3b


cmpNotEqual() ​

ts
static cmpNotEqual(a: Vector3f, b: Vector3f): Vector3b;

Defined in: math/vector3f.ts:173

Component-wise comparison of two vectors.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

Vector3b


cos() ​

ts
static cos(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:649

The standard trigonometric cosine function. The values returned by this function will range from [-1, 1].

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


cosh() ​

ts
static cosh(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:656

Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


cross() ​

ts
static cross(x: Vector3f, y: Vector3f): Vector3f;

Defined in: math/vector3f.ts:429

Returns the cross product of x and y.

Parameters ​

ParameterType
xVector3f
yVector3f

Returns ​

Vector3f


degrees() ​

ts
static degrees(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:663

Converts radians to degrees and returns the result.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


distance() ​

ts
static distance(p0: Vector3f, p1: Vector3f): number;

Defined in: math/vector3f.ts:436

Returns the distance between p0 and p1, i.e., length(p0 - p1).

Parameters ​

ParameterType
p0Vector3f
p1Vector3f

Returns ​

number


distance2() ​

ts
static distance2(p0: Vector3f, p1: Vector3f): number;

Defined in: math/vector3f.ts:446

Returns the sqquared distance between p0 and p1, i.e., length2(p0 - p1).

Parameters ​

ParameterType
p0Vector3f
p1Vector3f

Returns ​

number


div() ​

ts
static div(a: Vector3f, b: Vector3f): Vector3f;

Defined in: math/vector3f.ts:145

Returns division of two vectors.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

Vector3f


eq() ​

ts
static eq(a: Vector3f, b: Vector3f): boolean;

Defined in: math/vector3f.ts:152

Returns true if two vectors are equal.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

boolean


exp() ​

ts
static exp(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:319

Returns the natural exponentiation of x, i.e., e^x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


exp2() ​

ts
static exp2(v: Vector3f): Vector3f;

Defined in: math/vector3f.ts:326

Returns 2 raised to the v power.

Parameters ​

ParameterType
vVector3f

Returns ​

Vector3f


faceforward() ​

ts
static faceforward(
   N: Vector3f, 
   I: Vector3f, 
   Nref: Vector3f
): Vector3f;

Defined in: math/vector3f.ts:481

If dot(Nref, I) < 0.0, return N, otherwise, return -N.

Parameters ​

ParameterType
NVector3f
IVector3f
NrefVector3f

Returns ​

Vector3f


floor() ​

ts
static floor(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:203

Returns a value equal to the nearest integer that is less then or equal to x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


fract() ​

ts
static fract(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:232

Return x - floor(x).

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


fromInt() ​

ts
static fromInt(v: Vector3i): Vector3f;

Defined in: math/vector3f.ts:110

Convert a Vector3i to a Vector3f, losing precision.

Parameters ​

ParameterType
vVector3i

Returns ​

Vector3f


inversesqrt() ​

ts
static inversesqrt(v: Vector3f): Vector3f;

Defined in: math/vector3f.ts:334

Returns the reciprocal of the positive square root of v.

Parameters ​

ParameterType
vVector3f

Returns ​

Vector3f


isinf() ​

ts
static isinf(x: Vector3f): Vector3b;

Defined in: math/vector3f.ts:380

Returns true if x holds a positive infinity or negative infinity representation in the underlying implementation's set of floating point representations. Returns false otherwise, including for implementations with no infinity representations.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3b


isnan() ​

ts
static isnan(x: Vector3f): Vector3b;

Defined in: math/vector3f.ts:395

Returns true if x holds a NaN (not a number) representation in the underlying implementation's set of floating point representations. Returns false otherwise, including for implementations with no NaN representations.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3b


length() ​

ts
static length(x: Vector3f): number;

Defined in: math/vector3f.ts:210

Returns the length of x, i.e., sqrt(x * x).

Parameters ​

ParameterType
xVector3f

Returns ​

number


length2() ​

ts
static length2(x: Vector3f): number;

Defined in: math/vector3f.ts:217

Returns the squared length of x.

Parameters ​

ParameterType
xVector3f

Returns ​

number


log() ​

ts
static log(v: Vector3f): Vector3f;

Defined in: math/vector3f.ts:343

Returns the natural logarithm of v, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if v <= 0.

Parameters ​

ParameterType
vVector3f

Returns ​

Vector3f


log2() ​

ts
static log2(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:351

Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


max() ​

ts
static max(x: Vector3f, y: Vector3f): Vector3f;

Defined in: math/vector3f.ts:495

Returns y if x < y; otherwise, it returns x.

Parameters ​

ParameterType
xVector3f
yVector3f

Returns ​

Vector3f


min() ​

ts
static min(x: Vector3f, y: Vector3f): Vector3f;

Defined in: math/vector3f.ts:488

Returns y if y < x; otherwise, it returns x.

Parameters ​

ParameterType
xVector3f
yVector3f

Returns ​

Vector3f


mix() ​

ts
static mix(
   x: Vector3f, 
   y: Vector3f, 
   a: Vector3f
): Vector3f;

Defined in: math/vector3f.ts:406

If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1].

Parameters ​

ParameterType
xVector3f
yVector3f
aVector3f

Returns ​

Vector3f


mod() ​

ts
static mod(x: Vector3f, y: Vector3f): Vector3f;

Defined in: math/vector3f.ts:299

Modulus.

Parameters ​

ParameterType
xVector3f
yVector3f

Returns ​

Vector3f


modf() ​

ts
static modf(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:312

Returns the fractional part of x. The integer part is not returned, as AssemblyScript has no output parameters. The return value will have the same sign as x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


mul() ​

ts
static mul(a: Vector3f, b: Vector3f): Vector3f;

Defined in: math/vector3f.ts:138

Returns multiplication of two vectors.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

Vector3f


ne() ​

ts
static ne(a: Vector3f, b: Vector3f): boolean;

Defined in: math/vector3f.ts:159

Returns true if two vectors are not equal.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

boolean


normalize() ​

ts
static normalize(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:224

Returns a vector in the same direction as x but with length of 1.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


pow() ​

ts
static pow(base: Vector3f, exponent: Vector3f): Vector3f;

Defined in: math/vector3f.ts:358

Returns 'base' raised to the power 'exponent'.

Parameters ​

ParameterType
baseVector3f
exponentVector3f

Returns ​

Vector3f


radians() ​

ts
static radians(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:674

Converts degrees to radians and returns the result.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


reflect() ​

ts
static reflect(I: Vector3f, N: Vector3f): Vector3f;

Defined in: math/vector3f.ts:457

For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N.

Parameters ​

ParameterType
IVector3f
NVector3f

Returns ​

Vector3f


refract() ​

ts
static refract(
   I: Vector3f, 
   N: Vector3f, 
   eta: number
): Vector3f;

Defined in: math/vector3f.ts:467

For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector.

Parameters ​

ParameterType
IVector3f
NVector3f
etanumber

Returns ​

Vector3f


rotate() ​

ts
static rotate(
   v: Vector3f, 
   angle: number, 
   axis: Vector3f
): Vector3f;

Defined in: math/vector3f.ts:502

Rotate a vector around an axis.

Parameters ​

ParameterType
vVector3f
anglenumber
axisVector3f

Returns ​

Vector3f


rotateX() ​

ts
static rotateX(v: Vector3f, angle: number): Vector3f;

Defined in: math/vector3f.ts:529

Rotate a vector around the X axis.

Parameters ​

ParameterType
vVector3f
anglenumber

Returns ​

Vector3f


rotateY() ​

ts
static rotateY(v: Vector3f, angle: number): Vector3f;

Defined in: math/vector3f.ts:539

Rotate a vector around the Y axis.

Parameters ​

ParameterType
vVector3f
anglenumber

Returns ​

Vector3f


rotateZ() ​

ts
static rotateZ(v: Vector3f, angle: number): Vector3f;

Defined in: math/vector3f.ts:549

Rotate a vector around the Z axis.

Parameters ​

ParameterType
vVector3f
anglenumber

Returns ​

Vector3f


round() ​

ts
static round(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:239

Returns a value equal to the nearest integer to x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


roundEven() ​

ts
static roundEven(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:248

Returns a value equal to the nearest integer to x. A fractional part of 0.5 will round toward the nearest even integer. (Both 3.5 and 4.5 for x will return 4.0.)

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


saturate() ​

ts
static saturate(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:582

Returns clamp(x, 0, 1) for each component in x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


sign() ​

ts
static sign(a: Vector3f): Vector3f;

Defined in: math/vector3f.ts:187

Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.

Parameters ​

ParameterType
aVector3f

Returns ​

Vector3f


sin() ​

ts
static sin(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:686

The standard trigonometric sine function. The values returned by this function will range from [-1, 1].

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


sinh() ​

ts
static sinh(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:693

Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


slerp() ​

ts
static slerp(
   x: Vector3f, 
   y: Vector3f, 
   a: number
): Vector3f;

Defined in: math/vector3f.ts:559

Returns Spherical interpolation between two vectors.

Parameters ​

ParameterType
xVector3f
yVector3f
anumber

Returns ​

Vector3f


smoothstep() ​

ts
static smoothstep(
   edge0: Vector3f, 
   edge1: Vector3f, 
   x: Vector3f
): Vector3f;

Defined in: math/vector3f.ts:266

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1.

This is useful in cases where you would want a threshold function with a smooth transition. This is equivalent to: genType t; t = clamp ((x - edge0) / (edge1 - edge0), 0, 1); return t * t * (3 - 2 * t); Results are undefined if edge0 >= edge1.

Parameters ​

ParameterType
edge0Vector3f
edge1Vector3f
xVector3f

Returns ​

Vector3f


sqrt() ​

ts
static sqrt(v: Vector3f): Vector3f;

Defined in: math/vector3f.ts:369

Returns the positive square root of v.

Parameters ​

ParameterType
vVector3f

Returns ​

Vector3f


step() ​

ts
static step(edge: Vector3f, x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:280

Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.

Parameters ​

ParameterType
edgeVector3f
xVector3f

Returns ​

Vector3f


sub() ​

ts
static sub(a: Vector3f, b: Vector3f): Vector3f;

Defined in: math/vector3f.ts:131

Returns subtraction of two vectors.

Parameters ​

ParameterType
aVector3f
bVector3f

Returns ​

Vector3f


tan() ​

ts
static tan(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:700

The standard trigonometric tangent function.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


tanh() ​

ts
static tanh(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:707

Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


trunc() ​

ts
static trunc(x: Vector3f): Vector3f;

Defined in: math/vector3f.ts:292

Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolute value of x.

Parameters ​

ParameterType
xVector3f

Returns ​

Vector3f


unm() ​

ts
static unm(a: Vector3f): Vector3f;

Defined in: math/vector3f.ts:117

Returns the negation of the vector.

Parameters ​

ParameterType
aVector3f

Returns ​

Vector3f