Documentation
¶
Overview ¶
Package worldsource defines the high-level, separately versioned room and prefab schema consumed by public world compilers. It intentionally has no YAML implementation dependency; tags describe the stable field vocabulary.
Index ¶
- Constants
- Variables
- func CompileAnimationPreset(p AnimationPreset, textures map[string]uint32) (sdkworld.AnimationPreset, error)
- func CompileParticlePreset(p ParticlePreset, textures map[string]uint32) (worldparticles.Preset, error)
- func Validate(document *Document) error
- func ValidateBandSettings(b *BandSettings) error
- func ValidateSecondarySettings(s *SecondarySettings) error
- func ValidateUVSettings(settings *UVSettings) error
- type Actor
- type AmbientCube
- type AnimationBinding
- type AnimationPreset
- type Animations
- type BandSettings
- type Connection
- type Content
- type Document
- type Edge
- type Endpoint
- type Environment
- type HorizontalBandSettings
- type Instance
- type LightMotion
- type Lighting
- type MaterialAnimation
- type MaterialOverride
- type ParticleEmitter
- type ParticlePreset
- type ParticleSpawn
- type ParticleSprite
- type Particles
- type Plane
- type PointLight
- type Port
- type PortalDirection
- type Prefab
- type Room
- type SecondarySettings
- type Solid
- type Sprite
- type Transform
- type UVAnchor
- type UVMode
- type UVSettings
- type Vec2
- type Vec3
Constants ¶
const ( LegacyVersion = uint16(1) ActorVersion = uint16(2) PortalVersion = uint16(3) LightingVersion = uint16(4) MappingVersion = uint16(5) SolidsVersion = uint16(6) MaterialsVersion = uint16(7) AnimationsVersion = uint16(8) EnvironmentVersion = uint16(9) ParticlesVersion = uint16(10) Version = ParticlesVersion MaxRooms = 1024 MaxPrefabs = 256 MaxInstances = 4096 MaxConnections = 8192 MaxPorts = 4096 MaxEdges = 8192 MaxEdgesPerRoom = 256 MaxContents = 4096 MaxLights = sdkworld.MaxLights MinLightRadius = sdkworld.MinLightRadius MaxMaterialOverrides = 256 MaxIdentifierBytes = 128 MaxTags = 8 MaxTagBytes = 64 MaxCoordinate = 1_000_000.0 MinEdgeLength = 1e-6 MinClearance = 1e-6 )
const MinUVScale = 0.001
Variables ¶
var ( ErrVersion = errors.New("world source version is unsupported") ErrBounds = errors.New("world source exceeds a declared bound") ErrIdentity = errors.New("world source identity is invalid") ErrGeometry = errors.New("world source geometry is invalid") ErrReference = errors.New("world source reference is invalid") ErrConnection = errors.New("world source connection is invalid") ErrContent = errors.New("world source content is invalid") ErrUVMapping = errors.New("world source UV mapping is invalid") ErrLighting = errors.New("world source lighting is invalid") ErrEnvironment = errors.New("world source environment is invalid") ErrPrefabCycle = errors.New("world source prefab cycle is invalid") )
Functions ¶
func CompileAnimationPreset ¶ added in v0.0.11
func CompileAnimationPreset(p AnimationPreset, textures map[string]uint32) (sdkworld.AnimationPreset, error)
CompileAnimationPreset converts one authored preset using the level's declared texture IDs. All frames must resolve, including frames used only in animations.
func CompileParticlePreset ¶ added in v0.0.12
func CompileParticlePreset(p ParticlePreset, textures map[string]uint32) (worldparticles.Preset, error)
CompileParticlePreset resolves every named frame, including particle-only textures. Source and runtime share complete analytical configuration validation.
func Validate ¶
Validate checks the complete source graph without expanding prefabs or decomposing rooms. Those compiler operations retain their own post-expansion bounds and diagnostics.
func ValidateBandSettings ¶ added in v0.0.10
func ValidateBandSettings(b *BandSettings) error
func ValidateSecondarySettings ¶ added in v0.0.10
func ValidateSecondarySettings(s *SecondarySettings) error
func ValidateUVSettings ¶ added in v0.0.8
func ValidateUVSettings(settings *UVSettings) error
ValidateUVSettings checks typed authored controls without resolving inheritance.
Types ¶
type Actor ¶ added in v0.0.6
type Actor struct {
YawDegrees float64 `yaml:"yaw_degrees"`
PitchDegrees float64 `yaml:"pitch_degrees"`
RollDegrees float64 `yaml:"roll_degrees"`
Scale Vec3 `yaml:"scale"`
Sprite *Sprite `yaml:"sprite,omitempty"`
Tags []string `yaml:"tags,omitempty"`
Animation *AnimationBinding `yaml:"animation,omitempty"`
}
type AmbientCube ¶ added in v0.0.8
type AmbientCube struct {
PositiveX Vec3 `yaml:"positive_x"`
NegativeX Vec3 `yaml:"negative_x"`
PositiveY Vec3 `yaml:"positive_y"`
NegativeY Vec3 `yaml:"negative_y"`
PositiveZ Vec3 `yaml:"positive_z"`
NegativeZ Vec3 `yaml:"negative_z"`
}
AmbientCube supplies six world-space directional ambient colors. It replaces Ambient when present; squared unit-normal components weight each selected face. Colors are finite linear RGB intensities in [0,1].
type AnimationBinding ¶ added in v0.0.11
type AnimationPreset ¶ added in v0.0.11
type AnimationPreset struct {
Name string `yaml:"name"`
Kind string `yaml:"kind"`
Frames []string `yaml:"frames,omitempty"`
FPS float64 `yaml:"fps,omitempty"`
IntervalSeconds float64 `yaml:"interval_seconds,omitempty"`
Flow Vec2 `yaml:"flow,omitempty"`
Amplitude float64 `yaml:"amplitude,omitempty"`
SurfaceAmplitude float64 `yaml:"surface_amplitude,omitempty"`
Opacity *float64 `yaml:"opacity,omitempty"`
PixelSize uint32 `yaml:"pixel_size,omitempty"`
Frequency float64 `yaml:"frequency,omitempty"`
Speed float64 `yaml:"speed,omitempty"`
Axis Vec3 `yaml:"axis,omitempty"`
Pivot Vec3 `yaml:"pivot,omitempty"`
Offset Vec3 `yaml:"offset,omitempty"`
PeriodSeconds float64 `yaml:"period_seconds,omitempty"`
}
type Animations ¶ added in v0.0.11
type Animations struct {
Version uint32 `yaml:"version"`
Presets []AnimationPreset `yaml:"presets"`
Materials []MaterialAnimation `yaml:"materials,omitempty"`
}
type BandSettings ¶ added in v0.0.10
type BandSettings struct {
Enabled *bool `yaml:"enabled,omitempty"`
Top *HorizontalBandSettings `yaml:"top,omitempty"`
Bottom *HorizontalBandSettings `yaml:"bottom,omitempty"`
}
BandSettings adds optional horizontal trim textures to visible wall spans. Builders resolve texture references, coverage and UVs before packaging.
func MergeBandSettings ¶ added in v0.0.10
func MergeBandSettings(base, override *BandSettings) *BandSettings
MergeBandSettings applies non-omitted edge fields over a room default. The returned records are independent; nested pointer values remain immutable inputs.
type Connection ¶
type Connection struct {
ID string `yaml:"id"`
A Endpoint `yaml:"a"`
B Endpoint `yaml:"b"`
Direction PortalDirection `yaml:"direction,omitempty"`
NonEuclidean bool `yaml:"non_euclidean,omitempty"`
}
Connection links two aperture endpoints. Direction defaults to both for compatibility. Each endpoint may own one outgoing link and may be the target of any number of links. NonEuclidean permits equal-length edges at different positions or orientations.
type Document ¶
type Document struct {
Version uint16 `yaml:"version"`
Rooms []Room `yaml:"rooms"`
Prefabs []Prefab `yaml:"prefabs"`
Instances []Instance `yaml:"instances"`
Connections []Connection `yaml:"connections"`
// Lighting is available in source v4 and later, in global world coordinates.
// It is not part of any room, prefab or instance transform.
Lighting *Lighting `yaml:"lighting,omitempty"`
UV *UVSettings `yaml:"uv,omitempty"`
Solids []Solid `yaml:"solids,omitempty"`
Contents []Content `yaml:"contents,omitempty"`
Animations *Animations `yaml:"animations,omitempty"`
Environment *Environment `yaml:"environment,omitempty"`
Particles *Particles `yaml:"particles,omitempty"`
}
type Edge ¶
type Edge struct {
ID string `yaml:"id"`
Start Vec2 `yaml:"start"`
End Vec2 `yaml:"end"`
Material string `yaml:"material"`
UV *UVSettings `yaml:"uv,omitempty"`
Bands *BandSettings `yaml:"bands,omitempty"`
Secondary *SecondarySettings `yaml:"secondary,omitempty"`
// Sky opens a finite boundary visually, while retaining player confinement.
// It requires a sky room and cannot be a connection or port endpoint.
Sky bool `yaml:"sky,omitempty"`
}
Edge is one named, directed CCW boundary edge.
type Endpoint ¶
type Endpoint struct {
Room string `yaml:"room"`
Edge string `yaml:"edge"`
Instance string `yaml:"instance"`
Port string `yaml:"port"`
}
Endpoint selects either a room edge in the current scope or a named port on an instance in that scope. Exactly one pair must be populated.
type Environment ¶ added in v0.0.12
type Environment struct {
Preset sdkworld.EnvironmentPreset `yaml:"preset"`
Palette sdkworld.EnvironmentPalette `yaml:"palette,omitempty"`
Sun *sdkworld.EnvironmentSun `yaml:"sun,omitempty"`
TimeOfDay *float64 `yaml:"time_of_day,omitempty"`
CloudAmount *float64 `yaml:"cloud_amount,omitempty"`
}
Environment authors world/environment@1 in source v9 and later. A preset alone supplies sky and lighting defaults. Angles are explicit when Sun is present; omission uses the preset direction. Environment is global and never transformed by a prefab instance.
type HorizontalBandSettings ¶ added in v0.0.10
type HorizontalBandSettings struct {
Enabled *bool `yaml:"enabled,omitempty"`
Texture string `yaml:"texture,omitempty"`
Height *float64 `yaml:"height,omitempty"`
RepeatWidth *float64 `yaml:"repeat_width,omitempty"`
Offset *Vec2 `yaml:"offset,omitempty"`
}
func MergeHorizontalBandSettings ¶ added in v0.0.10
func MergeHorizontalBandSettings(base, override *HorizontalBandSettings) *HorizontalBandSettings
type Instance ¶
type Instance struct {
ID string `yaml:"id"`
Prefab string `yaml:"prefab"`
Transform Transform `yaml:"transform"`
Materials []MaterialOverride `yaml:"materials"`
// Tags replaces the actor tags of every content in this prefab instance.
// An empty list preserves the prefab-authored tags.
Tags []string `yaml:"tags,omitempty"`
}
type LightMotion ¶ added in v0.0.8
type LightMotion struct {
Version uint32 `yaml:"version"`
Offset Vec3 `yaml:"offset"`
PeriodSeconds float64 `yaml:"period_seconds"`
}
LightMotion authors the bounded version-1 runtime light path.
type Lighting ¶ added in v0.0.8
type Lighting struct {
Version uint32 `yaml:"version"`
Ambient Vec3 `yaml:"ambient"`
Lights []PointLight `yaml:"lights"`
AmbientCube *AmbientCube `yaml:"ambient_cube,omitempty"`
Actors bool `yaml:"actors,omitempty"`
}
Lighting authors the world/lighting@1 payload. Version is the nested payload version (sdkworld.LightingVersion, 1), not the source document version. Ambient and Color use linear RGB intensities in [0,1]. Lights retain authored order and global positions; prefab-local lights are not supported.
type MaterialAnimation ¶ added in v0.0.11
type MaterialOverride ¶
type ParticleEmitter ¶ added in v0.0.12
type ParticlePreset ¶ added in v0.0.12
type ParticlePreset struct {
Name string `yaml:"name"`
Capacity uint32 `yaml:"capacity"`
Emission worldparticles.Emission `yaml:"emission"`
LifetimeSeconds worldparticles.Range `yaml:"lifetime_seconds"`
Spawn ParticleSpawn `yaml:"spawn"`
VelocityMin Vec3 `yaml:"velocity_min,omitempty"`
VelocityMax Vec3 `yaml:"velocity_max,omitempty"`
Acceleration Vec3 `yaml:"acceleration,omitempty"`
Drag float64 `yaml:"drag,omitempty"`
Sprite ParticleSprite `yaml:"sprite"`
SizeOverLife []worldparticles.ScalarKey `yaml:"size_over_life"`
ColorOverLife []worldparticles.ColorKey `yaml:"color_over_life"`
RotationDegrees worldparticles.Range `yaml:"rotation_degrees,omitempty"`
RotationSpeedDegrees worldparticles.Range `yaml:"rotation_speed_degrees,omitempty"`
}
type ParticleSpawn ¶ added in v0.0.12
type ParticleSprite ¶ added in v0.0.12
type Particles ¶ added in v0.0.12
type Particles struct {
Version uint16 `yaml:"version"`
Presets []ParticlePreset `yaml:"presets"`
Emitters []ParticleEmitter `yaml:"emitters,omitempty"`
}
type PointLight ¶ added in v0.0.8
type PointLight struct {
ID string `yaml:"id"`
Position Vec3 `yaml:"position"`
Color Vec3 `yaml:"color"`
Radius float64 `yaml:"radius"`
Motion *LightMotion `yaml:"motion,omitempty"`
}
PointLight has the same bounds and semantics as sdkworld.PointLight.
type PortalDirection ¶ added in v0.0.7
type PortalDirection string
const ( PortalBoth PortalDirection = "both" PortalAToB PortalDirection = "a-to-b" PortalBToA PortalDirection = "b-to-a" )
type Prefab ¶
type Prefab struct {
ID string `yaml:"id"`
Rooms []Room `yaml:"rooms"`
Instances []Instance `yaml:"instances"`
Connections []Connection `yaml:"connections"`
Ports []Port `yaml:"ports"`
Solids []Solid `yaml:"solids,omitempty"`
Contents []Content `yaml:"contents,omitempty"`
ParticleEmitters []ParticleEmitter `yaml:"particle_emitters,omitempty"`
}
type Room ¶
type Room struct {
ID string `yaml:"id"`
Boundary []Edge `yaml:"boundary"`
Floor Plane `yaml:"floor"`
Ceiling Plane `yaml:"ceiling"`
FloorMaterial string `yaml:"floor_material"`
CeilingMaterial string `yaml:"ceiling_material"`
Contents []Content `yaml:"contents"`
FloorUV *UVSettings `yaml:"floor_uv,omitempty"`
CeilingUV *UVSettings `yaml:"ceiling_uv,omitempty"`
WallUV *UVSettings `yaml:"wall_uv,omitempty"`
WallBands *BandSettings `yaml:"wall_bands,omitempty"`
FloorSecondary *SecondarySettings `yaml:"floor_secondary,omitempty"`
CeilingSecondary *SecondarySettings `yaml:"ceiling_secondary,omitempty"`
WallSecondary *SecondarySettings `yaml:"wall_secondary,omitempty"`
Sky bool `yaml:"sky,omitempty"`
ParticleEmitters []ParticleEmitter `yaml:"particle_emitters,omitempty"`
}
Room may be concave. The compiler decomposes it into convex sectors after prefab expansion and connection resolution.
type SecondarySettings ¶ added in v0.0.10
type SecondarySettings struct {
Enabled *bool `yaml:"enabled,omitempty"`
Texture string `yaml:"texture,omitempty"`
Strength *float64 `yaml:"strength,omitempty"`
UV *UVSettings `yaml:"uv,omitempty"`
}
SecondarySettings describes one colour-only detail image in source v7. Nil fields inherit room settings; Enabled=false disables the resolved layer.
type Solid ¶ added in v0.0.8
type Solid struct {
ID string `yaml:"id"`
Footprint []Vec2 `yaml:"footprint"`
Bottom Plane `yaml:"bottom"`
Top Plane `yaml:"top"`
SideMaterial string `yaml:"side_material"`
TopMaterial string `yaml:"top_material"`
BottomMaterial string `yaml:"bottom_material"`
SideUV *UVSettings `yaml:"side_uv,omitempty"`
TopUV *UVSettings `yaml:"top_uv,omitempty"`
BottomUV *UVSettings `yaml:"bottom_uv,omitempty"`
Collision bool `yaml:"collision,omitempty"`
}
Solid is an extrusion independent of room decomposition. Root records use global coordinates; prefab records receive nested instance transforms. Optional UV controls inherit root horizontal defaults for caps; sides accept only an explicit planar/world mapping in version 6.
type Transform ¶
type Transform struct {
Translation Vec3 `yaml:"translation"`
YawDegrees float64 `yaml:"yaw_degrees"`
Scale float64 `yaml:"scale"`
}
Transform applies uniform scale, Z-axis yaw in degrees and translation. Scale zero means the schema default of one.
type UVSettings ¶ added in v0.0.8
type UVSettings struct {
Mode UVMode `yaml:"mode,omitempty"`
Anchor UVAnchor `yaml:"anchor,omitempty"`
Scale *Vec2 `yaml:"scale,omitempty"`
Offset *Vec2 `yaml:"offset,omitempty"`
RotationDegrees *float64 `yaml:"rotation_degrees,omitempty"`
}
UVSettings contains editor/compiler projection controls available in source v5. Empty Mode/Anchor and nil numeric fields inherit root -> room -> edge. Defaults are triplanar/world, scale (1,1), offset (0,0), rotation 0 degrees. Scale uses world units per repeat; Offset uses texture repeats. Rotation's pointer preserves an explicit zero override. Hosts receive only baked planes.