namespace NT { /** Represents a 3-component vector. */ export class Vector3 { private _x : number ; private _y : number ; private _z : number ; param x param y param z public constructor ( x = 0 , y = 0 , z = 0 ) { this . _x = x ; this . _y = y ; this . _z = z ; } /** The x component. */ public get x ( ) : number { return this . _x ; } /** The x component. */ public set x ( value ) { this . _x = value ; } /** The y component. */ public get y ( ) : number { return this . _y ; } /** The y component. */ public set y ( value ) { this . _y = value ; } /** The z component. */ public get z ( ) : number { return this . _z ; } /** The z component. */ public set z ( value ) { this . _z = value ; } /** Returns a vector3 with all components set to 0. */ public static get zero ( ) : Vector3 { return new Vector3 ( ) ; } /** Returns a vector3 with all components set to 1. */ public static get one ( ) : Vector3 { return new Vector3 ( 1 , 1 , 1 ) ; } param a param b public static distance ( a , b ) { let diff = a . subtract ( b ) ; return Math . sqrt ( diff . x * diff . x + diff . y * diff . y + diff . z * diff . z ) ; } param x param y param z public set ( x ? , y ? , z ? ) { if ( x !== undefined ) { this . _x = x ; } if ( y !== undefined ) { this . _y = y ; } if ( z !== undefined ) { this . _z = z ; } } param v public equals ( v ) { return ( this . x === v . x && this . y === v . y && this . z === v . z ) ; } /** Returns the data of this vector as a number array. */ public toArray ( ) { return [ this . _x , this . _y , this . _z ] ; } /** Returns the data of this vector as a Float32Array. */ public toFloat32Array ( ) { return new Float32Array ( this . toArray ( ) ) ; } /** Converts this vector to a Vector2 by dropping the Z component. */ public toVector2 ( ) { return new Vector2 ( this . _x , this . _y ) ; } param vector public copyFrom ( vector ) { this . _x = vector . _x ; this . _y = vector . _y ; this . _z = vector . _z ; } param json public setFromJson ( json ) { if ( json . x !== undefined ) { this . _x = Number ( json . x ) ; } if ( json . y !== undefined ) { this . _y = Number ( json . y ) ; } if ( json . z !== undefined ) { this . _z = Number ( json . z ) ; } } param v public add ( v ) { this . _x += v . _x ; this . _y += v . _y ; this . _z += v . _z ; return this ; } param v public subtract ( v ) { this . _x -= v . _x ; this . _y -= v . _y ; this . _z -= v . _z ; return this ; } param v public multiply ( v ) { this . _x *= v . _x ; this . _y *= v . _y ; this . _z *= v . _z ; return this ; } param v public divide ( v ) { this . _x /= v . _x ; this . _y /= v . _y ; this . _z /= v . _z ; return this ; } /**
         * Scales this vector by the provided number.
         */ public scale ( scale ) { this . _x *= scale ; this . _y *= scale ; this . _z *= scale ; return this ; } /** Clones this vector. */ public clone ( ) { return new Vector3 ( this . _x , this . _y , this . _z ) ; } } }