|
@@ -157,10 +157,9 @@ class Camera {
|
|
|
/**
|
|
|
Returns the forward of the camera. Cache the result until the next update().
|
|
|
**/
|
|
|
- public function getForward( ?forward : h3d.Vector ) : h3d.Vector {
|
|
|
- if ( forward == null)
|
|
|
- forward = new h3d.Vector();
|
|
|
|
|
|
+ inline public function getForward() : h3d.Vector {
|
|
|
+ var forward = new h3d.Vector();
|
|
|
if ( directions == null ) {
|
|
|
directions = new h3d.Matrix();
|
|
|
directions._44 = 0;
|
|
@@ -178,9 +177,9 @@ class Camera {
|
|
|
/**
|
|
|
Returns the right of the camera. Cache the result until the next update().
|
|
|
**/
|
|
|
- public function getRight( ?right : h3d.Vector ) : h3d.Vector {
|
|
|
- if ( right == null)
|
|
|
- right = new h3d.Vector();
|
|
|
+
|
|
|
+ inline public function getRight() : h3d.Vector {
|
|
|
+ var right = new h3d.Vector();
|
|
|
if ( directions == null ) {
|
|
|
directions = new h3d.Matrix();
|
|
|
directions._44 = 0;
|
|
@@ -198,9 +197,9 @@ class Camera {
|
|
|
/**
|
|
|
Returns the up of the camera. Cache the result until the next update().
|
|
|
**/
|
|
|
- public function getUp( ?up : h3d.Vector ) : h3d.Vector {
|
|
|
- if ( up == null)
|
|
|
- up = new h3d.Vector();
|
|
|
+
|
|
|
+ inline public function getUp() : h3d.Vector {
|
|
|
+ var up = new h3d.Vector();
|
|
|
if ( directions == null ) {
|
|
|
directions = new h3d.Matrix();
|
|
|
directions._44 = 0;
|
|
@@ -442,6 +441,20 @@ class Camera {
|
|
|
/**
|
|
|
Project a 3D point into the 2D screen. Make sure to update() the camera if it's been moved before using that.
|
|
|
**/
|
|
|
+
|
|
|
+ inline public function projectInline( x : Float, y : Float, z : Float, screenWidth : Float, screenHeight : Float, snapToPixel = true ) {
|
|
|
+ var p = new h3d.Vector();
|
|
|
+ p.set(x, y, z);
|
|
|
+ p.project(m);
|
|
|
+ p.x = (p.x + 1) * 0.5 * screenWidth;
|
|
|
+ p.y = (-p.y + 1) * 0.5 * screenHeight;
|
|
|
+ if( snapToPixel ) {
|
|
|
+ p.x = Math.round(p.x);
|
|
|
+ p.y = Math.round(p.y);
|
|
|
+ }
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+
|
|
|
public function project( x : Float, y : Float, z : Float, screenWidth : Float, screenHeight : Float, snapToPixel = true, ?p: h3d.Vector) {
|
|
|
if(p == null)
|
|
|
p = new h3d.Vector();
|