babylon.material.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var Material = (function () {
  4. function Material(name, scene, doNotAdd) {
  5. this.name = name;
  6. this.checkReadyOnEveryCall = true;
  7. this.checkReadyOnlyOnce = false;
  8. this.state = "";
  9. this.alpha = 1.0;
  10. this.wireframe = false;
  11. this.backFaceCulling = true;
  12. this._wasPreviouslyReady = false;
  13. this.id = name;
  14. this._scene = scene;
  15. if (!doNotAdd) {
  16. scene.materials.push(this);
  17. }
  18. }
  19. Material.prototype.isReady = function (mesh) {
  20. return true;
  21. };
  22. Material.prototype.getEffect = function () {
  23. return this._effect;
  24. };
  25. Material.prototype.getScene = function () {
  26. return this._scene;
  27. };
  28. Material.prototype.needAlphaBlending = function () {
  29. return (this.alpha < 1.0);
  30. };
  31. Material.prototype.needAlphaTesting = function () {
  32. return false;
  33. };
  34. Material.prototype.getAlphaTestTexture = function () {
  35. return null;
  36. };
  37. Material.prototype.trackCreation = function (onCompiled, onError) {
  38. };
  39. Material.prototype._preBind = function () {
  40. var engine = this._scene.getEngine();
  41. engine.enableEffect(this._effect);
  42. engine.setState(this.backFaceCulling);
  43. };
  44. Material.prototype.bind = function (world, mesh) {
  45. };
  46. Material.prototype.unbind = function () {
  47. };
  48. Material.prototype.dispose = function (forceDisposeEffect) {
  49. // Remove from scene
  50. var index = this._scene.materials.indexOf(this);
  51. this._scene.materials.splice(index, 1);
  52. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  53. if (forceDisposeEffect && this._effect) {
  54. this._scene.getEngine()._releaseEffect(this._effect);
  55. this._effect = null;
  56. }
  57. // Callback
  58. if (this.onDispose) {
  59. this.onDispose();
  60. }
  61. };
  62. return Material;
  63. })();
  64. BABYLON.Material = Material;
  65. })(BABYLON || (BABYLON = {}));
  66. //# sourceMappingURL=babylon.material.js.map