babylon.material.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.alpha = 1.0;
  9. this.wireframe = false;
  10. this.backFaceCulling = true;
  11. this._effect = null;
  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.trackCreation = function (onCompiled, onError) {
  35. };
  36. Material.prototype._preBind = function () {
  37. var engine = this._scene.getEngine();
  38. engine.enableEffect(this._effect);
  39. engine.setState(this.backFaceCulling);
  40. };
  41. Material.prototype.bind = function (world, mesh) {
  42. };
  43. Material.prototype.unbind = function () {
  44. };
  45. Material.prototype.dispose = function (forceDisposeEffect) {
  46. // Remove from scene
  47. var index = this._scene.materials.indexOf(this);
  48. this._scene.materials.splice(index, 1);
  49. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  50. if (forceDisposeEffect && this._effect) {
  51. this._scene.getEngine()._releaseEffect(this._effect);
  52. this._effect = null;
  53. }
  54. // Callback
  55. if (this.onDispose) {
  56. this.onDispose();
  57. }
  58. };
  59. return Material;
  60. })();
  61. BABYLON.Material = Material;
  62. })(BABYLON || (BABYLON = {}));
  63. //# sourceMappingURL=babylon.material.js.map