Skip to content

Use child mesh in SplatMesh to auto-inject SparkRenderer instead of monkey-patching #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrxz
Copy link
Collaborator

@mrxz mrxz commented Aug 15, 2025

The current monkey-patching of THREE.Scene to auto-inject a SparkRenderer has many limitations and can easily break. The following setups cause issues that aren't immediately clear to the user:

This PR introduces an alternative approach. Each SplatMesh adds an empty mesh to itself. During rendering it checks if the scene contains a SparkRenderer and if not injects one. Regardless of the outcome it will remove itself, ensuring the check is a one-time cost per SplatMesh.

This does mean that the following pattern is no longer allowed:

const spark = new SparkRenderer({ renderer });
// Never add it to the scene ourselves, yet expect it to take effect

Though, personally I think that's for the better. A few examples used this pattern, though it's unclear to me if this was intentional or not.

@mrxz mrxz force-pushed the auto-inject-renderer branch from 6b5a25a to 7f83f04 Compare August 15, 2025 13:26
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