View.project - item offscreen

Software: Away3D 4.x

Avatar
mrpinc, Sr. Member
Posted: 22 December 2011 07:31 PM   Total Posts: 119

I am using View.project() to determine if an Item is inside the screen coordinate space, this works fine except for a situation where the object is behind the camera but still inside of the screen bounds.

Is there a way to determine if an object is indeed being rendered by the camera?

   

Avatar
mrpinc, Sr. Member
Posted: 22 December 2011 10:09 PM   Total Posts: 119   [ # 1 ]

Came up with a solution myself - hope this helps someone else:

var sub:Vector3D target.position.subtract(camera.position);
sub.normalize();
var 
dp:Number sub.dotProductcamera.forwardVector );
 
if (
dp 0)
{
 
//Behind the camera
   

Avatar
Alexander Seifert, Moderator
Posted: 24 December 2011 02:11 PM   Total Posts: 129   [ # 2 ]

no need to normalize

 Signature 
signature_image

http://www.deltastrike.org

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X