Browse Source

adding default parameters for THREE.ArrowHelper

zz85 13 years ago
parent
commit
c959a0cee9
1 changed files with 20 additions and 2 deletions
  1. 20 2
      src/extras/helpers/ArrowHelper.js

+ 20 - 2
src/extras/helpers/ArrowHelper.js

@@ -1,12 +1,28 @@
 /**
 /**
  * @author WestLangley / https://github.com/WestLangley
  * @author WestLangley / https://github.com/WestLangley
  * @author zz85 / https://github.com/zz85
  * @author zz85 / https://github.com/zz85
+ *
+ * Creates an arrow for visualizing directions
+ *
+ * Parameters:
+ *  dir - Vector3
+ *  origin - Vector3
+ *  length - Number
+ *  hex - color in hex value
  */
  */
  
  
-THREE.ArrowHelper = function ( origin, dir, length, hex ) {
+THREE.ArrowHelper = function ( dir, origin, length, hex ) {
 
 
     THREE.Object3D.call( this );
     THREE.Object3D.call( this );
 
 
+    if (hex ===undefined) {
+        hex = 0xffff00;
+    }
+
+    if (length === undefined) {
+        length = 20;
+    }
+
     var lineGeometry = new THREE.Geometry();
     var lineGeometry = new THREE.Geometry();
     lineGeometry.vertices.push( new THREE.Vertex() );
     lineGeometry.vertices.push( new THREE.Vertex() );
     lineGeometry.vertices.push( new THREE.Vertex( new THREE.Vector3( 0, 1, 0 ) ) );
     lineGeometry.vertices.push( new THREE.Vertex( new THREE.Vector3( 0, 1, 0 ) ) );
@@ -20,7 +36,9 @@ THREE.ArrowHelper = function ( origin, dir, length, hex ) {
     this.cone.position.set( 0, 1, 0 );
     this.cone.position.set( 0, 1, 0 );
     this.add( this.cone );
     this.add( this.cone );
     
     
-    this.position = origin;
+    if (origin instanceof THREE.Vector3) {
+        this.position = origin;
+    }
     
     
     this.setDirection( dir );
     this.setDirection( dir );