project

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 42 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(x float32) AnimationClipSpec

DefaultAnimationClip creates the initial clip for an animation component that has no authored clip yet. Its first keyframe initializes the horizontal position.

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 AnimationSpecValue] 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 AnimationSpecValue added in v0.1.11

type AnimationSpecValue interface {
	float32 | bool | TextureSpec
}

AnimationSpecValue is a keyframe value supported by the project file format.

type AnimationTrackSpec

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

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 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 {
	Collider3DSettingsSpec
}

func NewCompoundCollider3DSpec

func NewCompoundCollider3DSpec() CompoundCollider3DSpec

func (*CompoundCollider3DSpec) UnmarshalJSON

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

type ConvexHullCollider3DSpec

type ConvexHullCollider3DSpec struct {
	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 for module assets.
	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 (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 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 or audio decoder bundles in project/assets.

func (ImageFeature[I]) ConfigureResources

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

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 ModelMaterialSpec

type ModelMaterialSpec struct {
	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 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 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)
	ShaderTarget   ShaderTarget
}

PreprocessOptions selects the 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 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 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.

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) 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) 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 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 ScenePlan

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

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