1 The relationship between camera classes

graph TD
Object3D --> Camera
Camera --> PerspectiveCamera
Camera --> OrthographicCamera

Common Settings API

Camera.position () sets the position of the camera. Camera.up () sets the direction of the camera and changes the direction to generate camera rotation. Default: (0,1,0) camera.lookat() specifies the position of the cameraCopy the code

As for the relationship between the camera and the world coordinates and various parameters of the camera, MY understanding is as follows: For example, if we want to take a picture of an object, such as a banana, with our mobile phone, what will we do? First of all, you have to pick up the phone and put it in a certain position. You have to hold the phone with your hand to take a picture, right? This corresponds to the three positions of the camera. Secondly, when you put your mobile phone in that position, you want to take a picture of the banana, do you have to point your mobile phone at the banana, otherwise although your mobile phone is in that position, but you flip your mobile phone up and down, might take a picture of the banana? Of course not, so pointing at the banana corresponds to the camera looAt() operation. Finally, your phone is set up and the banana is pointed, but do you still have to decide whether to shoot horizontally, vertically, or diagonally? The bananas taken by your mobile phone horizontally or vertically are different, so whether your mobile phone is horizontally or vertically corresponds to the up attribute of the camera, which refers to the upward direction of your mobile phone. When these three factors are determined, the camera can be determined, so as to take a certain picture. The condition of “certainty” is very important to the computer, because the uncertain things cannot be understood by the computer, so it cannot be presented by the computer. Reference link: blog.csdn.net/weixin_4337…

PerspectiveCamera

PerspectiveCamera = new THREE.PerspectiveCamera(45, width/height, 1, 1000);Copy the code

PerspectiveCamera( fov : Number, aspect : Number, near : Number, far : Number )

Fov -- Angle of vertical field of view of camera cone \ Default :50 Aspect -- Aspect ratio of camera cone \ Default :1 -> Width of canvas usually used/height of canvas NEAR -- near end of camera cone \ Default :0.1 far -- Far end of the camera cone Default :2000Copy the code

3 OrthographicCamera

Usage Scenarios: Render a 2D scene or UI element, Var camera = new THREE.OrthographicCamera(width / -2, width / 2, height / 2, height / -2, 1, 1000);Copy the code

OrthographicCamera( left : Number, right : Number, top : Number, bottom : Number, near : Number, far : Number )

Left - The left side of the camera cone. \ Right - The right side of the camera cone. \ TOP -- The upper side of the camera cone. \ bottom - The lower side of the camera cone. \ NEAR - Near end of camera cone. \ default:0.1 far -- Far end face of camera cone. default:2000Copy the code

4 as the cone

coneA solid shape that looks like a pyramid with its top cut parallel to the foundation helps explain why.

Imagine holding the end of a straight stick (such as a broomstick or pencil) towards the camera and taking a picture. If the stick is directly at the center of the photo, perpendicular to the lens, only a circle will be visible on the camera; All but the break point of the stick will be obscured. If you lift the stick up, the far end of the stick will be visible, but lifting the stick up will hide the far end. Continue moving up and adjust the stick Angle upwards, and the circular blackout will eventually reach the edge of the photo. At this point, all objects in the real world above the stick’s line will not appear in the photo.



Sticks can also be as simple as moving left, right, down, or horizontally or vertically in any combination. Adjust the Angle of the stick accordingly to hide the stick in the camera.

The point of this thought experiment is that any point in the camera image will eventually correspond to a line in the real world, and only one point on that line will be shown, and all objects behind that point will be obscured. The outer boundary of the image is defined by diverging lines corresponding to four vertices. These four lines eventually intersect at the point where the camera is located. This point in Unity is the transform position of the camera, called the center of the perspective view. The Angle formed by the connection between the top and bottom centers of the screen and the center of the perspective view is called the Field of View FOV.

As explained above, everything that falls outside the divergence line corresponding to the photo boundary is invisible to the camera, and there are two additional restrictions. The near and far clipping plane is parallel to the XY plane of the camera, and a definite distance is set on the center line of the camera. Objects that are closer to the camera than the near plane or closer than the far plane will not be rendered.

The emission lines corresponding to the image points together with the two cutting planes define a truncated pyramid, or cone.

Reference links: blog.csdn.net/asasqwqw121…

The above is only for recording personal learning understanding.