game

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 24 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("resource not found")

ErrNotFound indicates that a resource was not found.

Functions

func DirectionalLightFromNode added in v0.19.0

func DirectionalLightFromNode(node *hierarchy.Node) *graphics.DirectionalLight

func PointLightFromNode added in v0.21.0

func PointLightFromNode(node *hierarchy.Node) *graphics.PointLight

func SpotLightFromNode added in v0.21.0

func SpotLightFromNode(node *hierarchy.Node) *graphics.SpotLight

Types

type AdjustedAnimation added in v0.19.1

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

AdjustedAnimation is a decorator for an animation source that allows adjusting the playback speed.

func NewAdjustedAnimation added in v0.19.1

func NewAdjustedAnimation(delegate AnimationSource) *AdjustedAnimation

NewAdjustedAnimation creates a new adjusted animation source with the specified delegate.

func (*AdjustedAnimation) Length added in v0.19.1

func (a *AdjustedAnimation) Length() float64

Length returns the length of the animation in seconds.

func (*AdjustedAnimation) NodeTransform added in v0.19.1

func (a *AdjustedAnimation) NodeTransform(name string) NodeTransform

NodeTransform returns the transformation of the node with the specified name at the current time position.

func (*AdjustedAnimation) Position added in v0.19.1

func (a *AdjustedAnimation) Position() float64

Position returns the current position of the animation in seconds.

func (*AdjustedAnimation) SetPosition added in v0.19.1

func (a *AdjustedAnimation) SetPosition(position float64)

SetPosition sets the current position of the animation in seconds.

func (*AdjustedAnimation) SetSpeed added in v0.19.1

func (a *AdjustedAnimation) SetSpeed(speed float64)

SetSpeed sets the playback speed of the animation.

func (*AdjustedAnimation) Source added in v0.19.1

func (a *AdjustedAnimation) Source() AnimationSource

Source returns the underlying animation source.

func (*AdjustedAnimation) Speed added in v0.19.1

func (a *AdjustedAnimation) Speed() float64

Speed returns the current playback speed of the animation. A value of 1.0 means that the animation is played at normal speed.

type AmbientLightInfo added in v0.19.0

type AmbientLightInfo struct {
	ReflectionTexture render.Texture
	RefractionTexture render.Texture
	OuterRadius       opt.T[float64]
	InnerRadius       opt.T[float64]
	CastShadow        opt.T[bool]
}

AmbientLightInfo contains the information required to create an ambient light.

type AmbientLightNodeTarget added in v0.19.0

type AmbientLightNodeTarget struct {
	Light *graphics.AmbientLight
}

func (AmbientLightNodeTarget) ApplyFrom added in v0.19.0

func (t AmbientLightNodeTarget) ApplyFrom(node *hierarchy.Node)

func (AmbientLightNodeTarget) Release added in v0.19.0

func (t AmbientLightNodeTarget) Release()

type Animation added in v0.9.0

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

Animation represents an instantiation of a keyframe animation.

func (*Animation) BindingTransform added in v0.19.0

func (a *Animation) BindingTransform(name string, timestamp float64) NodeTransform

BindingTransform returns the transformation of the node with the specified name at the specified time position.

func (*Animation) EndTime added in v0.9.0

func (a *Animation) EndTime() float64

EndTime returns the time (in seconds) at which the animation ends.

func (*Animation) Length added in v0.9.0

func (a *Animation) Length() float64

Length returns the length of the animation in seconds.

func (*Animation) Loop added in v0.19.1

func (a *Animation) Loop() bool

Loop returns whether the animation should loop.

func (*Animation) Name added in v0.9.0

func (a *Animation) Name() string

Name returns the name of the animation.

func (*Animation) Playback added in v0.19.1

func (a *Animation) Playback() *AnimationPlayback

Playback creates a new AnimationPlayback that plays back the animation.

func (*Animation) StartTime added in v0.9.0

func (a *Animation) StartTime() float64

StartTime returns the time (in seconds) at which the animation starts.

type AnimationBindingDefinitionInfo added in v0.9.0

