Documentation ¶
Overview ¶
Package camera contains virtual cameras and associated controls.
Index ¶
- Constants
- type Axis
- type Camera
- func (c *Camera) Aspect() float32
- func (c *Camera) Axis() Axis
- func (c *Camera) Far() float32
- func (c *Camera) Fov() float32
- func (c *Camera) Near() float32
- func (c *Camera) ProjMatrix(m *math32.Matrix4)
- func (c *Camera) Project(v *math32.Vector3) *math32.Vector3
- func (c *Camera) Projection() Projection
- func (c *Camera) SetAspect(aspect float32)
- func (c *Camera) SetAxis(axis Axis)
- func (c *Camera) SetFar(far float32)
- func (c *Camera) SetFov(fov float32)
- func (c *Camera) SetNear(near float32)
- func (c *Camera) SetProjection(proj Projection)
- func (c *Camera) SetSize(size float32)
- func (c *Camera) Size() float32
- func (c *Camera) Unproject(v *math32.Vector3) *math32.Vector3
- func (c *Camera) UpdateFov(targetDist float32)
- func (c *Camera) UpdateSize(targetDist float32)
- func (c *Camera) ViewMatrix(m *math32.Matrix4)
- type ICamera
- type OrbitControl
- func (oc *OrbitControl) Dispose()
- func (oc *OrbitControl) Enabled() OrbitEnabled
- func (oc *OrbitControl) Pan(deltaX, deltaY float32)
- func (oc *OrbitControl) Reset()
- func (oc *OrbitControl) Rotate(thetaDelta, phiDelta float32)
- func (oc *OrbitControl) SetEnabled(bitmask OrbitEnabled)
- func (oc *OrbitControl) SetTarget(v math32.Vector3)
- func (oc *OrbitControl) Target() math32.Vector3
- func (oc *OrbitControl) Zoom(delta float32)
- type OrbitEnabled
- type Projection
Constants ¶
const ( Vertical = Axis(iota) Horizontal )
The two possible camera axes.
const ( Perspective = Projection(iota) Orthographic )
The possible camera projections.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
Camera represents a virtual camera, which specifies how to project a 3D scene onto an image.
func New ¶ added in v0.2.0
New creates and returns a new perspective camera with the specified aspect ratio and default parameters.
func NewOrthographic ¶
NewOrthographic creates and returns a new orthographic camera with the specified parameters.
func NewPerspective ¶
NewPerspective creates and returns a new perspective camera with the specified parameters.
func (*Camera) Axis ¶ added in v0.2.0
Axis returns the reference axis associated with the camera size/fov.
func (*Camera) Fov ¶ added in v0.2.0
Fov returns the perspective field-of-view in degrees along the reference axis.
func (*Camera) ProjMatrix ¶ added in v0.2.0
ProjMatrix returns the projection matrix of the camera.
func (*Camera) Project ¶
Project transforms the specified position from world coordinates to this camera projected coordinates.
func (*Camera) Projection ¶ added in v0.2.0
func (c *Camera) Projection() Projection
Projection returns the projection method used by the camera.
func (*Camera) SetAxis ¶ added in v0.2.0
SetAxis sets the reference axis associated with the camera size/fov.
func (*Camera) SetFov ¶ added in v0.2.0
SetFov sets the perspective field-of-view in degrees along the reference axis.
func (*Camera) SetProjection ¶ added in v0.2.0
func (c *Camera) SetProjection(proj Projection)
SetProjection sets the projection method used by the camera.
func (*Camera) SetSize ¶ added in v0.2.0
SetSize sets the orthographic view size along the camera's reference axis.
func (*Camera) Size ¶ added in v0.2.0
Size returns the orthographic view size along the camera's reference axis.
func (*Camera) Unproject ¶
Unproject transforms the specified position from camera projected coordinates to world coordinates.
func (*Camera) UpdateFov ¶ added in v0.2.0
UpdateFov updates the field-of-view such that the frustum matches the orthographic size at the depth specified by targetDist.
func (*Camera) UpdateSize ¶ added in v0.2.0
UpdateSize updates the orthographic size to match the current field-of-view frustum at the depth specified by targetDist.
func (*Camera) ViewMatrix ¶
ViewMatrix returns the view matrix of the camera.
type OrbitControl ¶ added in v0.2.0
type OrbitControl struct { core.Dispatcher // Embedded event dispatcher // Public properties MinDistance float32 // Minimum distance from target (default is 1) MaxDistance float32 // Maximum distance from target (default is infinity) MinPolarAngle float32 // Minimum polar angle in radians (default is 0) MaxPolarAngle float32 // Maximum polar angle in radians (default is Pi) MinAzimuthAngle float32 // Minimum azimuthal angle in radians (default is negative infinity) MaxAzimuthAngle float32 // Maximum azimuthal angle in radians (default is infinity) RotSpeed float32 // Rotation speed factor (default is 1) ZoomSpeed float32 // Zoom speed factor (default is 0.1) KeyRotSpeed float32 // Rotation delta in radians used on each rotation key event (default is the equivalent of 15 degrees) KeyZoomSpeed float32 // Zoom delta used on each zoom key event (default is 2) KeyPanSpeed float32 // Pan delta used on each pan key event (default is 35) // contains filtered or unexported fields }
OrbitControl is a camera controller that allows orbiting a target point while looking at it. It allows the user to rotate, zoom, and pan a 3D scene using the mouse or keyboard.
func NewOrbitControl ¶ added in v0.2.0
func NewOrbitControl(cam *Camera) *OrbitControl
NewOrbitControl creates and returns a pointer to a new orbit control for the specified camera.
func (*OrbitControl) Dispose ¶ added in v0.2.0
func (oc *OrbitControl) Dispose()
Dispose unsubscribes from all events.
func (*OrbitControl) Enabled ¶ added in v0.2.0
func (oc *OrbitControl) Enabled() OrbitEnabled
Enabled returns the current OrbitEnabled bitmask.
func (*OrbitControl) Pan ¶ added in v0.2.0
func (oc *OrbitControl) Pan(deltaX, deltaY float32)
Pan pans the camera and target the specified amount on the plane perpendicular to the viewing direction.
func (*OrbitControl) Reset ¶ added in v0.2.0
func (oc *OrbitControl) Reset()
Reset resets the orbit control.
func (*OrbitControl) Rotate ¶ added in v0.2.0
func (oc *OrbitControl) Rotate(thetaDelta, phiDelta float32)
Rotate rotates the camera around the target by the specified angles.
func (*OrbitControl) SetEnabled ¶ added in v0.2.0
func (oc *OrbitControl) SetEnabled(bitmask OrbitEnabled)
SetEnabled sets the current OrbitEnabled bitmask.
func (*OrbitControl) SetTarget ¶ added in v0.2.0
func (oc *OrbitControl) SetTarget(v math32.Vector3)
Set camera orbit target Vector3
func (*OrbitControl) Target ¶ added in v0.2.0
func (oc *OrbitControl) Target() math32.Vector3
Target returns the current orbit target.
func (*OrbitControl) Zoom ¶ added in v0.2.0
func (oc *OrbitControl) Zoom(delta float32)
Zoom moves the camera closer or farther from the target the specified amount and also updates the camera's orthographic size to match.
type OrbitEnabled ¶ added in v0.2.0
type OrbitEnabled int
OrbitEnabled specifies which control types are enabled.
const ( OrbitNone OrbitEnabled = 0x00 OrbitRot OrbitEnabled = 0x01 OrbitZoom OrbitEnabled = 0x02 OrbitPan OrbitEnabled = 0x04 OrbitKeys OrbitEnabled = 0x08 OrbitAll OrbitEnabled = 0xFF )
The possible control types.