A 3 dimensional vector object.

In many instances a Vec3 will be accessible from Nape which is marked as immutable, these cases will be documented and modifying such a Vec3 will result in an error.

Static methods

@:value({ z : 0, y : 0, x : 0 })staticget(x:Float = 0, y:Float = 0, z:Float = 0):Vec3

Allocate a Vec3 from the global object pool.

Use of this method should always be preferred to the constructor.

Parameters:

x

The x component of Vec3. (default 0)

y

The y component of Vec3. (default 0)

z

The z component of Vec3. (default 0)

Returns:

A Vec3 allocated from global object pool with given components.

Constructor

@:value({ z : 0, y : 0, x : 0 })new(x:Float = 0, y:Float = 0, z:Float = 0)

Construct a new Vec3.

This method should not generally be used with preference for the static get method which will make use of the global object pool.

Parameters:

x

The x component of Vec3. (default 0)

y

The y component of Vec3. (default 0)

z

The z component of Vec3. (default 0)

Returns:

A newly constructed Vec3 with given components.

Variables

length:Float

Length of Vec3.

This value may also be set to any value including negatives, though an error will be thrown if length of the Vec3 is already 0 as such a scaling would be undefined. As well as if this Vec3 has been disposed of, or is immutable.

x:Float

The x component of Vec3.

y:Float

The y component of Vec3.

z:Float

The z component of Vec3.

zpp_disp:Bool

@private

@:value(null)zpp_inner:ZPP_Vec3 = null

@private

@:value(null)zpp_pool:Vec3 = null

@private

Methods

dispose():Void

Produce a copy of this Vec3.

Returns:

The copy of this Vec3.

Throws:

#

If this Vec3 has been disposed of. public function copy():Vec3{

{
    #if(!NAPE_RELEASE_BUILD)
    if(this!=null&&this.zpp_disp)throw "Error: "+"Vec3"+" has been disposed and cannot be used!";
    #end
};
return Vec3.get(x,y,z);

} /** Release Vec3 object to global object pool.

#

If this Vec3 has already been disposed of.

#

If this Vec3 is immutable.

lsq():Float

Compute squared length of Vec3.

Returns:

The squared length of this Vec3.

Throws:

#

If the Vec3 has been disposed of.

set(vector:Vec3):Vec3

Set values of this Vec3 from another.

Parameters:

vector

The vector to set values from.

Returns:

A reference to this Vec3.

Throws:

#

If the vector argument is null.

#

If this, or the vector argument are disposed of.

#

If this Vec3 is immutable.

setxyz(x:Float, y:Float, z:Float):Vec3

Set values of this Vec3 from numbers.

Parameters:

x

The new x component value for this vector.

y

The new y component value for this vector.

z

The new z component value for this vector.

Returns:

A reference to this Vec3.

Throws:

#

If this Vec3 has been disposed of.

#

If this Vec3 is immutable.

@:keeptoString():String

@private

@:value({ weak : false })xy(weak:Bool = false):Vec2

Produce copy of the xy components of Vec3.

This function will return a new Vec2 completely seperate from this Vec3 with values equal to the xy components of this Vec3.

Parameters:

weak

If true, then the allocated Vec2 will be weak so that when used as an argument to a Nape function it will be automatically released back to the global object pool. (default false)

Returns:

An allocated Vec2 representing the xy components of this vector.