UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.08 kB
import{Vec3 as t}from"../../core/math/vec3.js";import{random as e}from"../../core/math/random.js";import{Color as a}from"../../core/math/color.js";import{Entity as i}from"../entity.js";import{SHADOW_PCF3 as o}from"../../scene/constants.js";import{BakeLight as s}from"./bake-light.js";const r=new t;class n extends s{constructor(t){const e=t.scene,s=new i("AmbientLight");s.addComponent("light",{type:"directional",affectDynamic:!0,affectLightmapped:!1,bake:!0,bakeNumSamples:e.ambientBakeNumSamples,castShadows:!0,normalOffsetBias:.05,shadowBias:.2,shadowDistance:1,shadowResolution:2048,shadowType:o,color:a.WHITE,intensity:1,bakeDir:!1}),super(e,s.light.light,t.lightingParams)}get numVirtualLights(){return this.light.bakeNumSamples}prepareVirtualLight(t,a){e.spherePointDeterministic(r,t,a,0,this.scene.ambientBakeSpherePart),this.light._node.lookAt(r.mulScalar(-1)),this.light._node.rotateLocal(90,0,0);const i=this.scene.gammaCorrection?2.2:1,o=2*Math.PI*this.scene.ambientBakeSpherePart,s=Math.pow(o,i);this.light.intensity=Math.pow(s/a,1/i)}}export{n as BakeLightAmbient};