Help us shape the future of Go! Take the 2026 Go Developer Survey

worldsource

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 11 Imported by: 0

README

World authoring semantics

worldsource defines typed room, prefab, port, content and material authoring semantics. It has no YAML implementation dependency: YAML tags describe field names, and Validate checks typed values. Public compilers own text parsing, presence and unknown-field checks, diagnostics, prefab expansion and convex decomposition. They must enforce compiled-world bounds again after expansion. Runtime format types have no JSON tags or custom JSON methods; source YAML vocabulary and TOML asset controls remain explicit and independently checked.

The Karty CLI generates local YAML editor schemas with karty schema. Run it from a game project to include that level's material, texture and prefab choices, or from this repository root to generate the shared base referenced by the standalone source fixture. The generated .karty/schemas directory is ignored; format validation and builds do not require the CLI or a YAML parser here.

Source version Added semantics
1 Rooms, prefabs and ordinary connections
2 Typed actors and instance tags
3 Directed and transformed connections
4 Root authored lighting
5 Material UV mapping
6 Static solids, root/prefab contents and room-free prefabs
7 Top/bottom wall bands and secondary colour textures
8 Reusable actor and material animations
9 Environment presets, sky ceilings and horizon boundaries
10 GPU sprite particle presets and transformed emitters
11 Solid prefab renderers and environment backdrop choices
12 Project-owned sky textures and presentation settings
13 Seeded floor/ceiling vegetation layers with sector density
14 Shrub vegetation geometry
15 Vegetation normal textures
16 Tree vegetation geometry
17 Liquid volumes
18 Explicit environment lighting and colors
19 Compact rectangular rooms
20 Palm vegetation geometry

Versions 1–20 remain supported. Optional fields must respect their version gates; omitting new fields preserves older encodings. See the compiled world contract for output validation and lighting bounds. Root lighting remains in global coordinates and is never transformed by a prefab.

The SDK separates the 4,096 authored-source bound (worldsource.MaxLights) from the 50 live direct-light budget (world.MaxRuntimeLights). Offline build policy may automatically select every fixed light without a nonzero linked emission pulse; motion and pulsing sources remain runtime lights. Authoring and compiled validation accept the complete source set, while producers check the remaining live budget when packaging a world. An unbaked preview still uses the runtime limit.

Environment and outdoor geometry, source version 9

Source v9 adds an optional root environment and room/edge sky markers:

version: 9
environment:
  preset: fantasy
  palette: violet # optional; omitted means the preset's default sky
  sun: # optional; omission uses the preset direction
    azimuth: 135
    elevation: 40
rooms:
  - id: courtyard
    sky: true
    # Ordinary finite geometry and material fields remain required.

preset is daylight, space, cartoon or fantasy. palette is omitted, default, violet or twilight; it changes sky colors without changing light colors or intensity. A supplied sun requires both finite angles in degrees: azimuth [0,360) measured from +X toward +Y, and elevation [0,90] above the XY plane. Environment belongs to the root, with no prefab transform. A preset alone supplies bounded sky, sun and outdoor fill defaults.

Optional time_of_day supplies finite hours [0,24) (midnight 0, sunrise 6, noon 12, sunset 18); optional cloud_amount supplies finite coverage [0,1]. Omitted time preserves fixed sun defaults or explicit angles; providing both time and sun is rejected. Omitted clouds resolve to 0.35; explicit zero is clear. Compilers preserve pointer presence for these optional controls. The engine live setter can subsequently override the clock/clouds for every camera in a mounted world while retaining authored preset/palette choices.

Room sky: true turns its ceiling into an environment opening. The room retains its finite ceiling for spatial bounds and portal confinement. Edge sky: true turns an opaque boundary into a horizon opening, while preserving confinement; it requires a sky room and cannot be a connection or exported port endpoint, including through nested prefab ports. Ordinary walls, floors, roofs and static solids keep their physical behavior. Sky rooms in prefabs require the root environment. Outdoor rooms remain ordinary connected playable geometry.

Source v1–8 reject all environment/sky fields, including explicitly supplied environment: null and sky: false. Text parsers reject null, unknown fields, missing sun angles and bad scalar types; typed SDK validation checks the values and complete graph. Compilers preserve sky markers through expansion and convex decomposition, add the compiled version-1 environment payload and declare world/environment@1 with world/sectors@1. See the compiled decision.

Environment backdrops, source version 11 / SDK 0.0.12

Optional environment.backdrop is none, mountains or city. The versioned selector and its encoding remain valid; current hosts draw decorative art from project-owned source v12 sky resources. The selector is a decorative horizon layer; it adds no geometry, collision, lighting or receivers. Source versions 1–10 reject explicit choices. Text parsers reject empty and null values; typed omission remains the empty string. Time/cloud runtime overrides preserve the authored selection and leave illumination independent of it.

An explicit selector declares candidate capability world/environment-backdrop@1 alongside world/environment@1 and world/sectors@1; SDK 0.0.11 does not support it. It uses the existing unreleased KWR2 extension after its solid-renderer trailer (1 none, 2 mountains, 3 city). Backdrop-only records carry a nil solid sentinel before the selector. Omission preserves exact KWR1 bytes and existing solid-only KWR2 bytes. Full bounded scans reject invalid selectors, missing payloads and trailing data before publishing any world.

Project-owned sky, source version 12 / SDK 0.0.12

Optional environment.sky authors a separate world/sky@1 level resource. Its cloud_sparse, cloud_dense, background and horizon fields reference PNGs relative to the owning level directory. References must be clean, confined paths: no absolute paths, parent traversal, backslashes, NULs or drive/URL prefixes, and at most 1,024 UTF-8 bytes. The CLI also checks filesystem path confinement before opening each source file. Omitted images contribute no artwork; an empty sky object is valid. Source versions 1–11 reject explicit sky fields.

version: 12
environment:
  preset: daylight
  sky:
    cloud_sparse: sky/clouds.png
    horizon: sky/horizon.png
    settings:
      horizon_haze: 0.2

settings is optional and overrides fields independently, preserving explicit zero. Omitted fields use worldsky.DefaultSettings: cloud UV scale [1, 1], dense scroll scale 1, horizon UV scale 1, and zero offsets, parallax, haze and emission. Available fields and bounds are documented in the sky resource contract. A supplied horizon renders regardless of the legacy backdrop choice. Without a sky sidecar the host renders an asset-free gradient and sun. Project images and presentation settings never modify environment lighting or runtime clock/cloud controls; those remain in the frozen compiled environment record.

Material mapping, version 1

SDK 0.0.8 provides world/material-mapping@1. Authoring source v5 supports optional root uv, room floor_uv, ceiling_uv, wall_uv, and edge uv. Source v1–4 reject those fields; omission preserves their previous encodings and compiler behavior. Source v5 defaults to triplanar mapping with world anchoring, one world unit per repeat, zero offset and zero rotation. Controls inherit field by field from root to room to edge; nil numeric pointers and empty mode/anchor strings inherit. Explicit rotation_degrees: 0 overrides an inherited rotation.

mode accepts triplanar, planar, wrap; anchor accepts world, top, bottom. scale: {x: ..., y: ...} gives positive world units per repeat in [0.001, 1,000,000]. offset is in repeats, with finite components bounded to ±1,000,000. rotation_degrees is finite and bounded to ±1,000,000. Wrap and vertical top/bottom anchors apply to walls: top uses ceiling(x,y)-z, bottom uses z-floor(x,y). Explicit floor/ceiling wrap or top/bottom anchors are invalid. Inherited root wrap falls back to planar on floors/ceilings; inherited wall anchors do not move horizontal surfaces. The compiler resolves inheritance, projection axes, scale, offset, rotation, anchoring and prefab transforms.

See compiled mapping for the resolved affine projections and capability requirements.

Solids and loose contents, version 1

Source v6 adds optional solids and contents to root documents and prefabs. Detail-only, sprite-only and nested room-free prefabs expand into existing rooms without creating sectors. Older source versions reject these fields. Omission preserves existing encoded bytes. The source solid count is at most 1,024 across root solids and prefab definitions; compilers enforce it again after expansion.

Source material names resolve through packaged textures. Nested prefab scale, yaw, translation and material overrides apply to solids and loose sprites. The compiler assigns loose contents to the first containing compiled sector in stable order, including shared boundaries and elevation. Source caps inherit horizontal root mapping defaults; source side_uv is restricted to shared planar/world X/Z mapping. Per-edge wrap and varying side triplanar weights are not expressible by a single SideUV and are rejected. Mapped solids require the existing world/material-mapping@1 marker/capability; hosts also require world/static-solids@1. No new guest command or level envelope version is added.

See compiled solids for exact geometry, material and collision bounds.

Wall bands and secondary colour, source version 7

Source v7 adds wall_bands to rooms and bands to directed authored edges. Each contains optional enabled, top and bottom. Each horizontal band accepts texture, enabled, height, repeat_width and offset: {x, y}. Textures resolve through the ordinary level texture catalog; the same texture can be reused by both bands. Enabled resolved bands require a texture and height. Repeat width defaults to 1 world unit and offset to zero. Alpha is band coverage; transparent pixels reveal the underlying opaque wall.

Rooms also supply floor_secondary, ceiling_secondary, wall_secondary, and edges may override secondary. A secondary references one opaque texture, optional enabled, strength in [0,1], and existing uv settings. Its colour modulates the main in linear space; neutral sRGB (188,188,188) preserves the main colour. It does not replace normal, height or AO channels.

All optional fields inherit field by field after prefab expansion; explicit enabled: false disables an inherited setting. Builders apply material substitution independently to top, bottom and secondary references. MergeBandSettings returns independent nested band records, preserving input values. Dimensions and repeats use world units and must be finite in [0.001,1000000]; offsets retain ±1000000 bounds. Source versions 1–6 reject these fields; omission preserves their existing serialized shape. Typed SDK validation checks versions and partial controls; public text parsers must additionally reject explicit null and unknown fields and validate the complete resolved settings and resource references.

Horizontal bands follow visible solid-span floor and ceiling profiles with fixed vertical thickness. Opposing envelopes on a short span crop at a proportional boundary, retaining requested texture density. The builder compiles the complete nonoverlapping wall partition, mappings, material IDs and coverage classes. There are no vertical-band or frame-sheet authoring fields. The source-v7 band vocabulary and compiled world/material-layer formats have separate version gates. See the compiled contract.

Source v8 reusable animations

Source v8 adds optional top-level animations: {version: 1, presets: [...], materials: [...]} and actor.animation: {preset: name, phase_seconds: 0}. Presets are level-wide and referenced by name, including inside prefabs. Material bindings use declared texture names; flipbook frames are lists of declared texture names. The compiler resolves every frame to a nonzero level texture ID. Material bindings apply wherever the material occurs; an explicit actor binding supplies its own preset and phase. Preset coordinates stay actor-local through prefab expansion, so placement scale and orientation carry motion along with the actor.

The initial catalogue is flipbook, liquid, spin, and oscillate. See the compiled contract for parameters, bounds and timing. Source v1–v7 reject animations and retain existing wire behavior. Frames are separate complete textures, which the world material atlas packs into ordinary slots; they are not arbitrary authored atlas rectangles. Flipbook frames must have equal processed dimensions. Presets cannot be nested or reference other presets, and frame materials cannot select another material animation.

Liquid presets may also specify surface_amplitude (0–0.25 world metres), opacity (0–1, omitted means 1), and pixel_size (integer 0–32). These fields are liquid-only; explicit nulls are rejected by the source YAML adapter. Compilation owns an independent copy of an explicit opacity value.

GPU sprite particles, source version 10

Source v10 adds root particles: {version: 1, presets: [...], emitters: [...]} and room/prefab particle_emitters arrays. Presets name level textures; emitter positions, yaw and uniform scale follow prefab transforms. Source v1–9 rejects particle fields, including explicit null. Optional fields should be omitted; text decoders also reject null inside the particle block and require explicitly authored zero-valued fields such as seed, position, curve age and burst time.

Compilers resolve all frames, require square matching frame dimensions, reserve complete birth schedule groups for overlapping lifetimes, compute conservative GPU motion bounds, and confine every emitter to one compiled convex sector. Room-local emitters remain in sectors owned by their expanded room. An emitter-only prefab is valid without unrelated geometry or marker contents. Optional scale omission or zero defaults to one; omitted vector components remain zero. They stage the separate @world/particles resource and declare world/particles@1 alongside world/sectors@1. See the version-1 particle contract for exact fields, units, lifecycle rules and resource bounds.

Solid renderers, source version 11

Prefab.Renderable packages a rigid solid-only prefab for runtime creation. Actor.SolidRenderer references one such prefab and also implicitly packages it. Renderer prefabs may nest solid-only instances; rooms, connections, ports, contents, emitters and collision-enabled solids are rejected. Actor sprites and actor animation bindings cannot coexist with a solid renderer. Public compilers retain one local definition per referenced/exported prefab, resolve level materials, and emit actor attachments in world.SolidRenderers. They must reject explicit renderer fields before v11 and null/empty renderer identifiers.

Alpha GPU particles, source version 11

Candidate SDK 0.0.12 permits particles.version: 2 in source v11. It adds sprite.blend: alpha and premultiplied using the existing particle fields, and declares the exact world/particles@2 capability. Source v10 retains version-1 semantics and rejects version 2. Source v11 can still author version 1, which rejects both new materials. The bounded layout, schedules, texture resolution, prefab transforms and whole-envelope confinement remain unchanged.

CompileParticlePreset remains strict version 1. Public compilers select CompileParticlePresetForVersion using the enclosing particle document version; hosts validate that version against the corresponding declared feature. See alpha rendering and ordering limits.

Sector vegetation, source version 13

An optional root vegetation library contains version-1 presets: name, named texture, width and height ranges (min and max), wind_amplitude, wind_frequency and draw_distance. A room's vegetation_layers assigns preset, density, uint32 seed and explicit surface: floor or ceiling. All fields are required in authored text, including zero density, wind or seed. Each layer is independently authored; masks and automatic biome interpolation are outside this contract. Ceiling placement on sky rooms is invalid.

Public compilers resolve texture names through CompileVegetationPreset, expand room layers onto convex sectors and stage the bounded @world/vegetation sidecar with world/vegetation@1 plus world/sectors@1. Reusable preset libraries without placements require no sidecar. Source v1–12 cannot use vegetation fields. See the version-1 vegetation decision and bounds.

Source 14 adds built-in shrub geometry through vegetation version 2 (KWV2, world/vegetation@2); Source 13 / KWV1 remain supported.

Source 15 adds optional normal_texture vegetation resources through version 3 (KWV3, world/vegetation@3); earlier vegetation versions remain supported.

Source 16 adds geometry: tree through vegetation version 4 (KWV4, world/vegetation@4), retaining previous vegetation versions.

Source 18 replaces environment preset, palette and backdrop selectors with required lighting (sun_color, sun_intensity, ambient, optional ambient_cube) and optional complete colors. Project sky assets remain unchanged. Legacy Source 9–17 selectors still decode; explicit lighting is rejected before Source 18. See world.EnvironmentLighting and world.EnvironmentColors for numeric bounds.

Compact rectangular rooms

Source version 19 accepts rect instead of boundary in ordinary and prefab rooms. For example:

version: 19
rooms:
  - id: room
    rect: {x: 0, y: 0, width: 8, depth: 6, material: stone}
    ceiling: {c: 3}
    floor_material: stone
    ceiling_material: stone

