{"record":{"id":"a4739d523db5022c","repo":"moeru-ai/airi","slug":"failed-to-set-colorspace-on-texture","errorCode":null,"errorMessage":"Failed to set colorSpace on texture:","messagePattern":"Failed to set colorSpace on texture:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui-three/src/components/Model/VRMModel.vue","lineNumber":810,"sourceCode":"    /*\n      * Shader setting\n    */\n    const isShaderMat = (m: any): m is ShaderMaterial => !!m?.isShaderMaterial\n\n    function configureInjectedShaderMaterial(mat: ShaderMaterial) {\n      if ('toneMapped' in mat)\n        mat.toneMapped = false\n      if ('envMap' in mat && mat.envMap)\n        mat.envMap = null\n\n      // NPR materials usually use sRGB textures.\n      const tex = (mat as any).map as Texture | undefined\n      if (tex && (tex as any).colorSpace !== undefined) {\n        try {\n          (tex as any).colorSpace = SRGBColorSpace\n        }\n        catch (e) {\n          console.warn('Failed to set colorSpace on texture:', e)\n        }\n      }\n\n      injectDiffuseIBL(mat)\n    }\n\n    // MToon material sky box lightProbe setting\n    if (!airiIblProbe && scene.value)\n      airiIblProbe = createIblProbeController(scene.value)\n\n    // Material traverse setting\n    _vrm.scene.traverse((child) => {\n      if (child instanceof Mesh && child.material) {\n        const material = Array.isArray(child.material) ? child.material : [child.material]\n        material.forEach((mat, materialIndex) => {\n          if (mat instanceof MeshStandardMaterial || mat instanceof MeshPhysicalMaterial) {\n            // Should read envMap intensity from outside props\n            mat.envMapIntensity = 1.0","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui-three/src/components/Model/VRMModel.vue#L792-L828","documentation":"While normalizing MToon/NPR materials on the freshly loaded VRM, the component assigns SRGBColorSpace to each material's map texture inside a try/catch. If the texture's colorSpace setter throws (already-disposed texture, exotic texture subclass, engine edge case), the assignment is skipped with this warning and material setup continues — the model still renders, possibly with slightly wrong color gamma on that material.","triggerScenarios":"mat.map is a Texture whose colorSpace assignment raises: a texture disposed during a concurrent load cancellation, or a custom/proxy texture implementation that validates assignments.","commonSituations":"Rapid model switching where an in-flight load is being torn down; third-party VRM variants with unusual material/texture implementations; three.js version changes altering Texture setter behavior.","solutions":["Usually ignorable: rendering continues and only sRGB enforcement for that material is skipped","Reproduce with a single, undisturbed model load — if the throw persists, inspect the texture instance type on the offending material","Update three / @pixiv three-vrm packages in case Texture setter behavior changed","If tied to one model, re-export the model and its textures with standard settings"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Skip assignment when the texture is disposed or lacks the setter\nconst tex = (mat as any).map as Texture | undefined\nif (tex && !('dispose' in tex && (tex as any).disposed) && (tex as any).colorSpace !== undefined) {\n  ;(tex as any).colorSpace = SRGBColorSpace\n}","typeGuard":"function isAssignableTexture(tex: unknown): tex is Texture {\n  return tex instanceof Texture && !(tex as any).disposed\n}","tryCatchPattern":"try {\n  ;(tex as any).colorSpace = SRGBColorSpace\n}\ncatch (e) {\n  // Non-fatal: continue material setup; log the material name to identify the offender\n  console.warn('Failed to set colorSpace on texture:', e, mat.name)\n}","preventionTips":["Avoid concurrent load/teardown of the same VRM (request-id guards should cancel before touching textures)","Verify unusual VRM exports render correctly after import instead of ignoring the warn","Keep three / @pixiv three-vrm versions updated to reduce setter behavior drift"],"tags":["vrm","three","texture","colorspace","materials"],"backgroundTag":"texture-colorspace-unsupported","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}