glyphcss 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements.cjs +5 -5
- package/dist/elements.d.cts +14 -1
- package/dist/elements.d.ts +14 -1
- package/dist/elements.js +5 -5
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +91 -23
- package/dist/index.d.ts +91 -23
- package/dist/index.js +5 -5
- package/package.json +2 -2
- /package/dist/{elements-ycVyIlYL.d.cts → GlyphMapControlsElement-ycVyIlYL.d.cts} +0 -0
- /package/dist/{elements-ycVyIlYL.d.ts → GlyphMapControlsElement-ycVyIlYL.d.ts} +0 -0
package/dist/elements.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{buildTextureSamplers as mn}from"@glyphcss/core";var Mt=Math.PI/180,xt=.01,qt=32e3,Ut=xt*1.01;function pt(n,t,e){let o=n[1],r=n[0],l=n[2],a=e*Mt,i=Math.cos(a),c=Math.sin(a),u=o*i-r*c,p=o*c+r*i,d=l,h=t*Mt,m=Math.cos(h),f=Math.sin(h),b=p*m-d*f,C=p*f+d*m;return[u,b,C]}function Ie(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??qt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let l=pt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),a=.001*1.01;if(t.eyeMode)return-l[2]-a;if(t.perspective>0){let i=l[2]*t.zoom*50-t.distance;return t.perspective-i-t.perspective*Ut}return t.distance-l[2]-a},project(r,l,a,i){let u=50/i,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=pt(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let y=t.focal/-d[2],w=d[0]*y*t.zoom*50,P=d[1]*y*t.zoom*50,H=l*e+w/u*t.stretch,v=a*o+P/50;return[H,v,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,y=d[0]*t.zoom*50,w=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,H=M-P,v=M*xt;if(H<v)return[NaN,NaN,P,NaN];let A=M/H,L=l*e+y*A/u*t.stretch*t.fovScale,s=a*o+w*A/50*t.fovScale;return[L,s,P,1/H]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,b=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,_=l*e+b/u*t.stretch*t.fovScale,x=a*o+C/50*t.fovScale;return[_,x,d[2],1/m]}}}function Ct(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,l,a,i){let u=50/i,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=pt(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=l*e+h/u*t.fovScale,b=a*o+m/50*t.fovScale;return[f,b,d[2]]}}}var Kt={direction:[-.5,-.7,-.5],intensity:1},Zt={intensity:.4};function Jt(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let l=0;l<r.length;l++){let a=r[l],i=r[(l+1)%r.length],c=`${a[0]},${a[1]},${a[2]}`,u=`${i[0]},${i[1]},${i[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:a,to:i,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function Gt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?Jt(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Kt,ambientLight:n.ambientLight??Zt,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as Qt,polygonTexture as en}from"@glyphcss/core";var Yn=" .:-=+*#%@".split(""),Dn=" .:-=+*#%@".split(""),ht={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Xn=ht.default;function mt(n){return ht[n]??ht.default}function _t(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:l,rows:a,cellAspect:i}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return tn(n,l,a,i,d)}let c=mt(n.glyphPalette),u=new Uint8Array(l*a),p=n.useColors?new Array(l*a).fill(null):null;for(let d of o){let h=t.project(d.from,l,a,i),m=t.project(d.to,l,a,i);h[0]!==h[0]||m[0]!==m[0]||un(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,l,a)}return dn(u,p,l,a,c)}function tn(n,t,e,o,r){let l=t*r,a=e*r,{camera:i,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,_=n.depthEpsilon??0,x=r>1?{zoom:i.zoom,eyeDepth:B=>i.eyeDepth(B),project:(B,X,V,Y)=>{let S=i.project(B,X,V,Y);return[X*.5+(S[0]-X*.5)*r,V*.5+(S[1]-V*.5)*r,S[2],S[3]]}}:i,M=mt(n.glyphPalette).solid,y=M.length-1,w=new Array(l*a).fill(" "),P=n.useColors,H=P?new Array(l*a).fill(null):null,v=new Float64Array(l*a).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(l*a*3).fill(NaN):null,s=u.direction,E=Math.hypot(s[0],s[1],s[2])||1,g=s[0]/E,G=s[1]/E,z=s[2]/E,F=u.intensity??1,T=p.intensity??.4,W=ze(u.color??"#ffffff"),R=ze(p.color??"#ffffff"),j=d&&h>0?an(c,h):null,N=new Map,re=n.textureSamplers??null,k=n.shadow,q=k!=null&&f.length>0?ln(c,f,g,G,z):null,oe=k?.opacity??.25,K=k?.lift??.05,Z=k?.color??"#000000",ie=q?ze(Z):[0,0,0],O=globalThis.__glyphPerfDetail,Xe=O?performance.now():0,ge=[],J=n.shadeCache??null,Q=-1,ve=(B,X,V,Y)=>{if(q===null||!Y)return null;let S=q,I=Oe(B,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),ee=Oe(X,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax),de=Oe(V,S.right[0],S.right[1],S.right[2],S.up[0],S.up[1],S.up[2],S.dir[0],S.dir[1],S.dir[2],S.uMin,S.uMax,S.vMin,S.vMax);return{map:S,luA:I[0],lvA:I[1],ldA:I[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:N}};for(let B=0;B<c.length;B++){let X=c[B],V=X.vertices;if(V.length<3)continue;let Y=X.uvs,S=null;if(re!==null&&Y&&Y.length>=V.length){let I=en(X);I&&(S=re.get(I)??null)}for(let I=0;I<V.length;I++)ge[I]=x.project(V[I],l,a,o);for(let I=1;I<V.length-1;I++){Q++;let ee=0,de=I,Ee=I+1,se=V[ee],pe=V[de],we=V[Ee],ae=ge[ee],ye=ge[de],Me=ge[Ee],rt=(ae[0]!==ae[0]?1:0)+(ye[0]!==ye[0]?1:0)+(Me[0]!==Me[0]?1:0);if(rt===3||rt===0&&!m&&(ye[0]-ae[0])*(Me[1]-ae[1])-(ye[1]-ae[1])*(Me[0]-ae[0])>0)continue;let Ge,Le,Te,Re=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],Re=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],Ae=pe[2]-se[2],me=we[0]-se[0],$e=we[1]-se[1],We=we[2]-se[2],je=he*We-Ae*$e,Ne=Ae*me-$*We,U=$*$e-he*me,D=Math.hypot(je,Ne,U)||1,te=je/D,fe=Ne/D,le=U/D,ce,_e,ot,it,st,lt,at,ct,ut;if(j){let ke=j[B],xe=ke[ee],Fe=ke[de],Ye=ke[Ee];ce=xe[0],_e=xe[1],ot=xe[2],it=Fe[0],st=Fe[1],lt=Fe[2],at=Ye[0],ct=Ye[1],ut=Ye[2]}else ce=it=at=te,_e=st=ct=fe,ot=lt=ut=le;let Et=ce*g+_e*G+ot*z,wt=it*g+st*G+lt*z,At=at*g+ct*G+ut*z,Nt=m?Math.abs(Et):Math.max(0,-Et),kt=m?Math.abs(wt):Math.max(0,-wt),Yt=m?Math.abs(At):Math.max(0,-At);if(Ge=Math.min(1,T+Nt*F),Le=Math.min(1,T+kt*F),Te=Math.min(1,T+Yt*F),P){let ke=(Ge+Le+Te)/3,xe=Math.max(0,ke-T),Fe=X.color??"#ffffff",Ye=xe*255|0,St=`${Fe}:${Ye}`,qe=N.get(St);if(qe===void 0){let dt=ze(Fe),Dt=T*R[0]/255+xe*W[0]/255,Xt=T*R[1]/255+xe*W[1]/255,Vt=T*R[2]/255+xe*W[2]/255,$t=Math.min(255,dt[0]*Dt),Wt=Math.min(255,dt[1]*Xt),jt=Math.min(255,dt[2]*Vt);qe=`#${ne($t)}${ne(Wt)}${ne(jt)}`,N.set(St,qe)}Re=qe}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=Re)}let bt=b[B]??!1,He=1+(C?.[B]??0),vt=null;if(S!==null&&Y){let $=Y[ee],he=Y[de],Ae=Y[Ee],me=Math.max(0,(Ge+Le+Te)/3-T);vt={sampler:S,ua:$[0],va:$[1],ub:he[0],vb:he[1],uc:Ae[0],vc:Ae[1],tintR:T*R[0]/255+me*W[0]/255,tintG:T*R[1]/255+me*W[1]/255,tintB:T*R[2]/255+me*W[2]/255}}if(rt===0)Lt(ae[0],ae[1],(ae[3]??ae[2])*He,Ge,ye[0],ye[1],(ye[3]??ye[2])*He,Le,Me[0],Me[1],(Me[3]??Me[2])*He,Te,M,y,Re,w,H,v,l,a,ve(se,pe,we,bt),m,se,pe,we,L,_,vt);else{let $=[],he=[],Ae=[se,pe,we],me=[Ge,Le,Te],$e=x.eyeDepth(se),We=x.eyeDepth(pe),je=x.eyeDepth(we),Ne=[$e,We,je];for(let U=0;U<3;U++){let D=(U+1)%3,te=Ne[U],fe=Ne[D];if(te>0&&($.push(Ae[U]),he.push(me[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[D];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),he.push(me[U]+le*(me[D]-me[U]))}}if($.length>=3){let U=$.map(D=>x.project(D,l,a,o));for(let D=1;D<$.length-1;D++){let te=U[0],fe=U[D],le=U[D+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!m&&ce>0||Lt(te[0],te[1],(te[3]??te[2])*He,he[0],fe[0],fe[1],(fe[3]??fe[2])*He,he[D],le[0],le[1],(le[3]??le[2])*He,he[D+1],M,y,Re,w,H,v,l,a,ve($[0],$[D],$[D+1],bt),m,$[0],$[D],$[D+1],L,_,null)}}}}}O&&(O.loop??(O.loop=[])).push(performance.now()-Xe);let yt=O?performance.now():0,Pe=w,Se=H,Ve=L;if(r>1){let B=rn(w,H,v,L,t,e,r,M);Pe=B.glyphBuf,Se=B.colorBuf,Ve=B.worldPos}A&&nn(Pe,Se,Ve,t,e,o,M,n.temporalBlend,n.temporalHistory,i);let nt=cn(Pe,Se,t,e);return O&&(O.string??(O.string=[])).push(performance.now()-yt),nt}function nn(n,t,e,o,r,l,a,i,c,u){let p=o*r,d=a.length-1,h=new Map;for(let M=0;M<a.length;M++)h.set(a[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Ie({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=y=>M.project(y,o,r,l)}let b=new Float32Array(p),C=new Float32Array(p),_=new Float32Array(p),x=new Float32Array(p);for(let M=0;M<r;M++)for(let y=0;y<o;y++){let w=M*o+y,P=h.get(n[w])??0,H=0,v=0,A=0,L=t?t[w]:null;if(L){let k=ze(L);H=k[0],v=k[1],A=k[2]}let s=0,E=0,g=0,G=0,z=0,F=e[w*3];if(f&&F===F){let k=f([F,e[w*3+1],e[w*3+2]]),q=Math.round(k[0]),oe=Math.round(k[1]);if(k[0]===k[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;E=c.idx[K],g=c.r[K],G=c.g[K],z=c.b[K],s=i}}let T=1-s,W=T*P+s*E,R=T*H+s*g,j=T*v+s*G,N=T*A+s*z;b[w]=W,C[w]=R,_[w]=j,x[w]=N;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[w]=a[re],t&&(t[w]=re===0?null:`#${ne(R)}${ne(j)}${ne(N)}`)}c.idx=b,c.r=C,c.g=_,c.b=x,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function rn(n,t,e,o,r,l,a,i){let c=new Map;for(let b=0;b<i.length;b++)c.set(i[b],b);let u=i.length-1,p=r*a,d=new Array(r*l).fill(" "),h=t?new Array(r*l).fill(null):null,m=o?new Float32Array(r*l*3).fill(NaN):null,f=1/(a*a);for(let b=0;b<l;b++)for(let C=0;C<r;C++){let _=0,x=0,M=0,y=0,w=0,P=0,H=0,v=0;for(let s=0;s<a;s++){let E=(b*a+s)*p+C*a;for(let g=0;g<a;g++){let G=E+g;if(e[G]!==-1/0){if(_+=c.get(n[G])??0,x++,h){let z=t[G];if(z){let F=ze(z);M+=F[0],y+=F[1],w+=F[2]}}m&&(P+=o[G*3],H+=o[G*3+1],v+=o[G*3+2])}}}let A=b*r+C;if(x===0)continue;let L=Math.round(_*f);L<0?L=0:L>u&&(L=u),d[A]=i[L],h&&(h[A]=`#${ne(M/x)}${ne(y/x)}${ne(w/x)}`),m&&(m[A*3]=P/x,m[A*3+1]=H/x,m[A*3+2]=v/x)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var on=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Oe(n,t,e,o,r,l,a,i,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],b=r*n[0]+l*n[1]+a*n[2],C=-(i*n[0]+c*n[1]+u*n[2]),_=(f-p)/(d-p)*(be-1),x=(b-h)/(m-h)*(be-1);return[_,x,C]}function sn(n,t,e,o){let r=t[0],l=t[1],a=t[2],i=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(i-r)*(d-l)-(c-l)*(p-r);if(m===0)return;let f=1/m,b=r<i?r:i;p<b&&(b=p);let C=r>i?r:i;p>C&&(C=p);let _=l<c?l:c;d<_&&(_=d);let x=l>c?l:c;d>x&&(x=d);let M=Math.max(0,Math.ceil(b)),y=Math.min(be-1,Math.floor(C)),w=Math.max(0,Math.ceil(_)),P=Math.min(be-1,Math.floor(x));if(M>y||w>P)return;let H=m>0;for(let v=w;v<=P;v++)for(let A=M;A<=y;A++){let L=A,s=v,E=(i-L)*(d-s)-(c-s)*(p-L),g=(p-L)*(l-s)-(d-s)*(r-L),G=(r-L)*(c-s)-(l-s)*(i-L);if(H?E<0||g<0||G<0:E>0||g>0||G>0)continue;let z=(E*a+g*u+G*h)*f,F=v*be+A;z>n[F]&&(n[F]=z)}}function ln(n,t,e,o,r){let l,a,i;Math.abs(e)<.9?(l=0,a=r,i=-o):(l=-r,a=0,i=e);let c=Math.hypot(l,a,i);l/=c,a/=c,i/=c;let u=a*r-i*o,p=i*e-l*r,d=l*o-a*e,h=1/0,m=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(t[y]){C=!0;for(let w of n[y].vertices){let P=l*w[0]+a*w[1]+i*w[2],H=u*w[0]+p*w[1]+d*w[2];P<h&&(h=P),P>m&&(m=P),H<f&&(f=H),H>b&&(b=H)}}if(!C)return null;let _=(m-h)*.05+.01,x=(b-f)*.05+.01;h-=_,m+=_,f-=x,b+=x;let M=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let w=n[y].vertices;if(!(w.length<3))for(let P=1;P<w.length-1;P++){let H=w[0],v=w[P],A=w[P+1],L=Oe(H,l,a,i,u,p,d,e,o,r,h,m,f,b),s=Oe(v,l,a,i,u,p,d,e,o,r,h,m,f,b),E=Oe(A,l,a,i,u,p,d,e,o,r,h,m,f,b);sn(M,L,s,E)}}return{buf:M,right:[l,a,i],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:b}}function Lt(n,t,e,o,r,l,a,i,c,u,p,d,h,m,f,b,C,_,x,M,y,w,P,H,v,A,L,s){let E=(r-n)*(u-t)-(l-t)*(c-n);if(E===0||!w&&E>0)return;let g=1/E,G=E>0,z=n<r?n:r;c<z&&(z=c);let F=n>r?n:r;c>F&&(F=c);let T=t<l?t:l;u<T&&(T=u);let W=t>l?t:l;u>W&&(W=u);let R=Math.max(0,Math.ceil(z)),j=Math.min(x-1,Math.floor(F)),N=Math.max(0,Math.ceil(T)),re=Math.min(M-1,Math.floor(W));if(!(R>j||N>re))for(let k=N;k<=re;k++){let q=k;for(let oe=R;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(l-q)*(c-K),ie=(c-K)*(t-q)-(u-q)*(n-K),O=(n-K)*(l-q)-(t-q)*(r-K);if(G?Z<0||ie<0||O<0:Z>0||ie>0||O>0)continue;let Xe=(Z*e+ie*a+O*p)*g,ge=k*x+oe,J=_[ge];if(Xe>(J>0?J*(1-L):J)){if(_[ge]=Xe,A!==null){let X=ge*3;A[X]=(Z*P[0]+ie*H[0]+O*v[0])*g,A[X+1]=(Z*P[1]+ie*H[1]+O*v[1])*g,A[X+2]=(Z*P[2]+ie*H[2]+O*v[2])*g}let Q=(Z*o+ie*i+O*d)*g,ve=f;if(s!==null){let X=(Z*s.ua+ie*s.ub+O*s.uc)*g,V=(Z*s.va+ie*s.vb+O*s.vc)*g,Y=Qt(s.sampler,X,V);if(Y!==null&&Y.a>8){let S=Y.r*s.tintR|0;S>255&&(S=255);let I=Y.g*s.tintG|0;I>255&&(I=255);let ee=Y.b*s.tintB|0;ee>255&&(ee=255),ve=`#${ne(S)}${ne(I)}${ne(ee)}`,Q*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Pe=(Q<0?0:Q>1?1:Q)*m,Se=Pe|0,Ve=Pe-Se,nt=on[(k&3)*4+(oe&3)],B=Ve>nt&&Se<m?Se+1:Se;if(B>m&&(B=m),y!==null){let X=(Z*y.luA+ie*y.luB+O*y.luC)*g,V=(Z*y.lvA+ie*y.lvB+O*y.lvC)*g,Y=(Z*y.ldA+ie*y.ldB+O*y.ldC)*g,S=X|0,I=V|0;if(S>=0&&S<be&&I>=0&&I<be){let ee=y.map.buf[I*be+S];if(ee>-1/0&&Y+y.lift<ee&&(B=Math.max(0,B-Math.round(y.opacity*m)),ve!==null)){let de=`shadow:${ve}:${B}`,Ee=y.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=y.shadowColorRgb,we=Math.round(se[0]*(1-y.opacity)+pe[0]*y.opacity),ae=Math.round(se[1]*(1-y.opacity)+pe[1]*y.opacity),ye=Math.round(se[2]*(1-y.opacity)+pe[2]*y.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ye)}`,y.litCache.set(de,Ee)}ve=Ee}}}b[ge]=h[B],C&&(C[ge]=ve)}}}}function an(n,t){let e=n.length,o=new Array(e);for(let i=0;i<e;i++){let c=n[i].vertices;if(c.length<3){o[i]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],b=d[0]-u[0],C=d[1]-u[1],_=d[2]-u[2],x=m*_-f*C,M=f*b-h*_,y=h*C-m*b,w=Math.hypot(x,M,y)||1;o[i]=[x/w,M/w,y/w]}let r=new Map;for(let i=0;i<e;i++){let c=n[i].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==i)&&h.push(i)}}let l=Math.cos(t*Math.PI/180),a=new Array(e);for(let i=0;i<e;i++){let c=n[i].vertices,u=o[i],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,b=0,C=0;for(let x=0;x<m.length;x++){let M=m[x],y=o[M];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=l&&(f+=y[0],b+=y[1],C+=y[2])}let _=Math.hypot(f,b,C)||1;p[d]=[f/_,b/_,C/_]}a[i]=p}return a}function cn(n,t,e,o){let r=[],l=null,a="",i=()=>{a&&(l!==null?r.push(`<span style="color:${l}">${a}</span>`):r.push(a),a="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==l&&(i(),l=h),a+=d}i(),l=null,c<o-1&&r.push(`
|
|
2
|
-
`)}return r.join("")}function
|
|
3
|
-
`)}return
|
|
1
|
+
import{buildTextureSamplers as Ln}from"@glyphcss/core";var Pt=Math.PI/180,Ht=.01,cn=32e3,un=Ht*1.01;function bt(n,t,e){let o=n[1],r=n[0],s=n[2],i=e*Pt,l=Math.cos(i),a=Math.sin(i),u=o*l-r*a,m=o*a+r*l,c=s,h=t*Pt,p=Math.cos(h),f=Math.sin(h),g=m*p-c*f,E=m*f+c*p;return[u,g,E]}function Ie(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??cn,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let s=bt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),i=.001*1.01;if(t.eyeMode)return-s[2]-i;if(t.perspective>0){let l=s[2]*t.zoom*50-t.distance;return t.perspective-l-t.perspective*un}return t.distance-s[2]-i},project(r,s,i,l){let u=50/l,m=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=bt(m,t.rotX,t.rotY);if(t.eyeMode){if(c[2]>=-.001)return[NaN,NaN,c[2],NaN];let y=t.focal/-c[2],A=c[0]*y*t.zoom*50,F=c[1]*y*t.zoom*50,z=s*e+A/u*t.stretch,O=i*o+F/50;return[z,O,c[2],-1/c[2]]}if(t.perspective>0){let x=t.perspective,y=c[0]*t.zoom*50,A=c[1]*t.zoom*50,F=c[2]*t.zoom*50-t.distance,z=x-F,O=x*Ht;if(z<O)return[NaN,NaN,F,NaN];let M=x/z,H=s*e+y*M/u*t.stretch*t.fovScale,d=i*o+A*M/50*t.fovScale;return[H,d,F,1/z]}let h=.001,p=t.distance-c[2];if(p<h)return[NaN,NaN,c[2],NaN];let f=t.distance/p,g=c[0]*f*t.zoom*50,E=c[1]*f*t.zoom*50,_=s*e+g/u*t.stretch*t.fovScale,T=i*o+E/50*t.fovScale;return[_,T,c[2],1/p]}}}function kt(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,s,i,l){let u=50/l,m=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=bt(m,t.rotX,t.rotY),h=c[0]*t.zoom*50,p=c[1]*t.zoom*50,f=s*e+h/u*t.fovScale,g=i*o+p/50*t.fovScale;return[f,g,c[2]]}}}var dn={direction:[-.5,-.7,-.5],intensity:1},hn={intensity:.4};function pn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let i=r[s],l=r[(s+1)%r.length],a=`${i[0]},${i[1]},${i[2]}`,u=`${l[0]},${l[1]},${l[2]}`,m=a<u?`${a}|${u}`:`${u}|${a}`;if(t.has(m))continue;t.add(m);let c={from:i,to:l,weight:2};o.color&&(c.color=o.color),e.push(c)}}return e}function zt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?pn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??dn,ambientLight:n.ambientLight??hn,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as mn,polygonTexture as fn}from"@glyphcss/core";var ir=" .:-=+*#%@".split(""),sr=" .:-=+*#%@".split(""),vt={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},lr=vt.default;function Et(n){return vt[n]??vt.default}function It(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:s,rows:i,cellAspect:l}=e;if(r==="solid"){let c=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return yn(n,s,i,l,c)}let a=Et(n.glyphPalette),u=new Uint8Array(s*i),m=n.useColors?new Array(s*i).fill(null):null;for(let c of o){let h=t.project(c.from,s,i,l),p=t.project(c.to,s,i,l);h[0]!==h[0]||p[0]!==p[0]||wn(u,m,h[0]|0,h[1]|0,p[0]|0,p[1]|0,c.weight??2,c.color??null,s,i)}return Gn(u,m,s,i,a)}function yn(n,t,e,o,r){let s=t*r,i=e*r,{camera:l,polygons:a,directionalLight:u,ambientLight:m,smoothShading:c,creaseAngle:h,doubleSided:p,castShadowFlags:f,receiveShadowFlags:g}=n,E=n.depthBiases,_=n.depthEpsilon??0,T=r>1?{zoom:l.zoom,eyeDepth:j=>l.eyeDepth(j),project:(j,J,Q,q)=>{let G=l.project(j,J,Q,q);return[J*.5+(G[0]-J*.5)*r,Q*.5+(G[1]-Q*.5)*r,G[2],G[3]]}}:l,x=Et(n.glyphPalette).solid,y=x.length-1,A=new Array(s*i).fill(" "),F=n.useColors,z=F?new Array(s*i).fill(null):null,O=new Float64Array(s*i).fill(-1/0),M=n.temporalBlend>0&&!!n.temporalHistory,H=M?new Float32Array(s*i*3).fill(NaN):null,d=u.direction,S=Math.hypot(d[0],d[1],d[2])||1,b=d[0]/S,P=d[1]/S,C=d[2]/S,k=u.intensity??1,L=m.intensity??.4,w=He(u.color??"#ffffff"),v=He(m.color??"#ffffff"),I=c&&h>0?An(a,h):null,R=new Map,B=n.textureSamplers??null,Y=n.shadow,N=Y!=null&&f.length>0?Cn(a,f,b,P,C):null,W=Y?.opacity??.25,$=Y?.lift??.05,V=Y?.color??"#000000",te=N?He(V):[0,0,0],D=globalThis.__glyphPerfDetail,ke=D?performance.now():0,ae=[],Z=n.shadeCache??null,U=-1,ve=(j,J,Q,q)=>{if(N===null||!q)return null;let G=N,X=Re(j,G.right[0],G.right[1],G.right[2],G.up[0],G.up[1],G.up[2],G.dir[0],G.dir[1],G.dir[2],G.uMin,G.uMax,G.vMin,G.vMax),re=Re(J,G.right[0],G.right[1],G.right[2],G.up[0],G.up[1],G.up[2],G.dir[0],G.dir[1],G.dir[2],G.uMin,G.uMax,G.vMin,G.vMax),he=Re(Q,G.right[0],G.right[1],G.right[2],G.up[0],G.up[1],G.up[2],G.dir[0],G.dir[1],G.dir[2],G.uMin,G.uMax,G.vMin,G.vMax);return{map:G,luA:X[0],lvA:X[1],ldA:X[2],luB:re[0],lvB:re[1],ldB:re[2],luC:he[0],lvC:he[1],ldC:he[2],lift:$,opacity:W,shadowColorRgb:te,shadowColorHex:V,litCache:R}};for(let j=0;j<a.length;j++){let J=a[j],Q=J.vertices;if(Q.length<3)continue;let q=J.uvs,G=null;if(B!==null&&q&&q.length>=Q.length){let X=fn(J);X&&(G=B.get(X)??null)}for(let X=0;X<Q.length;X++)ae[X]=T.project(Q[X],s,i,o);for(let X=1;X<Q.length-1;X++){U++;let re=0,he=X,Ee=X+1,se=Q[re],pe=Q[he],Ce=Q[Ee],ce=ae[re],ge=ae[he],Ge=ae[Ee],ct=(ce[0]!==ce[0]?1:0)+(ge[0]!==ge[0]?1:0)+(Ge[0]!==Ge[0]?1:0);if(ct===3||ct===0&&!p&&(ge[0]-ce[0])*(Ge[1]-ce[1])-(ge[1]-ce[1])*(Ge[0]-ce[0])>0)continue;let Le,Te,_e,Xe=null;if(Z!==null&&Z.iA[U]!==void 0)Le=Z.iA[U],Te=Z.iB[U],_e=Z.iC[U],Xe=Z.lit[U];else{let ee=pe[0]-se[0],me=pe[1]-se[1],Ae=pe[2]-se[2],fe=Ce[0]-se[0],Ze=Ce[1]-se[1],Ue=Ce[2]-se[2],Je=me*Ue-Ae*Ze,je=Ae*fe-ee*Ue,ne=ee*Ze-me*fe,K=Math.hypot(Je,je,ne)||1,oe=Je/K,ye=je/K,le=ne/K,ue,Pe,ut,dt,ht,pt,mt,ft,yt;if(I){let $e=I[j],xe=$e[re],Oe=$e[he],We=$e[Ee];ue=xe[0],Pe=xe[1],ut=xe[2],dt=Oe[0],ht=Oe[1],pt=Oe[2],mt=We[0],ft=We[1],yt=We[2]}else ue=dt=mt=oe,Pe=ht=ft=ye,ut=pt=yt=le;let Mt=ue*b+Pe*P+ut*C,Lt=dt*b+ht*P+pt*C,Tt=mt*b+ft*P+yt*C,Qt=p?Math.abs(Mt):Math.max(0,-Mt),en=p?Math.abs(Lt):Math.max(0,-Lt),tn=p?Math.abs(Tt):Math.max(0,-Tt);if(Le=Math.min(1,L+Qt*k),Te=Math.min(1,L+en*k),_e=Math.min(1,L+tn*k),F){let $e=(Le+Te+_e)/3,xe=Math.max(0,$e-L),Oe=J.color??"#ffffff",We=xe*255|0,_t=`${Oe}:${We}`,Qe=R.get(_t);if(Qe===void 0){let gt=He(Oe),nn=L*v[0]/255+xe*w[0]/255,rn=L*v[1]/255+xe*w[1]/255,on=L*v[2]/255+xe*w[2]/255,sn=Math.min(255,gt[0]*nn),ln=Math.min(255,gt[1]*rn),an=Math.min(255,gt[2]*on);Qe=`#${ie(sn)}${ie(ln)}${ie(an)}`,R.set(_t,Qe)}Xe=Qe}Z!==null&&(Z.iA[U]=Le,Z.iB[U]=Te,Z.iC[U]=_e,Z.lit[U]=Xe)}let Gt=g[j]??!1,Fe=1+(E?.[j]??0),xt=null;if(G!==null&&q){let ee=q[re],me=q[he],Ae=q[Ee],fe=Math.max(0,(Le+Te+_e)/3-L);xt={sampler:G,ua:ee[0],va:ee[1],ub:me[0],vb:me[1],uc:Ae[0],vc:Ae[1],tintR:L*v[0]/255+fe*w[0]/255,tintG:L*v[1]/255+fe*w[1]/255,tintB:L*v[2]/255+fe*w[2]/255}}if(ct===0)Ft(ce[0],ce[1],(ce[3]??ce[2])*Fe,Le,ge[0],ge[1],(ge[3]??ge[2])*Fe,Te,Ge[0],Ge[1],(Ge[3]??Ge[2])*Fe,_e,x,y,Xe,A,z,O,s,i,ve(se,pe,Ce,Gt),p,se,pe,Ce,H,_,xt);else{let ee=[],me=[],Ae=[se,pe,Ce],fe=[Le,Te,_e],Ze=T.eyeDepth(se),Ue=T.eyeDepth(pe),Je=T.eyeDepth(Ce),je=[Ze,Ue,Je];for(let ne=0;ne<3;ne++){let K=(ne+1)%3,oe=je[ne],ye=je[K];if(oe>0&&(ee.push(Ae[ne]),me.push(fe[ne])),oe>0!=ye>0){let le=oe/(oe-ye),ue=Ae[ne],Pe=Ae[K];ee.push([ue[0]+le*(Pe[0]-ue[0]),ue[1]+le*(Pe[1]-ue[1]),ue[2]+le*(Pe[2]-ue[2])]),me.push(fe[ne]+le*(fe[K]-fe[ne]))}}if(ee.length>=3){let ne=ee.map(K=>T.project(K,s,i,o));for(let K=1;K<ee.length-1;K++){let oe=ne[0],ye=ne[K],le=ne[K+1],ue=(ye[0]-oe[0])*(le[1]-oe[1])-(ye[1]-oe[1])*(le[0]-oe[0]);!p&&ue>0||Ft(oe[0],oe[1],(oe[3]??oe[2])*Fe,me[0],ye[0],ye[1],(ye[3]??ye[2])*Fe,me[K],le[0],le[1],(le[3]??le[2])*Fe,me[K+1],x,y,Xe,A,z,O,s,i,ve(ee[0],ee[K],ee[K+1],Gt),p,ee[0],ee[K],ee[K+1],H,_,null)}}}}}D&&(D.loop??(D.loop=[])).push(performance.now()-ke);let wt=D?performance.now():0,ze=A,we=z,Ke=H;if(r>1){let j=bn(A,z,O,H,t,e,r,x);ze=j.glyphBuf,we=j.colorBuf,Ke=j.worldPos}M&&gn(ze,we,Ke,t,e,o,x,n.temporalBlend,n.temporalHistory,l);let at=Sn(ze,we,t,e);return D&&(D.string??(D.string=[])).push(performance.now()-wt),at}function gn(n,t,e,o,r,s,i,l,a,u){let m=o*r,c=i.length-1,h=new Map;for(let x=0;x<i.length;x++)h.set(i[x],x);let p=a.cam;(a.cols!==o||a.rows!==r||a.idx.length!==m)&&(a.cols=o,a.rows=r,a.idx=new Float32Array(m),a.r=new Float32Array(m),a.g=new Float32Array(m),a.b=new Float32Array(m),p=null);let f=null;if(p){let x=Ie({rotX:p.rotX,rotY:p.rotY,distance:p.distance,perspective:p.perspective,zoom:p.zoom,stretch:p.stretch});x.target=p.target,f=y=>x.project(y,o,r,s)}let g=new Float32Array(m),E=new Float32Array(m),_=new Float32Array(m),T=new Float32Array(m);for(let x=0;x<r;x++)for(let y=0;y<o;y++){let A=x*o+y,F=h.get(n[A])??0,z=0,O=0,M=0,H=t?t[A]:null;if(H){let Y=He(H);z=Y[0],O=Y[1],M=Y[2]}let d=0,S=0,b=0,P=0,C=0,k=e[A*3];if(f&&k===k){let Y=f([k,e[A*3+1],e[A*3+2]]),N=Math.round(Y[0]),W=Math.round(Y[1]);if(Y[0]===Y[0]&&N>=0&&N<o&&W>=0&&W<r){let $=W*o+N;S=a.idx[$],b=a.r[$],P=a.g[$],C=a.b[$],d=l}}let L=1-d,w=L*F+d*S,v=L*z+d*b,I=L*O+d*P,R=L*M+d*C;g[A]=w,E[A]=v,_[A]=I,T[A]=R;let B=Math.round(w);B<0?B=0:B>c&&(B=c),n[A]=i[B],t&&(t[A]=B===0?null:`#${ie(v)}${ie(I)}${ie(R)}`)}a.idx=g,a.r=E,a.g=_,a.b=T,a.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function bn(n,t,e,o,r,s,i,l){let a=new Map;for(let g=0;g<l.length;g++)a.set(l[g],g);let u=l.length-1,m=r*i,c=new Array(r*s).fill(" "),h=t?new Array(r*s).fill(null):null,p=o?new Float32Array(r*s*3).fill(NaN):null,f=1/(i*i);for(let g=0;g<s;g++)for(let E=0;E<r;E++){let _=0,T=0,x=0,y=0,A=0,F=0,z=0,O=0;for(let d=0;d<i;d++){let S=(g*i+d)*m+E*i;for(let b=0;b<i;b++){let P=S+b;if(e[P]!==-1/0){if(_+=a.get(n[P])??0,T++,h){let C=t[P];if(C){let k=He(C);x+=k[0],y+=k[1],A+=k[2]}}p&&(F+=o[P*3],z+=o[P*3+1],O+=o[P*3+2])}}}let M=g*r+E;if(T===0)continue;let H=Math.round(_*f);H<0?H=0:H>u&&(H=u),c[M]=l[H],h&&(h[M]=`#${ie(x/T)}${ie(y/T)}${ie(A/T)}`),p&&(p[M*3]=F/T,p[M*3+1]=z/T,p[M*3+2]=O/T)}return{glyphBuf:c,colorBuf:h,worldPos:p}}var vn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Re(n,t,e,o,r,s,i,l,a,u,m,c,h,p){let f=t*n[0]+e*n[1]+o*n[2],g=r*n[0]+s*n[1]+i*n[2],E=-(l*n[0]+a*n[1]+u*n[2]),_=(f-m)/(c-m)*(be-1),T=(g-h)/(p-h)*(be-1);return[_,T,E]}function En(n,t,e,o){let r=t[0],s=t[1],i=t[2],l=e[0],a=e[1],u=e[2],m=o[0],c=o[1],h=o[2],p=(l-r)*(c-s)-(a-s)*(m-r);if(p===0)return;let f=1/p,g=r<l?r:l;m<g&&(g=m);let E=r>l?r:l;m>E&&(E=m);let _=s<a?s:a;c<_&&(_=c);let T=s>a?s:a;c>T&&(T=c);let x=Math.max(0,Math.ceil(g)),y=Math.min(be-1,Math.floor(E)),A=Math.max(0,Math.ceil(_)),F=Math.min(be-1,Math.floor(T));if(x>y||A>F)return;let z=p>0;for(let O=A;O<=F;O++)for(let M=x;M<=y;M++){let H=M,d=O,S=(l-H)*(c-d)-(a-d)*(m-H),b=(m-H)*(s-d)-(c-d)*(r-H),P=(r-H)*(a-d)-(s-d)*(l-H);if(z?S<0||b<0||P<0:S>0||b>0||P>0)continue;let C=(S*i+b*u+P*h)*f,k=O*be+M;C>n[k]&&(n[k]=C)}}function Cn(n,t,e,o,r){let s,i,l;Math.abs(e)<.9?(s=0,i=r,l=-o):(s=-r,i=0,l=e);let a=Math.hypot(s,i,l);s/=a,i/=a,l/=a;let u=i*r-l*o,m=l*e-s*r,c=s*o-i*e,h=1/0,p=-1/0,f=1/0,g=-1/0,E=!1;for(let y=0;y<n.length;y++)if(t[y]){E=!0;for(let A of n[y].vertices){let F=s*A[0]+i*A[1]+l*A[2],z=u*A[0]+m*A[1]+c*A[2];F<h&&(h=F),F>p&&(p=F),z<f&&(f=z),z>g&&(g=z)}}if(!E)return null;let _=(p-h)*.05+.01,T=(g-f)*.05+.01;h-=_,p+=_,f-=T,g+=T;let x=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let A=n[y].vertices;if(!(A.length<3))for(let F=1;F<A.length-1;F++){let z=A[0],O=A[F],M=A[F+1],H=Re(z,s,i,l,u,m,c,e,o,r,h,p,f,g),d=Re(O,s,i,l,u,m,c,e,o,r,h,p,f,g),S=Re(M,s,i,l,u,m,c,e,o,r,h,p,f,g);En(x,H,d,S)}}return{buf:x,right:[s,i,l],up:[u,m,c],dir:[e,o,r],uMin:h,uMax:p,vMin:f,vMax:g}}function Ft(n,t,e,o,r,s,i,l,a,u,m,c,h,p,f,g,E,_,T,x,y,A,F,z,O,M,H,d){let S=(r-n)*(u-t)-(s-t)*(a-n);if(S===0||!A&&S>0)return;let b=1/S,P=S>0,C=n<r?n:r;a<C&&(C=a);let k=n>r?n:r;a>k&&(k=a);let L=t<s?t:s;u<L&&(L=u);let w=t>s?t:s;u>w&&(w=u);let v=Math.max(0,Math.ceil(C)),I=Math.min(T-1,Math.floor(k)),R=Math.max(0,Math.ceil(L)),B=Math.min(x-1,Math.floor(w));if(!(v>I||R>B))for(let Y=R;Y<=B;Y++){let N=Y;for(let W=v;W<=I;W++){let $=W,V=(r-$)*(u-N)-(s-N)*(a-$),te=(a-$)*(t-N)-(u-N)*(n-$),D=(n-$)*(s-N)-(t-N)*(r-$);if(P?V<0||te<0||D<0:V>0||te>0||D>0)continue;let ke=(V*e+te*i+D*m)*b,ae=Y*T+W,Z=_[ae];if(ke>(Z>0?Z*(1-H):Z)){if(_[ae]=ke,M!==null){let J=ae*3;M[J]=(V*F[0]+te*z[0]+D*O[0])*b,M[J+1]=(V*F[1]+te*z[1]+D*O[1])*b,M[J+2]=(V*F[2]+te*z[2]+D*O[2])*b}let U=(V*o+te*l+D*c)*b,ve=f;if(d!==null){let J=(V*d.ua+te*d.ub+D*d.uc)*b,Q=(V*d.va+te*d.vb+D*d.vc)*b,q=mn(d.sampler,J,Q);if(q!==null&&q.a>8){let G=q.r*d.tintR|0;G>255&&(G=255);let X=q.g*d.tintG|0;X>255&&(X=255);let re=q.b*d.tintB|0;re>255&&(re=255),ve=`#${ie(G)}${ie(X)}${ie(re)}`,U*=(.299*q.r+.587*q.g+.114*q.b)/255}}let ze=(U<0?0:U>1?1:U)*p,we=ze|0,Ke=ze-we,at=vn[(Y&3)*4+(W&3)],j=Ke>at&&we<p?we+1:we;if(j>p&&(j=p),y!==null){let J=(V*y.luA+te*y.luB+D*y.luC)*b,Q=(V*y.lvA+te*y.lvB+D*y.lvC)*b,q=(V*y.ldA+te*y.ldB+D*y.ldC)*b,G=J|0,X=Q|0;if(G>=0&&G<be&&X>=0&&X<be){let re=y.map.buf[X*be+G];if(re>-1/0&&q+y.lift<re&&(j=Math.max(0,j-Math.round(y.opacity*p)),ve!==null)){let he=`shadow:${ve}:${j}`,Ee=y.litCache.get(he);if(Ee===void 0){let se=He(ve),pe=y.shadowColorRgb,Ce=Math.round(se[0]*(1-y.opacity)+pe[0]*y.opacity),ce=Math.round(se[1]*(1-y.opacity)+pe[1]*y.opacity),ge=Math.round(se[2]*(1-y.opacity)+pe[2]*y.opacity);Ee=`#${ie(Ce)}${ie(ce)}${ie(ge)}`,y.litCache.set(he,Ee)}ve=Ee}}}g[ae]=h[j],E&&(E[ae]=ve)}}}}function An(n,t){let e=n.length,o=new Array(e);for(let l=0;l<e;l++){let a=n[l].vertices;if(a.length<3){o[l]=[0,0,0];continue}let u=a[0],m=a[1],c=a[2],h=m[0]-u[0],p=m[1]-u[1],f=m[2]-u[2],g=c[0]-u[0],E=c[1]-u[1],_=c[2]-u[2],T=p*_-f*E,x=f*g-h*_,y=h*E-p*g,A=Math.hypot(T,x,y)||1;o[l]=[T/A,x/A,y/A]}let r=new Map;for(let l=0;l<e;l++){let a=n[l].vertices;for(let u=0;u<a.length;u++){let m=a[u],c=`${m[0]},${m[1]},${m[2]}`,h=r.get(c);h||(h=[],r.set(c,h)),(h.length===0||h[h.length-1]!==l)&&h.push(l)}}let s=Math.cos(t*Math.PI/180),i=new Array(e);for(let l=0;l<e;l++){let a=n[l].vertices,u=o[l],m=new Array(a.length);for(let c=0;c<a.length;c++){let h=a[c],p=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,g=0,E=0;for(let T=0;T<p.length;T++){let x=p[T],y=o[x];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=s&&(f+=y[0],g+=y[1],E+=y[2])}let _=Math.hypot(f,g,E)||1;m[c]=[f/_,g/_,E/_]}i[l]=m}return i}function Sn(n,t,e,o){let r=[],s=null,i="",l=()=>{i&&(s!==null?r.push(`<span style="color:${s}">${i}</span>`):r.push(i),i="")};for(let a=0;a<o;a++){for(let u=0;u<e;u++){let m=a*e+u,c=n[m],h=t&&c!==" "?t[m]??null:null;h!==s&&(l(),s=h),i+=c}l(),s=null,a<o-1&&r.push(`
|
|
2
|
+
`)}return r.join("")}function wn(n,t,e,o,r,s,i,l,a,u){let m=Math.abs(r-e),c=-Math.abs(s-o),h=e<r?1:-1,p=o<s?1:-1,f=m+c;for(;;){if(e>=0&&e<a&&o>=0&&o<u){let E=o*a+e;n[E]<i&&(n[E]=i,t&&(t[E]=l))}if(e===r&&o===s)break;let g=2*f;g>=c&&(f+=c,e+=h),g<=m&&(f+=m,o+=p)}}function Gn(n,t,e,o,r){let s=[],i=null,l="",a=()=>{l&&(i!==null?s.push(`<span style="color:${i}">${l}</span>`):s.push(l),l="")};for(let u=0;u<o;u++){for(let m=0;m<e;m++){let c=u*e+m,h=n[c],p,f;h===0?(p=" ",f=null):(p=h===1?r.thin[Math.random()*r.thin.length|0]:h===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[c]??null:null),f!==i&&(a(),i=f),l+=p}a(),i=null,u<o-1&&s.push(`
|
|
3
|
+
`)}return s.join("")}var Ot=new Map;function He(n){let t=Ot.get(n);if(t!==void 0)return t;let e=xn(n);return Ot.set(n,e),e}function xn(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function ie(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Rt="glyph-styles";function Bt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Rt))return;let e=t.createElement("style");e.id=Rt,e.textContent=Mn,t.head.appendChild(e)}var Mn=`
|
|
4
4
|
/* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5
5
|
|
|
6
6
|
.glyph-host {
|
|
@@ -59,5 +59,5 @@ import{buildTextureSamplers as mn}from"@glyphcss/core";var Mt=Math.PI/180,xt=.01
|
|
|
59
59
|
the content from the 3D vertex being labelled. */
|
|
60
60
|
transform: translate(-50%, -50%);
|
|
61
61
|
}
|
|
62
|
-
`;function
|
|
63
|
-
`),E.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(E);let g=E.getBoundingClientRect();return E.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function v(){let s=n.clientWidth,E=n.clientHeight;if(!s||!E)return;let g=H(),G=Math.max(20,Math.floor(s/g.w)),z=Math.max(8,Math.floor(E/g.h)),F=g.h/g.w,T=!1;e.cols!==G&&(e.cols=G,T=!0),e.rows!==z&&(e.rows=z,T=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,T=!0),T&&b()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>v()),A.observe(n),v());function L(){A&&(A.disconnect(),A=null),a.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:x,addHotspot:M,rerender:y,setOptions:w,getOptions:P,fit:v,destroy:L}}var yn=typeof HTMLElement<"u"?HTMLElement:class{},bn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Ce(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function vn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function En(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Ue=class extends yn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...bn]}getScene(){return this._scene}_readOptions(){let e={},o=vn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let l=En(this.getAttribute("use-colors"));l!==void 0&&(e.useColors=l);let a=Ce(this.getAttribute("cols"));a!==void 0&&(e.cols=a);let i=Ce(this.getAttribute("rows"));i!==void 0&&(e.rows=i);let c=Ce(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Ce(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Ce(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Ce(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Ce(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let b=Ce(this.getAttribute("shadow-max-extend"));b!==void 0&&(d.maxExtend=b),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Ft(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as wn,resolveGeometry as An,recenterPolygons as Sn}from"@glyphcss/core";var Mn=typeof HTMLElement<"u"?HTMLElement:class{},xn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function ft(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Cn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return ft(n)}}function Gn(n){return n.closest("glyph-scene")??null}var Ke=class extends Mn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...xn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:ft(this.getAttribute("position")),scale:Cn(this.getAttribute("scale")),rotation:ft(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Gn(this);if(r){if(!r.getScene()){let l=()=>{r.removeEventListener("glyphcss:scene-ready",l),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",l);return}if(e){let l=++this._loadToken,a;try{a=await wn(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(l!==this._loadToken){try{a.dispose()}catch{}return}let i=r.getScene();if(!i){try{a.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?Sn(a.polygons):a.polygons;this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let l=r.getScene();if(!l)return;let a=this.getAttribute("size"),i=a!==null?parseFloat(a):1,c=this.getAttribute("color")??void 0,u;try{u=An(o,{size:Number.isFinite(i)?i:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=l.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Ln=typeof HTMLElement<"u"?HTMLElement:class{};function Tn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function _n(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function zn(n){return n.closest("glyph-scene")??null}var Ze=class extends Ln{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Tn(this.getAttribute("at"));if(!e)return;let o=zn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let l=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),a=_n(this.getAttribute("size"));this._handle=r.addHotspot({id:l,at:e,size:a},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:l},bubbles:!0})));let i=this._handle.el;for(;this.firstChild;)i.appendChild(this.firstChild)}};var Pn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Je=class extends Pn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ie({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let l=this._camera;if(!l)return;let a=ue(this.getAttribute("rot-x")),i=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),h=!1;a!==void 0&&l.rotX!==a&&(l.rotX=a,h=!0),i!==void 0&&l.rotY!==i&&(l.rotY=i,h=!0),c!==void 0&&l.distance!==c&&(l.distance=c,h=!0),u!==void 0&&l.perspective!==u&&(l.perspective=u,h=!0),p!==void 0&&l.zoom!==p&&(l.zoom=p,h=!0),d!==void 0&&l.stretch!==d&&(l.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Hn=typeof HTMLElement<"u"?HTMLElement:class{};function Be(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var De=class extends Hn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ct({rotX:Be(this.getAttribute("rot-x")),rotY:Be(this.getAttribute("rot-y")),zoom:Be(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let l=this._camera;if(!l)return;let a=Be(this.getAttribute("rot-x")),i=Be(this.getAttribute("rot-y")),c=Be(this.getAttribute("zoom")),u=!1;a!==void 0&&l.rotX!==a&&(l.rotX=a,u=!0),i!==void 0&&l.rotY!==i&&(l.rotY=i,u=!0),c!==void 0&&l.zoom!==c&&(l.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function Ot(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=It(t.invert),a=t.clampPitch??!0,i=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function b(v){if(!(!o||c)&&h===null&&v.isPrimary!==!1){v.preventDefault(),h=v.pointerId,m={x:v.clientX,y:v.clientY},e.style.cursor="grabbing";try{v.target.setPointerCapture(v.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function C(v){if(h===null||v.pointerId!==h||!o||c)return;v.preventDefault();let A=v.clientX-m.x,L=v.clientY-m.y;m={x:v.clientX,y:v.clientY};let s=l,E=1/4;f.rotY=f.rotY-A*E*s;let g=f.rotX-L*E*s;f.rotX=a?Math.max(-90,Math.min(90,g)):g,n.rerender()}function _(v){if(h===v.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{v.target.releasePointerCapture(v.pointerId)}catch{}i&&(u=!1)}}function x(v){if(!r||c)return;v.preventDefault();let A=v.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(v){if(!(c||!i)){if(!u){let A=d!==null?Math.min(v-d,50):16.67,L=typeof i=="object"&&i.speed?i.speed:.3,s=typeof i=="object"&&i.axis?i.axis:"y",E=L*(A/16.67);s==="y"?f.rotY=f.rotY+E:f.rotX=f.rotX+E,n.rerender()}d=v,p=requestAnimationFrame(M)}}function y(){p===null&&typeof requestAnimationFrame<"u"&&i&&(p=requestAnimationFrame(M))}function w(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",b),e.addEventListener("pointermove",C),e.addEventListener("pointerup",_),e.addEventListener("pointercancel",_),e.addEventListener("wheel",x,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function H(){e.removeEventListener("pointerdown",b),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",_),e.removeEventListener("pointercancel",_),e.removeEventListener("wheel",x),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),y(),{update(v){let A=!!i;o=v.drag??o,r=v.wheel??r,l=It(v.invert),v.clampPitch!==void 0&&(a=v.clampPitch),i=v.animate??i,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!i;A&&!L?w():!A&&L&&y()},pause(){c||(c=!0,H(),w(),h=null,u=!1)},resume(){c&&(c=!1,P(),y())},destroy(){c||H(),w(),c=!0}}}function It(n){return n===void 0||n===!1?1:n===!0?-1:n}var Fn=typeof HTMLElement<"u"?HTMLElement:class{};function In(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Qe(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function On(n){return n.closest("glyph-scene")??null}var et=class extends Fn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Qe(this.getAttribute("drag")),o=Qe(this.getAttribute("wheel")),r=Qe(this.getAttribute("invert")),l=Qe(this.getAttribute("clamp-pitch")),a=In(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...l!==void 0?{clampPitch:l}:{},...a!==void 0?{animate:{speed:a,axis:i}}:{}}}_attach(){if(this._controls)return;let e=On(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Ot(o,this._readOptions())}};function Rt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=Bt(t.invert),a=t.animate??!1,i=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,b=1/4,C=.02;function _(s){if(!(!o||i)&&d===null&&s.isPrimary!==!1){s.preventDefault(),d=s.pointerId,h={x:s.clientX,y:s.clientY},m=s.button===2,e.style.cursor="grabbing";try{s.target.setPointerCapture(s.pointerId)}catch{}a&&a.pauseOnInteraction!==!1&&(c=!0)}}function x(s){if(d===null||s.pointerId!==d||!o||i)return;s.preventDefault();let E=s.clientX-h.x,g=s.clientY-h.y;h={x:s.clientX,y:s.clientY};let G=l;if(m||s.shiftKey)f.rotY=f.rotY-E*b*G,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*b*G));else{let z=f.target;f.target=[z[0]-E*C/f.zoom,z[1]-g*C/f.zoom,z[2]]}n.rerender()}function M(s){if(d===s.pointerId){d=null,m=!1,e.style.cursor=o&&!i?"grab":"";try{s.target.releasePointerCapture(s.pointerId)}catch{}a&&(c=!1)}}function y(s){s.preventDefault()}function w(s){if(!r||i)return;s.preventDefault();let E=s.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-E))),n.rerender()}function P(s){if(!(i||!a)){if(!c){let E=p!==null?Math.min(s-p,50):16.67,g=typeof a=="object"&&a.speed?a.speed:.3,G=typeof a=="object"&&a.axis?a.axis:"y",z=g*(E/16.67);G==="y"?f.rotY=f.rotY+z:f.rotX=f.rotX+z,n.rerender()}p=s,u=requestAnimationFrame(P)}}function H(){u===null&&typeof requestAnimationFrame<"u"&&a&&(u=requestAnimationFrame(P))}function v(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",x),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",y),e.addEventListener("wheel",w,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",x),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",y),e.removeEventListener("wheel",w),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),H(),{update(s){let E=!!a;o=s.drag??o,r=s.wheel??r,l=Bt(s.invert),a=s.animate??a,!i&&d===null&&(e.style.cursor=o?"grab":"");let g=!!a;E&&!g?v():!E&&g&&H()},pause(){i||(i=!0,L(),v(),d=null,c=!1)},resume(){i&&(i=!1,A(),H())},destroy(){i||L(),v(),i=!0}}}function Bt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Bn=typeof HTMLElement<"u"?HTMLElement:class{};function gt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Rn(n){return n.closest("glyph-scene")??null}var tt=class extends Bn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=gt(this.getAttribute("drag")),o=gt(this.getAttribute("wheel")),r=gt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Rn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Rt(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Ue),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",Ke),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",Ze),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",Je),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",De),!customElements.get("glyph-camera")){class n extends De{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",et),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",tt)}export{Ze as GlyphHotspotElement,tt as GlyphMapControlsElement,Ke as GlyphMeshElement,et as GlyphOrbitControlsElement,De as GlyphOrthographicCameraElement,Je as GlyphPerspectiveCameraElement,Ue as GlyphSceneElement};
|
|
62
|
+
`;function Yt(n,t,e,o,r){return n.map(s=>{let[i,l,a]=t.project(s.at,e,o,r),u=a>-3&&i>=0&&i<e&&l>=0&&l<o;return{id:s.id,col:i,row:l,depth:a,visible:u}})}var Tn=1;function _n(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[s,i,l]=e??[0,0,0],a=1,u=1,m=1;o!==void 0&&(typeof o=="number"?a=u=m=o:[a,u,m]=o);let c=Math.PI/180,[h,p,f]=r??[0,0,0],g=h*c,E=p*c,_=f*c,T=Math.cos(g),x=Math.sin(g),y=Math.cos(E),A=Math.sin(E),F=Math.cos(_),z=Math.sin(_);function O(M){let H=M[0]*a,d=M[1]*u,S=M[2]*m,b=F*H-z*d,P=z*H+F*d,C=S;return H=y*b+A*C,d=P,S=-A*b+y*C,b=H,P=T*d-x*S,C=x*d+T*S,[b+s,P+i,C+l]}return n.map(M=>({...M,vertices:M.vertices.map(O)}))}function Nt(n,t={}){Bt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Ie(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),n.appendChild(o);let i=new Map,l=[],a=!1,u={iA:[],iB:[],iC:[],lit:[]},m={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function c(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,p=0;function f(){let d=[];for(let b of i.values())for(let P of b.polygons)(P.texture||P.material?.texture)&&d.push(P);if(d.length===0){h&&(h=null,g());return}let S=++p;Ln(d).then(b=>{S===p&&(h=b.size>0?b:null,g())})}function g(){a||(a=!0,Promise.resolve().then(()=>{a=!1,E()}))}function E(){let d=[],S=[],b=[],P=[],C=!1;for(let R of i.values()){let B=_n(R.polygons,R.transform),Y=R.transform.castShadow??!1,N=R.transform.receiveShadow??!1,W=R.transform.depthBias??0;W!==0&&(C=!0);for(let $ of B)d.push($),S.push(Y),b.push(N),P.push(W)}let k=zt({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:d,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:S,receiveShadowFlags:b,depthBiases:C?P:void 0});k.shadeCache=u,k.textureSamplers=h,k.temporalHistory=m;let L=globalThis.__glyphPerf,w=L?performance.now():0,v=It(k),I=L?performance.now():0;if(e.useColors?r.innerHTML=v:r.textContent=v,L){let R=performance.now();(L.raster??(L.raster=[])).push(I-w),(L.dom??(L.dom=[])).push(R-I),(L.polys??(L.polys=[])).push(d.length)}_()}function _(){let{cols:d,rows:S,cellAspect:b,camera:P}=e,C=Yt(l.map(v=>v.hotspot),P,d,S,b),k=r.getBoundingClientRect(),L=d>0?k.width/d:8,w=S>0?k.height/S:16;for(let v=0;v<l.length;v++){let{el:I}=l[v],R=C[v];R.visible?(I.style.display="",I.style.left=`${(R.col+.5)*L}px`,I.style.top=`${(R.row+.5)*w}px`,I.style.zIndex=String(Math.round(R.depth*1e3))):I.style.display="none"}}function T(d,S={}){let b=Tn++;return i.set(b,{id:b,polygons:d,transform:S}),c(),f(),g(),{get id(){return b},get name(){return i.get(b)?.transform.id},get polygons(){return d},setTransform(P){let C=i.get(b);C&&(C.transform=P,c(),g())},dispose(){i.delete(b),c(),f(),g()}}}function x(d,S){let b=n.ownerDocument.createElement("div");b.className="glyph-hotspot",b.setAttribute("data-hotspot-id",d.id);let[P,C]=d.size??[1,1];b.style.position="absolute",b.style.width=`${P}ch`,b.style.height=`${C*e.cellAspect}ch`,S&&b.addEventListener("click",S),s.appendChild(b);let k={hotspot:{id:d.id,at:d.at,size:d.size},el:b,onClick:S};return l.push(k),g(),{get el(){return b},remove(){let L=l.indexOf(k);L>=0&&l.splice(L,1),S&&b.removeEventListener("click",S),s.removeChild(b),g()}}}function y(){E()}function A(d){d.mode!==void 0&&(e.mode=d.mode),d.glyphPalette!==void 0&&(e.glyphPalette=d.glyphPalette),d.useColors!==void 0&&(e.useColors=d.useColors),d.cols!==void 0&&(e.cols=d.cols),d.rows!==void 0&&(e.rows=d.rows),d.cellAspect!==void 0&&(e.cellAspect=d.cellAspect),d.directionalLight!==void 0&&(e.directionalLight=d.directionalLight),d.ambientLight!==void 0&&(e.ambientLight=d.ambientLight),d.camera!==void 0&&(e.camera=d.camera),d.smoothShading!==void 0&&(e.smoothShading=d.smoothShading),d.creaseAngle!==void 0&&(e.creaseAngle=d.creaseAngle),"shadow"in d&&(e.shadow=d.shadow),d.autoSize!==void 0&&(e.autoSize=d.autoSize,e.autoSize&&!M&&typeof ResizeObserver<"u"?(M=new ResizeObserver(()=>O()),M.observe(n),O()):!e.autoSize&&M&&(M.disconnect(),M=null)),(d.mode!==void 0||d.useColors!==void 0||d.directionalLight!==void 0||d.ambientLight!==void 0||d.smoothShading!==void 0||d.creaseAngle!==void 0||d.glyphPalette!==void 0)&&c(),g()}function F(){return{...e}}function z(){let S=n.ownerDocument.createElement("span");S.textContent=Array(20).fill("M").join(`
|
|
63
|
+
`),S.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(S);let b=S.getBoundingClientRect();return S.remove(),{w:b.width||8,h:b.height?b.height/20:16}}function O(){let d=n.clientWidth,S=n.clientHeight;if(!d||!S)return;let b=z(),P=Math.max(20,Math.floor(d/b.w)),C=Math.max(8,Math.floor(S/b.h)),k=b.h/b.w,L=!1;e.cols!==P&&(e.cols=P,L=!0),e.rows!==C&&(e.rows=C,L=!0),Math.abs(e.cellAspect-k)>.01&&(e.cellAspect=k,L=!0),L&&g()}let M=null;e.autoSize&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>O()),M.observe(n),O());function H(){M&&(M.disconnect(),M=null),i.clear(),n.contains(o)&&n.removeChild(o)}return g(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:T,addHotspot:x,rerender:y,setOptions:A,getOptions:F,fit:O,destroy:H}}var Pn=typeof HTMLElement<"u"?HTMLElement:class{},Hn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Me(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function kn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function zn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var et=class extends Pn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Hn]}getScene(){return this._scene}_readOptions(){let e={},o=kn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=zn(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let i=Me(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let l=Me(this.getAttribute("rows"));l!==void 0&&(e.rows=l);let a=Me(this.getAttribute("cell-aspect"));a!==void 0&&(e.cellAspect=a);let u=Me(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let m=Me(this.getAttribute("ambient-intensity"));if(m!==void 0&&(e.ambientLight={intensity:m}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let c={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(c.color=h);let p=Me(this.getAttribute("shadow-opacity"));p!==void 0&&(c.opacity=p);let f=Me(this.getAttribute("shadow-lift"));f!==void 0&&(c.lift=f);let g=Me(this.getAttribute("shadow-max-extend"));g!==void 0&&(c.maxExtend=g),e.shadow=c}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Nt(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Fn,resolveGeometry as On,recenterPolygons as In}from"@glyphcss/core";var Rn=typeof HTMLElement<"u"?HTMLElement:class{},Bn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function Ct(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Yn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Ct(n)}}function Nn(n){return n.closest("glyph-scene")??null}var tt=class extends Rn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Bn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Ct(this.getAttribute("position")),scale:Yn(this.getAttribute("scale")),rotation:Ct(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Nn(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(e){let s=++this._loadToken,i;try{i=await Fn(e)}catch(m){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:m,bubbles:!0}));return}if(s!==this._loadToken){try{i.dispose()}catch{}return}let l=r.getScene();if(!l){try{i.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?In(i.polygons):i.polygons;this._handle=l.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let i=this.getAttribute("size"),l=i!==null?parseFloat(i):1,a=this.getAttribute("color")??void 0,u;try{u=On(o,{size:Number.isFinite(l)?l:1,color:a})}catch(m){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:m,bubbles:!0}));return}this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Vn=typeof HTMLElement<"u"?HTMLElement:class{};function Dn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Xn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function jn(n){return n.closest("glyph-scene")??null}var nt=class extends Vn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Dn(this.getAttribute("at"));if(!e)return;let o=jn(this);if(!o)return;if(!o.getScene()){let a=()=>{o.removeEventListener("glyphcss:scene-ready",a),this._register()};o.addEventListener("glyphcss:scene-ready",a);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=Xn(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let l=this._handle.el;for(;this.firstChild;)l.appendChild(this.firstChild)}};var $n=typeof HTMLElement<"u"?HTMLElement:class{};function de(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var rt=class extends $n{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ie({rotX:de(this.getAttribute("rot-x")),rotY:de(this.getAttribute("rot-y")),distance:de(this.getAttribute("distance")),perspective:de(this.getAttribute("perspective")),zoom:de(this.getAttribute("zoom")),stretch:de(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=de(this.getAttribute("rot-x")),l=de(this.getAttribute("rot-y")),a=de(this.getAttribute("distance")),u=de(this.getAttribute("perspective")),m=de(this.getAttribute("zoom")),c=de(this.getAttribute("stretch")),h=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,h=!0),l!==void 0&&s.rotY!==l&&(s.rotY=l,h=!0),a!==void 0&&s.distance!==a&&(s.distance=a,h=!0),u!==void 0&&s.perspective!==u&&(s.perspective=u,h=!0),m!==void 0&&s.zoom!==m&&(s.zoom=m,h=!0),c!==void 0&&s.stretch!==c&&(s.stretch=c,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Wn=typeof HTMLElement<"u"?HTMLElement:class{};function Be(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var qe=class extends Wn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=kt({rotX:Be(this.getAttribute("rot-x")),rotY:Be(this.getAttribute("rot-y")),zoom:Be(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=Be(this.getAttribute("rot-x")),l=Be(this.getAttribute("rot-y")),a=Be(this.getAttribute("zoom")),u=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,u=!0),l!==void 0&&s.rotY!==l&&(s.rotY=l,u=!0),a!==void 0&&s.zoom!==a&&(s.zoom=a,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function Ye(){let n=[],t=[],e=[];function o(i){return i==="change"?n:i==="start"?t:e}function r(i){if(n.length===0)return;let l={type:"change",camera:i()};for(let a of n.slice())try{a(l)}catch(u){console.error("[glyphcss] controls 'change' listener threw:",u)}}function s(i,l){let a=i==="start"?t:e;if(a.length===0)return;let u={type:i,camera:l()};for(let m of a.slice())try{m(u)}catch(c){console.error(`[glyphcss] controls '${i}' listener threw:`,c)}}return{changeListeners:n,startListeners:t,endListeners:e,listenerArray:o,emitChange:r,emitInteraction:s}}function Ne(n){return()=>{let t=n.camera,e=t.target??[0,0,0];return{rotX:t.rotX??0,rotY:t.rotY??0,zoom:t.zoom??1,target:[e[0],e[1],e[2]],distance:t.distance??0}}}function Ve(n){return{addEventListener(t,e){let o=n.listenerArray(t);o.includes(e)||o.push(e)},removeEventListener(t,e){let o=n.listenerArray(t),r=o.indexOf(e);r>=0&&o.splice(r,1)},hasEventListener(t,e){return n.listenerArray(t).includes(e)}}}function Dt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Vt(t.invert),i=t.clampPitch??!0,l=t.animate??!1,a=!1,u=!1,m=null,c=null,h=null,p={x:0,y:0},f=n.camera,g=Ye(),E=Ne(n),{emitChange:_,emitInteraction:T}=g,x=!1,y=null;function A(C){if(!(!o||a)&&h===null&&C.isPrimary!==!1){C.preventDefault(),h=C.pointerId,p={x:C.clientX,y:C.clientY},e.style.cursor="grabbing";try{C.target.setPointerCapture(C.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(u=!0),T("start",E)}}function F(C){if(h===null||C.pointerId!==h||!o||a)return;C.preventDefault();let k=C.clientX-p.x,L=C.clientY-p.y;p={x:C.clientX,y:C.clientY};let w=s,v=1/4;f.rotY=f.rotY-k*v*w;let I=f.rotX-L*v*w;f.rotX=i?Math.max(-90,Math.min(90,I)):I,n.rerender(),_(E)}function z(C){if(h===C.pointerId){h=null,e.style.cursor=o&&!a?"grab":"";try{C.target.releasePointerCapture(C.pointerId)}catch{}l&&(u=!1),T("end",E)}}function O(C){if(!r||a)return;C.preventDefault();let k=C.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-k))),n.rerender(),x||(x=!0,T("start",E)),_(E),y!==null&&clearTimeout(y),y=setTimeout(()=>{y=null,x=!1,T("end",E)},150)}function M(C){if(!(a||!l)){if(!u){let k=c!==null?Math.min(C-c,50):16.67,L=typeof l=="object"&&l.speed?l.speed:.3,w=typeof l=="object"&&l.axis?l.axis:"y",v=L*(k/16.67);w==="y"?f.rotY=f.rotY+v:f.rotX=f.rotX+v,n.rerender(),_(E)}c=C,m=requestAnimationFrame(M)}}function H(){m===null&&typeof requestAnimationFrame<"u"&&l&&(m=requestAnimationFrame(M))}function d(){m!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(m),m=null),c=null}function S(){e.addEventListener("pointerdown",A),e.addEventListener("pointermove",F),e.addEventListener("pointerup",z),e.addEventListener("pointercancel",z),e.addEventListener("wheel",O,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function b(){e.removeEventListener("pointerdown",A),e.removeEventListener("pointermove",F),e.removeEventListener("pointerup",z),e.removeEventListener("pointercancel",z),e.removeEventListener("wheel",O),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}function P(){y!==null&&(clearTimeout(y),y=null),x=!1}return S(),H(),{...Ve(g),update(C){let k=!!l;o=C.drag??o,r=C.wheel??r,s=Vt(C.invert),C.clampPitch!==void 0&&(i=C.clampPitch),l=C.animate??l,!a&&h===null&&(e.style.cursor=o?"grab":"");let L=!!l;k&&!L?d():!k&&L&&H()},pause(){a||(a=!0,b(),d(),P(),h=null,u=!1)},resume(){a&&(a=!1,S(),H())},destroy(){a||b(),d(),P(),a=!0}}}function Vt(n){return n===void 0||n===!1?1:n===!0?-1:n}var qn=typeof HTMLElement<"u"?HTMLElement:class{};function Kn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ot(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Zn(n){return n.closest("glyph-scene")??null}var it=class extends qn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=ot(this.getAttribute("drag")),o=ot(this.getAttribute("wheel")),r=ot(this.getAttribute("invert")),s=ot(this.getAttribute("clamp-pitch")),i=Kn(this.getAttribute("animate-speed")),l=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...i!==void 0?{animate:{speed:i,axis:l}}:{}}}_attach(){if(this._controls)return;let e=Zn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Dt(o,this._readOptions())}};function jt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Xt(t.invert),i=t.animate??!1,l=!1,a=!1,u=null,m=null,c=null,h={x:0,y:0},p=!1,f=n.camera,g=Ye(),E=Ne(n),{emitChange:_,emitInteraction:T}=g,x=!1,y=null,A=1/4,F=.02;function z(w){if(!(!o||l)&&c===null&&w.isPrimary!==!1){w.preventDefault(),c=w.pointerId,h={x:w.clientX,y:w.clientY},p=w.button===2,e.style.cursor="grabbing";try{w.target.setPointerCapture(w.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0),T("start",E)}}function O(w){if(c===null||w.pointerId!==c||!o||l)return;w.preventDefault();let v=w.clientX-h.x,I=w.clientY-h.y;h={x:w.clientX,y:w.clientY};let R=s;if(p||w.shiftKey)f.rotY=f.rotY-v*A*R,f.rotX=Math.max(-90,Math.min(90,f.rotX+I*A*R));else{let B=f.target;f.target=[B[0]-v*F/f.zoom,B[1]-I*F/f.zoom,B[2]]}n.rerender(),_(E)}function M(w){if(c===w.pointerId){c=null,p=!1,e.style.cursor=o&&!l?"grab":"";try{w.target.releasePointerCapture(w.pointerId)}catch{}i&&(a=!1),T("end",E)}}function H(w){w.preventDefault()}function d(w){if(!r||l)return;w.preventDefault();let v=w.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-v))),n.rerender(),x||(x=!0,T("start",E)),_(E),y!==null&&clearTimeout(y),y=setTimeout(()=>{y=null,x=!1,T("end",E)},150)}function S(w){if(!(l||!i)){if(!a){let v=m!==null?Math.min(w-m,50):16.67,I=typeof i=="object"&&i.speed?i.speed:.3,R=typeof i=="object"&&i.axis?i.axis:"y",B=I*(v/16.67);R==="y"?f.rotY=f.rotY+B:f.rotX=f.rotX+B,n.rerender(),_(E)}m=w,u=requestAnimationFrame(S)}}function b(){u===null&&typeof requestAnimationFrame<"u"&&i&&(u=requestAnimationFrame(S))}function P(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),m=null}function C(){e.addEventListener("pointerdown",z),e.addEventListener("pointermove",O),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",H),e.addEventListener("wheel",d,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function k(){e.removeEventListener("pointerdown",z),e.removeEventListener("pointermove",O),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",H),e.removeEventListener("wheel",d),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}function L(){y!==null&&(clearTimeout(y),y=null),x=!1}return C(),b(),{...Ve(g),update(w){let v=!!i;o=w.drag??o,r=w.wheel??r,s=Xt(w.invert),i=w.animate??i,!l&&c===null&&(e.style.cursor=o?"grab":"");let I=!!i;v&&!I?P():!v&&I&&b()},pause(){l||(l=!0,k(),P(),L(),c=null,a=!1)},resume(){l&&(l=!1,C(),b())},destroy(){l||k(),P(),L(),l=!0}}}function Xt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Un=typeof HTMLElement<"u"?HTMLElement:class{};function At(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Jn(n){return n.closest("glyph-scene")??null}var st=class extends Un{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=At(this.getAttribute("drag")),o=At(this.getAttribute("wheel")),r=At(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Jn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=jt(o,this._readOptions())}};var Qn={enabled:!0,lookEnabled:!0,moveEnabled:!0,jumpEnabled:!0,crouchEnabled:!0,lookSensitivity:.15,invertY:!1,moveSpeed:5,jumpVelocity:7,gravity:18,eyeHeight:1.7,crouchHeight:1,groundZ:0,minPitch:5,maxPitch:175};function $t(n,t){return{enabled:t.enabled??n.enabled,lookEnabled:t.lookEnabled??n.lookEnabled,moveEnabled:t.moveEnabled??n.moveEnabled,jumpEnabled:t.jumpEnabled??n.jumpEnabled,crouchEnabled:t.crouchEnabled??n.crouchEnabled,lookSensitivity:t.lookSensitivity??n.lookSensitivity,invertY:t.invertY??n.invertY,moveSpeed:t.moveSpeed??n.moveSpeed,jumpVelocity:t.jumpVelocity??n.jumpVelocity,gravity:t.gravity??n.gravity,eyeHeight:t.eyeHeight??n.eyeHeight,crouchHeight:t.crouchHeight??n.crouchHeight,groundZ:t.groundZ??n.groundZ,minPitch:t.minPitch??n.minPitch,maxPitch:t.maxPitch??n.maxPitch}}var Wt=new Set(["KeyW","ArrowUp"]),qt=new Set(["KeyS","ArrowDown"]),Kt=new Set(["KeyA","ArrowLeft"]),Zt=new Set(["KeyD","ArrowRight"]),Ut=new Set(["Space"]),St=new Set(["ControlLeft","ControlRight"]);function Jt(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");let e=$t(Qn,t),o=n.camera,r=n.host,s=r.ownerDocument??document,i=s.defaultView??globalThis,l=Ye(),a=Ne(n),{emitChange:u,emitInteraction:m}=l,c=new Set,h=!1,p=!1,f=0,g=0,E=[0,0,e.groundZ+e.eyeHeight];function _(){o.target=[E[0],E[1],E[2]],n.rerender(),u(a)}function T(){let v=o.target??[0,0,0];E=[v[0],v[1],e.groundZ+e.eyeHeight],_()}let x=()=>{if(!(!e.enabled||!e.lookEnabled||p||h))try{r.requestPointerLock()}catch{}},y=()=>{let v=s.pointerLockElement===r;v!==h&&(h=v,m(v?"start":"end",a))},A=v=>{if(!h||!e.enabled||!e.lookEnabled||p)return;let I=v.movementX??0,R=v.movementY??0;if(I===0&&R===0)return;let B=e.lookSensitivity,Y=e.invertY?-1:1;o.rotY=((o.rotY-I*B)%360+360)%360;let N=o.rotX-R*B*Y;N<e.minPitch?N=e.minPitch:N>e.maxPitch&&(N=e.maxPitch),o.rotX=N,_()},F=v=>Wt.has(v)||qt.has(v)||Kt.has(v)||Zt.has(v)||Ut.has(v)||St.has(v),z=v=>{if(!(!e.enabled||p)&&F(v.code)&&!(!h&&!e.moveEnabled)){if(Ut.has(v.code)){if(!e.jumpEnabled)return;v.preventDefault(),!c.has(v.code)&&f===0&&g===0&&(f=e.jumpVelocity),c.add(v.code);return}St.has(v.code)&&!e.crouchEnabled||!e.moveEnabled&&!St.has(v.code)||(v.preventDefault(),c.add(v.code))}},O=v=>{F(v.code)&&c.delete(v.code)},M=()=>{c.clear()},H=null,d=0,S=.05,b=v=>{if(H===null||p)return;let I=Math.min(S,d?(v-d)/1e3:.0167);if(d=v,e.enabled){let R=!1;if(e.moveEnabled){let W=0,$=0;for(let V of c)Wt.has(V)?W+=1:qt.has(V)?W-=1:Zt.has(V)?$+=1:Kt.has(V)&&($-=1);if(W!==0||$!==0){let V=o.rotY*Math.PI/180,te=-Math.cos(V),D=-Math.sin(V),ke=-Math.sin(V),ae=Math.cos(V),Z=Math.hypot(W,$)||1,U=e.moveSpeed*I;E[0]+=(te*W+ke*$)/Z*U,E[1]+=(D*W+ae*$)/Z*U,R=!0}}let Y=e.crouchEnabled&&(c.has("ControlLeft")||c.has("ControlRight"))?e.crouchHeight:e.eyeHeight;e.jumpEnabled&&(f!==0||g>0)?(f-=e.gravity*I,g+=f*I,g<=0&&(g=0,f=0)):e.jumpEnabled||(g=0,f=0);let N=e.groundZ+Y+g;Math.abs(E[2]-N)>1e-4&&(E[2]=N,R=!0),R&&_()}H=i.requestAnimationFrame(b)};function P(){H!==null||p||(d=0,typeof i.requestAnimationFrame<"u"&&(H=i.requestAnimationFrame(b)))}function C(){H!==null&&(i.cancelAnimationFrame(H),H=null)}function k(){o.eyeMode=!0,r.addEventListener("click",x),s.addEventListener("pointerlockchange",y),s.addEventListener("mousemove",A),i.addEventListener("keydown",z),i.addEventListener("keyup",O),i.addEventListener("blur",M),r.style.cursor=e.lookEnabled?"crosshair":"",r.style.touchAction="none"}function L(){if(r.removeEventListener("click",x),s.removeEventListener("pointerlockchange",y),s.removeEventListener("mousemove",A),i.removeEventListener("keydown",z),i.removeEventListener("keyup",O),i.removeEventListener("blur",M),r.style.cursor="",r.style.touchAction="",c.clear(),h)try{s.exitPointerLock()}catch{}o.eyeMode=!1}T(),k(),P();function w(v){let I=e.eyeHeight,R=e.groundZ;e=$t(e,v),p||(r.style.cursor=e.lookEnabled?"crosshair":""),(e.eyeHeight!==I||e.groundZ!==R)&&(E[2]=e.groundZ+e.eyeHeight,_())}return{...Ve(l),update:w,resume(){p&&(p=!1,k(),P())},pause(){p||(p=!0,L(),C())},destroy(){p||(L(),C()),p=!0},lock(){if(!(!e.enabled||!e.lookEnabled||p))try{r.requestPointerLock()}catch{}},unlock(){if(h)try{s.exitPointerLock()}catch{}},isLocked(){return h},getOrigin(){return[E[0],E[1],E[2]]},setOrigin(v){E=[v[0],v[1],v[2]],_()}}}var er=typeof HTMLElement<"u"?HTMLElement:class{};function Se(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function De(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function tr(n){return n.closest("glyph-scene")??null}var nr=["enabled","look-enabled","move-enabled","jump-enabled","crouch-enabled","look-sensitivity","invert-y","move-speed","jump-velocity","gravity","eye-height","crouch-height","ground-z","min-pitch","max-pitch"],lt=class extends er{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...nr]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e={},o=De(this.getAttribute("enabled"));o!==void 0&&(e.enabled=o);let r=De(this.getAttribute("look-enabled"));r!==void 0&&(e.lookEnabled=r);let s=De(this.getAttribute("move-enabled"));s!==void 0&&(e.moveEnabled=s);let i=De(this.getAttribute("jump-enabled"));i!==void 0&&(e.jumpEnabled=i);let l=De(this.getAttribute("crouch-enabled"));l!==void 0&&(e.crouchEnabled=l);let a=Se(this.getAttribute("look-sensitivity"));if(a!==void 0&&(e.lookSensitivity=a),this.hasAttribute("invert-y")){let _=De(this.getAttribute("invert-y"));_!==void 0&&(e.invertY=_)}let u=Se(this.getAttribute("move-speed"));u!==void 0&&(e.moveSpeed=u);let m=Se(this.getAttribute("jump-velocity"));m!==void 0&&(e.jumpVelocity=m);let c=Se(this.getAttribute("gravity"));c!==void 0&&(e.gravity=c);let h=Se(this.getAttribute("eye-height"));h!==void 0&&(e.eyeHeight=h);let p=Se(this.getAttribute("crouch-height"));p!==void 0&&(e.crouchHeight=p);let f=Se(this.getAttribute("ground-z"));f!==void 0&&(e.groundZ=f);let g=Se(this.getAttribute("min-pitch"));g!==void 0&&(e.minPitch=g);let E=Se(this.getAttribute("max-pitch"));return E!==void 0&&(e.maxPitch=E),e}_attach(){if(this._controls)return;let e=tr(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Jt(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",et),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",tt),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",nt),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",rt),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",qe),!customElements.get("glyph-camera")){class n extends qe{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",it),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",st),customElements.get("glyph-first-person-controls")||customElements.define("glyph-first-person-controls",lt)}export{lt as GlyphFirstPersonControlsElement,nt as GlyphHotspotElement,st as GlyphMapControlsElement,tt as GlyphMeshElement,it as GlyphOrbitControlsElement,qe as GlyphOrthographicCameraElement,rt as GlyphPerspectiveCameraElement,et as GlyphSceneElement};
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Gt=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var yn=(n,t)=>{for(var e in t)Gt(n,e,{get:t[e],enumerable:!0})},Mt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mn(t))!fn.call(n,r)&&r!==e&&Gt(n,r,{get:()=>t[r],enumerable:!(o=hn(t,r))||o.enumerable});return n},V=(n,t,e)=>(Mt(n,t,"default"),e&&Mt(e,t,"default"));var gn=n=>Mt(Gt({},"__esModule",{value:!0}),n);var N={};yn(N,{DEFAULT_PERSPECTIVE:()=>Tt,DEFAULT_RAMP:()=>Vt,GlyphHotspotElement:()=>ut,GlyphMapControlsElement:()=>ft,GlyphMeshElement:()=>ct,GlyphOrbitControlsElement:()=>mt,GlyphOrthographicCameraElement:()=>pt,GlyphPerspectiveCameraElement:()=>dt,GlyphSceneElement:()=>at,SOLID_RAMP:()=>Xt,WIREFRAME_GLYPHS:()=>$t,WIREFRAME_PALETTES:()=>We,bakeFrames:()=>qt,buildRasterizeContext:()=>tt,createGlyphCamera:()=>Yt,createGlyphFirstPersonControls:()=>en,createGlyphMapControls:()=>lt,createGlyphOrbitControls:()=>st,createGlyphOrthographicCamera:()=>$e,createGlyphPerspectiveCamera:()=>Le,createGlyphScene:()=>it,findGlyphMeshHandle:()=>tn,findMeshUnderPoint:()=>nn,getWireframeGlyphs:()=>je,injectGlyphBaseStyles:()=>rt,pointInMeshElement:()=>_t,projectHotspots:()=>ot,rasterize:()=>qe});module.exports=gn(N);var Kt=require("@glyphcss/core");var Nt=Math.PI/180,Dt=.01,Tt=32e3,bn=Dt*1.01;function Lt(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*Nt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*Nt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Le(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Tt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=Lt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*bn}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],S=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+S/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,S=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Dt;if(y<E)return[NaN,NaN,P,NaN];let A=M/y,L=i*e+b*A/u*t.stretch*t.fovScale,a=l*o+S*A/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function $e(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Yt=$e;var vn={direction:[-.5,-.7,-.5],intensity:1},En={intensity:.4};function wn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function tt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?wn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??vn,ambientLight:n.ambientLight??En,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var nt=require("@glyphcss/core");var Vt=" .:-=+*#%@".split(""),Xt=" .:-=+*#%@".split(""),We={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},$t=We.default;function je(n){return We[n]??We.default}function qe(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return An(n,i,l,s,d)}let c=je(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||_n(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return Pn(u,p,i,l,c)}function An(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,$,W,Y)=>{let x=s.project(R,$,W,Y);return[$*.5+(x[0]-$*.5)*r,W*.5+(x[1]-W*.5)*r,x[2],x[3]]}}:s,M=je(n.glyphPalette).solid,b=M.length-1,S=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,q=Fe(u.color??"#ffffff"),B=Fe(p.color??"#ffffff"),U=d&&h>0?Ln(c,h):null,k=new Map,ie=n.textureSamplers??null,D=n.shadow,K=D!=null&&f.length>0?Gn(c,f,g,_,H):null,se=D?.opacity??.25,J=D?.lift??.05,Q=D?.color??"#000000",le=K?Fe(Q):[0,0,0],I=globalThis.__glyphPerfDetail,Ue=I?performance.now():0,be=[],ee=n.shadeCache??null,te=-1,we=(R,$,W,Y)=>{if(K===null||!Y)return null;let x=K,O=Be(R,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),ne=Be($,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),he=Be(W,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax);return{map:x,luA:O[0],lvA:O[1],ldA:O[2],luB:ne[0],lvB:ne[1],ldB:ne[2],luC:he[0],lvC:he[1],ldC:he[2],lift:J,opacity:se,shadowColorRgb:le,shadowColorHex:Q,litCache:k}};for(let R=0;R<c.length;R++){let $=c[R],W=$.vertices;if(W.length<3)continue;let Y=$.uvs,x=null;if(ie!==null&&Y&&Y.length>=W.length){let O=(0,nt.polygonTexture)($);O&&(x=ie.get(O)??null)}for(let O=0;O<W.length;O++)be[O]=G.project(W[O],i,l,o);for(let O=1;O<W.length-1;O++){te++;let ne=0,he=O,Ae=O+1,ae=W[ne],me=W[he],Se=W[Ae],ue=be[ne],ve=be[he],Me=be[Ae],gt=(ue[0]!==ue[0]?1:0)+(ve[0]!==ve[0]?1:0)+(Me[0]!==Me[0]?1:0);if(gt===3||gt===0&&!m&&(ve[0]-ue[0])*(Me[1]-ue[1])-(ve[1]-ue[1])*(Me[0]-ue[0])>0)continue;let _e,Pe,ze,De=null;if(ee!==null&&ee.iA[te]!==void 0)_e=ee.iA[te],Pe=ee.iB[te],ze=ee.iC[te],De=ee.lit[te];else{let j=me[0]-ae[0],fe=me[1]-ae[1],xe=me[2]-ae[2],ye=Se[0]-ae[0],Ze=Se[1]-ae[1],Je=Se[2]-ae[2],Qe=fe*Je-xe*Ze,Ye=xe*ye-j*Je,Z=j*Ze-fe*ye,X=Math.hypot(Qe,Ye,Z)||1,re=Qe/X,ge=Ye/X,ce=Z/X,de,He,bt,vt,Et,wt,At,St,xt;if(U){let Ve=U[R],Ge=Ve[ne],Re=Ve[he],Xe=Ve[Ae];de=Ge[0],He=Ge[1],bt=Ge[2],vt=Re[0],Et=Re[1],wt=Re[2],At=Xe[0],St=Xe[1],xt=Xe[2]}else de=vt=At=re,He=Et=St=ge,bt=wt=xt=ce;let It=de*g+He*_+bt*H,Rt=vt*g+Et*_+wt*H,Bt=At*g+St*_+xt*H,rn=m?Math.abs(It):Math.max(0,-It),on=m?Math.abs(Rt):Math.max(0,-Rt),sn=m?Math.abs(Bt):Math.max(0,-Bt);if(_e=Math.min(1,z+rn*F),Pe=Math.min(1,z+on*F),ze=Math.min(1,z+sn*F),P){let Ve=(_e+Pe+ze)/3,Ge=Math.max(0,Ve-z),Re=$.color??"#ffffff",Xe=Ge*255|0,kt=`${Re}:${Xe}`,et=k.get(kt);if(et===void 0){let Ct=Fe(Re),ln=z*B[0]/255+Ge*q[0]/255,an=z*B[1]/255+Ge*q[1]/255,cn=z*B[2]/255+Ge*q[2]/255,un=Math.min(255,Ct[0]*ln),dn=Math.min(255,Ct[1]*an),pn=Math.min(255,Ct[2]*cn);et=`#${oe(un)}${oe(dn)}${oe(pn)}`,k.set(kt,et)}De=et}ee!==null&&(ee.iA[te]=_e,ee.iB[te]=Pe,ee.iC[te]=ze,ee.lit[te]=De)}let Ft=v[R]??!1,Ie=1+(C?.[R]??0),Ot=null;if(x!==null&&Y){let j=Y[ne],fe=Y[he],xe=Y[Ae],ye=Math.max(0,(_e+Pe+ze)/3-z);Ot={sampler:x,ua:j[0],va:j[1],ub:fe[0],vb:fe[1],uc:xe[0],vc:xe[1],tintR:z*B[0]/255+ye*q[0]/255,tintG:z*B[1]/255+ye*q[1]/255,tintB:z*B[2]/255+ye*q[2]/255}}if(gt===0)Wt(ue[0],ue[1],(ue[3]??ue[2])*Ie,_e,ve[0],ve[1],(ve[3]??ve[2])*Ie,Pe,Me[0],Me[1],(Me[3]??Me[2])*Ie,ze,M,b,De,S,y,E,i,l,we(ae,me,Se,Ft),m,ae,me,Se,L,T,Ot);else{let j=[],fe=[],xe=[ae,me,Se],ye=[_e,Pe,ze],Ze=G.eyeDepth(ae),Je=G.eyeDepth(me),Qe=G.eyeDepth(Se),Ye=[Ze,Je,Qe];for(let Z=0;Z<3;Z++){let X=(Z+1)%3,re=Ye[Z],ge=Ye[X];if(re>0&&(j.push(xe[Z]),fe.push(ye[Z])),re>0!=ge>0){let ce=re/(re-ge),de=xe[Z],He=xe[X];j.push([de[0]+ce*(He[0]-de[0]),de[1]+ce*(He[1]-de[1]),de[2]+ce*(He[2]-de[2])]),fe.push(ye[Z]+ce*(ye[X]-ye[Z]))}}if(j.length>=3){let Z=j.map(X=>G.project(X,i,l,o));for(let X=1;X<j.length-1;X++){let re=Z[0],ge=Z[X],ce=Z[X+1],de=(ge[0]-re[0])*(ce[1]-re[1])-(ge[1]-re[1])*(ce[0]-re[0]);!m&&de>0||Wt(re[0],re[1],(re[3]??re[2])*Ie,fe[0],ge[0],ge[1],(ge[3]??ge[2])*Ie,fe[X],ce[0],ce[1],(ce[3]??ce[2])*Ie,fe[X+1],M,b,De,S,y,E,i,l,we(j[0],j[X],j[X+1],Ft),m,j[0],j[X],j[X+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ue);let Ht=I?performance.now():0,Oe=S,Ce=y,Ke=L;if(r>1){let R=xn(S,y,E,L,t,e,r,M);Oe=R.glyphBuf,Ce=R.colorBuf,Ke=R.worldPos}A&&Sn(Oe,Ce,Ke,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let yt=Tn(Oe,Ce,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ht),yt}function Sn(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Le({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let S=M*o+b,P=h.get(n[S])??0,y=0,E=0,A=0,L=t?t[S]:null;if(L){let D=Fe(L);y=D[0],E=D[1],A=D[2]}let a=0,w=0,g=0,_=0,H=0,F=e[S*3];if(f&&F===F){let D=f([F,e[S*3+1],e[S*3+2]]),K=Math.round(D[0]),se=Math.round(D[1]);if(D[0]===D[0]&&K>=0&&K<o&&se>=0&&se<r){let J=se*o+K;w=c.idx[J],g=c.r[J],_=c.g[J],H=c.b[J],a=s}}let z=1-a,q=z*P+a*w,B=z*y+a*g,U=z*E+a*_,k=z*A+a*H;v[S]=q,C[S]=B,T[S]=U,G[S]=k;let ie=Math.round(q);ie<0?ie=0:ie>d&&(ie=d),n[S]=l[ie],t&&(t[S]=ie===0?null:`#${oe(B)}${oe(U)}${oe(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function xn(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,S=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=Fe(H);M+=F[0],b+=F[1],S+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let A=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[A]=s[L],h&&(h[A]=`#${oe(M/G)}${oe(b/G)}${oe(S/G)}`),m&&(m[A*3]=P/G,m[A*3+1]=y/G,m[A*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var Cn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),Ee=256;function Be(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(Ee-1),G=(v-h)/(m-h)*(Ee-1);return[T,G,C]}function Mn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(Ee-1,Math.floor(C)),S=Math.max(0,Math.ceil(T)),P=Math.min(Ee-1,Math.floor(G));if(M>b||S>P)return;let y=m>0;for(let E=S;E<=P;E++)for(let A=M;A<=b;A++){let L=A,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*Ee+A;H>n[F]&&(n[F]=H)}}function Gn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let S of n[b].vertices){let P=i*S[0]+l*S[1]+s*S[2],y=u*S[0]+p*S[1]+d*S[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(Ee*Ee).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let S=n[b].vertices;if(!(S.length<3))for(let P=1;P<S.length-1;P++){let y=S[0],E=S[P],A=S[P+1],L=Be(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Be(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Be(A,i,l,s,u,p,d,e,o,r,h,m,f,v);Mn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Wt(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,S,P,y,E,A,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!S&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let q=t>i?t:i;u>q&&(q=u);let B=Math.max(0,Math.ceil(H)),U=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),ie=Math.min(M-1,Math.floor(q));if(!(B>U||k>ie))for(let D=k;D<=ie;D++){let K=D;for(let se=B;se<=U;se++){let J=se,Q=(r-J)*(u-K)-(i-K)*(c-J),le=(c-J)*(t-K)-(u-K)*(n-J),I=(n-J)*(i-K)-(t-K)*(r-J);if(_?Q<0||le<0||I<0:Q>0||le>0||I>0)continue;let Ue=(Q*e+le*l+I*p)*g,be=D*G+se,ee=T[be];if(Ue>(ee>0?ee*(1-L):ee)){if(T[be]=Ue,A!==null){let $=be*3;A[$]=(Q*P[0]+le*y[0]+I*E[0])*g,A[$+1]=(Q*P[1]+le*y[1]+I*E[1])*g,A[$+2]=(Q*P[2]+le*y[2]+I*E[2])*g}let te=(Q*o+le*s+I*d)*g,we=f;if(a!==null){let $=(Q*a.ua+le*a.ub+I*a.uc)*g,W=(Q*a.va+le*a.vb+I*a.vc)*g,Y=(0,nt.sampleTexel)(a.sampler,$,W);if(Y!==null&&Y.a>8){let x=Y.r*a.tintR|0;x>255&&(x=255);let O=Y.g*a.tintG|0;O>255&&(O=255);let ne=Y.b*a.tintB|0;ne>255&&(ne=255),we=`#${oe(x)}${oe(O)}${oe(ne)}`,te*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Oe=(te<0?0:te>1?1:te)*m,Ce=Oe|0,Ke=Oe-Ce,yt=Cn[(D&3)*4+(se&3)],R=Ke>yt&&Ce<m?Ce+1:Ce;if(R>m&&(R=m),b!==null){let $=(Q*b.luA+le*b.luB+I*b.luC)*g,W=(Q*b.lvA+le*b.lvB+I*b.lvC)*g,Y=(Q*b.ldA+le*b.ldB+I*b.ldC)*g,x=$|0,O=W|0;if(x>=0&&x<Ee&&O>=0&&O<Ee){let ne=b.map.buf[O*Ee+x];if(ne>-1/0&&Y+b.lift<ne&&(R=Math.max(0,R-Math.round(b.opacity*m)),we!==null)){let he=`shadow:${we}:${R}`,Ae=b.litCache.get(he);if(Ae===void 0){let ae=Fe(we),me=b.shadowColorRgb,Se=Math.round(ae[0]*(1-b.opacity)+me[0]*b.opacity),ue=Math.round(ae[1]*(1-b.opacity)+me[1]*b.opacity),ve=Math.round(ae[2]*(1-b.opacity)+me[2]*b.opacity);Ae=`#${oe(Se)}${oe(ue)}${oe(ve)}`,b.litCache.set(he,Ae)}we=Ae}}}v[be]=h[R],C&&(C[be]=we)}}}}function Ln(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,S=Math.hypot(G,M,b)||1;o[s]=[G/S,M/S,b/S]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function Tn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
|
|
2
|
-
`)}return r.join("")}function
|
|
3
|
-
`)}return
|
|
1
|
+
"use strict";var _t=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var xn=Object.prototype.hasOwnProperty;var An=(n,t)=>{for(var e in t)_t(n,e,{get:t[e],enumerable:!0})},Tt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Sn(t))!xn.call(n,r)&&r!==e&&_t(n,r,{get:()=>t[r],enumerable:!(o=Gn(t,r))||o.enumerable});return n},K=(n,t,e)=>(Tt(n,t,"default"),e&&Tt(e,t,"default"));var wn=n=>Tt(_t({},"__esModule",{value:!0}),n);var W={};An(W,{DEFAULT_PERSPECTIVE:()=>Ht,DEFAULT_RAMP:()=>Wt,GlyphHotspotElement:()=>ht,GlyphMapControlsElement:()=>bt,GlyphMeshElement:()=>dt,GlyphOrbitControlsElement:()=>gt,GlyphOrthographicCameraElement:()=>ft,GlyphPerspectiveCameraElement:()=>mt,GlyphSceneElement:()=>pt,SOLID_RAMP:()=>qt,WIREFRAME_GLYPHS:()=>Ut,WIREFRAME_PALETTES:()=>Ke,bakeFrames:()=>Jt,buildRasterizeContext:()=>ot,createGlyphCamera:()=>$t,createGlyphFirstPersonControls:()=>un,createGlyphMapControls:()=>ut,createGlyphOrbitControls:()=>ct,createGlyphOrthographicCamera:()=>Ue,createGlyphPerspectiveCamera:()=>Le,createGlyphScene:()=>at,findGlyphMeshHandle:()=>pn,findMeshUnderPoint:()=>dn,getWireframeGlyphs:()=>Ze,injectGlyphBaseStyles:()=>st,pointInMeshElement:()=>Ot,projectHotspots:()=>lt,rasterize:()=>Je});module.exports=wn(W);var en=require("@glyphcss/core");var Xt=Math.PI/180,jt=.01,Ht=32e3,Mn=jt*1.01;function Pt(n,t,e){let o=n[1],r=n[0],s=n[2],i=e*Xt,l=Math.cos(i),a=Math.sin(i),u=o*l-r*a,m=o*a+r*l,c=s,d=t*Xt,h=Math.cos(d),f=Math.sin(d),b=m*h-c*f,C=m*f+c*h;return[u,b,C]}function Le(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Ht,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let s=Pt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),i=.001*1.01;if(t.eyeMode)return-s[2]-i;if(t.perspective>0){let l=s[2]*t.zoom*50-t.distance;return t.perspective-l-t.perspective*Mn}return t.distance-s[2]-i},project(r,s,i,l){let u=50/l,m=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=Pt(m,t.rotX,t.rotY);if(t.eyeMode){if(c[2]>=-.001)return[NaN,NaN,c[2],NaN];let y=t.focal/-c[2],G=c[0]*y*t.zoom*50,k=c[1]*y*t.zoom*50,O=s*e+G/u*t.stretch,I=i*o+k/50;return[O,I,c[2],-1/c[2]]}if(t.perspective>0){let w=t.perspective,y=c[0]*t.zoom*50,G=c[1]*t.zoom*50,k=c[2]*t.zoom*50-t.distance,O=w-k,I=w*jt;if(O<I)return[NaN,NaN,k,NaN];let M=w/O,H=s*e+y*M/u*t.stretch*t.fovScale,p=i*o+G*M/50*t.fovScale;return[H,p,k,1/O]}let d=.001,h=t.distance-c[2];if(h<d)return[NaN,NaN,c[2],NaN];let f=t.distance/h,b=c[0]*f*t.zoom*50,C=c[1]*f*t.zoom*50,P=s*e+b/u*t.stretch*t.fovScale,T=i*o+C/50*t.fovScale;return[P,T,c[2],1/h]}}}function Ue(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,s,i,l){let u=50/l,m=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=Pt(m,t.rotX,t.rotY),d=c[0]*t.zoom*50,h=c[1]*t.zoom*50,f=s*e+d/u*t.fovScale,b=i*o+h/50*t.fovScale;return[f,b,c[2]]}}}var $t=Ue;var Ln={direction:[-.5,-.7,-.5],intensity:1},Tn={intensity:.4};function _n(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let i=r[s],l=r[(s+1)%r.length],a=`${i[0]},${i[1]},${i[2]}`,u=`${l[0]},${l[1]},${l[2]}`,m=a<u?`${a}|${u}`:`${u}|${a}`;if(t.has(m))continue;t.add(m);let c={from:i,to:l,weight:2};o.color&&(c.color=o.color),e.push(c)}}return e}function ot(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?_n(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Ln,ambientLight:n.ambientLight??Tn,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var it=require("@glyphcss/core");var Wt=" .:-=+*#%@".split(""),qt=" .:-=+*#%@".split(""),Ke={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Ut=Ke.default;function Ze(n){return Ke[n]??Ke.default}function Je(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:s,rows:i,cellAspect:l}=e;if(r==="solid"){let c=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return Pn(n,s,i,l,c)}let a=Ze(n.glyphPalette),u=new Uint8Array(s*i),m=n.useColors?new Array(s*i).fill(null):null;for(let c of o){let d=t.project(c.from,s,i,l),h=t.project(c.to,s,i,l);d[0]!==d[0]||h[0]!==h[0]||Bn(u,m,d[0]|0,d[1]|0,h[0]|0,h[1]|0,c.weight??2,c.color??null,s,i)}return Yn(u,m,s,i,a)}function Pn(n,t,e,o,r){let s=t*r,i=e*r,{camera:l,polygons:a,directionalLight:u,ambientLight:m,smoothShading:c,creaseAngle:d,doubleSided:h,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,P=n.depthEpsilon??0,T=r>1?{zoom:l.zoom,eyeDepth:j=>l.eyeDepth(j),project:(j,ee,te,U)=>{let A=l.project(j,ee,te,U);return[ee*.5+(A[0]-ee*.5)*r,te*.5+(A[1]-te*.5)*r,A[2],A[3]]}}:l,w=Ze(n.glyphPalette).solid,y=w.length-1,G=new Array(s*i).fill(" "),k=n.useColors,O=k?new Array(s*i).fill(null):null,I=new Float64Array(s*i).fill(-1/0),M=n.temporalBlend>0&&!!n.temporalHistory,H=M?new Float32Array(s*i*3).fill(NaN):null,p=u.direction,S=Math.hypot(p[0],p[1],p[2])||1,g=p[0]/S,_=p[1]/S,E=p[2]/S,z=u.intensity??1,L=m.intensity??.4,x=Oe(u.color??"#ffffff"),v=Oe(m.color??"#ffffff"),F=c&&d>0?Fn(a,d):null,R=new Map,B=n.textureSamplers??null,Y=n.shadow,N=Y!=null&&f.length>0?In(a,f,g,_,E):null,q=Y?.opacity??.25,$=Y?.lift??.05,D=Y?.color??"#000000",re=N?Oe(D):[0,0,0],V=globalThis.__glyphPerfDetail,ke=V?performance.now():0,ue=[],J=n.shadeCache??null,Q=-1,Ce=(j,ee,te,U)=>{if(N===null||!U)return null;let A=N,X=Be(j,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax),ie=Be(ee,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax),me=Be(te,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax);return{map:A,luA:X[0],lvA:X[1],ldA:X[2],luB:ie[0],lvB:ie[1],ldB:ie[2],luC:me[0],lvC:me[1],ldC:me[2],lift:$,opacity:q,shadowColorRgb:re,shadowColorHex:D,litCache:R}};for(let j=0;j<a.length;j++){let ee=a[j],te=ee.vertices;if(te.length<3)continue;let U=ee.uvs,A=null;if(B!==null&&U&&U.length>=te.length){let X=(0,it.polygonTexture)(ee);X&&(A=B.get(X)??null)}for(let X=0;X<te.length;X++)ue[X]=T.project(te[X],s,i,o);for(let X=1;X<te.length-1;X++){Q++;let ie=0,me=X,Ge=X+1,ae=te[ie],fe=te[me],Se=te[Ge],pe=ue[ie],ve=ue[me],we=ue[Ge],Et=(pe[0]!==pe[0]?1:0)+(ve[0]!==ve[0]?1:0)+(we[0]!==we[0]?1:0);if(Et===3||Et===0&&!h&&(ve[0]-pe[0])*(we[1]-pe[1])-(ve[1]-pe[1])*(we[0]-pe[0])>0)continue;let _e,Pe,He,je=null;if(J!==null&&J.iA[Q]!==void 0)_e=J.iA[Q],Pe=J.iB[Q],He=J.iC[Q],je=J.lit[Q];else{let ne=fe[0]-ae[0],ye=fe[1]-ae[1],xe=fe[2]-ae[2],ge=Se[0]-ae[0],et=Se[1]-ae[1],tt=Se[2]-ae[2],nt=ye*tt-xe*et,$e=xe*ge-ne*tt,oe=ne*et-ye*ge,Z=Math.hypot(nt,$e,oe)||1,se=nt/Z,be=$e/Z,ce=oe/Z,de,ze,Ct,Gt,St,xt,At,wt,Mt;if(F){let We=F[j],Me=We[ie],Re=We[me],qe=We[Ge];de=Me[0],ze=Me[1],Ct=Me[2],Gt=Re[0],St=Re[1],xt=Re[2],At=qe[0],wt=qe[1],Mt=qe[2]}else de=Gt=At=se,ze=St=wt=be,Ct=xt=Mt=ce;let Yt=de*g+ze*_+Ct*E,Nt=Gt*g+St*_+xt*E,Dt=At*g+wt*_+Mt*E,hn=h?Math.abs(Yt):Math.max(0,-Yt),mn=h?Math.abs(Nt):Math.max(0,-Nt),fn=h?Math.abs(Dt):Math.max(0,-Dt);if(_e=Math.min(1,L+hn*z),Pe=Math.min(1,L+mn*z),He=Math.min(1,L+fn*z),k){let We=(_e+Pe+He)/3,Me=Math.max(0,We-L),Re=ee.color??"#ffffff",qe=Me*255|0,Vt=`${Re}:${qe}`,rt=R.get(Vt);if(rt===void 0){let Lt=Oe(Re),yn=L*v[0]/255+Me*x[0]/255,gn=L*v[1]/255+Me*x[1]/255,bn=L*v[2]/255+Me*x[2]/255,vn=Math.min(255,Lt[0]*yn),En=Math.min(255,Lt[1]*gn),Cn=Math.min(255,Lt[2]*bn);rt=`#${le(vn)}${le(En)}${le(Cn)}`,R.set(Vt,rt)}je=rt}J!==null&&(J.iA[Q]=_e,J.iB[Q]=Pe,J.iC[Q]=He,J.lit[Q]=je)}let Rt=b[j]??!1,Fe=1+(C?.[j]??0),Bt=null;if(A!==null&&U){let ne=U[ie],ye=U[me],xe=U[Ge],ge=Math.max(0,(_e+Pe+He)/3-L);Bt={sampler:A,ua:ne[0],va:ne[1],ub:ye[0],vb:ye[1],uc:xe[0],vc:xe[1],tintR:L*v[0]/255+ge*x[0]/255,tintG:L*v[1]/255+ge*x[1]/255,tintB:L*v[2]/255+ge*x[2]/255}}if(Et===0)Kt(pe[0],pe[1],(pe[3]??pe[2])*Fe,_e,ve[0],ve[1],(ve[3]??ve[2])*Fe,Pe,we[0],we[1],(we[3]??we[2])*Fe,He,w,y,je,G,O,I,s,i,Ce(ae,fe,Se,Rt),h,ae,fe,Se,H,P,Bt);else{let ne=[],ye=[],xe=[ae,fe,Se],ge=[_e,Pe,He],et=T.eyeDepth(ae),tt=T.eyeDepth(fe),nt=T.eyeDepth(Se),$e=[et,tt,nt];for(let oe=0;oe<3;oe++){let Z=(oe+1)%3,se=$e[oe],be=$e[Z];if(se>0&&(ne.push(xe[oe]),ye.push(ge[oe])),se>0!=be>0){let ce=se/(se-be),de=xe[oe],ze=xe[Z];ne.push([de[0]+ce*(ze[0]-de[0]),de[1]+ce*(ze[1]-de[1]),de[2]+ce*(ze[2]-de[2])]),ye.push(ge[oe]+ce*(ge[Z]-ge[oe]))}}if(ne.length>=3){let oe=ne.map(Z=>T.project(Z,s,i,o));for(let Z=1;Z<ne.length-1;Z++){let se=oe[0],be=oe[Z],ce=oe[Z+1],de=(be[0]-se[0])*(ce[1]-se[1])-(be[1]-se[1])*(ce[0]-se[0]);!h&&de>0||Kt(se[0],se[1],(se[3]??se[2])*Fe,ye[0],be[0],be[1],(be[3]??be[2])*Fe,ye[Z],ce[0],ce[1],(ce[3]??ce[2])*Fe,ye[Z+1],w,y,je,G,O,I,s,i,Ce(ne[0],ne[Z],ne[Z+1],Rt),h,ne[0],ne[Z],ne[Z+1],H,P,null)}}}}}V&&(V.loop??(V.loop=[])).push(performance.now()-ke);let Ft=V?performance.now():0,Ie=G,Ae=O,Qe=H;if(r>1){let j=zn(G,O,I,H,t,e,r,w);Ie=j.glyphBuf,Ae=j.colorBuf,Qe=j.worldPos}M&&Hn(Ie,Ae,Qe,t,e,o,w,n.temporalBlend,n.temporalHistory,l);let vt=Rn(Ie,Ae,t,e);return V&&(V.string??(V.string=[])).push(performance.now()-Ft),vt}function Hn(n,t,e,o,r,s,i,l,a,u){let m=o*r,c=i.length-1,d=new Map;for(let w=0;w<i.length;w++)d.set(i[w],w);let h=a.cam;(a.cols!==o||a.rows!==r||a.idx.length!==m)&&(a.cols=o,a.rows=r,a.idx=new Float32Array(m),a.r=new Float32Array(m),a.g=new Float32Array(m),a.b=new Float32Array(m),h=null);let f=null;if(h){let w=Le({rotX:h.rotX,rotY:h.rotY,distance:h.distance,perspective:h.perspective,zoom:h.zoom,stretch:h.stretch});w.target=h.target,f=y=>w.project(y,o,r,s)}let b=new Float32Array(m),C=new Float32Array(m),P=new Float32Array(m),T=new Float32Array(m);for(let w=0;w<r;w++)for(let y=0;y<o;y++){let G=w*o+y,k=d.get(n[G])??0,O=0,I=0,M=0,H=t?t[G]:null;if(H){let Y=Oe(H);O=Y[0],I=Y[1],M=Y[2]}let p=0,S=0,g=0,_=0,E=0,z=e[G*3];if(f&&z===z){let Y=f([z,e[G*3+1],e[G*3+2]]),N=Math.round(Y[0]),q=Math.round(Y[1]);if(Y[0]===Y[0]&&N>=0&&N<o&&q>=0&&q<r){let $=q*o+N;S=a.idx[$],g=a.r[$],_=a.g[$],E=a.b[$],p=l}}let L=1-p,x=L*k+p*S,v=L*O+p*g,F=L*I+p*_,R=L*M+p*E;b[G]=x,C[G]=v,P[G]=F,T[G]=R;let B=Math.round(x);B<0?B=0:B>c&&(B=c),n[G]=i[B],t&&(t[G]=B===0?null:`#${le(v)}${le(F)}${le(R)}`)}a.idx=b,a.r=C,a.g=P,a.b=T,a.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function zn(n,t,e,o,r,s,i,l){let a=new Map;for(let b=0;b<l.length;b++)a.set(l[b],b);let u=l.length-1,m=r*i,c=new Array(r*s).fill(" "),d=t?new Array(r*s).fill(null):null,h=o?new Float32Array(r*s*3).fill(NaN):null,f=1/(i*i);for(let b=0;b<s;b++)for(let C=0;C<r;C++){let P=0,T=0,w=0,y=0,G=0,k=0,O=0,I=0;for(let p=0;p<i;p++){let S=(b*i+p)*m+C*i;for(let g=0;g<i;g++){let _=S+g;if(e[_]!==-1/0){if(P+=a.get(n[_])??0,T++,d){let E=t[_];if(E){let z=Oe(E);w+=z[0],y+=z[1],G+=z[2]}}h&&(k+=o[_*3],O+=o[_*3+1],I+=o[_*3+2])}}}let M=b*r+C;if(T===0)continue;let H=Math.round(P*f);H<0?H=0:H>u&&(H=u),c[M]=l[H],d&&(d[M]=`#${le(w/T)}${le(y/T)}${le(G/T)}`),h&&(h[M*3]=k/T,h[M*3+1]=O/T,h[M*3+2]=I/T)}return{glyphBuf:c,colorBuf:d,worldPos:h}}var On=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),Ee=256;function Be(n,t,e,o,r,s,i,l,a,u,m,c,d,h){let f=t*n[0]+e*n[1]+o*n[2],b=r*n[0]+s*n[1]+i*n[2],C=-(l*n[0]+a*n[1]+u*n[2]),P=(f-m)/(c-m)*(Ee-1),T=(b-d)/(h-d)*(Ee-1);return[P,T,C]}function kn(n,t,e,o){let r=t[0],s=t[1],i=t[2],l=e[0],a=e[1],u=e[2],m=o[0],c=o[1],d=o[2],h=(l-r)*(c-s)-(a-s)*(m-r);if(h===0)return;let f=1/h,b=r<l?r:l;m<b&&(b=m);let C=r>l?r:l;m>C&&(C=m);let P=s<a?s:a;c<P&&(P=c);let T=s>a?s:a;c>T&&(T=c);let w=Math.max(0,Math.ceil(b)),y=Math.min(Ee-1,Math.floor(C)),G=Math.max(0,Math.ceil(P)),k=Math.min(Ee-1,Math.floor(T));if(w>y||G>k)return;let O=h>0;for(let I=G;I<=k;I++)for(let M=w;M<=y;M++){let H=M,p=I,S=(l-H)*(c-p)-(a-p)*(m-H),g=(m-H)*(s-p)-(c-p)*(r-H),_=(r-H)*(a-p)-(s-p)*(l-H);if(O?S<0||g<0||_<0:S>0||g>0||_>0)continue;let E=(S*i+g*u+_*d)*f,z=I*Ee+M;E>n[z]&&(n[z]=E)}}function In(n,t,e,o,r){let s,i,l;Math.abs(e)<.9?(s=0,i=r,l=-o):(s=-r,i=0,l=e);let a=Math.hypot(s,i,l);s/=a,i/=a,l/=a;let u=i*r-l*o,m=l*e-s*r,c=s*o-i*e,d=1/0,h=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(t[y]){C=!0;for(let G of n[y].vertices){let k=s*G[0]+i*G[1]+l*G[2],O=u*G[0]+m*G[1]+c*G[2];k<d&&(d=k),k>h&&(h=k),O<f&&(f=O),O>b&&(b=O)}}if(!C)return null;let P=(h-d)*.05+.01,T=(b-f)*.05+.01;d-=P,h+=P,f-=T,b+=T;let w=new Float64Array(Ee*Ee).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let G=n[y].vertices;if(!(G.length<3))for(let k=1;k<G.length-1;k++){let O=G[0],I=G[k],M=G[k+1],H=Be(O,s,i,l,u,m,c,e,o,r,d,h,f,b),p=Be(I,s,i,l,u,m,c,e,o,r,d,h,f,b),S=Be(M,s,i,l,u,m,c,e,o,r,d,h,f,b);kn(w,H,p,S)}}return{buf:w,right:[s,i,l],up:[u,m,c],dir:[e,o,r],uMin:d,uMax:h,vMin:f,vMax:b}}function Kt(n,t,e,o,r,s,i,l,a,u,m,c,d,h,f,b,C,P,T,w,y,G,k,O,I,M,H,p){let S=(r-n)*(u-t)-(s-t)*(a-n);if(S===0||!G&&S>0)return;let g=1/S,_=S>0,E=n<r?n:r;a<E&&(E=a);let z=n>r?n:r;a>z&&(z=a);let L=t<s?t:s;u<L&&(L=u);let x=t>s?t:s;u>x&&(x=u);let v=Math.max(0,Math.ceil(E)),F=Math.min(T-1,Math.floor(z)),R=Math.max(0,Math.ceil(L)),B=Math.min(w-1,Math.floor(x));if(!(v>F||R>B))for(let Y=R;Y<=B;Y++){let N=Y;for(let q=v;q<=F;q++){let $=q,D=(r-$)*(u-N)-(s-N)*(a-$),re=(a-$)*(t-N)-(u-N)*(n-$),V=(n-$)*(s-N)-(t-N)*(r-$);if(_?D<0||re<0||V<0:D>0||re>0||V>0)continue;let ke=(D*e+re*i+V*m)*g,ue=Y*T+q,J=P[ue];if(ke>(J>0?J*(1-H):J)){if(P[ue]=ke,M!==null){let ee=ue*3;M[ee]=(D*k[0]+re*O[0]+V*I[0])*g,M[ee+1]=(D*k[1]+re*O[1]+V*I[1])*g,M[ee+2]=(D*k[2]+re*O[2]+V*I[2])*g}let Q=(D*o+re*l+V*c)*g,Ce=f;if(p!==null){let ee=(D*p.ua+re*p.ub+V*p.uc)*g,te=(D*p.va+re*p.vb+V*p.vc)*g,U=(0,it.sampleTexel)(p.sampler,ee,te);if(U!==null&&U.a>8){let A=U.r*p.tintR|0;A>255&&(A=255);let X=U.g*p.tintG|0;X>255&&(X=255);let ie=U.b*p.tintB|0;ie>255&&(ie=255),Ce=`#${le(A)}${le(X)}${le(ie)}`,Q*=(.299*U.r+.587*U.g+.114*U.b)/255}}let Ie=(Q<0?0:Q>1?1:Q)*h,Ae=Ie|0,Qe=Ie-Ae,vt=On[(Y&3)*4+(q&3)],j=Qe>vt&&Ae<h?Ae+1:Ae;if(j>h&&(j=h),y!==null){let ee=(D*y.luA+re*y.luB+V*y.luC)*g,te=(D*y.lvA+re*y.lvB+V*y.lvC)*g,U=(D*y.ldA+re*y.ldB+V*y.ldC)*g,A=ee|0,X=te|0;if(A>=0&&A<Ee&&X>=0&&X<Ee){let ie=y.map.buf[X*Ee+A];if(ie>-1/0&&U+y.lift<ie&&(j=Math.max(0,j-Math.round(y.opacity*h)),Ce!==null)){let me=`shadow:${Ce}:${j}`,Ge=y.litCache.get(me);if(Ge===void 0){let ae=Oe(Ce),fe=y.shadowColorRgb,Se=Math.round(ae[0]*(1-y.opacity)+fe[0]*y.opacity),pe=Math.round(ae[1]*(1-y.opacity)+fe[1]*y.opacity),ve=Math.round(ae[2]*(1-y.opacity)+fe[2]*y.opacity);Ge=`#${le(Se)}${le(pe)}${le(ve)}`,y.litCache.set(me,Ge)}Ce=Ge}}}b[ue]=d[j],C&&(C[ue]=Ce)}}}}function Fn(n,t){let e=n.length,o=new Array(e);for(let l=0;l<e;l++){let a=n[l].vertices;if(a.length<3){o[l]=[0,0,0];continue}let u=a[0],m=a[1],c=a[2],d=m[0]-u[0],h=m[1]-u[1],f=m[2]-u[2],b=c[0]-u[0],C=c[1]-u[1],P=c[2]-u[2],T=h*P-f*C,w=f*b-d*P,y=d*C-h*b,G=Math.hypot(T,w,y)||1;o[l]=[T/G,w/G,y/G]}let r=new Map;for(let l=0;l<e;l++){let a=n[l].vertices;for(let u=0;u<a.length;u++){let m=a[u],c=`${m[0]},${m[1]},${m[2]}`,d=r.get(c);d||(d=[],r.set(c,d)),(d.length===0||d[d.length-1]!==l)&&d.push(l)}}let s=Math.cos(t*Math.PI/180),i=new Array(e);for(let l=0;l<e;l++){let a=n[l].vertices,u=o[l],m=new Array(a.length);for(let c=0;c<a.length;c++){let d=a[c],h=r.get(`${d[0]},${d[1]},${d[2]}`),f=0,b=0,C=0;for(let T=0;T<h.length;T++){let w=h[T],y=o[w];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=s&&(f+=y[0],b+=y[1],C+=y[2])}let P=Math.hypot(f,b,C)||1;m[c]=[f/P,b/P,C/P]}i[l]=m}return i}function Rn(n,t,e,o){let r=[],s=null,i="",l=()=>{i&&(s!==null?r.push(`<span style="color:${s}">${i}</span>`):r.push(i),i="")};for(let a=0;a<o;a++){for(let u=0;u<e;u++){let m=a*e+u,c=n[m],d=t&&c!==" "?t[m]??null:null;d!==s&&(l(),s=d),i+=c}l(),s=null,a<o-1&&r.push(`
|
|
2
|
+
`)}return r.join("")}function Jt(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,s=new Array(t);for(let i=0;i<t;i++){let l=r+i/t*Math.PI*2;e==="y"?o.rotY=l:o.rotX=l,s[i]=Je(n)}return e==="y"?o.rotY=r:o.rotX=r,s}function Bn(n,t,e,o,r,s,i,l,a,u){let m=Math.abs(r-e),c=-Math.abs(s-o),d=e<r?1:-1,h=o<s?1:-1,f=m+c;for(;;){if(e>=0&&e<a&&o>=0&&o<u){let C=o*a+e;n[C]<i&&(n[C]=i,t&&(t[C]=l))}if(e===r&&o===s)break;let b=2*f;b>=c&&(f+=c,e+=d),b<=m&&(f+=m,o+=h)}}function Yn(n,t,e,o,r){let s=[],i=null,l="",a=()=>{l&&(i!==null?s.push(`<span style="color:${i}">${l}</span>`):s.push(l),l="")};for(let u=0;u<o;u++){for(let m=0;m<e;m++){let c=u*e+m,d=n[c],h,f;d===0?(h=" ",f=null):(h=d===1?r.thin[Math.random()*r.thin.length|0]:d===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[c]??null:null),f!==i&&(a(),i=f),l+=h}a(),i=null,u<o-1&&s.push(`
|
|
3
|
+
`)}return s.join("")}var Zt=new Map;function Oe(n){let t=Zt.get(n);if(t!==void 0)return t;let e=Nn(n);return Zt.set(n,e),e}function Nn(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function le(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Qt="glyph-styles";function st(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Qt))return;let e=t.createElement("style");e.id=Qt,e.textContent=Dn,t.head.appendChild(e)}var Dn=`
|
|
4
4
|
/* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5
5
|
|
|
6
6
|
.glyph-host {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
the content from the 3D vertex being labelled. */
|
|
60
60
|
transform: translate(-50%, -50%);
|
|
61
61
|
}
|
|
62
|
-
`;function
|
|
63
|
-
`),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>E()),A.observe(n),E());function L(){A&&(A.disconnect(),A=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:S,getOptions:P,fit:E,destroy:L}}function st(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Zt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let A=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-A*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let A=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let A=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(A/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function S(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let A=!!s;o=E.drag??o,r=E.wheel??r,i=Zt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;A&&!L?S():!A&&L&&b()},pause(){c||(c=!0,y(),S(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),S(),c=!0}}}function Zt(n){return n===void 0||n===!1?1:n===!0?-1:n}function lt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Jt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function S(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",S,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",S),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=Jt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,A(),y())},destroy(){s||L(),E(),s=!0}}}function Jt(n){return n===void 0||n===!1?1:n===!0?-1:n}function en(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Qt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,A=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+A*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,A=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-A*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+A*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-A*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+A*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function S(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return S(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Qt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,S())},destroy(){c||P(),c=!0}}}function Qt(n){return n===void 0||n===!1?1:n===!0?-1:n}function tn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function _t(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function nn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(_t(i,t,e))return i;return null}var In=typeof HTMLElement<"u"?HTMLElement:class{},Rn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Te(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Bn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function kn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var at=class extends In{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Rn]}getScene(){return this._scene}_readOptions(){let e={},o=Bn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=kn(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Te(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Te(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Te(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Te(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Te(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Te(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Te(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Te(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=it(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var ke=require("@glyphcss/core"),Nn=typeof HTMLElement<"u"?HTMLElement:class{},Dn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function Pt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Yn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Pt(n)}}function Vn(n){return n.closest("glyph-scene")??null}var ct=class extends Nn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Dn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Pt(this.getAttribute("position")),scale:Yn(this.getAttribute("scale")),rotation:Pt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Vn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await(0,ke.loadMesh)(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?(0,ke.recenterPolygons)(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=(0,ke.resolveGeometry)(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Xn=typeof HTMLElement<"u"?HTMLElement:class{};function $n(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Wn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function jn(n){return n.closest("glyph-scene")??null}var ut=class extends Xn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=$n(this.getAttribute("at"));if(!e)return;let o=jn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=Wn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var qn=typeof HTMLElement<"u"?HTMLElement:class{};function pe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var dt=class extends qn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Le({rotX:pe(this.getAttribute("rot-x")),rotY:pe(this.getAttribute("rot-y")),distance:pe(this.getAttribute("distance")),perspective:pe(this.getAttribute("perspective")),zoom:pe(this.getAttribute("zoom")),stretch:pe(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=pe(this.getAttribute("rot-x")),s=pe(this.getAttribute("rot-y")),c=pe(this.getAttribute("distance")),u=pe(this.getAttribute("perspective")),p=pe(this.getAttribute("zoom")),d=pe(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Un=typeof HTMLElement<"u"?HTMLElement:class{};function Ne(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var pt=class extends Un{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=$e({rotX:Ne(this.getAttribute("rot-x")),rotY:Ne(this.getAttribute("rot-y")),zoom:Ne(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Ne(this.getAttribute("rot-x")),s=Ne(this.getAttribute("rot-y")),c=Ne(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var Kn=typeof HTMLElement<"u"?HTMLElement:class{};function Zn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ht(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Jn(n){return n.closest("glyph-scene")??null}var mt=class extends Kn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=ht(this.getAttribute("drag")),o=ht(this.getAttribute("wheel")),r=ht(this.getAttribute("invert")),i=ht(this.getAttribute("clamp-pitch")),l=Zn(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=Jn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=st(o,this._readOptions())}};var Qn=typeof HTMLElement<"u"?HTMLElement:class{};function zt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function er(n){return n.closest("glyph-scene")??null}var ft=class extends Qn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=zt(this.getAttribute("drag")),o=zt(this.getAttribute("wheel")),r=zt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=er(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=lt(o,this._readOptions())}};V(N,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_PERSPECTIVE,DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
|
|
62
|
+
`;function lt(n,t,e,o,r){return n.map(s=>{let[i,l,a]=t.project(s.at,e,o,r),u=a>-3&&i>=0&&i<e&&l>=0&&l<o;return{id:s.id,col:i,row:l,depth:a,visible:u}})}var Vn=1;function Xn(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[s,i,l]=e??[0,0,0],a=1,u=1,m=1;o!==void 0&&(typeof o=="number"?a=u=m=o:[a,u,m]=o);let c=Math.PI/180,[d,h,f]=r??[0,0,0],b=d*c,C=h*c,P=f*c,T=Math.cos(b),w=Math.sin(b),y=Math.cos(C),G=Math.sin(C),k=Math.cos(P),O=Math.sin(P);function I(M){let H=M[0]*a,p=M[1]*u,S=M[2]*m,g=k*H-O*p,_=O*H+k*p,E=S;return H=y*g+G*E,p=_,S=-G*g+y*E,g=H,_=T*p-w*S,E=w*p+T*S,[g+s,_+i,E+l]}return n.map(M=>({...M,vertices:M.vertices.map(I)}))}function at(n,t={}){st(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Le(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),n.appendChild(o);let i=new Map,l=[],a=!1,u={iA:[],iB:[],iC:[],lit:[]},m={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function c(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let d=null,h=0;function f(){let p=[];for(let g of i.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&p.push(_);if(p.length===0){d&&(d=null,b());return}let S=++h;(0,en.buildTextureSamplers)(p).then(g=>{S===h&&(d=g.size>0?g:null,b())})}function b(){a||(a=!0,Promise.resolve().then(()=>{a=!1,C()}))}function C(){let p=[],S=[],g=[],_=[],E=!1;for(let R of i.values()){let B=Xn(R.polygons,R.transform),Y=R.transform.castShadow??!1,N=R.transform.receiveShadow??!1,q=R.transform.depthBias??0;q!==0&&(E=!0);for(let $ of B)p.push($),S.push(Y),g.push(N),_.push(q)}let z=ot({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:p,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:S,receiveShadowFlags:g,depthBiases:E?_:void 0});z.shadeCache=u,z.textureSamplers=d,z.temporalHistory=m;let L=globalThis.__glyphPerf,x=L?performance.now():0,v=Je(z),F=L?performance.now():0;if(e.useColors?r.innerHTML=v:r.textContent=v,L){let R=performance.now();(L.raster??(L.raster=[])).push(F-x),(L.dom??(L.dom=[])).push(R-F),(L.polys??(L.polys=[])).push(p.length)}P()}function P(){let{cols:p,rows:S,cellAspect:g,camera:_}=e,E=lt(l.map(v=>v.hotspot),_,p,S,g),z=r.getBoundingClientRect(),L=p>0?z.width/p:8,x=S>0?z.height/S:16;for(let v=0;v<l.length;v++){let{el:F}=l[v],R=E[v];R.visible?(F.style.display="",F.style.left=`${(R.col+.5)*L}px`,F.style.top=`${(R.row+.5)*x}px`,F.style.zIndex=String(Math.round(R.depth*1e3))):F.style.display="none"}}function T(p,S={}){let g=Vn++;return i.set(g,{id:g,polygons:p,transform:S}),c(),f(),b(),{get id(){return g},get name(){return i.get(g)?.transform.id},get polygons(){return p},setTransform(_){let E=i.get(g);E&&(E.transform=_,c(),b())},dispose(){i.delete(g),c(),f(),b()}}}function w(p,S){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",p.id);let[_,E]=p.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${E*e.cellAspect}ch`,S&&g.addEventListener("click",S),s.appendChild(g);let z={hotspot:{id:p.id,at:p.at,size:p.size},el:g,onClick:S};return l.push(z),b(),{get el(){return g},remove(){let L=l.indexOf(z);L>=0&&l.splice(L,1),S&&g.removeEventListener("click",S),s.removeChild(g),b()}}}function y(){C()}function G(p){p.mode!==void 0&&(e.mode=p.mode),p.glyphPalette!==void 0&&(e.glyphPalette=p.glyphPalette),p.useColors!==void 0&&(e.useColors=p.useColors),p.cols!==void 0&&(e.cols=p.cols),p.rows!==void 0&&(e.rows=p.rows),p.cellAspect!==void 0&&(e.cellAspect=p.cellAspect),p.directionalLight!==void 0&&(e.directionalLight=p.directionalLight),p.ambientLight!==void 0&&(e.ambientLight=p.ambientLight),p.camera!==void 0&&(e.camera=p.camera),p.smoothShading!==void 0&&(e.smoothShading=p.smoothShading),p.creaseAngle!==void 0&&(e.creaseAngle=p.creaseAngle),"shadow"in p&&(e.shadow=p.shadow),p.autoSize!==void 0&&(e.autoSize=p.autoSize,e.autoSize&&!M&&typeof ResizeObserver<"u"?(M=new ResizeObserver(()=>I()),M.observe(n),I()):!e.autoSize&&M&&(M.disconnect(),M=null)),(p.mode!==void 0||p.useColors!==void 0||p.directionalLight!==void 0||p.ambientLight!==void 0||p.smoothShading!==void 0||p.creaseAngle!==void 0||p.glyphPalette!==void 0)&&c(),b()}function k(){return{...e}}function O(){let S=n.ownerDocument.createElement("span");S.textContent=Array(20).fill("M").join(`
|
|
63
|
+
`),S.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(S);let g=S.getBoundingClientRect();return S.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function I(){let p=n.clientWidth,S=n.clientHeight;if(!p||!S)return;let g=O(),_=Math.max(20,Math.floor(p/g.w)),E=Math.max(8,Math.floor(S/g.h)),z=g.h/g.w,L=!1;e.cols!==_&&(e.cols=_,L=!0),e.rows!==E&&(e.rows=E,L=!0),Math.abs(e.cellAspect-z)>.01&&(e.cellAspect=z,L=!0),L&&b()}let M=null;e.autoSize&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>I()),M.observe(n),I());function H(){M&&(M.disconnect(),M=null),i.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:T,addHotspot:w,rerender:y,setOptions:G,getOptions:k,fit:I,destroy:H}}function Ye(){let n=[],t=[],e=[];function o(i){return i==="change"?n:i==="start"?t:e}function r(i){if(n.length===0)return;let l={type:"change",camera:i()};for(let a of n.slice())try{a(l)}catch(u){console.error("[glyphcss] controls 'change' listener threw:",u)}}function s(i,l){let a=i==="start"?t:e;if(a.length===0)return;let u={type:i,camera:l()};for(let m of a.slice())try{m(u)}catch(c){console.error(`[glyphcss] controls '${i}' listener threw:`,c)}}return{changeListeners:n,startListeners:t,endListeners:e,listenerArray:o,emitChange:r,emitInteraction:s}}function Ne(n){return()=>{let t=n.camera,e=t.target??[0,0,0];return{rotX:t.rotX??0,rotY:t.rotY??0,zoom:t.zoom??1,target:[e[0],e[1],e[2]],distance:t.distance??0}}}function De(n){return{addEventListener(t,e){let o=n.listenerArray(t);o.includes(e)||o.push(e)},removeEventListener(t,e){let o=n.listenerArray(t),r=o.indexOf(e);r>=0&&o.splice(r,1)},hasEventListener(t,e){return n.listenerArray(t).includes(e)}}}function ct(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=tn(t.invert),i=t.clampPitch??!0,l=t.animate??!1,a=!1,u=!1,m=null,c=null,d=null,h={x:0,y:0},f=n.camera,b=Ye(),C=Ne(n),{emitChange:P,emitInteraction:T}=b,w=!1,y=null;function G(E){if(!(!o||a)&&d===null&&E.isPrimary!==!1){E.preventDefault(),d=E.pointerId,h={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(u=!0),T("start",C)}}function k(E){if(d===null||E.pointerId!==d||!o||a)return;E.preventDefault();let z=E.clientX-h.x,L=E.clientY-h.y;h={x:E.clientX,y:E.clientY};let x=s,v=1/4;f.rotY=f.rotY-z*v*x;let F=f.rotX-L*v*x;f.rotX=i?Math.max(-90,Math.min(90,F)):F,n.rerender(),P(C)}function O(E){if(d===E.pointerId){d=null,e.style.cursor=o&&!a?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}l&&(u=!1),T("end",C)}}function I(E){if(!r||a)return;E.preventDefault();let z=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-z))),n.rerender(),w||(w=!0,T("start",C)),P(C),y!==null&&clearTimeout(y),y=setTimeout(()=>{y=null,w=!1,T("end",C)},150)}function M(E){if(!(a||!l)){if(!u){let z=c!==null?Math.min(E-c,50):16.67,L=typeof l=="object"&&l.speed?l.speed:.3,x=typeof l=="object"&&l.axis?l.axis:"y",v=L*(z/16.67);x==="y"?f.rotY=f.rotY+v:f.rotX=f.rotX+v,n.rerender(),P(C)}c=E,m=requestAnimationFrame(M)}}function H(){m===null&&typeof requestAnimationFrame<"u"&&l&&(m=requestAnimationFrame(M))}function p(){m!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(m),m=null),c=null}function S(){e.addEventListener("pointerdown",G),e.addEventListener("pointermove",k),e.addEventListener("pointerup",O),e.addEventListener("pointercancel",O),e.addEventListener("wheel",I,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function g(){e.removeEventListener("pointerdown",G),e.removeEventListener("pointermove",k),e.removeEventListener("pointerup",O),e.removeEventListener("pointercancel",O),e.removeEventListener("wheel",I),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}function _(){y!==null&&(clearTimeout(y),y=null),w=!1}return S(),H(),{...De(b),update(E){let z=!!l;o=E.drag??o,r=E.wheel??r,s=tn(E.invert),E.clampPitch!==void 0&&(i=E.clampPitch),l=E.animate??l,!a&&d===null&&(e.style.cursor=o?"grab":"");let L=!!l;z&&!L?p():!z&&L&&H()},pause(){a||(a=!0,g(),p(),_(),d=null,u=!1)},resume(){a&&(a=!1,S(),H())},destroy(){a||g(),p(),_(),a=!0}}}function tn(n){return n===void 0||n===!1?1:n===!0?-1:n}function ut(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=nn(t.invert),i=t.animate??!1,l=!1,a=!1,u=null,m=null,c=null,d={x:0,y:0},h=!1,f=n.camera,b=Ye(),C=Ne(n),{emitChange:P,emitInteraction:T}=b,w=!1,y=null,G=1/4,k=.02;function O(x){if(!(!o||l)&&c===null&&x.isPrimary!==!1){x.preventDefault(),c=x.pointerId,d={x:x.clientX,y:x.clientY},h=x.button===2,e.style.cursor="grabbing";try{x.target.setPointerCapture(x.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0),T("start",C)}}function I(x){if(c===null||x.pointerId!==c||!o||l)return;x.preventDefault();let v=x.clientX-d.x,F=x.clientY-d.y;d={x:x.clientX,y:x.clientY};let R=s;if(h||x.shiftKey)f.rotY=f.rotY-v*G*R,f.rotX=Math.max(-90,Math.min(90,f.rotX+F*G*R));else{let B=f.target;f.target=[B[0]-v*k/f.zoom,B[1]-F*k/f.zoom,B[2]]}n.rerender(),P(C)}function M(x){if(c===x.pointerId){c=null,h=!1,e.style.cursor=o&&!l?"grab":"";try{x.target.releasePointerCapture(x.pointerId)}catch{}i&&(a=!1),T("end",C)}}function H(x){x.preventDefault()}function p(x){if(!r||l)return;x.preventDefault();let v=x.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-v))),n.rerender(),w||(w=!0,T("start",C)),P(C),y!==null&&clearTimeout(y),y=setTimeout(()=>{y=null,w=!1,T("end",C)},150)}function S(x){if(!(l||!i)){if(!a){let v=m!==null?Math.min(x-m,50):16.67,F=typeof i=="object"&&i.speed?i.speed:.3,R=typeof i=="object"&&i.axis?i.axis:"y",B=F*(v/16.67);R==="y"?f.rotY=f.rotY+B:f.rotX=f.rotX+B,n.rerender(),P(C)}m=x,u=requestAnimationFrame(S)}}function g(){u===null&&typeof requestAnimationFrame<"u"&&i&&(u=requestAnimationFrame(S))}function _(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),m=null}function E(){e.addEventListener("pointerdown",O),e.addEventListener("pointermove",I),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",H),e.addEventListener("wheel",p,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function z(){e.removeEventListener("pointerdown",O),e.removeEventListener("pointermove",I),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",H),e.removeEventListener("wheel",p),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}function L(){y!==null&&(clearTimeout(y),y=null),w=!1}return E(),g(),{...De(b),update(x){let v=!!i;o=x.drag??o,r=x.wheel??r,s=nn(x.invert),i=x.animate??i,!l&&c===null&&(e.style.cursor=o?"grab":"");let F=!!i;v&&!F?_():!v&&F&&g()},pause(){l||(l=!0,z(),_(),L(),c=null,a=!1)},resume(){l&&(l=!1,E(),g())},destroy(){l||z(),_(),L(),l=!0}}}function nn(n){return n===void 0||n===!1?1:n===!0?-1:n}var jn={enabled:!0,lookEnabled:!0,moveEnabled:!0,jumpEnabled:!0,crouchEnabled:!0,lookSensitivity:.15,invertY:!1,moveSpeed:5,jumpVelocity:7,gravity:18,eyeHeight:1.7,crouchHeight:1,groundZ:0,minPitch:5,maxPitch:175};function rn(n,t){return{enabled:t.enabled??n.enabled,lookEnabled:t.lookEnabled??n.lookEnabled,moveEnabled:t.moveEnabled??n.moveEnabled,jumpEnabled:t.jumpEnabled??n.jumpEnabled,crouchEnabled:t.crouchEnabled??n.crouchEnabled,lookSensitivity:t.lookSensitivity??n.lookSensitivity,invertY:t.invertY??n.invertY,moveSpeed:t.moveSpeed??n.moveSpeed,jumpVelocity:t.jumpVelocity??n.jumpVelocity,gravity:t.gravity??n.gravity,eyeHeight:t.eyeHeight??n.eyeHeight,crouchHeight:t.crouchHeight??n.crouchHeight,groundZ:t.groundZ??n.groundZ,minPitch:t.minPitch??n.minPitch,maxPitch:t.maxPitch??n.maxPitch}}var on=new Set(["KeyW","ArrowUp"]),sn=new Set(["KeyS","ArrowDown"]),ln=new Set(["KeyA","ArrowLeft"]),an=new Set(["KeyD","ArrowRight"]),cn=new Set(["Space"]),zt=new Set(["ControlLeft","ControlRight"]);function un(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");let e=rn(jn,t),o=n.camera,r=n.host,s=r.ownerDocument??document,i=s.defaultView??globalThis,l=Ye(),a=Ne(n),{emitChange:u,emitInteraction:m}=l,c=new Set,d=!1,h=!1,f=0,b=0,C=[0,0,e.groundZ+e.eyeHeight];function P(){o.target=[C[0],C[1],C[2]],n.rerender(),u(a)}function T(){let v=o.target??[0,0,0];C=[v[0],v[1],e.groundZ+e.eyeHeight],P()}let w=()=>{if(!(!e.enabled||!e.lookEnabled||h||d))try{r.requestPointerLock()}catch{}},y=()=>{let v=s.pointerLockElement===r;v!==d&&(d=v,m(v?"start":"end",a))},G=v=>{if(!d||!e.enabled||!e.lookEnabled||h)return;let F=v.movementX??0,R=v.movementY??0;if(F===0&&R===0)return;let B=e.lookSensitivity,Y=e.invertY?-1:1;o.rotY=((o.rotY-F*B)%360+360)%360;let N=o.rotX-R*B*Y;N<e.minPitch?N=e.minPitch:N>e.maxPitch&&(N=e.maxPitch),o.rotX=N,P()},k=v=>on.has(v)||sn.has(v)||ln.has(v)||an.has(v)||cn.has(v)||zt.has(v),O=v=>{if(!(!e.enabled||h)&&k(v.code)&&!(!d&&!e.moveEnabled)){if(cn.has(v.code)){if(!e.jumpEnabled)return;v.preventDefault(),!c.has(v.code)&&f===0&&b===0&&(f=e.jumpVelocity),c.add(v.code);return}zt.has(v.code)&&!e.crouchEnabled||!e.moveEnabled&&!zt.has(v.code)||(v.preventDefault(),c.add(v.code))}},I=v=>{k(v.code)&&c.delete(v.code)},M=()=>{c.clear()},H=null,p=0,S=.05,g=v=>{if(H===null||h)return;let F=Math.min(S,p?(v-p)/1e3:.0167);if(p=v,e.enabled){let R=!1;if(e.moveEnabled){let q=0,$=0;for(let D of c)on.has(D)?q+=1:sn.has(D)?q-=1:an.has(D)?$+=1:ln.has(D)&&($-=1);if(q!==0||$!==0){let D=o.rotY*Math.PI/180,re=-Math.cos(D),V=-Math.sin(D),ke=-Math.sin(D),ue=Math.cos(D),J=Math.hypot(q,$)||1,Q=e.moveSpeed*F;C[0]+=(re*q+ke*$)/J*Q,C[1]+=(V*q+ue*$)/J*Q,R=!0}}let Y=e.crouchEnabled&&(c.has("ControlLeft")||c.has("ControlRight"))?e.crouchHeight:e.eyeHeight;e.jumpEnabled&&(f!==0||b>0)?(f-=e.gravity*F,b+=f*F,b<=0&&(b=0,f=0)):e.jumpEnabled||(b=0,f=0);let N=e.groundZ+Y+b;Math.abs(C[2]-N)>1e-4&&(C[2]=N,R=!0),R&&P()}H=i.requestAnimationFrame(g)};function _(){H!==null||h||(p=0,typeof i.requestAnimationFrame<"u"&&(H=i.requestAnimationFrame(g)))}function E(){H!==null&&(i.cancelAnimationFrame(H),H=null)}function z(){o.eyeMode=!0,r.addEventListener("click",w),s.addEventListener("pointerlockchange",y),s.addEventListener("mousemove",G),i.addEventListener("keydown",O),i.addEventListener("keyup",I),i.addEventListener("blur",M),r.style.cursor=e.lookEnabled?"crosshair":"",r.style.touchAction="none"}function L(){if(r.removeEventListener("click",w),s.removeEventListener("pointerlockchange",y),s.removeEventListener("mousemove",G),i.removeEventListener("keydown",O),i.removeEventListener("keyup",I),i.removeEventListener("blur",M),r.style.cursor="",r.style.touchAction="",c.clear(),d)try{s.exitPointerLock()}catch{}o.eyeMode=!1}T(),z(),_();function x(v){let F=e.eyeHeight,R=e.groundZ;e=rn(e,v),h||(r.style.cursor=e.lookEnabled?"crosshair":""),(e.eyeHeight!==F||e.groundZ!==R)&&(C[2]=e.groundZ+e.eyeHeight,P())}return{...De(l),update:x,resume(){h&&(h=!1,z(),_())},pause(){h||(h=!0,L(),E())},destroy(){h||(L(),E()),h=!0},lock(){if(!(!e.enabled||!e.lookEnabled||h))try{r.requestPointerLock()}catch{}},unlock(){if(d)try{s.exitPointerLock()}catch{}},isLocked(){return d},getOrigin(){return[C[0],C[1],C[2]]},setOrigin(v){C=[v[0],v[1],v[2]],P()}}}function pn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function Ot(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function dn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let s of r)if(Ot(s,t,e))return s;return null}var $n=typeof HTMLElement<"u"?HTMLElement:class{},Wn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Te(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function qn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Un(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var pt=class extends $n{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Wn]}getScene(){return this._scene}_readOptions(){let e={},o=qn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=Un(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let i=Te(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let l=Te(this.getAttribute("rows"));l!==void 0&&(e.rows=l);let a=Te(this.getAttribute("cell-aspect"));a!==void 0&&(e.cellAspect=a);let u=Te(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let m=Te(this.getAttribute("ambient-intensity"));if(m!==void 0&&(e.ambientLight={intensity:m}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let c={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},d=this.getAttribute("shadow-color");d&&(c.color=d);let h=Te(this.getAttribute("shadow-opacity"));h!==void 0&&(c.opacity=h);let f=Te(this.getAttribute("shadow-lift"));f!==void 0&&(c.lift=f);let b=Te(this.getAttribute("shadow-max-extend"));b!==void 0&&(c.maxExtend=b),e.shadow=c}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=at(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var Ve=require("@glyphcss/core"),Kn=typeof HTMLElement<"u"?HTMLElement:class{},Zn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function kt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Jn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return kt(n)}}function Qn(n){return n.closest("glyph-scene")??null}var dt=class extends Kn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Zn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:kt(this.getAttribute("position")),scale:Jn(this.getAttribute("scale")),rotation:kt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Qn(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(e){let s=++this._loadToken,i;try{i=await(0,Ve.loadMesh)(e)}catch(m){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:m,bubbles:!0}));return}if(s!==this._loadToken){try{i.dispose()}catch{}return}let l=r.getScene();if(!l){try{i.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?(0,Ve.recenterPolygons)(i.polygons):i.polygons;this._handle=l.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let i=this.getAttribute("size"),l=i!==null?parseFloat(i):1,a=this.getAttribute("color")??void 0,u;try{u=(0,Ve.resolveGeometry)(o,{size:Number.isFinite(l)?l:1,color:a})}catch(m){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:m,bubbles:!0}));return}this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var er=typeof HTMLElement<"u"?HTMLElement:class{};function tr(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function nr(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function rr(n){return n.closest("glyph-scene")??null}var ht=class extends er{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=tr(this.getAttribute("at"));if(!e)return;let o=rr(this);if(!o)return;if(!o.getScene()){let a=()=>{o.removeEventListener("glyphcss:scene-ready",a),this._register()};o.addEventListener("glyphcss:scene-ready",a);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=nr(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let l=this._handle.el;for(;this.firstChild;)l.appendChild(this.firstChild)}};var or=typeof HTMLElement<"u"?HTMLElement:class{};function he(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var mt=class extends or{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Le({rotX:he(this.getAttribute("rot-x")),rotY:he(this.getAttribute("rot-y")),distance:he(this.getAttribute("distance")),perspective:he(this.getAttribute("perspective")),zoom:he(this.getAttribute("zoom")),stretch:he(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=he(this.getAttribute("rot-x")),l=he(this.getAttribute("rot-y")),a=he(this.getAttribute("distance")),u=he(this.getAttribute("perspective")),m=he(this.getAttribute("zoom")),c=he(this.getAttribute("stretch")),d=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,d=!0),l!==void 0&&s.rotY!==l&&(s.rotY=l,d=!0),a!==void 0&&s.distance!==a&&(s.distance=a,d=!0),u!==void 0&&s.perspective!==u&&(s.perspective=u,d=!0),m!==void 0&&s.zoom!==m&&(s.zoom=m,d=!0),c!==void 0&&s.stretch!==c&&(s.stretch=c,d=!0),d&&this.querySelector("glyph-scene")?.rerender?.()}};var ir=typeof HTMLElement<"u"?HTMLElement:class{};function Xe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var ft=class extends ir{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ue({rotX:Xe(this.getAttribute("rot-x")),rotY:Xe(this.getAttribute("rot-y")),zoom:Xe(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=Xe(this.getAttribute("rot-x")),l=Xe(this.getAttribute("rot-y")),a=Xe(this.getAttribute("zoom")),u=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,u=!0),l!==void 0&&s.rotY!==l&&(s.rotY=l,u=!0),a!==void 0&&s.zoom!==a&&(s.zoom=a,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var sr=typeof HTMLElement<"u"?HTMLElement:class{};function lr(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function yt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ar(n){return n.closest("glyph-scene")??null}var gt=class extends sr{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=yt(this.getAttribute("drag")),o=yt(this.getAttribute("wheel")),r=yt(this.getAttribute("invert")),s=yt(this.getAttribute("clamp-pitch")),i=lr(this.getAttribute("animate-speed")),l=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...i!==void 0?{animate:{speed:i,axis:l}}:{}}}_attach(){if(this._controls)return;let e=ar(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=ct(o,this._readOptions())}};var cr=typeof HTMLElement<"u"?HTMLElement:class{};function It(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ur(n){return n.closest("glyph-scene")??null}var bt=class extends cr{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=It(this.getAttribute("drag")),o=It(this.getAttribute("wheel")),r=It(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=ur(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=ut(o,this._readOptions())}};K(W,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_PERSPECTIVE,DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
|