Browse Source

OutlinePass: Honor visibility state

Mugen87 7 years ago
parent
commit
2caaa3d700
1 changed files with 17 additions and 3 deletions
  1. 17 3
      examples/js/postprocessing/OutlinePass.js

+ 17 - 3
examples/js/postprocessing/OutlinePass.js

@@ -163,7 +163,21 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 
 		function gatherSelectedMeshesCallBack( object ) {
 
-			if ( object instanceof THREE.Mesh ) object.visible = bVisible;
+			if ( object.isMesh ) {
+
+				if ( bVisible ) {
+
+					object.visible = object.userData.oldVisible;
+					delete object.userData.oldVisible;
+
+				} else {
+
+					object.userData.oldVisible = object.visible;
+					object.visible = bVisible;
+
+				}
+
+			}
 
 		}
 
@@ -182,7 +196,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 
 		function gatherSelectedMeshesCallBack( object ) {
 
-			if ( object instanceof THREE.Mesh ) selectedMeshes.push( object );
+			if ( object.isMesh ) selectedMeshes.push( object );
 
 		}
 
@@ -195,7 +209,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype
 
 		function VisibilityChangeCallBack( object ) {
 
-			if ( object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Sprite ) {
+			if ( object.isMesh || object.isLine || object.isSprite ) {
 
 				var bFound = false;