Browse Source

Merge pull request #15057 from WestLangley/dev-arrow_helper_clone

ArrowHelper: support cloning
Mr.doob 6 years ago
parent
commit
3447ee8dec
1 changed files with 19 additions and 1 deletions
  1. 19 1
      src/helpers/ArrowHelper.js

+ 19 - 1
src/helpers/ArrowHelper.js

@@ -32,8 +32,10 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
 
 	Object3D.call( this );
 
-	if ( color === undefined ) color = 0xffff00;
+	if ( dir === undefined ) dir = new THREE.Vector3( 0, 0, 1 );
+	if ( origin === undefined ) origin = new THREE.Vector3( 0, 0, 0 );
 	if ( length === undefined ) length = 1;
+	if ( color === undefined ) color = 0xffff00;
 	if ( headLength === undefined ) headLength = 0.2 * length;
 	if ( headWidth === undefined ) headWidth = 0.2 * headLength;
 
@@ -117,5 +119,21 @@ ArrowHelper.prototype.setColor = function ( color ) {
 
 };
 
+ArrowHelper.prototype.copy = function ( source ) {
+
+	Object3D.prototype.copy.call( this, source, false );
+
+	this.line.copy( source.line );
+	this.cone.copy( source.cone );
+
+	return this;
+
+};
+
+ArrowHelper.prototype.clone = function () {
+
+	return new this.constructor().copy( this );
+
+};
 
 export { ArrowHelper };