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.

Example

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

Constructors

Constructor

new GlobalUniforms(): GlobalUniforms

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

Returns

GlobalUniforms

Properties

fogColorNode

readonly fogColorNode: UniformNode<"color", Color>

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

Fog color uniform node (vec3/color)


fogRangeNode

readonly fogRangeNode: UniformNode<"vec2", Vector2>

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

Fog range uniform node (vec2 — near, far)


globalTintNode

readonly globalTintNode: UniformNode<"color", Color>

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

Global tint uniform node (vec3/color)


pixelRatioNode

readonly pixelRatioNode: UniformNode<"float", number>

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

Pixel ratio uniform node (float)


timeNode

readonly timeNode: UniformNode<"float", number>

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

Time uniform node (float)


viewportSizeNode

readonly viewportSizeNode: UniformNode<"vec2", Vector2>

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

Viewport size uniform node (vec2)


windNode

readonly windNode: UniformNode<"vec2", Vector2>

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

Wind uniform node (vec2 — direction * strength)

Accessors

effectiveTime

Get Signature

get effectiveTime(): number

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

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

Returns

number


fogColor

Get Signature

get fogColor(): Color

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

Returns

Color

Set Signature

set fogColor(value): void

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

Parameters
value

Color

Returns

void


fogRange

Get Signature

get fogRange(): Vector2

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

Returns

Vector2

Set Signature

set fogRange(value): void

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

Parameters
value

Vector2

Returns

void


globalTint

Get Signature

get globalTint(): Color

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

Returns

Color

Set Signature

set globalTint(value): void

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

Parameters
value

Color

Returns

void


pixelRatio

Get Signature

get pixelRatio(): number

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

Returns

number

Set Signature

set pixelRatio(value): void

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

Parameters
value

number

Returns

void


time

Get Signature

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.

Returns

number | undefined

Set Signature

set time(value): void

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

Parameters
value

number | undefined

Returns

void


viewportSize

Get Signature

get viewportSize(): Vector2

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

Returns

Vector2

Set Signature

set viewportSize(value): void

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

Parameters
value

Vector2

Returns

void


wind

Get Signature

get wind(): Vector2

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

Returns

Vector2

Set Signature

set wind(value): void

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

Parameters
value

Vector2

Returns

void

Methods

updateTime()

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

Parameters

delta

number

Returns

void