babylon.material.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON.Material = function (name, scene) {
  4. this.name = name;
  5. this.id = name;
  6. this._scene = scene;
  7. scene.materials.push(this);
  8. };
  9. // Members
  10. BABYLON.Material.prototype.checkReadyOnEveryCall = true;
  11. BABYLON.Material.prototype.alpha = 1.0;
  12. BABYLON.Material.prototype.wireframe = false;
  13. BABYLON.Material.prototype.backFaceCulling = true;
  14. BABYLON.Material.prototype._effect = null;
  15. BABYLON.Material.prototype.onDispose = null;
  16. // Properties
  17. BABYLON.Material.prototype.isReady = function (mesh) {
  18. return true;
  19. };
  20. BABYLON.Material.prototype.getEffect = function () {
  21. return this._effect;
  22. };
  23. BABYLON.Material.prototype.needAlphaBlending = function () {
  24. return (this.alpha < 1.0);
  25. };
  26. BABYLON.Material.prototype.needAlphaTesting = function () {
  27. return false;
  28. };
  29. // Methods
  30. BABYLON.Material.prototype._preBind = function () {
  31. var engine = this._scene.getEngine();
  32. engine.enableEffect(this._effect);
  33. engine.setState(this.backFaceCulling);
  34. };
  35. BABYLON.Material.prototype.bind = function (world, mesh) {
  36. };
  37. BABYLON.Material.prototype.unbind = function () {
  38. };
  39. BABYLON.Material.prototype.baseDispose = function () {
  40. // Remove from scene
  41. var index = this._scene.materials.indexOf(this);
  42. this._scene.materials.splice(index, 1);
  43. // Callback
  44. if (this.onDispose) {
  45. this.onDispose();
  46. }
  47. };
  48. BABYLON.Material.prototype.dispose = function () {
  49. this.baseDispose();
  50. };
  51. })();