The Y axis gets inverted whenever my rotation about the Y axis exceeds
90 degrees or falls below -90.

Have a look:
http://sites.google.com/site/terintemp/index/example.swf?attredirects=0

Here is my code:

package
{
        import away3dlite.containers.Scene3D;
        import away3dlite.containers.View3D;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.geom.Point;
        import flash.geom.Vector3D;
        import flash.ui.Mouse;
        import levels.Test;
        import utils.Console;
        import utils.Key
        import utils.MouseState

        /**
         * ...
         * @author William fagerstrom
         */
        public class Main extends Sprite
        {
                private var view:View3D;
                private var level:Test;
                private var key:Key;
                private var mouse:MouseState;

                private var old:Point = new Point();
                private var change:Point = new Point();

                private var xRotation:Number = 0;
                private var yRotation:Number = 0;

                public function Main():void
                {
                        if (stage) init();
                        else addEventListener(Event.ADDED_TO_STAGE, init);
                }

                private function init(e:Event = null):void
                {
                        removeEventListener(Event.ADDED_TO_STAGE, init);
                        addEventListener(Event.ENTER_FRAME, loop);
                        // entry point

                        mouse = new MouseState(this.stage);
                        key = new Key(this);
                        view = new View3D();
                        view.scene = new Scene3D();

                        level = new Test();

                        view.scene.addChild(level);
                        addChild(view);
                        addChild(Console.instance);

                        view.camera.zoom = 10;
                        view.camera.x = 0;
                        view.camera.y = -100;
                        view.camera.z = -10;

                        view.render();
                }

                private function loop(e:Event):void
                {
                        change.x = old.x - mouseX;
                        change.y = old.y - mouseY;

                        old.x = mouseX;
                        old.y = mouseY;

                        if (mouse.left)
                        {
                                xRotation += change.y / 2;
                                yRotation += change.x / 2;

                                /*if (yRotation > 180)
                                {
                                        yRotation = 180;
                                }

                                if (yRotation < -89)
                                {
                                        yRotation = -89;
                                }*/

                                view.camera.rotationX = xRotation;
                                view.camera.rotationY = yRotation;

                                Console.instance.print(xRotation, yRotation);
                        }

                        view.camera.transform.matrix3D.prependTranslation(0, 0, 
1);
                        view.render();
                }

        }

}


In case it matters, Test is this file.
http://sites.google.com/site/terintemp/index/Test.as?attredirects=0&d=1

Reply via email to