A Camera3d is a perspective or orthographic camera in 3D, encapsulating
the camera's viewpoint and projection matrix as well as the dimensions of the
screen the camera renders to. This module contains functions for:
Cameras have a couple of commmon properties regardless of how they are constructed:
viewpoint defines the position and orientation of the camera in 3D space.clipDepth specifies the standard near clipping plane used when rendering.
The far clipping plane is assumed to be at infinity.Create a perspective camera from a viewpoint, a vertical field of view and a clip depth.
perspectiveCamera =
Camera3d.perspective
{ viewpoint = cameraViewpoint
, verticalFieldOfView = Angle.degrees 30
, clipDepth = Length.meters 0.1
}Create an orthographic camera from a viewpoint, a clip depth and the height of the orthographic viewport: this is the height in 3D world units of the section of the model to be rendered.
orthographicCamera =
Camera3d.orthographic
{ viewpoint = cameraViewpoint
, viewportHeight = Length.meters 5
, clipDepth = Length.meters 0.1
}Get the viewpoint defining the position and orientation of a camera.
Get the clip depth of a camera.
Get the clip plane of a camera.
Given a camera and a 2D screen point, calculate the corresponding 3D ray as
an Axis3d. Conceptually, the ray will pass through the given point on the
screen and will have direction equal to the viewing direction at that point.
For a perspective camera, the origin of the ray will be constant (always equal to the camera's eye point) and the direction will vary depending on the 2D screen point. For an orthographic camera, the direction of the ray will be constant (the view direction of the camera) but the origin will vary depending on the 2D screen point.
Get the view matrix of a camera;
Camera3d.viewMatrix camerais shorthand for
Viewpoint3d.viewMatrix (Camera3d.viewpoint camera)Construct a WebGL model-view matrix given a camera and a Frame3d that
defines the position and orientation of an object;
Camera3d.modelViewMatrix modelFrame camerais shorthand for
Viewpoint3d.modelViewMatrix
modelFrame
(Camera3d.viewpoint camera)Construct a special Vec4 containing values useful for settting up
perspective and orthographic projection in WebGL. For a perspective camera,
the entries are
clip depth
screen aspect ratio
1 / camera frustum slope
0For an orthographic camera, the entries are
clip depth
screen aspect ratio
0
-2 / camera viewport heightCurrently used internally by elm-3d-scene.