xeokit-sdk icon indicating copy to clipboard operation
xeokit-sdk copied to clipboard

Be able to create a "Mask" with objects

Open tgranie opened this issue 8 months ago • 5 comments

Hello,

Is there a way to hide objects (= not visible by the user) but still creating a "mask" regarding the other objects of the scene. Objects could be glb or xkt.

Thanks for your help

tgranie avatar Apr 03 '25 16:04 tgranie

Hi @tgranie, What specifically do you mean by a "mask"? If a front object is to be hidden, how would a "masked" object behind it look like?

MichalDybizbanskiCreoox avatar Apr 04 '25 15:04 MichalDybizbanskiCreoox

Hi @MichalDybizbanskiCreoox

Ok you're right it was not clear enough. Let me explain with this simple schema :

Image

  • The red square is an object the user see
  • The gray square is an object the user does not see but in front of the red square
  • The gray square "mask" the red square because it exists even if not visible

So I was wondering if there is a way to simulate this in xeokit, objects could be xkt or glb.

Thanks for your help,

Thibault

tgranie avatar Apr 07 '25 09:04 tgranie

This sounds like the "depth-pre-pass" technique, where the renderer avoids drawing anything that's obscured by something else.

It would involve refactoring the renderer to

  1. draw pixel depths to a depth buffer, then
  2. draw pixel colors only when the pixel has a depth that is not greater than the value already written for that pixel in the depth buffer

It's a technique that can speed up drawing for high-detail scenes, so possibly worth having.

xeolabs avatar Apr 07 '25 11:04 xeolabs

Hi @tgranie , By "gray square "mask" the red square" should we understand that parts of the red square that overlap with the gray square are not being rendered? In the 3D context that would mean that an invisible "masking" object effectively creates a "hole" through the scene, so the only thing that's "visible" in its place is the canvas background. If that would indeed be what "masking" was supposed to work like, then the xeokit SDK doesn't currently support if out of the box, but we could consider adding this as a new feature (with possible edge case limitations related to picking). Best, Michał

MichalDybizbanskiCreoox avatar Apr 07 '25 11:04 MichalDybizbanskiCreoox

@MichalDybizbanskiCreoox To answer your question, Yes

tgranie avatar Apr 07 '25 11:04 tgranie