babylon.multiMaterial.js 961 B

1234567891011121314151617181920212223242526272829303132333435
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON.MultiMaterial = function (name, scene) {
  4. this.name = name;
  5. this.id = name;
  6. this._scene = scene;
  7. scene.multiMaterials.push(this);
  8. this.subMaterials = [];
  9. };
  10. // Properties
  11. BABYLON.MultiMaterial.prototype.getSubMaterial = function (index) {
  12. if (index < 0 || index >= this.subMaterials.length) {
  13. return this._scene.defaultMaterial;
  14. }
  15. return this.subMaterials[index];
  16. };
  17. // Methods
  18. BABYLON.MultiMaterial.prototype.isReady = function (mesh) {
  19. var result = true;
  20. for (var index = 0; index < this.subMaterials.length; index++) {
  21. var subMaterial = this.subMaterials[index];
  22. if (subMaterial) {
  23. result &= this.subMaterials[index].isReady(mesh);
  24. }
  25. }
  26. return result;
  27. };
  28. })();