Skip to content

Optimize globe satellite rendering with InstancedMesh matrix buffer updates#79

Merged
seanwevans merged 1 commit intomainfrom
codex/migrate-satellite-rendering-to-instancedmesh
Apr 1, 2026
Merged

Optimize globe satellite rendering with InstancedMesh matrix buffer updates#79
seanwevans merged 1 commit intomainfrom
codex/migrate-satellite-rendering-to-instancedmesh

Conversation

@seanwevans
Copy link
Copy Markdown
Owner

Motivation

  • Reduce CPU/GPU overhead when rendering large numbers of satellites by batching transforms into a single instanced draw path.
  • Support up to 100_000 objects so the globe can render high-density streams without per-instance draw calls.

Description

  • Increase instance capacity by changing MAX_OBJECTS from 10_000 to 100_000 and add MATRIX_SIZE and SATELLITE_SCALE constants.
  • Import Quaternion and Vector3 and add a matrixBufferRef that stores a direct reference to InstancedMesh.instanceMatrix.array for typed-array updates.
  • Replace per-instance setMatrixAt calls with composing a transform (position, rotation, scale) and writing each 4x4 matrix directly into the shared Float32Array via matrix.toArray(matrixBuffer, i * MATRIX_SIZE).
  • After batched writes, toggle instanced.instanceMatrix.needsUpdate = true, and clear the buffer reference during cleanup to avoid stale pointers.

Testing

  • Ran the production build with npm --prefix web run build, which completed successfully (TypeScript compile + Vite build).

Codex Task

@seanwevans seanwevans merged commit 413b6d1 into main Apr 1, 2026
2 checks passed
@seanwevans seanwevans deleted the codex/migrate-satellite-rendering-to-instancedmesh branch April 1, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant