OctahedronGeometry.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @author timothypratley / https://github.com/timothypratley
  3. * @author Mugen87 / https://github.com/Mugen87
  4. */
  5. import { Geometry } from '../core/Geometry.js';
  6. import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';
  7. // OctahedronGeometry
  8. function OctahedronGeometry( radius, detail ) {
  9. Geometry.call( this );
  10. this.type = 'OctahedronGeometry';
  11. this.parameters = {
  12. radius: radius,
  13. detail: detail
  14. };
  15. this.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );
  16. this.mergeVertices();
  17. }
  18. OctahedronGeometry.prototype = Object.create( Geometry.prototype );
  19. OctahedronGeometry.prototype.constructor = OctahedronGeometry;
  20. // OctahedronBufferGeometry
  21. function OctahedronBufferGeometry( radius, detail ) {
  22. var vertices = [
  23. 1, 0, 0, - 1, 0, 0, 0, 1, 0,
  24. 0, - 1, 0, 0, 0, 1, 0, 0, - 1
  25. ];
  26. var indices = [
  27. 0, 2, 4, 0, 4, 3, 0, 3, 5,
  28. 0, 5, 2, 1, 2, 5, 1, 5, 3,
  29. 1, 3, 4, 1, 4, 2
  30. ];
  31. PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );
  32. this.type = 'OctahedronBufferGeometry';
  33. this.parameters = {
  34. radius: radius,
  35. detail: detail
  36. };
  37. }
  38. OctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );
  39. OctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;
  40. export { OctahedronGeometry, OctahedronBufferGeometry };