babylon.baseTexture.js 5.1 KB

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