Documentation
¶
Overview ¶
Package seen
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearInterval ¶
func ClearInterval(id IntervalID)
Types ¶
type FutureRecursiveTask ¶
type Group ¶
Group is the object collection class. It stores Shapes, Lights, and other Groups as well as a transformation matrix.
Notably, groups are hierarchical, like a tree. This means you can isolate the transformation of groups of shapes in the scene, as well as create chains of transformations for creating, for example, articulated skeletons.
func NewGroupWithLights ¶
func (*Group) Add ¶
Add Nodes as children of this `Group` Any number of children can by supplied as arguments.
func (*Group) EachRenderable ¶
func (m *Group) EachRenderable(cb ObjectFunc)
EachRenderable visits each Node, recursively accumulating the model matrix along the way. The model matrix is used to transform the points of a node into the global World space. For every Node the callback is invoked passing in the node and the model matrix as well as the list of light render datas that apply to the node.
type Light ¶
type Light interface {
Transformer
IsEnabled() bool
ShaderData(matrix.Matrix) light.ShaderData
}
Light represents a light in the scene graph.
type Node ¶
type Node interface {
Transformer
Kind() string
}
Node represents the fundamental element in a 3D scene graph. This Node interface defines a transformable object that encapsulates geometric information and face data for rendering.
type ObjectFunc ¶
type ObjectFunc func(object Object, lights []light.ShaderData, model matrix.Matrix)
type RecursiveTask ¶
type RecursiveTask func(self func())
type Scene ¶
type Scene struct {
// Group is the root group for the scene, which contains Shapes, Lights, and
// other Groups
Group *Group
// Camera which defines the projection transformation.
// The default projection is perspective.
Camera camera.Camera
// Viewport maps normalized device coordinates to screen space. The
// default maps to a space from (0,0,0) to (1,1,1). To map more
// naturally to pixels, configure the scene with FitCenter or FitOrigin
// using the width/height of the view.
Viewport viewport.Viewport
// Shader determines which lighting model is used.
Shader shader.Shader
// The ShowBackfaces bool can be used to turn on showing of backfaces
// for the whole scene. Beware, turning this on can slow down a scene's
// rendering by a factor of 2. You can also turn on backface showing for
// individual faces with a boolean on those objects.
ShowBackfaces bool
// Regenerate is a bool that when set to true will force regeneration of render faces.
// A render face is generated for each face in the scene. When Regenerate is set
// to false (default), the generated render faces will be cached. The cache is a simple
// map keyed by the face's unique id. The cache has no eviction policy.
// To flush the cache, call FlushCache()
Regenerate bool
}
Scene
func NewDefaultScene ¶
func NewDefaultScene() *Scene
NewDefaultScene returns a new Scene that has a default Camera, Viewport and Shader and a Group with Hollywood-style 3-part lighting.
func NewScene ¶
func NewScene() *Scene
NewScene returns a new Scene that has a default Camera, Viewport and Shader and an empty Group. So, there are no lights present in the scene.
func (*Scene) FitCenter ¶ added in v0.0.5
FitCenter fits the scene to a view region so that the scene's origin maps to the centre of the region: it places the camera eye above world (x, y) at the fitting distance, sets the camera's view normalization to the region's scale, and maps the result to the region's pixels with world (x, y, 0) at the centre.
By default the projection's scale and camera distance follow the view's width and height, so the scene fills the view and rescales as the view is resized.
Pass an optional dist to lock the projection to that fixed reference distance instead. The scale and camera distance then no longer depend on width and height — those only position the centre — so one world unit projects to a constant number of pixels at any view size. Use this to keep on-screen size from changing as the window resizes; only the first dist value is used. FitCenter(x, y, s, s) and FitCenter(x, y, w, h, s) coincide when w == h == s.
Camera.Transform and Camera.Projection are left untouched.
func (*Scene) FitOrigin ¶ added in v0.0.5
FitOrigin fits the scene to a view region so that the scene's origin aligns with the region's origin ([x, y]), which is usually the top left.
As with FitCenter, the projection by default follows the view's width and height. Pass an optional dist to lock the scale and camera distance to that fixed reference instead, so on-screen size stays constant as the view is resized (width and height then only place the origin); only the first dist value is used.
Camera.Transform and Camera.Projection are left untouched.
type TaskRunner ¶
type TaskRunner interface {
Cancel()
}
type TaskScheduler ¶
type TaskScheduler interface {
Now() time.Time
Schedule(task Task) TaskRunner
ScheduleFuture(task Task, due time.Duration) TaskRunner
ScheduleRecursive(task RecursiveTask) TaskRunner
ScheduleFutureRecursive(task FutureRecursiveTask, due time.Duration) TaskRunner
Run() bool
Len() int
}
var Scheduler TaskScheduler = &scheduler{}
type Transformer ¶
type Transformer interface {
// Translation returns the object's position offset relative to its parent's coordinate system.
// Returns tx, ty, tz as the displacement along the x, y, and z axes respectively.
Translation() (tx, ty, tz float64)
// SetTranslation updates the object's position in 3D space.
// Parameters tx, ty, tz specify the displacement along the x, y, and z axes respectively.
SetTranslation(tx, ty, tz float64)
// Rotation returns the object's orientation as a quaternion.
// The quaternion represents the rotation relative to the parent's coordinate system.
Rotation() quaternion.Quat
// SetRotation updates the object's orientation using the provided quaternion.
// Parameter r specifies the new rotation to be applied.
SetRotation(r quaternion.Quat)
// Rotator introduces 3 methods that allow rotations to be specified more succintly.
transform.Rotator
// Scale returns the object's scaling factors along each axis.
// Returns sx, sy, sz as the scale factors for x, y, and z axes respectively.
Scale() (sx, sy, sz float64)
// SetScale updates the object's size by applying scale factors along each axis.
// Parameters sx, sy, sz specify the scale factors for x, y, and z axes respectively.
SetScale(sx, sy, sz float64)
// Matrix returns the complete transformation matrix for this object.
// The 4x4 homogeneous matrix combines translation, rotation, and scale,
// expressing the object's full transformation relative to its parent.
Matrix() matrix.Matrix
}
Transformer defines the interface for 3D objects that can be transformed in space. It provides methods to manipulate an object's position (translation), orientation (rotation), and size (scale), as well as access to its transformation matrix.
type Visitor ¶
Visitor manages scene graph coordinate transformations. It maintains the 'model transform' the object-space to world-space coordinate transform that allows local object coordinates to be transformed into world coordinates. It supports push/pop operations to correctly compose transformations as you enter and exit shapes or groups.
func NewVisitor ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package affine contains fake projections with affine transforms
|
Package affine contains fake projections with affine transforms |
|
Package bvh parses Biovision Hierarchical (BVH) motion capture files.
|
Package bvh parses Biovision Hierarchical (BVH) motion capture files. |
|
gio
module
|
|
|
internal/ordercheck
Package ordercheck is a deterministic repro + regression harness for painter-order (visibility) correctness, shared by the ordering layers.
|
Package ordercheck is a deterministic repro + regression harness for painter-order (visibility) correctness, shared by the ordering layers. |
|
nsort
Package nsort renders a scene with a Newell–Newell–Sancha depth sort: a view-DEPENDENT painter's order recomputed per frame for the current eye.
|
Package nsort renders a scene with a Newell–Newell–Sancha depth sort: a view-DEPENDENT painter's order recomputed per frame for the current eye. |
|
Package mocap turns a parsed BVH bvh.Hierarchy into an animatable seen scene-graph skeleton.
|
Package mocap turns a parsed BVH bvh.Hierarchy into an animatable seen scene-graph skeleton. |
|
Package shape contains primitive generation functions.
|
Package shape contains primitive generation functions. |
|
Package viewport provides the screen mapping of the render pipeline: the matrix that takes normalized device coordinates (the result of the camera's projection and perspective divide) to pixels.
|
Package viewport provides the screen mapping of the render pipeline: the matrix that takes normalized device coordinates (the result of the camera's projection and perspective divide) to pixels. |