Skip to content

Commit

Permalink
Editor: Add serialization support for modelviewer environment. (mrdoo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 authored Sep 8, 2023
1 parent 0dbaea7 commit 08a6153
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
23 changes: 20 additions & 3 deletions editor/js/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Editor.prototype = {

helper = new THREE.SkeletonHelper( object.skeleton.bones[ 0 ] );

} else if ( object.isBone === true && object.parent?.isBone !== true ) {
} else if ( object.isBone === true && object.parent && object.parent.isBone !== true ) {

helper = new THREE.SkeletonHelper( object );

Expand Down Expand Up @@ -540,7 +540,7 @@ Editor.prototype = {

},

setViewportShading: function( value ) {
setViewportShading: function ( value ) {

this.viewportShading = value;
this.signals.viewportShadingChanged.dispatch();
Expand Down Expand Up @@ -659,6 +659,12 @@ Editor.prototype = {

this.setScene( await loader.parseAsync( json.scene ) );

if ( json.environment === 'ModelViewer' ) {

this.signals.sceneEnvironmentChanged.dispatch( json.environment );

}

},

toJSON: function () {
Expand All @@ -680,6 +686,16 @@ Editor.prototype = {

}

// honor modelviewer environment

let environment = null;

if ( this.scene.environment !== null && this.scene.environment.isRenderTargetTexture === true ) {

environment = 'ModelViewer';

}

//

return {
Expand All @@ -695,7 +711,8 @@ Editor.prototype = {
camera: this.viewportCamera.toJSON(),
scene: this.scene.toJSON(),
scripts: this.scripts,
history: this.history.toJSON()
history: this.history.toJSON(),
environment: environment

};

Expand Down
6 changes: 6 additions & 0 deletions editor/js/Sidebar.Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ function SidebarScene( editor ) {
environmentType.setValue( 'Equirectangular' );
environmentEquirectangularTexture.setValue( scene.environment );

} else if ( scene.environment.isRenderTargetTexture === true ) {

environmentType.setValue( 'ModelViewer' );

}

} else {
Expand Down Expand Up @@ -480,6 +484,8 @@ function SidebarScene( editor ) {

signals.sceneGraphChanged.add( refreshUI );

signals.sceneEnvironmentChanged.add( refreshUI );

/*
signals.objectChanged.add( function ( object ) {
Expand Down

0 comments on commit 08a6153

Please sign in to comment.