package cameras
Types
Camera
interface
type Camera interface {
SetPosition(position matrix.Vec3)
SetFOV(fov float32)
SetNearPlane(near float32)
SetFarPlane(far float32)
SetWidth(width float32)
SetHeight(height float32)
ViewportChanged(width, height float32)
SetProperties(fov, nearPlane, farPlane, width, height float32)
Forward() matrix.Vec3
Right() matrix.Vec3
Up() matrix.Vec3
SetLookAt(position matrix.Vec3)
SetLookAtWithUp(point, up matrix.Vec3)
SetPositionAndLookAt(position, lookAt matrix.Vec3)
RayCast(screenPos matrix.Vec2) collision.Ray
TryPlaneHit(screenPos matrix.Vec2, planePos, planeNml matrix.Vec3) (hit matrix.Vec3, success bool)
ForwardPlaneHit(screenPos matrix.Vec2, planePos matrix.Vec3) (matrix.Vec3, bool)
Position() matrix.Vec3
Width() float32
Height() float32
View() matrix.Mat4
Projection() matrix.Mat4
LookAt() matrix.Vec3
NearPlane() float32
FarPlane() float32
}
StandardCamera
struct
NewStandardCamera
NewStandardCamera creates a new perspective camera using the width/height for the viewport and the position to place the camera.
NewStandardCameraOrthographic
NewStandardCameraOrthographic creates a new orthographic camera using the width/height for the viewport and the position to place the camera.
StandardCamera.FarPlane
FarPlane will return the far plane of the camera.
StandardCamera.Forward
Forward returns the forward vector of the camera.
StandardCamera.ForwardPlaneHit
func (c *StandardCamera) ForwardPlaneHit(screenPos matrix.Vec2, planePos matrix.Vec3) (matrix.Vec3, bool)
ForwardPlaneHit will project a ray from the camera's position given a screen position and test if it hits a plane directly facing the cameras position.
StandardCamera.Height
Height will return the height of the camera's viewport.
StandardCamera.LookAt
LookAt will return the look at position of the camera.
StandardCamera.NearPlane
NearPlane will return the near plane of the camera.
StandardCamera.Position
Position will return the position of the camera.
StandardCamera.Projection
Projection will return the projection matrix of the camera.
StandardCamera.RayCast
RayCast will project a ray from the camera's position given a screen position using the camera's view and projection matrices.
StandardCamera.Right
Right returns the right vector of the camera.
StandardCamera.SetFOV
SetFOV sets the field of view for the camera.
StandardCamera.SetFarPlane
SetFarPlane sets the far plane for the camera.
StandardCamera.SetHeight
SetHeight sets the height of the camera viewport.
StandardCamera.SetLookAt
SetLookAt sets the look at position of the camera.
StandardCamera.SetLookAtWithUp
SetLookAtWithUp sets the look at position of the camera and the up vector to use.
StandardCamera.SetNearPlane
SetNearPlane sets the near plane for the camera.
StandardCamera.SetPosition
SetPosition sets the position of the camera.
StandardCamera.SetPositionAndLookAt
SetPositionAndLookAt sets the position and look at position of the camera. This is often useful for when the camera warps to another location in space and avoids needless view matrix updates when setting the position and look at separately.
StandardCamera.SetProperties
SetProperties is quick access to set many properties of the camera at once. This is typically used for initializing the camera to new values. Calling each individual setter for fields would otherwise do needless projection matrix updates.
StandardCamera.SetWidth
SetWidth sets the width of the camera viewport.
StandardCamera.TryPlaneHit
func (c *StandardCamera) TryPlaneHit(screenPos matrix.Vec2, planePos, planeNml matrix.Vec3) (hit matrix.Vec3, success bool)
TryPlaneHit will project a ray from the camera's position given a screen position and test if it hits a plane. If it does, it will return the hit position and true. If it does not, it will return the zero vector and false.
StandardCamera.Up
Up returns the up vector of the camera.
StandardCamera.View
View will return the view matrix of the camera.
StandardCamera.ViewportChanged
ViewportChanged will update the camera's projection matrix and should only be used when there is a change in the viewport. This is typically done internally in the system and should not be called by the end-developer.
StandardCamera.Width
Width will return the width of the camera's viewport.
TurntableCamera
struct
ToTurntable
ToTurntable converts a standard camera to a turntable camera.
TurntableCamera.Dolly
Dolly moves the camera closer/further from the look at point by the given delta.
TurntableCamera.Orbit
Orbit orbits the camera around the look at point by the given delta.
TurntableCamera.Pan
Pan pans the camera while keeping the same facing by the given delta.
TurntableCamera.Pitch
Pitch returns the pitch of the camera.
TurntableCamera.RayCast
RayCast will project a ray from the camera's position given a screen position using the camera's view and projection matrices.
TurntableCamera.SetLookAt
SetLookAt sets the look at position of the camera.
TurntableCamera.SetLookAtWithUp
SetLookAtWithUp sets the look at position of the camera and the up vector to use.
TurntableCamera.SetPitch
SetPitch sets the pitch of the camera.
TurntableCamera.SetPosition
SetPosition sets the position of the camera.
TurntableCamera.SetYaw
SetYaw sets the yaw of the camera.
TurntableCamera.SetYawAndPitch
SetYawAndPitch sets the yaw and pitch of the camera. This helps skip needless view matrix calculations by setting both before updating the view.
TurntableCamera.SetYawPitchZoom
SetYawPitchZoom sets the yaw, pitch, and zoom of the camera. This helps skip needless view matrix calculations by setting all three before updating the view.
TurntableCamera.SetZoom
SetZoom sets the zoom of the camera.
TurntableCamera.Yaw
Yaw returns the yaw of the camera.
TurntableCamera.Zoom
Zoom returns the zoom of the camera.