engine: github.com/g3n/engine/camera Index | Files | Directories

package camera

import "github.com/g3n/engine/camera"

Package camera contains common camera types used for rendering 3D scenes.

Index

Package Files

camera.go logger.go orthographic.go perspective.go

type Camera Uses

type Camera struct {
    core.Node // Embedded Node
    // contains filtered or unexported fields
}

Camera is the base camera which is normally embedded in other camera types.

func (*Camera) GetCamera Uses

func (cam *Camera) GetCamera() *Camera

GetCamera satisfies the ICamera interface.

func (*Camera) Initialize Uses

func (cam *Camera) Initialize()

Initialize initializes the base camera. Normally used by other camera types which embed this base camera.

func (*Camera) LookAt Uses

func (cam *Camera) LookAt(target *math32.Vector3)

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 Uses

func (cam *Camera) Project(v *math32.Vector3) (*math32.Vector3, error)

Project satisfies the ICamera interface and must be implemented for specific camera types.

func (*Camera) SetRaycaster Uses

func (cam *Camera) SetRaycaster(rc *core.Raycaster, x, y float32) error

SetRaycaster satisfies the ICamera interface and must be implemented for specific camera types.

func (*Camera) SetUp Uses

func (cam *Camera) SetUp(up *math32.Vector3)

SetUp sets the camera up vector.

func (*Camera) Target Uses

func (cam *Camera) Target() math32.Vector3

Target get the current target position.

func (*Camera) Unproject Uses

func (cam *Camera) Unproject(v *math32.Vector3) (*math32.Vector3, error)

Unproject satisfies the ICamera interface and must be implemented for specific camera types.

func (*Camera) Up Uses

func (cam *Camera) Up() math32.Vector3

Up get the current camera up vector.

func (*Camera) ViewMatrix Uses

func (cam *Camera) ViewMatrix(m *math32.Matrix4)

ViewMatrix returns the current view matrix of this camera.

type ICamera Uses

type ICamera interface {
    GetCamera() *Camera
    SetAspect(float32)
    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 Uses

type Orthographic struct {
    Camera // Embedded camera
    // contains filtered or unexported fields
}

Orthographic is an orthographic camera.

func NewOrthographic Uses

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 Uses

func (cam *Orthographic) Planes() (left, right, top, bottom, near, far float32)

Planes returns the coordinates of the camera planes.

func (*Orthographic) ProjMatrix Uses

func (cam *Orthographic) ProjMatrix(m *math32.Matrix4)

ProjMatrix satisfies the ICamera interface.

func (*Orthographic) SetAspect Uses

func (cam *Orthographic) SetAspect(aspect float32)

SetAspect sets the camera aspect ratio (width/height).

func (*Orthographic) SetZoom Uses

func (cam *Orthographic) SetZoom(zoom float32)

SetZoom sets the zoom factor of the camera.

func (*Orthographic) Zoom Uses

func (cam *Orthographic) Zoom() float32

Zoom returns the zoom factor of the camera.

type Perspective Uses

type Perspective struct {
    Camera // Embedded camera
    // contains filtered or unexported fields
}

Perspective is a perspective camera.

func NewPerspective Uses

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 Uses

func (cam Perspective) Aspect() float32

Aspect returns the current camera aspect ratio.

func (*Perspective) Far Uses

func (cam *Perspective) Far() float32

Far returns the current camera far plane Z coordinate.

func (*Perspective) Fov Uses

func (cam *Perspective) Fov() float32

Fov returns the current camera FOV (field of view) in degrees.

func (*Perspective) Near Uses

func (cam *Perspective) Near() float32

Near returns the current camera near plane Z coordinate.

func (*Perspective) ProjMatrix Uses

func (cam *Perspective) ProjMatrix(m *math32.Matrix4)

ProjMatrix satisfies the ICamera interface.

func (*Perspective) Project Uses

func (cam *Perspective) Project(v *math32.Vector3) (*math32.Vector3, error)

Project transforms the specified position from world coordinates to this camera projected coordinates.

func (*Perspective) SetAspect Uses

func (cam *Perspective) SetAspect(aspect float32)

SetAspect sets the camera aspect ratio (width/height).

func (*Perspective) SetFov Uses

func (cam *Perspective) SetFov(fov float32)

SetFov sets the camera field of view in degrees.

func (*Perspective) SetRaycaster Uses

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.

func (*Perspective) Unproject Uses

func (cam *Perspective) Unproject(v *math32.Vector3) (*math32.Vector3, error)

Unproject transforms the specified position from camera projected coordinates to world coordinates.

Directories

PathSynopsis
controlPackage control implements controllers for cameras

Package camera imports 3 packages (graph) and is imported by 7 packages. Updated 2018-08-29. Refresh now. Tools for package owners.