babylon.mesh.vertexData.tests.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Describes the test suite.
  3. */
  4. describe('Babylon Mesh Vertex Data', () => {
  5. /**
  6. * Loads the dependencies.
  7. */
  8. before(function(done) {
  9. this.timeout(180000);
  10. (BABYLONDEVTOOLS).Loader
  11. .useDist()
  12. .testMode()
  13. .load(function() {
  14. // Force apply promise polyfill for consistent behavior between chrome headless, IE11, and other browsers.
  15. BABYLON.PromisePolyfill.Apply(true);
  16. done();
  17. });
  18. });
  19. describe('#Mesh Vertex Data Merge', () => {
  20. it('should be able to merge data', () => {
  21. const foo = new BABYLON.VertexData();
  22. foo.positions = [0, 0, 0];
  23. foo.normals = [0, 0, 1];
  24. const bar = new BABYLON.VertexData();
  25. bar.positions = [0, 0, 1];
  26. bar.normals = [0, 1, 0];
  27. const merged = foo.merge(bar);
  28. expect(merged.positions).to.eql([0, 0, 0, 0, 0, 1]);
  29. expect(merged.normals).to.eql([0, 0, 1, 0, 1, 0]);
  30. });
  31. it('should not be able to merge data that are not valid', () => {
  32. const foo = new BABYLON.VertexData();
  33. foo.positions = [0, 0, 0];
  34. foo.normals = [0];
  35. const bar = new BABYLON.VertexData();
  36. bar.positions = [0, 0, 1];
  37. bar.normals = [0];
  38. expect(() => {
  39. foo.merge(bar);
  40. }).to.throw(Error);
  41. });
  42. it('should not be able to merge data with different attributes', () => {
  43. const foo = new BABYLON.VertexData();
  44. foo.positions = [0, 0, 0];
  45. foo.normals = [0, 0, 1];
  46. const bar = new BABYLON.VertexData();
  47. bar.positions = [0, 0, 1];
  48. expect(() => {
  49. foo.merge(bar);
  50. }).to.throw(Error);
  51. });
  52. });
  53. });