ExpandCompactRooms builds the counterclockwise edges south, east, north, west before normal validation and compiler expansion. X/Y default to zero; width/depth must be positive, material names and coordinates remain bounded. Explicit boundary and rect cannot coexist, even with an empty boundary. Prefabs retain their existing transforms, ports and material overrides. Older source versions reject this shorthand. Compiled worlds and runtime capabilities are unchanged; explicit and compact equivalents retain identical room/edge IDs.

Palm vegetation, source version 20

Source 20 accepts vegetation.version: 5 and geometry: palm. The compiler resolves the existing albedo and optional normal texture references and declares world/vegetation@5. Width defines full crown extent and height full tree height; independent density, seed, surface, draw distance and wind controls are unchanged. Source 1–19 reject v5 libraries even without placements. Vegetation versions 1–4 reject palms even on unused presets. Source 20 can still author all earlier vegetation versions. No imported model or new authoring field is required. See the v5 format decision.

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

View Source
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)
	SolidRenderersVersion      = uint16(11)
	SkyVersion                 = uint16(12)
	VegetationVersion          = uint16(13)
	VegetationGeometryVersion  = uint16(14)
	VegetationNormalVersion    = uint16(15)
	VegetationTreeVersion      = uint16(16)
	FluidsVersion              = uint16(17)
	ExplicitEnvironmentVersion = uint16(18)
	CompactRoomVersion         = uint16(19)
	VegetationPalmVersion      = uint16(20)
	Version                    = VegetationPalmVersion
	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
)
View Source
const AlphaParticlesVersion = uint16(11)
View Source
const EnvironmentBackdropVersion = uint16(11)
View Source
const MinUVScale = 0.001

Variables

View Source
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 CompileFluids added in v0.0.15

func CompileFluids(f *Fluids) *world.Fluids

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 CompileParticlePresetForVersion added in v0.0.13

func CompileParticlePresetForVersion(p ParticlePreset, textures map[string]uint32, version uint16) (worldparticles.Preset, error)

CompileParticlePresetForVersion resolves frames under the selected particle contract. The legacy CompileParticlePreset helper remains strict version 1.

func CompileVegetationPreset added in v0.0.15

func CompileVegetationPreset(p VegetationPreset, textures map[string]uint32) (worldvegetation.Preset, error)

func CompileVegetationPresetForVersion added in v0.0.15

func CompileVegetationPresetForVersion(p VegetationPreset, textures map[string]uint32, version uint16) (worldvegetation.Preset, error)

CompileVegetationPresetForVersion resolves a built-in shape, albedo and optional tangent-space normal map.

func Validate

func Validate(document *Document) error

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"`
	SolidRenderer string            `yaml:"solid_renderer,omitempty"`
	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 AnimationBinding struct {
	Preset       string  `yaml:"preset"`
	PhaseSeconds float64 `yaml:"phase_seconds,omitempty"`
}

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 Content

type Content struct {
	ID       string `yaml:"id"`
	Kind     string `yaml:"kind"`
	Position Vec3   `yaml:"position"`
	Actor    *Actor `yaml:"actor,omitempty"`
}

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"`
	Vegetation  *Vegetation  `yaml:"vegetation,omitempty"`
	Fluids      *Fluids      `yaml:"fluids,omitempty"`
}

func ExpandCompactRooms added in v0.0.15

func ExpandCompactRooms(document *Document) (Document, error)

