/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{lerp as i}from"../../../../core/mathUtils.js";import{copy as t,scale as s,add as h,lerp as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{SphericalHarmonicsAmbientLight as o,MainLight as e}from"./Lightsources.js";import{combineLights as c}from"./SphericalHarmonics.js";import{Vector9 as g}from"../../../support/Vector9.js";class m{constructor(){this.color=n(),this.intensity=1}}class l{constructor(){this.direction=n(),this.ambient=new m,this.diffuse=new m}}const _=.4;class p{constructor(){this._legacy=new l,this.globalFactor=.5,this.noonFactor=.5,this._sphericalHarmonics=new o,this._mainLight=new e(n(),a(1,0,0),!1)}get legacy(){return this._legacy}get sh(){return this._sphericalHarmonics}get mainLight(){return this._mainLight}set(i){c(i,this._mainLight,this._sphericalHarmonics),this.updateLegacy()}updateLegacy(){t(this._legacy.direction,this._mainLight.direction);const i=1/Math.PI;this._legacy.ambient.color[0]=.282095*this._sphericalHarmonics.r[0]*i,this._legacy.ambient.color[1]=.282095*this._sphericalHarmonics.g[0]*i,this._legacy.ambient.color[2]=.282095*this._sphericalHarmonics.b[0]*i,s(this._legacy.diffuse.color,this._mainLight.intensity,i),t(L,this._legacy.diffuse.color),s(L,L,_*this.globalFactor),h(this._legacy.ambient.color,this._legacy.ambient.color,L)}copyFrom(i){g.copy(this._sphericalHarmonics.r,i.sh.r),g.copy(this._sphericalHarmonics.g,i.sh.g),g.copy(this._sphericalHarmonics.b,i.sh.b),t(this._mainLight.direction,i.mainLight.direction),t(this._mainLight.intensity,i.mainLight.intensity),this._mainLight.castShadows=i.mainLight.castShadows,this._mainLight.specularStrength=i.mainLight.specularStrength,this._mainLight.environmentStrength=i.mainLight.environmentStrength,this.globalFactor=i.globalFactor,this.noonFactor=i.noonFactor}lerpLighting(s,h,n){if(r(this._mainLight.intensity,s.mainLight.intensity,h.mainLight.intensity,n),this._mainLight.environmentStrength=i(s.mainLight.environmentStrength,h.mainLight.environmentStrength,n),this._mainLight.specularStrength=i(s.mainLight.specularStrength,h.mainLight.specularStrength,n),t(this._mainLight.direction,h.mainLight.direction),this._mainLight.castShadows=h.mainLight.castShadows,this.globalFactor=i(s.globalFactor,h.globalFactor,n),this.noonFactor=i(s.noonFactor,h.noonFactor,n),s.sh.r.length===h.sh.r.length)for(let t=0;t<h.sh.r.length;t++)this._sphericalHarmonics.r[t]=i(s.sh.r[t],h.sh.r[t],n),this._sphericalHarmonics.g[t]=i(s.sh.g[t],h.sh.g[t],n),this._sphericalHarmonics.b[t]=i(s.sh.b[t],h.sh.b[t],n);else for(let i=0;i<h.sh.r.length;i++)this._sphericalHarmonics.r[i]=h.sh.r[i],this._sphericalHarmonics.g[i]=h.sh.g[i],this._sphericalHarmonics.b[i]=h.sh.b[i];this.updateLegacy()}}const L=n();export{p as SceneLighting,l as SunLight,_ as ambientBoost};
