Can we render threejs component and babylonjs component in the same screen?

Can we render threejs component and babylonjs component in the same scene or on same canvas ??If possible can you provide some demo playground??

Yes it is feasible as we can instantiate the engine on an existing gl context

The only thing to know is that you need to call engine.wipeCaches(true) before rendering with Babylon

2 Likes

What DK said. You need to first decide which you are rendering in foreground/background as well.
Use wipeCaches(true) before rendering with something else (if you are putting Babylon behind) and use scene.autoClear = false; if you are putting Babylon on top.

I have some PIXI examples using onEndRenderObservable, but they are a bit hard to read if you don’t know React hooks:


Looks like this - the fonts are done in PIXI v5:
https://brianzinn.github.io/react-babylonjs/?path=/story/integrations--pixi-story

For three, I think you just need to call render on your THREE.WebGLRenderer and you will need alpha true for foreground rendering. Maybe you can make a codepen or something to try it out?

2 Likes

ok,Thank you!

1 Like