Struct three_d::core::Camera[][src]

pub struct Camera { /* fields omitted */ }
Expand description

Used in a render call to define how to view the 3D world.

Implementations

New camera which projects the world with an orthographic projection. See also set_view, set_perspective_projection and set_orthographic_projection.

New camera which projects the world with a perspective projection.

Specify the camera to use perspective projection with the given field of view in the y-direction and near and far plane.

Specify the camera to use orthographic projection with the given height and depth. The view frustum height is +/- height/2 The view frustum width is calculated as height * viewport.width / viewport.height. The view frustum depth is z_near to z_far.

Set the current viewport. Returns whether or not the viewport actually changed.

Change the view of the camera. The camera is placed at the given position, looking at the given target and with the given up direction.

Change the camera view such that it is mirrored in the xz-plane.

Returns whether or not the given bounding box is within the camera frustum. It returns false if it is fully outside and true if it is inside or intersects.

Returns the 3D position at the given pixel coordinate. The pixel coordinate must be in physical pixels, where (viewport.x, viewport.y) indicate the top left corner of the viewport and (viewport.x + viewport.width, viewport.y + viewport.height) indicate the bottom right corner.

Returns the 3D view direction at the given pixel coordinate. The pixel coordinate must be in physical pixels, where (viewport.x, viewport.y) indicate the top left corner of the viewport and (viewport.x + viewport.width, viewport.y + viewport.height) indicate the bottom right corner.

Returns the uv coordinate for the given pixel coordinate. The pixel coordinate must be in physical pixels, where (viewport.x, viewport.y) indicate the top left corner of the viewport and (viewport.x + viewport.width, viewport.y + viewport.height) indicate the bottom right corner. The returned uv coordinate are between 0 and 1 where (0,0) indicate the top left corner of the viewport and (1,1) indicate the bottom right corner.

Returns the uv coordinate for the given world position. The returned uv coordinate are between 0 and 1 where (0,0) indicate a position that maps to the top left corner of the viewport and (1,1) indicate a position that maps to the bottom right corner.

Returns the view matrix, ie. the matrix that transforms objects from world space (as placed in the world) to view space (as seen from this camera).

Returns the projection matrix, ie. the matrix that projects objects in view space onto this cameras image plane.

Returns the viewport.

Returns the distance to the near plane of the camera frustum.

Returns the distance to the far plane of the camera frustum.

Returns the position of this camera.

Returns the target of this camera, ie the point that this camera looks towards.

Returns the up direction of this camera (might not be orthogonal to the view direction).

Returns the view direction of this camera, ie. the direction the camera is looking.

Returns the right direction of this camera.

Returns an uniform buffer containing camera information which makes it easy to transfer all necessary camera information to a shader.

Use this buffer in your Program like this program.use_uniform_block(camera.uniform_buffer(), "Camera"); and add the following to your shader code:

layout (std140) uniform Camera
{
    mat4 viewProjection;
    mat4 view;
    mat4 projection;
    vec3 position;
    float padding;
} camera;

Translate the camera by the given change while keeping the same view and up directions.

Rotates the camera by the angle delta around the ‘right’ direction.

Rotates the camera by the angle delta around the ‘up’ direction.

Rotates the camera by the angle delta around the ‘view’ direction.

Rotate the camera around the given point while keeping the same distance to the point. The input x specifies the amount of rotation in the left direction and y specifies the amount of rotation in the up direction. If you want the camera up direction to stay fixed, use the rotate_around_with_fixed_up function instead.

Rotate the camera around the given point while keeping the same distance to the point and the same up direction. The input x specifies the amount of rotation in the left direction and y specifies the amount of rotation in the up direction.

Moves the camera towards the given point by the amount delta while keeping the given minimum and maximum distance to the point.

👎 Deprecated:

Use pick function instead

Finds the closest intersection between a ray from this camera in the given pixel coordinate and the given geometries. The pixel coordinate must be in physical pixels, where (viewport.x, viewport.y) indicate the top left corner of the viewport and (viewport.x + viewport.width, viewport.y + viewport.height) indicate the bottom right corner. Returns None if no geometry was hit before the given maximum depth.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more