Discussion:
Zooming into a clicked point on a model
Kevin Burke
2010-10-09 16:27:49 UTC
Permalink
Hi,
I have a client who wants some things in Papervision that I'm not sure how
to do, namely: when the user clicks somewhere on a model, zoom the camera
into that point.

I would use a tween engine to tween the camera forward, but as moveForward
is a method, I'm not sure how I'd enter this data into a tweening call.
Tweenlite.to(camera, 1, {??????});


Second, I need to set the camera to lookAt wherever the user clicked on the
model. How can I tell what the closest vertex is next to the mouse click? Or
maybe there's a better way to do this? Thank you!
--
View this message in context: http://papervision3d.758870.n4.nabble.com/Zooming-into-a-clicked-point-on-a-model-tp2969689p2969689.html
Sent from the Papervision3D mailing list archive at Nabble.com.
Kevin Burke
2010-10-13 19:51:41 UTC
Permalink
I figured out a solution. I created a display object called cameraTarget.
When the user clicks the model, it fires an InteractiveScene3DEvent. That
event ("e" in this code) has a face3D property that contains three vertices
with x, y, & z values. In the first three lines, I'm finding the average of
those values. I then tween the target to that point and zoom with the
TweenMax calls in the TimelineLite instance:
var xPos:Number = (e.face3d.v0.x + e.face3d.v1.x + e.face3d.v2.x)/3;
var yPos:Number = (e.face3d.v0.y + e.face3d.v1.y + e.face3d.v2.y)/3;
var zPos:Number = (e.face3d.v0.z + e.face3d.v1.z + e.face3d.v2.z)/3;

var timeline:TimelineLite = new TimelineLite();
timeline.append(TweenMax.to(cameraTarget, zoomTime, {x:(xPos * -1),
y:yPos, z:zPos, ease:Expo.easeOut}));
timeline.append(TweenMax.to(camera, zoomTime, {zoom:900}), zoomTime *
-1);
In my render function I have my camera looking at the target each frame:
camera.lookAt(cameraTarget);
Hope this helps someone!
--
View this message in context: http://papervision3d.758870.n4.nabble.com/Zooming-into-a-clicked-point-on-a-model-tp2969689p2994341.html
Sent from the Papervision3D mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...