Skip to content

GlobalUniforms

Defined in: packages/three-flatland/src/GlobalUniforms.ts:30

Global uniforms shared across all sprite materials in a Flatland instance.

These uniforms are set once per frame and shared by all sprites. They avoid per-sprite duplication and never cause shader recompilation.

// Flatland creates and owns the global uniforms
const globals = flatland.globals
// Access TSL nodes in custom colorTransform
const material = new Sprite2DMaterial({
colorTransform: (ctx) => {
const tinted = ctx.color.rgb.mul(globals.globalTintNode)
return tinted.toVec4(ctx.color.a)
}
})
// Each frame, Flatland updates the values
// (or set them directly for manual control)
globals.time = performance.now() / 1000
globals.globalTint = new Color(0.8, 0.9, 1.0) // moonlight

new GlobalUniforms(): GlobalUniforms

Defined in: packages/three-flatland/src/GlobalUniforms.ts:82

GlobalUniforms

readonly fogColorNode: UniformNode <"color", Color >

Defined in: packages/three-flatland/src/GlobalUniforms.ts:78

Fog color uniform node (vec3/color)


readonly fogRangeNode: UniformNode <"vec2", Vector2 >

Defined in: packages/three-flatland/src/GlobalUniforms.ts:80

Fog range uniform node (vec2 — near, far)


readonly globalTintNode: UniformNode <"color", Color >

Defined in: packages/three-flatland/src/GlobalUniforms.ts:70

Global tint uniform node (vec3/color)


readonly pixelRatioNode: UniformNode <"float", number>

Defined in: packages/three-flatland/src/GlobalUniforms.ts:74

Pixel ratio uniform node (float)


readonly timeNode: UniformNode <"float", number>

Defined in: packages/three-flatland/src/GlobalUniforms.ts:68

Time uniform node (float)


readonly viewportSizeNode: UniformNode <"vec2", Vector2 >

Defined in: packages/three-flatland/src/GlobalUniforms.ts:72

Viewport size uniform node (vec2)


readonly windNode: UniformNode <"vec2", Vector2 >

Defined in: packages/three-flatland/src/GlobalUniforms.ts:76

Wind uniform node (vec2 — direction * strength)

get effectiveTime(): number

Defined in: packages/three-flatland/src/GlobalUniforms.ts:117

Get the current effective time value (what the shader sees).

number


get fogColor(): Color 

Defined in: packages/three-flatland/src/GlobalUniforms.ts:167

Color 

set fogColor(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:171

Color 

void


get fogRange(): Vector2 

Defined in: packages/three-flatland/src/GlobalUniforms.ts:175

Vector2 

set fogRange(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:179

Vector2 

void


get globalTint(): Color 

Defined in: packages/three-flatland/src/GlobalUniforms.ts:134

Color 

set globalTint(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:138

Color 

void


get pixelRatio(): number

Defined in: packages/three-flatland/src/GlobalUniforms.ts:150

number

set pixelRatio(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:154

number

void


get time(): number | undefined

Defined in: packages/three-flatland/src/GlobalUniforms.ts:103

Get/set time.

  • undefined = auto mode (accumulates elapsed time via updateTime())
  • number = manual mode (exact value used for shader time)

Setting back to undefined resumes auto-accumulation from where it left off.

number | undefined

set time(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:107

number | undefined

void


get viewportSize(): Vector2 

Defined in: packages/three-flatland/src/GlobalUniforms.ts:142

Vector2 

set viewportSize(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:146

Vector2 

void


get wind(): Vector2 

Defined in: packages/three-flatland/src/GlobalUniforms.ts:159

Vector2 

set wind(value): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:163

Vector2 

void

updateTime(delta): void

Defined in: packages/three-flatland/src/GlobalUniforms.ts:127

Advance auto-time by delta seconds. Called by Flatland each frame. In auto mode, this accumulates and updates the time node. In manual mode, this is a no-op (the manual value is already set via the setter).

number

void