babylon.material.js 1.9 KB

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