Documentation
¶
Index ¶
- Variables
- func DefaultTransformFunc(parent, current dprec.Mat4) dprec.Mat4
- type Animation
- type AnimationBindingDefinitionInfo
- type AnimationDefinition
- type AnimationDefinitionInfo
- type AnimationInfo
- type Controller
- type CubeTexture
- type Engine
- func (e *Engine) ActiveScene() *Scene
- func (e *Engine) Create()
- func (e *Engine) CreateAnimationDefinition(info AnimationDefinitionInfo) *AnimationDefinition
- func (e *Engine) CreateResourceSet() *ResourceSet
- func (e *Engine) CreateScene() *Scene
- func (e *Engine) Destroy()
- func (e *Engine) ECS() *ecs.Engine
- func (e *Engine) GFXWorker() Worker
- func (e *Engine) Graphics() *graphics.Engine
- func (e *Engine) IOWorker() Worker
- func (e *Engine) Physics() *physics.Engine
- func (e *Engine) Registry() asset.Registry
- func (e *Engine) Render(viewport graphics.Viewport)
- func (e *Engine) ResetDeltaTime()
- func (e *Engine) SetActiveScene(scene *Scene)
- func (e *Engine) SubscribePostUpdate(callback UpdateCallback) *UpdateSubscription
- func (e *Engine) SubscribePreUpdate(callback UpdateCallback) *UpdateSubscription
- func (e *Engine) Update()
- type EngineOption
- func WithECS(ecsEngine *ecs.Engine) EngineOption
- func WithGFXWorker(worker Worker) EngineOption
- func WithGraphics(gfxEngine *graphics.Engine) EngineOption
- func WithIOWorker(worker Worker) EngineOption
- func WithPhysics(physicsEngine *physics.Engine) EngineOption
- func WithRegistry(registry asset.Registry) EngineOption
- type Keyframe
- type KeyframeList
- type Model
- type ModelDefinition
- type ModelInfo
- type Node
- func (n *Node) AbsoluteMatrix() dprec.Mat4
- func (n *Node) AppendChild(child *Node)
- func (n *Node) AppendSibling(sibling *Node)
- func (n *Node) Armature() *graphics.Armature
- func (n *Node) ArmatureBone() int
- func (n *Node) Body() *physics.Body
- func (n *Node) Camera() *graphics.Camera
- func (n *Node) Detach()
- func (n *Node) FindNode(name string) *Node
- func (n *Node) FirstChild() *Node
- func (n *Node) LastChild() *Node
- func (n *Node) LeftSibling() *Node
- func (n *Node) Light() *graphics.Light
- func (n *Node) Matrix() dprec.Mat4
- func (n *Node) Mesh() *graphics.Mesh
- func (n *Node) Name() string
- func (n *Node) Parent() *Node
- func (n *Node) Position() dprec.Vec3
- func (n *Node) PrependChild(child *Node)
- func (n *Node) PrependSibling(sibling *Node)
- func (n *Node) PrintHierarchy(depth int)
- func (n *Node) RemoveChild(child *Node)
- func (n *Node) RightSibling() *Node
- func (n *Node) Rotation() dprec.Quat
- func (n *Node) Scale() dprec.Vec3
- func (n *Node) SetArmature(armature *graphics.Armature)
- func (n *Node) SetArmatureBone(bone int)
- func (n *Node) SetBody(body *physics.Body)
- func (n *Node) SetCamera(camera *graphics.Camera)
- func (n *Node) SetLight(light *graphics.Light)
- func (n *Node) SetMesh(mesh *graphics.Mesh)
- func (n *Node) SetName(name string)
- func (n *Node) SetPosition(position dprec.Vec3)
- func (n *Node) SetRotation(rotation dprec.Quat)
- func (n *Node) SetScale(scale dprec.Vec3)
- func (n *Node) UseTransformation(transform TransformFunc)
- type Operation
- type Promise
- type ResourceSet
- func (s *ResourceSet) CreateResourceSet() *ResourceSet
- func (s *ResourceSet) Delete()
- func (s *ResourceSet) OpenCubeTexture(id string) async.Promise[*CubeTexture]
- func (s *ResourceSet) OpenModel(id string) async.Promise[*ModelDefinition]
- func (s *ResourceSet) OpenModelByName(name string) async.Promise[*ModelDefinition]
- func (s *ResourceSet) OpenScene(id string) async.Promise[*SceneDefinition]
- func (s *ResourceSet) OpenSceneByName(name string) async.Promise[*SceneDefinition]
- func (s *ResourceSet) OpenTwoDTexture(id string) async.Promise[*TwoDTexture]
- type Scene
- func (s *Scene) CreateAnimation(info AnimationInfo) *Animation
- func (s *Scene) CreateModel(info ModelInfo) *Model
- func (s *Scene) Delete()
- func (s *Scene) ECS() *ecs.Scene
- func (s *Scene) Graphics() *graphics.Scene
- func (s *Scene) Initialize(definition *SceneDefinition)
- func (s *Scene) Physics() *physics.Scene
- func (s *Scene) Root() *Node
- func (s *Scene) Update(elapsedSeconds float64)
- type SceneDefinition
- type TransformFunc
- type TwoDTexture
- type UpdateCallback
- type UpdateSubscription
- type Worker
- type WorkerFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("resource not found") ErrStillLoading = errors.New("resource still loading") )
Functions ¶
Types ¶
type Animation ¶ added in v0.9.0
type Animation struct {
// contains filtered or unexported fields
}
type AnimationBindingDefinitionInfo ¶ added in v0.9.0
type AnimationBindingDefinitionInfo struct {
NodeIndex int
NodeName string //alternative in case of isolated animation
TranslationKeyframes KeyframeList[dprec.Vec3]
RotationKeyframes KeyframeList[dprec.Quat]
ScaleKeyframes KeyframeList[dprec.Vec3]
}
type AnimationDefinition ¶ added in v0.9.0
type AnimationDefinition struct {
// contains filtered or unexported fields
}
type AnimationDefinitionInfo ¶ added in v0.9.0
type AnimationDefinitionInfo struct {
Name string
StartTime float64
EndTime float64
Bindings []AnimationBindingDefinitionInfo
}
type AnimationInfo ¶ added in v0.9.0
type AnimationInfo struct {
Model *Model
Definition *AnimationDefinition
}
type Controller ¶
type Controller struct {
app.NopController
// contains filtered or unexported fields
}
func NewController ¶ added in v0.9.0
func NewController(registry asset.Registry, api render.API, shaders graphics.ShaderCollection) *Controller
func (*Controller) Engine ¶ added in v0.9.0
func (c *Controller) Engine() *Engine
func (*Controller) OnCreate ¶ added in v0.9.0
func (c *Controller) OnCreate(window app.Window)
func (*Controller) OnDestroy ¶ added in v0.9.0
func (c *Controller) OnDestroy(window app.Window)
func (*Controller) OnRender ¶ added in v0.9.0
func (c *Controller) OnRender(window app.Window)
type CubeTexture ¶ added in v0.9.0
type CubeTexture struct {
// contains filtered or unexported fields
}
type Engine ¶ added in v0.9.0
type Engine struct {
// contains filtered or unexported fields
}
func NewEngine ¶ added in v0.9.0
func NewEngine(opts ...EngineOption) *Engine
func (*Engine) ActiveScene ¶ added in v0.9.0
func (*Engine) CreateAnimationDefinition ¶ added in v0.9.0
func (e *Engine) CreateAnimationDefinition(info AnimationDefinitionInfo) *AnimationDefinition
func (*Engine) CreateResourceSet ¶ added in v0.9.0
func (e *Engine) CreateResourceSet() *ResourceSet
func (*Engine) CreateScene ¶ added in v0.9.0
func (*Engine) ResetDeltaTime ¶ added in v0.9.0
func (e *Engine) ResetDeltaTime()
func (*Engine) SetActiveScene ¶ added in v0.9.0
func (*Engine) SubscribePostUpdate ¶ added in v0.9.0
func (e *Engine) SubscribePostUpdate(callback UpdateCallback) *UpdateSubscription
func (*Engine) SubscribePreUpdate ¶ added in v0.9.0
func (e *Engine) SubscribePreUpdate(callback UpdateCallback) *UpdateSubscription
type EngineOption ¶ added in v0.9.0
type EngineOption func(e *Engine)
func WithECS ¶ added in v0.9.0
func WithECS(ecsEngine *ecs.Engine) EngineOption
func WithGFXWorker ¶ added in v0.9.0
func WithGFXWorker(worker Worker) EngineOption
func WithGraphics ¶ added in v0.9.0
func WithGraphics(gfxEngine *graphics.Engine) EngineOption
func WithIOWorker ¶ added in v0.9.0
func WithIOWorker(worker Worker) EngineOption
func WithPhysics ¶ added in v0.9.0
func WithPhysics(physicsEngine *physics.Engine) EngineOption
func WithRegistry ¶ added in v0.9.0
func WithRegistry(registry asset.Registry) EngineOption
type KeyframeList ¶ added in v0.9.0
type Model ¶ added in v0.9.0
type Model struct {
// contains filtered or unexported fields
}
func (*Model) Animations ¶ added in v0.9.0
func (*Model) BodyInstances ¶ added in v0.9.0
func (*Model) FindAnimation ¶ added in v0.9.0
type ModelDefinition ¶ added in v0.9.0
type ModelDefinition struct {
// contains filtered or unexported fields
}
func (*ModelDefinition) FindAnimation ¶ added in v0.9.0
func (d *ModelDefinition) FindAnimation(name string) *AnimationDefinition
type ModelInfo ¶ added in v0.9.0
type ModelInfo struct {
// Name specifies the name of this instance. This should not be
// confused with the name of the definition.
Name string
// Definition specifies the template from which this instance will
// be created.
Definition *ModelDefinition
// Position is used to specify a location for the model instance.
Position dprec.Vec3
// Rotation is used to specify a rotation for the model instance.
Rotation dprec.Quat
// Scale is used to specify a scale for the model instance.
Scale dprec.Vec3
// IsDynamic determines whether the model can be repositioned once
// placed in the Scene.
// (i.e. whether it should be added to the scene hierarchy)
IsDynamic bool
// PrepareAnimations indicates whether animation definitions should be
// instantiated for this model.
PrepareAnimations bool
}
ModelInfo contains the information necessary to place a Model instance into a Scene.
type Node ¶ added in v0.9.0
type Node struct {
// contains filtered or unexported fields
}
Node represents a positioning of an object or part of one in the 3D scene.
func (*Node) AbsoluteMatrix ¶ added in v0.9.0
AbsoluteMatrix returns the matrix transformation of this Node relative to the root coordinate system.
func (*Node) AppendChild ¶ added in v0.9.0
AppendChild adds the specified Node as the right-most child of this Node. If the appended Node already has a parent, it is first detached from that parent.
func (*Node) AppendSibling ¶ added in v0.9.0
AppendSibling attaches a Node to the right of the current one.
func (*Node) Armature ¶ added in v0.9.0
Armature returns the graphics Armature that is attached to this Node.
func (*Node) ArmatureBone ¶ added in v0.9.0
ArmatureBone returns the bone index if the Armature that is affected by this Node.
func (*Node) Camera ¶ added in v0.9.0
Camera returns the graphics Camera that is attached to this Node.
func (*Node) Detach ¶ added in v0.9.0
func (n *Node) Detach()
Detach removes this Node from the hierarchy but does not release any resources.
func (*Node) FindNode ¶ added in v0.9.0
FindNode searches the hierarchy starting from this Node (inclusive) for a Node that has the specified name.
func (*Node) FirstChild ¶ added in v0.9.0
FirstChild returns the first (left-most) child Node of this Node. If this Node does not have any children then this method returns nil.
func (*Node) LastChild ¶ added in v0.9.0
LastChild returns the last (right-most) child Node of this Node. If this Node does not have any children then this method returns nil.
func (*Node) LeftSibling ¶ added in v0.9.0
LeftSibling returns the left sibling Node of this Node. If this Node is the left-most child of its parent or does not have a parent then this method returns nil.
func (*Node) Light ¶ added in v0.9.0
Light returns the graphics Light that is attached to this Node.
func (*Node) Matrix ¶ added in v0.9.0
Matrix returns the matrix transformation of this Node relative to the parent.
func (*Node) Parent ¶ added in v0.9.0
Parent returns the parent Node in the hierarchy. If this is the top-most Node then nil is returned.
func (*Node) Position ¶ added in v0.9.0
Position returns this Node's relative position to the parent.
func (*Node) PrependChild ¶ added in v0.9.0
PrependChild adds the specified Node as the left-most child of this Node. If the preprended Node already has a parent, it is first detached from that parent.
func (*Node) PrependSibling ¶ added in v0.9.0
PrependSibling attaches a Node to the left of the current one.
func (*Node) PrintHierarchy ¶ added in v0.9.0
PrintHierarchy prints debug information regarding the hierarchy that starts from this node.
func (*Node) RemoveChild ¶ added in v0.9.0
RemoveChild removes the specified Node from the list of children held by this Node. If the specified Node is not a child of this Node, then nothing happens.
func (*Node) RightSibling ¶ added in v0.9.0
RightSibling returns the right sibling Node of this Node. If this Node is the right-most child of its parent or does not have a parent then this method returns nil.
func (*Node) Rotation ¶ added in v0.9.0
Rotation returns this Node's rotation relative to the parent.
func (*Node) SetArmature ¶ added in v0.9.0
SetArmature attaches a graphics Armature to this Node.
func (*Node) SetArmatureBone ¶ added in v0.9.0
SetArmatureBone configures the bone index of the Armature that is affected by this Node.
func (*Node) SetPosition ¶ added in v0.9.0
SetPosition changes this Node's relative position to the parent.
func (*Node) SetRotation ¶ added in v0.9.0
SetRotation changes this Node's rotation relative to the parent.
func (*Node) UseTransformation ¶ added in v0.9.0
func (n *Node) UseTransformation(transform TransformFunc)
UseTransformation configures a TransformFunc to be used for calculating the absolute matrix of this node. Pass nil to restore default behavior.
type Operation ¶ added in v0.9.0
type Operation struct {
// contains filtered or unexported fields
}
func NewOperation ¶ added in v0.9.0
func NewOperation() Operation
type Promise ¶ added in v0.9.0
type Promise[T any] struct { // contains filtered or unexported fields }
func NewPromise ¶ added in v0.9.0
func SafePromise ¶ added in v0.9.0
type ResourceSet ¶ added in v0.9.0
type ResourceSet struct {
// contains filtered or unexported fields
}
func (*ResourceSet) CreateResourceSet ¶ added in v0.9.0
func (s *ResourceSet) CreateResourceSet() *ResourceSet
func (*ResourceSet) Delete ¶ added in v0.9.0
func (s *ResourceSet) Delete()
Delete schedules all resources managed by this ResourceSet for deletion. After this method returns, the resources are not guaranteed to have been released.
Calling this method twice is not allowed. Allocating new resources after this method has been called is also not allowed.
func (*ResourceSet) OpenCubeTexture ¶ added in v0.9.0
func (s *ResourceSet) OpenCubeTexture(id string) async.Promise[*CubeTexture]
func (*ResourceSet) OpenModel ¶ added in v0.9.0
func (s *ResourceSet) OpenModel(id string) async.Promise[*ModelDefinition]
func (*ResourceSet) OpenModelByName ¶ added in v0.9.0
func (s *ResourceSet) OpenModelByName(name string) async.Promise[*ModelDefinition]
func (*ResourceSet) OpenScene ¶ added in v0.9.0
func (s *ResourceSet) OpenScene(id string) async.Promise[*SceneDefinition]
func (*ResourceSet) OpenSceneByName ¶ added in v0.9.0
func (s *ResourceSet) OpenSceneByName(name string) async.Promise[*SceneDefinition]
func (*ResourceSet) OpenTwoDTexture ¶ added in v0.9.0
func (s *ResourceSet) OpenTwoDTexture(id string) async.Promise[*TwoDTexture]
type Scene ¶ added in v0.9.0
type Scene struct {
// contains filtered or unexported fields
}
func (*Scene) CreateAnimation ¶ added in v0.9.0
func (s *Scene) CreateAnimation(info AnimationInfo) *Animation
func (*Scene) CreateModel ¶ added in v0.9.0
func (*Scene) Initialize ¶ added in v0.9.0
func (s *Scene) Initialize(definition *SceneDefinition)
type SceneDefinition ¶ added in v0.9.0
type SceneDefinition struct {
// contains filtered or unexported fields
}
type TransformFunc ¶ added in v0.9.0
TransformFunc is a mechanism to calculate a custom absolute matrix off of the parent and the current matrix, circumventing standard matrix multiplication rules.
type TwoDTexture ¶ added in v0.9.0
type TwoDTexture struct {
// contains filtered or unexported fields
}
type UpdateCallback ¶ added in v0.9.0
type UpdateSubscription ¶ added in v0.9.0
type UpdateSubscription struct {
// contains filtered or unexported fields
}
func (*UpdateSubscription) Delete ¶ added in v0.9.0
func (s *UpdateSubscription) Delete()
type WorkerFunc ¶ added in v0.9.0
func (WorkerFunc) Schedule ¶ added in v0.9.0
func (f WorkerFunc) Schedule(fn func() error) Operation
func (WorkerFunc) ScheduleVoid ¶ added in v0.9.0
func (f WorkerFunc) ScheduleVoid(fn func()) Operation