babylon.baseTexture.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var BaseTexture = (function () {
  4. function BaseTexture(scene) {
  5. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
  6. this.hasAlpha = false;
  7. this.level = 1;
  8. this.isCube = false;
  9. this.isRenderTarget = false;
  10. this.animations = new Array();
  11. this.coordinatesIndex = 0;
  12. this.coordinatesMode = BABYLON.Texture.EXPLICIT_MODE;
  13. this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
  14. this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
  15. this.anisotropicFilteringLevel = 4;
  16. this._scene = scene;
  17. this._scene.textures.push(this);
  18. }
  19. BaseTexture.prototype.getScene = function () {
  20. return this._scene;
  21. };
  22. BaseTexture.prototype.getTextureMatrix = function () {
  23. return null;
  24. };
  25. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  26. return null;
  27. };
  28. BaseTexture.prototype.getInternalTexture = function () {
  29. return this._texture;
  30. };
  31. BaseTexture.prototype.isReady = function () {
  32. if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
  33. return true;
  34. }
  35. if (this._texture) {
  36. return this._texture.isReady;
  37. }
  38. return false;
  39. };
  40. BaseTexture.prototype.getSize = function () {
  41. if (this._texture._width) {
  42. return { width: this._texture._width, height: this._texture._height };
  43. }
  44. if (this._texture._size) {
  45. return { width: this._texture._size, height: this._texture._size };
  46. }
  47. return { width: 0, height: 0 };
  48. };
  49. BaseTexture.prototype.getBaseSize = function () {
  50. if (!this.isReady())
  51. return { width: 0, height: 0 };
  52. if (this._texture._size) {
  53. return { width: this._texture._size, height: this._texture._size };
  54. }
  55. return { width: this._texture._baseWidth, height: this._texture._baseHeight };
  56. };
  57. BaseTexture.prototype._getFromCache = function (url, noMipmap) {
  58. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  59. for (var index = 0; index < texturesCache.length; index++) {
  60. var texturesCacheEntry = texturesCache[index];
  61. if (texturesCacheEntry.url === url && texturesCacheEntry.noMipmap === noMipmap) {
  62. texturesCacheEntry.references++;
  63. return texturesCacheEntry;
  64. }
  65. }
  66. return null;
  67. };
  68. BaseTexture.prototype.delayLoad = function () {
  69. };
  70. BaseTexture.prototype.releaseInternalTexture = function () {
  71. if (!this._texture) {
  72. return;
  73. }
  74. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  75. this._texture.references--;
  76. // Final reference ?
  77. if (this._texture.references == 0) {
  78. var index = texturesCache.indexOf(this._texture);
  79. texturesCache.splice(index, 1);
  80. this._scene.getEngine()._releaseTexture(this._texture);
  81. delete this._texture;
  82. }
  83. };
  84. BaseTexture.prototype.clone = function () {
  85. return null;
  86. };
  87. BaseTexture.prototype.dispose = function () {
  88. // Remove from scene
  89. var index = this._scene.textures.indexOf(this);
  90. if (index >= 0) {
  91. this._scene.textures.splice(index, 1);
  92. }
  93. if (this._texture === undefined) {
  94. return;
  95. }
  96. this.releaseInternalTexture();
  97. // Callback
  98. if (this.onDispose) {
  99. this.onDispose();
  100. }
  101. };
  102. return BaseTexture;
  103. })();
  104. BABYLON.BaseTexture = BaseTexture;
  105. })(BABYLON || (BABYLON = {}));
  106. //# sourceMappingURL=babylon.baseTexture.js.map