renderable.spec.ts 979 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { calculateBoundingSphere } from '../renderable/util';
  7. describe('renderable', () => {
  8. it('calculateBoundingSphere', () => {
  9. const position = new Float32Array([
  10. 0, 0, 0,
  11. 1, 0, 0
  12. ])
  13. const transform = new Float32Array([
  14. 1, 0, 0, 0,
  15. 0, 1, 0, 0,
  16. 0, 0, 1, 0,
  17. 0, 0, 0, 0,
  18. 1, 0, 0, 0,
  19. 0, 1, 0, 0,
  20. 0, 0, 1, 0,
  21. 1, 0, 0, 0,
  22. 1, 0, 0, 0,
  23. 0, 1, 0, 0,
  24. 0, 0, 1, 0,
  25. 2, 0, 0, 0
  26. ])
  27. const bs = calculateBoundingSphere(
  28. position, position.length / 3,
  29. transform, transform.length / 16
  30. )
  31. expect(bs.radius).toBe(1.5)
  32. expect(bs.center).toEqual([1.5, 0.0, 0.0])
  33. })
  34. })