project

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 48 Imported by: ? modules, 0 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 (
	DefaultSceneFile = "main.json"
	SceneDirectory   = "resources/scenes"
	ModFileName      = "mod.json"
)
View Source
const ModulePlanFile = "resources/modules.bin"

Variables

This section is empty.

Functions

func ClampFloat32

func ClampFloat32(value, minimum, maximum float32) float32

func ClampFloat64

func ClampFloat64(value, minimum, maximum float64) float64

func MarshalModulePlan

func MarshalModulePlan(plan *ProjectPlan) ([]byte, error)

MarshalModulePlan is build-time work. The binary retains resolved indices, typed slot defaults and behavior entries for every registered scene.

func NormalizeEnvironmentPath

func NormalizeEnvironmentPath(value string) (string, error)

NormalizeEnvironmentPath accepts a baked PNG atlas, RGBE HDR, or Ultra HDR JPEG panorama.

func NormalizeLocalResourcePath

func NormalizeLocalResourcePath(value string) (string, error)

NormalizeLocalResourcePath validates a file reference that cannot contain parent segments.

func NormalizeResourcePath

func NormalizeResourcePath(value string) (string, error)

NormalizeResourcePath validates and canonicalizes a project-relative file reference. Parent segments are retained so projects mounted below an fs.FS root can share repository resources; ResolveResourcePath enforces that root.

func ParseColor

func ParseColor(value string, alpha float32) (graphics.ColorRGBA, error)

ParseColor shares the engine's authored CSS color parser with module loaders.

func Queue2DEntityUploads

func Queue2DEntityUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)

Queue2DEntityUploads collects sprites, animation frames, text and 2D materials.

func QueueEntityUploads

func QueueEntityUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)

QueueEntityUploads collects authored resources and prepared text into the shared upload queue. It does not acquire handles or invoke a render driver.

func QueueParticlesEntityUploads

func QueueParticlesEntityUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)

func QueueSpatialEntityUploads

func QueueSpatialEntityUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)

func QueueSpineEntityUploads

func QueueSpineEntityUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)

func QueueTilemapsEntityUploads

func QueueTilemapsEntityUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)

func ResolveLocalResourcePath

func ResolveLocalResourcePath(baseDir, value string) (string, error)

ResolveLocalResourcePath resolves a file that must remain below baseDir.

func ResolveModResourcePath

func ResolveModResourcePath(id ModID, file string) (string, error)

ResolveModResourcePath accepts arbitrary module-owned folder layouts. File references cannot escape a module and are never resolved at project scope.

func ResolveResourcePath

func ResolveResourcePath(baseDir, value string) (string, error)

ResolveResourcePath resolves a project-relative file reference without allowing it to escape the mounted resource source.

func ScenePath

func ScenePath(id SceneID) string

ScenePath resolves a scene ID to its authored file, relative to the project.

func ValidateProjectSpec

func ValidateProjectSpec(spec ProjectSpec) error

Types

type AmbientLightSpec

type AmbientLightSpec struct {
	Color      string  `json:"color"`
	Brightness float32 `json:"brightness"`
}

func NewAmbientLightSpec

func NewAmbientLightSpec() AmbientLightSpec

func (*AmbientLightSpec) UnmarshalJSON

func (s *AmbientLightSpec) UnmarshalJSON(data []byte) error

type AnimationClipSpec

type AnimationClipSpec struct {
	FloatTracks   []AnimationTrackSpec[float32]     `json:"floatTracks,omitempty"`
	TextureTracks []AnimationTrackSpec[TextureSpec] `json:"textureTracks,omitempty"`
	BoolTracks    []AnimationTrackSpec[bool]        `json:"boolTracks,omitempty"`
	Events        []AnimationEventSpec              `json:"events,omitempty"`
	Duration      float32                           `json:"duration"`
	SampleRate    float32                           `json:"sampleRate"`
	Loop          bool                              `json:"loop"`
}

func DefaultAnimationClip

func DefaultAnimationClip(spec SceneNodeSpec) AnimationClipSpec

DefaultAnimationClip creates the initial clip for an animation component that has no authored clip yet. Scene loading and the editor use the same first keyframe.

func (AnimationClipSpec) Clone

Clone returns an independent authoring copy, including texture slice data.

func (AnimationClipSpec) HasContent

func (s AnimationClipSpec) HasContent() bool

HasContent reports whether the clip contains authored animation data.

func (AnimationClipSpec) Validate

func (s AnimationClipSpec) Validate() error

Validate validates an inline animation clip.

type AnimationComponentSpec

type AnimationComponentSpec struct {
	Clip  AnimationClipSpec `json:"clip,omitzero"`
	Speed float32           `json:"speed,omitempty"`
}

AnimationComponentSpec attaches one immutable inline clip to a node.

func (*AnimationComponentSpec) UnmarshalJSON

func (s *AnimationComponentSpec) UnmarshalJSON(data []byte) error

type AnimationEventSpec

type AnimationEventSpec struct {
	Name  string  `json:"name"`
	Value string  `json:"value,omitempty"`
	Time  float32 `json:"time"`
}

type AnimationKeyframeSpec

type AnimationKeyframeSpec[T any] struct {
	Value      T                    `json:"value"`
	InTangent  T                    `json:"inTangent,omitzero"`
	OutTangent T                    `json:"outTangent,omitzero"`
	Tween      scene.AnimationTween `json:"tween,omitempty"`
	Curve      scene.AnimationCurve `json:"curve,omitzero"`
	Time       float32              `json:"time"`
}

func (AnimationKeyframeSpec[T]) EffectiveAnimationTween

func (key AnimationKeyframeSpec[T]) EffectiveAnimationTween(defaultTween scene.AnimationTween) scene.AnimationTween

EffectiveAnimationTween returns the curve used for the segment starting at key, defaulting to the track's type-specific curve.

type AnimationTrackSpec

type AnimationTrackSpec[T any] struct {
	Binding   scene.AnimationBinding     `json:"binding"`
	TimeTween scene.AnimationTween       `json:"timeTween,omitempty"`
	Keyframes []AnimationKeyframeSpec[T] `json:"keyframes"`
	TimeCurve scene.AnimationCurve       `json:"timeCurve,omitzero"`
}

type AppConfig

type AppConfig struct {
	Viewport SizeConfig
	Window   WindowConfig
}

type AreaLightSpec

type AreaLightSpec struct {
	Color     string                  `json:"color"`
	Unit      graphics.LightUnit      `json:"unit"`
	Shape     render3d.AreaLightShape `json:"shape"`
	Intensity float32                 `json:"intensity"`
	Range     float32                 `json:"range"`
	Width     float32                 `json:"width"`
	Height    float32                 `json:"height"`
	Radius    float32                 `json:"radius"`
}

func NewAreaLightSpec

func NewAreaLightSpec() AreaLightSpec

func (AreaLightSpec) Light

func (s AreaLightSpec) Light() (render3d.AreaLight, error)

func (*AreaLightSpec) UnmarshalJSON

func (s *AreaLightSpec) UnmarshalJSON(data []byte) error

type BoxCollider2DSpec

type BoxCollider2DSpec struct {
	Collider2DSettingsSpec
	Offset   [2]float64 `json:"offset,omitempty"`
	Width    float64    `json:"width,omitempty"`
	Height   float64    `json:"height,omitempty"`
	Rotation float64    `json:"rotation,omitempty"`
}

func NewBoxCollider2DSpec

func NewBoxCollider2DSpec() BoxCollider2DSpec

func (*BoxCollider2DSpec) UnmarshalJSON

func (s *BoxCollider2DSpec) UnmarshalJSON(data []byte) error

type Bundle

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

func Load

func Load(source iofs.FS, root string) (*Bundle, error)

func LoadConfiguredWith

func LoadConfiguredWith[F ResourceFeature](source iofs.FS, root string, config EngineConfig) (*Bundle, error)

LoadConfiguredWith loads a project using explicit resource and runtime feature selections.

func LoadDefault

func LoadDefault() (*Bundle, error)

func LoadDefaultConfigured

func LoadDefaultConfigured[F ResourceFeature](config EngineConfig) (*Bundle, error)

LoadDefaultConfigured loads a project from the resource source mounted by generated build code.

func LoadDirectoryConfigured

func LoadDirectoryConfigured[F ResourceFeature](dir string, config EngineConfig) (*Bundle, error)

LoadDirectoryConfigured loads a project using an explicit EngineConfig while retaining the caller's statically selected resource feature type.

func LoadDirectoryFromManifest

func LoadDirectoryFromManifest[F ResourceFeature](dir string) (*Bundle, error)

LoadDirectoryFromManifest loads a project using the explicit EngineConfig stored in resources/project.json. The resource feature type remains a compile-time decoder/link boundary while runtime features stay project data.

func LoadDirectoryWithProfile

func LoadDirectoryWithProfile[P LoadProfile, F ResourceFeature](dir string) (*Bundle, error)

LoadDirectoryWithProfile loads a project through a statically selected scene/resource profile. The profile type is a link boundary: only the resource and scene builders implemented by P are reachable from the final executable.

func MustDefault

func MustDefault() *Bundle

MustDefault loads the mounted project resource package and panics on error.

func MustLoadDefault

func MustLoadDefault(loader func(string) (*Bundle, error)) *Bundle

MustLoadDefault invokes a generated project loader against the mounted resource package and panics when loading fails.

func (*Bundle) AppConfig

func (b *Bundle) AppConfig() AppConfig

func (*Bundle) BeginPreloadScene

func (b *Bundle) BeginPreloadScene(world *ecs.World, id SceneID) (*ScenePreloader, error)

BeginPreloadScene starts an incremental scene preload. Advance must be called until Ready reports true before Activate may be used.

func (*Bundle) ClearColor

func (b *Bundle) ClearColor() (graphics.ColorRGBA, bool)

func (*Bundle) CompileAnimationClip

func (b *Bundle) CompileAnimationClip(spec AnimationClipSpec) (*scene.AnimationClip, error)

CompileAnimationClip compiles an inline authoring clip against this bundle's texture resources. The returned clip is independent of any scene instance and can be shared across instances and editor previews.

func (*Bundle) Dispose

func (b *Bundle) Dispose() error

func (*Bundle) EntrySceneID

func (b *Bundle) EntrySceneID() SceneID

func (*Bundle) Has3D

func (b *Bundle) Has3D() bool

func (*Bundle) HasUI

func (b *Bundle) HasUI() bool

func (*Bundle) InstantiateEntryScene

func (b *Bundle) InstantiateEntryScene(world *ecs.World) (*SceneInstance, error)

func (*Bundle) InstantiateScene

func (b *Bundle) InstantiateScene(world *ecs.World, id SceneID) (*SceneInstance, error)

func (*Bundle) ModelAnimation

func (b *Bundle) ModelAnimation(modelID, animationName string) (*scene.AnimationClip, error)

ModelAnimation returns a compiled ECS clip exported by a glTF/FBX model. The clip is immutable and can be shared by multiple Animator components.

func (*Bundle) ModelDeformation

func (b *Bundle) ModelDeformation(modelID string) (render3d.Deformation, error)

ModelDeformation creates reusable runtime state sized for the model's morph targets, joints and rigid nodes. Initial matrices preserve the source pose.

func (*Bundle) ModelMaterials

func (b *Bundle) ModelMaterials(modelID string) ([]graphics.StandardMaterial, error)

ModelMaterials returns imported PBR descriptors. Texture paths are resolved through the same resource cache used by authored model materials.

