A camera is an abstract concept in a graphics engine for 3D projection, similar to a camera or eyes in the real world. Without a camera, the canvas will render nothing. Galacean's camera implements automatic frustum culling, rendering only objects within the frustum.
Perspective projection conforms to our model of objects appearing larger when closer and smaller when farther away. Here is a diagram of the perspective model:
As shown in the diagram above, the near clipping plane (nearClipPlane), far clipping plane (farClipPlane), and field of view (fieldOfView) form a view frustum (View Frustum). Objects within the frustum are projected into the camera and rendered on the canvas, while objects outside the frustum are clipped.
In orthographic projection, objects appear the same size regardless of their distance from the camera. The visible area created by orthographic projection is called a box-shaped view volume, as shown below:
As shown in the diagram above, there are top, bottom, left, and right boundaries. Galacean simplifies orthographic properties to better suit developers' habits, using only orthographicSize. The relationships between the various properties and orthographicSize are as follows:
top = orthographicSize
bottom = -orthographicSize
right = orthographicSize * aspectRatio
left = -orthographicSize * aspectRatio
Comparing perspective projection and orthographic projection reveals their differences:
In Galacean, both local and world coordinates follow the right-hand coordinate system
, so the camera's forward
direction is the -Z
axis, and the camera's viewing direction is also the -Z
direction.
Having introduced the basic concepts of the camera, let's get started: