hierarchy

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package hierarchy provides the means to represent a hierarchy of 3D objects.

Index

Constants

This section is empty.

Variables

View Source
var NilNodeID = NodeID{0, 0}

NilNodeID is a sentinel value representing a nil NodeID.

Functions

func DefaultTransformFunc

func DefaultTransformFunc(scene *Scene, node NodeID) dprec.Mat4

DefaultTransformFunc is a TransformFunc that applies standard matrix multiplication rules.

Types

type Binding added in v0.23.0

type Binding[T BindingObject] interface {

	// OnStaleBinding is called when the node is deleted and the binding
	// is determined to no longer be valid.
	OnStaleBinding(*Scene, T)
}

Binding represents a relationship between an object and a node.

type BindingObject added in v0.23.0

type BindingObject interface {
	comparable
}

BindingObject represents a type that can be bound to a node.

type BindingSet added in v0.23.0

type BindingSet[T BindingObject] struct {
	// contains filtered or unexported fields
}

BindingSet represents a set of bindings for a specific object type.

func NewBindingSet added in v0.23.0

func NewBindingSet[T BindingObject](scene *Scene, binding Binding[T]) *BindingSet[T]

NewManualBindingSet creates a binding set that only tracks deletions.

func (*BindingSet[T]) Bind added in v0.23.0

func (s *BindingSet[T]) Bind(id NodeID, obj T)

Bind binds the object to the node with the given ID.

func (*BindingSet[T]) Get added in v0.23.0

func (s *BindingSet[T]) Get(id NodeID) T

Get returns the object bound to the node with the given ID. If one is not found, the zero value is returned.

func (*BindingSet[T]) Unbind added in v0.23.0

func (s *BindingSet[T]) Unbind(id NodeID, notify bool) (T, bool)

Unbind unbinds the object from its node.

type DeleteCallback added in v0.23.0

type DeleteCallback func(scene *Scene, id NodeID)

DeleteCallback is a function type for callbacks that are invoked when a node is about to be deleted.

type DeleteSubscription added in v0.23.0

type DeleteSubscription = observer.Subscription[DeleteCallback]

DeleteSubscription represents a notification subscription for node deletions.

type DeleteSubscriptionSet added in v0.23.0

type DeleteSubscriptionSet = observer.SubscriptionSet[DeleteCallback]

DeleteSubscriptionSet represents a set of deletion subscriptions.

func NewDeleteSubscriptionSet added in v0.23.0

func NewDeleteSubscriptionSet() *DeleteSubscriptionSet

NewDeleteSubscriptionSet creates a new DeleteSubscriptionSet.

type InterpolationBinding added in v0.23.0

type InterpolationBinding[T BindingObject] interface {
	Binding[T]

	// OnNodeToInterpolation is called when the node's state should be applied to
	// the target, using interpolation.
	OnNodeToInterpolation(*Scene, NodeID, T, float64)
}

InterpolationBinding represents a binding between a node and a target that needs to use interpolated state from the node.

type InterpolationBindingSet added in v0.23.0

type InterpolationBindingSet[T BindingObject] struct {
	*BindingSet[T]
	// contains filtered or unexported fields
}

InterpolationBindingSet represents a set of interpolation bindings for a specific object type.

func NewInterpolationBindingSet added in v0.23.0

func NewInterpolationBindingSet[T BindingObject](scene *Scene, binding InterpolationBinding[T]) *InterpolationBindingSet[T]

InterpolationBindingSet creates a binding set that tracks deletions and notifies when the node should be applied to the target using interpolation.

func (*InterpolationBindingSet[T]) ApplyNodeToInterpolation added in v0.23.0

func (s *InterpolationBindingSet[T]) ApplyNodeToInterpolation(id NodeID, fraction float64)

ApplyNodeToInterpolation applies the state of the node to its target using interpolation.

type InterpolationCallback added in v0.23.0

type InterpolationCallback func(scene *Scene, id NodeID, fraction float64)

InterpolationCallback is a function type for callbacks that are invoked when a target needs to be interpolated from the node.

type InterpolationSubscription added in v0.23.0

type InterpolationSubscription = observer.Subscription[InterpolationCallback]

InterpolationSubscription represents a notification subscription for interpolation updates.

