Jump to content
Search Community

3d Zooming

kranke test
Moderator Tag

Recommended Posts

Hi

 

I am using Twenmax and Papervision to zoom the camera in 3D space. I have a camera and 250 planes randomly place in Z space.

 

I am using a function to detect mouse movement up and down the screen. Basically this works with the exception that if mouse stops moving then tweening stops after it completes the offset. and if I move up and down the animation can become jerky. This is specially troublesome if I want to muse over a 3D plane since moving the mouse zooms it fast and until i am on top of it. I have tried everything I can think of and I am sure there is a better way to do it but I just can figure out.

 

function checkDirection(e:MouseEvent):void {
//trace("X movement: " + getHorizontalDirection() + ", Y movement: " + getVerticalDirection());
switch (getVerticalDirection()) {
	case "up" :
		if (camera.z > ((SGSettings.allPlanes.length * defaultZIncrement) - (defaultZIncrement * 3))) {
			//TweenMax.killTweensOf(camera);
			TweenMax.to(camera, 1, {z: ((SGSettings.allPlanes.length * defaultZIncrement) - (defaultZIncrement * 3)), ease: Linear.easeNone});
		} else {
			if (! mouseOverInPlane) {
				TweenMax.killTweensOf(camera);
				TweenMax.to(camera, 1, {z: "1700", ease: Linear.easeNone});
			} else {
				TweenMax.killTweensOf(camera);
				TweenMax.to(camera, 1, {z: "50", ease: Linear.easeNone});
			}
		}
		break;

	case "down" :
		if (camera.z < (defaultZIncrement * -1)) {
			TweenMax.to(camera, 1, {z: (defaultZIncrement * -1), ease: Linear.easeNone});
		} else {
			if (! mouseOverInPlane) {
				TweenMax.killTweensOf(camera);
				TweenMax.to(camera, 1, {z: "-1700", ease: Linear.easeNone});
			} else {
				TweenMax.killTweensOf(camera);
				TweenMax.to(camera, 1, {z: "-50", ease: Linear.easeNone});
			}
		}

	case "none" :
		//TweenMax.killTweensOf(camera);
		break;
}
e.updateAfterEvent();
}

 

Here is the getVerticalDirection function

 

	private function getVerticalDirection():String
	{
		prevY = curY;
		curY = stage.mouseY;

		if (prevY > curY)
		{
			dirY = "up";
		}
		else if (prevY < curY)
		{
			dirY = "down";
		}
		else
		{
			dirY = "none";
		}

		return dirY;
	}

 

So if you will be so kind and point me out in the right direction. Basically I want to zoom in and out in mouse move but be able to slow down when on rollover all smoothly. Please take a look at my site (I am also in the process of implementing loader max for better download) but bear with download time so you can see what I mean.

 

http://clients.letsmota.com/synapse/sga/beta-01/

 

---- I also forgot to mention that in the function above a have a min - max z ...

Thank you in advance!!!

Link to comment
Share on other sites

I guess to clarify my question, is that if anyone know of an easy way to yse tweenmax to zoom in and out using mouse position?

 

I am using the tweenmax relative position z:"1000"... but that doesnt work?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...