Sfoglia il codice sorgente

Merge pull request #10245 from looeee/bug/Object3D/clone/missingLayers

Added copy and clone to Layers
Mr.doob 8 anni fa
parent
commit
526ad005a6
2 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 14 0
      src/core/Layers.js
  2. 2 0
      src/core/Object3D.js

+ 14 - 0
src/core/Layers.js

@@ -40,6 +40,20 @@ Layers.prototype = {
 
 
 		return ( this.mask & layers.mask ) !== 0;
 		return ( this.mask & layers.mask ) !== 0;
 
 
+	},
+
+	clone: function ( ) {
+
+		return new Layers().copy( this );
+
+	},
+
+	copy: function ( source ) {
+
+		this.mask = source.mask;
+
+		return this;
+
 	}
 	}
 
 
 };
 };

+ 2 - 0
src/core/Object3D.js

@@ -702,6 +702,8 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 		this.matrixAutoUpdate = source.matrixAutoUpdate;
 		this.matrixAutoUpdate = source.matrixAutoUpdate;
 		this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
 		this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
 
 
+		this.layers.copy( source.layers );
+
 		this.visible = source.visible;
 		this.visible = source.visible;
 
 
 		this.castShadow = source.castShadow;
 		this.castShadow = source.castShadow;