func (*Bundle) ModelMorphTargets

func (b *Bundle) ModelMorphTargets(modelID string) ([]ModelMorphTarget, error)

ModelMorphTargets returns imported morph data without copying its delta arrays. The model cache owns the returned slices for the bundle lifetime.

func (*Bundle) ModelNodes

func (b *Bundle) ModelNodes(modelID string) ([]ModelNode, error)

ModelNodes returns immutable node metadata owned by the model cache.

func (*Bundle) ModelRig

func (b *Bundle) ModelRig(modelID string) (*ModelRig, error)

func (*Bundle) ModelSkeleton

func (b *Bundle) ModelSkeleton(modelID string) ([]ModelJoint, error)

ModelSkeleton returns the immutable skeleton metadata imported for a model.

func (*Bundle) ModelSkinWeights

func (b *Bundle) ModelSkinWeights(modelID string) ([]ModelSkinVertex, error)

ModelSkinWeights returns the imported skin influences in mesh vertex order.

func (*Bundle) PreloadScene

func (b *Bundle) PreloadScene(id SceneID) error

PreloadScene synchronously prepares CPU resources in an isolated world. PreloadSceneFor optionally uploads them to an explicit device; interactive loading uses BeginPreloadScene.

func (*Bundle) PreloadSceneFor

func (b *Bundle) PreloadSceneFor(device *render.Device, id SceneID) error

PreloadSceneFor prepares CPU resources and optionally uploads to the supplied device.

func (*Bundle) PreloadScenes

func (b *Bundle) PreloadScenes(ids ...SceneID) error

PreloadScenes preloads registered scenes in order.

func (*Bundle) Resources

func (b *Bundle) Resources() *Resources

func (*Bundle) SceneIDs

func (b *Bundle) SceneIDs() []SceneID

func (*Bundle) ValidateSceneFeatures

func (b *Bundle) ValidateSceneFeatures(id SceneID, installed func(RuntimeFeatureID) bool) error

ValidateSceneFeatures verifies that installed reports all runtime features needed to materialize scene id. It keeps the check at the scene boundary so loading a project cannot silently produce an unrendered or unanimated scene.

func (*Bundle) ViewportSize

func (b *Bundle) ViewportSize() (int, int, bool)

func (*Bundle) WindowIcon

func (b *Bundle) WindowIcon() []byte

func (*Bundle) WindowIconDecoder

func (b *Bundle) WindowIconDecoder() window.IconDecoder

WindowIconDecoder returns the decoder selected by the project's resource feature. A nil value means window icons are not configured.

func (*Bundle) WindowSize

func (b *Bundle) WindowSize() (int, int, bool)

type Camera3DSpec

type Camera3DSpec struct {
	SSAO        *SSAOSpec            `json:"ssao,omitempty"`
	SSR         *SSRSpec             `json:"ssr,omitempty"`
	Environment *EnvironmentSpec     `json:"environment,omitempty"`
	Fog         *FogSpec             `json:"fog,omitempty"`
	ClearColor  string               `json:"clearColor"`
	ToneMapping graphics.ToneMapping `json:"toneMapping,omitempty"`
	Quality     render3d.Quality     `json:"quality,omitempty"`
	Exposure    graphics.Exposure    `json:"exposure"`
	Order       int                  `json:"order"`
	Viewport    CameraViewport3DSpec `json:"viewport"`
	Near        float32              `json:"near"`
	Fov         float32              `json:"fov"`
	FXAA        bool                 `json:"fxaa,omitempty"`
}

func NewCamera3DSpec

func NewCamera3DSpec() Camera3DSpec

func (*Camera3DSpec) UnmarshalJSON

func (s *Camera3DSpec) UnmarshalJSON(data []byte) error

type CameraViewport3DSpec

type CameraViewport3DSpec struct {
	X      float32 `json:"x"`
	Y      float32 `json:"y"`
	Width  float32 `json:"width"`
	Height float32 `json:"height"`
}

type CircleCollider2DSpec

type CircleCollider2DSpec struct {
	Collider2DSettingsSpec
	Offset [2]float64 `json:"offset,omitempty"`
	Radius float64    `json:"radius,omitempty"`
}

func NewCircleCollider2DSpec

func NewCircleCollider2DSpec() CircleCollider2DSpec

func (*CircleCollider2DSpec) UnmarshalJSON

func (s *CircleCollider2DSpec) UnmarshalJSON(data []byte) error

type Collider2DSettingsSpec

type Collider2DSettingsSpec struct {
	Friction      float64 `json:"friction,omitempty"`
	Restitution   float64 `json:"restitution,omitempty"`
	Sensor        bool    `json:"sensor,omitempty"`
	Group         int32   `json:"group,omitempty"`
	Categories    uint64  `json:"categories,omitempty"`
	Mask          uint64  `json:"mask,omitempty"`
	CollisionType uint32  `json:"collisionType,omitempty"`
}

func NewCollider2DSettingsSpec

func NewCollider2DSettingsSpec() Collider2DSettingsSpec

type Collider3DSettingsSpec

type Collider3DSettingsSpec struct {
	Friction      float64 `json:"friction,omitempty"`
	Restitution   float64 `json:"restitution,omitempty"`
	Sensor        bool    `json:"sensor,omitempty"`
	Group         int32   `json:"group,omitempty"`
	Categories    uint64  `json:"categories,omitempty"`
	Mask          uint64  `json:"mask,omitempty"`
	CollisionType uint32  `json:"collisionType,omitempty"`
}

func NewCollider3DSettingsSpec

func NewCollider3DSettingsSpec() Collider3DSettingsSpec

type CollisionPieceSpec

type CollisionPieceSpec struct {
	Vertices [][3]float64 `json:"vertices"`
	Indices  []uint32     `json:"indices,omitempty"`
	Position [3]float64   `json:"position,omitempty"`
	Rotation [4]float64   `json:"rotation,omitempty"`
}

type CollisionResourceSpec

type CollisionResourceSpec struct {
	Cooked   *enginephysics.CookedCollision `json:"-"`
	Mode     enginephysics.CollisionMode    `json:"mode"`
	Vertices [][3]float64                   `json:"vertices,omitempty"`
	Indices  []uint32                       `json:"indices,omitempty"`
	Pieces   []CollisionPieceSpec           `json:"pieces,omitempty"`
}

CollisionResourceSpec is the interchange format for collision geometry exported by an offline baker such as CoACD. The runtime only consumes this deterministic geometry and never invokes the decomposition tool.

Collision resources are kept under resources/ and use a .collision.json suffix. A convex decomposition resource stores one convex piece per entry; piece indices are optional because the hull is reconstructed from support vertices, but are validated when present.

type CompileCache

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

CompileCache retains immutable module plans between authoring transactions. Scenes are always rebuilt so changed slots, types and hierarchy are validated. A cache belongs to one sequential compilation owner.

func (*CompileCache) Compile

func (cache *CompileCache) Compile(source fs.FS, root string, definitions []ModID) (*ProjectPlan, error)

type CompoundCollider3DSpec

type CompoundCollider3DSpec struct {
	Model string `json:"model,omitempty"`
	Collider3DSettingsSpec
}

func NewCompoundCollider3DSpec

func NewCompoundCollider3DSpec() CompoundCollider3DSpec

func (*CompoundCollider3DSpec) UnmarshalJSON

func (s *CompoundCollider3DSpec) UnmarshalJSON(data []byte) error

type ControlSpec

type ControlSpec struct {
	Text     string  `json:"text,omitempty"`
	Font     string  `json:"font,omitempty"`
	FontSize float64 `json:"fontSize,omitempty"`
}

type ConvexHullCollider3DSpec

type ConvexHullCollider3DSpec struct {
	Model string `json:"model,omitempty"`
	Collider3DSettingsSpec
}

func NewConvexHullCollider3DSpec

func NewConvexHullCollider3DSpec() ConvexHullCollider3DSpec

func (*ConvexHullCollider3DSpec) UnmarshalJSON

func (s *ConvexHullCollider3DSpec) UnmarshalJSON(data []byte) error

type CoordinateSpace

type CoordinateSpace string
const (
	CoordinateSpaceWorld CoordinateSpace = "world"
	CoordinateSpaceUI    CoordinateSpace = "ui"
)

type CreateProjectOptions

type CreateProjectOptions struct {
	Title string
	// Used when there is no enclosing go.mod. EngineDirectory selects a local
	// engine checkout; EngineVersion selects a published module version.
	ModulePath      string
	EngineDirectory string
	EngineVersion   string
	Width           int
	Height          int
}

CreateProjectOptions configures the authoring scaffold. Module folders and their private resource layouts are created by the module author.

type DirectionalLightSpec

type DirectionalLightSpec struct {
	Shadows     *ShadowSpec `json:"shadows,omitempty"`
	Color       string      `json:"color"`
	Illuminance float32     `json:"illuminance"`
}

func NewDirectionalLightSpec

func NewDirectionalLightSpec() DirectionalLightSpec

func (*DirectionalLightSpec) UnmarshalJSON

func (s *DirectionalLightSpec) UnmarshalJSON(data []byte) error

type EmitterSpec

type EmitterSpec struct {
	Particles  []string `json:"particles"`
	Width      float32  `json:"width"`
	Height     float32  `json:"height"`
	Count      int      `json:"count"`
	Rate       float32  `json:"rate"`
	Lifetime   float32  `json:"lifetime"`
	SpeedMin   float32  `json:"speedMin"`
	SpeedMax   float32  `json:"speedMax"`
	SizeMin    float32  `json:"sizeMin"`
	SizeMax    float32  `json:"sizeMax"`
	Direction  float32  `json:"direction"`
	Spread     float32  `json:"spread"`
	GravityX   float32  `json:"gravityX"`
	GravityY   float32  `json:"gravityY"`
	AlphaStart float32  `json:"alphaStart"`
	AlphaEnd   float32  `json:"alphaEnd"`
	Loop       bool     `json:"loop"`
}

EmitterSpec is a module component that spawns particles. It carries only emission behaviour; the sprite and colour of each particle come from the elements named by Particles, whose particle components declare textures.

type EngineConfig

type EngineConfig struct {
	Features      []RuntimeFeatureID `json:"features,omitempty"`
	Resources     []ResourceID       `json:"resources,omitempty"`
	ImageDecoders []ImageDecoderID   `json:"imageDecoders,omitempty"`
	// TextureCompressionExcludes lists project-relative resources that must keep
	// their source pixels, for example "resources/ui.png". This is useful for
	// pixel-art and other assets where block compression is visibly lossy.
	TextureCompressionExcludes []string `json:"textureCompressionExcludes,omitempty"`
	// TextureCompression enables build-time block compression. When an engine
	// section is present and the field is omitted, project loading defaults it to
	// true; set it to false for source-texture builds.
	TextureCompression bool `json:"textureCompression,omitempty"`
}

EngineConfig contains explicit project-level runtime and resource choices. The editor turns feature IDs into static InstallSystems calls during code generation.

func ReadEngineConfig

func ReadEngineConfig(source iofs.FS, root string) (EngineConfig, error)

ReadEngineConfig reads the engine section of a project manifest. A project without a manifest reports the zero config, which leaves optional features off.

func (EngineConfig) HasFeature

func (config EngineConfig) HasFeature(id RuntimeFeatureID) bool

HasFeature reports whether a runtime feature is explicitly enabled.

func (EngineConfig) HasResource

