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.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var mt=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var tn=(n,t)=>{for(var e in t)mt(n,e,{get:t[e],enumerable:!0})},nn=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Qt(t))!en.call(n,r)&&r!==e&&mt(n,r,{get:()=>t[r],enumerable:!(o=Jt(t,r))||o.enumerable});return n};var rn=n=>nn(mt({},"__esModule",{value:!0}),n);var Xn={};tn(Xn,{GlyphHotspotElement:()=>We,GlyphMapControlsElement:()=>Ue,GlyphMeshElement:()=>$e,GlyphOrbitControlsElement:()=>qe,GlyphOrthographicCameraElement:()=>Ne,GlyphPerspectiveCameraElement:()=>je,GlyphSceneElement:()=>Ve});module.exports=rn(Xn);var Bt=require("@glyphcss/core");var Gt=Math.PI/180,Lt=.01,on=32e3,sn=Lt*1.01;function ft(n,t,e){let o=n[1],r=n[0],l=n[2],a=e*Gt,i=Math.cos(a),c=Math.sin(a),u=o*i-r*c,p=o*c+r*i,d=l,h=t*Gt,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??on,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=ft([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*sn}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=ft(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*Lt;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 Tt(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=ft(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 ln={direction:[-.5,-.7,-.5],intensity:1},an={intensity:.4};function cn(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 _t(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?cn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??ln,ambientLight:n.ambientLight??an,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 jn=" .:-=+*#%@".split(""),qn=" .:-=+*#%@".split(""),gt={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("")}},Un=gt.default;function yt(n){return gt[n]??gt.default}function Ht(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 un(n,l,a,i,d)}let c=yt(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]||bn(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,l,a)}return vn(u,p,l,a,c)}function un(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=yt(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?gn(c,h):null,N=new Map,re=n.textureSamplers??null,k=n.shadow,q=k!=null&&f.length>0?fn(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,Ke=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=(0,nt.polygonTexture)(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],it=(ae[0]!==ae[0]?1:0)+(ye[0]!==ye[0]?1:0)+(Me[0]!==Me[0]?1:0);if(it===3||it===0&&!m&&(ye[0]-ae[0])*(Me[1]-ae[1])-(ye[1]-ae[1])*(Me[0]-ae[0])>0)continue;let Ge,Le,Te,ke=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],ke=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],Ae=pe[2]-se[2],me=we[0]-se[0],Je=we[1]-se[1],Qe=we[2]-se[2],et=he*Qe-Ae*Je,Ye=Ae*me-$*Qe,U=$*Je-he*me,D=Math.hypot(et,Ye,U)||1,te=et/D,fe=Ye/D,le=U/D,ce,_e,st,lt,at,ct,ut,dt,pt;if(j){let De=j[B],xe=De[ee],Fe=De[de],Xe=De[Ee];ce=xe[0],_e=xe[1],st=xe[2],lt=Fe[0],at=Fe[1],ct=Fe[2],ut=Xe[0],dt=Xe[1],pt=Xe[2]}else ce=lt=ut=te,_e=at=dt=fe,st=ct=pt=le;let St=ce*g+_e*G+st*z,Mt=lt*g+at*G+ct*z,xt=ut*g+dt*G+pt*z,Xt=m?Math.abs(St):Math.max(0,-St),Vt=m?Math.abs(Mt):Math.max(0,-Mt),$t=m?Math.abs(xt):Math.max(0,-xt);if(Ge=Math.min(1,T+Xt*F),Le=Math.min(1,T+Vt*F),Te=Math.min(1,T+$t*F),P){let De=(Ge+Le+Te)/3,xe=Math.max(0,De-T),Fe=X.color??"#ffffff",Xe=xe*255|0,Ct=`${Fe}:${Xe}`,tt=N.get(Ct);if(tt===void 0){let ht=ze(Fe),Wt=T*R[0]/255+xe*W[0]/255,jt=T*R[1]/255+xe*W[1]/255,qt=T*R[2]/255+xe*W[2]/255,Ut=Math.min(255,ht[0]*Wt),Kt=Math.min(255,ht[1]*jt),Zt=Math.min(255,ht[2]*qt);tt=`#${ne(Ut)}${ne(Kt)}${ne(Zt)}`,N.set(Ct,tt)}ke=tt}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=ke)}let wt=b[B]??!1,He=1+(C?.[B]??0),At=null;if(S!==null&&Y){let $=Y[ee],he=Y[de],Ae=Y[Ee],me=Math.max(0,(Ge+Le+Te)/3-T);At={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(it===0)zt(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,ke,w,H,v,l,a,ve(se,pe,we,wt),m,se,pe,we,L,_,At);else{let $=[],he=[],Ae=[se,pe,we],me=[Ge,Le,Te],Je=x.eyeDepth(se),Qe=x.eyeDepth(pe),et=x.eyeDepth(we),Ye=[Je,Qe,et];for(let U=0;U<3;U++){let D=(U+1)%3,te=Ye[U],fe=Ye[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||zt(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,ke,w,H,v,l,a,ve($[0],$[D],$[D+1],wt),m,$[0],$[D],$[D+1],L,_,null)}}}}}O&&(O.loop??(O.loop=[])).push(performance.now()-Ke);let Et=O?performance.now():0,Pe=w,Se=H,Ze=L;if(r>1){let B=pn(w,H,v,L,t,e,r,M);Pe=B.glyphBuf,Se=B.colorBuf,Ze=B.worldPos}A&&dn(Pe,Se,Ze,t,e,o,M,n.temporalBlend,n.temporalHistory,i);let ot=yn(Pe,Se,t,e);return O&&(O.string??(O.string=[])).push(performance.now()-Et),ot}function dn(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 pn(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 hn=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 mn(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 fn(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);mn(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 zt(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 Ke=(Z*e+ie*a+O*p)*g,ge=k*x+oe,J=_[ge];if(Ke>(J>0?J*(1-L):J)){if(_[ge]=Ke,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=(0,nt.sampleTexel)(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,Ze=Pe-Se,ot=hn[(k&3)*4+(oe&3)],B=Ze>ot&&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 gn(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 yn(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
|
+
"use strict";var Et=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var yn=(n,t)=>{for(var e in t)Et(n,e,{get:t[e],enumerable:!0})},gn=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mn(t))!fn.call(n,r)&&r!==e&&Et(n,r,{get:()=>t[r],enumerable:!(o=pn(t,r))||o.enumerable});return n};var bn=n=>gn(Et({},"__esModule",{value:!0}),n);var lr={};yn(lr,{GlyphFirstPersonControlsElement:()=>nt,GlyphHotspotElement:()=>Je,GlyphMapControlsElement:()=>tt,GlyphMeshElement:()=>Ue,GlyphOrbitControlsElement:()=>et,GlyphOrthographicCameraElement:()=>Ne,GlyphPerspectiveCameraElement:()=>Qe,GlyphSceneElement:()=>Ze});module.exports=bn(lr);var Xt=require("@glyphcss/core");var zt=Math.PI/180,Ft=.01,vn=32e3,En=Ft*1.01;function Ct(n,t,e){let o=n[1],r=n[0],s=n[2],i=e*zt,l=Math.cos(i),a=Math.sin(i),u=o*l-r*a,m=o*a+r*l,c=s,h=t*zt,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??vn,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=Ct([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*En}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=Ct(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*Ft;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 Ot(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=Ct(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 Cn={direction:[-.5,-.7,-.5],intensity:1},An={intensity:.4};function Sn(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 It(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?Sn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Cn,ambientLight:n.ambientLight??An,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 at=require("@glyphcss/core");var dr=" .:-=+*#%@".split(""),hr=" .:-=+*#%@".split(""),At={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("")}},pr=At.default;function St(n){return At[n]??At.default}function Yt(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 wn(n,s,i,l,c)}let a=St(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]||Hn(u,m,h[0]|0,h[1]|0,p[0]|0,p[1]|0,c.weight??2,c.color??null,s,i)}return kn(u,m,s,i,a)}function wn(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=St(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?_n(a,h):null,R=new Map,B=n.textureSamplers??null,Y=n.shadow,N=Y!=null&&f.length>0?Tn(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=(0,at.polygonTexture)(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],dt=(ce[0]!==ce[0]?1:0)+(ge[0]!==ge[0]?1:0)+(Ge[0]!==Ge[0]?1:0);if(dt===3||dt===0&&!p&&(ge[0]-ce[0])*(Ge[1]-ce[1])-(ge[1]-ce[1])*(Ge[0]-ce[0])>0)continue;let Le,Te,_e,$e=null;if(Z!==null&&Z.iA[U]!==void 0)Le=Z.iA[U],Te=Z.iB[U],_e=Z.iC[U],$e=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],ot=Ce[1]-se[1],it=Ce[2]-se[2],st=me*it-Ae*ot,We=Ae*fe-ee*it,ne=ee*ot-me*fe,K=Math.hypot(st,We,ne)||1,oe=st/K,ye=We/K,le=ne/K,ue,Pe,ht,pt,mt,ft,yt,gt,bt;if(I){let qe=I[j],xe=qe[re],Oe=qe[he],Ke=qe[Ee];ue=xe[0],Pe=xe[1],ht=xe[2],pt=Oe[0],mt=Oe[1],ft=Oe[2],yt=Ke[0],gt=Ke[1],bt=Ke[2]}else ue=pt=yt=oe,Pe=mt=gt=ye,ht=ft=bt=le;let _t=ue*b+Pe*P+ht*C,Pt=pt*b+mt*P+ft*C,Ht=yt*b+gt*P+bt*C,rn=p?Math.abs(_t):Math.max(0,-_t),on=p?Math.abs(Pt):Math.max(0,-Pt),sn=p?Math.abs(Ht):Math.max(0,-Ht);if(Le=Math.min(1,L+rn*k),Te=Math.min(1,L+on*k),_e=Math.min(1,L+sn*k),F){let qe=(Le+Te+_e)/3,xe=Math.max(0,qe-L),Oe=J.color??"#ffffff",Ke=xe*255|0,kt=`${Oe}:${Ke}`,lt=R.get(kt);if(lt===void 0){let vt=He(Oe),ln=L*v[0]/255+xe*w[0]/255,an=L*v[1]/255+xe*w[1]/255,cn=L*v[2]/255+xe*w[2]/255,un=Math.min(255,vt[0]*ln),dn=Math.min(255,vt[1]*an),hn=Math.min(255,vt[2]*cn);lt=`#${ie(un)}${ie(dn)}${ie(hn)}`,R.set(kt,lt)}$e=lt}Z!==null&&(Z.iA[U]=Le,Z.iB[U]=Te,Z.iC[U]=_e,Z.lit[U]=$e)}let Lt=g[j]??!1,Fe=1+(E?.[j]??0),Tt=null;if(G!==null&&q){let ee=q[re],me=q[he],Ae=q[Ee],fe=Math.max(0,(Le+Te+_e)/3-L);Tt={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(dt===0)Rt(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,$e,A,z,O,s,i,ve(se,pe,Ce,Lt),p,se,pe,Ce,H,_,Tt);else{let ee=[],me=[],Ae=[se,pe,Ce],fe=[Le,Te,_e],ot=T.eyeDepth(se),it=T.eyeDepth(pe),st=T.eyeDepth(Ce),We=[ot,it,st];for(let ne=0;ne<3;ne++){let K=(ne+1)%3,oe=We[ne],ye=We[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||Rt(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,$e,A,z,O,s,i,ve(ee[0],ee[K],ee[K+1],Lt),p,ee[0],ee[K],ee[K+1],H,_,null)}}}}}D&&(D.loop??(D.loop=[])).push(performance.now()-ke);let Mt=D?performance.now():0,ze=A,we=z,rt=H;if(r>1){let j=xn(A,z,O,H,t,e,r,x);ze=j.glyphBuf,we=j.colorBuf,rt=j.worldPos}M&&Gn(ze,we,rt,t,e,o,x,n.temporalBlend,n.temporalHistory,l);let ut=Pn(ze,we,t,e);return D&&(D.string??(D.string=[])).push(performance.now()-Mt),ut}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 xn(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 Mn=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 Ln(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 Tn(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);Ln(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 Rt(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=(0,at.sampleTexel)(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,rt=ze-we,ut=Mn[(Y&3)*4+(W&3)],j=rt>ut&&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 _n(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 Pn(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 Hn(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 kn(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 Bt=new Map;function He(n){let t=Bt.get(n);if(t!==void 0)return t;let e=zn(n);return Bt.set(n,e),e}function zn(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 Nt="glyph-styles";function Vt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Nt))return;let e=t.createElement("style");e.id=Nt,e.textContent=Fn,t.head.appendChild(e)}var Fn=`
|
|
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
|
-
`),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 Mn=typeof HTMLElement<"u"?HTMLElement:class{},xn=["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 Cn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Gn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Ve=class extends Mn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...xn]}getScene(){return this._scene}_readOptions(){let e={},o=Cn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let l=Gn(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=Rt(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 Be=require("@glyphcss/core"),Ln=typeof HTMLElement<"u"?HTMLElement:class{},Tn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function bt(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){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return bt(n)}}function zn(n){return n.closest("glyph-scene")??null}var $e=class extends Ln{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Tn]}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:bt(this.getAttribute("position")),scale:_n(this.getAttribute("scale")),rotation:bt(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=zn(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(0,Be.loadMesh)(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")?(0,Be.recenterPolygons)(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=(0,Be.resolveGeometry)(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 Pn=typeof HTMLElement<"u"?HTMLElement:class{};function Hn(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 Fn(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 In(n){return n.closest("glyph-scene")??null}var We=class extends Pn{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=Hn(this.getAttribute("at"));if(!e)return;let o=In(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=Fn(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 On=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 On{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 Bn=typeof HTMLElement<"u"?HTMLElement:class{};function Re(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Ne=class extends Bn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Tt({rotX:Re(this.getAttribute("rot-x")),rotY:Re(this.getAttribute("rot-y")),zoom:Re(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=Re(this.getAttribute("rot-x")),i=Re(this.getAttribute("rot-y")),c=Re(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 kt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=Nt(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=Nt(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 Nt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Rn=typeof HTMLElement<"u"?HTMLElement:class{};function Nn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function rt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function kn(n){return n.closest("glyph-scene")??null}var qe=class extends Rn{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=rt(this.getAttribute("drag")),o=rt(this.getAttribute("wheel")),r=rt(this.getAttribute("invert")),l=rt(this.getAttribute("clamp-pitch")),a=Nn(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=kn(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=kt(o,this._readOptions())}};function Dt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,l=Yt(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=Yt(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 Yt(n){return n===void 0||n===!1?1:n===!0?-1:n}var Yn=typeof HTMLElement<"u"?HTMLElement:class{};function vt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Dn(n){return n.closest("glyph-scene")??null}var Ue=class extends Yn{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=vt(this.getAttribute("drag")),o=vt(this.getAttribute("wheel")),r=vt(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=Dn(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())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Ve),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",$e),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",We),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",je),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",Ne),!customElements.get("glyph-camera")){class n extends Ne{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",qe),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",Ue)}0&&(module.exports={GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement});
|
|
62
|
+
`;function Dt(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 On=1;function In(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 jt(n,t={}){Vt(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;(0,Xt.buildTextureSamplers)(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=In(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=It({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=Yt(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=Dt(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=On++;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 Rn=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 Me(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Yn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Nn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Ze=class extends Rn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Bn]}getScene(){return this._scene}_readOptions(){let e={},o=Yn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=Nn(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=jt(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 Be=require("@glyphcss/core"),Vn=typeof HTMLElement<"u"?HTMLElement:class{},Dn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function wt(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){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return wt(n)}}function jn(n){return n.closest("glyph-scene")??null}var Ue=class extends Vn{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:wt(this.getAttribute("position")),scale:Xn(this.getAttribute("scale")),rotation:wt(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=jn(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,Be.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,Be.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,Be.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 $n=typeof HTMLElement<"u"?HTMLElement:class{};function Wn(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 qn(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 Kn(n){return n.closest("glyph-scene")??null}var Je=class extends $n{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=Wn(this.getAttribute("at"));if(!e)return;let o=Kn(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=qn(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 Zn=typeof HTMLElement<"u"?HTMLElement:class{};function de(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Qe=class extends Zn{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 Un=typeof HTMLElement<"u"?HTMLElement:class{};function Ye(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Ne=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=Ot({rotX:Ye(this.getAttribute("rot-x")),rotY:Ye(this.getAttribute("rot-y")),zoom:Ye(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=Ye(this.getAttribute("rot-x")),l=Ye(this.getAttribute("rot-y")),a=Ye(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 Ve(){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 De(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 Xe(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 Wt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=$t(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=Ve(),E=De(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(),{...Xe(g),update(C){let k=!!l;o=C.drag??o,r=C.wheel??r,s=$t(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 $t(n){return n===void 0||n===!1?1:n===!0?-1:n}var Jn=typeof HTMLElement<"u"?HTMLElement:class{};function Qn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ct(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 et=class extends Jn{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=ct(this.getAttribute("drag")),o=ct(this.getAttribute("wheel")),r=ct(this.getAttribute("invert")),s=ct(this.getAttribute("clamp-pitch")),i=Qn(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=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=Wt(o,this._readOptions())}};function Kt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=qt(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=Ve(),E=De(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(),{...Xe(g),update(w){let v=!!i;o=w.drag??o,r=w.wheel??r,s=qt(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 qt(n){return n===void 0||n===!1?1:n===!0?-1:n}var tr=typeof HTMLElement<"u"?HTMLElement:class{};function Gt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function nr(n){return n.closest("glyph-scene")??null}var tt=class extends tr{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=nr(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=Kt(o,this._readOptions())}};var rr={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 Zt(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 Ut=new Set(["KeyW","ArrowUp"]),Jt=new Set(["KeyS","ArrowDown"]),Qt=new Set(["KeyA","ArrowLeft"]),en=new Set(["KeyD","ArrowRight"]),tn=new Set(["Space"]),xt=new Set(["ControlLeft","ControlRight"]);function nn(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");let e=Zt(rr,t),o=n.camera,r=n.host,s=r.ownerDocument??document,i=s.defaultView??globalThis,l=Ve(),a=De(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=>Ut.has(v)||Jt.has(v)||Qt.has(v)||en.has(v)||tn.has(v)||xt.has(v),z=v=>{if(!(!e.enabled||p)&&F(v.code)&&!(!h&&!e.moveEnabled)){if(tn.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}xt.has(v.code)&&!e.crouchEnabled||!e.moveEnabled&&!xt.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)Ut.has(V)?W+=1:Jt.has(V)?W-=1:en.has(V)?$+=1:Qt.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=Zt(e,v),p||(r.style.cursor=e.lookEnabled?"crosshair":""),(e.eyeHeight!==I||e.groundZ!==R)&&(E[2]=e.groundZ+e.eyeHeight,_())}return{...Xe(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 or=typeof HTMLElement<"u"?HTMLElement:class{};function Se(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function je(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ir(n){return n.closest("glyph-scene")??null}var sr=["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"],nt=class extends or{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return[...sr]}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=je(this.getAttribute("enabled"));o!==void 0&&(e.enabled=o);let r=je(this.getAttribute("look-enabled"));r!==void 0&&(e.lookEnabled=r);let s=je(this.getAttribute("move-enabled"));s!==void 0&&(e.moveEnabled=s);let i=je(this.getAttribute("jump-enabled"));i!==void 0&&(e.jumpEnabled=i);let l=je(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 _=je(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=ir(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=nn(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Ze),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",Ue),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",Je),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",Qe),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",Ne),!customElements.get("glyph-camera")){class n extends Ne{}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),customElements.get("glyph-first-person-controls")||customElements.define("glyph-first-person-controls",nt)}0&&(module.exports={GlyphFirstPersonControlsElement,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement});
|
package/dist/elements.d.cts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
export { e as GlyphHotspotElement, h as GlyphMapControlsElement, i as GlyphMeshElement, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, p as GlyphPerspectiveCameraElement, s as GlyphSceneElement } from './
|
|
1
|
+
export { e as GlyphHotspotElement, h as GlyphMapControlsElement, i as GlyphMeshElement, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, p as GlyphPerspectiveCameraElement, s as GlyphSceneElement } from './GlyphMapControlsElement-ycVyIlYL.cjs';
|
|
2
2
|
import '@glyphcss/core';
|
|
3
|
+
|
|
4
|
+
declare const ELEMENT_BASE: typeof HTMLElement;
|
|
5
|
+
declare class GlyphFirstPersonControlsElement extends ELEMENT_BASE {
|
|
6
|
+
static get observedAttributes(): string[];
|
|
7
|
+
private _controls;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
11
|
+
private _readOptions;
|
|
12
|
+
private _attach;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { GlyphFirstPersonControlsElement };
|
package/dist/elements.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
export { e as GlyphHotspotElement, h as GlyphMapControlsElement, i as GlyphMeshElement, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, p as GlyphPerspectiveCameraElement, s as GlyphSceneElement } from './
|
|
1
|
+
export { e as GlyphHotspotElement, h as GlyphMapControlsElement, i as GlyphMeshElement, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, p as GlyphPerspectiveCameraElement, s as GlyphSceneElement } from './GlyphMapControlsElement-ycVyIlYL.js';
|
|
2
2
|
import '@glyphcss/core';
|
|
3
|
+
|
|
4
|
+
declare const ELEMENT_BASE: typeof HTMLElement;
|
|
5
|
+
declare class GlyphFirstPersonControlsElement extends ELEMENT_BASE {
|
|
6
|
+
static get observedAttributes(): string[];
|
|
7
|
+
private _controls;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
11
|
+
private _readOptions;
|
|
12
|
+
private _attach;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { GlyphFirstPersonControlsElement };
|