diff --git a/src/extras/helpers/ArrowHelper.js b/src/extras/helpers/ArrowHelper.js index 8e777e07b10c6791ea8422eed0b820bca55b23ce..7d7ea7085e223bc15b0f7f9d54a9cb0e5e096e1b 100644 --- a/src/extras/helpers/ArrowHelper.js +++ b/src/extras/helpers/ArrowHelper.js @@ -8,8 +8,6 @@ import { Mesh } from '../../objects/Mesh'; import { LineBasicMaterial } from '../../materials/LineBasicMaterial'; import { Line } from '../../objects/Line'; -var ArrowHelper; - /** * @author WestLangley / http://github.com/WestLangley * @author zz85 / http://github.com/zz85 @@ -26,41 +24,37 @@ var ArrowHelper; * headWidth - Number */ -ArrowHelper = ( function () { - - var lineGeometry = new BufferGeometry(); - lineGeometry.addAttribute( 'position', new Float32Attribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) ); +var lineGeometry = new BufferGeometry(); +lineGeometry.addAttribute( 'position', new Float32Attribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) ); - var coneGeometry = new CylinderBufferGeometry( 0, 0.5, 1, 5, 1 ); - coneGeometry.translate( 0, - 0.5, 0 ); +var coneGeometry = new CylinderBufferGeometry( 0, 0.5, 1, 5, 1 ); +coneGeometry.translate( 0, - 0.5, 0 ); - return function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { - - // dir is assumed to be normalized +function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { - Object3D.call( this ); + // dir is assumed to be normalized - if ( color === undefined ) color = 0xffff00; - if ( length === undefined ) length = 1; - if ( headLength === undefined ) headLength = 0.2 * length; - if ( headWidth === undefined ) headWidth = 0.2 * headLength; + Object3D.call( this ); - this.position.copy( origin ); + if ( color === undefined ) color = 0xffff00; + if ( length === undefined ) length = 1; + if ( headLength === undefined ) headLength = 0.2 * length; + if ( headWidth === undefined ) headWidth = 0.2 * headLength; - this.line = new Line( lineGeometry, new LineBasicMaterial( { color: color } ) ); - this.line.matrixAutoUpdate = false; - this.add( this.line ); + this.position.copy( origin ); - this.cone = new Mesh( coneGeometry, new MeshBasicMaterial( { color: color } ) ); - this.cone.matrixAutoUpdate = false; - this.add( this.cone ); + this.line = new Line( lineGeometry, new LineBasicMaterial( { color: color } ) ); + this.line.matrixAutoUpdate = false; + this.add( this.line ); - this.setDirection( dir ); - this.setLength( length, headLength, headWidth ); + this.cone = new Mesh( coneGeometry, new MeshBasicMaterial( { color: color } ) ); + this.cone.matrixAutoUpdate = false; + this.add( this.cone ); - }; + this.setDirection( dir ); + this.setLength( length, headLength, headWidth ); -}() ); +} ArrowHelper.prototype = Object.create( Object3D.prototype ); ArrowHelper.prototype.constructor = ArrowHelper; @@ -118,4 +112,4 @@ ArrowHelper.prototype.setColor = function ( color ) { }; -export { ArrowHelper }; \ No newline at end of file +export { ArrowHelper };