ExpandCompactRooms copies room slices and creates compact boundaries without changing the input or bypassing ordinary validation. Other fields stay shared. Compilers call this before prefab expansion; runtimes consume existing sectors.

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 {
	Lighting    *sdkworld.EnvironmentLighting `yaml:"lighting,omitempty"`
	Colors      *sdkworld.EnvironmentColors   `yaml:"colors,omitempty"`
	Preset      sdkworld.EnvironmentPreset    `yaml:"preset,omitempty"`
	Palette     sdkworld.EnvironmentPalette   `yaml:"palette,omitempty"`
	Sun         *sdkworld.EnvironmentSun      `yaml:"sun,omitempty"`
	TimeOfDay   *float64                      `yaml:"time_of_day,omitempty"`
	Backdrop    sdkworld.EnvironmentBackdrop  `yaml:"backdrop,omitempty"`
	CloudAmount *float64                      `yaml:"cloud_amount,omitempty"`
	Sky         *Sky                          `yaml:"sky,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 Fluid added in v0.0.15

type Fluid struct {
	ID           string   `yaml:"id"`
	Solids       []string `yaml:"solids"`
	Density      float64  `yaml:"density"`
	LinearDrag   float64  `yaml:"linear_drag"`
	AngularDrag  float64  `yaml:"angular_drag"`
	FoamWidth    float64  `yaml:"foam_width"`
	FoamStrength float64  `yaml:"foam_strength"`
	FoamColor    Vec3     `yaml:"foam_color"`
	FogDensity   float64  `yaml:"fog_density"`
	FogColor     Vec3     `yaml:"fog_color"`
	Distortion   float64  `yaml:"distortion"`
}

type Fluids added in v0.0.15

type Fluids struct {
	Version uint32  `yaml:"version"`
	Items   []Fluid `yaml:"items"`
}

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 MaterialAnimation struct {
	Material     string  `yaml:"material"`
	Preset       string  `yaml:"preset"`
	PhaseSeconds float64 `yaml:"phase_seconds,omitempty"`
}

type MaterialOverride

type MaterialOverride struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
}

type ParticleEmitter added in v0.0.12

type ParticleEmitter struct {
	ID         string                  `yaml:"id"`
	Preset     string                  `yaml:"preset"`
	Position   Vec3                    `yaml:"position"`
	YawDegrees float64                 `yaml:"yaw_degrees,omitempty"`
	Scale      float64                 `yaml:"scale,omitempty"`
	Seed       uint32                  `yaml:"seed"`
	Playback   worldparticles.Playback `yaml:"playback"`
}

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 ParticleSpawn struct {
	Shape      string `yaml:"shape"`
	HalfExtent Vec3   `yaml:"half_extent,omitempty"`
}

type ParticleSprite added in v0.0.12

type ParticleSprite struct {
	Frames   []string `yaml:"frames"`
	FPS      float64  `yaml:"fps,omitempty"`
	Playback string   `yaml:"playback"`
	Facing   string   `yaml:"facing"`
	Blend    string   `yaml:"blend"`
}

type Particles added in v0.0.12

type Particles struct {
	Version  uint16            `yaml:"version"`
	Presets  []ParticlePreset  `yaml:"presets"`
	Emitters []ParticleEmitter `yaml:"emitters,omitempty"`
}

type Plane

type Plane struct {
	A float64 `yaml:"a"`
	B float64 `yaml:"b"`
	C float64 `yaml:"c"`
}

Plane describes elevation z=A*x+B*y+C in source coordinates.

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 Port

type Port struct {
	ID       string   `yaml:"id"`
	Endpoint Endpoint `yaml:"endpoint"`
}

Port exposes one otherwise unconnected prefab endpoint to its instances.

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 {
	Renderable       bool              `yaml:"renderable,omitempty"`
	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 {
	Rect             *RoomRectangle     `yaml:"rect,omitempty"`
	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"`
	VegetationLayers []VegetationLayer  `yaml:"vegetation_layers,omitempty"`
}

Room may be concave. The compiler decomposes it into convex sectors after prefab expansion and connection resolution.

type RoomRectangle added in v0.0.15

type RoomRectangle struct {
	X        float64 `yaml:"x"`
	Y        float64 `yaml:"y"`
	Width    float64 `yaml:"width"`
	Depth    float64 `yaml:"depth"`
	Material string  `yaml:"material"`
}

RoomRectangle expands to four named CCW edges: south, east, north, west. Floor, ceiling and their materials remain ordinary room fields.

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 Sky added in v0.0.14

