game

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 32 Imported by: 5 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const UnspecifiedID = uint32(0xFFFFFFFF)

UnspecifiedID is a special ID value that indicates that a reference to an object is not specified.

Variables

View Source
var ECSScope = ecs.NewScope()

ECSScope is the default scope used for all ECS scenes in the game.

Functions

func InstantiateAmbientLightTemplate added in v0.23.0

func InstantiateAmbientLightTemplate(scene *Scene, template AmbientLightTemplate, nodes IdentifiableList[hierarchy.NodeID], textures IdentifiableList[render.Texture]) *graphics.AmbientLight

InstantiateAmbientLightTemplate creates an ambient light in the scene based on the provided template.

This operation needs to be called from the main thread.

func InstantiateArmatureTemplate added in v0.23.0

func InstantiateArmatureTemplate(scene *Scene, template ArmatureTemplate, nodes IdentifiableList[hierarchy.NodeID]) *graphics.Armature

InstantiateArmatureTemplate creates an armature in the given scene from the provided armature template.

This operation needs to be called from the main thread.

func InstantiateDirectionalLightTemplate added in v0.23.0

func InstantiateDirectionalLightTemplate(scene *Scene, template DirectionalLightTemplate, nodes IdentifiableList[hierarchy.NodeID]) *graphics.DirectionalLight

InstantiateDirectionalLightTemplate creates a directional light in the scene based on the provided template.

This operation needs to be called from the main thread.

func InstantiateMeshTemplateDynamic added in v0.23.0

func InstantiateMeshTemplateDynamic(scene *Scene, template MeshTemplate, nodes IdentifiableList[hierarchy.NodeID], definitions IdentifiableList[*graphics.MeshDefinition], armatures IdentifiableList[*graphics.Armature]) *graphics.Mesh

InstantiateMeshTemplateDynamic creates a dynamic mesh in the given scene from the provided mesh template.

This operation needs to be called from the main thread.

func InstantiateMeshTemplateStatic added in v0.23.0

func InstantiateMeshTemplateStatic(scene *Scene, template MeshTemplate, nodes IdentifiableList[hierarchy.NodeID], definitions IdentifiableList[*graphics.MeshDefinition], armatures IdentifiableList[*graphics.Armature])

InstantiateMeshTemplateStatic creates a static mesh in the given scene from the provided mesh template.

This operation needs to be called from the main thread.

func InstantiatePhysicsTerrainTemplate added in v0.25.0

func InstantiatePhysicsTerrainTemplate(scene *Scene, template TerrainTemplate, nodes IdentifiableList[hierarchy.NodeID])

func InstantiatePointLightTemplate added in v0.23.0

func InstantiatePointLightTemplate(scene *Scene, template PointLightTemplate, nodes IdentifiableList[hierarchy.NodeID]) *graphics.PointLight

InstantiatePointLightTemplate creates a point light in the scene based on the provided template.

This operation needs to be called from the main thread.

func InstantiateSkyTemplate added in v0.23.0

func InstantiateSkyTemplate(scene *Scene, template SkyTemplate, nodes IdentifiableList[hierarchy.NodeID]) *graphics.Sky

InstantiateSkyTemplate instantiates a sky template in the given scene.

This operation needs to be called from the main thread.

func InstantiateSpotLightTemplate added in v0.23.0

func InstantiateSpotLightTemplate(scene *Scene, template SpotLightTemplate, nodes IdentifiableList[hierarchy.NodeID]) *graphics.SpotLight

InstantiateSpotLightTemplate creates a spot light in the scene based on the provided template.

This operation needs to be called from the main thread.

func LoadMaterialPass added in v0.23.0

func LoadMaterialPass(loader *AssetLoader, assetPass dto.MaterialPass, shaders IdentifiableList[*graphics.Shader]) (graphics.MaterialPassInfo, error)

LoadMaterialPass resolves a material pass from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadMaterialPasses added in v0.23.0

func LoadMaterialPasses(loader *AssetLoader, assetPasses []dto.MaterialPass, shaders IdentifiableList[*graphics.Shader]) ([]graphics.MaterialPassInfo, error)

LoadMaterialPasses resolves a list of material passes from the given asset data.

This is a blocking operation and should be called from a worker thread.

func UnloadAmbientLightTemplate added in v0.23.0

func UnloadAmbientLightTemplate(loader *AssetLoader, idLight Identifiable[AmbientLightTemplate]) error

UnloadAmbientLightTemplate unloads an ambient light template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadAmbientLightTemplates added in v0.23.0

func UnloadAmbientLightTemplates(loader *AssetLoader, idLights IdentifiableList[AmbientLightTemplate]) error

UnloadAmbientLightTemplates unloads a list of ambient light templates from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadArmatureTemplate added in v0.23.0

func UnloadArmatureTemplate(loader *AssetLoader, idTemplate Identifiable[ArmatureTemplate]) error

UnloadArmatureTemplate unloads an armature template from the engine.

This is a blocking operation and should be called from a worker thread.

func UnloadArmatureTemplates added in v0.23.0

func UnloadArmatureTemplates(loader *AssetLoader, idTemplates IdentifiableList[ArmatureTemplate]) error

UnloadArmatureTemplates unloads a list of armature templates from the engine.

This is a blocking operation and should be called from a worker thread.

func UnloadDirectionalLightTemplate added in v0.23.0

func UnloadDirectionalLightTemplate(loader *AssetLoader, idLight Identifiable[DirectionalLightTemplate]) error

UnloadDirectionalLightTemplate unloads a directional light template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadDirectionalLightTemplates added in v0.23.0

func UnloadDirectionalLightTemplates(loader *AssetLoader, idLights IdentifiableList[DirectionalLightTemplate]) error

UnloadDirectionalLightTemplates unloads a list of directional light templates from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMaterial added in v0.23.0

func UnloadMaterial(loader *AssetLoader, idMaterial Identifiable[*graphics.Material]) error

UnloadMaterial unloads a material from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMaterials added in v0.23.0

func UnloadMaterials(loader *AssetLoader, idMaterials IdentifiableList[*graphics.Material]) error

UnloadMaterials unloads a list of materials from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMeshDefinition added in v0.23.0

func UnloadMeshDefinition(loader *AssetLoader, idDefinition Identifiable[*graphics.MeshDefinition]) error

UnloadMeshDefinition unloads a mesh definition from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMeshDefinitions added in v0.23.0

func UnloadMeshDefinitions(loader *AssetLoader, idDefinitions IdentifiableList[*graphics.MeshDefinition]) error

UnloadMeshDefinitions unloads a list of mesh definitions from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMeshGeometries added in v0.23.0

func UnloadMeshGeometries(loader *AssetLoader, idGeometries IdentifiableList[*graphics.MeshGeometry]) error

UnloadMeshGeometries unloads a list of mesh geometries from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMeshGeometry added in v0.23.0

func UnloadMeshGeometry(loader *AssetLoader, idGeometry Identifiable[*graphics.MeshGeometry]) error

UnloadMeshGeometry unloads a mesh geometry from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMeshTemplate added in v0.23.0

func UnloadMeshTemplate(loader *AssetLoader, idTemplate Identifiable[MeshTemplate]) error

UnloadMeshTemplate unloads a mesh template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadMeshTemplates added in v0.23.0

func UnloadMeshTemplates(loader *AssetLoader, idTemplates IdentifiableList[MeshTemplate]) error

UnloadMeshTemplates unloads a list of mesh templates from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadModelTemplate added in v0.23.0

func UnloadModelTemplate(loader *AssetLoader, template *ModelTemplate) error

UnloadModelTemplate unloads the given model template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadNodeTemplate added in v0.23.0

func UnloadNodeTemplate(loader *AssetLoader, idNode Identifiable[NodeTemplate]) error

UnloadNodeTemplate unloads a node template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadNodeTemplates added in v0.23.0

func UnloadNodeTemplates(loader *AssetLoader, idNodes IdentifiableList[NodeTemplate]) error

UnloadNodeTemplates unloads a list of node templates from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadPointLightTemplate added in v0.23.0

func UnloadPointLightTemplate(loader *AssetLoader, idLight Identifiable[PointLightTemplate]) error

UnloadPointLightTemplate unloads a point light template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadPointLightTemplates added in v0.23.0

func UnloadPointLightTemplates(loader *AssetLoader, idLights IdentifiableList[PointLightTemplate]) error

UnloadPointLightTemplates unloads a list of point light templates from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadRecording added in v0.23.0

func UnloadRecording(loader *AssetLoader, idRecording Identifiable[*animation.Clip]) error

UnloadRecording unloads the given animation recording.

This is a blocking operation and should be called from a worker thread.

func UnloadRecordings added in v0.23.0

func UnloadRecordings(loader *AssetLoader, idRecordings IdentifiableList[*animation.Clip]) error

UnloadRecordings unloads a list of animation recordings.

This is a blocking operation and should be called from a worker thread.

func UnloadShader added in v0.23.0

func UnloadShader(loader *AssetLoader, idShader Identifiable[*graphics.Shader]) error

UnloadShader unloads a shader from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadShaders added in v0.23.0

func UnloadShaders(loader *AssetLoader, idShaders IdentifiableList[*graphics.Shader]) error

UnloadShaders unloads a list of shaders from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadSkyTemplate added in v0.23.0

func UnloadSkyTemplate(loader *AssetLoader, idSky Identifiable[SkyTemplate]) error

UnloadSkyTemplate unloads a sky template from the engine.

This is a blocking operation and should be called from a worker thread.

func UnloadSkyTemplates added in v0.23.0

func UnloadSkyTemplates(loader *AssetLoader, idSkies IdentifiableList[SkyTemplate]) error

UnloadSkyTemplates unloads a list of sky templates from the engine.

This is a blocking operation and should be called from a worker thread.

func UnloadSpotLightTemplate added in v0.23.0

func UnloadSpotLightTemplate(loader *AssetLoader, idLight Identifiable[SpotLightTemplate]) error

UnloadSpotLightTemplate unloads a spot light template from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadSpotLightTemplates added in v0.23.0

func UnloadSpotLightTemplates(loader *AssetLoader, idLights IdentifiableList[SpotLightTemplate]) error

UnloadSpotLightTemplates unloads a list of spot light templates from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadTexture added in v0.23.0

func UnloadTexture(loader *AssetLoader, idTexture Identifiable[render.Texture]) error

UnloadTexture unloads a texture from the asset loader.

This is a blocking operation and should be called from a worker thread.

func UnloadTextures added in v0.23.0

func UnloadTextures(loader *AssetLoader, idTextures IdentifiableList[render.Texture]) error

UnloadTextures unloads a list of textures from the asset loader.

This is a blocking operation and should be called from a worker thread.

Types

type AmbientLightBindingSolver added in v0.25.0

type AmbientLightBindingSolver struct{}

func NewAmbientLightBindingSolver added in v0.25.0

func NewAmbientLightBindingSolver() *AmbientLightBindingSolver

func (*AmbientLightBindingSolver) OnDelete added in v0.25.0

func (*AmbientLightBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *AmbientLightBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, light *graphics.AmbientLight, fraction float64)

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 AmbientLightTemplate added in v0.23.0

type AmbientLightTemplate struct {
	NodeID              uint32
	ReflectionTextureID uint32
	RefractionTextureID uint32
	CastShadow          bool
}

AmbientLightTemplate represents a template for an ambient light in the scene.

type AnimationBindingSolver added in v0.25.0

type AnimationBindingSolver struct{}

AnimationBindingSolver applies the transformation of the bone of an AnimationSource to the hierarchy node that the source is bound to.

func NewAnimationBindingSolver added in v0.25.0

func NewAnimationBindingSolver() *AnimationBindingSolver

NewAnimationBindingSolver creates a new AnimationBindingSolver.

func (*AnimationBindingSolver) OnSourceToNode added in v0.25.0

func (s *AnimationBindingSolver) OnSourceToNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, source AnimationSource)

OnSourceToNode sets the local transformation of the hierarchy node to the current transformation of the bone of the source.

type AnimationSource added in v0.19.0

type AnimationSource struct {

	// Node is the animation node tree whose output drives the hierarchy node.
	Node animation.Node

	// Bone is the index of the bone, in the skeleton of the node tree, whose
	// transformation is applied to the hierarchy node.
	Bone int
}

AnimationSource specifies the bone of an animation node tree that drives a hierarchy node through the Scene.ArmatureBindingSet.

type ArmatureTemplate added in v0.23.0

type ArmatureTemplate struct {
	Definition   *graphics.ArmatureDefinition
	NodeBindings []uint32
}

ArmatureTemplate represents a template for an armature that can be instantiated in a scene.

type AssetLoader added in v0.23.0

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

AssetLoader represents an async loading process.

func (*AssetLoader) Engine added in v0.23.0

func (l *AssetLoader) Engine() *Engine

AsyncEngine returns the async engine associated with this asset loader.

func (*AssetLoader) ResourceSet added in v0.23.0

func (l *AssetLoader) ResourceSet() *ResourceSet

ResourceSet returns the resource set associated with this asset loader.

func (*AssetLoader) ScheduleIO added in v0.23.0

func (l *AssetLoader) ScheduleIO(cb func() error) async.Operation

ScheduleIO schedules an operation to be executed on the IO worker.

func (*AssetLoader) ScheduleMain added in v0.23.0

func (l *AssetLoader) ScheduleMain(cb func() error) async.Operation

ScheduleMain schedules an operation to be executed on the main thread.

type BodyBindingSolver added in v0.25.0

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

func NewBodyBindingSolver added in v0.25.0

func NewBodyBindingSolver(physicsScene *physics.Scene) *BodyBindingSolver

func (*BodyBindingSolver) OnDelete added in v0.25.0

func (s *BodyBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, bodyID physics.BodyID)

func (*BodyBindingSolver) OnSourceToNode added in v0.25.0

func (s *BodyBindingSolver) OnSourceToNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, bodyID physics.BodyID)

type BoneBindingSolver added in v0.25.0

type BoneBindingSolver struct{}

func NewBoneBindingSolver added in v0.25.0

func NewBoneBindingSolver() *BoneBindingSolver

func (*BoneBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *BoneBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, target BoneTarget, fraction float64)

type BoneTarget added in v0.23.0

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

type CameraBindingSolver added in v0.25.0

type CameraBindingSolver struct{}

func NewCameraBindingSolver added in v0.25.0

func NewCameraBindingSolver() *CameraBindingSolver

func (*CameraBindingSolver) OnDelete added in v0.25.0

func (s *CameraBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, camera *graphics.Camera)

func (*CameraBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *CameraBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, camera *graphics.Camera, fraction float64)

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(store resource.Store, 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) Store added in v0.24.0

func (c *Controller) Store() resource.Store

Store returns the resource store to be used by the game.

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.

type DirectionalLightBindingSolver added in v0.25.0

type DirectionalLightBindingSolver struct{}

func NewDirectionalLightBindingSolver added in v0.25.0

func NewDirectionalLightBindingSolver() *DirectionalLightBindingSolver

func (*DirectionalLightBindingSolver) OnDelete added in v0.25.0

func (*DirectionalLightBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *DirectionalLightBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, light *graphics.DirectionalLight, fraction float64)

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 DirectionalLightTemplate added in v0.23.0

type DirectionalLightTemplate struct {
	NodeID     uint32
	EmitColor  dprec.Vec3
	CastShadow bool
}

DirectionalLightTemplate represents a template for a directional light in the scene.

type EmitterBindingSolver added in v0.25.0

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

EmitterBindingSolver keeps sound emitters in sync with the hierarchy nodes that they are bound to. The position and rotation of an emitter follow the interpolated transformation of its node, and its velocity is derived from the distance that the node covers during a fixed step.

func NewEmitterBindingSolver added in v0.25.0

func NewEmitterBindingSolver(soundScene *sound.Scene, fixedTimestep time.Duration) *EmitterBindingSolver

NewEmitterBindingSolver creates a new EmitterBindingSolver for the emitters of the specified sound scene, where fixedTimestep is the duration of a single fixed step of the hierarchy.

func (*EmitterBindingSolver) OnDelete added in v0.25.0

func (s *EmitterBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, emitterID sound.EmitterID)

func (*EmitterBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *EmitterBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, emitterID sound.EmitterID, fraction float64)

func (*EmitterBindingSolver) OnTargetFromNode added in v0.25.0

func (s *EmitterBindingSolver) OnTargetFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, emitterID sound.EmitterID)

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) Audio added in v0.25.0

func (e *Engine) Audio() audio.API

Audio returns the audio API that is used by the engine, or nil if the engine was created without one.

func (*Engine) Create added in v0.9.0

func (e *Engine) Create()

func (*Engine) CreateResourceSet added in v0.9.0

func (e *Engine) CreateResourceSet() *ResourceSet

CreateResourceSet creates a new ResourceSet that can be used to manage resources together.

func (*Engine) CreateScene added in v0.9.0

func (e *Engine) CreateScene(info SceneInfo) *Scene

func (*Engine) Destroy added in v0.9.0

func (e *Engine) Destroy()

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) RegisterResourceLoader added in v0.23.0

func (e *Engine) RegisterResourceLoader(resourceLoader ResourceLoader[any])

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) ScheduleIO added in v0.23.0

func (e *Engine) ScheduleIO(cb func() error) async.Operation

func (*Engine) ScheduleMain added in v0.23.0

func (e *Engine) ScheduleMain(cb func() error) async.Operation

func (*Engine) SetActiveScene added in v0.9.0

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

func (*Engine) Storage added in v0.23.0

func (e *Engine) Storage() resource.Store

func (*Engine) UnregisterResourceLoader added in v0.23.0

func (e *Engine) UnregisterResourceLoader(resourceLoader ResourceLoader[any])

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 WithAudio added in v0.25.0

func WithAudio(audioAPI audio.API) EngineOption

WithAudio configures the engine to use the specified audio API for the Sound sub-scenes of the scenes that it creates. Without it, or if the API is nil, scenes are created without sound.

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 WithStore added in v0.24.0

func WithStore(registry resource.Store) EngineOption

type Hierarchy added in v0.23.0

type Hierarchy struct {
	RootNode hierarchy.NodeID
	Nodes    IdentifiableList[hierarchy.NodeID]
}

Hierarchy represents a scene hierarchy that has been instantiated from a HierarchyInfo.

func InstantiateHierarchy added in v0.23.0

func InstantiateHierarchy(scene *Scene, info HierarchyInfo) *Hierarchy

InstantiateHierarchy instantiates a hierarchy in the given scene based on the provided info.

type HierarchyInfo added in v0.23.0

type HierarchyInfo struct {
	NodeTemplates IdentifiableList[NodeTemplate]
	Name          opt.T[string]
	Position      opt.T[dprec.Vec3]
	Rotation      opt.T[dprec.Quat]
	Scale         opt.T[dprec.Vec3]
	SubTreeNode   opt.T[string]
}

HierarchyInfo contains information about a hierarchy to be instantiated in a scene.

type Identifiable added in v0.23.0

type Identifiable[T any] struct {
	ID    uint32
	Value T
}

Identifiable is a generic type that holds an ID and a value of type T.

It is used to represent objects loaded from an asset file. The ID is not globally unique and should be used in the scope of other objects from the same asset file.

func LoadAmbientLightTemplate added in v0.23.0

func LoadAmbientLightTemplate(loader *AssetLoader, assetLight dto.AmbientLight) (Identifiable[AmbientLightTemplate], error)

LoadAmbientLightTemplate loads an ambient light template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadAnimationRecording added in v0.23.0

func LoadAnimationRecording(loader *AssetLoader, assetAnimation dto.Animation, restTransforms map[string]animation.Transform) (Identifiable[*animation.Clip], error)

LoadAnimationRecording loads an animation recording from the given asset.

The rest transforms, keyed by node name, provide the value of the components (translation, rotation or scale) that a binding of the recording does not animate. Components of nodes without a rest transform default to those of the animation.IdentityTransform.

This is a blocking operation and should be called from a worker thread.

func LoadArmatureTemplate added in v0.23.0

func LoadArmatureTemplate(loader *AssetLoader, assetArmature dto.Armature) (Identifiable[ArmatureTemplate], error)

LoadArmatureTemplate resolves an armature template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadDirectionalLightTemplate added in v0.23.0

func LoadDirectionalLightTemplate(loader *AssetLoader, assetLight dto.DirectionalLight) (Identifiable[DirectionalLightTemplate], error)

LoadDirectionalLightTemplate loads a directional light template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadMaterial added in v0.23.0

func LoadMaterial(loader *AssetLoader, assetMaterial dto.Material, shaders IdentifiableList[*graphics.Shader], textures IdentifiableList[render.Texture]) (Identifiable[*graphics.Material], error)

LoadMaterial resolves a material from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadMeshDefinition added in v0.23.0

func LoadMeshDefinition(loader *AssetLoader, assetDefinition dto.MeshDefinition, geometries IdentifiableList[*graphics.MeshGeometry], materials IdentifiableList[*graphics.Material]) (Identifiable[*graphics.MeshDefinition], error)

LoadMeshDefinition resolves a mesh definition from the given asset data, using the provided geometries and materials.

This is a blocking operation and should be called from a worker thread.

func LoadMeshGeomety added in v0.23.0

func LoadMeshGeomety(loader *AssetLoader, assetGeometry dto.Geometry) (Identifiable[*graphics.MeshGeometry], error)

LoadMeshGeomety resolves a mesh geometry from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadMeshTemplate added in v0.23.0

func LoadMeshTemplate(loader *AssetLoader, assetMesh dto.Mesh) (Identifiable[MeshTemplate], error)

LoadMeshTemplate resolves a mesh template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadNodeTemplate added in v0.23.0

func LoadNodeTemplate(loader *AssetLoader, assetNode dto.Node) (Identifiable[NodeTemplate], error)

LoadNodeTemplate resolves a node template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadPhysicsTerrainTemplate added in v0.25.0

func LoadPhysicsTerrainTemplate(loader *AssetLoader, assetTerrain dto.PhysicsTerrain) (Identifiable[TerrainTemplate], error)

LoadPhysicsTerrainTemplate resolves a physics body template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadPointLightTemplate added in v0.23.0

func LoadPointLightTemplate(loader *AssetLoader, assetLight dto.PointLight) (Identifiable[PointLightTemplate], error)

LoadPointLightTemplate loads a point light template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadShader added in v0.23.0

func LoadShader(loader *AssetLoader, assetShader dto.Shader) (Identifiable[*graphics.Shader], error)

LoadShader resolves a shader from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadSkyTemplate added in v0.23.0

func LoadSkyTemplate(loader *AssetLoader, assetSky dto.Sky, materials IdentifiableList[*graphics.Material]) (Identifiable[SkyTemplate], error)

LoadSkyTemplate resolves a sky template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadSpotLightTemplate added in v0.23.0

func LoadSpotLightTemplate(loader *AssetLoader, assetLight dto.SpotLight) (Identifiable[SpotLightTemplate], error)

LoadSpotLightTemplate loads a spot light template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadTexture added in v0.23.0

func LoadTexture(loader *AssetLoader, assetTexture dto.Texture) (Identifiable[render.Texture], error)

LoadTexture resolves a texture from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadTexture2D added in v0.23.0

func LoadTexture2D(loader *AssetLoader, assetTexture dto.Texture) (Identifiable[render.Texture], error)

LoadTexture2D resolves a 2D texture from the given asset data.

This is a blocking operation and should be called from a worker thread.

func LoadTextureCube added in v0.23.0

func LoadTextureCube(loader *AssetLoader, assetTexture dto.Texture) (Identifiable[render.Texture], error)

LoadTextureCube resolves a cube map texture from the given asset data.

This is a blocking operation and should be called from a worker thread.

type IdentifiableList added in v0.23.0

type IdentifiableList[T any] []Identifiable[T]

IdentifiableList is a slice of Identifiable[T] that provides additional methods for iterating and accessing the values by their IDs.

func LoadAmbientLightTemplates added in v0.23.0

func LoadAmbientLightTemplates(loader *AssetLoader, assetLights []dto.AmbientLight) (IdentifiableList[AmbientLightTemplate], error)

LoadAmbientLightTemplates loads a list of ambient light templates from the given asset ambient lights.

This is a blocking operation and should be called from a worker thread.

func LoadAnimationRecordings added in v0.23.0

func LoadAnimationRecordings(loader *AssetLoader, assetAnimations []dto.Animation, restTransforms map[string]animation.Transform) (IdentifiableList[*animation.Clip], error)

LoadAnimationRecordings loads a list of animation recordings from the given asset animations. See LoadAnimationRecording for the meaning of the rest transforms.

This is a blocking operation and should be called from a worker thread.

func LoadArmatureTemplates added in v0.23.0

func LoadArmatureTemplates(loader *AssetLoader, assetArmatures []dto.Armature) (IdentifiableList[ArmatureTemplate], error)

LoadArmatureTemplates resolves a list of armature templates from the given asset armatures.

This is a blocking operation and should be called from a worker thread.

func LoadDirectionalLightTemplates added in v0.23.0

func LoadDirectionalLightTemplates(loader *AssetLoader, assetLights []dto.DirectionalLight) (IdentifiableList[DirectionalLightTemplate], error)

LoadDirectionalLightTemplates loads a list of directional light templates from the given asset directional lights.

This is a blocking operation and should be called from a worker thread.

func LoadMaterials added in v0.23.0

func LoadMaterials(loader *AssetLoader, assetMaterials []dto.Material, shaders IdentifiableList[*graphics.Shader], textures IdentifiableList[render.Texture]) (IdentifiableList[*graphics.Material], error)

LoadMaterials resolves a list of materials from the given asset materials.

This is a blocking operation and should be called from a worker thread.

func LoadMeshDefinitions added in v0.23.0

func LoadMeshDefinitions(loader *AssetLoader, assetDefinitions []dto.MeshDefinition, geometries IdentifiableList[*graphics.MeshGeometry], materials IdentifiableList[*graphics.Material]) (IdentifiableList[*graphics.MeshDefinition], error)

LoadMeshDefinitions resolves a list of mesh definitions from the given asset definitions, using the provided geometries and materials.

This is a blocking operation and should be called from a worker thread.

func LoadMeshGeometries added in v0.23.0

func LoadMeshGeometries(loader *AssetLoader, assetGeometries []dto.Geometry) (IdentifiableList[*graphics.MeshGeometry], error)

LoadMeshGeometries resolves a list of mesh geometries from the given asset geometries.

This is a blocking operation and should be called from a worker thread.

func LoadMeshTemplates added in v0.23.0

func LoadMeshTemplates(loader *AssetLoader, assetMeshes []dto.Mesh) (IdentifiableList[MeshTemplate], error)

LoadMeshTemplates resolves a list of mesh templates from the given asset meshes.

This is a blocking operation and should be called from a worker thread.

func LoadNodeTemplates added in v0.23.0

func LoadNodeTemplates(loader *AssetLoader, assetNodes []dto.Node) (IdentifiableList[NodeTemplate], error)

LoadNodeTemplates resolves a list of node templates from the given asset nodes.

This is a blocking operation and should be called from a worker thread.

func LoadPhysicsTerrainTemplates added in v0.25.0

func LoadPhysicsTerrainTemplates(loader *AssetLoader, assetTerrains []dto.PhysicsTerrain) (IdentifiableList[TerrainTemplate], error)

LoadPhysicsTerrainTemplates resolves a list of physics body templates from the given asset bodies.

This is a blocking operation and should be called from a worker thread.

func LoadPointLightTemplates added in v0.23.0

func LoadPointLightTemplates(loader *AssetLoader, assetLights []dto.PointLight) (IdentifiableList[PointLightTemplate], error)

LoadPointLightTemplates loads a list of point light templates from the given asset point lights.

This is a blocking operation and should be called from a worker thread.

func LoadShaders added in v0.23.0

func LoadShaders(loader *AssetLoader, assetShaders []dto.Shader) (IdentifiableList[*graphics.Shader], error)

LoadShaders resolves a list of shaders from the given asset shaders.

This is a blocking operation and should be called from a worker thread.

func LoadSkyTemplates added in v0.23.0

func LoadSkyTemplates(loader *AssetLoader, assetSkies []dto.Sky, materials IdentifiableList[*graphics.Material]) (IdentifiableList[SkyTemplate], error)

LoadSkyTemplates resolves a list of sky templates from the given asset skies.

This is a blocking operation and should be called from a worker thread.

func LoadSpotLightTemplates added in v0.23.0

func LoadSpotLightTemplates(loader *AssetLoader, assetLights []dto.SpotLight) (IdentifiableList[SpotLightTemplate], error)

LoadSpotLightTemplates loads a list of spot light templates from the given asset spot lights.

This is a blocking operation and should be called from a worker thread.

func LoadTextures added in v0.23.0

func LoadTextures(loader *AssetLoader, assetTextures []dto.Texture) (IdentifiableList[render.Texture], error)

LoadTextures resolves a list of textures from the given asset textures.

This is a blocking operation and should be called from a worker thread.

func (IdentifiableList[T]) FindByID added in v0.23.0

func (l IdentifiableList[T]) FindByID(id uint32) (T, bool)

FindByID searches for an entry with the specified ID and returns its value and a boolean indicating whether the entry was found.

func (IdentifiableList[T]) GetByID added in v0.23.0

func (l IdentifiableList[T]) GetByID(id uint32) T

GetByID searches for an entry with the specified ID and returns its value. If the entry is not found, it panics.

func (IdentifiableList[T]) HasID added in v0.23.0

func (l IdentifiableList[T]) HasID(id uint32) bool

HasID checks if the list contains an entry with the specified ID.

func (IdentifiableList[T]) Iter added in v0.23.0

func (l IdentifiableList[T]) Iter() iter.Seq2[uint32, T]

Iter returns an iterator that yields pairs of ID and value for each entry in the list.

func (IdentifiableList[T]) Values added in v0.23.0

func (l IdentifiableList[T]) Values() iter.Seq[T]

Values returns an iterator that yields only the values of type T for each entry in the list.

func (IdentifiableList[T]) ValuesList added in v0.23.0

func (l IdentifiableList[T]) ValuesList() []T

ValuesList returns a slice of values of type T for each entry in the list.

type ListenerBindingSolver added in v0.25.0

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

ListenerBindingSolver keeps sound listeners in sync with the hierarchy nodes that they are bound to. The position and rotation of a listener follow the interpolated transformation of its node, and its velocity is derived from the distance that the node covers during a fixed step.

func NewListenerBindingSolver added in v0.25.0

func NewListenerBindingSolver(soundScene *sound.Scene, fixedTimestep time.Duration) *ListenerBindingSolver

NewListenerBindingSolver creates a new ListenerBindingSolver for the listeners of the specified sound scene, where fixedTimestep is the duration of a single fixed step of the hierarchy.

func (*ListenerBindingSolver) OnDelete added in v0.25.0

func (s *ListenerBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, listenerID sound.ListenerID)

func (*ListenerBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *ListenerBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, listenerID sound.ListenerID, fraction float64)

func (*ListenerBindingSolver) OnTargetFromNode added in v0.25.0

func (s *ListenerBindingSolver) OnTargetFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, listenerID sound.ListenerID)

type MeshBindingSolver added in v0.25.0

type MeshBindingSolver struct{}

func NewMeshBindingSolver added in v0.25.0

func NewMeshBindingSolver() *MeshBindingSolver

func (*MeshBindingSolver) OnDelete added in v0.25.0

func (s *MeshBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, mesh *graphics.Mesh)

func (*MeshBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *MeshBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, mesh *graphics.Mesh, fraction float64)

type MeshTemplate added in v0.23.0

type MeshTemplate struct {
	NodeID       uint32
	DefinitionID uint32
	ArmatureID   uint32
}

MeshTemplate represents a template for a mesh that can be instantiated in a scene.

type Model added in v0.9.0

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

Model represents an instance of a ModelTemplate in a Scene.

func InstantiateModel added in v0.23.0

func InstantiateModel(scene *Scene, info ModelInfo) *Model

InstantiateModel instantiates a model in the given scene based on the provided info.

func (*Model) AnimatedNodes added in v0.19.0

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

func (*Model) BindAnimation added in v0.23.0

func (m *Model) BindAnimation(root animation.Node)

BindAnimation binds the animated nodes of the model (see Model.AnimatedNodes) to the bones of the specified animation node tree through the Scene.ArmatureBindingSet. The tree is not advanced by this; use Scene.PlayAnimation for that.

func (*Model) BindAnimationSubtree added in v0.23.0

func (m *Model) BindAnimationSubtree(root animation.Node, nodeName string)

BindAnimationSubtree binds all nodes in the subtree of the node with the specified name to the bones of the specified animation node tree through the Scene.ArmatureBindingSet. The tree is not advanced by this; use Scene.PlayAnimation for that.

func (*Model) FindNode added in v0.10.0

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

FindNode is a convenience method that searches for a node by its name in the model hierarchy.

func (*Model) FindRecording added in v0.23.0

func (m *Model) FindRecording(name string) *animation.Clip

func (*Model) Nodes added in v0.23.0

func (m *Model) Nodes() IdentifiableList[hierarchy.NodeID]

func (*Model) Recordings added in v0.23.0

func (m *Model) Recordings() []*animation.Clip

func (*Model) Root added in v0.9.0

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

Root returns the root node of the model hierarchy.

func (*Model) Skeleton added in v0.25.0

func (m *Model) Skeleton() *animation.Skeleton

Skeleton returns the skeleton that resolves this model's node names to bone indices and holds their rest transforms. It is used when constructing animation node trees for this model.

type ModelInfo added in v0.9.0

type ModelInfo struct {

	// Template specifies the template from which this instance will
	// be created.
	Template *ModelTemplate

	// Name specifies the name of this instance.
	Name opt.T[string]

	// SubTreeNode 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.
	SubTreeNode opt.T[string]

	// 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 - whether it should be added to the scene hierarchy.
	//
	// TODO: Base this on individual node flags.
	IsDynamic bool

	// DiscardHierarchy will remove the model's hierarchy from the scene
	// after instantiation, leaving only the graphical and physical
	// representations.
	//
	// This is applicable only for static models.
	DiscardHierarchy bool
}

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

type ModelTemplate added in v0.23.0

ModelTemplate represents a template for a model that can be instantiated in a Scene.

func LoadModelTemplate added in v0.23.0

func LoadModelTemplate(loader *AssetLoader, assetModel dto.Model) (*ModelTemplate, error)

LoadModelTemplate resolves a model template from the given asset data.

This is a blocking operation and should be called from a worker thread.

func (*ModelTemplate) FindRecording added in v0.23.0

func (t *ModelTemplate) FindRecording(name string) *animation.Clip

type NodeTemplate added in v0.23.0

type NodeTemplate struct {
	ParentID uint32
	Name     string
	Position dprec.Vec3
	Rotation dprec.Quat
	Scale    dprec.Vec3
}

NodeTemplate represents a template for a node in the scene hierarchy.

type PointLightBindingSolver added in v0.25.0

type PointLightBindingSolver struct{}

func NewPointLightBindingSolver added in v0.25.0

func NewPointLightBindingSolver() *PointLightBindingSolver

func (*PointLightBindingSolver) OnDelete added in v0.25.0

func (s *PointLightBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, light *graphics.PointLight)

func (*PointLightBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *PointLightBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, light *graphics.PointLight, fraction float64)

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 PointLightTemplate added in v0.23.0

type PointLightTemplate struct {
	NodeID       uint32
	EmitColor    dprec.Vec3
	EmitDistance float64
	CastShadow   bool
}

PointLightTemplate represents a template for a point light in the scene.

type ResourceLoader added in v0.23.0

type ResourceLoader[T any] interface {

	// ApplicableType returns the reflect.Type of the resource that this loader
	// is capable of loading. This is used to determine which loader to use
	// when loading a resource.
	ApplicableType() reflect.Type

	// LoadResource loads the resource from the given asset.
	LoadResource(loader *AssetLoader, asset *chunked.Asset) (T, error)

	// UnloadResource unloads the given resource. This is called when the resource
	// is no longer needed and should be cleaned up.
	UnloadResource(loader *AssetLoader, resource T) error
}

ResourceLoader represents a loader for a specific type of resource.

func GenericResourceLoader added in v0.23.0

func GenericResourceLoader[T any](delegate ResourceLoader[T]) ResourceLoader[any]

GenericResourceLoader allows a generic resource loader to be passed to the engine.

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.

This makes it possible to release multiple resources at once, without having to track them individually.

func (*ResourceSet) Delete added in v0.9.0

func (s *ResourceSet) Delete()

Delete schedules all resources managed by this ResourceSet for deletion.

This method can be called from any thread.

func (*ResourceSet) Engine added in v0.23.0

func (s *ResourceSet) Engine() *Engine

Engine returns the engine associated with this ResourceSet.

func (*ResourceSet) FetchResource added in v0.23.0

func (s *ResourceSet) FetchResource(path string, target any) async.Operation

FetchResource requests a resource to be read from the storage and loaded.

Once loaded, the resource will be stored in the target object and will be tracked by this ResourceSet. Once the ResourceSet is deleted, all tracked resources will be scheduled for deletion.

The target must be a non-nil pointer to a type that has a registered ResourceLoader. Out of the box, an Engine supports *ModelTemplate for model assets and github.com/mokiat/lacking/core/audio.Media for sound assets. Loading a sound fails if the engine was created without WithAudio.

This method can be called from any thread.

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) AmbientLightBindingSet added in v0.23.0

func (s *Scene) AmbientLightBindingSet() *hierarchy.Binding[*graphics.AmbientLight]

AmbientLightBindingSet returns the binding set that binds ambient light objects.

func (*Scene) ArmatureBindingSet added in v0.23.0

func (s *Scene) ArmatureBindingSet() *hierarchy.Binding[AnimationSource]

ArmatureBindingSet returns the binding set that drives hierarchy nodes from the bones of animation node trees.

func (*Scene) BodyBindingSet added in v0.23.0

func (s *Scene) BodyBindingSet() *hierarchy.Binding[physics.BodyID]

BodyBindingSet returns the binding set that binds physics bodies.

func (*Scene) BoneBindingSet added in v0.23.0

func (s *Scene) BoneBindingSet() *hierarchy.Binding[BoneTarget]

BoneBindingSet returns the binding set that binds bone target objects.

func (*Scene) CameraBindingSet added in v0.23.0

func (s *Scene) CameraBindingSet() *hierarchy.Binding[*graphics.Camera]

CameraBindingSet returns the binding set that binds camera objects.

func (*Scene) CreateAmbientLight added in v0.19.0

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

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

func (*Scene) CreateDirectionalLight added in v0.19.0

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

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

func (*Scene) CreatePointLight added in v0.19.0

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

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.NodeID

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) DirectionalLightBindingSet added in v0.23.0

func (s *Scene) DirectionalLightBindingSet() *hierarchy.Binding[*graphics.DirectionalLight]

DirectionalLightBindingSet returns the binding set that binds directional light objects.

func (*Scene) ECS added in v0.9.0

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

ECS returns the ECS sub-scene associated with this scene.

Returns `nil` if this scene does not have ECS enabled.

func (*Scene) EmitterBindingSet added in v0.25.0

func (s *Scene) EmitterBindingSet() *hierarchy.Binding[sound.EmitterID]

EmitterBindingSet returns the binding set that binds sound emitters.

func (*Scene) Engine added in v0.23.0

func (s *Scene) Engine() *Engine

Engine returns the engine 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 sub-scene associated with the scene.

Returns `nil` if this scene does not have Graphics enabled.

func (*Scene) Hierarchy added in v0.23.0

func (s *Scene) Hierarchy() *hierarchy.Scene

Hierarchy returns the Hierarchy sub-scene associated with this scene.

func (*Scene) InstantiateModel added in v0.23.0

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

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) ListenerBindingSet added in v0.25.0

func (s *Scene) ListenerBindingSet() *hierarchy.Binding[sound.ListenerID]

ListenerBindingSet returns the binding set that binds sound listeners.

func (*Scene) MeshBindingSet added in v0.23.0

func (s *Scene) MeshBindingSet() *hierarchy.Binding[*graphics.Mesh]

MeshBindingSet returns the binding set that binds mesh objects.

func (*Scene) Physics added in v0.9.0

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

Physics returns the Physics sub-scene associated with this scene.

Returns `nil` if this scene does not have Physics enabled.

func (*Scene) PlaceAmbientLight added in v0.23.0

func (s *Scene) PlaceAmbientLight(nodeID hierarchy.NodeID, info AmbientLightInfo) *graphics.AmbientLight

PlaceAmbientLight places an ambient light on the provided node.

func (*Scene) PlaceDirectionalLight added in v0.23.0

func (s *Scene) PlaceDirectionalLight(nodeID hierarchy.NodeID, info DirectionalLightInfo) *graphics.DirectionalLight

PlaceDirectionalLight places a directional light on the provided node.

func (*Scene) PlacePointLight added in v0.23.0

func (s *Scene) PlacePointLight(nodeID hierarchy.NodeID, info PointLightInfo) *graphics.PointLight

PlacePointLight places a point light on the provided node.

func (*Scene) PlaceSky added in v0.23.0

func (s *Scene) PlaceSky(node hierarchy.NodeID, info SkyInfo) *graphics.Sky

PlaceSky places a sky on the provided node using the provided definition.

func (*Scene) PlaceSpotLight added in v0.23.0

func (s *Scene) PlaceSpotLight(nodeID hierarchy.NodeID, info SpotLightInfo) *graphics.SpotLight

PlaceSpotLight places a spot light on the provided node.

func (*Scene) PlayAnimation added in v0.10.0

func (s *Scene) PlayAnimation(node animation.Node)

PlayAnimation adds the provided animation node tree to the scene, which advances it on each update. The node must be comparable, which is the case for pointer types.

func (*Scene) PointLightBindingSet added in v0.23.0

func (s *Scene) PointLightBindingSet() *hierarchy.Binding[*graphics.PointLight]

PointLightBindingSet returns the binding set that binds point light objects.

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) SkyBindingSet added in v0.23.0

func (s *Scene) SkyBindingSet() *hierarchy.Binding[*graphics.Sky]

SkyBindingSet returns the binding set that binds sky objects.

func (*Scene) Sound added in v0.25.0

func (s *Scene) Sound() *sound.Scene

Sound returns the Sound sub-scene associated with the scene.

Returns `nil` if this scene does not have Sound enabled or if the engine has no audio API.

func (*Scene) SpotLightBindingSet added in v0.23.0

func (s *Scene) SpotLightBindingSet() *hierarchy.Binding[*graphics.SpotLight]

SpotLightBindingSet returns the binding set that binds spot light objects.

func (*Scene) StopAnimation added in v0.23.0

func (s *Scene) StopAnimation(node animation.Node)

StopAnimation removes the provided animation node tree from the scene, so that it is no longer advanced.

func (*Scene) SubscribeFixedUpdate added in v0.23.0

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

SubscribeFixedUpdate adds a callback to be executed after each fixed time update.

func (*Scene) SubscribeInterpolation added in v0.23.0

func (s *Scene) SubscribeInterpolation(callback timestep.InterpolationCallback) *timestep.InterpolationSubscription

SubscribeInterpolation adds a callback to be executed after a series of fixed time updates are performed and interpolation is to be performed.

func (*Scene) SubscribeStepUpdate added in v0.23.0

func (s *Scene) SubscribeStepUpdate(callback timestep.StepCallback) *timestep.StepSubscription

SubscribeStepUpdate adds a callback to be executed before fixed time updates

func (*Scene) SubscribeUpdate added in v0.23.0

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

SubscribeUpdate adds a callback to be executed after each dynamic time update.

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 SceneInfo added in v0.23.0

type SceneInfo struct {

	// IncludeECS indicates whether an ECS sub-scene would be required.
	//
	// Defaults to `true`.
	IncludeECS opt.T[bool]

	// IncludePhysics indicates whether a Physics sub-scene would be required.
	//
	// Defaults to `true`.
	IncludePhysics opt.T[bool]

	// IncludeGraphics indicates whether a Graphics sub-scene would be required.
	//
	// Defaults to `true`.
	IncludeGraphics opt.T[bool]

	// IncludeSound indicates whether a Sound sub-scene would be required.
	//
	// Defaults to `true`.
	IncludeSound opt.T[bool]

	// ECSScope specifies the scope to be used for the ECS sub-scene of the scene.
	//
	// Defaults to the global `ECSScope`.
	ECSScope opt.T[*ecs.Scope]

	// FixedTimestep determines the duration of a single fixed-step tick.
	FixedTimestep opt.T[time.Duration]
}

SceneInfo specifies details regarding the scene to be created.

type SkyBindingSolver added in v0.25.0

type SkyBindingSolver struct{}

func NewSkyBindingSolver added in v0.25.0

func NewSkyBindingSolver() *SkyBindingSolver

func (*SkyBindingSolver) OnDelete added in v0.25.0

func (s *SkyBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, sky *graphics.Sky)

func (*SkyBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *SkyBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, sky *graphics.Sky, fraction float64)

type SkyInfo added in v0.23.0

type SkyInfo struct {
	Definition *graphics.SkyDefinition
}

SkyInfo contains the information required to create a sky.

type SkyTemplate added in v0.23.0

type SkyTemplate struct {
	NodeID     uint32
	Definition *graphics.SkyDefinition
}

SkyTemplate represents a sky template that can be instantiated in a scene.

type SpotLightBindingSolver added in v0.25.0

type SpotLightBindingSolver struct{}

func NewSpotLightBindingSolver added in v0.25.0

func NewSpotLightBindingSolver() *SpotLightBindingSolver

func (*SpotLightBindingSolver) OnDelete added in v0.25.0

func (s *SpotLightBindingSolver) OnDelete(_ *hierarchy.Scene, nodeID hierarchy.NodeID, light *graphics.SpotLight)

func (*SpotLightBindingSolver) OnInterpolationFromNode added in v0.25.0

func (s *SpotLightBindingSolver) OnInterpolationFromNode(hierarchyScene *hierarchy.Scene, nodeID hierarchy.NodeID, light *graphics.SpotLight, fraction float64)

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 SpotLightTemplate added in v0.23.0

type SpotLightTemplate struct {
	NodeID         uint32
	EmitColor      dprec.Vec3
	EmitDistance   float64
	EmitAngleOuter dprec.Angle
	EmitAngleInner dprec.Angle
	CastShadow     bool
}

SpotLightTemplate represents a template for a spot light in the scene.

type TerrainTemplate added in v0.25.0

type TerrainTemplate struct {
	NodeID uint32

	CollisionMeshes []physics.CollisionMesh
}

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 animation provides skeletal animation playback through trees of composable animation nodes.
Package animation provides skeletal animation playback through trees of composable animation nodes.
asset
dsl
dto
mdl
ecs
Package ecs provides an Entity-Component-System (ECS) framework for game development.
Package ecs provides an Entity-Component-System (ECS) framework for game development.
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 a scene graph of 3D nodes arranged in parent-child relationships.
Package hierarchy provides a scene graph of 3D nodes arranged in parent-child relationships.
Package physics provides a rigid-body physics simulation.
Package physics provides a rigid-body physics simulation.
Package sound provides a game-oriented sound stage on top of the low-level audio package.
Package sound provides a game-oriented sound stage on top of the low-level audio package.

Jump to

Keyboard shortcuts

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