babylon.material.tests.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. .load(function () {
  14. // Force apply promise polyfill for consistent behavior between PhantomJS, IE11, and other browsers.
  15. BABYLON.PromisePolyfill.Apply(true);
  16. done();
  17. });
  18. });
  19. /**
  20. * Create a new engine subject before each test.
  21. */
  22. beforeEach(function () {
  23. subject = new BABYLON.NullEngine({
  24. renderHeight: 256,
  25. renderWidth: 256,
  26. textureSize: 256,
  27. deterministicLockstep: false,
  28. lockstepMaxSteps: 1
  29. });
  30. });
  31. describe('#PBRMaterial', () => {
  32. it('forceCompilation of a single material', () => {
  33. const scene = new BABYLON.Scene(subject);
  34. const mesh = BABYLON.Mesh.CreateBox("mesh", 1, scene);
  35. const material = new BABYLON.PBRMaterial("material", scene);
  36. return material.forceCompilationAsync(mesh);
  37. });
  38. it('forceCompilation of already compiled material', () => {
  39. const scene = new BABYLON.Scene(subject);
  40. const mesh = BABYLON.Mesh.CreateBox("mesh", 1, scene);
  41. const material = new BABYLON.PBRMaterial("material", scene);
  42. material.albedoTexture = new BABYLON.Texture("/Playground/scenes/BoomBox/BoomBox_baseColor.png", scene);
  43. return material.forceCompilationAsync(mesh).then(() => {
  44. return material.forceCompilationAsync(mesh);
  45. });
  46. });
  47. it('forceCompilation of same material in parallel', () => {
  48. const scene = new BABYLON.Scene(subject);
  49. const mesh = BABYLON.Mesh.CreateBox("mesh", 1, scene);
  50. const material = new BABYLON.PBRMaterial("material", scene);
  51. material.albedoTexture = new BABYLON.Texture("/Playground/scenes/BoomBox/BoomBox_baseColor.png", scene);
  52. return Promise.all([
  53. material.forceCompilationAsync(mesh),
  54. material.forceCompilationAsync(mesh)
  55. ]);
  56. });
  57. });
  58. });