AxisHelper.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @author sroucheray / http://sroucheray.org/
  3. * @author mr.doob / http://mrdoob.com/
  4. */
  5. THREE.AxisHelper = function () {
  6. THREE.Object3D.call( this );
  7. var lineGeometry = new THREE.Geometry();
  8. lineGeometry.vertices.push( new THREE.Vector3() );
  9. lineGeometry.vertices.push( new THREE.Vector3( 0, 100, 0 ) );
  10. var coneGeometry = new THREE.CylinderGeometry( 0, 5, 25, 5, 1 );
  11. var line, cone;
  12. // x
  13. line = new THREE.Line( lineGeometry, new THREE.LineBasicMaterial( { color : 0xff0000 } ) );
  14. line.rotation.z = - Math.PI / 2;
  15. this.add( line );
  16. cone = new THREE.Mesh( coneGeometry, new THREE.MeshBasicMaterial( { color : 0xff0000 } ) );
  17. cone.position.x = 100;
  18. cone.rotation.z = - Math.PI / 2;
  19. this.add( cone );
  20. // y
  21. line = new THREE.Line( lineGeometry, new THREE.LineBasicMaterial( { color : 0x00ff00 } ) );
  22. this.add( line );
  23. cone = new THREE.Mesh( coneGeometry, new THREE.MeshBasicMaterial( { color : 0x00ff00 } ) );
  24. cone.position.y = 100;
  25. this.add( cone );
  26. // z
  27. line = new THREE.Line( lineGeometry, new THREE.LineBasicMaterial( { color : 0x0000ff } ) );
  28. line.rotation.x = Math.PI / 2;
  29. this.add( line );
  30. cone = new THREE.Mesh( coneGeometry, new THREE.MeshBasicMaterial( { color : 0x0000ff } ) );
  31. cone.position.z = 100;
  32. cone.rotation.x = Math.PI / 2;
  33. this.add( cone );
  34. };
  35. THREE.AxisHelper.prototype = new THREE.Object3D();
  36. THREE.AxisHelper.prototype.constructor = THREE.AxisHelper;