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 Intersection
- type Projection
- type Raycaster
- func (rc *Raycaster) IntersectObject(inode core.INode, recursive bool, intersections []Intersection) []Intersection
- func (rc *Raycaster) IntersectObjects(inodes []core.INode, recursive bool, intersections []Intersection) []Intersection
- func (rc *Raycaster) RaycastLineStrip(l *graphic.LineStrip, intersections []Intersection) []Intersection
- func (rc *Raycaster) RaycastLines(l *graphic.Lines, intersections []Intersection) []Intersection
- func (rc *Raycaster) RaycastMesh(m *graphic.Mesh, intersections []Intersection) []Intersection
- func (rc *Raycaster) RaycastMeshFirst(m *graphic.Mesh) (result Intersection, intersects bool)
- func (rc *Raycaster) RaycastPoints(p *graphic.Points, intersections []Intersection) []Intersection
- func (rc *Raycaster) RaycastSprite(s *graphic.Sprite) (Intersection, bool)
- func (rc *Raycaster) SetFromCamera(cam *Camera, sx, sy float32)
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 ¶
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) ProjMatrix ¶
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 ¶
func (c *Camera) Projection() Projection
Projection returns the projection method used by the camera.
func (*Camera) SetFov ¶
SetFov sets the perspective field-of-view in degrees along the reference axis.
func (*Camera) SetProjection ¶
func (c *Camera) SetProjection(proj Projection)
SetProjection sets the projection method used by the camera.
func (*Camera) Unproject ¶
Unproject transforms the specified position from camera projected coordinates to world coordinates.
func (*Camera) UpdateFov ¶
UpdateFov updates the field-of-view such that the frustum matches the orthographic size at the depth specified by targetDist.
func (*Camera) UpdateSize ¶
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 Intersection ¶ added in v0.2.75
type Intersection struct { // Distance between the origin of the ray and the intersection Distance float32 // Point of intersection in world coordinates Point math32.Vector3 // Intersected node Object core.INode // If the geometry has indices, this field is the // index in the Indices buffer of the vertex intersected // or the first vertex of the intersected face. // If the geometry doesn't have indices, this field is the // index in the positions buffer of the vertex intersected // or the first vertex of the intersected face. Index uint32 }
Intersection describes the intersection between a ray and an object
type Raycaster ¶ added in v0.2.8
type Raycaster struct { math32.Ray // The distance from the ray origin to the intersected points // must be greater than the value of this field to be considered. // The default value is 0.0 Near float32 // The distance from the ray origin to the intersected points // must be less than the value of this field to be considered. // The default value is +Infinity. Far float32 // Minimum distance in world coordinates between the ray and // a line segment when checking intersects with lines. // The default value is 0.1 LinePrecision float32 // Minimum distance in world coordinates between the ray and // a point when checking intersects with points. // The default value is 0.1 PointPrecision float32 // This field must be set with the camera view matrix used // when checking for sprite intersections. // It is set automatically when using camera.SetRaycaster ViewMatrix math32.Matrix4 }
Raycaster represents an empty object that can cast rays and check for ray intersections.
func NewRaycaster ¶ added in v0.2.8
NewRaycaster creates and returns a pointer to a new raycaster object with the specified origin and direction.
func (*Raycaster) IntersectObject ¶ added in v0.2.8
func (rc *Raycaster) IntersectObject(inode core.INode, recursive bool, intersections []Intersection) []Intersection
IntersectObject checks intersections between this raycaster and the specified node. If recursive is true, it also checks the intersection with the node's children. Intersections are returned sorted by distance, closest first.
func (*Raycaster) IntersectObjects ¶ added in v0.2.8
func (rc *Raycaster) IntersectObjects(inodes []core.INode, recursive bool, intersections []Intersection) []Intersection
IntersectObjects checks intersections between this raycaster and the specified array of scene nodes. If recursive is true, it also checks the intersection with each nodes' children. Intersections are returned sorted by distance, closest first.
func (*Raycaster) RaycastLineStrip ¶ added in v0.2.8
func (rc *Raycaster) RaycastLineStrip(l *graphic.LineStrip, intersections []Intersection) []Intersection
RaycastLineStrip checks for intersections with a graphic.LineStrip.
func (*Raycaster) RaycastLines ¶ added in v0.2.8
func (rc *Raycaster) RaycastLines(l *graphic.Lines, intersections []Intersection) []Intersection
RaycastLines checks for intersections with a graphic.Lines.
func (*Raycaster) RaycastMesh ¶ added in v0.2.8
func (rc *Raycaster) RaycastMesh(m *graphic.Mesh, intersections []Intersection) []Intersection
RaycastMesh checks for intersections with a graphic.Mesh.
func (*Raycaster) RaycastMeshFirst ¶ added in v0.2.75
func (rc *Raycaster) RaycastMeshFirst(m *graphic.Mesh) (result Intersection, intersects bool)
RaycastMeshFirst checks for intersections with a graphic.Mesh. This will return the first intersection found.
func (*Raycaster) RaycastPoints ¶ added in v0.2.8
func (rc *Raycaster) RaycastPoints(p *graphic.Points, intersections []Intersection) []Intersection
RaycastPoints checks for intersections with a graphic.Points.
func (*Raycaster) RaycastSprite ¶ added in v0.2.8
func (rc *Raycaster) RaycastSprite(s *graphic.Sprite) (Intersection, bool)
RaycastSprite checks intersections between the raycaster and the specified sprite and if any found appends it to the specified intersects array.
func (*Raycaster) SetFromCamera ¶ added in v0.2.8
SetFromCamera sets the specified raycaster with this camera position in world coordinates pointing to the direction defined by the specified coordinates unprojected using this camera.