|
@@ -31,6 +31,7 @@ var Viewport = function ( editor ) {
|
|
|
//
|
|
|
|
|
|
var renderer = null;
|
|
|
+ var pmremGenerator = null;
|
|
|
|
|
|
var camera = editor.camera;
|
|
|
var scene = editor.scene;
|
|
@@ -324,7 +325,7 @@ var Viewport = function ( editor ) {
|
|
|
|
|
|
} );
|
|
|
|
|
|
- signals.rendererChanged.add( function ( newRenderer ) {
|
|
|
+ signals.rendererChanged.add( function ( newRenderer, newPmremGenerator ) {
|
|
|
|
|
|
if ( renderer !== null ) {
|
|
|
|
|
@@ -333,6 +334,7 @@ var Viewport = function ( editor ) {
|
|
|
}
|
|
|
|
|
|
renderer = newRenderer;
|
|
|
+ pmremGenerator = newPmremGenerator;
|
|
|
|
|
|
renderer.autoClear = false;
|
|
|
renderer.autoUpdateScene = false;
|
|
@@ -473,7 +475,7 @@ var Viewport = function ( editor ) {
|
|
|
|
|
|
var currentBackgroundType = null;
|
|
|
|
|
|
- signals.sceneBackgroundChanged.add( function ( backgroundType, backgroundColor, backgroundTexture, backgroundCubeTexture ) {
|
|
|
+ signals.sceneBackgroundChanged.add( function ( backgroundType, backgroundColor, backgroundTexture, backgroundCubeTexture, backgroundEquirectTexture ) {
|
|
|
|
|
|
if ( currentBackgroundType !== backgroundType ) {
|
|
|
|
|
@@ -493,14 +495,46 @@ var Viewport = function ( editor ) {
|
|
|
if ( backgroundType === 'Color' ) {
|
|
|
|
|
|
scene.background.set( backgroundColor );
|
|
|
+ scene.environment = null;
|
|
|
|
|
|
} else if ( backgroundType === 'Texture' ) {
|
|
|
|
|
|
scene.background = backgroundTexture;
|
|
|
+ scene.environment = null;
|
|
|
|
|
|
} else if ( backgroundType === 'CubeTexture' ) {
|
|
|
|
|
|
- scene.background = backgroundCubeTexture;
|
|
|
+ if ( backgroundCubeTexture && backgroundCubeTexture.isHDRTexture ) {
|
|
|
+
|
|
|
+ var texture = pmremGenerator.fromCubemap( backgroundCubeTexture ).texture;
|
|
|
+ texture.isPmremTexture = true;
|
|
|
+
|
|
|
+ scene.background = texture;
|
|
|
+ scene.environment = texture;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ scene.background = backgroundCubeTexture;
|
|
|
+ scene.environment = null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ( backgroundType === 'Equirect' ) {
|
|
|
+
|
|
|
+ if ( backgroundEquirectTexture && backgroundEquirectTexture.isHDRTexture ) {
|
|
|
+
|
|
|
+ var texture = pmremGenerator.fromEquirectangular( backgroundEquirectTexture ).texture;
|
|
|
+ texture.isPmremTexture = true;
|
|
|
+
|
|
|
+ scene.background = texture;
|
|
|
+ scene.environment = texture;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ scene.background = null;
|
|
|
+ scene.environment = null;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|