{"record":{"id":"3057c117f2bf3687","repo":"BabylonJS/Babylon.js","slug":"extracontext-material-type-not-supported","errorCode":null,"errorMessage":"${extraContext}: Material type not supported","messagePattern":"(.+?): Material type not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.pure.ts","lineNumber":40,"sourceCode":"    /** @internal */\r\n    constructor(loader: GLTFLoader) {\r\n        this._loader = loader;\r\n        this.enabled = this._loader.isExtensionUsed(NAME);\r\n    }\r\n\r\n    /** @internal */\r\n    public dispose() {\r\n        (this._loader as any) = null;\r\n    }\r\n\r\n    /** @internal */\r\n    // eslint-disable-next-line no-restricted-syntax\r\n    public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n        return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, async (extraContext, extra) => {\r\n            if (extra) {\r\n                const impl = this._loader._pbrMaterialImpls.get(\"pbr\");\r\n                if (!impl) {\r\n                    throw new Error(`${extraContext}: Material type not supported`);\r\n                }\r\n\r\n                const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n                if (babylonMaterial.needAlphaBlending()) {\r\n                    babylonMaterial.forceDepthWrite = true;\r\n                    babylonMaterial.separateCullingPass = true;\r\n                }\r\n\r\n                babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;\r\n                (babylonMaterial as PBRMaterial).twoSidedLighting = true;\r\n\r\n                return await promise;\r\n            }\r\n        });\r\n    }\r\n}\r\n\r","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.pure.ts#L22-L58","documentation":"MSFT_minecraftMesh requires the loader to have created a PBR material implementation, since it applies its extra properties on top of the 'pbr' metal-rough workflow. loadMaterialPropertiesAsync looks up _loader._pbrMaterialImpls.get('pbr'); if the material is not a PBR metallic-roughness material (or the PBR implementation wasn't registered), it throws.","triggerScenarios":"Loading a glTF where a material carries the MSFT_minecraftMesh extra but the material is not PBR metallic-roughness — e.g. it uses KHR_materials_unlit, spec-gloss (KHR_materials_pbrSpecularGlossiness), or another workflow.","commonSituations":"Assets mixing MSFT_minecraft_mesh with unlit or legacy specular-glossiness materials; converting assets between workflows and keeping the extension; custom loaders that don't populate the PBR implementation map.","solutions":["Ensure materials with MSFT_minecraft_mesh use the pbrMetallicRoughness workflow.","Remove the MSFT_minecraft_mesh extension from non-PBR materials.","Re-export the asset converting unlit/spec-gloss materials to metallic-roughness."],"exampleFix":"// before: unlit material with the extension\n\"materials\": [{ \"extensions\": { \"MSFT_minecraft_mesh\": {} }, \"KHR_materials_unlit\": {} }]\n// after: PBR material keeps the extension\n\"materials\": [{ \"extensions\": { \"MSFT_minecraft_mesh\": {} }, \"pbrMetallicRoughness\": { \"baseColorFactor\": [1,1,1,1] } }]","handlingStrategy":"type-guard","validationCode":"const isPbr = material.defs?.some(d => d.name === 'pbrMetallicRoughness') || !material.extensions?.KHR_materials_unlit;\nif (!isPbr) throw new Error('MSFT_minecraft_mesh requires PBR metallic-roughness materials');","typeGuard":"function isPbrMaterial(m: IMaterial): boolean {\n  return !m.extensions?.['KHR_materials_unlit'] && !m.extensions?.['KHR_materials_pbrSpecularGlossiness'] && 'pbrMetallicRoughness' in m;\n}","tryCatchPattern":"try { await loader.loadAsync(url); } catch (e) {\n  if (e.message.includes('Material type not supported')) {\n    // convert the material to metallic-roughness or strip the extension, then retry\n  } else throw e;\n}","preventionTips":["Pair MSFT_minecraft_mesh only with pbrMetallicRoughness materials.","Audit material/extension combinations when converting assets between workflows.","Prefer checking the material definition before load rather than catching at runtime."],"tags":["gltf","materials","pbr","extensions"],"backgroundTag":"unsupported-material-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}