Skip to content

Stream textures: an app replaces a texture's pixels while the scene runs - #148

Merged
doodlewind merged 2 commits into
mainfrom
stream-texture
Nov 17, 2026
Merged

doodlewind merged 2 commits into
mainfrom
stream-texture

Conversation

@doodlewind

Copy link
Copy Markdown
Collaborator

A texture whose pixels the embedding app replaces every frame without rebuilding the scene: a screen in the scene that shows what a program draws, a camera, a video. Made for an embedded room whose device screen shows a simulator's frames.

  • SDK: StreamTexture(name, width, height, rgba?) in @threert/scene (a clamped DataTexture, opaque black until the first picture); TextureDesc.stream carries its name.
  • Engine: TextureSource::Stream. Its key in the texture pages is its name and size (texpack::stream_key), so set_key does not change with a picture. pack records each stream's Place; texpack::patch builds its padded rect at every mip level exactly as pack fills it; Gpu::write_stream writes it with queue.write_texture. The last picture is kept and re-applied when the pages are packed again.
  • Embedding API: LiveCore::write_stream(name, w, h, rgba) before a frame's render. No script-side call: pictures come from the app.
  • Docs: docs/RUNTIME.md "Stream textures".

Tests: texpack::tests::a_patch_is_the_pages_texels (a patch equals the pages packed with the new pixels, every level, every texel); npm run typecheck, npm test, cargo build --release, wasm32 --lib check pass locally. Used in a macOS app for two days (640 x 360 at frame rate on an M3 Max).

Known: content that changes every frame should be emitted from a material function (short history); through a plain emissiveMap the live view blends a few frames.

🤖 Generated with Claude Code

@doodlewind
doodlewind merged commit 138978a into main Nov 17, 2026
8 checks passed
@doodlewind
doodlewind deleted the stream-texture branch November 17, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant