Camera
The Camera in a game is the main tool used to capture Scenes. The visible range of the Camera is controlled by adjusting camera-related parameters. The Camera is represented as follows in the Cocos Creator editor:
The Camera‘s visual range is composed of 6 planes forming a Frustum, a Near Plane, and a Far Plane to control the visible distance and range of near and far distance, at the same time, they also constitute the size of the viewport.
To use Camera
, please refer to the Camera API.
Camera components
The Camera Component is an important functional component that we use to present a Scene.
Parameter | Description |
---|---|
ClearFlags | Camera clear logo. Contains: DONT_CLEAR: not clear; DEPTH_ONLY: only clear the depth; SLOD_COLOR: clear the color, depth and template buffer |
Color | Clear the specified color |
Depth | Clear the specified depth |
Stencil | Clear the specified template buffer |
Far | Far cutting distance |
Near | Near cutting distance |
Fov | Angle of view |
OrthoHeight | The height of the orthogonal Camera |
Priority | Priority. High-priority Cameras will be rendered first in the rendering process |
Projection | Projection mode. Divided into perspective projection (PERSPECTIVE) and orthogonal projection (ORTHO) |
Rect | Viewport size of Camera |
Visibility | The visibility of the Camera. Used to control the visibility of different models in the same Camera. |
Camera group rendering
The Camera‘s group rendering function works with the Model Component through the Visibility property of the Camera Component. The user can set the Visibility value through code to complete the group rendering. It should be noted that the Visibility value is bitwise comparison, and the user can manipulate the top 20 bits of Visibility through bit operations to complete the grouping.
The Camera and models provided by default are all rendered without grouping. You do not need to change this value if the game has no special requirements to do so.