Documentation ¶
Overview ¶
Package camera contains common camera types used for rendering 3D scenes.
Index ¶
- type Camera
- func (cam *Camera) GetCamera() *Camera
- func (cam *Camera) Initialize()
- func (cam *Camera) LookAt(target *math32.Vector3)
- func (cam *Camera) Project(v *math32.Vector3) (*math32.Vector3, error)
- func (cam *Camera) SetRaycaster(rc *core.Raycaster, x, y float32) error
- func (cam *Camera) SetUp(up *math32.Vector3)
- func (cam *Camera) Target() math32.Vector3
- func (cam *Camera) Unproject(v *math32.Vector3) (*math32.Vector3, error)
- func (cam *Camera) Up() math32.Vector3
- func (cam *Camera) ViewMatrix(m *math32.Matrix4)
- type ICamera
- type Orthographic
- type Perspective
- func (cam Perspective) Aspect() float32
- func (cam *Perspective) Far() float32
- func (cam *Perspective) Fov() float32
- func (cam *Perspective) Near() float32
- func (cam *Perspective) ProjMatrix(m *math32.Matrix4)
- func (cam *Perspective) Project(v *math32.Vector3) (*math32.Vector3, error)
- func (cam *Perspective) SetAspect(aspect float32)
- func (cam *Perspective) SetFov(fov float32)
- func (cam *Perspective) SetRaycaster(rc *core.Raycaster, sx, sy float32) error
- func (cam *Perspective) Unproject(v *math32.Vector3) (*math32.Vector3, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
Camera is the base camera which is normally embedded in other camera types.
func (*Camera) Initialize ¶
func (cam *Camera) Initialize()
Initialize initializes the base camera. Normally used by other camera types which embed this base camera.
func (*Camera) LookAt ¶
LookAt rotates the camera to look at the specified target position. This method does not support objects with rotated and/or translated parent(s). TODO: maybe move method to Node, or create similar in Node.
func (*Camera) Project ¶
Project satisfies the ICamera interface and must be implemented for specific camera types.
func (*Camera) SetRaycaster ¶
SetRaycaster satisfies the ICamera interface and must be implemented for specific camera types.
func (*Camera) Unproject ¶
Unproject satisfies the ICamera interface and must be implemented for specific camera types.
func (*Camera) ViewMatrix ¶
ViewMatrix returns the current view matrix of this camera.
type ICamera ¶
type ICamera interface { GetCamera() *Camera ViewMatrix(*math32.Matrix4) ProjMatrix(*math32.Matrix4) Project(*math32.Vector3) (*math32.Vector3, error) Unproject(*math32.Vector3) (*math32.Vector3, error) SetRaycaster(rc *core.Raycaster, x, y float32) error }
ICamera is interface for all camera types.
type Orthographic ¶
type Orthographic struct { Camera // Embedded camera // contains filtered or unexported fields }
Orthographic is an orthographic camera.
func NewOrthographic ¶
func NewOrthographic(left, right, top, bottom, near, far float32) *Orthographic
NewOrthographic creates and returns a pointer to a new orthographic camera with the specified parameters.
func (*Orthographic) Planes ¶
func (cam *Orthographic) Planes() (left, right, top, bottom, near, far float32)
Planes returns the coordinates of the camera planes.
func (*Orthographic) ProjMatrix ¶
func (cam *Orthographic) ProjMatrix(m *math32.Matrix4)
ProjMatrix satisfies the ICamera interface.
func (*Orthographic) SetZoom ¶
func (cam *Orthographic) SetZoom(zoom float32)
SetZoom sets the zoom factor of the camera.
func (*Orthographic) Zoom ¶
func (cam *Orthographic) Zoom() float32
Zoom returns the zoom factor of the camera.
type Perspective ¶
type Perspective struct { Camera // Embedded camera // contains filtered or unexported fields }
Perspective is a perspective camera.
func NewPerspective ¶
func NewPerspective(fov, aspect, near, far float32) *Perspective
NewPerspective creates and returns a pointer to a new perspective camera with the specified parameters.
func (Perspective) Aspect ¶
func (cam Perspective) Aspect() float32
Aspect returns the current camera aspect ratio.
func (*Perspective) Far ¶
func (cam *Perspective) Far() float32
Far returns the current camera far plane Z coordinate.
func (*Perspective) Fov ¶
func (cam *Perspective) Fov() float32
Fov returns the current camera FOV (field of view) in degrees.
func (*Perspective) Near ¶
func (cam *Perspective) Near() float32
Near returns the current camera near plane Z coordinate.
func (*Perspective) ProjMatrix ¶
func (cam *Perspective) ProjMatrix(m *math32.Matrix4)
ProjMatrix satisfies the ICamera interface.
func (*Perspective) Project ¶
Project transforms the specified position from world coordinates to this camera projected coordinates.
func (*Perspective) SetAspect ¶
func (cam *Perspective) SetAspect(aspect float32)
SetAspect sets the camera aspect ratio (width/height).
func (*Perspective) SetFov ¶
func (cam *Perspective) SetFov(fov float32)
SetFov sets the camera field of view in degrees.
func (*Perspective) SetRaycaster ¶
func (cam *Perspective) SetRaycaster(rc *core.Raycaster, sx, sy float32) error
SetRaycaster sets the specified raycaster with this camera position in world coordinates pointing to the direction defined by the specified coordinates unprojected using this camera.