浏览代码

Merge pull request #9243 from Popov72/fix-reload-texture-after-contextlost

Fix 404 error when reloading textures after a context lost
sebavan 4 年之前
父节点
当前提交
271a71e8a1
共有 2 个文件被更改,包括 7 次插入1 次删除
  1. 4 0
      src/Engines/thinEngine.ts
  2. 3 1
      src/Materials/Textures/internalTexture.ts

+ 4 - 0
src/Engines/thinEngine.ts

@@ -2886,6 +2886,10 @@ export class ThinEngine {
             url = this._transformTextureUrl(url);
         }
 
+        if (originalUrl !== url) {
+            texture._originalUrl = originalUrl;
+        }
+
         // establish the file extension, if possible
         const lastDot = url.lastIndexOf('.');
         let extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");

+ 3 - 1
src/Materials/Textures/internalTexture.ts

@@ -106,6 +106,8 @@ export class InternalTexture {
      * Gets the URL used to load this texture
      */
     public url: string = "";
+    /** @hidden */
+    public _originalUrl: string; // not empty only if different from url
     /**
      * Gets the sampling mode of the texture
      */
@@ -327,7 +329,7 @@ export class InternalTexture {
                 return;
 
             case InternalTextureSource.Url:
-                proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, () => {
+                proxy = this._engine.createTexture(this._originalUrl ?? this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, () => {
                     proxy._swapAndDie(this);
                     this.isReady = true;
                 }, null, this._buffer, undefined, this.format);