Tween camera.lookAt?

51 views
Skip to first unread message

Petermm

unread,
Dec 30, 2008, 11:21:27 AM12/30/08
to away3d.dev
Is there a way to read the three rotation-values that the
camera.lookAt-function calculates? I would like to tween the camera to
a new lookAt position, instead of suddenly setting it to that
orientation.

richardolsson

unread,
Dec 30, 2008, 11:35:35 AM12/30/08
to away3d.dev
The best way of doing that, I reckon, is to tween the values of a
position vector, and for every frame (or other interval) invoke lookAt
().

This would be one way of doing it using Tweener:

var myTargetPos:Number3D = new Number3D;
Tweener.addTween(myTargetPos, { x: 100, y: 100, z: 100, time: 1,
onUpdate: function() {
myCamera.lookAt(myTargetPos);
} });

The above code may contain errors, but I hope that you are able to
understand the concept of it.


Regards
/R

Petermm

unread,
Dec 30, 2008, 11:44:20 AM12/30/08
to away3d.dev
I do. Thanks, i hadn't thought of something like that. I use TweenLite
and i can use an onUpdate-function there as well.

richardolsson

unread,
Dec 30, 2008, 4:10:25 PM12/30/08
to away3d.dev
Great! An onUpdate function may or may not be the preferred way,
depending on how often it fires. It is unnecessary to invoke the lookAt
() method at a higher frequence than the stage redraws, so if onUpdate
fires between screen redraws (for example on a timer) you are probably
better off calling lookAt() from your render loop.


Good luck!

/R

Jensa

unread,
Jan 1, 2009, 5:16:18 PM1/1/09
to away3d.dev
Another and much simpler trick is of course to use a TargetCam on a
cube that you don't add to the scene? Just tell the camera to look at
it and tween it to where you want the camera to look? That way you can
also turn it on/off for debugging.

J
Reply all
Reply to author
Forward
0 new messages