Skip to content

FlxCamera perspective projection #167

Description

@flunardelli

I added a helper function to work with perspective projection in FlxCamera that I think could be useful.

/**
         * Helper function to change the camera's perpective.
         * 
         * @param   fiedOfView  Specifies an angle, as a degree between 0 and 180, for the field of view in three dimensions.
         * This value determines how strong the perspective transformation and distortion apply to a three-dimensional display object with a non-zero z-coordinate.
         * @param   rotationX   Indicates the x-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. 
         * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 
         * Values outside this range are added to or subtracted from 360 to obtain a value within the range.
         * @param   rotationY   Indicates the y-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. 
         * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 
         * Values outside this range are added to or subtracted from 360 to obtain a value within the range.
         * @param   rotationZ  Indicates the z-axis rotation of the DisplayObject instance, in degrees, from its original orientation relative to the 3D parent container. 
         * Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. 
         * Values outside this range are added to or subtracted from 360 to obtain a value within the range.
         */
        public function perspectiveProjection(fiedOfView:uint=90,rotationX:Number=-40,rotationY:Number=0,rotationZ:Number=0):void {         
            var perpective:PerspectiveProjection = new PerspectiveProjection;
            perpective.fieldOfView = fiedOfView;            
            _flashSprite.rotationX = rotationX;
            _flashSprite.rotationY = rotationY;
            _flashSprite.rotationZ = rotationZ;         
            _flashSprite.transform.perspectiveProjection = perpective;          
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions