game

package
v0.23.0 Latest Latest
Warning

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

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

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

This section is empty.

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

func InstantiatePhysicsBodyTemplateDynamic(scene *Scene, template BodyTemplate, nodes IdentifiableList[hierarchy.NodeID]) physics.Body

InstantiatePhysicsBodyTemplateDynamic creates a dynamic physics body in the given scene from the provided body template and returns it.

This operation needs to be called from the main thread.

func InstantiatePhysicsBodyTemplateStatic added in v0.23.0

func InstantiatePhysicsBodyTemplateStatic(scene *Scene, template BodyTemplate, nodes IdentifiableList[hierarchy.NodeID])

InstantiatePhysicsBodyTemplateStatic creates a static physics body in the given scene from the provided body template.

This operation needs to be called from the main thread.

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

func NewAmbientLightBinding() hierarchy.InterpolationBinding[*graphics.AmbientLight]

NewAmbientLightBinding creates a new binding for ambient lights.

func NewAnimationBinding added in v0.23.0

func NewAnimationBinding() hierarchy.SourceBinding[*animation.Player]

NewAnimationBinding creates a new binding for animations.

func NewBodyBinding added in v0.23.0

func NewBodyBinding() hierarchy.SourceBinding[physics.Body]

NewBodyBinding creates a new binding for physics bodies.

func NewBoneBinding added in v0.23.0

func NewBoneBinding() hierarchy.InterpolationBinding[BoneTarget]

NewBoneBinding creates a new binding for armature bones.

func NewCameraBinding added in v0.23.0

func NewCameraBinding() hierarchy.InterpolationBinding[*graphics.Camera]

NewCameraBinding creates a new binding for cameras.

func NewDirectionalLightBinding added in v0.23.0

func NewDirectionalLightBinding() hierarchy.InterpolationBinding[*graphics.DirectionalLight]

NewDirectionalLightBinding creates a new binding for directional lights.

func NewMeshBinding added in v0.23.0

func NewMeshBinding() hierarchy.InterpolationBinding[*graphics.Mesh]

NewMeshBinding creates a new binding for meshes.

func NewPointLightBinding added in v0.23.0

func NewPointLightBinding() hierarchy.InterpolationBinding[*graphics.PointLight]

NewPointLightBinding creates a new binding for point lights.

func NewSkyBinding added in v0.23.0

func NewSkyBinding() hierarchy.InterpolationBinding[*graphics.Sky]

NewSkyBinding creates a new binding for skies.

func NewSpotLightBinding added in v0.23.0

func NewSpotLightBinding() hierarchy.InterpolationBinding[*graphics.SpotLight]

NewSpotLightBinding creates a new binding for spot lights.

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

func UnloadPhysicsBodyDefinition(loader *AssetLoader, idBodyDefinition Identifiable[*physics.BodyDefinition]) error

UnloadPhysicsBodyDefinition unloads a physics body definition from the asset loader.

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

func UnloadPhysicsBodyDefinitions added in v0.23.0

func UnloadPhysicsBodyDefinitions(loader *AssetLoader, idBodyDefinitions IdentifiableList[*physics.BodyDefinition]) error

UnloadPhysicsBodyDefinitions unloads a list of physics body definitions from the asset loader.

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

func UnloadPhysicsBodyTemplate added in v0.23.0

func UnloadPhysicsBodyTemplate(loader *AssetLoader, idBody Identifiable[BodyTemplate]) error

UnloadPhysicsBodyTemplate unloads a physics body template from the asset loader.

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

func UnloadPhysicsBodyTemplates added in v0.23.0

func UnloadPhysicsBodyTemplates(loader *AssetLoader, idBodies IdentifiableList[BodyTemplate]) error

UnloadPhysicsBodyTemplates unloads a list of physics body templates from the asset loader.

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

func UnloadPhysicsMaterial added in v0.23.0

func UnloadPhysicsMaterial(loader *AssetLoader, idMaterial Identifiable[*physics.Material]) error

UnloadPhysicsMaterial unloads a physics material from the asset loader.

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

func UnloadPhysicsMaterials added in v0.23.0

func UnloadPhysicsMaterials(loader *AssetLoader, idMaterials IdentifiableList[*physics.Material]) error

UnloadPhysicsMaterials unloads a list of physics materials 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.Recording]) 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.Recording]) 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 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 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 BodyTemplate added in v0.23.0

type BodyTemplate struct {
	NodeID     uint32
	Definition *physics.BodyDefinition
}

