1313import com .jme3 .environment .LightProbeFactory ;
1414import com .jme3 .environment .generation .JobProgressAdapter ;
1515import com .jme3 .font .BitmapFont ;
16+ import com .jme3 .light .LightList ;
1617import com .jme3 .light .LightProbe ;
1718import com .jme3 .material .Material ;
1819import com .jme3 .material .TechniqueDef ;
@@ -258,7 +259,7 @@ public Camera getCamera() {
258259 @ Override
259260 public void simpleInitApp () {
260261 renderManager .setPreferredLightMode (TechniqueDef .LightMode .SinglePass );
261- renderManager .setSinglePassLightBatchSize (5 );
262+ renderManager .setSinglePassLightBatchSize (15 );
262263
263264 assetManager .registerLoader (XbufLoader .class , FileExtensions .MODEL_XBUF );
264265
@@ -325,7 +326,7 @@ public void simpleInitApp() {
325326 stateManager .attach (previewEnvironmentCamera );
326327 }
327328
328- createProbe ();
329+ createLightProbes ();
329330
330331 new EditorThread (new ThreadGroup ("JavaFX" ), JFXApplication ::start , "JavaFX Launch" ).start ();
331332 }
@@ -430,9 +431,9 @@ public FilterPostProcessor getPostProcessor() {
430431 }
431432
432433 /**
433- * Create the light probe for the PBR render.
434+ * Create the light probes for the PBR render.
434435 */
435- private void createProbe () {
436+ private void createLightProbes () {
436437
437438 final EnvironmentCamera environmentCamera = getEnvironmentCamera ();
438439 final EnvironmentCamera previewEnvironmentCamera = getPreviewEnvironmentCamera ();
@@ -443,7 +444,7 @@ private void createProbe() {
443444
444445 if (environmentCamera .getApplication () == null ) {
445446 final JMEThreadExecutor gameThreadExecutor = JMEThreadExecutor .getInstance ();
446- gameThreadExecutor .addToExecute (this ::createProbe );
447+ gameThreadExecutor .addToExecute (this ::createLightProbes );
447448 return ;
448449 }
449450
@@ -465,7 +466,7 @@ private void createProbe() {
465466 *
466467 * @param progressAdapter the progress adapter
467468 */
468- public void updateProbe (@ NotNull final JobProgressAdapter <LightProbe > progressAdapter ) {
469+ public void updateLightProbe (@ NotNull final JobProgressAdapter <LightProbe > progressAdapter ) {
469470
470471 final LightProbe lightProbe = getLightProbe ();
471472 final EnvironmentCamera environmentCamera = getEnvironmentCamera ();
@@ -478,12 +479,46 @@ public void updateProbe(@NotNull final JobProgressAdapter<LightProbe> progressAd
478479 LightProbeFactory .updateProbe (lightProbe , environmentCamera , rootNode , progressAdapter );
479480 }
480481
482+ /**
483+ * Disable PBR Light probe.
484+ */
485+ public void disableLightProbe () {
486+
487+ final LightProbe lightProbe = getLightProbe ();
488+
489+ if (lightProbe != null ) {
490+ rootNode .removeLight (lightProbe );
491+ }
492+ }
493+
494+ /**
495+ * Enable PBR Light probe.
496+ */
497+ public void enableLightProbe () {
498+
499+ final LightProbe lightProbe = getLightProbe ();
500+
501+ if (lightProbe == null ) {
502+ return ;
503+ }
504+
505+ final LightList lightList = rootNode .getLocalLightList ();
506+
507+ for (int i = 0 ; i < lightList .size (); i ++) {
508+ if (lightList .get (i ) == lightProbe ) {
509+ return ;
510+ }
511+ }
512+
513+ rootNode .addLight (lightProbe );
514+ }
515+
481516 /**
482517 * Update the light probe.
483518 *
484519 * @param progressAdapter the progress adapter
485520 */
486- public void updatePreviewProbe (@ NotNull final JobProgressAdapter <LightProbe > progressAdapter ) {
521+ public void updatePreviewLightProbe (@ NotNull final JobProgressAdapter <LightProbe > progressAdapter ) {
487522
488523 final LightProbe lightProbe = getPreviewLightProbe ();
489524 final EnvironmentCamera environmentCamera = getPreviewEnvironmentCamera ();
0 commit comments