A Camera is a Overlay that renders a 3D scene on to a two-dimensional window or texture, as seen from the camera's point-of-view. Its properties establish how the camera operates:
- The scene to render (typically $.scene).
- Its placement in the scene's world (or a shape's) coordinates: origin, orientation and scale. following specifies a shape (avatar) in the scene which the camera is following or looking through the eyes of. The camera's placement is automatically calculated into 'vmatrix', used to transform world into camera coordinates.
- Its projection technique which specifies the clip and view frustum, whose distance from the camera is bounded by near and far and whose field of view angle is defined by fov. This is converted to 'pmatrix', used to transform 3-D coordinates to a sized 2-D image.
- The render context, state information that helps guide the render, such as background, border, etc.
- The window or frame target, which is the main window ($window) by default. Rendering to a frame's texture can facilitate shadow maps, reflections, post-processing effects, etc. A viewport can be specified within the target.
Methods
- CameraXyz
- (xyz, matrix) Convert an Xyz position to camera coordinates, by multiplying mvmatrix*xyz. The assumption is that Xyz is a position (w=1.0), so the position will be scaled, rotated and translated as needed.
- Lookat
- Calculates the camera's lookat view using 'location', 'lookat' and 'up'.
- New
- -> camera. Creates a new camera.
- Orthogonal
- Calculates the orthogonal projection using 'near', 'far', 'viewHeight', and the window's aspect ratio.
- Perspective
- Calculates the perspective projection using 'near', 'far', 'fov', and the window's aspect ratio.
Properties
- background
- The background color applied to the viewport before rendering the 3-D scene.
- far
- (Float) Maximum positive distance object can be from camera and still be visible. Default is 1000.
- following
- A shape that the camera is following. The camera's origin, orientation and scale is calculated relative to the shape's eye/origin, orientation and scale.
- fov
- (Float) The vertical "field of view" angle (in radians) that defines a perspective frustum. If the value is >= pi, it is converted from degrees to radians. The default fov is 50 degrees. The horizontal fov angle is calculated using the window's aspect ratio.
- near
- (Float) Minimum positive distance object can be from camera and still be visible. Default is 0.1.
- orientation
- A Quat specifying the rotation used to orient the camera in the world (or following's) coordinate system. If not specified, no rotation takes place.
- origin
- (Xyz) The position of the camera within the scene. The default is +Xyz(0.,0.,3.).
- projection
- Name of the method to use when calculating the camera's projection matrix.
- scale
- An Xyz vector specifying how much to re-size the camera's view of the world, The default is no scaling: +Xyz(1.,1.,1.)
- scene
- The scene to render. If unspecified: $.scene
- target
- The window or frame that receives the rendered 2-d image. If unspecified: $window
- up
- (Xyz) The camera's "up" direction. The default is +Xyz(0.,1.,0.).
- viewHeight
- (Float) The vertical size of the orthogonal projection clip and view box (the default is 10). The horizontal size is calculated using the window's aspect ratio.
- viewport
- A Rect specifying which rectangular area of the target image to render into. If unspecified, rendering targets the entire image.