{"record":{"id":"e41d26cdafd35531","repo":"BabylonJS/Babylon.js","slug":"context-irradiance-coefficients-are-missing","errorCode":null,"errorMessage":"${context}: Irradiance coefficients are missing","messagePattern":"(.+?): Irradiance coefficients are missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.pure.ts","lineNumber":137,"sourceCode":"                light._babylonTexture = babylonTexture;\r\n\r\n                if (light.intensity != undefined) {\r\n                    babylonTexture.level = light.intensity;\r\n                }\r\n\r\n                if (light.rotation) {\r\n                    let rotation = Quaternion.FromArray(light.rotation);\r\n\r\n                    // Invert the rotation so that positive rotation is counter-clockwise.\r\n                    if (!this._loader.babylonScene.useRightHandedSystem) {\r\n                        rotation = Quaternion.Inverse(rotation);\r\n                    }\r\n\r\n                    Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());\r\n                }\r\n\r\n                if (!light.irradianceCoefficients) {\r\n                    throw new Error(`${context}: Irradiance coefficients are missing`);\r\n                }\r\n\r\n                const sphericalHarmonics = SphericalHarmonics.FromArray(light.irradianceCoefficients);\r\n                sphericalHarmonics.scaleInPlace(light.intensity);\r\n\r\n                sphericalHarmonics.convertIrradianceToLambertianRadiance();\r\n                const sphericalPolynomial = SphericalPolynomial.FromHarmonics(sphericalHarmonics);\r\n\r\n                // Compute the lod generation scale to fit exactly to the number of levels available.\r\n                const lodGenerationScale = (imageData.length - 1) / Math.log2(light.specularImageSize);\r\n                return await babylonTexture.updateRGBDAsync(imageData, sphericalPolynomial, lodGenerationScale);\r\n            });\r\n        }\r\n\r\n        // eslint-disable-next-line github/no-then\r\n        return light._loaded.then(() => {\r\n            return light._babylonTexture!;\r\n        });\r","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.pure.ts#L119-L155","documentation":"The EXT_lights_image_based extension requires each image-based light to provide irradianceCoefficients (spherical harmonics data) used to build the environment irradiance. When light.irradianceCoefficients is absent, _loadLightAsync throws, aborting scene load. The coefficients are mandatory for the loader to construct the IBL.","triggerScenarios":"Loading a glTF with an EXT_lights_image_based light object missing the irradianceCoefficients array in its JSON definition.","commonSituations":"Hand-authored environment extension blocks; exporters that emit only rotation/intensity without SH coefficients; assets stripped by optimization tools that dropped 'unknown' JSON fields.","solutions":["Add the irradianceCoefficients array (9 or 27 float SH coefficients) to the light definition","Re-export the environment lighting from the original tool with IBL data included","Remove the EXT_lights_image_based extension if baked lighting is not needed","Check optimizer/exporter settings so custom extension fields are preserved"],"exampleFix":"// before\n\"lights\": [{ \"type\": \"imagebased\", \"intensity\": 1 }]\n// after\n\"lights\": [{ \"type\": \"imagebased\", \"intensity\": 1, \"irradianceCoefficients\": [0.1,0.1,0.1, 0.1,0.1,0.1, 0.1,0.1,0.1, ...] }]","handlingStrategy":"validation","validationCode":"const lights = asset.extensions?.EXT_lights_image_based?.lights ?? [];\nfor (const l of lights) {\n  if (!Array.isArray(l.irradianceCoefficients) || l.irradianceCoefficients.length === 0) {\n    throw new Error(`IBL light missing irradianceCoefficients`);\n  }\n}","typeGuard":"function hasIrradiance(l: { irradianceCoefficients?: number[] }): l is { irradianceCoefficients: number[] } {\n  return Array.isArray(l.irradianceCoefficients) && l.irradianceCoefficients.length > 0;\n}","tryCatchPattern":"try {\n  await BABYLON.SceneLoader.LoadAsync('./', 'env.gltf', engine);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Irradiance coefficients are missing')) {\n    console.error('Re-export IBL with SH coefficients or remove EXT_lights_image_based');\n  } else throw e;\n}","preventionTips":["Preserve extension fields in optimizer/exporter settings","Pre-validate IBL lights for irradianceCoefficients before load","Avoid hand-authoring extension JSON; use supported exporters"],"tags":["gltf","extension","ibl","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}