[Papervision3D] better roation

Ross Hulford ross at welovethedesign.com
Tue Jul 28 02:55:31 PDT 2009


This my code below. This works  fine, however the object can be  
dragged and then is rotated on its y axis onEnterFrame. The problem is  
it is not that smooth and have tried rotating the camera replacing

collada.rotationY +=2;

with

camera.rotationY +=2;

then the collada object disappears of screen for a while ( do I need  
to target the center of the collada with the camera?). Should i always  
rotate the camera rather than the object?


Can someone help me

(i) rotate the camera so it rotates around the center point of the  
collada

And or

(ii) use tweener to rotate the collada



I would like to hear any  opinions and methods you would like to  
suggest.


Thanks,


R.




			addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
			addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
			addEventListener(Event.ENTER_FRAME, render);
			
		function render(e:Event) {
		collada.rotationY +=2;
        renderer.renderScene(scene, camera, viewport);
	
		}
			
		 function onMouseDown(event:MouseEvent):void
		
		{
			isOribiting = true;
			previousMouseX = event.stageX;
			previousMouseY = event.stageY;
		}

		function onMouseUp(event:MouseEvent):void
		{
			isOribiting = false;
		}

		function onMouseMove(event:MouseEvent):void
		{
			var differenceX:Number = event.stageX - previousMouseX;
			var differenceY:Number = event.stageY - previousMouseY;

			if(isOribiting)
			{
				cameraPitch += differenceY;
				cameraYaw += differenceX;

				cameraPitch %= 360;
				cameraYaw %= 360;

				cameraPitch = cameraPitch > 0 ? cameraPitch : 0.0001;
				cameraPitch = cameraPitch < 90 ? cameraPitch : 89.9999;

				previousMouseX = event.stageX;
				previousMouseY = event.stageY;

				camera.orbit(cameraPitch, cameraYaw, true, cameraTarget);
			}
		}




More information about the Papervision3D mailing list