UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.43 kB
import{Quat as o}from"../../core/math/quat.js";import{Vec3 as e}from"../../core/math/vec3.js";import{Mat4 as t}from"../../core/math/mat4.js";import{ASPECT_MANUAL as r,LIGHTTYPE_DIRECTIONAL as s,PROJECTION_ORTHOGRAPHIC as n,LIGHTTYPE_SPOT as a,PROJECTION_PERSPECTIVE as i,LIGHTTYPE_OMNI as c}from"../constants.js";import{Camera as m}from"../camera.js";import{GraphNode as l}from"../graph-node.js";const p=new t,w=new t,g=new t;class u{static create(o,e,t){const p=new m;switch(p.node=new l(o),p.aspectRatio=1,p.aspectRatioMode=r,p._scissorRectClear=!0,e){case c:p.node.setRotation(u.pointLightRotations[t]),p.fov=90,p.projection=i;break;case a:p.projection=i;break;case s:p.projection=n}return p}static evalSpotCookieMatrix(o){let t=u._spotCookieCamera;t||(t=u.create("SpotCookieCamera",a),u._spotCookieCamera=t),t.fov=2*o._outerConeAngle;const r=t._node;r.setPosition(o._node.getPosition()),r.setRotation(o._node.getRotation()),r.rotateLocal(-90,0,0),p.setTRS(r.getPosition(),r.getRotation(),e.ONE).invert(),w.mul2(t.projectionMatrix,p);const s=o.cookieMatrix,n=o.atlasViewport;return g.setViewport(n.x,n.y,n.z,n.w),s.mul2(g,w),s}}u.pointLightRotations=[(new o).setFromEulerAngles(0,90,180),(new o).setFromEulerAngles(0,-90,180),(new o).setFromEulerAngles(90,0,0),(new o).setFromEulerAngles(-90,0,0),(new o).setFromEulerAngles(0,180,180),(new o).setFromEulerAngles(0,0,180)],u._spotCookieCamera=null;export{u as LightCamera};