babylon.multiMaterial.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var __extends = (this && this.__extends) || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5. };
  6. var BABYLON;
  7. (function (BABYLON) {
  8. var MultiMaterial = (function (_super) {
  9. __extends(MultiMaterial, _super);
  10. function MultiMaterial(name, scene) {
  11. _super.call(this, name, scene, true);
  12. this.subMaterials = new Array();
  13. scene.multiMaterials.push(this);
  14. }
  15. // Properties
  16. MultiMaterial.prototype.getSubMaterial = function (index) {
  17. if (index < 0 || index >= this.subMaterials.length) {
  18. return this.getScene().defaultMaterial;
  19. }
  20. return this.subMaterials[index];
  21. };
  22. // Methods
  23. MultiMaterial.prototype.isReady = function (mesh) {
  24. for (var index = 0; index < this.subMaterials.length; index++) {
  25. var subMaterial = this.subMaterials[index];
  26. if (subMaterial) {
  27. if (!this.subMaterials[index].isReady(mesh)) {
  28. return false;
  29. }
  30. }
  31. }
  32. return true;
  33. };
  34. MultiMaterial.prototype.clone = function (name) {
  35. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  36. for (var index = 0; index < this.subMaterials.length; index++) {
  37. var subMaterial = this.subMaterials[index];
  38. newMultiMaterial.subMaterials.push(subMaterial);
  39. }
  40. return newMultiMaterial;
  41. };
  42. return MultiMaterial;
  43. })(BABYLON.Material);
  44. BABYLON.MultiMaterial = MultiMaterial;
  45. })(BABYLON || (BABYLON = {}));