type AnimationBindingDefinitionInfo struct {

	// NodeName is the name of the node that is affected by the animation.
	NodeName string

	// TranslationKeyframes is a list of keyframes that define the translation
	// of the node.
	TranslationKeyframes KeyframeList[dprec.Vec3]

	// RotationKeyframes is a list of keyframes that define the rotation of the
	// node.
	RotationKeyframes KeyframeList[dprec.Quat]

	// ScaleKeyframes is a list of keyframes that define the scale of the node.
	ScaleKeyframes KeyframeList[dprec.Vec3]
}

AnimationBindingDefinitionInfo contains the information required to define an animation node binding.

type AnimationDefinition added in v0.9.0

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

AnimationDefinition represents a definition of an animation.

func (*AnimationDefinition) EndTime added in v0.19.1

func (d *AnimationDefinition) EndTime() float64

EndTime returns the time (in seconds) at which the animation ends.

func (*AnimationDefinition) Loop added in v0.19.1

func (d *AnimationDefinition) Loop() bool

Loop returns whether the animation should loop.

func (*AnimationDefinition) Name added in v0.19.0

func (d *AnimationDefinition) Name() string

Name returns the name of the animation.

func (*AnimationDefinition) NodeNames added in v0.19.1

func (d *AnimationDefinition) NodeNames() []string

NodeNames returns the names of the nodes that are animated by the animation.

func (*AnimationDefinition) StartTime added in v0.19.1

func (d *AnimationDefinition) StartTime() float64

StartTime returns the time (in seconds) at which the animation starts.

type AnimationDefinitionInfo added in v0.9.0

type AnimationDefinitionInfo struct {

	// Name is the name of the animation.
	Name string

	// StartTime is the time (in seconds) at which the animation starts.
	StartTime float64

	// EndTime is the time (in seconds) at which the animation ends.
	EndTime float64

	// Loop specifies whether the animation should loop.
	Loop bool

	// Bindings is a list of node bindings that are affected by the animation.
	Bindings []AnimationBindingDefinitionInfo
}

AnimationDefinitionInfo contains the information required to define an animation.

type AnimationInfo added in v0.9.0

type AnimationInfo struct {

	// Definition is the definition of the animation.
	Definition *AnimationDefinition

	// ClipStart, if specified, overrides the start time of the animation.
	ClipStart opt.T[float64]

	// ClipEnd, if specified, overrides the end time of the animation.
	ClipEnd opt.T[float64]

	// Loop, if specified, overrides the loop setting of the animation.
	Loop opt.T[bool]
}

AnimationInfo represents an instantiation of an animation instance.

type AnimationMask added in v0.19.1

type AnimationMask struct {
	AnimationSource
	// contains filtered or unexported fields
}

AnimationMask is an animation source that picks specific bones from another animation source.

func NewAnimationMask added in v0.19.1

func NewAnimationMask(delegate AnimationSource, selection filter.Func[string]) *AnimationMask

NewAnimationMask creates a new AnimationSource that picks specific bones from the specified AnimationSource.

func (*AnimationMask) NodeTransform added in v0.19.1

func (m *AnimationMask) NodeTransform(name string) NodeTransform

NodeTransform returns the transformation of the node with the specified name at the current time position.

type AnimationNodeSource added in v0.19.0

type AnimationNodeSource struct {
	Source AnimationSource
}

func (AnimationNodeSource) ApplyTo added in v0.19.0

func (s AnimationNodeSource) ApplyTo(node *hierarchy.Node)

func (AnimationNodeSource) Release added in v0.19.0

func (s AnimationNodeSource) Release()

type AnimationPlayback added in v0.19.1

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

AnimationPlayback represents an animation source that plays back an animation.

func NewAnimationPlayback added in v0.19.1

func NewAnimationPlayback(animation *Animation) *AnimationPlayback

NewAnimationPlayback creates a new AnimationSource using the specified Animation.

func (*AnimationPlayback) Length added in v0.19.1

func (p *AnimationPlayback) Length() float64

Length returns the length of the animation in seconds.

func (*AnimationPlayback) Loop added in v0.19.1

func (p *AnimationPlayback) Loop() bool

Loop returns whether the animation should loop.

