@@ -80,26 +80,28 @@ public class LightsDebugState extends BaseAppState {
8080 private static final String POINT_LIGHT_RADIUS_NAME = "PointLightRadius" ;
8181 private static final String ARROW_NAME = "Arrow" ;
8282
83- // The scene whose lights will be debugged
84- private Spatial scene ;
85- private ViewPort viewPort ;
86- private Node debugNode ;
8783 private final Map <Light , Spatial > lightGizmoMap = new WeakHashMap <>();
8884 private final ArrayDeque <Light > lightDeque = new ArrayDeque <>();
8985 private Predicate <Light > lightFilter = x -> true ; // Identity Function
9086
91- private AssetManager assetManager ;
92- private Material debugMaterial ;
87+ protected ViewPort viewPort ;
88+ protected AssetManager assetManager ;
89+ protected Material debugMaterial ;
90+ protected Node debugNode ;
91+ protected Spatial scene ; // The scene whose lights will be debugged
9392
93+ private boolean showOnTop = true ;
9494 private float lightProbeScale = 1.0f ;
9595 private final ColorRGBA debugColor = ColorRGBA .DarkGray ;
9696 private final Quaternion tempRotation = new Quaternion ();
9797
9898 @ Override
9999 protected void initialize (Application app ) {
100100
101- this .viewPort = app .getRenderManager ().createMainView ("LightsDebugView" , app .getCamera ());
102- this .assetManager = app .getAssetManager ();
101+ viewPort = app .getRenderManager ().createMainView ("LightsDebugView" , app .getCamera ());
102+ viewPort .setClearFlags (false , showOnTop , true );
103+
104+ assetManager = app .getAssetManager ();
103105 debugNode = new Node ("LightsDebugNode" );
104106
105107 debugMaterial = new Material (assetManager , "Common/MatDefs/Misc/Unshaded.j3md" );
@@ -398,6 +400,29 @@ public void setLightProbeScale(float scale) {
398400 this .lightProbeScale = scale ;
399401 }
400402
403+ /**
404+ * Checks if the light debug gizmos are set to always
405+ * render on top of other scene geometry.
406+ *
407+ * @return true if gizmos always render on top, false otherwise.
408+ */
409+ public boolean isShowOnTop () {
410+ return showOnTop ;
411+ }
412+
413+ /**
414+ * Sets whether light debug gizmos should always
415+ * render on top of other scene geometry.
416+ *
417+ * @param showOnTop true to always show gizmos on top, false to respect depth.
418+ */
419+ public void setShowOnTop (boolean showOnTop ) {
420+ this .showOnTop = showOnTop ;
421+ if (viewPort != null ) {
422+ viewPort .setClearDepth (showOnTop );
423+ }
424+ }
425+
401426 /**
402427 * Sets a filter to control which lights are displayed by the debug state.
403428 * By default, no filter is applied, meaning all lights are displayed.
0 commit comments