Posted By

allnatural on 12/17/09


Tagged

hover camera Papervision3D Away3D


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tombarc


Away3D Object Hover Camera Functionality


 / Published in: ActionScript 3
 

URL: http://www.destroyyourcomputer.com

Hover around an Object in away3D (will work with papervision3d and other 3D libraries, just plug in the correct data)

  1. //in enterframe function
  2. hoverCamera(currentObject);
  3.  
  4. //function
  5. private function hoverCamera(_currentObject:ObjectContainer3D):void
  6. {
  7. var mX:Number = this.mouseX > 0 ? this.mouseX : 0;
  8. var mZ:Number = this.mouseY > 0 ? this.mouseY : 0;
  9.  
  10. var tarX:Number = 3*(mX - stage.stageWidth/2);
  11. var tarZ:Number = -2*(mZ - stage.stageHeight/2);
  12.  
  13. var dX:Number = camera.x - tarX;
  14. var dZ:Number = camera.z - tarZ;
  15.  
  16. camera.x -= dX*0.25;
  17. camera.z -= dZ*0.25;
  18. camera.lookAt(new Number3D(_currentObject.x, 50, _currentObject.z));
  19. }

Report this snippet  

You need to login to post a comment.