babylon.baseTexture.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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, sampling) {
  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. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  83. texturesCacheEntry.references++;
  84. return texturesCacheEntry;
  85. }
  86. }
  87. }
  88. return null;
  89. };
  90. BaseTexture.prototype.delayLoad = function () {
  91. };
  92. BaseTexture.prototype.releaseInternalTexture = function () {
  93. if (!this._texture) {
  94. return;
  95. }
  96. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  97. this._texture.references--;
  98. // Final reference ?
  99. if (this._texture.references === 0) {
  100. var index = texturesCache.indexOf(this._texture);
  101. texturesCache.splice(index, 1);
  102. this._scene.getEngine()._releaseTexture(this._texture);
  103. delete this._texture;
  104. }
  105. };
  106. BaseTexture.prototype.clone = function () {
  107. return null;
  108. };
  109. BaseTexture.prototype.dispose = function () {
  110. // Remove from scene
  111. var index = this._scene.textures.indexOf(this);
  112. if (index >= 0) {
  113. this._scene.textures.splice(index, 1);
  114. }
  115. if (this._texture === undefined) {
  116. return;
  117. }
  118. this.releaseInternalTexture();
  119. // Callback
  120. if (this.onDispose) {
  121. this.onDispose();
  122. }
  123. };
  124. return BaseTexture;
  125. })();
  126. BABYLON.BaseTexture = BaseTexture;
  127. })(BABYLON || (BABYLON = {}));
  128. //# sourceMappingURL=babylon.baseTexture.js.map