{"record":{"id":"79d9a8aa5e4b0502","repo":"BabylonJS/Babylon.js","slug":"loading-textures-from-iinternaltextureloader-not-y","errorCode":null,"errorMessage":"Loading textures from IInternalTextureLoader not yet implemented.","messagePattern":"Loading textures from IInternalTextureLoader not yet implemented\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/thinNativeEngine.pure.ts","lineNumber":2035,"sourceCode":"                }\r\n\r\n                if (EngineStore.UseFallbackTexture) {\r\n                    this.createTexture(EngineStore.FallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, onError, buffer, texture);\r\n                }\r\n\r\n                if (onError) {\r\n                    onError((message || \"Unknown error\") + (EngineStore.UseFallbackTexture ? \" - Fallback texture was used\" : \"\"), exception);\r\n                }\r\n            } else {\r\n                // fall back to the original url if the transformed url fails to load\r\n                Logger.Warn(`Failed to load ${url}, falling back to ${originalUrl}`);\r\n                this.createTexture(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, buffer, texture, format, forcedExtension, mimeType, loaderOptions);\r\n            }\r\n        };\r\n\r\n        // processing for non-image formats\r\n        if (loaderPromise) {\r\n            throw new Error(\"Loading textures from IInternalTextureLoader not yet implemented.\");\r\n        } else {\r\n            const onload = (data: ArrayBufferView) => {\r\n                if (!texture._hardwareTexture) {\r\n                    if (scene) {\r\n                        scene.removePendingData(texture);\r\n                    }\r\n\r\n                    return;\r\n                }\r\n\r\n                const underlyingResource = texture._hardwareTexture.underlyingResource;\r\n\r\n                this._engine.loadTexture(\r\n                    underlyingResource,\r\n                    data,\r\n                    !noMipmap,\r\n                    invertY,\r\n                    texture._useSRGBBuffer,\r","sourceCodeStart":2017,"sourceCodeEnd":2053,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/thinNativeEngine.pure.ts#L2017-L2053","documentation":"ThinNativeEngine.createTexture does not support loading textures through an IInternalTextureLoader promise-based loader (used for non-image formats like .dds/.ktx2/etc. that need async transcoding). The Babylon Native/bgfx engine only implements the raw-data loading path, so when the loader selection produces a loaderPromise instead of a buffer-based load, it throws immediately.","triggerScenarios":"Calling engine.createTexture (or loading a scene/texture) with a URL whose extension maps to an IInternalTextureLoader-based format (.dds, .basis, .ktx2, .ktx, etc.) when using ThinNativeEngine/NativeEngine.","commonSituations":"Porting a WebGL Babylon.js project to Babylon Native and reusing compressed-texture assets (.dds/.ktx2) or forceExtension-based loader plugins; materials referencing those textures fail at creation time.","solutions":["Convert the asset to a raw image format supported by the native path (e.g. .png/.jpg) and load that instead.","Pre-decode the texture yourself (CPU-side) and pass the raw ArrayBuffer/Uint8Array data via createTexture's buffer parameter or use createRawTexture.","If you own the pipeline, implement the missing loaderPromise branch in thinNativeEngine.pure.ts (the error is an explicit not-yet-implemented marker)."],"exampleFix":"// before\nconst tex = new BABYLON.Texture(\"env.ktx2\", scene);\n\n// after\nconst tex = new BABYLON.Texture(\"env.png\", scene); // or pass decoded raw data to createRawTexture","handlingStrategy":"validation","validationCode":"const loaderExts = [\".dds\", \".ktx\", \".ktx2\", \".basis\"];\nconst ext = url.split(\"?\")[0].slice(url.lastIndexOf(\".\")).toLowerCase();\nif (engine instanceof BABYLON.ThinNativeEngine && loaderExts.includes(ext)) {\n  throw new Error(`Native engine cannot load ${ext}; use a raw image or pre-decoded data.`);\n}","typeGuard":"const isNativeSafeTextureUrl = (url: string): boolean =>\n  ![\".dds\", \".ktx\", \".ktx2\", \".basis\"].some(e => url.toLowerCase().includes(e));","tryCatchPattern":"try {\n  const tex = engine.createTexture(url, false, false, scene);\n} catch (e) {\n  if (e.message.includes(\"not yet implemented\")) {\n    console.warn(\"Falling back to PNG texture for\", url);\n    tex = engine.createTexture(toRawImageUrl(url), false, false, scene);\n  } else throw e;\n}","preventionTips":["Audit asset pipelines for compressed formats (.dds/.ktx2/.basis) before targeting Babylon Native.","Maintain a Native-specific asset manifest with raw image formats.","Centralize texture creation behind a helper that branches on engine type."],"tags":["native","texture-loading","not-implemented"],"backgroundTag":"unsupported-texture-format","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}