Просмотр исходного кода

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
Konsey 3 месяцев назад
Родитель
Сommit
0dfaecd6f7
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      examples/jsm/renderers/CSS2DRenderer.js

+ 11 - 1
examples/jsm/renderers/CSS2DRenderer.js

@@ -137,6 +137,16 @@ class CSS2DRenderer {
 		 */
 		this.domElement = domElement;
 
+		/**
+		 * Controls whether the renderer assigns `z-index` values to CSS2DObject DOM elements.
+		 * If set to `true`, z-index values are assigned first based on the `renderOrder`
+		 * and secondly - the distance to the camera. If set to `false`, no z-index values are assigned.
+		 *
+		 * @type {boolean}
+		 * @default true
+		 */
+		this.sortObjects = true;
+
 		/**
 		 * Returns an object containing the width and height of the renderer.
 		 *
@@ -166,7 +176,7 @@ class CSS2DRenderer {
 			_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );
 
 			renderObject( scene, scene, camera );
-			zOrder( scene );
+			if ( this.sortObjects ) zOrder( scene );
 
 		};
 

粤ICP备19079148号