Browse Source

Merge pull request #13139 from WestLangley/dev-sprite

Added Sprite.copy() method
Mr.doob 7 years ago
parent
commit
d1067db7c5
2 changed files with 16 additions and 0 deletions
  1. 5 0
      docs/api/objects/Sprite.html
  2. 11 0
      src/objects/Sprite.js

+ 5 - 0
docs/api/objects/Sprite.html

@@ -71,6 +71,11 @@ scene.add( sprite );
 		Returns a clone of this Sprite object and any descendants.
 		</div>
 
+		<h3>[method:Sprite copy]( [page:Sprite sprite] )</h3>
+		<div>
+		Copies the properties of the passed sprite to this one.
+		</div>
+
 		<h3>[method:Array raycast]( [page:Raycaster raycaster], [page:Array intersects] )</h3>
 		<div>
 		Get intersections between a casted ray and this sprite.

+ 11 - 0
src/objects/Sprite.js

@@ -63,8 +63,19 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		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 );
+
+		return this;
+
 	}
 
+
 } );