func (config EngineConfig) HasResource(id ResourceID) bool

HasResource reports whether a resource family is explicitly enabled.

func (EngineConfig) Validate

func (config EngineConfig) Validate() error

Validate checks IDs, duplicates, and explicit feature dependencies.

type EnvironmentSpec

type EnvironmentSpec struct {
	Path       string  `json:"path"`
	Intensity  float32 `json:"intensity"`
	Rotation   float32 `json:"rotation,omitempty"`
	Exposure   float32 `json:"exposure,omitempty"`
	Background bool    `json:"background"`
}

type FileResource

type FileResource struct {
	ID     string `json:"id"`
	Path   string `json:"path"`
	Stream bool   `json:"stream,omitempty"`
}

type FogSpec

type FogSpec struct {
	Mode       render3d.FogMode `json:"mode"`
	Color      string           `json:"color"`
	Brightness float32          `json:"brightness"`
	Start      float32          `json:"start"`
	End        float32          `json:"end"`
	Density    float32          `json:"density"`
}

func NewFogSpec

func NewFogSpec() *FogSpec

func (*FogSpec) Settings

func (s *FogSpec) Settings() (render3d.FogSettings, error)

func (*FogSpec) UnmarshalJSON

func (s *FogSpec) UnmarshalJSON(data []byte) error

type FontDecoder

type FontDecoder interface {
	DecodeFont([]byte, string) (*onixtext.Font, error)
}

FontDecoder decodes a project font selected by an injected resource feature.

type Hooks

type Hooks[T any] struct {
	Install   func(*T, *ScriptContext) error
	Update    func(*T, *ScriptContext) error
	Input     func(*T, *ScriptContext, *scene.InputEventContext) error
	Destroy   func(*T, *ScriptContext) error
	InputMask scene.InputMask
}

Hooks supplies statically typed lifecycle methods. Only registration creates closures; update traversal reuses scene-owned contexts and entity lists.

type IconFeature

type IconFeature[K window.IconDecoder] struct{}

IconFeature installs the decoder used by a project's window.icon setting.

func (IconFeature[K]) ConfigureResources

func (IconFeature[K]) ConfigureResources(context ResourceLoadContext, _ ResourceEntries) error

type ImageDecoder

type ImageDecoder interface {
	DecodeImage([]byte, string, graphics.TextureOptions) (*graphics.Texture, error)
}

ImageDecoder decodes scene images selected by an injected resource feature.

type ImageDecoderID

type ImageDecoderID string

ImageDecoderID identifies one statically linked image format decoder.

const (
	ImageDecoderGIF  ImageDecoderID = "gif"
	ImageDecoderJPEG ImageDecoderID = "jpeg"
	ImageDecoderPNG  ImageDecoderID = "png"
	ImageDecoderWebP ImageDecoderID = "webp"
)

type ImageFeature

type ImageFeature[I ImageDecoder] struct{}

ImageFeature installs a statically selected image decoder without importing the font, icon, or audio decoder bundles in project/assets.

func (ImageFeature[I]) ConfigureResources

func (ImageFeature[I]) ConfigureResources(context ResourceLoadContext, _ ResourceEntries) error

type LoadProfile

type LoadProfile interface {
	// contains filtered or unexported methods
}

LoadProfile is the compile-time boundary for project resource and scene support. Profiles intentionally use unexported methods so applications can select only engine-owned implementations through generic APIs. Each profile installs its resources directly on the bundle so unsupported resource families stay outside its static call graph.

type MeshSpec

type MeshSpec struct {
	Primitive string           `json:"primitive,omitempty"`
	Vertices  []MeshVertexSpec `json:"vertices,omitempty"`
	Indices   []uint32         `json:"indices,omitempty"`
	Sectors   int              `json:"sectors,omitempty"`
	Stacks    int              `json:"stacks,omitempty"`
	Size      float32          `json:"size,omitempty"`
	Radius    float32          `json:"radius,omitempty"`
}

type MeshVertexSpec

type MeshVertexSpec struct {
	Position [3]float32 `json:"position"`
	Normal   [3]float32 `json:"normal"`
	UV       [2]float32 `json:"uv,omitempty"`
}

type ModCamera2DSpec

type ModCamera2DSpec struct {
	Clear      *bool                `json:"clear,omitempty"`
	ClearColor string               `json:"clearColor,omitempty"`
	Order      int                  `json:"order,omitempty"`
	Viewport   scene.CameraViewport `json:"viewport,omitzero"`
	Scale      float32              `json:"scale,omitempty"`
}

type ModCollisionSpec

type ModCollisionSpec struct {
	Emit string `json:"emit"`
}

Collision publishes solver results without exposing either module's ECS IDs.

type ModComponents

type ModComponents struct {
	RigidBody3D            *RigidBody3DSpec            `json:"rigidBody3D,omitempty"`
	AmbientLight           *AmbientLightSpec           `json:"ambientLight,omitempty"`
	Anchor                 *scene.Anchor               `json:"anchor,omitempty"`
	Sprite                 *ModSpriteSpec              `json:"sprite,omitempty"`
	Trail                  *SpriteTrailSpec            `json:"trail,omitempty"`
	Material               *ModMaterial2DSpec          `json:"material,omitempty"`
	Shader                 *ShaderComponentSpec        `json:"shader,omitempty"`
	Input                  *ModInputSpec               `json:"input,omitempty"`
	SegmentCollider2D      *SegmentCollider2DSpec      `json:"segmentCollider2D,omitempty"`
	Animation              *AnimationComponentSpec     `json:"animation,omitempty"`
	HTML                   *ModHTMLSpec                `json:"html,omitempty"`
	Emitter                *EmitterSpec                `json:"emitter,omitempty"`
	Particle               *TextureSpec                `json:"particle,omitempty"`
	Tilemap                *TilemapSpec                `json:"tilemap,omitempty"`
	Layout                 *engineui.Layout            `json:"layout,omitempty"`
	TriangleMeshCollider3D *TriangleMeshCollider3DSpec `json:"triangleMeshCollider3D,omitempty"`
	Text                   *TextComponentSpec          `json:"text,omitempty"`
	Spine                  *ModSpineSpec               `json:"spine,omitempty"`
	ConvexHullCollider3D   *ConvexHullCollider3DSpec   `json:"convexHullCollider3D,omitempty"`
	CompoundCollider3D     *CompoundCollider3DSpec     `json:"compoundCollider3D,omitempty"`
	Camera                 *Camera3DSpec               `json:"camera,omitempty"`
	Camera2D               *ModCamera2DSpec            `json:"camera2D,omitempty"`
	Model                  *ModelSpec                  `json:"model,omitempty"`
	DirectionalLight       *DirectionalLightSpec       `json:"directionalLight,omitempty"`
	PointLight             *PointLightSpec             `json:"pointLight,omitempty"`
	SpotLight              *SpotLightSpec              `json:"spotLight,omitempty"`
	AreaLight              *AreaLightSpec              `json:"areaLight,omitempty"`
	RigidBody2D            *RigidBody2DSpec            `json:"rigidBody2D,omitempty"`
	Collision              *ModCollisionSpec           `json:"collision,omitempty"`
	CircleCollider2D       *CircleCollider2DSpec       `json:"circleCollider2D,omitempty"`
	BoxCollider2D          *BoxCollider2DSpec          `json:"boxCollider2D,omitempty"`
	Size                   []float32                   `json:"size,omitempty"`
}

func (ModComponents) ContentFeatures

func (c ModComponents) ContentFeatures() (features ModContentFeatures)

type ModContentFeatures

type ModContentFeatures uint16
const (
	ModContentAnimations ModContentFeatures = 1 << iota
	ModContentLayout
	ModContentTrail
	ModContentHTML
	ModContentParticles
	ModContentTilemaps
	ModContentSpine
	ModContentSpatial
	ModContentPhysics2D
	ModContentAll = (ModContentPhysics2D << 1) - 1
)

type ModElementPlan

type ModElementPlan struct {
	Spec      ModElementSpec
	Parent    int32
	Transform ModTransform
}

type ModElementSpec

type ModElementSpec struct {
	Components ModComponents    `json:"components,omitzero"`
	Visible    *bool            `json:"visible,omitempty"`
	ID         string           `json:"id"`
	Parent     string           `json:"parent,omitempty"`
	Space      CoordinateSpace  `json:"space,omitempty"`
	Transform  ModTransformSpec `json:"transform,omitzero"`
}

Elements are private implementation details of one module. Scene messages and placements cannot address them; only the owning behavior can obtain a handle.

type ModHTMLSpec

type ModHTMLSpec struct {
	Resource    string `json:"resource"`
	Font        string `json:"font,omitempty"`
	BoldFont    string `json:"boldFont,omitempty"`
	PassThrough bool   `json:"passThrough,omitempty"`
}

type ModID

type ModID string

func NormalizeModPath

func NormalizeModPath(id ModID) (ModID, error)

type ModInputSpec

type ModInputSpec struct {
	Pointer  bool `json:"pointer,omitempty"`
	Keyboard bool `json:"keyboard,omitempty"`
	Text     bool `json:"text,omitempty"`
	Files    bool `json:"files,omitempty"`
}

type ModInstancePlan

type ModInstancePlan struct {
	ID        string
	Slots     []SlotValue
	Placement ModTransform
	Mod       uint32
	Parent    int32
	Enabled   bool
	Visible   bool
}

type ModInstanceSpec

type ModInstanceSpec struct {
	Slots     map[string]json.RawMessage `json:"slots,omitempty"`
	Enabled   *bool                      `json:"enabled,omitempty"`
	Visible   *bool                      `json:"visible,omitempty"`
	ID        string                     `json:"id"`
	Mod       ModID                      `json:"mod"`
	Placement ModTransformSpec           `json:"placement,omitzero"`
	Children  []ModInstanceSpec          `json:"children,omitempty"`
}

type ModMaterial2D

type ModMaterial2D struct {
	Custom [4][4]float32
}

ModMaterial2D keeps material uniforms per instance.

func (ModMaterial2D) Material2D

func (m ModMaterial2D) Material2D() graphics.Material2DData

type ModMaterial2DSpec

type ModMaterial2DSpec struct {
	Custom [4][4]float32 `json:"custom,omitzero"`
}

type ModPlan

type ModPlan struct {
	Spec      ModSpec
	ID        ModID
	Resources []ModResourcePlan
	Slots     []SlotPlan
	Elements  []ModElementPlan
	Transform ModTransform
}

type ModResourcePlan

type ModResourcePlan struct {
	Name string
	Kind string
	Path string
}

type ModResourceSpec

type ModResourceSpec struct {
	Kind string `json:"kind"`
	Path string `json:"path"`
}

type ModSpec

type ModSpec struct {
	Components ModComponents              `json:"components,omitzero"`
	Resources  map[string]ModResourceSpec `json:"resources,omitempty"`
	Slots      map[string]SlotSpec        `json:"slots,omitempty"`
	Name       string                     `json:"name,omitempty"`
	Space      CoordinateSpace            `json:"space,omitempty"`
	Behavior   string                     `json:"behavior,omitempty"`
	Transform  ModTransformSpec           `json:"transform,omitzero"`
	Elements   []ModElementSpec           `json:"elements,omitempty"`
}

type ModSpineSpec

type ModSpineSpec struct {
	Source    SpineSpec `json:"source"`
	Animation string    `json:"animation,omitempty"`
	Skin      string    `json:"skin,omitempty"`
	Loop      bool      `json:"loop,omitempty"`
	Speed     float32   `json:"speed,omitempty"`
}

