Hi All

First time blogger and hope this makes sense!

I have a 3d map on stage, which you can rotate around. My client wants
to be able to rotate around different areas of this map (for this test
1-4 on the keyboard ;-) ).

Ok!

I have 3d map,
I have set up a small plane which is invisible and the camera points
to.
When press the key the plane Tweens to the correct area.

This is all no problem.

The problem is after this when I try to rotates around the camera
jumps. I don't know how to fix this, do I need to adjust the
targetpanangle and the targettiltangle?

I'm pretty rubbish at trig and maths (i have tried, read all of Keith
Peters books as well as gone to his 2 day lecture!!!).

Is this a long winded/ correct way?

code  -

        private function onKeyDown():void
                {
                        _oldX = _navigator.x;
                        _oldZ = _navigator.z;

                        switch (_model.keyCode)
                        {
                                case 49:
                                        TweenMax.to (_navigator, 
_model.animTime, {x:900, z:-100,
onComplete:renderCamLight})
                                        break;

                                case 50:
                                        TweenMax.to (_navigator, 
_model.animTime, {x:900, z:100,
onComplete:renderCamLight})
                                        break;
                        }
                }

                private function renderCamLight():void
                {
                        _dx = _navigator.x - _oldX;
                        _dz = _navigator.z - _oldZ;
                        var radians:Number = Math.atan2(_dx, _dz);
                        var rotation:Number = radians * 180 / Math.PI;
                        var catchPan:Number = _hoverCamera.targetpanangle - 
rotation;

                        _lastPanAngle = _hoverCamera.targetpanangle;
                        _lastTiltAngle = _hoverCamera.targettiltangle;

                        _hoverCamera.targetpanangle = SPEED * (rotation); + 
_lastPanAngle;
                        _hoverCamera.targettiltangle = SPEED * (_navigator.z - 
_oldZ) +
_lastTiltAngle;

                        _hoverCamera.hover();
                }


                private function renderStage():void
                {

                        /* -- HOVER STATES -- */

                        if (_model.mouseState) {
                                _hoverCamera.targetpanangle = SPEED 
*(_model.stage.mouseX -
_lastMouseX) + _lastPanAngle;
                                _hoverCamera.targettiltangle = SPEED 
*(_model.stage.mouseY -
_lastMouseY) + _lastTiltAngle;

                                _hoverCamera.hover();
                        }
                        _view.render();
                }

        }

Reply via email to