type Sky struct {
	CloudSparse string       `yaml:"cloud_sparse,omitempty"`
	CloudDense  string       `yaml:"cloud_dense,omitempty"`
	Background  string       `yaml:"background,omitempty"`
	Horizon     string       `yaml:"horizon,omitempty"`
	Settings    *SkySettings `yaml:"settings,omitempty"`
}

Sky authors the separately packaged world/sky@1 resource in source v12. Image paths are confined, slash-separated level-relative PNG references.

func (Sky) ResolvedSettings added in v0.0.14

func (sky Sky) ResolvedSettings() worldsky.Settings

ResolvedSettings merges individual authored fields onto artwork-free defaults.

type SkySettings added in v0.0.14

type SkySettings struct {
	CloudUVScale          *[2]float64 `yaml:"cloud_uv_scale,omitempty"`
	CloudDenseScrollScale *float64    `yaml:"cloud_dense_scroll_scale,omitempty"`
	CloudDenseOffset      *[2]float64 `yaml:"cloud_dense_offset,omitempty"`
	CloudParallax         *[2]float64 `yaml:"cloud_parallax,omitempty"`
	HorizonUVScale        *float64    `yaml:"horizon_uv_scale,omitempty"`
	HorizonParallax       *float64    `yaml:"horizon_parallax,omitempty"`
	HorizonHaze           *float64    `yaml:"horizon_haze,omitempty"`
	HorizonEmission       *[3]float64 `yaml:"horizon_emission,omitempty"`
}

SkySettings applies optional presentation overrides independently. Explicit zero is retained, while omission inherits worldsky.DefaultSettings().

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 Sprite added in v0.0.6

type Sprite struct {
	Texture string  `yaml:"texture"`
	Facing  string  `yaml:"facing"`
	Alpha   string  `yaml:"alpha"`
	Width   float64 `yaml:"width"`
	Height  float64 `yaml:"height"`
	OriginX float64 `yaml:"origin_x"`
	OriginY float64 `yaml:"origin_y"`
}

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 UVAnchor added in v0.0.8

type UVAnchor string
const (
	UVWorld  UVAnchor = "world"
	UVTop    UVAnchor = "top"
	UVBottom UVAnchor = "bottom"
)

type UVMode added in v0.0.8

type UVMode string
const (
	UVTriplanar UVMode = "triplanar"
	UVPlanar    UVMode = "planar"
	UVWrap      UVMode = "wrap"
)

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.

type Vec2

type Vec2 struct {
	X float64 `yaml:"x"`
	Y float64 `yaml:"y"`
}

type Vec3

type Vec3 struct {
	X float64 `yaml:"x"`
	Y float64 `yaml:"y"`
	Z float64 `yaml:"z"`
}

type Vegetation added in v0.0.15

type Vegetation struct {
	Version uint16             `yaml:"version"`
	Presets []VegetationPreset `yaml:"presets"`
}

Vegetation is a root preset library, introduced in source version 13.

type VegetationLayer added in v0.0.15

type VegetationLayer struct {
	Preset  string  `yaml:"preset"`
	Density float64 `yaml:"density"`
	Seed    uint32  `yaml:"seed"`
	Surface string  `yaml:"surface"`
}

VegetationLayer assigns independent density and seed to one room surface. Surface must be explicit; omission does not silently pick a surface.

type VegetationPreset added in v0.0.15

type VegetationPreset struct {
	Name          string                `yaml:"name"`
	Geometry      string                `yaml:"geometry,omitempty"`
	NormalTexture string                `yaml:"normal_texture,omitempty"`
	Texture       string                `yaml:"texture"`
	Width         worldvegetation.Range `yaml:"width"`
	Height        worldvegetation.Range `yaml:"height"`
	WindAmplitude float64               `yaml:"wind_amplitude"`
	WindFrequency float64               `yaml:"wind_frequency"`
	DrawDistance  float64               `yaml:"draw_distance"`
}

Jump to

Keyboard shortcuts

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