type InterpolationSubscriptionSet added in v0.23.0

type InterpolationSubscriptionSet = observer.SubscriptionSet[InterpolationCallback]

InterpolationSubscriptionSet represents a set of interpolation subscriptions.

func NewInterpolationSubscriptionSet added in v0.23.0

func NewInterpolationSubscriptionSet() *InterpolationSubscriptionSet

NewInterpolationSubscriptionSet creates a new InterpolationSubscriptionSet.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is a wrapper over a NodeID that simplifies interactions related to the node.

It should not be persisted for long-term use.

func (Node) AbsoluteMatrix

func (n Node) AbsoluteMatrix() dprec.Mat4

AbsoluteMatrix returns the absolute transformation matrix of the node.

func (Node) AppendChild

func (n Node) AppendChild(child Node, preserveWorldTransform bool)

AppendChild attaches the specified child node as the last child of this node.

func (Node) AppendSibling

func (n Node) AppendSibling(sibling Node, preserveWorldTransform bool)

AppendSibling attaches the specified sibling node as the right sibling of this node.

func (Node) BaseMatrix added in v0.23.0

func (n Node) BaseMatrix() dprec.Mat4

BaseMatrix returns the base transformation matrix of the node with the specified ID - this is the absolute matrix of the parent, if there is one, or the identity matrix otherwise.

func (Node) Delete added in v0.19.0

func (n Node) Delete()

Delete removes the node from the scene.

func (Node) Detach

func (n Node) Detach(preserveWorldTransform bool)

Detach detaches the node from its parent. If preserveWorldTransform is true, the world transform of the node is preserved.

func (Node) FindNode

func (n Node) FindNode(name string) Node

FindNode searches for a node with the specified name in the subtree rooted at this node. It returns a nil Node if no such node is found.

func (Node) FirstChild

func (n Node) FirstChild() Node

FirstChild returns the first child of the node, or a nil Node if it has no children.

func (Node) HasParent added in v0.23.0

func (n Node) HasParent() bool

HasParent returns whether the node has a parent.

func (Node) ID added in v0.23.0

func (n Node) ID() NodeID

ID returns the NodeID of the node.

func (Node) InitializeMatrix added in v0.23.0

func (n Node) InitializeMatrix(matrix dprec.Mat4)

InitializeMatrix initializes the local transformation matrix of the node with the specified ID, avoiding interpolation with previous value.

func (Node) InitializePosition added in v0.23.0

func (n Node) InitializePosition(position dprec.Vec3)

InitializePosition initializes the local position of the node with the specified ID, avoiding interpolation with previous value.

func (Node) InitializeRotation added in v0.23.0

func (n Node) InitializeRotation(rotation dprec.Quat)

InitializeRotation initializes the local rotation of the node with the specified ID, avoiding interpolation with previous value.

func (Node) InitializeScale added in v0.23.0

func (n Node) InitializeScale(scale dprec.Vec3)

InitializeScale initializes the local scale of the node with the specified ID, avoiding interpolation with previous value.

func (Node) InterpolatedAbsoluteMatrix added in v0.23.0

func (n Node) InterpolatedAbsoluteMatrix(alpha float64) dprec.Mat4

InterpolatedAbsoluteMatrix returns the interpolated absolute transformation matrix of the node, based on the specified alpha value in the range [0, 1].

func (Node) IsAncestorOf added in v0.23.0

func (n Node) IsAncestorOf(descendant Node) bool

IsAncestorOf returns whether the node is an ancestor of the specified descendant node.

func (Node) IsIndependent added in v0.23.0

func (n Node) IsIndependent() bool

IsIndependent returns whether the node is independent (i.e., not affected by parent transforms).

func (Node) IsNil added in v0.23.0

func (n Node) IsNil() bool

IsNil returns whether the Node is nil.

func (Node) IsValid added in v0.23.0

func (n Node) IsValid() bool

IsValid returns whether the Node is valid.

func (Node) IsVisible added in v0.23.0

func (n Node) IsVisible() bool

IsVisible returns whether the node is visible.

func (Node) LastChild

func (n Node) LastChild() Node

LastChild returns the last child of the node, or a nil Node if it has no children.

func (Node) LeftSibling

func (n Node) LeftSibling() Node

