Permalink
Please sign in to comment.
Showing
with
0 additions
and 139 deletions.
- +0 −106 vendor/ArrowHelper.js
- +0 −33 vendor/AxisHelper.js
@@ -1,106 +0,0 @@ | ||
-/** | ||
- * @author WestLangley / http://github.com/WestLangley | ||
- * @author zz85 / http://github.com/zz85 | ||
- * @author bhouston / http://clara.io | ||
- * | ||
- * Creates an arrow for visualizing directions | ||
- * | ||
- * Parameters: | ||
- * dir - Vector3 | ||
- * origin - Vector3 | ||
- * length - Number | ||
- * color - color in hex value | ||
- * headLength - Number | ||
- * headWidth - Number | ||
- */ | ||
- | ||
-THREE.ArrowHelper = ( function () { | ||
- | ||
- var lineGeometry = new THREE.Geometry(); | ||
- lineGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) ); | ||
- | ||
- var coneGeometry = new THREE.CylinderGeometry( 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 | ||
- | ||
- THREE.Object3D.call( this ); | ||
- | ||
- 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.position.copy( origin ); | ||
- | ||
- this.line = new THREE.Line( lineGeometry, new THREE.LineBasicMaterial( { color: color } ) ); | ||
- this.line.matrixAutoUpdate = false; | ||
- this.add( this.line ); | ||
- | ||
- this.cone = new THREE.Mesh( coneGeometry, new THREE.MeshBasicMaterial( { color: color } ) ); | ||
- this.cone.matrixAutoUpdate = false; | ||
- this.add( this.cone ); | ||
- | ||
- this.setDirection( dir ); | ||
- this.setLength( length, headLength, headWidth ); | ||
- | ||
- } | ||
- | ||
-}() ); | ||
- | ||
-THREE.ArrowHelper.prototype = Object.create( THREE.Object3D.prototype ); | ||
-THREE.ArrowHelper.prototype.constructor = THREE.ArrowHelper; | ||
- | ||
-THREE.ArrowHelper.prototype.setDirection = ( function () { | ||
- | ||
- var axis = new THREE.Vector3(); | ||
- var radians; | ||
- | ||
- return function setDirection( dir ) { | ||
- | ||
- // dir is assumed to be normalized | ||
- | ||
- if ( dir.y > 0.99999 ) { | ||
- | ||
- this.quaternion.set( 0, 0, 0, 1 ); | ||
- | ||
- } else if ( dir.y < - 0.99999 ) { | ||
- | ||
- this.quaternion.set( 1, 0, 0, 0 ); | ||
- | ||
- } else { | ||
- | ||
- axis.set( dir.z, 0, - dir.x ).normalize(); | ||
- | ||
- radians = Math.acos( dir.y ); | ||
- | ||
- this.quaternion.setFromAxisAngle( axis, radians ); | ||
- | ||
- } | ||
- | ||
- }; | ||
- | ||
-}() ); | ||
- | ||
-THREE.ArrowHelper.prototype.setLength = function ( length, headLength, headWidth ) { | ||
- | ||
- if ( headLength === undefined ) headLength = 0.2 * length; | ||
- if ( headWidth === undefined ) headWidth = 0.2 * headLength; | ||
- | ||
- this.line.scale.set( 1, Math.max( 0, length - headLength ), 1 ); | ||
- this.line.updateMatrix(); | ||
- | ||
- this.cone.scale.set( headWidth, headLength, headWidth ); | ||
- this.cone.position.y = length; | ||
- this.cone.updateMatrix(); | ||
- | ||
-}; | ||
- | ||
-THREE.ArrowHelper.prototype.setColor = function ( color ) { | ||
- | ||
- this.line.material.color.set( color ); | ||
- this.cone.material.color.set( color ); | ||
- | ||
-}; |
@@ -1,33 +0,0 @@ | ||
-/** | ||
- * @author sroucheray / http://sroucheray.org/ | ||
- * @author mrdoob / http://mrdoob.com/ | ||
- */ | ||
- | ||
-THREE.AxisHelper = function ( size ) { | ||
- | ||
- size = size || 1; | ||
- | ||
- var vertices = new Float32Array( [ | ||
- 0, 0, 0, size, 0, 0, | ||
- 0, 0, 0, 0, size, 0, | ||
- 0, 0, 0, 0, 0, size | ||
- ] ); | ||
- | ||
- var colors = new Float32Array( [ | ||
- 1, 0, 0, 1, 0.6, 0, | ||
- 0, 1, 0, 0.6, 1, 0, | ||
- 0, 0, 1, 0, 0.6, 1 | ||
- ] ); | ||
- | ||
- var geometry = new THREE.BufferGeometry(); | ||
- geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); | ||
- geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) ); | ||
- | ||
- var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } ); | ||
- | ||
- THREE.LineSegments.call( this, geometry, material ); | ||
- | ||
-}; | ||
- | ||
-THREE.AxisHelper.prototype = Object.create( THREE.LineSegments.prototype ); | ||
-THREE.AxisHelper.prototype.constructor = THREE.AxisHelper; |
0 comments on commit
d24afe7