diff --git a/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java b/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java index 92163d398c..4966c001c9 100644 --- a/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java +++ b/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 void render(final RenderManager renderManager) { 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 ViewPort[] getViewPorts(){ @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];