func (*AnimationPlayback) NodeTransform added in v0.19.1

func (p *AnimationPlayback) NodeTransform(name string) NodeTransform

NodeTransform returns the transformation of the node with the specified name at the current time position.

func (*AnimationPlayback) Position added in v0.19.1

func (p *AnimationPlayback) Position() float64

Position returns the current position of the animation in seconds.

func (*AnimationPlayback) SetLoop added in v0.19.1

func (p *AnimationPlayback) SetLoop(loop bool) *AnimationPlayback

SetLoop sets whether the animation should loop.

func (*AnimationPlayback) SetPosition added in v0.19.1

func (p *AnimationPlayback) SetPosition(position float64)

SetPosition sets the current position of the animation in seconds.

type AnimationSource added in v0.19.0

type AnimationSource interface {

	// Length returns the length of the animation in seconds.
	Length() float64

	// Position returns the current position of the animation in seconds.
	Position() float64

	// SetPosition sets the current position of the animation in seconds.
	SetPosition(position float64)

	// NodeTransform returns the transformation of the node with the
	// specified name at the current time position.
	NodeTransform(name string) NodeTransform
}

AnimationSource represents a source of animation data.

type BodyNodeSource added in v0.14.0

type BodyNodeSource struct {
	Body physics.Body
}

func (BodyNodeSource) ApplyTo added in v0.14.0

func (s BodyNodeSource) ApplyTo(node *hierarchy.Node)

func (BodyNodeSource) Release added in v0.19.0

func (s BodyNodeSource) Release()

type BoneNodeTarget added in v0.14.0

type BoneNodeTarget struct {
	Armature  *graphics.Armature
	BoneIndex int
}

func (BoneNodeTarget) ApplyFrom added in v0.14.0

func (t BoneNodeTarget) ApplyFrom(node *hierarchy.Node)

func (BoneNodeTarget) Release added in v0.19.0

func (t BoneNodeTarget) Release()

type CameraNodeTarget added in v0.14.0

type CameraNodeTarget struct {
	Camera *graphics.Camera
}

func (CameraNodeTarget) ApplyFrom added in v0.14.0

func (t CameraNodeTarget) ApplyFrom(node *hierarchy.Node)

func (CameraNodeTarget) Release added in v0.19.0

func (t CameraNodeTarget) Release()

type Controller

type Controller struct {
	app.NopController
	// contains filtered or unexported fields
}

Controller is an implementation of the app.Controller interface which initializes a game engine and manages its lifecycle. Furthermore, it ensures that the game engine is updated and rendered on each frame.

func NewController added in v0.9.0

func NewController(registry *asset.Registry, shaders graphics.ShaderCollection, shaderBuilder graphics.ShaderBuilder) *Controller

NewController creates a new game controller that manages the lifecycle of a game engine. The controller will use the provided asset registry to load and manage assets. The provided shader collection will be used to render the game. The provided shader builder will be used to create new shaders when needed.

func (*Controller) Engine added in v0.9.0

func (c *Controller) Engine() *Engine

Engine returns the game engine that is managed by the controller.

This method should only be called after the controller has been initialized by the app framework.

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) OnFramebufferResize added in v0.12.0

func (c *Controller) OnFramebufferResize(window app.Window, width, height int)

func (*Controller) OnRender added in v0.9.0

func (c *Controller) OnRender(window app.Window)

func (*Controller) Registry added in v0.19.0

func (c *Controller) Registry() *asset.Registry

Registry returns the asset registry to be used by the game.

func (*Controller) UseECSOptions added in v0.20.0

func (c *Controller) UseECSOptions(opts ...ecs.Option)

UseECSOptions allows to specify options that will be used when initializing the ECS engine. This method should be called before the controller is initialized by the app framework.

func (*Controller) UseGraphicsOptions added in v0.20.0

func (c *Controller) UseGraphicsOptions(opts ...graphics.Option)

UseGraphicsOptions allows to specify options that will be used when initializing the graphics engine. This method should be called before the controller is initialized by the app framework.

func (*Controller) UsePhysicsOptions added in v0.20.0

func (c *Controller) UsePhysicsOptions(opts ...physics.Option)