LeftSibling returns the left sibling of the node, or a nil Node if it has no left sibling.

func (Node) Matrix

func (n Node) Matrix() dprec.Mat4

Matrix returns the local transformation matrix of the node.

func (Node) Name

func (n Node) Name() string

Name returns the name of the node.

func (Node) Parent

func (n Node) Parent() Node

Parent returns the parent of the node, or a nil Node if it has no parent.

func (Node) Position

func (n Node) Position() dprec.Vec3

Position returns the local position of the node.

func (Node) PrependChild

func (n Node) PrependChild(child Node, preserveWorldTransform bool)

PrependChild attaches the specified child node as the first child of this node.

func (Node) PrependSibling

func (n Node) PrependSibling(sibling Node, preserveWorldTransform bool)

PrependSibling attaches the specified sibling node as the left sibling of this node.

func (Node) ResetDelta added in v0.23.0

func (n Node) ResetDelta(recursive bool)

ResetDelta resets the delta state of the node. If recursive is true, the delta state of all descendants is also reset.

func (Node) RightSibling

func (n Node) RightSibling() Node

RightSibling returns the right sibling of the node, or a nil Node if it has no right sibling.

func (Node) Rotation

func (n Node) Rotation() dprec.Quat

Rotation returns the local rotation of the node.

func (Node) Scale

func (n Node) Scale() dprec.Vec3

Scale returns the local scale of the node.

func (Node) SetAbsoluteMatrix

func (n Node) SetAbsoluteMatrix(matrix dprec.Mat4)

SetAbsoluteMatrix sets the absolute transformation matrix of the node. This is a convenience method that sets the local transformation matrix accordingly.

func (Node) SetIndependent added in v0.23.0

func (n Node) SetIndependent(independent bool)

SetIndependent sets whether the node is independent (i.e., not affected by parent transforms).

func (Node) SetMatrix

func (n Node) SetMatrix(matrix dprec.Mat4)

SetMatrix sets the local transformation matrix of the node.

func (Node) SetName

func (n Node) SetName(name string)

SetName sets the name of the node.

func (Node) SetPosition

func (n Node) SetPosition(position dprec.Vec3)

SetPosition sets the local position of the node.

func (Node) SetRotation

func (n Node) SetRotation(rotation dprec.Quat)

SetRotation sets the local rotation of the node.

func (Node) SetScale

func (n Node) SetScale(scale dprec.Vec3)

SetScale sets the local scale of the node.

func (Node) SetTransformFunc added in v0.23.0

func (n Node) SetTransformFunc(transformFunc TransformFunc)

SetTransformFunc sets the custom transformation function of the node.

func (Node) SetVisible added in v0.23.0

func (n Node) SetVisible(visible bool)

SetVisible sets whether the node is visible.

func (Node) TransformFunc added in v0.23.0

func (n Node) TransformFunc() TransformFunc

TransformFunc returns the custom transformation function of the node.

func (Node) TreeIter added in v0.23.0

func (n Node) TreeIter() iter.Seq[Node]

TreeIter returns an iterator that traverses the node and all its descendants in depth-first order.

func (Node) Visit added in v0.22.0

func (n Node) Visit(visitor func(Node) bool)

Visit visits the node and all its descendants in depth-first order, calling the specified visitor function for each node. If the visitor function returns false, the traversal is stopped.

type NodeID added in v0.23.0

type NodeID struct {
	// contains filtered or unexported fields
}

NodeID represents a unique identifier for a node in the scene.

func (NodeID) IsNil added in v0.23.0

func (id NodeID) IsNil() bool

IsNil returns whether the NodeID is nil.

type Scene added in v0.23.0

type Scene struct {
	// contains filtered or unexported fields
}

func NewScene added in v0.23.0

func NewScene(initialCapacity int) *Scene

NewScene creates a new scene with the specified initial capacity for nodes.

func (*Scene) AppendNodeChild added in v0.23.0

func (s *Scene) AppendNodeChild(parentID, childID NodeID, preserveWorldTransform bool)

AppendNodeChild attaches the node with the specified childID as the last child of the node with the specified parentID.

func (*Scene) AppendNodeSibling added in v0.23.0

func (s *Scene) AppendNodeSibling(currentID, siblingID NodeID, preserveWorldTransform bool)