type ModSpriteSpec

type ModSpriteSpec struct {
	Texture *TextureSpec `json:"texture,omitempty"`
	Alpha   *float32     `json:"alpha,omitempty"`
	Color   string       `json:"color,omitempty"`
	Size    []float32    `json:"size,omitempty"`
}

type ModTransform

type ModTransform struct {
	Position [3]float32
	Rotation [3]float32
	Scale    [3]float32
}

type ModTransformSpec

type ModTransformSpec struct {
	Position []float32 `json:"position,omitempty"`
	Rotation []float32 `json:"rotation,omitempty"`
	Scale    []float32 `json:"scale,omitempty"`
}

type ModelAnimationSource

type ModelAnimationSource struct {
	Name      string                      `json:"name"`
	Tracks    []ModelAnimationTrackSource `json:"tracks"`
	BlendMode int                         `json:"blendMode,omitempty"`
	Duration  float32                     `json:"duration"`
}

ModelAnimationSource is a named collection of vector/quaternion keyframe tracks. Paths identify imported nodes; unique node names are also accepted.

type ModelAnimationTrackSource

type ModelAnimationTrackSource struct {
	Name   string    `json:"name"`
	Type   string    `json:"type"`
	Times  []float32 `json:"times"`
	Values []float32 `json:"values"`
}

type ModelJoint

type ModelJoint struct {
	Name        string
	Node        int32
	Parent      int32
	InverseBind [16]float32
}

ModelJoint is an imported skin joint in model-local space.

type ModelMaterialSpec

type ModelMaterialSpec struct {
	Shader              string  `json:"shader,omitempty"`
	BaseColor           string  `json:"baseColor,omitempty"`
	Emissive            string  `json:"emissive,omitempty"`
	IOR                 float32 `json:"ior,omitempty"`
	EmissiveStrength    float32 `json:"emissiveStrength,omitempty"`
	Metallic            float32 `json:"metallic,omitempty"`
	PerceptualRoughness float32 `json:"roughness,omitempty"`
	MetallicSet         bool    `json:"-"`
	RoughnessSet        bool    `json:"-"`
	IORSet              bool    `json:"-"`
	EmissiveStrengthSet bool    `json:"-"`
}

func (ModelMaterialSpec) MarshalJSON

func (s ModelMaterialSpec) MarshalJSON() ([]byte, error)

func (*ModelMaterialSpec) UnmarshalJSON

func (s *ModelMaterialSpec) UnmarshalJSON(data []byte) error

type ModelMorphTarget

type ModelMorphTarget struct {
	Name          string
	PositionDelta [][3]float32
	NormalDelta   [][3]float32
	TangentDelta  [][3]float32
}

ModelMorphTarget is an imported morph target and its per-vertex deltas.

type ModelNode

type ModelNode struct {
	Name   string
	Path   string
	Parent int32
	Local  [16]float32
	World  [16]float32
}

ModelNode retains the source node index, hierarchy and initial transforms. Path is the unambiguous animation binding, including for duplicate names.

type ModelPose

type ModelPose struct {
	Deformation render3d.Deformation
	// contains filtered or unexported fields
}

func (*ModelPose) NodeMatrix

func (p *ModelPose) NodeMatrix(index int) mgl32.Mat4

NodeMatrix returns an animated node in model space for weapon/socket attachments.

func (*ModelPose) Sample

func (p *ModelPose) Sample(clip *ModelPoseClip, time float32, loop bool)

Sample resets untracked nodes to their bind pose, then samples this rig's clip. Loop wraps positive time; a non-looping clip holds its last keyframe.

type ModelPoseClip

type ModelPoseClip struct {
	Name string

	Duration float32
	// contains filtered or unexported fields
}

type ModelRig

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

ModelRig shares immutable hierarchy and animation data between instances. ModelPose owns the per-instance buffers; sampling performs no allocations.

func (*ModelRig) Animation

func (r *ModelRig) Animation(name string) (*ModelPoseClip, error)

func (*ModelRig) NewPose

func (r *ModelRig) NewPose() *ModelPose

func (*ModelRig) NodeIndex

func (r *ModelRig) NodeIndex(name string) (int, error)

NodeIndex resolves an exact path or an unambiguous source node name at setup.

type ModelSkinVertex

type ModelSkinVertex struct {
	Joints  [4]uint32
	Weights [4]float32
	Active  bool
}

ModelSkinVertex contains up to four joint influences for one model vertex.

type ModelSpec

type ModelSpec struct {
	Mesh          *MeshSpec                   `json:"mesh,omitempty"`
	AnimationPath string                      `json:"animationPath,omitempty"`
	ID            string                      `json:"id"`
	Path          string                      `json:"path,omitempty"`
	Collision     enginephysics.CollisionMode `json:"collision,omitempty"`
	CollisionPath string                      `json:"collisionPath,omitempty"`
	Material      ModelMaterialSpec           `json:"material,omitempty"`
}

func (ModelSpec) CookCollision

func (s ModelSpec) CookCollision(mesh *graphics.Mesh) (enginephysics.CookedCollision, error)

CookCollision converts a render mesh into the immutable collision resource selected by the model's import mode. It is intended for the asset-loading stage; collider synchronization only receives the returned baked value.

func (ModelSpec) Validate

func (s ModelSpec) Validate() error

type NineSlice

type NineSlice struct {
	Left   int `json:"left"`
	Right  int `json:"right"`
	Top    int `json:"top"`
	Bottom int `json:"bottom"`
}

func (NineSlice) Validate

func (s NineSlice) Validate(width, height int) error

type ParticleSpec

type ParticleSpec struct {
	Texture    *TextureSpec `json:"texture"`
	ID         string       `json:"id"`
	Colors     []string     `json:"colors"`
	Count      int          `json:"count"`
	SpeedMin   float32      `json:"speedMin"`
	SizeMax    float32      `json:"sizeMax"`
	Rate       float32      `json:"rate"`
	Lifetime   float32      `json:"lifetime"`
	Width      float32      `json:"width"`
	SpeedMax   float32      `json:"speedMax"`
	SizeMin    float32      `json:"sizeMin"`
	Height     float32      `json:"height"`
	Direction  float32      `json:"direction"`
	Spread     float32      `json:"spread"`
	GravityX   float32      `json:"gravityX"`
	GravityY   float32      `json:"gravityY"`
	AlphaStart float32      `json:"alphaStart"`
	AlphaEnd   float32      `json:"alphaEnd"`
	Loop       bool         `json:"loop"`
}

type PointLightSpec

type PointLightSpec struct {
	Shadows     *PunctualShadowSpec `json:"shadows,omitempty"`
	Color       string              `json:"color"`
	Unit        graphics.LightUnit  `json:"unit"`
	Intensity   float32             `json:"intensity"`
	LuxDistance float32             `json:"luxDistance"`
	Range       float32             `json:"range"`
	Radius      float32             `json:"radius"`
}

func NewPointLightSpec

func NewPointLightSpec() PointLightSpec

func (PointLightSpec) Light

func (s PointLightSpec) Light() (render3d.PointLight, error)

func (*PointLightSpec) UnmarshalJSON

func (s *PointLightSpec) UnmarshalJSON(data []byte) error

type PreprocessOptions

type PreprocessOptions struct {
	ShaderCompiler ShaderCompiler
	// Progress reports the module and asset family about to be compiled.
	Progress func(module, asset string, completed, total int)
	// TextureEncoder replaces model images with a runtime texture container.
	// External glTF images are read during model preprocessing so their material
	// sampling options select the same compression profile as embedded images.
	TextureEncoder func([]byte, string, graphics.TextureOptions) ([]byte, error)
	Root           string
	ShaderTarget   ShaderTarget
}

PreprocessOptions selects the project root and build target for resource compilation.

type PreprocessedFile

type PreprocessedFile struct {
	Path string
	// SourcePath identifies the source resource's path when Data is generated
	// rather than replacing a file already collected from disk.
	SourcePath string
	Data       []byte
	SourceSize int
	Remove     bool
}

PreprocessedFile is a source resource replacement or removal.

func PreprocessManifests

func PreprocessManifests(source iofs.FS, options PreprocessOptions) ([]PreprocessedFile, error)

PreprocessManifests compiles project, resource, catalog, and scene manifests.

func PreprocessModShaders

func PreprocessModShaders(source fs.FS, mod *ModPlan, options PreprocessOptions) ([]PreprocessedFile, error)

PreprocessModShaders compiles element shader components using the module's private filesystem. Sources shared by elements are compiled only once.

func PreprocessModuleAssets

func PreprocessModuleAssets(source fs.FS, plan *ProjectPlan, options PreprocessOptions) ([]PreprocessedFile, error)

PreprocessModuleAssets compiles native asset families from the module plan. Authoring manifests are never loaded here. Paths stay relative to each module until the resulting private files are placed in the project resource package.

type ProjectPlan

type ProjectPlan struct {
	Mods   []ModPlan
	Scenes []ScenePlan
	Spec   ProjectSpec
	Entry  uint32
}

Plans contain resolved indices and typed values. JSON bytes are authoring data only; dispatch and slot updates do not need to decode JSON or use any.

func CompileProject

func CompileProject(source fs.FS, root string) (*ProjectPlan, error)

CompileProject reads project, scene, and module documents. Compilation owns allocations; the resulting plans use indices and typed data.

func CompileProjectDefinitions

func CompileProjectDefinitions(source fs.FS, root string, definitions []ModID) (*ProjectPlan, error)

CompileProjectDefinitions also validates definitions already opened by an authoring tool, even when a nested definition has no remaining scene instance.

func CompileProjectDirectory

func CompileProjectDirectory(directory string) (*ProjectPlan, error)

func CreateProjectDirectory

func CreateProjectDirectory(directory string, options CreateProjectOptions) (*ProjectPlan, error)

CreateProjectDirectory creates the module-system project entry. Existing entry files are never overwritten, including user main.go. It returns the same compiled representation used by the authoring validator.

func OpenModuleProject

func OpenModuleProject() (*ProjectPlan, fs.FS, error)

OpenModuleProject uses the mounted package source in published applications. Authoring builds without a package mount read the current project directory.

func ReadModulePlan

func ReadModulePlan(source fs.FS) (*ProjectPlan, error)

func (*ProjectPlan) RuntimeFeatures

func (p *ProjectPlan) RuntimeFeatures() []RuntimeFeatureID

RuntimeFeatures includes explicitly selected systems and systems required by used content. Unreferenced definitions do not add features to the executable.

type ProjectSpec

type ProjectSpec struct {
	Types      map[ValueType]ValueSchema `json:"types,omitempty"`
	Entry      SceneID                   `json:"entry"`
	ClearColor string                    `json:"clearColor,omitempty"`
	Engine     EngineConfig              `json:"engine,omitempty"`
	Scenes     []SceneID                 `json:"scenes,omitempty"`
	Viewport   SizeConfig                `json:"viewport,omitempty"`
	Window     WindowConfig              `json:"window,omitempty"`
}

ProjectSpec selects the entry and scene order. Scene files live in resources/scenes; compilation discovers additional scenes in that directory.

type PunctualShadowSpec

type PunctualShadowSpec struct {
	Resolution int     `json:"resolution"`
	Near       float32 `json:"near"`
	Bias       float32 `json:"bias"`
	NormalBias float32 `json:"normalBias"`
}

