Forráskód Böngészése

Editor: Add serialization support for modelviewer environment. (#26718)

Michael Herzog 1 éve
szülő
commit
08a6153b58
2 módosított fájl, 26 hozzáadás és 3 törlés
  1. 20 3
      editor/js/Editor.js
  2. 6 0
      editor/js/Sidebar.Scene.js

+ 20 - 3
editor/js/Editor.js

@@ -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 );
 
@@ -540,7 +540,7 @@ Editor.prototype = {
 
 	},
 
-	setViewportShading: function( value ) {
+	setViewportShading: function ( value ) {
 
 		this.viewportShading = value;
 		this.signals.viewportShadingChanged.dispatch();
@@ -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 () {
@@ -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 {
@@ -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
 
 		};
 

+ 6 - 0
editor/js/Sidebar.Scene.js

@@ -424,6 +424,10 @@ function SidebarScene( editor ) {
 				environmentType.setValue( 'Equirectangular' );
 				environmentEquirectangularTexture.setValue( scene.environment );
 
+			} else if ( scene.environment.isRenderTargetTexture === true ) {
+
+				environmentType.setValue( 'ModelViewer' );
+
 			}
 
 		} else {
@@ -480,6 +484,8 @@ function SidebarScene( editor ) {
 
 	signals.sceneGraphChanged.add( refreshUI );
 
+	signals.sceneEnvironmentChanged.add( refreshUI );
+
 	/*
 	signals.objectChanged.add( function ( object ) {