1

I am developing an AR application using Babylon.js. I need to hide a virtual object behind a real object using a transparent mesh, like is described on this question regarding Three.js: three.js transparent object occlusion

Is it possible to do something like this with Babylon.js, I haven't been able to figure it out?

gman
  • 100,619
  • 31
  • 269
  • 393
Julio Garcia
  • 1,904
  • 16
  • 26

1 Answers1

1

Sure, you can use a mesh to occlude parts of another mesh, you only have to turn off and turn on the mesh (occluder) before and after rendering.

occluderMesh.onBeforeRenderObservable.add(() => engine.setColorWrite(false));
occluderMesh.onAfterRenderObservable.add(() => engine.setColorWrite(true));

Check this example: https://playground.babylonjs.com/#AAM6LK

jalamprea
  • 136
  • 8