octahedron.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { createPrimitive, Primitive } from './primitive';
  7. import { createCage, Cage } from './cage';
  8. export const octahedronVertices: ReadonlyArray<number> = [
  9. 0.5, 0, 0, -0.5, 0, 0, 0, 0.5, 0,
  10. 0, -0.5, 0, 0, 0, 0.5, 0, 0, -0.5
  11. ];
  12. export const octahedronIndices: ReadonlyArray<number> = [
  13. 0, 2, 4, 0, 4, 3, 0, 3, 5,
  14. 0, 5, 2, 1, 2, 5, 1, 5, 3,
  15. 1, 3, 4, 1, 4, 2
  16. ];
  17. export const perforatedOctahedronIndices: ReadonlyArray<number> = [
  18. 0, 2, 4, 0, 4, 3,
  19. // 0, 3, 5, 0, 5, 2,
  20. 1, 2, 5, 1, 5, 3,
  21. // 1, 3, 4, 1, 4, 2
  22. ];
  23. const octahedronEdges: ReadonlyArray<number> = [
  24. 0, 2, 1, 3, 2, 1, 3, 0,
  25. 0, 4, 1, 4, 2, 4, 3, 4,
  26. 0, 5, 1, 5, 2, 5, 3, 5,
  27. ];
  28. let octahedron: Primitive;
  29. export function Octahedron(): Primitive {
  30. if (!octahedron) octahedron = createPrimitive(octahedronVertices, octahedronIndices);
  31. return octahedron;
  32. }
  33. let perforatedOctahedron: Primitive;
  34. export function PerforatedOctahedron(): Primitive {
  35. if (!perforatedOctahedron) perforatedOctahedron = createPrimitive(octahedronVertices, perforatedOctahedronIndices);
  36. return perforatedOctahedron;
  37. }
  38. const octahedronCage = createCage(octahedronVertices, octahedronEdges);
  39. export function OctahedronCage(): Cage {
  40. return octahedronCage;
  41. }