1 /**
2 * @author WestLangley / http://github.com/WestLangley
3 * @author zz85 / https://github.com/zz85
4 *
5 * Creates an arrow for visualizing directions
6 *
7 * Parameters:
8 * dir - Vector3
9 * origin - Vector3
10 * length - Number
11 * hex - color in hex value
12 */
13
14 /**@constructor*/
15 THREE.ArrowHelper = function ( dir, origin, length, hex ) {
16
17 THREE.Object3D.call( this );
18
19 if ( hex === undefined ) hex = 0xffff00;
20 if ( length === undefined ) length = 20;
21
22 var lineGeometry = new THREE.Geometry();
23 lineGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ) );
24 lineGeometry.vertices.push( new THREE.Vector3( 0, 1, 0 ) );
25
26 this.line = new THREE.Line( lineGeometry, new THREE.LineBasicMaterial( { color: hex } ) );
27 this.add( this.line );
28
29 var coneGeometry = new THREE.CylinderGeometry( 0, 0.05, 0.25, 5, 1 );
30
31 this.cone = new THREE.Mesh( coneGeometry, new THREE.MeshBasicMaterial( { color: hex } ) );
32 this.cone.position.set( 0, 1, 0 );
33 this.add( this.cone );
34
35 if ( origin instanceof THREE.Vector3 ) this.position = origin;
36
37 this.setDirection( dir );
38 this.setLength( length );
39
40 };
41
42 THREE.ArrowHelper.prototype = Object.create( THREE.Object3D.prototype );
43
44 THREE.ArrowHelper.prototype.setDirection = function ( dir ) {
45
46 var axis = new THREE.Vector3( 0, 1, 0 ).crossSelf( dir );
47
48 var radians = Math.acos( new THREE.Vector3( 0, 1, 0 ).dot( dir.clone().normalize() ) );
49
50 this.matrix = new THREE.Matrix4().makeRotationAxis( axis.normalize(), radians );
51
52 this.rotation.setEulerFromRotationMatrix( this.matrix, this.eulerOrder );
53
54 };
55
56 THREE.ArrowHelper.prototype.setLength = function ( length ) {
57
58 this.scale.set( length, length, length );
59
60 };
61
62 THREE.ArrowHelper.prototype.setColor = function ( hex ) {
63
64 this.line.material.color.setHex( hex );
65 this.cone.material.color.setHex( hex );
66
67 };
68
nike free rn
new balance hombre baratas
cinturones gucci
ugg rebajas
cinturon gucci
ray ban baratas
nike cortez
peuterey mujer
christian louboutin madrid
mbt zapatos
gafas ray ban baratas
mbt ofertas
air max blancas
mbt barcelona
nike air max 90
woolrich barcelona
nike mujer
botas ugg
gafas de sol carrera aratas
air max 2016 baratas
oakley baratas
nike air max 2016