ci-platforms / windows amd64 smoke (push) Skipped
ci / release (push) Successful in 8m58s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 4m46s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 13m28s
98 lines
2.8 KiB
Go
98 lines
2.8 KiB
Go
package asset
|
|
|
|
import (
|
|
"aego/core/ids"
|
|
"aego/render/material"
|
|
"aego/render/mesh"
|
|
"aego/render/texture"
|
|
)
|
|
|
|
type ArtifactKind string
|
|
|
|
const (
|
|
ArtTexture ArtifactKind = "texture"
|
|
ArtAtlasPage ArtifactKind = "atlaspage"
|
|
ArtSpriteRegion ArtifactKind = "spriteregion"
|
|
ArtScene ArtifactKind = "scene"
|
|
ArtPrefab ArtifactKind = "prefab"
|
|
ArtMesh ArtifactKind = "mesh"
|
|
ArtScript ArtifactKind = "script"
|
|
ArtData ArtifactKind = "data"
|
|
ArtTable ArtifactKind = "table"
|
|
ArtPreset ArtifactKind = "preset"
|
|
ArtAudio ArtifactKind = "audio"
|
|
ArtAnim ArtifactKind = "anim"
|
|
ArtCtrl ArtifactKind = "animctrl"
|
|
ArtShader ArtifactKind = "shader"
|
|
ArtShaderInclude ArtifactKind = "shaderinclude"
|
|
ArtMaterial ArtifactKind = "material"
|
|
)
|
|
|
|
type Reloaded struct {
|
|
ID ids.AssetID
|
|
Kind ArtifactKind
|
|
}
|
|
|
|
type Resolver interface {
|
|
Texture(id ids.AssetID) (texture.Region, bool)
|
|
Mesh(id ids.AssetID) (*mesh.Mesh, bool)
|
|
Scene(id ids.AssetID) ([]byte, bool)
|
|
Prefab(id ids.AssetID) ([]byte, bool)
|
|
Generation() uint32
|
|
Subscribe(fn func(Reloaded)) func()
|
|
}
|
|
|
|
type Decoder interface {
|
|
Decoded(id ids.AssetID, key string, build func() (any, error)) (any, error)
|
|
}
|
|
|
|
type AnimSource interface {
|
|
Anim(id ids.AssetID) ([]byte, bool)
|
|
}
|
|
|
|
type CtrlSource interface {
|
|
Controller(id ids.AssetID) ([]byte, bool)
|
|
}
|
|
|
|
type PresetSource interface {
|
|
Preset(ids.AssetID) ([]byte, bool)
|
|
}
|
|
|
|
type DataSource interface {
|
|
Data(id ids.AssetID) ([]byte, bool)
|
|
Table(id ids.AssetID) ([]byte, bool)
|
|
}
|
|
|
|
// MaterialSource is optional so resolvers for scenes without materials remain
|
|
// valid. Runtime loaders expose only prepared definitions through this API.
|
|
type MaterialSource interface {
|
|
Material(id ids.AssetID) (*material.Material, bool)
|
|
}
|
|
|
|
type ShaderSource interface {
|
|
Shader(id ids.AssetID) (*material.Shader, bool)
|
|
}
|
|
|
|
// NormalSource optionally associates a prepared asset; an unresolved saved normal reference retains its nonzero ID.
|
|
// Normal regions have their own atlas UV and original-canvas trim mapping; do not sample them with albedo atlas coordinates.
|
|
type NormalSource interface {
|
|
NormalFor(albedo ids.AssetID) (normalID ids.AssetID, region texture.Region, ok bool)
|
|
}
|
|
|
|
// TextureMetadata describes prepared source semantics without a GPU, letting validators and export distinguish valid data masks from unresolved references.
|
|
type TextureMetadata struct {
|
|
Width, Height int
|
|
Semantic TextureSemantic
|
|
Region bool
|
|
}
|
|
|
|
type TextureMetadataSource interface {
|
|
TextureMetadata(ids.AssetID) (TextureMetadata, bool)
|
|
}
|
|
|
|
// EmissionSource exposes prepared independent region mappings. A nonzero ID
|
|
// survives a missing source; callers use uniform emission as the fallback.
|
|
type EmissionSource interface {
|
|
EmissionFor(albedo ids.AssetID) (ids.AssetID, texture.Emission, bool)
|
|
}
|