UsePhysicsOptions allows to specify options that will be used when initializing the physics engine. This method should be called before the controller is initialized by the app framework.

type DirectionalLightInfo added in v0.19.0

type DirectionalLightInfo struct {
	EmitColor  opt.T[dprec.Vec3]
	CastShadow opt.T[bool]
}

DirectionalLightInfo contains the information required to create a directional light.

type DirectionalLightNodeTarget added in v0.14.0

type DirectionalLightNodeTarget struct {
	Light                 *graphics.DirectionalLight
	UseOnlyParentPosition bool
}

func (DirectionalLightNodeTarget) ApplyFrom added in v0.14.0

func (t DirectionalLightNodeTarget) ApplyFrom(node *hierarchy.Node)

func (DirectionalLightNodeTarget) Release added in v0.19.0

func (t DirectionalLightNodeTarget) Release()

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 (e *Engine) ActiveScene() *Scene

func (*Engine) Create added in v0.9.0

func (e *Engine) Create()

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 (e *Engine) CreateScene() *Scene

func (*Engine) Destroy added in v0.9.0

func (e *Engine) Destroy()

func (*Engine) ECS added in v0.9.0

func (e *Engine) ECS() *ecs.Engine

func (*Engine) GFXWorker added in v0.9.0

func (e *Engine) GFXWorker() Worker

func (*Engine) Graphics added in v0.9.0

func (e *Engine) Graphics() *graphics.Engine

func (*Engine) IOWorker added in v0.9.0

func (e *Engine) IOWorker() Worker

func (*Engine) Physics added in v0.9.0

func (e *Engine) Physics() *physics.Engine

func (*Engine) Registry added in v0.9.0

func (e *Engine) Registry() *asset.Registry

func (*Engine) Render added in v0.9.0

func (e *Engine) Render(framebuffer render.Framebuffer, viewport graphics.Viewport)

func (*Engine) ResetDeltaTime added in v0.9.0

func (e *Engine) ResetDeltaTime()

func (*Engine) SetActiveScene added in v0.9.0

func (e *Engine) SetActiveScene(scene *Scene)

func (*Engine) Update added in v0.9.0

func (e *Engine) Update()

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 Keyframe added in v0.9.0

type Keyframe[T any] struct {
	Timestamp float64
	Value     T
}

Keyframe represents a single keyframe in an animation.

type KeyframeList added in v0.9.0

type KeyframeList[T any] []Keyframe[T]

KeyframeList is a list of keyframes.

func (KeyframeList[T]) Keyframe added in v0.9.0

func (l KeyframeList[T]) Keyframe(timestamp float64) (Keyframe[T], Keyframe[T], float64)

Keyframe returns the keyframes that are closest to the specified timestamp and the interpolation factor between them.

type MeshNodeTarget added in v0.14.0

type MeshNodeTarget struct {
	Mesh *graphics.Mesh
}

func (MeshNodeTarget) ApplyFrom added in v0.14.0

func (t MeshNodeTarget) ApplyFrom(node *hierarchy.Node)

func (MeshNodeTarget) Release added in v0.19.0

func (t MeshNodeTarget) Release()

type Model added in v0.9.0

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

func (*Model) AnimatedNodes added in v0.19.0

func (m *Model) AnimatedNodes() []*hierarchy.Node

func (*Model) Animations added in v0.9.0

func (m *Model) Animations() []*Animation

func (*Model) BindAnimationSource added in v0.19.0

func (m *Model) BindAnimationSource(source AnimationSource)

func (*Model) BodyInstances added in v0.9.0

func (m *Model) BodyInstances() []physics.Body

func (*Model) FindAnimation added in v0.9.0

func (m *Model) FindAnimation(name string) *Animation

func (*Model) FindNode added in v0.10.0

func (m *Model) FindNode(name string) *hierarchy.Node

func (*Model) Root added in v0.9.0

func (m *Model) Root() *hierarchy.Node

type ModelDefinition added in v0.9.0

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

func (*ModelDefinition) AnimatedNodeNames added in v0.19.0

func (d *ModelDefinition) AnimatedNodeNames() []string

