Skip to content

Commit

Permalink
Add some Vector3D helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hugh committed Aug 12, 2023
1 parent 59921ec commit 016c6ec
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/nme/geom/Vector3D.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Vector3D
x/=w;
y/=w;
z/=w;
w = 1.0;
}
return this;
}
Expand Down Expand Up @@ -125,26 +126,42 @@ class Vector3D
return l;
}

inline public function project():Void
inline public function project():Vector3D
{
x /= w;
y /= w;
z /= w;
w = 1.0;
return this;
}
inline public function setTo(xa:Float, ya:Float, za:Float):Void {

inline public function setTo(xa:Float, ya:Float, za:Float):Vector3D {
x = xa;
y = ya;
z = za;
return this;
}

inline public function scaleBy(s:Float):Void
inline public function scaleBy(s:Float):Vector3D
{
x *= s;
y *= s;
z *= s;
return this;
}

public function scaled(s:Float):Vector3D
{
return new Vector3D(x*s, y*s, z*s, 1);
}

public function addScaled(v:Vector3D, s:Float):Vector3D
{
return new Vector3D(x + v.x*s, y + v.y*s, z + v.y*s, 1);
}



inline public function subtract(a:Vector3D):Vector3D
{
return new Vector3D(x - a.x, y - a.y, z - a.z);
Expand Down

0 comments on commit 016c6ec

Please sign in to comment.