babylon.material.tests.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Describes the test suite.
  3. */
  4. describe('Babylon Material', function() {
  5. let subject: BABYLON.Engine;
  6. /**
  7. * Loads the dependencies.
  8. */
  9. before(function(done) {
  10. this.timeout(180000);
  11. (BABYLONDEVTOOLS).Loader
  12. .useDist()
  13. .testMode()
  14. .load(function() {
  15. // Force apply promise polyfill for consistent behavior between chrome headless, IE11, and other browsers.
  16. BABYLON.PromisePolyfill.Apply(true);
  17. done();
  18. });
  19. });
  20. /**
  21. * Create a new engine subject before each test.
  22. */
  23. beforeEach(function() {
  24. subject = new BABYLON.NullEngine({
  25. renderHeight: 256,
  26. renderWidth: 256,
  27. textureSize: 256,
  28. deterministicLockstep: false,
  29. lockstepMaxSteps: 1
  30. });
  31. });
  32. describe('#PBRMaterial', () => {
  33. it('forceCompilation of a single material', () => {
  34. const scene = new BABYLON.Scene(subject);
  35. const mesh = BABYLON.Mesh.CreateBox("mesh", 1, scene);
  36. const material = new BABYLON.PBRMaterial("material", scene);
  37. return material.forceCompilationAsync(mesh);
  38. });
  39. it('forceCompilation of already compiled material', () => {
  40. const scene = new BABYLON.Scene(subject);
  41. const mesh = BABYLON.Mesh.CreateBox("mesh", 1, scene);
  42. const material = new BABYLON.PBRMaterial("material", scene);
  43. material.albedoTexture = new BABYLON.Texture("/Playground/scenes/BoomBox/BoomBox_baseColor.png", scene);
  44. return material.forceCompilationAsync(mesh).then(() => {
  45. return material.forceCompilationAsync(mesh);
  46. });
  47. });
  48. it('forceCompilation of same material in parallel', () => {
  49. const scene = new BABYLON.Scene(subject);
  50. const mesh = BABYLON.Mesh.CreateBox("mesh", 1, scene);
  51. const material = new BABYLON.PBRMaterial("material", scene);
  52. material.albedoTexture = new BABYLON.Texture("/Playground/scenes/BoomBox/BoomBox_baseColor.png", scene);
  53. return Promise.all([
  54. material.forceCompilationAsync(mesh),
  55. material.forceCompilationAsync(mesh)
  56. ]);
  57. });
  58. });
  59. });