func (*ModelDefinition) Animations added in v0.19.0

func (d *ModelDefinition) Animations() []*AnimationDefinition

func (*ModelDefinition) FindAnimation added in v0.9.0

func (d *ModelDefinition) FindAnimation(name string) *AnimationDefinition

func (*ModelDefinition) FindBlob added in v0.22.0

func (m *ModelDefinition) FindBlob(name string) []byte

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

	// RootNode specifies the name of the root node of the model to use, in which
	// case a wrapper root node will not be created. The selected root node will
	// be renamed to Name if it is specified.
	RootNode opt.T[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 opt.T[dprec.Vec3]

	// Rotation is used to specify a rotation for the model instance.
	Rotation opt.T[dprec.Quat]

	// Scale is used to specify a scale for the model instance.
	Scale opt.T[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
}

ModelInfo contains the information necessary to place a Model instance into a Scene.

type NodeTransform added in v0.19.0

type NodeTransform struct {

	// Translation, if specified, indicates the translation of the node.
	Translation opt.T[dprec.Vec3]

	// Rotation, if specified, indicates the rotation of the node.
	Rotation opt.T[dprec.Quat]

	// Scale, if specified, indicates the scale of the node.
	Scale opt.T[dprec.Vec3]
}

NodeTransform represents the transformation of a node.

func BlendNodeTransforms added in v0.19.1

func BlendNodeTransforms(first, second NodeTransform, factor float64) NodeTransform

BlendNodeTransforms blends two node transformations using the specified factor. A factor of 0.0 means that the first transformation is used, a factor of 1.0 means that the second transformation is used.

type PairAnimationBlending added in v0.19.1

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

PairAnimationBlending represents an animation source that blends two animation sources. The blending factor is determined by the factor field of the node.

func NewPairAnimationBlending added in v0.19.1

func NewPairAnimationBlending(first, second AnimationSource) *PairAnimationBlending

NewPairAnimationBlending creates a new pair animation blending node with the specified sources.

func (*PairAnimationBlending) Factor added in v0.19.1

func (n *PairAnimationBlending) Factor() float64

Factor returns the blending factor of the node. A value of 0.0 means that the first source is used, a value of 1.0 means that the second source is used. The value is clamped to the range [0.0, 1.0].

func (*PairAnimationBlending) First added in v0.19.1

First returns the first source of the node.

func (*PairAnimationBlending) Length added in v0.19.1

func (n *PairAnimationBlending) Length() float64

Length returns the length of the animation in seconds.

func (*PairAnimationBlending) NodeTransform added in v0.19.1

func (n *PairAnimationBlending) NodeTransform(name string) NodeTransform

NodeTransform returns the transformation of the node with the specified name. The transformation is a blend of the transformations of the two sources of the node.

func (*PairAnimationBlending) Position added in v0.19.1

func (n *PairAnimationBlending) Position() float64

Position returns the current position of the animation in seconds.

func (*PairAnimationBlending) Second added in v0.19.1

Second returns the second source of the node.

func (*PairAnimationBlending) SetFactor added in v0.19.1

func (n *PairAnimationBlending) SetFactor(factor float64)

SetFactor sets the blending factor of the node. The value is clamped to the range [0.0, 1.0].

func (*PairAnimationBlending) SetFirst added in v0.19.1

func (n *PairAnimationBlending) SetFirst(first AnimationSource)

SetFirst sets the first source of the node.

func (*PairAnimationBlending) SetPosition added in v0.19.1

func (n *PairAnimationBlending) SetPosition(position float64)

SetPosition sets the current position of the animation in seconds.

func (*PairAnimationBlending) SetSecond added in v0.19.1

func (n *PairAnimationBlending) SetSecond(second AnimationSource)

SetSecond sets the second source of the node.

func (*PairAnimationBlending) SetSynchronized added in v0.19.1

func (n *PairAnimationBlending) SetSynchronized(synchronized bool)

SetSynchronized sets whether the two sources of the node are synchronized.

func (*PairAnimationBlending) Synchronized added in v0.19.1

func (n *PairAnimationBlending) Synchronized() bool

Synchronized returns whether the two sources of the node are synchronized.

type PointLightInfo added in v0.19.0

type PointLightInfo struct {
	EmitColor    opt.T[dprec.Vec3]
	EmitDistance opt.T[float64]
	CastShadow   opt.T[bool]
}

PointLightInfo contains the information required to create a point light.

type PointLightNodeTarget added in v0.14.0

type PointLightNodeTarget struct {
	Light *graphics.PointLight
}

func (PointLightNodeTarget) ApplyFrom added in v0.14.0

func (t PointLightNodeTarget) ApplyFrom(node *hierarchy.Node)

func (PointLightNodeTarget) Release added in v0.19.0

func (t PointLightNodeTarget) Release()

type ResourceSet added in v0.9.0

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

ResourceSet is a collection of resources that are managed together.

func (*ResourceSet) CreateResourceSet added in v0.9.0

func (s *ResourceSet) CreateResourceSet() *ResourceSet

CreateResourceSet creates a new ResourceSet that inherits resources from the current one. Opening a resource in the new resource set will first check if the current one has it.

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.

func (*ResourceSet) OpenModelByID added in v0.19.0

func (s *ResourceSet) OpenModelByID(id string) async.Promise[*ModelDefinition]

OpenModelByID loads a model definition by its ID.

func (*ResourceSet) OpenModelByName added in v0.9.0

func (s *ResourceSet) OpenModelByName(name string) async.Promise[*ModelDefinition]

OpenModelByName loads a model definition by its name.

type Scene added in v0.9.0

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

Scene is the main container for all game objects and systems.

func (*Scene) CreateAmbientLight added in v0.19.0

func (s *Scene) CreateAmbientLight(info AmbientLightInfo) *hierarchy.Node

CreateAmbientLight creates a new ambient light and appends it to the root of the scene.

func (*Scene) CreateAnimation added in v0.9.0

func (s *Scene) CreateAnimation(info AnimationInfo) *Animation

CreateAnimation creates a new animation based on the provided information.

func (*Scene) CreateDirectionalLight added in v0.19.0

func (s *Scene) CreateDirectionalLight(info DirectionalLightInfo) *hierarchy.Node

CreateDirectionalLight creates a new directional light and appends it to the root of the scene.

func (*Scene) CreateModel added in v0.9.0

func (s *Scene) CreateModel(info ModelInfo) *Model

TODO: Return the node instead and have the Model be a target?

func (*Scene) CreateNode added in v0.19.0

func (s *Scene) CreateNode() *hierarchy.Node

CreateNode creates a new node and appends it to the root of the scene.

func (*Scene) CreatePointLight added in v0.19.0

func (s *Scene) CreatePointLight(info PointLightInfo) *hierarchy.Node

CreatePointLight creates a new point light and appends it to the root of the scene.

func (*Scene) CreateSpotLight added in v0.19.0

func (s *Scene) CreateSpotLight(info SpotLightInfo) *hierarchy.Node

CreateSpotLight creates a new spot light and appends it to the root of the scene.

func (*Scene) Delete added in v0.9.0

func (s *Scene) Delete()

Delete removes all resources associated with the scene.

func (*Scene) ECS added in v0.9.0

func (s *Scene) ECS() *ecs.Scene

ECS returns the ECS scene associated with the scene.

func (*Scene) Freeze added in v0.10.0

func (s *Scene) Freeze()

Freeze stops the scene from updating any of its systems.

func (*Scene) Graphics added in v0.9.0

func (s *Scene) Graphics() *graphics.Scene

Graphics returns the graphics scene associated with the scene.

func (*Scene) IsFrozen added in v0.10.0

func (s *Scene) IsFrozen() bool

IsFrozen returns whether the scene is currently frozen. A frozen scene will not update any of its systems.

func (*Scene) Physics added in v0.9.0

func (s *Scene) Physics() *physics.Scene

Physics returns the physics scene associated with the scene.

func (*Scene) PlayAnimationTree added in v0.19.1

func (s *Scene) PlayAnimationTree(tree AnimationSource)

PlayAnimationTree adds the provided animation tree to the scene.

func (*Scene) Render added in v0.10.0

func (s *Scene) Render(framebuffer render.Framebuffer, viewport graphics.Viewport)

Render draws the scene to the provided viewport.

func (*Scene) Root added in v0.9.0

func (s *Scene) Root() *hierarchy.Node

Root returns the root node of the scene.

func (*Scene) StopAnimationTree added in v0.19.1

func (s *Scene) StopAnimationTree(tree AnimationSource)

StopAnimationTree removes the provided animation tree from the scene.

func (*Scene) SubscribePostAnimation added in v0.14.0

func (s *Scene) SubscribePostAnimation(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePostAnimation adds a callback to be executed after the animations are updated.

func (*Scene) SubscribePostNode added in v0.14.0

func (s *Scene) SubscribePostNode(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePostNode adds a callback to be executed after the nodes are updated.

func (*Scene) SubscribePostPhysics added in v0.14.0

func (s *Scene) SubscribePostPhysics(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePostPhysics adds a callback to be executed after the physics scene updates.

func (*Scene) SubscribePostUpdate added in v0.14.0

func (s *Scene) SubscribePostUpdate(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePostUpdate adds a callback to be executed after the scene updates.

func (*Scene) SubscribePreAnimation added in v0.14.0

func (s *Scene) SubscribePreAnimation(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePreAnimation adds a callback to be executed before the animations are updated.

func (*Scene) SubscribePreNode added in v0.14.0

func (s *Scene) SubscribePreNode(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePreNode adds a callback to be executed before the nodes are updated.

func (*Scene) SubscribePrePhysics added in v0.14.0

func (s *Scene) SubscribePrePhysics(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePrePhysics adds a callback to be executed before the physics scene updates.

func (*Scene) SubscribePreUpdate added in v0.14.0

func (s *Scene) SubscribePreUpdate(callback timestep.UpdateCallback) *timestep.UpdateSubscription

SubscribePreUpdate adds a callback to be executed before the scene updates.

func (*Scene) Unfreeze added in v0.10.0

func (s *Scene) Unfreeze()

Unfreeze allows the scene to update its systems.

func (*Scene) Update added in v0.9.0

func (s *Scene) Update(elapsedTime time.Duration)

Update advances the scene by the provided time.

type SkyNodeTarget added in v0.19.0

type SkyNodeTarget struct {
	Sky *graphics.Sky
}

func (SkyNodeTarget) ApplyFrom added in v0.19.0

func (t SkyNodeTarget) ApplyFrom(node *hierarchy.Node)

func (SkyNodeTarget) Release added in v0.19.0

func (t SkyNodeTarget) Release()

type SpotLightInfo added in v0.19.0

type SpotLightInfo struct {
	EmitColor          opt.T[dprec.Vec3]
	EmitDistance       opt.T[float64]
	EmitOuterConeAngle opt.T[dprec.Angle]
	EmitInnerConeAngle opt.T[dprec.Angle]
	CastShadow         opt.T[bool]
}

SpotLightInfo contains the information required to create a spot light.

type SpotLightNodeTarget added in v0.14.0

type SpotLightNodeTarget struct {
	Light *graphics.SpotLight
}

func (SpotLightNodeTarget) ApplyFrom added in v0.14.0

func (t SpotLightNodeTarget) ApplyFrom(node *hierarchy.Node)

func (SpotLightNodeTarget) Release added in v0.19.0

func (t SpotLightNodeTarget) Release()

type Worker added in v0.9.0

type Worker interface {
	Schedule(fn func())
}

type WorkerFunc added in v0.9.0

type WorkerFunc func(fn func())

func (WorkerFunc) Schedule added in v0.9.0

func (f WorkerFunc) Schedule(fn func())

Directories

Path Synopsis
Package asseet provides data transfer objects for the game's asset types.
Package asseet provides data transfer objects for the game's asset types.
dsl
mdl
lsl
Package lsl provides a simple interface to the Lacking Shader Language.
Package lsl provides a simple interface to the Lacking Shader Language.
Package hierarchy provides the means to represent a hierarchy of 3D objects.
Package hierarchy provides the means to represent a hierarchy of 3D objects.

Jump to

Keyboard shortcuts

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