func NewPunctualShadowSpec

func NewPunctualShadowSpec() *PunctualShadowSpec

func (PunctualShadowSpec) Settings

func (*PunctualShadowSpec) UnmarshalJSON

func (s *PunctualShadowSpec) UnmarshalJSON(data []byte) error

type Render2DAnimationsProfile

type Render2DAnimationsProfile struct{}

Render2DAnimationsProfile adds the 2D animator to Render2DProfile.

type Render2DProfile

type Render2DProfile struct{}

Render2DProfile is the smallest scene profile. It materializes only the 2D transform, sprite, and text components used by the renderer.

type ResourceComponentSpec

type ResourceComponentSpec struct {
	Resource string `json:"resource"`
}

type ResourceEntries

type ResourceEntries struct {
	Audio []FileResource
}

ResourceEntries is the manifest subset handled by an injected feature.

type ResourceFeature

type ResourceFeature interface {
	ConfigureResources(ResourceLoadContext, ResourceEntries) error
}

ResourceFeature provides project resource implementations selected by the application. Feature types are composed at the generic loading boundary so unused implementations are not reachable from the final binary.

type ResourceFeatureSet

type ResourceFeatureSet[A, B ResourceFeature] struct{}

ResourceFeatureSet composes two statically selected resource features. A nil interface type argument is skipped so callers may use ResourceFeature when a slot is intentionally empty.

func (ResourceFeatureSet[A, B]) ConfigureResources

func (ResourceFeatureSet[A, B]) ConfigureResources(context ResourceLoadContext, entries ResourceEntries) error

type ResourceID

type ResourceID string

ResourceID identifies one resource family enabled by a project.

const (
	ResourceImages    ResourceID = "images"
	ResourceFonts     ResourceID = "fonts"
	ResourceAudio     ResourceID = "audio"
	ResourceVideos    ResourceID = "videos"
	ResourceParticles ResourceID = "particles"
	ResourceTilemaps  ResourceID = "tilemaps"
	ResourceModels    ResourceID = "models"
	ResourceSpine     ResourceID = "spine"
	ResourceShaders   ResourceID = "shaders"
	ResourceHTML      ResourceID = "html"
)

type ResourceLoadContext

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

ResourceLoadContext gives a feature controlled access to the resource store.

func (ResourceLoadContext) OpenBlob

func (context ResourceLoadContext) OpenBlob(path string) (*resource.Blob, error)

OpenBlob opens and pins a path relative to the project directory. Ownership of the returned Blob is transferred to the caller.

func (ResourceLoadContext) ReadFile

func (context ResourceLoadContext) ReadFile(path string) ([]byte, error)

ReadFile reads a path relative to the project directory.

func (ResourceLoadContext) RegisterNamedResource

func (context ResourceLoadContext) RegisterNamedResource[T any](kind, id string, registration ResourceRegistration[T]) error

RegisterNamedResource installs one lazily loaded feature resource. The concrete resource type remains outside the project core package.

func (ResourceLoadContext) SetFontDecoder

func (context ResourceLoadContext) SetFontDecoder(decoder FontDecoder)

SetFontDecoder configures the font decoder used by project font resources.

func (ResourceLoadContext) SetImageDecoder

func (context ResourceLoadContext) SetImageDecoder(decoder ImageDecoder)

SetImageDecoder configures the image decoder used by scene sprites and atlases. Passing nil disables image resources for this project.

func (ResourceLoadContext) SetWindowIconDecoder

func (context ResourceLoadContext) SetWindowIconDecoder(decoder window.IconDecoder)

SetWindowIconDecoder configures the decoder used when a project declares a window icon.

type ResourceRegistration

type ResourceRegistration[T any] struct {
	Load    func() (T, error)
	Dispose func(T) error
}

ResourceRegistration defines both halves of a named resource lifecycle. Dispose may be nil for values that own no explicit native resources.

type ResourceStatistics

type ResourceStatistics struct {
	CacheHits         uint64
	CacheMisses       uint64
	ResidentResources uint64
}

ResourceStatistics reports aggregate behavior of the typed runtime caches.

type Resources

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

func OpenModResources

func OpenModResources(source fs.FS, mod *ModPlan, feature ResourceFeature) (_ *Resources, resultErr error)

OpenModResources installs only this definition's private resource namespace. The scoped filesystem also confines references in HTML, atlases and models. Instances share this store, while mutable ECS components remain per instance.

func (*Resources) AppendModContent

