Documentation ¶
Overview ¶
Scene provides a widget for duit, that can render a 3d scene and react to mouse and key events with changing the transformation matrix.
The opengl style 3d interface is based on github.com/foglman/{fauxl,ln,pt}. For the arcball see: github.com/fogleman/meshview/interactor.go.
Index ¶
- type Matrix
- func Frustum(l, r, b, t, n, f float64) Matrix
- func Identity() Matrix
- func LookAt(eye, center, up Vector) Matrix
- func LookAtDirection(forward, up Vector) Matrix
- func Orient(position, size, up Vector, rotation float64) Matrix
- func Orthographic(l, r, b, t, n, f float64) Matrix
- func Perspective(fovy, aspect, near, far float64) Matrix
- func Rotate(v Vector, a float64) Matrix
- func RotateTo(a, b Vector) Matrix
- func Scale(v Vector) Matrix
- func Screen(w, h int) Matrix
- func Translate(v Vector) Matrix
- func Viewport(x, y, w, h float64) Matrix
- func (a Matrix) Determinant() float64
- func (m Matrix) Frustum(l, r, b, t, n, f float64) Matrix
- func (a Matrix) Inverse() Matrix
- func (m Matrix) LookAt(eye, center, up Vector) Matrix
- func (a Matrix) Mul(b Matrix) Matrix
- func (a Matrix) MulDirection(b Vector) Vector
- func (a Matrix) MulPosition(b Vector) Vector
- func (a Matrix) MulPositionW(b Vector) VectorW
- func (a Matrix) MulScalar(b float64) Matrix
- func (m Matrix) Orthographic(l, r, b, t, n, f float64) Matrix
- func (m Matrix) Perspective(fovy, aspect, near, far float64) Matrix
- func (m Matrix) Rotate(v Vector, a float64) Matrix
- func (m Matrix) RotateTo(a, b Vector) Matrix
- func (m Matrix) Scale(v Vector) Matrix
- func (m Matrix) Translate(v Vector) Matrix
- func (a Matrix) Transpose() Matrix
- func (m Matrix) Viewport(x, y, w, h float64) Matrix
- type Scene
- func (s *Scene) Draw(dui *duit.DUI, self *duit.Kid, img *duitdraw.Image, orig image.Point, ...)
- func (s *Scene) FirstFocus(dui *duit.DUI, self *duit.Kid) (warp *image.Point)
- func (s *Scene) Focus(dui *duit.DUI, self *duit.Kid, o duit.UI) (warp *image.Point)
- func (s *Scene) Key(dui *duit.DUI, self *duit.Kid, k rune, m duitdraw.Mouse, orig image.Point) (r duit.Result)
- func (s *Scene) Layout(dui *duit.DUI, self *duit.Kid, sizeAvail image.Point, force bool)
- func (s *Scene) Mark(self *duit.Kid, o duit.UI, forLayout bool) (marked bool)
- func (s *Scene) Mouse(dui *duit.DUI, self *duit.Kid, m duitdraw.Mouse, origM duitdraw.Mouse, ...) (r duit.Result)
- func (s *Scene) Print(self *duit.Kid, indent int)
- type SceneDrawer
- type Vector
- func (a Vector) Abs() Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) AddScalar(b float64) Vector
- func (a Vector) Ceil() Vector
- func (a Vector) Cross(b Vector) Vector
- func (a Vector) Distance(b Vector) float64
- func (a Vector) DistanceSquared(b Vector) float64
- func (a Vector) Div(b Vector) Vector
- func (a Vector) DivScalar(b float64) Vector
- func (a Vector) Dot(b Vector) float64
- func (a Vector) Floor() Vector
- func (a Vector) IsDegenerate() bool
- func (a Vector) Length() float64
- func (a Vector) LengthSquared() float64
- func (a Vector) Lerp(b Vector, t float64) Vector
- func (a Vector) LerpDistance(b Vector, d float64) Vector
- func (a Vector) Less(b Vector) bool
- func (a Vector) Max(b Vector) Vector
- func (a Vector) MaxComponent() float64
- func (a Vector) Min(b Vector) Vector
- func (a Vector) MinComponent() float64
- func (a Vector) Mod(b Vector) Vector
- func (a Vector) Mul(b Vector) Vector
- func (a Vector) MulScalar(b float64) Vector
- func (a Vector) Negate() Vector
- func (a Vector) Normalize() Vector
- func (a Vector) Perpendicular() Vector
- func (i Vector) Reflect(n Vector) Vector
- func (p Vector) SegmentDistance(v Vector, w Vector) float64
- func (a Vector) Sub(b Vector) Vector
- func (a Vector) SubScalar(b float64) Vector
- func (a Vector) VectorW() VectorW
- type VectorW
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix struct {
X00, X01, X02, X03 float64
X10, X11, X12, X13 float64
X20, X21, X22, X23 float64
X30, X31, X32, X33 float64
}
func LookAtDirection ¶
func Orthographic ¶
func Perspective ¶
func (Matrix) Determinant ¶
func (Matrix) MulDirection ¶
func (Matrix) MulPosition ¶
func (Matrix) MulPositionW ¶
func (Matrix) Orthographic ¶
func (Matrix) Perspective ¶
type Scene ¶
type Scene struct { View SceneDrawer `json:"-"` }
Scene is a UI which renders a 3d scene and reacts to events with pan, zoom and rotate.
func (*Scene) FirstFocus ¶
type SceneDrawer ¶
SceneDrawer can draw a 3d object onto an image.
type Vector ¶
type Vector struct {
X, Y, Z float64
}
func RandomUnitVector ¶
func RandomUnitVector() Vector
func (Vector) DistanceSquared ¶
func (Vector) IsDegenerate ¶
func (Vector) LengthSquared ¶
func (Vector) MaxComponent ¶
func (Vector) MinComponent ¶
func (Vector) Perpendicular ¶
type View ¶
type View struct { Eye Vector // Eye position in object space Center Vector // Centeral position (where the eye looks at) in object space. Up Vector // Unit direction going up in object space. Near, Far float64 // Clipping planes Fovy float64 // Field of view angle in degree in y direction (normally 45..60 deg) Width, Height float64 // Destination image dimensions. // contains filtered or unexported fields }
View defines where we look at.
func NewView ¶
func NewView() View
NewView initializes the view and arcball with default values. The values can be changed afterwards.
Click to show internal directories.
Click to hide internal directories.