AppendNodeSibling attaches the node with the specified siblingID to the right of the node with the specified ID.

func (*Scene) ApplyNodeToInterpolation added in v0.23.0

func (s *Scene) ApplyNodeToInterpolation(id NodeID, fraction float64, recursive bool)

ApplyNodeToInterpolation applies the state of the node with the specified ID to its interpolation target.

If recursive is true, the state is applied to all descendant nodes as well.

func (*Scene) ApplyNodeToTarget added in v0.23.0

func (s *Scene) ApplyNodeToTarget(id NodeID, recursive bool)

ApplyNodeToTarget applies the state of the node with the specified ID to its target.

If recursive is true, the state is applied to all descendant nodes as well.

func (*Scene) ApplyNodesToInterpolations added in v0.23.0

func (s *Scene) ApplyNodesToInterpolations(fraction float64)

ApplyNodesToInterpolations applies the state of all nodes to their interpolation targets.

func (*Scene) ApplyNodesToTargets added in v0.23.0

func (s *Scene) ApplyNodesToTargets()

ApplyNodesToTargets applies the state of all nodes to their targets.

func (*Scene) ApplySourceToTarget added in v0.23.0

func (s *Scene) ApplySourceToTarget(rootID NodeID, recursive bool)

ApplySourceToTarget applies the state of the source to its target.

If recursive is true, the state is applied to all descendant nodes as well.

func (*Scene) ApplySourcesToNodes added in v0.23.0

func (s *Scene) ApplySourcesToNodes()

ApplySourcesToNodes applies the state of the sources to their nodes.

func (*Scene) CreateNode added in v0.23.0

func (s *Scene) CreateNode() NodeID

CreateNode creates a new node in the scene and returns its ID.

func (*Scene) DeleteNode added in v0.23.0

func (s *Scene) DeleteNode(id NodeID)

DeleteNode deletes the node with the specified ID, as well as any children, from the scene.

func (*Scene) DetachNode added in v0.23.0

func (s *Scene) DetachNode(id NodeID, preserveWorldTransform bool)

DetachNode detaches the node with the specified ID from its parent.

func (*Scene) FindNode added in v0.23.0

func (s *Scene) FindNode(name string) NodeID

FindNode returns the first found node with the specified name or NilNodeID if no such node exists.

The search order is arbitrary and should not be relied upon, hence use this method for nodes that have unique names only.

func (*Scene) FindSubtreeNode added in v0.23.0

func (s *Scene) FindSubtreeNode(rootID NodeID, name string) NodeID

FindSubtreeNode returns the first found node with the specified name in the subtree rooted at the node with the specified ID or NilNodeID if no such node exists.

func (*Scene) InitializeNodeMatrix added in v0.23.0

func (s *Scene) InitializeNodeMatrix(id NodeID, matrix dprec.Mat4)

InitializeNodeMatrix initializes the local transformation matrix of the node with the specified ID, avoiding interpolation with previous value.

func (*Scene) InitializeNodePosition added in v0.23.0

func (s *Scene) InitializeNodePosition(id NodeID, position dprec.Vec3)

InitializeNodePosition initializes the local position of the node with the specified ID, avoiding interpolation with previous value.

If multiple aspects are initialized, it is best to use the Set methods followed by a ResetNodeDelta call.

func (*Scene) InitializeNodeRotation added in v0.23.0

func (s *Scene) InitializeNodeRotation(id NodeID, rotation dprec.Quat)

InitializeNodeRotation initializes the local rotation of the node with the specified ID, avoiding interpolation with previous value.

If multiple aspects are initialized, it is best to use the Set methods followed by a ResetNodeDelta call.

func (*Scene) InitializeNodeScale added in v0.23.0

func (s *Scene) InitializeNodeScale(id NodeID, scale dprec.Vec3)

InitializeNodeScale initializes the local scale of the node with the specified ID, avoiding interpolation with previous value.

If multiple aspects are initialized, it is best to use the Set methods followed by a ResetNodeDelta call.

func (*Scene) IsNodeChain added in v0.23.0

func (s *Scene) IsNodeChain(rootID, leafID NodeID) bool

IsNodeChain returns whether the node with the specified leaf ID is a descendant of the node with the specified root ID.

