tetrahedron.ts 1009 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Copyright (c) 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 tetrahedronVertices: ReadonlyArray<number> = [
  9. 0.7071, 0, 0, -0.3535, 0.6123, 0, -0.3535, -0.6123, 0,
  10. 0, 0, 0.7071, 0, 0, -0.7071
  11. ];
  12. export const tetrahedronIndices: ReadonlyArray<number> = [
  13. 4, 1, 0, 4, 2, 1, 4, 0, 2,
  14. 0, 1, 3, 1, 2, 3, 2, 0, 3,
  15. ];
  16. const tetrahedronEdges: ReadonlyArray<number> = [
  17. 0, 1, 1, 2, 2, 0,
  18. 0, 3, 1, 3, 2, 3,
  19. 0, 4, 1, 4, 2, 4,
  20. ]
  21. let tetrahedron: Primitive
  22. export function Tetrahedron(): Primitive {
  23. if (!tetrahedron) tetrahedron = createPrimitive(tetrahedronVertices, tetrahedronIndices)
  24. return tetrahedron
  25. }
  26. const tetrahedronCage = createCage(tetrahedronVertices, tetrahedronEdges)
  27. export function TetrahedronCage(): Cage {
  28. return tetrahedronCage
  29. }