Explorar o código

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

Added copy and clone to Layers
Mr.doob %!s(int64=8) %!d(string=hai) anos
pai
achega
526ad005a6
Modificáronse 2 ficheiros con 16 adicións e 0 borrados
  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;
 
+	},
+
+	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.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
 
+		this.layers.copy( source.layers );
+
 		this.visible = source.visible;
 
 		this.castShadow = source.castShadow;