{"record":{"id":"82ccd07308d366ab","repo":"BabylonJS/Babylon.js","slug":"atmosphere-only-supports-one-light-source-currentl","errorCode":null,"errorMessage":"Atmosphere only supports one light source currently.","messagePattern":"Atmosphere only supports one light source currently\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/addons/src/atmosphere/atmosphere.ts","lineNumber":687,"sourceCode":"        lights: DirectionalLight[],\r\n        options?: IAtmosphereOptions\r\n    ) {\r\n        RegisterEngineUniformBuffer();\r\n        RegisterEnginesExtensionsEngineRenderTarget();\r\n\r\n        const engine = (this._engine = scene.getEngine());\r\n\r\n        if (!engine.isWebGPU && engine.version < 2) {\r\n            throw new Error(`Atmosphere is not supported on WebGL ${engine.version}.`);\r\n        }\r\n\r\n        this._physicalProperties = options?.physicalProperties ?? new AtmospherePhysicalProperties();\r\n        this._physicalProperties.onChangedObservable.add(() => {\r\n            this._transmittanceLut?.markDirty();\r\n        });\r\n\r\n        if (lights.length !== 1) {\r\n            throw new Error(\"Atmosphere only supports one light source currently.\");\r\n        }\r\n        this._lights = lights;\r\n\r\n        this.depthTexture = options?.depthTexture ?? null;\r\n        this._exposure = options?.exposure ?? 1.0;\r\n        this._isLinearSpaceLight = options?.isLinearSpaceLight ?? false;\r\n        this._isLinearSpaceComposition = options?.isLinearSpaceComposition ?? false;\r\n        this._applyApproximateTransmittance = options?.applyApproximateTransmittance ?? true;\r\n        this._aerialPerspectiveRadianceBias = options?.aerialPerspectiveRadianceBias ?? 0.0;\r\n        this._aerialPerspectiveTransmittanceScale = options?.aerialPerspectiveTransmittanceScale ?? 1.0;\r\n        this._aerialPerspectiveSaturation = options?.aerialPerspectiveSaturation ?? 1.0;\r\n        this._aerialPerspectiveIntensity = options?.aerialPerspectiveIntensity ?? 1.0;\r\n        this._diffuseSkyIrradianceDesaturationFactor = options?.diffuseSkyIrradianceDesaturationFactor ?? 0.5;\r\n        this._diffuseSkyIrradianceIntensity = options?.diffuseSkyIrradianceIntensity ?? 1.0;\r\n        this._additionalDiffuseSkyIrradianceIntensity = options?.additionalDiffuseSkyIrradianceIntensity ?? 0.01;\r\n        this._multiScatteringIntensity = options?.multiScatteringIntensity ?? 1.0;\r\n        this._minimumMultiScatteringIntensity = options?.minimumMultiScatteringIntensity ?? 0.000618;\r\n        this._isSkyViewLutEnabled = options?.isSkyViewLutEnabled ?? true;\r","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/addons/src/atmosphere/atmosphere.ts#L669-L705","documentation":"Atmosphere's physical sky model currently evaluates sun/sky lighting for exactly one light (typically the sun). The constructor validates the `lights` array and throws when it does not contain exactly one element, because the lighting pipeline and shader uniforms are hardcoded for a single light source.","triggerScenarios":"Calling `new Atmosphere(scene, lights, options)` with an empty lights array (`[]`) or with more than one light (`length !== 1`), e.g. passing sun plus a moon or fill light.","commonSituations":"Passing `scene.lights` directly (a scene usually has multiple lights: hemispheric + directional), passing an empty array before lights are created, or attempting multi-light setups like sun + moon in the same Atmosphere instance.","solutions":["Pass exactly one light, typically the scene's directional (sun) light: `new Atmosphere(scene, [sunLight])`.","If you need multiple light sources, create separate handling outside Atmosphere or use a different sky solution; Atmosphere supports only one light per instance.","Filter/choose the light before constructing: pick the directional light from scene.lights instead of passing the whole array."],"exampleFix":"// before\nconst atmosphere = new Atmosphere(scene, scene.lights); // may contain several lights\n// after\nconst sun = scene.lights.find((l) => l.getTypeID() === BAB.Light.LIGHTTYPEID_DIRECTIONALLIGHT)!;\nconst atmosphere = new Atmosphere(scene, [sun]);","handlingStrategy":"validation","validationCode":"const lightsForAtmosphere = scene.lights.filter((l) => l.getTypeID() === BABYLON.Light.LIGHTTYPEID_DIRECTIONALLIGHT).slice(0, 1);\nif (lightsForAtmosphere.length !== 1) throw new Error(\"Need exactly one sun light for Atmosphere\");","typeGuard":"const isSingleLight = (lights: BABYLON.Light[]): lights is [BABYLON.Light] => lights.length === 1;","tryCatchPattern":"try {\n  atmosphere = new Atmosphere(scene, lights);\n} catch (e) {\n  if (String(e).includes(\"one light source\")) {\n    atmosphere = new Atmosphere(scene, [lights[0] ?? defaultSun]);\n  } else throw e;\n}","preventionTips":["Never pass scene.lights wholesale; select the sun light explicitly.","Create the sun light before constructing Atmosphere.","Model additional lights outside Atmosphere (they won't affect the sky)."],"tags":["atmosphere","lights","api-misuse","initialization"],"backgroundTag":"invalid-argument-count","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}