Skip to content

Conversation

Konseyy
Copy link

@Konseyy Konseyy commented Sep 25, 2025

Fixed #31945.

Description

Implemented a way of opting out from CSS2DRenderer automatic z-index assignment

@Konseyy
Copy link
Author

Konseyy commented Sep 25, 2025

Revised to have depthTest property on CSS2DObject. This allows all objects to still be assigned z-index values, but allows certain objects to opt out of distance-to-camera calculations.
Objects with depthTest = false will get assigned z-index values based on their renderOrder, but multiple objects with the same renderOrder and depthTest = false will have the same z-index.

Current approach puts objects with depthTest = false in front of objects with depthTest = true to mimic normal rendering

@Konseyy Konseyy requested a review from Mugen87 September 25, 2025 12:36
@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 25, 2025

I think these changes make the renderer unnecessarily complex. If you need such a fine-granular control, I suggest your fork the renderer and use a custom version. IMO, the only change that would be consistent is introducing renderer.sortObjects.

@Konseyy
Copy link
Author

Konseyy commented Sep 25, 2025

Understandable, changed the implementation to just sortObjects

@Mugen87 Mugen87 changed the title Implement automatic z index opt out from css2drenderer CSS2DRenderer: Add sortObjects. Sep 25, 2025
@Mugen87 Mugen87 added this to the r181 milestone Sep 25, 2025
@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 25, 2025

@yomotsu Are you okay with this change?

The idea is to add sortObjects to CSS2DRenderer, a flag that is known from WebGLRenderer. In context of CSS2DRenderer, setting it to false gives the developer full control over z-index.

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.

CSS2DRenderer auto z-index opt out
2 participants