func (*Scene) IsNodeIndependent added in v0.23.0

func (s *Scene) IsNodeIndependent(id NodeID) bool

IsNodeIndependent returns whether the node with the specified ID is marked as independent (i.e. not affected by parent transformations).

func (*Scene) IsNodeVisible added in v0.23.0

func (s *Scene) IsNodeVisible(id NodeID) bool

IsNodeVisible returns whether the node with the specified ID is marked as visible.

func (*Scene) IsValidNode added in v0.23.0

func (s *Scene) IsValidNode(id NodeID) bool

IsValidNode returns whether the specified ID represents a valid node in the scene.

func (*Scene) NodeAbsoluteMatrix added in v0.23.0

func (s *Scene) NodeAbsoluteMatrix(id NodeID) dprec.Mat4

NodeAbsoluteMatrix returns the absolute transformation matrix of the node with the specified ID.

func (*Scene) NodeBaseMatrix added in v0.23.0

func (s *Scene) NodeBaseMatrix(id NodeID) dprec.Mat4

NodeBaseMatrix returns the base transformation matrix of the node with the specified ID - this is the absolute matrix of the parent, if there is one, or the identity matrix otherwise.

func (*Scene) NodeFirstChild added in v0.23.0

func (s *Scene) NodeFirstChild(id NodeID) NodeID

NodeFirstChild returns the ID of the first child of the node with the specified ID.

func (*Scene) NodeHasParent added in v0.23.0

func (s *Scene) NodeHasParent(id NodeID) bool

NodeHasParent returns whether the node with the specified ID has a parent.

func (*Scene) NodeInterpolatedAbsoluteMatrix added in v0.23.0

func (s *Scene) NodeInterpolatedAbsoluteMatrix(id NodeID, fraction float64) dprec.Mat4

NodeInterpolatedAbsoluteMatrix returns the absolute transformation matrix of the node with the specified ID, interpolated between the previous and current states by the specified fraction in [0, 1].

func (*Scene) NodeLastChild added in v0.23.0

func (s *Scene) NodeLastChild(id NodeID) NodeID

NodeLastChild returns the ID of the last child of the node with the specified ID.

func (*Scene) NodeLeftSibling added in v0.23.0

func (s *Scene) NodeLeftSibling(id NodeID) NodeID

NodeLeftSibling returns the ID of the left sibling of the node with the specified ID.

func (*Scene) NodeMatrix added in v0.23.0

func (s *Scene) NodeMatrix(id NodeID) dprec.Mat4

NodeMatrix returns the local transformation matrix of the node with the specified ID.

func (*Scene) NodeName added in v0.23.0

func (s *Scene) NodeName(id NodeID) string

NodeName returns the name of the node with the specified ID.

func (*Scene) NodeParent added in v0.23.0

func (s *Scene) NodeParent(id NodeID) NodeID

NodeParent returns the ID of the parent of the node with the specified ID.

func (*Scene) NodePosition added in v0.23.0

func (s *Scene) NodePosition(id NodeID) dprec.Vec3

NodePosition returns the local position of the node with the specified ID.

func (*Scene) NodeRightSibling added in v0.23.0

func (s *Scene) NodeRightSibling(id NodeID) NodeID

NodeRightSibling returns the ID of the right sibling of the node with the specified ID.

func (*Scene) NodeRotation added in v0.23.0

func (s *Scene) NodeRotation(id NodeID) dprec.Quat

NodeRotation returns the local rotation of the node with the specified ID.

func (*Scene) NodeScale added in v0.23.0

func (s *Scene) NodeScale(id NodeID) dprec.Vec3

NodeScale returns the local scale of the node with the specified ID.

func (*Scene) NodeTransformFunc added in v0.23.0

func (s *Scene) NodeTransformFunc(id NodeID) TransformFunc

NodeTransformFunc returns the custom transformation function of the node with the specified ID.

func (*Scene) NodesIter added in v0.23.0

func (s *Scene) NodesIter() iter.Seq[NodeID]

NodesIter returns an iterator that traverses all the nodes in a depth-first manner.

func (*Scene) PrependNodeChild added in v0.23.0

func (s *Scene) PrependNodeChild(parentID, childID NodeID, preserveWorldTransform bool)

PrependNodeChild attaches the node with the specified childID as the first child of the node with the specified parentID.

func (*Scene) PrependNodeSibling added in v0.23.0

func (s *Scene) PrependNodeSibling(currentID, siblingID NodeID, preserveWorldTransform bool)

PrependNodeSibling attaches the node with the specified siblingID to the left of the node with the specified ID.

func (*Scene) ResetDelta added in v0.23.0

func (s *Scene) ResetDelta()

ResetDelta resets the delta state of all nodes in the scene.

func (*Scene) ResetNodeDelta added in v0.23.0

func (s *Scene) ResetNodeDelta(id NodeID, recursive bool)

ResetNodeDelta resets the delta state of the node with the specified ID.

If recursive is true, the delta state of all descendant nodes is also reset.

func (*Scene) RootNodesIter added in v0.23.0

func (s *Scene) RootNodesIter() iter.Seq[NodeID]

RootNodesIter returns an iterator that traverses all root nodes in the scene.

func (*Scene) SetNodeAbsoluteMatrix added in v0.23.0

func (s *Scene) SetNodeAbsoluteMatrix(id NodeID, matrix dprec.Mat4)

SetNodeAbsoluteMatrix sets the absolute transformation matrix of the node with the specified ID.

func (*Scene) SetNodeIndependent added in v0.23.0

func (s *Scene) SetNodeIndependent(id NodeID, independent bool)

SetNodeIndependent sets whether the node with the specified ID is marked as independent (i.e. not affected by parent transformations).

func (*Scene) SetNodeMatrix added in v0.23.0

func (s *Scene) SetNodeMatrix(id NodeID, matrix dprec.Mat4)

SetNodeMatrix sets the local transformation matrix of the node with the specified ID.

func (*Scene) SetNodeName added in v0.23.0

func (s *Scene) SetNodeName(id NodeID, name string)

SetNodeName sets the name of the node with the specified ID.

func (*Scene) SetNodePosition added in v0.23.0

func (s *Scene) SetNodePosition(id NodeID, position dprec.Vec3)

SetNodePosition sets the local position of the node with the specified ID.

func (*Scene) SetNodeRotation added in v0.23.0

func (s *Scene) SetNodeRotation(id NodeID, rotation dprec.Quat)

SetNodeRotation sets the local rotation of the node with the specified ID.

func (*Scene) SetNodeScale added in v0.23.0

func (s *Scene) SetNodeScale(id NodeID, scale dprec.Vec3)

SetNodeScale sets the local scale of the node with the specified ID.

func (*Scene) SetNodeTransformFunc added in v0.23.0

func (s *Scene) SetNodeTransformFunc(id NodeID, transformFunc TransformFunc)

SetNodeTransformFunc sets the custom transformation function of the node with the specified ID.

func (*Scene) SetNodeVisible added in v0.23.0

func (s *Scene) SetNodeVisible(id NodeID, visible bool)

SetNodeVisible sets whether the node with the specified ID is marked as visible.

func (*Scene) SubscribeInterpolationApply added in v0.23.0

func (s *Scene) SubscribeInterpolationApply(callback InterpolationCallback) *InterpolationSubscription

SubscribeInterpolationApply subscribes to events for interpolation applications.

func (*Scene) SubscribeNodeDelete added in v0.23.0

func (s *Scene) SubscribeNodeDelete(callback DeleteCallback) *DeleteSubscription

SubscribeNodeDelete subscribes to node deletion events.

func (*Scene) SubscribeSourceApply added in v0.23.0

func (s *Scene) SubscribeSourceApply(callback SourceCallback) *SourceSubscription

SubscribeSourceApply subscribes to events for source applications.

func (*Scene) SubscribeTargetApply added in v0.23.0

func (s *Scene) SubscribeTargetApply(callback TargetCallback) *TargetSubscription

SubscribeTargetApply subscribes to events for target applications.

func (*Scene) SubtreeIter added in v0.23.0

func (s *Scene) SubtreeIter(rootID NodeID) iter.Seq[NodeID]

SubtreeIter returns an iterator that traverses the subtree rooted at the node with the specified ID.

func (*Scene) Visit added in v0.23.0

func (s *Scene) Visit(callback func(NodeID) bool) bool

