3.1 KiB
order, title, type, group, label
| order | title | type | group | label |
|---|---|---|---|---|
| 0 | Camera Overview | Graphics | Camera | Graphics/Camera |
A camera is an abstract concept in a graphics engine for 3D projection, similar to a camera or eye in the real world. Galacean's camera implements automatic frustum culling, rendering only objects within the view frustum.
Types of Cameras
Perspective Projection
Perspective projection follows our model of objects appearing larger when closer and smaller when farther away. Take a look at the diagram of the perspective model:
As shown in the diagram, the near clipping plane (nearClipPlane), far clipping plane (farClipPlane), and field of view (fieldOfView) form a view frustum (View Frustum). Objects inside the view frustum are projected onto the camera and rendered on the canvas, while objects outside the view frustum are clipped.
Orthographic Projection
Orthographic projection shows objects at the same size regardless of their distance from the viewer. The visible area generated by the orthographic projection model is called an orthographic box, depicted as follows:
As shown in the diagram, there are top, bottom, left, and right values. Galacean simplifies the orthographic properties to align more with developers' habits, using only orthographicSize. The relationships between the properties and orthographicSize are as follows:
top = orthographicSizebottom = -orthographicSizeright = orthographicSize * aspectRatioleft = -orthographicSize * aspectRatio
Choosing Between Projections
By comparing perspective and orthographic projections, we can identify their differences:
- Visual area model
- Presence of the near/far effect
The following example demonstrates the visual differences between orthographic and perspective cameras. In summary, choose an orthographic camera for 2D effects and a perspective camera for 3D effects.
Camera Orientation
In Galacean, local coordinates and world coordinates follow the right-hand coordinate system, so the camera's forward direction is along the -Z axis, and the direction of the camera's view is also in the -Z direction.
Getting Started
Now that we've covered the basic concepts of cameras, let's get started:
- Add a camera component to the scene
- Use camera controls to easily manipulate the camera component
- Utilize multiple cameras in the scene
- Access camera depth textures