babylon.material.js 2.3 KB

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