Visit traverses the all the nodes in a depth-first manner, invoking the specified callback for each node in the scene.

func (*Scene) VisitSubtree added in v0.23.0

func (s *Scene) VisitSubtree(rootID NodeID, callback func(NodeID) bool) bool

VisitSubtree traverses the subtree rooted at the node with the specified ID, invoking the specified callback for each node in the subtree.

func (*Scene) Wrap added in v0.23.0

func (s *Scene) Wrap(id NodeID) Node

Wrap creates a Node wrapper for the specified NodeID.

type SourceBinding added in v0.23.0

type SourceBinding[T BindingObject] interface {
	Binding[T]

	// OnSourceToNode is called when the source's state should be applied to the
	// node.
	OnSourceToNode(*Scene, T, NodeID)
}

SourceBinding represents a binding between a source of data to a node.

type SourceBindingSet added in v0.23.0

type SourceBindingSet[T BindingObject] struct {
	*BindingSet[T]
	// contains filtered or unexported fields
}

SourceBindingSet represents a set of source bindings for a specific object type.

func NewSourceBindingSet added in v0.23.0

func NewSourceBindingSet[T BindingObject](scene *Scene, binding SourceBinding[T]) *SourceBindingSet[T]

NewSourceBindingSet creates a binding set that tracks deletions and notifies when the source should be applied to the node.

func (*SourceBindingSet[T]) ApplySourceToNode added in v0.23.0

func (s *SourceBindingSet[T]) ApplySourceToNode(id NodeID)

ApplyTargetToNode applies the state of the target to its node.

type SourceCallback added in v0.23.0

type SourceCallback func(scene *Scene, id NodeID)

SourceCallback is a function type for callbacks that are invoked when a source needs to be applied to a node.

type SourceSubscription added in v0.23.0

type SourceSubscription = observer.Subscription[SourceCallback]

SourceSubscription represents a notification subscription for source updates.

type SourceSubscriptionSet added in v0.23.0

type SourceSubscriptionSet = observer.SubscriptionSet[SourceCallback]

SourceSubscriptionSet represents a set of source subscriptions.

func NewSourceSubscriptionSet added in v0.23.0

func NewSourceSubscriptionSet() *SourceSubscriptionSet

NewSourceSubscriptionSet creates a new SourceSubscriptionSet.

type TargetBinding added in v0.23.0

type TargetBinding[T BindingObject] interface {
	Binding[T]

	// OnNodeToTarget is called when the node's state should be applied to the
	// target.
	OnNodeToTarget(*Scene, NodeID, T)
}

TargetBinding represents a binding between a node and a target.

type TargetBindingSet added in v0.23.0

type TargetBindingSet[T BindingObject] struct {
	*BindingSet[T]
	// contains filtered or unexported fields
}

TargetBindingSet represents a set of target bindings for a specific object type.

func NewTargetBindingSet added in v0.23.0

func NewTargetBindingSet[T BindingObject](scene *Scene, binding TargetBinding[T]) *TargetBindingSet[T]

NewTargetBindingSet creates a binding set that tracks deletions and notifies when the node should be applied to the target.

func (*TargetBindingSet[T]) ApplyNodeToTarget added in v0.23.0

func (s *TargetBindingSet[T]) ApplyNodeToTarget(id NodeID)

ApplyNodeToTarget applies the state of the node to its target.

type TargetCallback added in v0.23.0

type TargetCallback func(scene *Scene, id NodeID)

TargetCallback is a function type for callbacks that are invoked when a target needs to be applied from a node.

type TargetSubscription added in v0.23.0

type TargetSubscription = observer.Subscription[TargetCallback]

TargetSubscription represents a notification subscription for target updates.

type TargetSubscriptionSet added in v0.23.0

type TargetSubscriptionSet = observer.SubscriptionSet[TargetCallback]

TargetSubscriptionSet represents a set of target subscriptions.

func NewTargetSubscriptionSet added in v0.23.0

func NewTargetSubscriptionSet() *TargetSubscriptionSet

NewTargetSubscriptionSet creates a new TargetSubscriptionSet.

type TransformFunc

type TransformFunc func(scene *Scene, node NodeID) dprec.Mat4

TransformFunc is a mechanism to calculate a custom absolute matrix for the node from its local state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL