babylon.material.js 2.4 KB

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