babylon.material.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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, useInstances) {
  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.bindOnlyWorldMatrix = function (world) {
  47. };
  48. Material.prototype.unbind = function () {
  49. };
  50. Material.prototype.dispose = function (forceDisposeEffect) {
  51. // Remove from scene
  52. var index = this._scene.materials.indexOf(this);
  53. this._scene.materials.splice(index, 1);
  54. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  55. if (forceDisposeEffect && this._effect) {
  56. this._scene.getEngine()._releaseEffect(this._effect);
  57. this._effect = null;
  58. }
  59. // Callback
  60. if (this.onDispose) {
  61. this.onDispose();
  62. }
  63. };
  64. return Material;
  65. })();
  66. BABYLON.Material = Material;
  67. })(BABYLON || (BABYLON = {}));
  68. //# sourceMappingURL=babylon.material.js.map