Kaynağa Gözat

Merge pull request #19471 from Mugen87/dev45

Mesh/Line/Points: Fix copy().
Mr.doob 5 yıl önce
ebeveyn
işleme
d687097241

BIN
examples/screenshots/webgl_shadowmap_performance.jpg


+ 11 - 0
src/objects/InstancedMesh.js

@@ -30,6 +30,17 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 	isInstancedMesh: true,
 
+	copy: function ( source ) {
+
+		Mesh.prototype.copy.call( this, source );
+
+		this.instanceMatrix.copy( source.instanceMatrix );
+		this.count = source.count;
+
+		return this;
+
+	},
+
 	getMatrixAt: function ( index, matrix ) {
 
 		matrix.fromArray( this.instanceMatrix.array, index * 16 );

+ 11 - 6
src/objects/Line.js

@@ -42,6 +42,17 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	isLine: true,
 
+	copy: function ( source ) {
+
+		Object3D.prototype.copy.call( this, source );
+
+		this.material = source.material;
+		this.geometry = source.geometry;
+
+		return this;
+
+	},
+
 	computeLineDistances: function () {
 
 		const geometry = this.geometry;
@@ -279,12 +290,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-	},
-
-	clone: function () {
-
-		return new this.constructor( this.geometry, this.material ).copy( this );
-
 	}
 
 } );

+ 3 - 6
src/objects/Mesh.js

@@ -75,6 +75,9 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
+		this.material = source.material;
+		this.geometry = source.geometry;
+
 		return this;
 
 	},
@@ -332,12 +335,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-	},
-
-	clone: function () {
-
-		return new this.constructor( this.geometry, this.material ).copy( this );
-
 	}
 
 } );

+ 11 - 6
src/objects/Points.js

@@ -34,6 +34,17 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	isPoints: true,
 
+	copy: function ( source ) {
+
+		Object3D.prototype.copy.call( this, source );
+
+		this.material = source.material;
+		this.geometry = source.geometry;
+
+		return this;
+
+	},
+
 	raycast: function ( raycaster, intersects ) {
 
 		const geometry = this.geometry;
@@ -147,12 +158,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-	},
-
-	clone: function () {
-
-		return new this.constructor( this.geometry, this.material ).copy( this );
-
 	}
 
 } );

+ 14 - 6
src/objects/SkinnedMesh.js

@@ -33,6 +33,20 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 	isSkinnedMesh: true,
 
+	copy: function ( source ) {
+
+		Mesh.prototype.copy.call( this, source );
+
+		this.bindMode = source.bindMode;
+		this.bindMatrix.copy( source.bindMatrix );
+		this.bindMatrixInverse.copy( source.bindMatrixInverse );
+
+		this.skeleton = source.skeleton;
+
+		return this;
+
+	},
+
 	bind: function ( skeleton, bindMatrix ) {
 
 		this.skeleton = skeleton;
@@ -109,12 +123,6 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 	},
 
-	clone: function () {
-
-		return new this.constructor( this.geometry, this.material ).copy( this );
-
-	},
-
 	boneTransform: ( function () {
 
 		const basePosition = new Vector3();

+ 2 - 7
src/objects/Sprite.js

@@ -144,23 +144,18 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	},
 
-	clone: function () {
-
-		return new this.constructor( this.material ).copy( this );
-
-	},
-
 	copy: function ( source ) {
 
 		Object3D.prototype.copy.call( this, source );
 
 		if ( source.center !== undefined ) this.center.copy( source.center );
 
+		this.material = source.material;
+
 		return this;
 
 	}
 
-
 } );
 
 function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) {