class nape.geom.Vec3

Available on all platforms

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.

Class Fields

static function get(?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. * *

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.

Instance Fields

var 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. * * @default 0

var x:Float

The x component of Vec3. * @default 0

var y:Float

The y component of Vec3. * @default 0

var z:Float

The z component of Vec3. * @default 0

var zpp_disp:Bool

@private

var zpp_inner:ZPP_Vec3

@private

var zpp_pool:Vec3

@private

function new(?x:Float = 0, ?y:Float = 0, ?z:Float = 0):Void

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. * *

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.

function dispose():Void

Produce a copy of this Vec3. * *

returns

The copy of this Vec3. *

function lsq():Float

Compute squared length of Vec3. * *

returns

The squared length of this Vec3. *

function set(vector:Vec3):Vec3

Set values of this Vec3 from another. * *

vector

The vector to set values from. *

returns

A reference to this Vec3. *

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

Set values of this Vec3 from numbers. * *

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. *

function toString():String

@private

function 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. * *

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.