Skip to content

Commit 0dfaecd

Browse files
authored
CSS2DRenderer: Add sortObjects. (#31946)
* Implement automatic z index opt out from css2drenderer * Implement css2dobject depth test property * invert depthtest order * fix comment * implement sortObjects instead
1 parent bf8916d commit 0dfaecd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

examples/jsm/renderers/CSS2DRenderer.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ class CSS2DRenderer {
137137
*/
138138
this.domElement = domElement;
139139

140+
/**
141+
* Controls whether the renderer assigns `z-index` values to CSS2DObject DOM elements.
142+
* If set to `true`, z-index values are assigned first based on the `renderOrder`
143+
* and secondly - the distance to the camera. If set to `false`, no z-index values are assigned.
144+
*
145+
* @type {boolean}
146+
* @default true
147+
*/
148+
this.sortObjects = true;
149+
140150
/**
141151
* Returns an object containing the width and height of the renderer.
142152
*
@@ -166,7 +176,7 @@ class CSS2DRenderer {
166176
_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );
167177

168178
renderObject( scene, scene, camera );
169-
zOrder( scene );
179+
if ( this.sortObjects ) zOrder( scene );
170180

171181
};
172182

0 commit comments

Comments
 (0)