Enumerationmigueldeicaza.swiftgodot 0.45.0SwiftGodot
ProjectionType
Camera3D.swift:13enum ProjectionType
Cases
case perspective
Perspective projection. Objects on the screen becomes smaller when they are far away.
case orthogonal
Orthogonal projection, also known as orthographic projection. Objects remain the same size on the screen no matter how far away they are.
case frustum
Frustum projection. This mode allows adjusting
frustumOffset
to create “tilted frustum” effects.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (36) members.
Types
Type members
Instance members
var attributes: CameraAttributes?
The
CameraAttributes
to use for this camera.var cullMask: UInt32
The culling mask that describes which
layers
are rendered by this camera. By default, all 20 user-visible layers are rendered.var current: Bool
If
true
, the ancestorViewport
is currently using this camera.var dopplerTracking: Camera3D.DopplerTracking
If not .disabled, this camera will simulate the Doppler effect for objects changed in particular
_process
methods. SeeDopplerTracking
for possible values.var environment: Environment?
The
Environment
to use for this camera.var far: Double
The distance to the far culling boundary for this camera relative to its local Z axis. Higher values allow the camera to see further away, while decreasing
far
can improve performance if it results in objects being partially or fully culled.var fov: Double
The camera’s field of view angle (in degrees). Only applicable in perspective mode. Since
keepAspect
locks one axis,fov
sets the other axis’ field of view angle.var frustumOffset: Vector2
The camera’s frustum offset. This can be changed from the default to create “tilted frustum” effects such as Y-shearing.
var hOffset: Double
The horizontal (X) offset of the camera viewport.
var keepAspect: Camera3D.KeepAspect
The axis to lock during
fov
/size
adjustments. Can be either .keepWidth or .keepHeight.var near: Double
The distance to the near culling boundary for this camera relative to its local Z axis. Lower values allow the camera to see objects more up close to its origin, at the cost of lower precision across the entire range. Values lower than the default can lead to increased Z-fighting.
var projection: Camera3D.ProjectionType
The camera’s projection mode. In .projectionPerspective mode, objects’ Z distance from the camera’s local space scales their perceived size.
var size: Double
The camera’s size in meters measured as the diameter of the width or height, depending on
keepAspect
. Only applicable in orthogonal and frustum modes.var vOffset: Double
The vertical (Y) offset of the camera viewport.
func clearCurrent(enableNext: Bool
) If this is the current camera, remove it from being current. If
enableNext
istrue
, request to make the next camera current, if any.func getCameraProjection(
) -> Projection Returns the projection matrix that this camera uses to render to its associated viewport. The camera must be part of the scene tree to function.
func getCameraRid(
) -> RID Returns the camera’s RID from the
RenderingServer
.func getCameraTransform(
) -> Transform3D Returns the transform of the camera plus the vertical (
vOffset
) and horizontal (hOffset
) offsets; and any other adjustments made to the position and orientation of the camera by subclassed cameras such asXRCamera3D
.func getCullMaskValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
cullMask
is enabled, given alayerNumber
between 1 and 20.func getFrustum(
) -> VariantCollection<Plane> Returns the camera’s frustum planes in world space units as an array of
Plane
s in the following order: near, far, left, top, right, bottom. Not to be confused withfrustumOffset
.func getPyramidShapeRid(
) -> RID Returns the RID of a pyramid shape encompassing the camera’s view frustum, ignoring the camera’s near plane. The tip of the pyramid represents the position of the camera.
func isPositionBehind(worldPoint: Vector3
) -> Bool Returns
true
if the given position is behind the camera (the blue part of the linked diagram). See this diagram for an overview of position query methods.func isPositionInFrustum(worldPoint: Vector3
) -> Bool Returns
true
if the given position is inside the camera’s frustum (the green part of the linked diagram). See this diagram for an overview of position query methods.func makeCurrent(
) Makes this camera the current camera for the
Viewport
(see class description). If the camera node is outside the scene tree, it will attempt to become current once it’s added.func projectLocalRayNormal(screenPoint: Vector2
) -> Vector3 Returns a normal vector from the screen point location directed along the camera. Orthogonal cameras are normalized. Perspective cameras account for perspective, screen width/height, etc.
func projectPosition(screenPoint: Vector2, zDepth: Double
) -> Vector3 Returns the 3D point in world space that maps to the given 2D coordinate in the
Viewport
rectangle on a plane that is the givenzDepth
distance into the scene away from the camera.func projectRayNormal(screenPoint: Vector2
) -> Vector3 Returns a normal vector in world space, that is the result of projecting a point on the
Viewport
rectangle by the inverse camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.func projectRayOrigin(screenPoint: Vector2
) -> Vector3 Returns a 3D position in world space, that is the result of projecting a point on the
Viewport
rectangle by the inverse camera projection. This is useful for casting rays in the form of (origin, normal) for object intersection or picking.func setCullMaskValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thecullMask
, given alayerNumber
between 1 and 20.func setFrustum(size: Double, offset: Vector2, zNear: Double, zFar: Double
) Sets the camera projection to frustum mode (see .projectionFrustum), by specifying a
size
, anoffset
, and thezNear
andzFar
clip planes in world space units. See alsofrustumOffset
.func setOrthogonal(size: Double, zNear: Double, zFar: Double
) Sets the camera projection to orthogonal mode (see .projectionOrthogonal), by specifying a
size
, and thezNear
andzFar
clip planes in world space units. (As a hint, 2D games often use this projection, with values specified in pixels.)func setPerspective(fov: Double, zNear: Double, zFar: Double
) Sets the camera projection to perspective mode (see .projectionPerspective), by specifying a
fov
(field of view) angle in degrees, and thezNear
andzFar
clip planes in world space units.func unprojectPosition(worldPoint: Vector3
) -> Vector2 Returns the 2D coordinate in the
Viewport
rectangle that maps to the given 3D point in world space.
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.