Quellcode durchsuchen

resolve issue #1447 (no setter for EnvironmentCamera background color) (#1481)

Stephen Gold vor 4 Jahren
Ursprung
Commit
4fdee8f79a
1 geänderte Dateien mit 20 neuen und 2 gelöschten Zeilen
  1. 20 2
      jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java

+ 20 - 2
jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2019 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -196,6 +196,24 @@ public class EnvironmentCamera extends BaseAppState {
         jobs.remove(0);
     }
 
+    /**
+     * Alter the background color of an initialized EnvironmentCamera.
+     *
+     * @param bgColor the desired color (not null, unaffected, default is the
+     * background color of the application's default viewport)
+     */
+    public void setBackGroundColor(ColorRGBA bgColor) {
+        if (!isInitialized()) {
+            throw new IllegalStateException(
+                    "The EnvironmentCamera is uninitialized.");
+        }
+
+        backGroundColor.set(bgColor);
+        for (int i = 0; i < 6; ++i) {
+            viewports[i].setBackgroundColor(bgColor);
+        }
+    }
+
     /**
      * Gets the size of environment cameras.
      *
@@ -260,7 +278,7 @@ public class EnvironmentCamera extends BaseAppState {
 
     @Override
     protected void initialize(Application app) {
-        this.backGroundColor = app.getViewPort().getBackgroundColor();
+        this.backGroundColor = app.getViewPort().getBackgroundColor().clone();
 
         final Camera[] cameras = new Camera[6];
         final Texture2D[] textures = new Texture2D[6];