Skip to content
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

Decouple scene from canvas #842

Open
4 tasks done
mablay opened this issue Sep 26, 2024 · 1 comment
Open
4 tasks done

Decouple scene from canvas #842

mablay opened this issue Sep 26, 2024 · 1 comment

Comments

@mablay
Copy link

mablay commented Sep 26, 2024

Description

Hey there,
Tres looks amazing. Great work!

I'd love to switch to Tres, but my application uses multiple canvas elements, each rendering a different camera perspectives to the same scene. Of what I read in the docs & source code, TresCanvas creates its own scene and doesn't share it with other TresCanvas instances. I'd love to see TresCanvas taking scene as an optional prop, but I can also imagine that there might be a lot of side effects coming with such a change.

What do you think of it? Edge case that's hard to implement or easy and viable for the ecosystem?

Have a great day!
Marc

Suggested solution

/src/components/TresCanvas.vue

const props = withDefaults(defineProps<TresCanvasProps>(), {
  ...,
  scene: new Scene() // TresScene | Scene
})

I already know, I'm missing out on component lifecycle handling. I just wanted to point in the direction this is going.

Alternative

No response

Additional context

I think this is somehow the reverse request to Portal

Validations

@andretchen0
Copy link
Contributor

andretchen0 commented Oct 17, 2024

Hi @mablay

Thanks for having a look and for providing feedback!

What do you think of it? Edge case that's hard to implement or easy and viable for the ecosystem?

As far as I've seen, this is probably something of an edge case, but I think we are working on features that could make it easier. For example, we're currently working on Portals, which require multiple contexts, each with its own scene. Once that's implemented, I think it's just one additional step to set up something like THREE's "scissors" to render multiple scenes in a canvas.

https://threejs.org/manual/#en/multiple-scenes

Fwiw, you can already render multiple scenes using the process described above, but you have to "roll your own". Tres lets you override its default render function with useLoop().render(...). In particular THREE's renderer doesn't require a scene, so you could send it a series of Tres-managed Object3Ds that stand in for your scenes.

But at the moment, Tres doesn't offer a lot of help for this use case. For example, if you use scissors to render multiple Object3Ds as scenes, you'll also have to roll your own events because the event system works with the single actual Scene.

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

No branches or pull requests

2 participants