babylon.baseTexture.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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._getFromCache = function (url, noMipmap) {
  59. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  60. for (var index = 0; index < texturesCache.length; index++) {
  61. var texturesCacheEntry = texturesCache[index];
  62. if (texturesCacheEntry.url === url && texturesCacheEntry.noMipmap === noMipmap) {
  63. texturesCacheEntry.references++;
  64. return texturesCacheEntry;
  65. }
  66. }
  67. return null;
  68. };
  69. BaseTexture.prototype.delayLoad = function () {
  70. };
  71. BaseTexture.prototype.releaseInternalTexture = function () {
  72. if (!this._texture) {
  73. return;
  74. }
  75. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  76. this._texture.references--;
  77. // Final reference ?
  78. if (this._texture.references == 0) {
  79. var index = texturesCache.indexOf(this._texture);
  80. texturesCache.splice(index, 1);
  81. this._scene.getEngine()._releaseTexture(this._texture);
  82. delete this._texture;
  83. }
  84. };
  85. BaseTexture.prototype.clone = function () {
  86. return null;
  87. };
  88. BaseTexture.prototype.dispose = function () {
  89. // Remove from scene
  90. var index = this._scene.textures.indexOf(this);
  91. if (index >= 0) {
  92. this._scene.textures.splice(index, 1);
  93. }
  94. if (this._texture === undefined) {
  95. return;
  96. }
  97. this.releaseInternalTexture();
  98. // Callback
  99. if (this.onDispose) {
  100. this.onDispose();
  101. }
  102. };
  103. return BaseTexture;
  104. })();
  105. BABYLON.BaseTexture = BaseTexture;
  106. })(BABYLON || (BABYLON = {}));
  107. //# sourceMappingURL=babylon.baseTexture.js.map