Skip to content

Add injectable LOD runtime interfaces#297

Open
promontis wants to merge 3 commits into
sparkjsdev:v2.0.0-previewfrom
promontis:feature/plugin-interfaces-clean
Open

Add injectable LOD runtime interfaces#297
promontis wants to merge 3 commits into
sparkjsdev:v2.0.0-previewfrom
promontis:feature/plugin-interfaces-clean

Conversation

@promontis
Copy link
Copy Markdown

@promontis promontis commented Apr 9, 2026

Add injectable runtime seams for Spark's LOD and sorting pipeline via SparkRendererOptions, while preserving current behavior by default.

This PR exposes three extension points:

  • ILodTraverser for LOD tree traversal
  • ISortProvider for depth sorting
  • ILodScheduler for deciding how overlapping LOD update requests are handled

Default behavior remains unchanged:

  • WorkerLodTraverser remains the default traversal implementation
  • WorkerSortProvider remains the default sort implementation
  • DropIfBusyLodScheduler preserves Spark's current "drop overlapping LOD updates while busy" behavior

Why ILodScheduler is separate:

  • traversal and sorting describe how work is performed
  • scheduling describes when overlapping LOD work should run, be skipped, or be coalesced
  • keeping scheduling as a separate seam avoids baking policy into SparkRenderer while keeping the default path intact

This keeps the public change narrowly scoped and non-breaking while enabling external integrations to inject custom policies, such as:

  • latest-camera-wins LOD scheduling
  • custom GPU/WebGPU traversal or sorting paths
  • domain-specific residency or prioritization logic outside Spark core

The interfaces and default implementations are exported from the package root so consumers do not need internal module-path imports.

Validation:

  • existing lint/test hooks pass
  • added a focused test covering DropIfBusyLodScheduler default behavior

…ction

Allow external LOD traverser and sort provider implementations to be
injected via SparkRendererOptions. This enables replacing the built-in
WASM worker-based traversal and sorting with custom implementations
(e.g. WebGPU compute shaders) without modifying SparkJS itself.

Without injection, behavior is completely unchanged.
@promontis promontis changed the title Add ILodTraverser/ISortProvider interfaces Add injectable LOD runtime interfaces Apr 9, 2026
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