BodyTemplate represents a template for physics body that can be instantiated in a scene.

type BoneTarget added in v0.23.0

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

BoneTarget is a placeholder type for armature bone bindings.

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(storage chunked.Storage, 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) Storage added in v0.23.0

func (c *Controller) Storage() chunked.Storage

Storage returns the storage 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 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 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) 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) 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) 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() chunked.Storage

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

func WithStorage(storage chunked.Storage) EngineOption

type GenericBindingSet added in v0.23.0

type GenericBindingSet interface {
	ApplyTargetToNode(id hierarchy.NodeID)
	ApplyTargetsToNodes()
	ApplyNodeToTarget(id hierarchy.NodeID, fraction float64)
	ApplyNodesToTargets(fraction float64)
	DeleteStale()
}

GenericBindingSet represents any hierarchy binding set, regardless of the target type.

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) (Identifiable[*animation.Recording], error)

LoadAnimationRecording loads an animation recording from the given asset.

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

func LoadPhysicsBodyDefinition(loader *AssetLoader, assetBodyDefinition dto.BodyDefinition, materials IdentifiableList[*physics.Material]) (Identifiable[*physics.BodyDefinition], error)

LoadPhysicsBodyDefinition loads a physics body definition from the given asset data.

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

func LoadPhysicsBodyTemplate added in v0.23.0

func LoadPhysicsBodyTemplate(loader *AssetLoader, assetBody dto.Body, bodyDefinitions IdentifiableList[*physics.BodyDefinition]) (Identifiable[BodyTemplate], error)

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

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

func LoadPhysicsMaterial added in v0.23.0

func LoadPhysicsMaterial(loader *AssetLoader, assetMaterial dto.BodyMaterial) (Identifiable[*physics.Material], error)

LoadPhysicsMaterial loads a physics material 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) (IdentifiableList[*animation.Recording], error)

LoadAnimationRecordings loads a list of animation recordings from the given asset animations.

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

func LoadPhysicsBodyDefinitions(loader *AssetLoader, assetBodyDefinitions []dto.BodyDefinition, materials IdentifiableList[*physics.Material]) (IdentifiableList[*physics.BodyDefinition], error)

LoadPhysicsBodyDefinitions loads a list of physics body definitions from the given asset body definitions.

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

func LoadPhysicsBodyTemplates added in v0.23.0

func LoadPhysicsBodyTemplates(loader *AssetLoader, assetBodies []dto.Body, bodyDefinitions IdentifiableList[*physics.BodyDefinition]) (IdentifiableList[BodyTemplate], error)

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

func LoadPhysicsMaterials(loader *AssetLoader, assetMaterials []dto.BodyMaterial) (IdentifiableList[*physics.Material], error)

LoadPhysicsMaterials loads a list of physics materials from the given asset materials.

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 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) *animation.Player

func (*Model) BindAnimationSubtree added in v0.23.0

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

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

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

func (*Model) Root added in v0.9.0

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

Root returns the root node of the model hierarchy.

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

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

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.InterpolationBindingSet[*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.SourceBindingSet[*animation.Player]

ArmatureBindingSet returns the binding set that binds animation players to armatures.

func (*Scene) BodyBindingSet added in v0.23.0

func (s *Scene) BodyBindingSet() *hierarchy.SourceBindingSet[physics.Body]

BodyBindingSet returns the binding set that binds physics bodies.

func (*Scene) BoneBindingSet added in v0.23.0

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

BoneBindingSet returns the binding set that binds bone target objects.

func (*Scene) CameraBindingSet added in v0.23.0

func (s *Scene) CameraBindingSet() *hierarchy.InterpolationBindingSet[*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.InterpolationBindingSet[*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) 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) MeshBindingSet added in v0.23.0

func (s *Scene) MeshBindingSet() *hierarchy.InterpolationBindingSet[*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(player *animation.Player)

PlayAnimation adds the provided animation player to the scene.

func (*Scene) PointLightBindingSet added in v0.23.0

func (s *Scene) PointLightBindingSet() *hierarchy.InterpolationBindingSet[*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.InterpolationBindingSet[*graphics.Sky]

SkyBindingSet returns the binding set that binds sky objects.

func (*Scene) SpotLightBindingSet added in v0.23.0

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

SpotLightBindingSet returns the binding set that binds spot light objects.

func (*Scene) StopAnimation added in v0.23.0

func (s *Scene) StopAnimation(player *animation.Player)

StopAnimationTree removes the provided animation player from the scene.

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]

	// 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 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 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 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
asset
dsl
dto
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