func (r *Resources) AppendModContent(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContent2D

func (r *Resources) AppendModContent2D(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentAnimation

func (r *Resources) AppendModContentAnimation(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentHTML

func (r *Resources) AppendModContentHTML(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentLayout

func (r *Resources) AppendModContentLayout(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentParticles

func (r *Resources) AppendModContentParticles(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentPhysics2D

func (r *Resources) AppendModContentPhysics2D(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentSpatial

func (r *Resources) AppendModContentSpatial(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentSpine

func (r *Resources) AppendModContentSpine(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentTilemaps

func (r *Resources) AppendModContentTilemaps(b *ecs.Bundle, c ModComponents) error

func (*Resources) AppendModContentTrail

func (r *Resources) AppendModContentTrail(b *ecs.Bundle, c ModComponents) error

func (*Resources) Atlas

func (r *Resources) Atlas(path string) (*graphics.Atlas, error)

func (*Resources) AtlasWithOptions

func (r *Resources) AtlasWithOptions(path string, options graphics.TextureOptions) (*graphics.Atlas, error)

func (*Resources) Dispose

func (r *Resources) Dispose() error

func (*Resources) Font

func (r *Resources) Font(id string) (*onixtext.Font, error)

func (*Resources) HTML

func (r *Resources) HTML(id string) (string, error)

HTML returns the source of a named HTML resource, loaded lazily on first use.

func (*Resources) LoadNamedResource

func (resources *Resources) LoadNamedResource[T any](kind, id string) (T, error)

LoadNamedResource returns a lazily loaded resource registered by a feature.

func (*Resources) Material2DShader

func (r *Resources) Material2DShader(id string) (*graphics.Material2DShader, error)

func (*Resources) MeshShader

func (r *Resources) MeshShader(id string) (*graphics.MeshShader, error)

func (*Resources) ModContent

func (r *Resources) ModContent(c ModComponents) (ecs.Bundle, error)

ModContent builds private component values; it has no scene/entity registry.

func (*Resources) ModelRig

func (r *Resources) ModelRig(name string) (*ModelRig, error)

ModelRig reads a model already loaded by this module's private content.

func (*Resources) ParseColor

func (r *Resources) ParseColor(value string, alpha float32) (graphics.ColorRGBA, error)

func (*Resources) Shader

func (r *Resources) Shader(id string) (render.ShaderDescriptor, error)

Shader returns the descriptor for a named shader resource. The source files are read only on first access.

func (*Resources) Spine

func (r *Resources) Spine(id string) (*spineruntime.Resource, error)

func (*Resources) Statistics

func (r *Resources) Statistics() ResourceStatistics

func (*Resources) Video

func (r *Resources) Video(id string) (*Video, error)

type RigidBody2DSpec

type RigidBody2DSpec struct {
	Type            string     `json:"type,omitempty"`
	Mass            float64    `json:"mass,omitempty"`
	Inertia         float64    `json:"inertia,omitempty"`
	GravityScale    float64    `json:"gravityScale,omitempty"`
	LinearDamping   float64    `json:"linearDamping,omitempty"`
	AngularDamping  float64    `json:"angularDamping,omitempty"`
	Velocity        [2]float64 `json:"velocity,omitempty"`
	AngularVelocity float64    `json:"angularVelocity,omitempty"`
	FixedRotation   bool       `json:"fixedRotation,omitempty"`
}

func NewRigidBody2DSpec

func NewRigidBody2DSpec() RigidBody2DSpec

func (*RigidBody2DSpec) UnmarshalJSON

func (s *RigidBody2DSpec) UnmarshalJSON(data []byte) error

type RigidBody3DSpec

type RigidBody3DSpec struct {
	Type            string     `json:"type,omitempty"`
	Mass            float64    `json:"mass,omitempty"`
	Inertia         float64    `json:"inertia,omitempty"`
	GravityScale    float64    `json:"gravityScale,omitempty"`
	LinearDamping   float64    `json:"linearDamping,omitempty"`
	AngularDamping  float64    `json:"angularDamping,omitempty"`
	Velocity        [3]float64 `json:"velocity,omitempty"`
	AngularVelocity [3]float64 `json:"angularVelocity,omitempty"`
	FixedRotation   bool       `json:"fixedRotation,omitempty"`
}

func NewRigidBody3DSpec

func NewRigidBody3DSpec() RigidBody3DSpec

func (*RigidBody3DSpec) UnmarshalJSON

func (s *RigidBody3DSpec) UnmarshalJSON(data []byte) error

type RuntimeFeatureID

type RuntimeFeatureID string

RuntimeFeatureID identifies one engine-owned runtime feature in a project manifest. IDs are persisted instead of Go type names so manifests remain stable when a feature's implementation changes.

const (
	FeatureRender2D       RuntimeFeatureID = "render2d"
	FeatureRender3D       RuntimeFeatureID = "render3d"
	FeatureInput2D        RuntimeFeatureID = "input2d"
	FeatureAnimations2D   RuntimeFeatureID = "animations2d"
	FeatureSpriteTrails2D RuntimeFeatureID = "sprite-trails2d"
	FeatureParticles2D    RuntimeFeatureID = "particles2d"
	FeatureTilemaps2D     RuntimeFeatureID = "tilemaps2d"
	FeatureSpine2D        RuntimeFeatureID = "spine2d"
	FeaturePhysics2D      RuntimeFeatureID = "physics2d"
	FeaturePhysics3D      RuntimeFeatureID = "physics3d"
	FeatureUIControls     RuntimeFeatureID = "ui-controls"
	FeatureUIWidgets      RuntimeFeatureID = "ui-widgets"
	FeatureUITextInput    RuntimeFeatureID = "ui-text-input"
	FeatureUIMarkdown     RuntimeFeatureID = "ui-markdown"
	FeatureUIHTML         RuntimeFeatureID = "ui-html"
	FeatureWebView        RuntimeFeatureID = "webview"
	FeatureFileDialogs    RuntimeFeatureID = "file-dialogs"
)

func (RuntimeFeatureID) Dependencies added in v0.1.10

func (id RuntimeFeatureID) Dependencies() []RuntimeFeatureID

Dependencies lists the runtime features required in a project's engine configuration.

type SSAOSpec

type SSAOSpec struct {
	Radius          float32 `json:"radius"`
	Bias            float32 `json:"bias"`
	Strength        float32 `json:"strength"`
	ResolutionScale float32 `json:"resolutionScale"`
	Samples         int     `json:"samples"`
}

A nil camera SSAO spec disables the depth prepass.

func NewSSAOSpec

func NewSSAOSpec() *SSAOSpec

func (*SSAOSpec) Settings

func (s *SSAOSpec) Settings() render3d.SSAOSettings

func (*SSAOSpec) UnmarshalJSON

func (s *SSAOSpec) UnmarshalJSON(data []byte) error

type SSRSpec

type SSRSpec struct {
	MaxDistance  float32 `json:"maxDistance"`
	Thickness    float32 `json:"thickness"`
	Strength     float32 `json:"strength"`
	MaxRoughness float32 `json:"maxRoughness"`
	EdgeFade     float32 `json:"edgeFade"`
	Steps        int     `json:"steps"`
}

A nil camera SSR spec disables screen-space reflection targets.

func NewSSRSpec

func NewSSRSpec() *SSRSpec

func (*SSRSpec) Settings

func (s *SSRSpec) Settings() render3d.SSRSettings

func (*SSRSpec) UnmarshalJSON

func (s *SSRSpec) UnmarshalJSON(data []byte) error

type SceneCatalogEntry

type SceneCatalogEntry struct {
	ID   SceneID `json:"id"`
	Path string  `json:"path"`
}

type SceneComponent

type SceneComponent string
const (
	SceneComponentSprite                 SceneComponent = "sprite"
	SceneComponentAnimation              SceneComponent = "animation"
	SceneComponentText                   SceneComponent = "text"
	SceneComponentHTML                   SceneComponent = "html"
	SceneComponentParticle               SceneComponent = "particle"
	SceneComponentTilemap                SceneComponent = "tilemap"
	SceneComponentSpine                  SceneComponent = "spine"
	SceneComponentModel                  SceneComponent = "model"
	SceneComponentCamera                 SceneComponent = "camera"
	SceneComponentAmbientLight           SceneComponent = "ambientlight"
	SceneComponentDirectionalLight       SceneComponent = "directionallight"
	SceneComponentPointLight             SceneComponent = "pointlight"
	SceneComponentSpotLight              SceneComponent = "spotlight"
	SceneComponentAreaLight              SceneComponent = "arealight"
	SceneComponentRigidBody2D            SceneComponent = "rigidbody2d"
	SceneComponentCircleCollider2D       SceneComponent = "circlecollider2d"
	SceneComponentBoxCollider2D          SceneComponent = "boxcollider2d"
	SceneComponentSegmentCollider2D      SceneComponent = "segmentcollider2d"
	SceneComponentRigidBody3D            SceneComponent = "rigidbody3d"
	SceneComponentTriangleMeshCollider3D SceneComponent = "trianglemeshcollider3d"
	SceneComponentConvexHullCollider3D   SceneComponent = "convexhullcollider3d"
	SceneComponentCompoundCollider3D     SceneComponent = "compoundcollider3d"
	SceneComponentLayout                 SceneComponent = "layout"
	SceneComponentWidget                 SceneComponent = "widget"
)

type SceneComponents

type SceneComponents struct {
	Sprite                 *SpriteComponentSpec        `json:"sprite,omitempty"`
	Animation              *AnimationComponentSpec     `json:"animation,omitempty"`
	Text                   *TextComponentSpec          `json:"text,omitempty"`
	HTML                   *ResourceComponentSpec      `json:"html,omitempty"`
	Particle               *ResourceComponentSpec      `json:"particle,omitempty"`
	Tilemap                *ResourceComponentSpec      `json:"tilemap,omitempty"`
	Spine                  *SpineComponentSpec         `json:"spine,omitempty"`
	Model                  *ResourceComponentSpec      `json:"model,omitempty"`
	Camera                 *Camera3DSpec               `json:"camera,omitempty"`
	AmbientLight           *AmbientLightSpec           `json:"ambientLight,omitempty"`
	DirectionalLight       *DirectionalLightSpec       `json:"directionalLight,omitempty"`
	PointLight             *PointLightSpec             `json:"pointLight,omitempty"`
	SpotLight              *SpotLightSpec              `json:"spotLight,omitempty"`
	AreaLight              *AreaLightSpec              `json:"areaLight,omitempty"`
	RigidBody2D            *RigidBody2DSpec            `json:"rigidBody2D,omitempty"`
	CircleCollider2D       *CircleCollider2DSpec       `json:"circleCollider2D,omitempty"`
	BoxCollider2D          *BoxCollider2DSpec          `json:"boxCollider2D,omitempty"`
	SegmentCollider2D      *SegmentCollider2DSpec      `json:"segmentCollider2D,omitempty"`
	RigidBody3D            *RigidBody3DSpec            `json:"rigidBody3D,omitempty"`
	TriangleMeshCollider3D *TriangleMeshCollider3DSpec `json:"triangleMeshCollider3D,omitempty"`
	ConvexHullCollider3D   *ConvexHullCollider3DSpec   `json:"convexHullCollider3D,omitempty"`
	CompoundCollider3D     *CompoundCollider3DSpec     `json:"compoundCollider3D,omitempty"`
}

func Components

func Components(values ...SceneComponent) SceneComponents

func (*SceneComponents) Add

func (c *SceneComponents) Add(component SceneComponent)

Add attaches one component without changing components already attached to the node.

func (SceneComponents) Clone

func (components SceneComponents) Clone() SceneComponents

Clone returns an independent authoring copy, including nested animation and texture data.

func (SceneComponents) Empty

func (c SceneComponents) Empty() bool

func (SceneComponents) Has

func (c SceneComponents) Has(component SceneComponent) bool

Has reports whether the authored component set contains component. Scene nodes are component compositions; no component is implicitly selected as a node kind.

func (SceneComponents) Has2D

func (c SceneComponents) Has2D() bool

func (SceneComponents) Has3D

func (c SceneComponents) Has3D() bool

func (SceneComponents) HasPhysics2D

func (c SceneComponents) HasPhysics2D() bool

func (SceneComponents) HasPhysics3D

func (c SceneComponents) HasPhysics3D() bool

func (SceneComponents) IsZero

func (c SceneComponents) IsZero() bool

func (SceneComponents) VisualsEmpty

func (c SceneComponents) VisualsEmpty() bool

type SceneExitPolicy

type SceneExitPolicy string

SceneExitPolicy controls the departing scene's lifetime. The zero value uses the switch request's Retain setting, which defaults to destruction.

const (
	SceneExitDestroy SceneExitPolicy = "destroy"
	SceneExitRetain  SceneExitPolicy = "retain"
)

type SceneID

type SceneID string

type SceneInstance

type SceneInstance struct {
	World    *ecs.World
	Entities map[string]ecs.Entity

	EntityIDs map[ecs.Entity]string

	Roots []ecs.Entity
	// contains filtered or unexported fields
}

func (*SceneInstance) ApplyNode

func (s *SceneInstance) ApplyNode(spec SceneNodeSpec) error

func (*SceneInstance) ApplyNodeUnder

func (s *SceneInstance) ApplyNodeUnder(parentID string, spec SceneNodeSpec) error

ApplyNodeUnder creates a missing node under an existing parent. Updating an existing node preserves its current hierarchy.

func (*SceneInstance) BindControl

func (scene *SceneInstance) BindControl[T any](id string, component T) error

BindControl installs an explicitly selected runtime behavior on an authored control root.

func (*SceneInstance) BindControlEntity

func (scene *SceneInstance) BindControlEntity[T any](entity ecs.Entity, component T) error

BindControlEntity installs behavior on a runtime entity created from a scene template. It is the entity-based counterpart to BindControl.

func (*SceneInstance) BindScripts

func (s *SceneInstance) BindScripts() error

BindScripts binds the scene's authored script components. It is idempotent for one scene generation and is also used after a scene hierarchy rebuild.

func (*SceneInstance) Bounds

func (s *SceneInstance) Bounds(entity ecs.Entity) (float32, float32, float32, float32, bool)

func (*SceneInstance) BoundsByID

func (s *SceneInstance) BoundsByID(id string) (float32, float32, float32, float32, bool)

func (*SceneInstance) Child

func (s *SceneInstance) Child(parent ecs.Entity, id string) (ecs.Entity, error)

func (*SceneInstance) CloneChildrenUnder

func (s *SceneInstance) CloneChildrenUnder(parent ecs.Entity, templateID, prefix string) (map[string]ecs.Entity, error)

CloneChildrenUnder clones the authored children of a scene node under an existing runtime entity. The cloned nodes get a unique ID prefix and remain part of the scene so their authored UI composition can be bound normally.

func (*SceneInstance) CloneNodeUnder

func (s *SceneInstance) CloneNodeUnder(parent ecs.Entity, templateID, prefix string) (map[string]ecs.Entity, error)

CloneNodeUnder clones one authored scene node and its descendants under an existing entity. It is useful for data-driven UI that keeps one editable item template in the scene and creates the remaining items at runtime.

func (*SceneInstance) CloneRootsUnder

func (s *SceneInstance) CloneRootsUnder(parent ecs.Entity, prefix string) (map[string]ecs.Entity, error)

CloneRootsUnder clones all authored root nodes under an existing runtime entity. The cloned nodes get a unique ID prefix and remain part of the scene so their authored UI composition can be bound normally.

func (*SceneInstance) Component

func (scene *SceneInstance) Component[T any](id string) (*T, error)

Component resolves a named scene node and acquires write access. Use RequireComponent once at installation and slot access for repeated updates.

func (*SceneInstance) DispatchInputScripts

func (s *SceneInstance) DispatchInputScripts(context *ecs.SystemContext, reader *ecs.MessageReader[scene.InputEvent]) error

DispatchInputScripts delivers global input to every bound input script and routes pointer input only to the event target or its bubbling path.

func (*SceneInstance) Dispose

func (s *SceneInstance) Dispose()

Dispose despawns every entity owned by the scene.

func (*SceneInstance) Entity

func (s *SceneInstance) Entity(id string) (ecs.Entity, error)

func (*SceneInstance) EntityAt

func (s *SceneInstance) EntityAt(path string) (ecs.Entity, error)

func (*SceneInstance) EntityBySlot

func (s *SceneInstance) EntityBySlot(slot ecs.EntitySlot) (ecs.Entity, bool)

EntityBySlot resolves a slot created from this scene's world without a string lookup. It returns false for stale entities and slots from another world.

func (*SceneInstance) ID

func (s *SceneInstance) ID(entity ecs.Entity) string

func (*SceneInstance) IsUI

func (s *SceneInstance) IsUI(entity ecs.Entity) bool

func (*SceneInstance) MustChild

func (s *SceneInstance) MustChild(parent ecs.Entity, id string) ecs.Entity

func (*SceneInstance) MustEntity

func (s *SceneInstance) MustEntity(id string) ecs.Entity

func (*SceneInstance) MustEntityAt

func (s *SceneInstance) MustEntityAt(path string) ecs.Entity

func (*SceneInstance) MustSlot

func (s *SceneInstance) MustSlot(id string) ecs.EntitySlot

MustSlot is the panic-on-error form of Slot for setup code.

func (*SceneInstance) Path

func (s *SceneInstance) Path(id string) string

func (*SceneInstance) Pick

func (s *SceneInstance) Pick(worldPosition, viewportPosition mgl32.Vec2) (string, bool)

func (*SceneInstance) RefreshTransforms

func (s *SceneInstance) RefreshTransforms() error

func (*SceneInstance) RemoveNodes

func (s *SceneInstance) RemoveNodes(ids ...string) int

RemoveNodes despawns the requested game objects and their ECS descendants.

func (*SceneInstance) RenderItems

func (s *SceneInstance) RenderItems() []SceneRenderItem

func (*SceneInstance) ReplaceNodes

func (s *SceneInstance) ReplaceNodes(specs []SceneNodeSpec) error

ReplaceNodes replaces the authored scene hierarchy while retaining the scene world and loaded project resources.

func (*SceneInstance) RequireComponent

func (scene *SceneInstance) RequireComponent[T any](id string) (ecs.EntitySlot, error)

RequireComponent validates a named node without marking its component changed. The returned slot rejects retired entities and slots used in another world.

func (*SceneInstance) Resources

func (s *SceneInstance) Resources() *Resources

Resources returns the resources owned by the scene's project bundle.

func (*SceneInstance) SceneID

func (s *SceneInstance) SceneID() SceneID

func (*SceneInstance) SetModelResource

func (s *SceneInstance) SetModelResource(spec ModelSpec) error

func (*SceneInstance) SetParticleResource

func (s *SceneInstance) SetParticleResource(spec ParticleSpec) error

func (*SceneInstance) SetScriptRegistry

func (s *SceneInstance) SetScriptRegistry(registry ScriptRegistry) error

SetScriptRegistry installs the registry used by this scene and binds all currently authored script components. Calling it again replaces bindings using the new registry. A binding error leaves the scene unbound.

func (*SceneInstance) SetSpineResource

func (s *SceneInstance) SetSpineResource(spec SpineSpec) error

func (*SceneInstance) SetTilemapResource

func (s *SceneInstance) SetTilemapResource(spec TilemapSpec) error

func (*SceneInstance) Slot

func (s *SceneInstance) Slot(id string) (ecs.EntitySlot, error)

Slot resolves an authored or runtime entity name once into a generation checked lookup handle. Reuse the returned slot in frame code instead of rebuilding string IDs for every access.

func (*SceneInstance) Switch

func (s *SceneInstance) Switch(id SceneID) error

func (*SceneInstance) TransformMatrix2D

func (s *SceneInstance) TransformMatrix2D(entity ecs.Entity) (mgl32.Mat4, bool)

TransformMatrix2D returns the resolved matrix for a world or UI entity.

func (*SceneInstance) UpdateScripts

func (s *SceneInstance) UpdateScripts(context *ecs.SystemContext) error

UpdateScripts runs script types in registry order and their bound entities in ascending handle order. Typed queries visit only this scene's entity lists; the hot loop uses no string lookup and reuses contexts at each call depth.

type SceneNodeSpec

type SceneNodeSpec struct {
	Components      SceneComponents       `json:"components,omitzero"`
	Control         *ControlSpec          `json:"control,omitempty"`
	Layout          *engineui.Layout      `json:"layout,omitempty"`
	Widget          *engineui.Widget      `json:"widget,omitempty"`
	Visible         *bool                 `json:"visible,omitempty"`
	ID              string                `json:"id"`
	CoordinateSpace CoordinateSpace       `json:"coordinateSpace,omitempty"`
	TargetCamera    string                `json:"targetCamera,omitempty"`
	Scripts         []ScriptComponentSpec `json:"scripts,omitempty"`
	Children        []SceneNodeSpec       `json:"children,omitempty"`
	RenderLayers    []uint                `json:"renderLayers,omitempty"`
	Height          int                   `json:"height"`
	Width           int                   `json:"width"`
	Order           int                   `json:"order,omitempty"`
	Anchor          scene.Anchor          `json:"anchor"`
	RotationY       float32               `json:"rotationY,omitempty"`
	Alpha           float32               `json:"alpha,omitempty"`
	ScaleY          float32               `json:"scaleY,omitempty"`
	Rotation        float32               `json:"rotation,omitempty"`
	RotationX       float32               `json:"rotationX,omitempty"`
	Z               float32               `json:"z,omitempty"`
	RotationZ       float32               `json:"rotationZ,omitempty"`
	ScaleX          float32               `json:"scaleX,omitempty"`
	X               float32               `json:"x"`
	Y               float32               `json:"y"`
	ScaleZ          float32               `json:"scaleZ,omitempty"`
	BlockInput      bool                  `json:"blockInput,omitempty"`
	PassThrough     bool                  `json:"passThrough,omitempty"`
	Disabled        bool                  `json:"disabled,omitempty"`
}

SceneNodeSpec is the authoring representation of one entity in a scene. Runtime code operates on ecs.Entity values produced from these nodes.

func (SceneNodeSpec) Has3DComponents

func (s SceneNodeSpec) Has3DComponents() bool

func (SceneNodeSpec) HasComponent

func (s SceneNodeSpec) HasComponent(component SceneComponent) bool

HasComponent reports whether the node contains component.

func (SceneNodeSpec) IsEmpty

func (s SceneNodeSpec) IsEmpty() bool

func (*SceneNodeSpec) UnmarshalJSON

func (s *SceneNodeSpec) UnmarshalJSON(data []byte) error

type ScenePlan

type ScenePlan struct {
	ID        SceneID
	Spec      SceneSpec
	Instances []ModInstancePlan
	Transform ModTransform
}

type ScenePreloader

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

ScenePreloader incrementally builds a scene in the active world. Its nodes remain hidden and its cameras inactive until Activate is called.

func (*ScenePreloader) Activate

func (p *ScenePreloader) Activate(current *SceneInstance) error

Activate replaces current with this already-built scene without spawning it a second time. Both scenes must belong to the same world.

func (*ScenePreloader) Advance

func (p *ScenePreloader) Advance(budget time.Duration) (bool, error)

Advance builds scene nodes until the supplied time budget is exhausted. A non-positive budget still completes one unit of work so callers always make progress in deterministic tests.

func (*ScenePreloader) AdvanceFor

func (p *ScenePreloader) AdvanceFor(device *render.Device, budget graphics.UploadBudget) (ready bool, err error)

AdvanceFor commits CPU results and uploads on the caller's render thread. Reading and decoding continue on the worker while this method returns.

func (*ScenePreloader) CPUReady

func (p *ScenePreloader) CPUReady() bool

func (*ScenePreloader) Discard

func (p *ScenePreloader) Discard()

Discard removes the hidden scene when the preload is no longer needed.

func (*ScenePreloader) GPUReadyFor

func (p *ScenePreloader) GPUReadyFor(device *render.Device) bool

func (*ScenePreloader) Ready

func (p *ScenePreloader) Ready() bool

Ready reports whether construction, resource loading, and static text measurement have completed, and uploads are ready for the owning world's frame device.

func (*ScenePreloader) ReadyFor

func (p *ScenePreloader) ReadyFor(device *render.Device) bool

ReadyFor permits headless activation after CPU preparation. With a device, every queued asset must already be resident on that exact device.

type SceneRenderItem

type SceneRenderItem struct {
	Entity    ecs.Entity
	SortIndex int
	Sequence  uint64
	Material  uint64
	Depth     float32
	UI        bool
}

type SceneSpec

type SceneSpec struct {
	Behavior string `json:"behavior,omitempty"`
	// ExitPolicy overrides the switch's Retain setting when set. Overlays
	// always retain their background scene until it is explicitly disposed.
	ExitPolicy SceneExitPolicy   `json:"exitPolicy,omitempty"`
	Modules    []ModInstanceSpec `json:"modules"`
	Transform  ModTransformSpec  `json:"transform,omitzero"`
}

type ScriptBinding

type ScriptBinding struct {
	Bind    func(*ScriptContext, ScriptComponentSpec) error
	Update  func(*ScriptContext) error
	Input   func(*ScriptContext, *scene.InputEventContext) error
	Destroy func(*ScriptContext) error
	Remove  func(*ScriptContext) error
	Name    string
	// InputMask limits which input categories reach Input. Zero subscribes to all categories.
	InputMask scene.InputMask
}

ScriptBinding is the lifecycle bridge produced by Script for a component type. Bind installs the typed component and invokes its install hook. Update, Input and Destroy are optional. Remove clears the typed component when a binding is replaced while a scene remains alive.

func Script

func Script[T any](name string, hooks Hooks[T]) ScriptBinding

Script creates the lifecycle bridge for a concrete component type. Install runs after insertion, so its changes affect the component stored in the ECS.

type ScriptComponentSpec

type ScriptComponentSpec struct {
	Values map[string]json.RawMessage `json:"values,omitempty"`
	Name   string                     `json:"name"`
}

ScriptComponentSpec describes one user-authored script component attached to a scene node. Values are kept as JSON so the editor can round-trip fields discovered from the user's Go source without coupling the project package to that source package.

func (ScriptComponentSpec) DecodeScriptValues

func (spec ScriptComponentSpec) DecodeScriptValues[T any](target *T) error

DecodeScriptValues applies editor-authored values to a typed script value. This is only used while a scene is instantiated; generated update paths do not use JSON or reflection.

type ScriptContext

type ScriptContext struct {
	Scene    *SceneInstance
	World    *ecs.World
	Commands *ecs.Commands

	Entity ecs.Entity
	// contains filtered or unexported fields
}

ScriptContext is the per-call context passed to a script component. Entity is set to the entity currently being processed by the generated script system. The context value must not be retained across callbacks.

func (*ScriptContext) ListenInput

func (context *ScriptContext) ListenInput(target ecs.Entity) error

ListenInput routes input events from target to the script currently being installed. Registrations are removed with the owning script.

type ScriptRegistry

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

ScriptRegistry contains generated script bindings in deterministic order.

func NewScriptRegistry

func NewScriptRegistry(bindings ...ScriptBinding) ScriptRegistry

NewScriptRegistry creates a registry from generated bindings.

func (ScriptRegistry) Empty

func (r ScriptRegistry) Empty() bool

Empty reports whether the registry contains no generated script bindings.

func (ScriptRegistry) InputMask

func (r ScriptRegistry) InputMask() scene.InputMask

InputMask reports the input categories handled by registered scripts.

type SegmentCollider2DSpec

type SegmentCollider2DSpec struct {
	Collider2DSettingsSpec
	Start  [2]float64 `json:"start"`
	End    [2]float64 `json:"end"`
	Radius float64    `json:"radius,omitempty"`
}

func NewSegmentCollider2DSpec

func NewSegmentCollider2DSpec() SegmentCollider2DSpec

func (*SegmentCollider2DSpec) UnmarshalJSON

func (s *SegmentCollider2DSpec) UnmarshalJSON(data []byte) error

type ShaderCompileRequest

type ShaderCompileRequest struct {
	ID         string
	SourcePath string
	Source     []byte
	Target     ShaderTarget
}

type ShaderCompileResult

type ShaderCompileResult struct {
	Vertex           []byte
	Fragment         []byte
	Metal            []byte
	HasVertexEntry   bool
	HasFragmentEntry bool
	WebGL2Generated  bool
}

type ShaderCompiler

type ShaderCompiler interface {
	CompileShader(ShaderCompileRequest) (ShaderCompileResult, error)
}

ShaderCompiler converts one WGSL module into the native representation for a single build target. The compiler is invoked only during preprocessing; runtime packages contain the returned native bytes.

type ShaderComponentSpec

type ShaderComponentSpec struct {
	WGSLVertex   string        `json:"wgslVertex,omitempty"`
	WGSLFragment string        `json:"wgslFragment,omitempty"`
	Compiled     ShaderSources `json:"-"`
	Custom       [4][4]float32 `json:"custom,omitzero"`
}

ShaderComponentSpec authors WGSL stages and per-element uniforms. Compiled is generated by the build tools and retained only in binary plans.

func (ShaderComponentSpec) HasSource

func (s ShaderComponentSpec) HasSource() bool

func (ShaderComponentSpec) SourcePaths

func (s ShaderComponentSpec) SourcePaths() [2]string

type ShaderSources

type ShaderSources struct {
	DirectXVertex   string `json:"directXVertex,omitempty"`
	DirectXFragment string `json:"directXFragment,omitempty"`
	WGSLVertex      string `json:"wgslVertex,omitempty"`
	WGSLFragment    string `json:"wgslFragment,omitempty"`
	VulkanVertex    string `json:"vulkanVertex,omitempty"`
	VulkanFragment  string `json:"vulkanFragment,omitempty"`
	Metal           string `json:"metal,omitempty"`
	WebGL2Vertex    string `json:"webGL2Vertex,omitempty"`
	WebGL2Fragment  string `json:"webGL2Fragment,omitempty"`
	WebGPUVertex    string `json:"webGPUVertex,omitempty"`
	WebGPUFragment  string `json:"webGPUFragment,omitempty"`
	WebGL2Generated bool   `json:"webGL2Generated,omitempty"`
}

ShaderSources holds the source paths used by shader compilation and loading.

func (ShaderSources) HasSource

func (s ShaderSources) HasSource() bool

func (ShaderSources) SourcePaths

func (s ShaderSources) SourcePaths() [11]string

func (ShaderSources) Validate

func (s ShaderSources) Validate() error

type ShaderSpec

type ShaderSpec struct {
	ID string `json:"id"`
	ShaderSources
}

ShaderSpec maps one named shader resource to the native source files used by Onix's render backends. Missing stages inherit the built-in pipeline stage.

func (ShaderSpec) Validate

func (s ShaderSpec) Validate() error

type ShaderTarget

type ShaderTarget uint8
const (
	ShaderTargetAll ShaderTarget = iota
	ShaderTargetVulkan
	ShaderTargetMetal
	ShaderTargetWebGL2
	ShaderTargetWebGPU
	ShaderTargetDirectX
)

func (ShaderTarget) String

func (target ShaderTarget) String() string

type ShadowSpec

type ShadowSpec struct {
	Resolution   int     `json:"resolution"`
	Radius       float32 `json:"radius"`
	Depth        float32 `json:"depth"`
	Bias         float32 `json:"bias"`
	NormalBias   float32 `json:"normalBias"`
	Cascades     int     `json:"cascades,omitempty"`
	Distance     float32 `json:"distance,omitempty"`
	SplitLambda  float32 `json:"splitLambda,omitempty"`
	CascadeBlend float32 `json:"cascadeBlend,omitempty"`
}

func NewShadowSpec

func NewShadowSpec() *ShadowSpec

func (ShadowSpec) Settings

func (s ShadowSpec) Settings() render3d.ShadowSettings

func (*ShadowSpec) UnmarshalJSON

func (s *ShadowSpec) UnmarshalJSON(data []byte) error

type SizeConfig

type SizeConfig struct {
	Mode   window.ViewportMode `json:"mode,omitempty"`
	Width  int                 `json:"width"`
	Height int                 `json:"height"`
}

type SlotFieldValue

type SlotFieldValue struct {
	Name  string
	Value SlotValue
}

type SlotPlan

type SlotPlan struct {
	Name      string
	Type      ValueType
	Default   SlotValue
	Writable  bool
	Placement ModTransform
}

type SlotSpec

type SlotSpec struct {
	Type      ValueType        `json:"type"`
	Default   json.RawMessage  `json:"default,omitempty"`
	Writable  *bool            `json:"writable,omitempty"`
	Placement ModTransformSpec `json:"placement,omitzero"`
}

type SlotValue

type SlotValue struct {
	Type    ValueType
	String  string
	Fields  []SlotFieldValue
	Number  float64
	Integer int64
	Vector  [4]float32
	Bool    bool
}

type SpineComponentSpec

type SpineComponentSpec struct {
	Resource  string  `json:"resource"`
	Animation string  `json:"animation,omitempty"`
	Skin      string  `json:"skin,omitempty"`
	Loop      bool    `json:"loop"`
	Speed     float32 `json:"speed,omitempty"`
}

func (*SpineComponentSpec) UnmarshalJSON

func (s *SpineComponentSpec) UnmarshalJSON(data []byte) error

type SpineSpec

type SpineSpec struct {
	ID       string `json:"id"`
	Skeleton string `json:"skeleton"`
	Atlas    string `json:"atlas"`
	Texture  string `json:"texture"`
}

SpineSpec groups the three files that form one Spine export.

func (SpineSpec) Validate

func (s SpineSpec) Validate() error

type SpotLightSpec

type SpotLightSpec struct {
	Shadows          *PunctualShadowSpec     `json:"shadows,omitempty"`
	Color            string                  `json:"color"`
	Shape            render3d.SpotLightShape `json:"shape"`
	Unit             graphics.LightUnit      `json:"unit"`
	Radius           float32                 `json:"radius"`
	Range            float32                 `json:"range"`
	LuxDistance      float32                 `json:"luxDistance"`
	Intensity        float32                 `json:"intensity"`
	InnerConeAngle   float32                 `json:"innerConeAngle"`
	OuterConeAngle   float32                 `json:"outerConeAngle"`
	AspectRatio      float32                 `json:"aspectRatio"`
	Width            float32                 `json:"width"`
	Height           float32                 `json:"height"`
	Reflector        bool                    `json:"reflector"`
	RangeAttenuation bool                    `json:"rangeAttenuation"`
}

func NewSpotLightSpec

func NewSpotLightSpec() SpotLightSpec

func (SpotLightSpec) Light

func (s SpotLightSpec) Light() (render3d.SpotLight, error)

func (*SpotLightSpec) UnmarshalJSON

func (s *SpotLightSpec) UnmarshalJSON(data []byte) error

type SpriteComponentSpec

type SpriteComponentSpec struct {
	Texture *TextureSpec     `json:"texture,omitempty"`
	Trail   *SpriteTrailSpec `json:"trail,omitempty"`
}

func (*SpriteComponentSpec) UnmarshalJSON

func (s *SpriteComponentSpec) UnmarshalJSON(data []byte) error

type SpriteTrailSpec

type SpriteTrailSpec struct {
	Lifetime    float32 `json:"lifetime,omitempty"`
	Interval    float32 `json:"interval,omitempty"`
	MinDistance float32 `json:"minDistance,omitempty"`
	AlphaStart  float32 `json:"alphaStart,omitempty"`
	AlphaEnd    float32 `json:"alphaEnd,omitempty"`
	MaxSamples  int     `json:"maxSamples,omitempty"`
}

type TextComponentSpec

type TextComponentSpec struct {
	Shadow        *TextShadow `json:"shadow,omitempty"`
	Color         string      `json:"color,omitempty"`
	Font          string      `json:"font,omitempty"`
	WrapMode      string      `json:"wrapMode,omitempty"`
	OutlineColor  string      `json:"outlineColor,omitempty"`
	Value         string      `json:"value,omitempty"`
	TextAlignment string      `json:"textAlignment,omitempty"`
	FontSize      float64     `json:"fontSize,omitempty"`
	LineHeight    float32     `json:"lineHeight,omitempty"`
	OutlineWidth  float32     `json:"outlineWidth,omitempty"`
	LetterSpacing float32     `json:"letterSpacing,omitempty"`
	MaxWidth      float32     `json:"maxWidth,omitempty"`
	WrapWidth     float32     `json:"wrapWidth,omitempty"`
}

type TextShadow

type TextShadow struct {
	Color   string  `json:"color"`
	OffsetX float32 `json:"offsetX"`
	OffsetY float32 `json:"offsetY"`
}

type TextureSpec

type TextureSpec struct {
	Slice  *NineSlice `json:"slice,omitempty"`
	Image  string     `json:"image,omitempty"`
	Atlas  string     `json:"atlas,omitempty"`
	Frame  string     `json:"frame,omitempty"`
	Color  string     `json:"color,omitempty"`
	Mipmap bool       `json:"mipmap,omitempty"`
}

type TileRun

type TileRun struct {
	Value  int
	Length int
}

type TilemapSpec

type TilemapSpec struct {
	ID         string    `json:"id"`
	Tileset    string    `json:"tileset,omitempty"`
	Tiles      []int     `json:"tiles"`
	TileRuns   []TileRun `json:"-"`
	Width      int       `json:"width"`
	Height     int       `json:"height"`
	TileWidth  int       `json:"tileWidth"`
	TileHeight int       `json:"tileHeight"`
}

func (*TilemapSpec) Compact

func (s *TilemapSpec) Compact()

func (*TilemapSpec) Expand

func (s *TilemapSpec) Expand() error

func (*TilemapSpec) Normalize

func (s *TilemapSpec) Normalize()

func (TilemapSpec) Validate

func (s TilemapSpec) Validate() error

type TriangleMeshCollider3DSpec

type TriangleMeshCollider3DSpec struct {
	Model string `json:"model,omitempty"`
	Collider3DSettingsSpec
}

func NewTriangleMeshCollider3DSpec

func NewTriangleMeshCollider3DSpec() TriangleMeshCollider3DSpec

func (*TriangleMeshCollider3DSpec) UnmarshalJSON

func (s *TriangleMeshCollider3DSpec) UnmarshalJSON(data []byte) error

type ValueSchema

type ValueSchema struct {
	Fields map[string]ValueType `json:"fields"`
}

type ValueType

type ValueType string
const (
	StringValue ValueType = "string"
	BoolValue   ValueType = "bool"
	NumberValue ValueType = "number"
	IntValue    ValueType = "int"
	ColorValue  ValueType = "color"
	Vec2Value   ValueType = "vec2"
	Vec3Value   ValueType = "vec3"
	VisualValue ValueType = "visual"
)

type Video

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

Video owns a pinned encoded video blob. Bytes returns an immutable borrowed view; ReadAll returns an independent mutable copy.

func (*Video) Bytes

func (v *Video) Bytes() ([]byte, error)

func (*Video) Close

func (v *Video) Close() error

func (*Video) Info

func (v *Video) Info() resource.AssetInfo

func (*Video) Open

func (v *Video) Open() (io.ReadSeekCloser, error)

func (*Video) ReadAll

func (v *Video) ReadAll() ([]byte, error)

type WindowConfig

type WindowConfig struct {
	TPS                 *int                  `json:"tps"`
	Vsync               *bool                 `json:"vsync"`
	Antialias           *bool                 `json:"antialias,omitempty"`
	AlwaysOnTop         *bool                 `json:"alwaysOnTop,omitempty"`
	Border              *bool                 `json:"border,omitempty"`
	Shadow              *bool                 `json:"shadow,omitempty"`
	FPS                 *int                  `json:"fps"`
	ShowInTaskbar       *bool                 `json:"showInTaskbar,omitempty"`
	Resizable           *bool                 `json:"resizable,omitempty"`
	Title               string                `json:"title"`
	Icon                string                `json:"icon"`
	DRMDevice           string                `json:"drmDevice,omitempty"`
	Decorations         window.DecorationMode `json:"decorations,omitempty"`
	RenderScale         float64               `json:"renderScale,omitempty"`
	Height              int                   `json:"height"`
	Width               int                   `json:"width"`
	MaxDevicePixelRatio float64               `json:"maxDevicePixelRatio,omitempty"`
	CornerRadius        int                   `json:"cornerRadius,omitempty"`
	TitleBarHeight      float64               `json:"titleBarHeight,omitempty"`
	DRMConnectorID      uint32                `json:"drmConnectorId,omitempty"`
	Transparent         bool                  `json:"transparent,omitempty"`
}

Directories

Path Synopsis
Package assets contains opt-in project resource implementations.
Package assets contains opt-in project resource implementations.
Package projectaudio provides an opt-in audio resource feature for project bundles.
Package projectaudio provides an opt-in audio resource feature for project bundles.

Jump to

Keyboard shortcuts

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