未验证 提交 66dfe96f 编写于 作者: M Mr.doob 提交者: GitHub

Editor: Added equirect option to environment (#22010)

上级 2f6358dd
...@@ -150,18 +150,6 @@ function SidebarScene( editor ) { ...@@ -150,18 +150,6 @@ function SidebarScene( editor ) {
// background // background
function onBackgroundChanged() {
signals.sceneBackgroundChanged.dispatch(
backgroundType.getValue(),
backgroundColor.getHexValue(),
backgroundTexture.getValue(),
backgroundEquirectangularTexture.getValue(),
environmentType.getValue()
);
}
var backgroundRow = new UIRow(); var backgroundRow = new UIRow();
var backgroundType = new UISelect().setOptions( { var backgroundType = new UISelect().setOptions( {
...@@ -196,7 +184,16 @@ function SidebarScene( editor ) { ...@@ -196,7 +184,16 @@ function SidebarScene( editor ) {
container.add( backgroundRow ); container.add( backgroundRow );
// function onBackgroundChanged() {
signals.sceneBackgroundChanged.dispatch(
backgroundType.getValue(),
backgroundColor.getHexValue(),
backgroundTexture.getValue(),
backgroundEquirectangularTexture.getValue()
);
}
function refreshBackgroundUI() { function refreshBackgroundUI() {
...@@ -216,22 +213,45 @@ function SidebarScene( editor ) { ...@@ -216,22 +213,45 @@ function SidebarScene( editor ) {
var environmentType = new UISelect().setOptions( { var environmentType = new UISelect().setOptions( {
'None': '', 'None': '',
'Background': 'Background', 'Equirectangular': 'Equirect',
'ModelViewer': 'ModelViewer' 'ModelViewer': 'ModelViewer'
} ).setWidth( '150px' ); } ).setWidth( '150px' );
environmentType.setValue( 'None' ); environmentType.setValue( 'None' );
environmentType.onChange( function () { environmentType.onChange( function () {
signals.sceneEnvironmentChanged.dispatch( environmentType.getValue() ); onEnvironmentChanged();
refreshEnvironmentUI();
} ); } );
environmentRow.add( new UIText( strings.getKey( 'sidebar/scene/environment' ) ).setWidth( '90px' ) ); environmentRow.add( new UIText( strings.getKey( 'sidebar/scene/environment' ) ).setWidth( '90px' ) );
environmentRow.add( environmentType ); environmentRow.add( environmentType );
var environmentEquirectangularTexture = new UITexture().setMarginLeft( '8px' ).onChange( onEnvironmentChanged );
environmentEquirectangularTexture.setDisplay( 'none' );
environmentRow.add( environmentEquirectangularTexture );
container.add( environmentRow ); container.add( environmentRow );
function onEnvironmentChanged() {
signals.sceneEnvironmentChanged.dispatch(
environmentType.getValue(),
environmentEquirectangularTexture.getValue()
);
}
function refreshEnvironmentUI() {
var type = environmentType.getValue();
environmentType.setWidth( type !== 'Equirectangular' ? '150px' : '110px' );
environmentEquirectangularTexture.setDisplay( type === 'Equirectangular' ? '' : 'none' );
}
// fog // fog
function onFogChanged() { function onFogChanged() {
......
...@@ -32,7 +32,6 @@ function Viewport( editor ) { ...@@ -32,7 +32,6 @@ function Viewport( editor ) {
var renderer = null; var renderer = null;
var pmremGenerator = null; var pmremGenerator = null;
var pmremTexture = null;
var camera = editor.camera; var camera = editor.camera;
var scene = editor.scene; var scene = editor.scene;
...@@ -354,7 +353,6 @@ function Viewport( editor ) { ...@@ -354,7 +353,6 @@ function Viewport( editor ) {
renderer.setAnimationLoop( null ); renderer.setAnimationLoop( null );
renderer.dispose(); renderer.dispose();
pmremGenerator.dispose(); pmremGenerator.dispose();
pmremTexture = null;
container.dom.removeChild( renderer.domElement ); container.dom.removeChild( renderer.domElement );
...@@ -537,9 +535,7 @@ function Viewport( editor ) { ...@@ -537,9 +535,7 @@ function Viewport( editor ) {
// background // background
signals.sceneBackgroundChanged.add( function ( backgroundType, backgroundColor, backgroundTexture, backgroundEquirectangularTexture, environmentType ) { signals.sceneBackgroundChanged.add( function ( backgroundType, backgroundColor, backgroundTexture, backgroundEquirectangularTexture ) {
pmremTexture = null;
switch ( backgroundType ) { switch ( backgroundType ) {
...@@ -569,9 +565,7 @@ function Viewport( editor ) { ...@@ -569,9 +565,7 @@ function Viewport( editor ) {
if ( backgroundEquirectangularTexture ) { if ( backgroundEquirectangularTexture ) {
pmremTexture = pmremGenerator.fromEquirectangular( backgroundEquirectangularTexture ).texture; var renderTarget = new THREE.WebGLCubeRenderTarget( backgroundEquirectangularTexture.image.width );
var renderTarget = new THREE.WebGLCubeRenderTarget( 512 );
renderTarget.fromEquirectangularTexture( renderer, backgroundEquirectangularTexture ); renderTarget.fromEquirectangularTexture( renderer, backgroundEquirectangularTexture );
renderTarget.toJSON = function () { return null }; // TODO Remove hack renderTarget.toJSON = function () { return null }; // TODO Remove hack
...@@ -583,30 +577,38 @@ function Viewport( editor ) { ...@@ -583,30 +577,38 @@ function Viewport( editor ) {
} }
if ( environmentType === 'Background' ) {
scene.environment = pmremTexture;
}
render(); render();
} ); } );
// environment // environment
signals.sceneEnvironmentChanged.add( function ( environmentType ) { signals.sceneEnvironmentChanged.add( function ( environmentType, environmentEquirectangularTexture ) {
switch ( environmentType ) { switch ( environmentType ) {
case 'None': case 'None':
scene.environment = null; scene.environment = null;
break; break;
case 'Background':
scene.environment = pmremTexture; case 'Equirectangular':
scene.environment = null;
if ( environmentEquirectangularTexture ) {
scene.environment = pmremGenerator.fromEquirectangular( environmentEquirectangularTexture ).texture;
}
break; break;
case 'ModelViewer': case 'ModelViewer':
scene.environment = pmremGenerator.fromScene( new RoomEnvironment(), 0.04 ).texture; scene.environment = pmremGenerator.fromScene( new RoomEnvironment(), 0.04 ).texture;
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册