glyphcss 0.0.3 → 0.0.5

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var ze=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var gt=(n,t)=>{for(var e in t)ze(n,e,{get:t[e],enumerable:!0})},Te=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ft(t))!yt.call(n,r)&&r!==e&&ze(n,r,{get:()=>t[r],enumerable:!(o=mt(t,r))||o.enumerable});return n},T=(n,t,e)=>(Te(n,t,"default"),e&&Te(e,t,"default"));var bt=n=>Te(ze({},"__esModule",{value:!0}),n);var H={};gt(H,{DEFAULT_RAMP:()=>$e,GlyphHotspotElement:()=>fe,GlyphMapControlsElement:()=>ve,GlyphMeshElement:()=>me,GlyphOrbitControlsElement:()=>be,GlyphOrthographicCameraElement:()=>ge,GlyphPerspectiveCameraElement:()=>ye,GlyphSceneElement:()=>he,SOLID_RAMP:()=>je,WIREFRAME_GLYPHS:()=>Ue,WIREFRAME_PALETTES:()=>te,bakeFrames:()=>qe,buildRasterizeContext:()=>le,createGlyphCamera:()=>We,createGlyphFirstPersonControls:()=>et,createGlyphMapControls:()=>pe,createGlyphOrbitControls:()=>de,createGlyphOrthographicCamera:()=>ee,createGlyphPerspectiveCamera:()=>j,createGlyphScene:()=>ue,findGlyphMeshHandle:()=>tt,findMeshUnderPoint:()=>nt,getWireframeGlyphs:()=>ne,injectGlyphBaseStyles:()=>ae,pointInMeshElement:()=>ke,projectHotspots:()=>ce,rasterize:()=>re});module.exports=bt(H);function Be(n,t,e){let o=Math.cos(t),r=Math.sin(t),s=o*n[1]-r*n[0],i=r*n[1]+o*n[0],a=n[2],u=Math.cos(e),c=Math.sin(e),h=u*i-c*a,d=c*i+u*a;return[s,h,d]}function j(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:n.distance??3,zoom:n.zoom??.4,stretch:n.stretch??1,target:[0,0,0],eyeMode:!1,focal:5},[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 zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},project(r,s,i,a){let u=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=Be(u,t.rotY,t.rotX);if(t.eyeMode){if(c[2]>=-.001)return[NaN,NaN,c[2]];let x=t.focal/-c[2],p=Math.min(s,i)*t.zoom*x,b=s*e+c[0]*p*a*t.stretch,l=i*o+c[1]*p;return[b,l,c[2]]}let h=30,d=1.5,f=c[2]*h,m=.001,g=1-f/t.distance;if(g<m)return[NaN,NaN,c[2]];let L=1/g,E=Math.min(s,i)*t.zoom*d*L,S=s*e+c[0]*E*a*t.stretch,A=i*o+c[1]*E;return[S,A,c[2]]}}}function ee(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:0,zoom:n.zoom??.4,stretch: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 zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},project(r,s,i,a){let u=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=Be(u,t.rotY,t.rotX),d=Math.min(s,i)*t.zoom*1.5,f=s*e+c[0]*d*a*t.stretch,m=i*o+c[1]*d;return[f,m,c[2]]}}}var We=ee;var vt={direction:[.5,.7,.5],intensity:1},Et={intensity:.4};function Gt(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],a=r[(s+1)%r.length],u=`${i[0]},${i[1]},${i[2]}`,c=`${a[0]},${a[1]},${a[2]}`,h=u<c?`${u}|${c}`:`${c}|${u}`;if(t.has(h))continue;t.add(h);let d={from:i,to:a,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function le(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?Gt(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??vt,ambientLight:n.ambientLight??Et,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60}}var $e=" .:-=+*#%@".split(""),je=" .:-=+*#%@".split(""),te={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("")}},Ue=te.default;function ne(n){return te[n]??te.default}function re(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:s,rows:i,cellAspect:a}=e;if(r==="solid")return Mt(n,s,i,a);let u=ne(n.glyphPalette),c=new Uint8Array(s*i),h=n.useColors?new Array(s*i).fill(null):null;for(let d of o){let f=t.project(d.from,s,i,a),m=t.project(d.to,s,i,a);f[0]!==f[0]||m[0]!==m[0]||St(c,h,f[0]|0,f[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,s,i)}return wt(c,h,s,i,u)}function Mt(n,t,e,o){let{camera:r,polygons:s,directionalLight:i,ambientLight:a,smoothShading:u,creaseAngle:c}=n,h=ne(n.glyphPalette).solid,d=h.length-1,f=new Array(t*e).fill(" "),m=n.useColors,g=m?new Array(t*e).fill(null):null,L=new Float64Array(t*e).fill(-1/0),E=i.direction,S=Math.hypot(E[0],E[1],E[2])||1,A=E[0]/S,M=E[1]/S,x=E[2]/S,p=i.intensity??1,b=a.intensity??.4,l=Pe(i.color??"#ffffff"),v=Pe(a.color??"#ffffff"),G=u&&c>0?At(s,c):null;for(let C=0;C<s.length;C++){let y=s[C],w=y.vertices;if(!(w.length<3))for(let _=1;_<w.length-1;_++){let z=_,Y=_+1,O=w[0],k=w[z],D=w[Y],R=r.project(O,t,e,o),I=r.project(k,t,e,o),N=r.project(D,t,e,o);if(R[0]!==R[0]||I[0]!==I[0]||N[0]!==N[0])continue;let X=k[0]-O[0],$=k[1]-O[1],Ee=k[2]-O[2],K=D[0]-O[0],V=D[1]-O[1],ie=D[2]-O[2],se=$*ie-Ee*V,Z=Ee*K-X*ie,Ye=X*V-$*K,Ge=Math.hypot(se,Z,Ye)||1,rt=se/Ge,ot=Z/Ge,it=Ye/Ge,Me,Ce,xe,Ae,Le,Se,we,_e,He;if(G){let J=G[C],B=J[0],W=J[z],Q=J[Y];Me=B[0],Ce=B[1],xe=B[2],Ae=W[0],Le=W[1],Se=W[2],we=Q[0],_e=Q[1],He=Q[2]}else Me=Ae=we=rt,Ce=Le=_e=ot,xe=Se=He=it;let st=Me*A+Ce*M+xe*x,lt=Ae*A+Le*M+Se*x,at=we*A+_e*M+He*x,De=Math.min(1,b+Math.max(0,st)*p),Ne=Math.min(1,b+Math.max(0,lt)*p),Xe=Math.min(1,b+Math.max(0,at)*p),Ve=null;if(m){let J=(De+Ne+Xe)/3,B=Math.max(0,J-b),W=y.color?Pe(y.color):[255,255,255],Q=b*v[0]/255+B*l[0]/255,ct=b*v[1]/255+B*l[1]/255,ut=b*v[2]/255+B*l[2]/255,dt=Math.min(255,W[0]*Q),pt=Math.min(255,W[1]*ct),ht=Math.min(255,W[2]*ut);Ve=`#${Oe(dt)}${Oe(pt)}${Oe(ht)}`}xt(R[0],R[1],R[2],De,I[0],I[1],I[2],Ne,N[0],N[1],N[2],Xe,h,d,Ve,f,g,L,t,e)}}return Lt(f,g,t,e)}var Ct=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]);function xt(n,t,e,o,r,s,i,a,u,c,h,d,f,m,g,L,E,S,A,M){let x=(r-n)*(c-t)-(s-t)*(u-n);if(x===0||x>0)return;let p=1/x,b=x>0,l=n<r?n:r;u<l&&(l=u);let v=n>r?n:r;u>v&&(v=u);let G=t<s?t:s;c<G&&(G=c);let C=t>s?t:s;c>C&&(C=c);let y=Math.max(0,Math.ceil(l)),w=Math.min(A-1,Math.floor(v)),_=Math.max(0,Math.ceil(G)),P=Math.min(M-1,Math.floor(C));if(!(y>w||_>P))for(let z=_;z<=P;z++){let Y=z;for(let O=y;O<=w;O++){let k=O,D=(r-k)*(c-Y)-(s-Y)*(u-k),R=(u-k)*(t-Y)-(c-Y)*(n-k),I=(n-k)*(s-Y)-(t-Y)*(r-k);if(b?D<0||R<0||I<0:D>0||R>0||I>0)continue;let N=(D*e+R*i+I*h)*p,X=z*A+O;if(N>S[X]){S[X]=N;let $=(D*o+R*a+I*d)*p,K=($<0?0:$>1?1:$)*m,V=K|0,ie=K-V,se=Ct[(z&3)*4+(O&3)],Z=ie>se&&V<m?V+1:V;L[X]=f[Z>m?m:Z],E&&(E[X]=g)}}}}function At(n,t){let e=n.length,o=new Array(e);for(let a=0;a<e;a++){let u=n[a].vertices;if(u.length<3){o[a]=[0,0,0];continue}let c=u[0],h=u[1],d=u[2],f=h[0]-c[0],m=h[1]-c[1],g=h[2]-c[2],L=d[0]-c[0],E=d[1]-c[1],S=d[2]-c[2],A=m*S-g*E,M=g*L-f*S,x=f*E-m*L,p=Math.hypot(A,M,x)||1;o[a]=[A/p,M/p,x/p]}let r=new Map;for(let a=0;a<e;a++){let u=n[a].vertices;for(let c=0;c<u.length;c++){let h=u[c],d=`${h[0]},${h[1]},${h[2]}`,f=r.get(d);f||(f=[],r.set(d,f)),(f.length===0||f[f.length-1]!==a)&&f.push(a)}}let s=Math.cos(t*Math.PI/180),i=new Array(e);for(let a=0;a<e;a++){let u=n[a].vertices,c=o[a],h=new Array(u.length);for(let d=0;d<u.length;d++){let f=u[d],m=r.get(`${f[0]},${f[1]},${f[2]}`),g=0,L=0,E=0;for(let A=0;A<m.length;A++){let M=m[A],x=o[M];c[0]*x[0]+c[1]*x[1]+c[2]*x[2]>=s&&(g+=x[0],L+=x[1],E+=x[2])}let S=Math.hypot(g,L,E)||1;h[d]=[g/S,L/S,E/S]}i[a]=h}return i}function Lt(n,t,e,o){let r=[],s=null,i="",a=()=>{i&&(s!==null?r.push(`<span style="color:${s}">${i}</span>`):r.push(i),i="")};for(let u=0;u<o;u++){for(let c=0;c<e;c++){let h=u*e+c,d=n[h],f=t&&d!==" "?t[h]??null:null;f!==s&&(a(),s=f),i+=d}a(),s=null,u<o-1&&r.push(`
2
- `)}return r.join("")}function qe(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,s=new Array(t);for(let i=0;i<t;i++){let a=r+i/t*Math.PI*2;e==="y"?o.rotY=a:o.rotX=a,s[i]=re(n)}return e==="y"?o.rotY=r:o.rotX=r,s}function St(n,t,e,o,r,s,i,a,u,c){let h=Math.abs(r-e),d=-Math.abs(s-o),f=e<r?1:-1,m=o<s?1:-1,g=h+d;for(;;){if(e>=0&&e<u&&o>=0&&o<c){let E=o*u+e;n[E]<i&&(n[E]=i,t&&(t[E]=a))}if(e===r&&o===s)break;let L=2*g;L>=d&&(g+=d,e+=f),L<=h&&(g+=h,o+=m)}}function wt(n,t,e,o,r){let s=[],i=null,a="",u=()=>{a&&(i!==null?s.push(`<span style="color:${i}">${a}</span>`):s.push(a),a="")};for(let c=0;c<o;c++){for(let h=0;h<e;h++){let d=c*e+h,f=n[d],m,g;f===0?(m=" ",g=null):(m=f===1?r.thin[Math.random()*r.thin.length|0]:f===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],g=t?t[d]??null:null),g!==i&&(u(),i=g),a+=m}u(),i=null,c<o-1&&s.push(`
3
- `)}return s.join("")}function Pe(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 Oe(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Ke="glyph-styles";function ae(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Ke))return;let e=t.createElement("style");e.id=Ke,e.textContent=_t,t.head.appendChild(e)}var _t=`
1
+ "use strict";var Gt=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var yn=(n,t)=>{for(var e in t)Gt(n,e,{get:t[e],enumerable:!0})},Mt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of mn(t))!fn.call(n,r)&&r!==e&&Gt(n,r,{get:()=>t[r],enumerable:!(o=hn(t,r))||o.enumerable});return n},V=(n,t,e)=>(Mt(n,t,"default"),e&&Mt(e,t,"default"));var gn=n=>Mt(Gt({},"__esModule",{value:!0}),n);var N={};yn(N,{DEFAULT_PERSPECTIVE:()=>Tt,DEFAULT_RAMP:()=>Vt,GlyphHotspotElement:()=>ut,GlyphMapControlsElement:()=>ft,GlyphMeshElement:()=>ct,GlyphOrbitControlsElement:()=>mt,GlyphOrthographicCameraElement:()=>pt,GlyphPerspectiveCameraElement:()=>dt,GlyphSceneElement:()=>at,SOLID_RAMP:()=>Xt,WIREFRAME_GLYPHS:()=>$t,WIREFRAME_PALETTES:()=>We,bakeFrames:()=>qt,buildRasterizeContext:()=>tt,createGlyphCamera:()=>Yt,createGlyphFirstPersonControls:()=>en,createGlyphMapControls:()=>lt,createGlyphOrbitControls:()=>st,createGlyphOrthographicCamera:()=>$e,createGlyphPerspectiveCamera:()=>Le,createGlyphScene:()=>it,findGlyphMeshHandle:()=>tn,findMeshUnderPoint:()=>nn,getWireframeGlyphs:()=>je,injectGlyphBaseStyles:()=>rt,pointInMeshElement:()=>_t,projectHotspots:()=>ot,rasterize:()=>qe});module.exports=gn(N);var Kt=require("@glyphcss/core");var Nt=Math.PI/180,Dt=.01,Tt=32e3,bn=Dt*1.01;function Lt(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*Nt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*Nt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Le(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Tt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=Lt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*bn}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],A=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+A/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,A=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Dt;if(y<E)return[NaN,NaN,P,NaN];let x=M/y,L=i*e+b*x/u*t.stretch*t.fovScale,a=l*o+A*x/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function $e(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=Lt(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Yt=$e;var vn={direction:[-.5,-.7,-.5],intensity:1},En={intensity:.4};function wn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function tt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?wn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??vn,ambientLight:n.ambientLight??En,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}var nt=require("@glyphcss/core");var Vt=" .:-=+*#%@".split(""),Xt=" .:-=+*#%@".split(""),We={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},$t=We.default;function je(n){return We[n]??We.default}function qe(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return xn(n,i,l,s,d)}let c=je(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||_n(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return Pn(u,p,i,l,c)}function xn(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,$,W,Y)=>{let S=s.project(R,$,W,Y);return[$*.5+(S[0]-$*.5)*r,W*.5+(S[1]-W*.5)*r,S[2],S[3]]}}:s,M=je(n.glyphPalette).solid,b=M.length-1,A=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),x=n.temporalBlend>0&&!!n.temporalHistory,L=x?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,q=Fe(u.color??"#ffffff"),B=Fe(p.color??"#ffffff"),U=d&&h>0?Ln(c,h):null,k=new Map,ie=n.textureSamplers??null,D=n.shadow,K=D!=null&&f.length>0?Gn(c,f,g,_,H):null,se=D?.opacity??.25,J=D?.lift??.05,Q=D?.color??"#000000",le=K?Fe(Q):[0,0,0],I=globalThis.__glyphPerfDetail,Ue=I?performance.now():0,be=[],ee=n.shadeCache??null,te=-1,we=(R,$,W,Y)=>{if(K===null||!Y)return null;let S=K,O=Be(R,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),ne=Be($,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),he=Be(W,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:O[0],lvA:O[1],ldA:O[2],luB:ne[0],lvB:ne[1],ldB:ne[2],luC:he[0],lvC:he[1],ldC:he[2],lift:J,opacity:se,shadowColorRgb:le,shadowColorHex:Q,litCache:k}};for(let R=0;R<c.length;R++){let $=c[R],W=$.vertices;if(W.length<3)continue;let Y=$.uvs,S=null;if(ie!==null&&Y&&Y.length>=W.length){let O=(0,nt.polygonTexture)($);O&&(S=ie.get(O)??null)}for(let O=0;O<W.length;O++)be[O]=G.project(W[O],i,l,o);for(let O=1;O<W.length-1;O++){te++;let ne=0,he=O,xe=O+1,ae=W[ne],me=W[he],Ae=W[xe],ue=be[ne],ve=be[he],Me=be[xe],gt=(ue[0]!==ue[0]?1:0)+(ve[0]!==ve[0]?1:0)+(Me[0]!==Me[0]?1:0);if(gt===3||gt===0&&!m&&(ve[0]-ue[0])*(Me[1]-ue[1])-(ve[1]-ue[1])*(Me[0]-ue[0])>0)continue;let _e,Pe,ze,De=null;if(ee!==null&&ee.iA[te]!==void 0)_e=ee.iA[te],Pe=ee.iB[te],ze=ee.iC[te],De=ee.lit[te];else{let j=me[0]-ae[0],fe=me[1]-ae[1],Se=me[2]-ae[2],ye=Ae[0]-ae[0],Ze=Ae[1]-ae[1],Je=Ae[2]-ae[2],Qe=fe*Je-Se*Ze,Ye=Se*ye-j*Je,Z=j*Ze-fe*ye,X=Math.hypot(Qe,Ye,Z)||1,re=Qe/X,ge=Ye/X,ce=Z/X,de,He,bt,vt,Et,wt,xt,At,St;if(U){let Ve=U[R],Ge=Ve[ne],Re=Ve[he],Xe=Ve[xe];de=Ge[0],He=Ge[1],bt=Ge[2],vt=Re[0],Et=Re[1],wt=Re[2],xt=Xe[0],At=Xe[1],St=Xe[2]}else de=vt=xt=re,He=Et=At=ge,bt=wt=St=ce;let It=de*g+He*_+bt*H,Rt=vt*g+Et*_+wt*H,Bt=xt*g+At*_+St*H,rn=m?Math.abs(It):Math.max(0,-It),on=m?Math.abs(Rt):Math.max(0,-Rt),sn=m?Math.abs(Bt):Math.max(0,-Bt);if(_e=Math.min(1,z+rn*F),Pe=Math.min(1,z+on*F),ze=Math.min(1,z+sn*F),P){let Ve=(_e+Pe+ze)/3,Ge=Math.max(0,Ve-z),Re=$.color??"#ffffff",Xe=Ge*255|0,kt=`${Re}:${Xe}`,et=k.get(kt);if(et===void 0){let Ct=Fe(Re),ln=z*B[0]/255+Ge*q[0]/255,an=z*B[1]/255+Ge*q[1]/255,cn=z*B[2]/255+Ge*q[2]/255,un=Math.min(255,Ct[0]*ln),dn=Math.min(255,Ct[1]*an),pn=Math.min(255,Ct[2]*cn);et=`#${oe(un)}${oe(dn)}${oe(pn)}`,k.set(kt,et)}De=et}ee!==null&&(ee.iA[te]=_e,ee.iB[te]=Pe,ee.iC[te]=ze,ee.lit[te]=De)}let Ft=v[R]??!1,Ie=1+(C?.[R]??0),Ot=null;if(S!==null&&Y){let j=Y[ne],fe=Y[he],Se=Y[xe],ye=Math.max(0,(_e+Pe+ze)/3-z);Ot={sampler:S,ua:j[0],va:j[1],ub:fe[0],vb:fe[1],uc:Se[0],vc:Se[1],tintR:z*B[0]/255+ye*q[0]/255,tintG:z*B[1]/255+ye*q[1]/255,tintB:z*B[2]/255+ye*q[2]/255}}if(gt===0)Wt(ue[0],ue[1],(ue[3]??ue[2])*Ie,_e,ve[0],ve[1],(ve[3]??ve[2])*Ie,Pe,Me[0],Me[1],(Me[3]??Me[2])*Ie,ze,M,b,De,A,y,E,i,l,we(ae,me,Ae,Ft),m,ae,me,Ae,L,T,Ot);else{let j=[],fe=[],Se=[ae,me,Ae],ye=[_e,Pe,ze],Ze=G.eyeDepth(ae),Je=G.eyeDepth(me),Qe=G.eyeDepth(Ae),Ye=[Ze,Je,Qe];for(let Z=0;Z<3;Z++){let X=(Z+1)%3,re=Ye[Z],ge=Ye[X];if(re>0&&(j.push(Se[Z]),fe.push(ye[Z])),re>0!=ge>0){let ce=re/(re-ge),de=Se[Z],He=Se[X];j.push([de[0]+ce*(He[0]-de[0]),de[1]+ce*(He[1]-de[1]),de[2]+ce*(He[2]-de[2])]),fe.push(ye[Z]+ce*(ye[X]-ye[Z]))}}if(j.length>=3){let Z=j.map(X=>G.project(X,i,l,o));for(let X=1;X<j.length-1;X++){let re=Z[0],ge=Z[X],ce=Z[X+1],de=(ge[0]-re[0])*(ce[1]-re[1])-(ge[1]-re[1])*(ce[0]-re[0]);!m&&de>0||Wt(re[0],re[1],(re[3]??re[2])*Ie,fe[0],ge[0],ge[1],(ge[3]??ge[2])*Ie,fe[X],ce[0],ce[1],(ce[3]??ce[2])*Ie,fe[X+1],M,b,De,A,y,E,i,l,we(j[0],j[X],j[X+1],Ft),m,j[0],j[X],j[X+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ue);let Ht=I?performance.now():0,Oe=A,Ce=y,Ke=L;if(r>1){let R=Sn(A,y,E,L,t,e,r,M);Oe=R.glyphBuf,Ce=R.colorBuf,Ke=R.worldPos}x&&An(Oe,Ce,Ke,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let yt=Tn(Oe,Ce,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ht),yt}function An(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Le({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let A=M*o+b,P=h.get(n[A])??0,y=0,E=0,x=0,L=t?t[A]:null;if(L){let D=Fe(L);y=D[0],E=D[1],x=D[2]}let a=0,w=0,g=0,_=0,H=0,F=e[A*3];if(f&&F===F){let D=f([F,e[A*3+1],e[A*3+2]]),K=Math.round(D[0]),se=Math.round(D[1]);if(D[0]===D[0]&&K>=0&&K<o&&se>=0&&se<r){let J=se*o+K;w=c.idx[J],g=c.r[J],_=c.g[J],H=c.b[J],a=s}}let z=1-a,q=z*P+a*w,B=z*y+a*g,U=z*E+a*_,k=z*x+a*H;v[A]=q,C[A]=B,T[A]=U,G[A]=k;let ie=Math.round(q);ie<0?ie=0:ie>d&&(ie=d),n[A]=l[ie],t&&(t[A]=ie===0?null:`#${oe(B)}${oe(U)}${oe(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function Sn(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,A=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=Fe(H);M+=F[0],b+=F[1],A+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let x=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[x]=s[L],h&&(h[x]=`#${oe(M/G)}${oe(b/G)}${oe(A/G)}`),m&&(m[x*3]=P/G,m[x*3+1]=y/G,m[x*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var Cn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),Ee=256;function Be(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(Ee-1),G=(v-h)/(m-h)*(Ee-1);return[T,G,C]}function Mn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(Ee-1,Math.floor(C)),A=Math.max(0,Math.ceil(T)),P=Math.min(Ee-1,Math.floor(G));if(M>b||A>P)return;let y=m>0;for(let E=A;E<=P;E++)for(let x=M;x<=b;x++){let L=x,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*Ee+x;H>n[F]&&(n[F]=H)}}function Gn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let A of n[b].vertices){let P=i*A[0]+l*A[1]+s*A[2],y=u*A[0]+p*A[1]+d*A[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(Ee*Ee).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let A=n[b].vertices;if(!(A.length<3))for(let P=1;P<A.length-1;P++){let y=A[0],E=A[P],x=A[P+1],L=Be(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Be(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Be(x,i,l,s,u,p,d,e,o,r,h,m,f,v);Mn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Wt(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,A,P,y,E,x,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!A&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let q=t>i?t:i;u>q&&(q=u);let B=Math.max(0,Math.ceil(H)),U=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),ie=Math.min(M-1,Math.floor(q));if(!(B>U||k>ie))for(let D=k;D<=ie;D++){let K=D;for(let se=B;se<=U;se++){let J=se,Q=(r-J)*(u-K)-(i-K)*(c-J),le=(c-J)*(t-K)-(u-K)*(n-J),I=(n-J)*(i-K)-(t-K)*(r-J);if(_?Q<0||le<0||I<0:Q>0||le>0||I>0)continue;let Ue=(Q*e+le*l+I*p)*g,be=D*G+se,ee=T[be];if(Ue>(ee>0?ee*(1-L):ee)){if(T[be]=Ue,x!==null){let $=be*3;x[$]=(Q*P[0]+le*y[0]+I*E[0])*g,x[$+1]=(Q*P[1]+le*y[1]+I*E[1])*g,x[$+2]=(Q*P[2]+le*y[2]+I*E[2])*g}let te=(Q*o+le*s+I*d)*g,we=f;if(a!==null){let $=(Q*a.ua+le*a.ub+I*a.uc)*g,W=(Q*a.va+le*a.vb+I*a.vc)*g,Y=(0,nt.sampleTexel)(a.sampler,$,W);if(Y!==null&&Y.a>8){let S=Y.r*a.tintR|0;S>255&&(S=255);let O=Y.g*a.tintG|0;O>255&&(O=255);let ne=Y.b*a.tintB|0;ne>255&&(ne=255),we=`#${oe(S)}${oe(O)}${oe(ne)}`,te*=(.299*Y.r+.587*Y.g+.114*Y.b)/255}}let Oe=(te<0?0:te>1?1:te)*m,Ce=Oe|0,Ke=Oe-Ce,yt=Cn[(D&3)*4+(se&3)],R=Ke>yt&&Ce<m?Ce+1:Ce;if(R>m&&(R=m),b!==null){let $=(Q*b.luA+le*b.luB+I*b.luC)*g,W=(Q*b.lvA+le*b.lvB+I*b.lvC)*g,Y=(Q*b.ldA+le*b.ldB+I*b.ldC)*g,S=$|0,O=W|0;if(S>=0&&S<Ee&&O>=0&&O<Ee){let ne=b.map.buf[O*Ee+S];if(ne>-1/0&&Y+b.lift<ne&&(R=Math.max(0,R-Math.round(b.opacity*m)),we!==null)){let he=`shadow:${we}:${R}`,xe=b.litCache.get(he);if(xe===void 0){let ae=Fe(we),me=b.shadowColorRgb,Ae=Math.round(ae[0]*(1-b.opacity)+me[0]*b.opacity),ue=Math.round(ae[1]*(1-b.opacity)+me[1]*b.opacity),ve=Math.round(ae[2]*(1-b.opacity)+me[2]*b.opacity);xe=`#${oe(Ae)}${oe(ue)}${oe(ve)}`,b.litCache.set(he,xe)}we=xe}}}v[be]=h[R],C&&(C[be]=we)}}}}function Ln(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,A=Math.hypot(G,M,b)||1;o[s]=[G/A,M/A,b/A]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function Tn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
2
+ `)}return r.join("")}function qt(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,i=new Array(t);for(let l=0;l<t;l++){let s=r+l/t*Math.PI*2;e==="y"?o.rotY=s:o.rotX=s,i[l]=qe(n)}return e==="y"?o.rotY=r:o.rotX=r,i}function _n(n,t,e,o,r,i,l,s,c,u){let p=Math.abs(r-e),d=-Math.abs(i-o),h=e<r?1:-1,m=o<i?1:-1,f=p+d;for(;;){if(e>=0&&e<c&&o>=0&&o<u){let C=o*c+e;n[C]<l&&(n[C]=l,t&&(t[C]=s))}if(e===r&&o===i)break;let v=2*f;v>=d&&(f+=d,e+=h),v<=p&&(f+=p,o+=m)}}function Pn(n,t,e,o,r){let i=[],l=null,s="",c=()=>{s&&(l!==null?i.push(`<span style="color:${l}">${s}</span>`):i.push(s),s="")};for(let u=0;u<o;u++){for(let p=0;p<e;p++){let d=u*e+p,h=n[d],m,f;h===0?(m=" ",f=null):(m=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[d]??null:null),f!==l&&(c(),l=f),s+=m}c(),l=null,u<o-1&&i.push(`
3
+ `)}return i.join("")}var jt=new Map;function Fe(n){let t=jt.get(n);if(t!==void 0)return t;let e=zn(n);return jt.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 oe(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Ut="glyph-styles";function rt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Ut))return;let e=t.createElement("style");e.id=Ut,e.textContent=Hn,t.head.appendChild(e)}var Hn=`
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,4 +59,5 @@
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function ce(n,t,e,o,r){return n.map(s=>{let[i,a,u]=t.project(s.at,e,o,r),c=u>-3&&i>=0&&i<e&&a>=0&&a<o;return{id:s.id,col:i,row:a,depth:u,visible:c}})}var Ht=1;function Tt(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[s,i,a]=e??[0,0,0],u=1,c=1,h=1;o!==void 0&&(typeof o=="number"?u=c=h=o:[u,c,h]=o);let[d,f,m]=r??[0,0,0],g=Math.cos(d),L=Math.sin(d),E=Math.cos(f),S=Math.sin(f),A=Math.cos(m),M=Math.sin(m);function x(p){let b=p[0]*u,l=p[1]*c,v=p[2]*h,G=A*b-M*l,C=M*b+A*l,y=v;return b=E*G+S*y,l=C,v=-S*G+E*y,G=b,C=g*l-L*v,y=L*l+g*v,[G+s,C+i,y+a]}return n.map(p=>({...p,vertices:p.vertices.map(x)}))}function ue(n,t={}){ae(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??j(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,autoSize:t.autoSize??!1},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,a=[],u=!1;function c(){u||(u=!0,Promise.resolve().then(()=>{u=!1,h()}))}function h(){let p=[];for(let v of i.values()){let G=Tt(v.polygons,v.transform);for(let C of G)p.push(C)}let b=le({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:p,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle}),l=re(b);e.useColors?r.innerHTML=l:r.textContent=l,d()}function d(){let{cols:p,rows:b,cellAspect:l,camera:v}=e,G=ce(a.map(_=>_.hotspot),v,p,b,l),C=r.getBoundingClientRect(),y=p>0?C.width/p:8,w=b>0?C.height/b:16;for(let _=0;_<a.length;_++){let{el:P}=a[_],z=G[_];z.visible?(P.style.display="",P.style.left=`${(z.col+.5)*y}px`,P.style.top=`${(z.row+.5)*w}px`,P.style.zIndex=String(Math.round(z.depth*1e3))):P.style.display="none"}}function f(p,b={}){let l=Ht++;return i.set(l,{id:l,polygons:p,transform:b}),c(),{get id(){return l},get name(){return i.get(l)?.transform.id},get polygons(){return p},setTransform(v){let G=i.get(l);G&&(G.transform=v,c())},dispose(){i.delete(l),c()}}}function m(p,b){let l=n.ownerDocument.createElement("div");l.className="glyph-hotspot",l.setAttribute("data-hotspot-id",p.id);let[v,G]=p.size??[1,1];l.style.position="absolute",l.style.width=`${v}ch`,l.style.height=`${G*e.cellAspect}ch`,b&&l.addEventListener("click",b),s.appendChild(l);let C={hotspot:{id:p.id,at:p.at,size:p.size},el:l,onClick:b};return a.push(C),c(),{get el(){return l},remove(){let y=a.indexOf(C);y>=0&&a.splice(y,1),b&&l.removeEventListener("click",b),s.removeChild(l),c()}}}function g(){h()}function L(p){p.mode!==void 0&&(e.mode=p.mode),p.glyphPalette!==void 0&&(e.glyphPalette=p.glyphPalette),p.useColors!==void 0&&(e.useColors=p.useColors),p.cols!==void 0&&(e.cols=p.cols),p.rows!==void 0&&(e.rows=p.rows),p.cellAspect!==void 0&&(e.cellAspect=p.cellAspect),p.directionalLight!==void 0&&(e.directionalLight=p.directionalLight),p.ambientLight!==void 0&&(e.ambientLight=p.ambientLight),p.camera!==void 0&&(e.camera=p.camera),p.smoothShading!==void 0&&(e.smoothShading=p.smoothShading),p.creaseAngle!==void 0&&(e.creaseAngle=p.creaseAngle),p.autoSize!==void 0&&(e.autoSize=p.autoSize,e.autoSize&&!M&&typeof ResizeObserver<"u"?(M=new ResizeObserver(()=>A()),M.observe(n),A()):!e.autoSize&&M&&(M.disconnect(),M=null)),c()}function E(){return{...e}}function S(){let p=n.ownerDocument.createElement("span");p.textContent="M",p.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(p);let b=p.getBoundingClientRect();return p.remove(),{w:b.width||8,h:b.height||16}}function A(){let p=n.clientWidth,b=n.clientHeight;if(!p||!b)return;let l=S(),v=Math.max(20,Math.floor(p/l.w)),G=Math.max(8,Math.floor(b/l.h)),C=l.h/l.w,y=!1;e.cols!==v&&(e.cols=v,y=!0),e.rows!==G&&(e.rows=G,y=!0),Math.abs(e.cellAspect-C)>.01&&(e.cellAspect=C,y=!0),y&&c()}let M=null;e.autoSize&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>A()),M.observe(n),A());function x(){M&&(M.disconnect(),M=null),i.clear(),n.contains(o)&&n.removeChild(o)}return c(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:f,addHotspot:m,rerender:g,setOptions:L,getOptions:E,fit:A,destroy:x}}function de(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Ze(t.invert),i=t.animate??!1,a=!1,u=!1,c=null,h=null,d=null,f={x:0,y:0},m=n.camera;function g(l){if(!(!o||a)&&d===null&&l.isPrimary!==!1){l.preventDefault(),d=l.pointerId,f={x:l.clientX,y:l.clientY},e.style.cursor="grabbing";try{l.target.setPointerCapture(l.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function L(l){if(d===null||l.pointerId!==d||!o||a)return;l.preventDefault();let v=l.clientX-f.x,G=l.clientY-f.y;f={x:l.clientX,y:l.clientY};let C=s,w=1/4*Math.PI/180;m.rotY=m.rotY-v*w*C,m.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,m.rotX-G*w*C)),n.rerender()}function E(l){if(d===l.pointerId){d=null,e.style.cursor=o&&!a?"grab":"";try{l.target.releasePointerCapture(l.pointerId)}catch{}i&&(u=!1)}}function S(l){if(!r||a)return;l.preventDefault();let v=l.deltaY*.001;m.zoom=Math.max(.05,Math.min(10,m.zoom*(1-v))),n.rerender()}function A(l){if(!(a||!i)){if(!u){let v=h!==null?Math.min(l-h,50):16.67,G=typeof i=="object"&&i.speed?i.speed:.3,C=typeof i=="object"&&i.axis?i.axis:"y",y=G*(Math.PI/180)*(v/16.67);C==="y"?m.rotY=m.rotY+y:m.rotX=m.rotX+y,n.rerender()}h=l,c=requestAnimationFrame(A)}}function M(){c===null&&typeof requestAnimationFrame<"u"&&i&&(c=requestAnimationFrame(A))}function x(){c!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(c),c=null),h=null}function p(){e.addEventListener("pointerdown",g),e.addEventListener("pointermove",L),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),e.addEventListener("wheel",S,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function b(){e.removeEventListener("pointerdown",g),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.removeEventListener("wheel",S),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return p(),M(),{update(l){let v=!!i;o=l.drag??o,r=l.wheel??r,s=Ze(l.invert),i=l.animate??i,!a&&d===null&&(e.style.cursor=o?"grab":"");let G=!!i;v&&!G?x():!v&&G&&M()},pause(){a||(a=!0,b(),x(),d=null,u=!1)},resume(){a&&(a=!1,p(),M())},destroy(){a||b(),x(),a=!0}}}function Ze(n){return n===void 0||n===!1?1:n===!0?-1:n}function pe(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Je(t.invert),i=t.animate??!1,a=!1,u=!1,c=null,h=null,d=null,f={x:0,y:0},m=!1,g=n.camera,L=1/4*Math.PI/180,E=.02;function S(y){if(!(!o||a)&&d===null&&y.isPrimary!==!1){y.preventDefault(),d=y.pointerId,f={x:y.clientX,y:y.clientY},m=y.button===2,e.style.cursor="grabbing";try{y.target.setPointerCapture(y.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function A(y){if(d===null||y.pointerId!==d||!o||a)return;y.preventDefault();let w=y.clientX-f.x,_=y.clientY-f.y;f={x:y.clientX,y:y.clientY};let P=s;if(m||y.shiftKey)g.rotY=g.rotY-w*L*P,g.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,g.rotX+_*L*P));else{let z=g.target;g.target=[z[0]-w*E/g.zoom,z[1]-_*E/g.zoom,z[2]]}n.rerender()}function M(y){if(d===y.pointerId){d=null,m=!1,e.style.cursor=o&&!a?"grab":"";try{y.target.releasePointerCapture(y.pointerId)}catch{}i&&(u=!1)}}function x(y){y.preventDefault()}function p(y){if(!r||a)return;y.preventDefault();let w=y.deltaY*.001;g.zoom=Math.max(.05,Math.min(10,g.zoom*(1-w))),n.rerender()}function b(y){if(!(a||!i)){if(!u){let w=h!==null?Math.min(y-h,50):16.67,_=typeof i=="object"&&i.speed?i.speed:.3,P=typeof i=="object"&&i.axis?i.axis:"y",z=_*(Math.PI/180)*(w/16.67);P==="y"?g.rotY=g.rotY+z:g.rotX=g.rotX+z,n.rerender()}h=y,c=requestAnimationFrame(b)}}function l(){c===null&&typeof requestAnimationFrame<"u"&&i&&(c=requestAnimationFrame(b))}function v(){c!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(c),c=null),h=null}function G(){e.addEventListener("pointerdown",S),e.addEventListener("pointermove",A),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",x),e.addEventListener("wheel",p,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function C(){e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",A),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",x),e.removeEventListener("wheel",p),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return G(),l(),{update(y){let w=!!i;o=y.drag??o,r=y.wheel??r,s=Je(y.invert),i=y.animate??i,!a&&d===null&&(e.style.cursor=o?"grab":"");let _=!!i;w&&!_?v():!w&&_&&l()},pause(){a||(a=!0,C(),v(),d=null,u=!1)},resume(){a&&(a=!1,G(),l())},destroy(){a||C(),v(),a=!0}}}function Je(n){return n===void 0||n===!1?1:n===!0?-1:n}function et(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,s=t.moveSpeed??.05,i=t.lookSpeed??.004,a=Qe(t.invert),u=!1,c=null,h={x:0,y:0},d=new Set,f=null,m=n.camera;function g(l){if(!(!o||u)&&c===null){l.preventDefault(),c=l.pointerId,h={x:l.clientX,y:l.clientY};try{l.target.setPointerCapture(l.pointerId)}catch{}}}function L(l){if(c===null||l.pointerId!==c||!o||u)return;l.preventDefault();let v=l.clientX-h.x,G=l.clientY-h.y;h={x:l.clientX,y:l.clientY},m.rotY=m.rotY-v*i*a,m.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,m.rotX+G*i*a)),n.rerender()}function E(l){if(c===l.pointerId){c=null;try{l.target.releasePointerCapture(l.pointerId)}catch{}}}function S(l){r&&!u&&d.add(l.key.toLowerCase())}function A(l){d.delete(l.key.toLowerCase())}function M(){if(u||!r||d.size===0)return;let l=m.target,v=Math.cos(m.rotY),G=Math.sin(m.rotY),C=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[l[0]-G*s,l[1]-v*s,l[2]],C=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[l[0]+G*s,l[1]+v*s,l[2]],C=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[l[0]-v*s,l[1]+G*s,l[2]],C=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[l[0]+v*s,l[1]-G*s,l[2]],C=!0),C&&n.rerender()}function x(){u||(M(),f=requestAnimationFrame(x))}function p(){e.addEventListener("pointerdown",g),e.addEventListener("pointermove",L),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),r&&(e.ownerDocument?.addEventListener("keydown",S),e.ownerDocument?.addEventListener("keyup",A)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(f=requestAnimationFrame(x))}function b(){e.removeEventListener("pointerdown",g),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.ownerDocument?.removeEventListener("keydown",S),e.ownerDocument?.removeEventListener("keyup",A),e.style.touchAction="",e.style.userSelect="",f!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(f),f=null),d.clear(),n.camera.eyeMode=!1}return p(),{update(l){o=l.drag??o,r=l.keyboard??r,s=l.moveSpeed??s,i=l.lookSpeed??i,a=Qe(l.invert)},pause(){u||(u=!0,b(),c=null)},resume(){u&&(u=!1,p())},destroy(){u||b(),u=!0}}}function Qe(n){return n===void 0||n===!1?1:n===!0?-1:n}function tt(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function ke(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function nt(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let s of r)if(ke(s,t,e))return s;return null}var zt=typeof HTMLElement<"u"?HTMLElement:class{},Pt=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size"];function oe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ot(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function kt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var he=class extends zt{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Pt]}getScene(){return this._scene}_readOptions(){let e={},o=Ot(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=kt(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let i=oe(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let a=oe(this.getAttribute("rows"));a!==void 0&&(e.rows=a);let u=oe(this.getAttribute("cell-aspect"));u!==void 0&&(e.cellAspect=u);let c=oe(this.getAttribute("directional-intensity"));c!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:c});let h=oe(this.getAttribute("ambient-intensity"));return h!==void 0&&(e.ambientLight={intensity:h}),this.hasAttribute("auto-size")&&(e.autoSize=!0),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=ue(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 U=require("@glyphcss/core"),Rt=typeof HTMLElement<"u"?HTMLElement:class{},It=["src","geometry","size","color","position","scale","rotation","normalize"];function Ft(n){let t=(0,U.computeSceneBbox)(n),e=(t.min[0]+t.max[0])/2,o=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,i=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(a=>({...a,vertices:a.vertices.map(u=>[(u[0]-e)*i,(u[1]-o)*i,(u[2]-r)*i])}))}function Re(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 Yt(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Re(n)}}function Dt(n){return n.closest("glyph-scene")??null}var me=class extends Rt{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...It]}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:Re(this.getAttribute("position")),scale:Yt(this.getAttribute("scale")),rotation:Re(this.getAttribute("rotation"))}}_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=Dt(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,U.loadMesh)(e)}catch(h){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:h,bubbles:!0}));return}if(s!==this._loadToken){try{i.dispose()}catch{}return}let a=r.getScene();if(!a){try{i.dispose()}catch{}return}let c=this.hasAttribute("normalize")?Ft(i.polygons):i.polygons;this._handle=a.add(c,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:c},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let i=this.getAttribute("size"),a=i!==null?parseFloat(i):1,u=this.getAttribute("color")??void 0,c;try{c=(0,U.resolveGeometry)(o,{size:Number.isFinite(a)?a:1,color:u})}catch(h){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:h,bubbles:!0}));return}this._handle=s.add(c,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:c},bubbles:!0}))}}}};var Nt=typeof HTMLElement<"u"?HTMLElement:class{};function Xt(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 Vt(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 Bt(n){return n.closest("glyph-scene")??null}var fe=class extends Nt{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=Xt(this.getAttribute("at"));if(!e)return;let o=Bt(this);if(!o)return;if(!o.getScene()){let u=()=>{o.removeEventListener("glyphcss:scene-ready",u),this._register()};o.addEventListener("glyphcss:scene-ready",u);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=Vt(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 a=this._handle.el;for(;this.firstChild;)a.appendChild(this.firstChild)}};var Wt=typeof HTMLElement<"u"?HTMLElement:class{};function F(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var ye=class extends Wt{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=j({rotX:F(this.getAttribute("rot-x")),rotY:F(this.getAttribute("rot-y")),distance:F(this.getAttribute("distance")),zoom:F(this.getAttribute("zoom")),stretch:F(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=F(this.getAttribute("rot-x")),a=F(this.getAttribute("rot-y")),u=F(this.getAttribute("distance")),c=F(this.getAttribute("zoom")),h=F(this.getAttribute("stretch")),d=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,d=!0),a!==void 0&&s.rotY!==a&&(s.rotY=a,d=!0),u!==void 0&&s.distance!==u&&(s.distance=u,d=!0),c!==void 0&&s.zoom!==c&&(s.zoom=c,d=!0),h!==void 0&&s.stretch!==h&&(s.stretch=h,d=!0),d&&this.querySelector("glyph-scene")?.rerender?.()}};var $t=typeof HTMLElement<"u"?HTMLElement:class{};function q(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var ge=class extends $t{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=ee({rotX:q(this.getAttribute("rot-x")),rotY:q(this.getAttribute("rot-y")),zoom:q(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=q(this.getAttribute("rot-x")),a=q(this.getAttribute("rot-y")),u=q(this.getAttribute("zoom")),c=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,c=!0),a!==void 0&&s.rotY!==a&&(s.rotY=a,c=!0),u!==void 0&&s.zoom!==u&&(s.zoom=u,c=!0),c&&this.querySelector("glyph-scene")?.rerender?.()}};var jt=typeof HTMLElement<"u"?HTMLElement:class{};function Ut(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ie(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function qt(n){return n.closest("glyph-scene")??null}var be=class extends jt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","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=Ie(this.getAttribute("drag")),o=Ie(this.getAttribute("wheel")),r=Ie(this.getAttribute("invert")),s=Ut(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}:{},...s!==void 0?{animate:{speed:s,axis:i}}:{}}}_attach(){if(this._controls)return;let e=qt(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=de(o,this._readOptions())}};var Kt=typeof HTMLElement<"u"?HTMLElement:class{};function Fe(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Zt(n){return n.closest("glyph-scene")??null}var ve=class extends Kt{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=Fe(this.getAttribute("drag")),o=Fe(this.getAttribute("wheel")),r=Fe(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=Zt(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=pe(o,this._readOptions())}};T(H,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
62
+ `;function ot(n,t,e,o,r){return n.map(i=>{let[l,s,c]=t.project(i.at,e,o,r),u=c>-3&&l>=0&&l<e&&s>=0&&s<o;return{id:i.id,col:l,row:s,depth:c,visible:u}})}var Fn=1;function On(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[i,l,s]=e??[0,0,0],c=1,u=1,p=1;o!==void 0&&(typeof o=="number"?c=u=p=o:[c,u,p]=o);let d=Math.PI/180,[h,m,f]=r??[0,0,0],v=h*d,C=m*d,T=f*d,G=Math.cos(v),M=Math.sin(v),b=Math.cos(C),A=Math.sin(C),P=Math.cos(T),y=Math.sin(T);function E(x){let L=x[0]*c,a=x[1]*u,w=x[2]*p,g=P*L-y*a,_=y*L+P*a,H=w;return L=b*g+A*H,a=_,w=-A*g+b*H,g=L,_=G*a-M*w,H=M*a+G*w,[g+i,_+l,H+s]}return n.map(x=>({...x,vertices:x.vertices.map(E)}))}function it(n,t={}){rt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Le(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let i=n.ownerDocument.createElement("div");i.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(i),n.appendChild(o);let l=new Map,s=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]},p={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let h=null,m=0;function f(){let a=[];for(let g of l.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&a.push(_);if(a.length===0){h&&(h=null,v());return}let w=++m;(0,Kt.buildTextureSamplers)(a).then(g=>{w===m&&(h=g.size>0?g:null,v())})}function v(){c||(c=!0,Promise.resolve().then(()=>{c=!1,C()}))}function C(){let a=[],w=[],g=[],_=[],H=!1;for(let k of l.values()){let ie=On(k.polygons,k.transform),D=k.transform.castShadow??!1,K=k.transform.receiveShadow??!1,se=k.transform.depthBias??0;se!==0&&(H=!0);for(let J of ie)a.push(J),w.push(D),g.push(K),_.push(se)}let F=tt({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:a,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:w,receiveShadowFlags:g,depthBiases:H?_:void 0});F.shadeCache=u,F.textureSamplers=h,F.temporalHistory=p;let z=globalThis.__glyphPerf,q=z?performance.now():0,B=qe(F),U=z?performance.now():0;if(e.useColors?r.innerHTML=B:r.textContent=B,z){let k=performance.now();(z.raster??(z.raster=[])).push(U-q),(z.dom??(z.dom=[])).push(k-U),(z.polys??(z.polys=[])).push(a.length)}T()}function T(){let{cols:a,rows:w,cellAspect:g,camera:_}=e,H=ot(s.map(B=>B.hotspot),_,a,w,g),F=r.getBoundingClientRect(),z=a>0?F.width/a:8,q=w>0?F.height/w:16;for(let B=0;B<s.length;B++){let{el:U}=s[B],k=H[B];k.visible?(U.style.display="",U.style.left=`${(k.col+.5)*z}px`,U.style.top=`${(k.row+.5)*q}px`,U.style.zIndex=String(Math.round(k.depth*1e3))):U.style.display="none"}}function G(a,w={}){let g=Fn++;return l.set(g,{id:g,polygons:a,transform:w}),d(),f(),v(),{get id(){return g},get name(){return l.get(g)?.transform.id},get polygons(){return a},setTransform(_){let H=l.get(g);H&&(H.transform=_,d(),v())},dispose(){l.delete(g),d(),f(),v()}}}function M(a,w){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",a.id);let[_,H]=a.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${H*e.cellAspect}ch`,w&&g.addEventListener("click",w),i.appendChild(g);let F={hotspot:{id:a.id,at:a.at,size:a.size},el:g,onClick:w};return s.push(F),v(),{get el(){return g},remove(){let z=s.indexOf(F);z>=0&&s.splice(z,1),w&&g.removeEventListener("click",w),i.removeChild(g),v()}}}function b(){C()}function A(a){a.mode!==void 0&&(e.mode=a.mode),a.glyphPalette!==void 0&&(e.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(e.useColors=a.useColors),a.cols!==void 0&&(e.cols=a.cols),a.rows!==void 0&&(e.rows=a.rows),a.cellAspect!==void 0&&(e.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(e.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(e.ambientLight=a.ambientLight),a.camera!==void 0&&(e.camera=a.camera),a.smoothShading!==void 0&&(e.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(e.creaseAngle=a.creaseAngle),"shadow"in a&&(e.shadow=a.shadow),a.autoSize!==void 0&&(e.autoSize=a.autoSize,e.autoSize&&!x&&typeof ResizeObserver<"u"?(x=new ResizeObserver(()=>E()),x.observe(n),E()):!e.autoSize&&x&&(x.disconnect(),x=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&d(),v()}function P(){return{...e}}function y(){let w=n.ownerDocument.createElement("span");w.textContent=Array(20).fill("M").join(`
63
+ `),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let x=null;e.autoSize&&typeof ResizeObserver<"u"&&(x=new ResizeObserver(()=>E()),x.observe(n),E());function L(){x&&(x.disconnect(),x=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:A,getOptions:P,fit:E,destroy:L}}function st(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Zt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let x=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-x*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let x=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-x))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let x=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(x/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function A(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let x=!!s;o=E.drag??o,r=E.wheel??r,i=Zt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;x&&!L?A():!x&&L&&b()},pause(){c||(c=!0,y(),A(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),A(),c=!0}}}function Zt(n){return n===void 0||n===!1?1:n===!0?-1:n}function lt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Jt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function A(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function x(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",A,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",A),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return x(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=Jt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,x(),y())},destroy(){s||L(),E(),s=!0}}}function Jt(n){return n===void 0||n===!1?1:n===!0?-1:n}function en(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Qt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,x=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+x*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,x=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-x*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+x*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-x*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+x*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function A(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return A(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Qt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,A())},destroy(){c||P(),c=!0}}}function Qt(n){return n===void 0||n===!1?1:n===!0?-1:n}function tn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function _t(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function nn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(_t(i,t,e))return i;return null}var In=typeof HTMLElement<"u"?HTMLElement:class{},Rn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Te(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Bn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function kn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var at=class extends In{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Rn]}getScene(){return this._scene}_readOptions(){let e={},o=Bn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=kn(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Te(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Te(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Te(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Te(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Te(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Te(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Te(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Te(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=it(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var ke=require("@glyphcss/core"),Nn=typeof HTMLElement<"u"?HTMLElement:class{},Dn=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function Yn(n){let t=(0,ke.computeSceneBbox)(n),e=(t.min[0]+t.max[0])/2,o=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,l=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(s=>({...s,vertices:s.vertices.map(c=>[(c[0]-e)*l,(c[1]-o)*l,(c[2]-r)*l])}))}function Pt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Vn(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Pt(n)}}function Xn(n){return n.closest("glyph-scene")??null}var ct=class extends Nn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Dn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Pt(this.getAttribute("position")),scale:Vn(this.getAttribute("scale")),rotation:Pt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Xn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await(0,ke.loadMesh)(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("normalize")?Yn(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=(0,ke.resolveGeometry)(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var $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 jn(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 qn(n){return n.closest("glyph-scene")??null}var ut=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=qn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=jn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var Un=typeof HTMLElement<"u"?HTMLElement:class{};function pe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var dt=class extends Un{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Le({rotX:pe(this.getAttribute("rot-x")),rotY:pe(this.getAttribute("rot-y")),distance:pe(this.getAttribute("distance")),perspective:pe(this.getAttribute("perspective")),zoom:pe(this.getAttribute("zoom")),stretch:pe(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=pe(this.getAttribute("rot-x")),s=pe(this.getAttribute("rot-y")),c=pe(this.getAttribute("distance")),u=pe(this.getAttribute("perspective")),p=pe(this.getAttribute("zoom")),d=pe(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Kn=typeof HTMLElement<"u"?HTMLElement:class{};function Ne(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var pt=class extends Kn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=$e({rotX:Ne(this.getAttribute("rot-x")),rotY:Ne(this.getAttribute("rot-y")),zoom:Ne(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Ne(this.getAttribute("rot-x")),s=Ne(this.getAttribute("rot-y")),c=Ne(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var Zn=typeof HTMLElement<"u"?HTMLElement:class{};function Jn(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ht(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Qn(n){return n.closest("glyph-scene")??null}var mt=class extends Zn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=ht(this.getAttribute("drag")),o=ht(this.getAttribute("wheel")),r=ht(this.getAttribute("invert")),i=ht(this.getAttribute("clamp-pitch")),l=Jn(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=Qn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=st(o,this._readOptions())}};var er=typeof HTMLElement<"u"?HTMLElement:class{};function zt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function tr(n){return n.closest("glyph-scene")??null}var ft=class extends er{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=zt(this.getAttribute("drag")),o=zt(this.getAttribute("wheel")),r=zt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=tr(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=lt(o,this._readOptions())}};V(N,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_PERSPECTIVE,DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
package/dist/index.d.cts CHANGED
@@ -1,14 +1,18 @@
1
- import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight } from './elements-DVWVBIG0.cjs';
2
- export { d as GlyphHotspotElement, e as GlyphHotspotHandle, f as GlyphHotspotOptions, g as GlyphMapControlsElement, h as GlyphMeshElement, i as GlyphMeshHandle, j as GlyphMeshTransform, k as GlyphOrbitControlsElement, l as GlyphOrthographicCameraElement, m as GlyphOrthographicCameraHandle, n as GlyphOrthographicCameraOptions, o as GlyphPerspectiveCameraElement, p as GlyphPerspectiveCameraHandle, q as GlyphPerspectiveCameraOptions, r as GlyphSceneElement, s as GlyphSceneOptions, t as createGlyphCamera, u as createGlyphOrthographicCamera, v as createGlyphPerspectiveCamera, w as createGlyphScene } from './elements-DVWVBIG0.cjs';
3
- import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, CharRamp } from '@glyphcss/core';
1
+ import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './elements-ycVyIlYL.cjs';
2
+ export { D as DEFAULT_PERSPECTIVE, e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './elements-ycVyIlYL.cjs';
3
+ import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, TextureSampler, CharRamp } from '@glyphcss/core';
4
4
  export * from '@glyphcss/core';
5
5
 
6
6
  /**
7
7
  * createGlyphOrbitControls — orbit-mode camera input for a GlyphScene.
8
8
  *
9
9
  * Left-drag rotates rotX / rotY around the target (orbit). Wheel zooms or
10
- * dollies. Mirrors glyphcss's createPolyOrbitControls semantics, adapted for
10
+ * dollies. Mirrors voxcss's createPolyOrbitControls semantics, adapted for
11
11
  * the ASCII rasterizer's GlyphCamera instead of the CSS matrix3d camera.
12
+ *
13
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
14
+ * Drag sensitivity: 4 px per degree (POINTER_DRAG_SPEED = 4).
15
+ * Animate speed: degrees per 60 Hz-equivalent frame.
12
16
  */
13
17
 
14
18
  interface GlyphOrbitControlsOptions {
@@ -18,6 +22,12 @@ interface GlyphOrbitControlsOptions {
18
22
  wheel?: boolean;
19
23
  /** Drag-direction inversion. Default: false. */
20
24
  invert?: boolean | number;
25
+ /**
26
+ * Clamp vertical drag to ±90° (camera stays above the equator, never
27
+ * flipping past either pole). Default: true. Set to false for globe-style
28
+ * unrestricted tumbling.
29
+ */
30
+ clampPitch?: boolean;
21
31
  /** Auto-rotate. Pass false or omit to disable. */
22
32
  animate?: false | {
23
33
  speed?: number;
@@ -37,8 +47,12 @@ declare function createGlyphOrbitControls(scene: GlyphSceneHandle, options?: Gly
37
47
  * createGlyphMapControls — map/pan-mode camera input for a GlyphScene.
38
48
  *
39
49
  * Left-drag pans the target (slippy-map semantics). Right-drag or
40
- * Shift+left-drag orbits. Wheel zooms. Mirrors glyphcss's createPolyMapControls
50
+ * Shift+left-drag orbits. Wheel zooms. Mirrors voxcss's createPolyMapControls
41
51
  * semantics, adapted for the ASCII rasterizer's GlyphCamera.
52
+ *
53
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
54
+ * Drag sensitivity: 4 px per degree (POINTER_DRAG_SPEED = 4).
55
+ * Animate speed: degrees per 60 Hz-equivalent frame.
42
56
  */
43
57
 
44
58
  interface GlyphMapControlsOptions {
@@ -68,12 +82,17 @@ declare function createGlyphMapControls(scene: GlyphSceneHandle, options?: Glyph
68
82
  * detach, restores `eyeMode = false`.
69
83
  *
70
84
  * Mouse-drag looks around (rotX/rotY). WASD or arrow keys move forward/backward/strafe.
85
+ *
86
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
87
+ * lookSpeed: degrees per pixel. Default: 0.15.
88
+ * moveSpeed: world units per frame.
71
89
  */
72
90
 
73
91
  interface GlyphFirstPersonControlsOptions {
74
92
  drag?: boolean;
75
93
  keyboard?: boolean;
76
94
  moveSpeed?: number;
95
+ /** Mouselook sensitivity in degrees per pixel. Default: 0.15. */
77
96
  lookSpeed?: number;
78
97
  invert?: boolean | number;
79
98
  }
@@ -184,6 +203,82 @@ interface RasterizeContextOptions {
184
203
  * shading; `180` smooths every shared vertex. Default `60`.
185
204
  */
186
205
  creaseAngle?: number;
206
+ /**
207
+ * Render both faces of every polygon (no backface culling). Default `false`
208
+ * (cull back faces — correct + faster for closed meshes). Set `true` for
209
+ * single-sided surfaces whose winding isn't guaranteed to face the camera —
210
+ * e.g. level geometry imported from a BSP — matching how a CSS/DOM renderer
211
+ * (polycss) shows both sides. Without it, "back-wound" faces vanish.
212
+ */
213
+ doubleSided?: boolean;
214
+ /**
215
+ * Supersampled anti-aliasing factor (solid mode). `1` (default) = off. `2`/`3`
216
+ * rasterize at N× the grid resolution and box-average down, removing the
217
+ * motion crawl where sub-cell-sized surfaces flip their per-cell winner
218
+ * frame-to-frame. Cost scales ~N². Use `2` for a big stability win at ~4× cost.
219
+ */
220
+ supersample?: number;
221
+ /**
222
+ * Temporal anti-aliasing: exponential blend of this frame with the previous
223
+ * one, weight in [0,1) (history weight). `0` (default) = off. Smooths the
224
+ * frame-to-frame crawl of edges that move faster than spatial supersampling
225
+ * can cover, at the cost of motion ghosting. Needs `temporalHistory` retained
226
+ * across renders (the scene does this).
227
+ */
228
+ temporalBlend?: number;
229
+ shadow?: GlyphShadowOptions;
230
+ /** Per-polygon cast flag (parallel to `polygons` array). True = this poly's mesh has castShadow. */
231
+ castShadowFlags?: boolean[];
232
+ /** Per-polygon receive flag (parallel to `polygons` array). True = this poly's mesh has receiveShadow. */
233
+ receiveShadowFlags?: boolean[];
234
+ /** Per-polygon relative depth bias (parallel to `polygons`). `pixelDepth *= 1 + bias`. */
235
+ depthBiases?: number[];
236
+ /**
237
+ * Global depth-test deadband (0 = exact, the default). A polygon replaces the
238
+ * current cell only when nearer by more than this relative fraction, so
239
+ * near-coplanar surfaces (overlapping brushes, decals, a translucent plane
240
+ * over its backing face) keep a STABLE winner instead of z-fighting per-cell
241
+ * as the camera moves. A CSS/DOM renderer gets this for free from stacking
242
+ * order; a projection-painted depth buffer needs the deadband. Typical 0.002–0.01.
243
+ */
244
+ depthEpsilon?: number;
245
+ }
246
+ /**
247
+ * Cross-frame per-triangle shading cache. The Lambert intensities and lit
248
+ * color depend only on world-space normals + light, never the camera — so
249
+ * during a camera-only change (orbit/zoom drag) they are identical frame to
250
+ * frame. Parallel arrays indexed by positional triangle order; lazily filled
251
+ * as triangles become visible. The scene clears it when geometry, light, or
252
+ * shading options change. Absent/null → always recompute (current behavior).
253
+ */
254
+ interface ShadeCache {
255
+ iA: number[];
256
+ iB: number[];
257
+ iC: number[];
258
+ lit: (string | null)[];
259
+ }
260
+ /**
261
+ * Retained previous-frame buffer for temporal anti-aliasing. Per output cell:
262
+ * blended ramp index + RGB. The scene keeps one and reuses it across renders;
263
+ * `rasterize` resets it when the grid size changes.
264
+ */
265
+ interface TemporalHistory {
266
+ idx: Float32Array;
267
+ r: Float32Array;
268
+ g: Float32Array;
269
+ b: Float32Array;
270
+ cols: number;
271
+ rows: number;
272
+ /** Snapshot of the camera that produced the stored frame (for reprojection). */
273
+ cam: {
274
+ rotX: number;
275
+ rotY: number;
276
+ target: [number, number, number];
277
+ zoom: number;
278
+ perspective: number;
279
+ distance: number;
280
+ stretch: number;
281
+ } | null;
187
282
  }
188
283
  interface RasterizeContext {
189
284
  camera: GlyphCamera;
@@ -198,6 +293,26 @@ interface RasterizeContext {
198
293
  useColors: boolean;
199
294
  smoothShading: boolean;
200
295
  creaseAngle: number;
296
+ doubleSided: boolean;
297
+ supersample: number;
298
+ temporalBlend: number;
299
+ shadow: GlyphShadowOptions | undefined;
300
+ castShadowFlags: boolean[];
301
+ receiveShadowFlags: boolean[];
302
+ depthBiases?: number[];
303
+ /** Global depth-test deadband — see {@link RasterizeContextOptions.depthEpsilon}. */
304
+ depthEpsilon?: number;
305
+ /** Optional cross-frame shading cache (see {@link ShadeCache}). */
306
+ shadeCache?: ShadeCache | null;
307
+ /**
308
+ * Decoded texture pixel samplers keyed by texture URL. When a polygon has a
309
+ * texture + UVs and its sampler is present here, the solid rasterizer samples
310
+ * the texture per cell (full image, glyph-resolution) instead of using the
311
+ * flat baked `poly.color`. Built by the scene via `buildTextureSamplers`.
312
+ */
313
+ textureSamplers?: Map<string, TextureSampler> | null;
314
+ /** Optional retained previous-frame buffer for temporal AA. */
315
+ temporalHistory?: TemporalHistory | null;
201
316
  }
202
317
  declare function buildRasterizeContext(opts: RasterizeContextOptions): RasterizeContext;
203
318
 
@@ -252,4 +367,4 @@ declare function getWireframeGlyphs(name: string): WireframeGlyphTiers;
252
367
 
253
368
  declare function injectGlyphBaseStyles(doc?: Document): void;
254
369
 
255
- export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
370
+ export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
- import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight } from './elements-DVWVBIG0.js';
2
- export { d as GlyphHotspotElement, e as GlyphHotspotHandle, f as GlyphHotspotOptions, g as GlyphMapControlsElement, h as GlyphMeshElement, i as GlyphMeshHandle, j as GlyphMeshTransform, k as GlyphOrbitControlsElement, l as GlyphOrthographicCameraElement, m as GlyphOrthographicCameraHandle, n as GlyphOrthographicCameraOptions, o as GlyphPerspectiveCameraElement, p as GlyphPerspectiveCameraHandle, q as GlyphPerspectiveCameraOptions, r as GlyphSceneElement, s as GlyphSceneOptions, t as createGlyphCamera, u as createGlyphOrthographicCamera, v as createGlyphPerspectiveCamera, w as createGlyphScene } from './elements-DVWVBIG0.js';
3
- import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, CharRamp } from '@glyphcss/core';
1
+ import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './elements-ycVyIlYL.js';
2
+ export { D as DEFAULT_PERSPECTIVE, e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './elements-ycVyIlYL.js';
3
+ import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, TextureSampler, CharRamp } from '@glyphcss/core';
4
4
  export * from '@glyphcss/core';
5
5
 
6
6
  /**
7
7
  * createGlyphOrbitControls — orbit-mode camera input for a GlyphScene.
8
8
  *
9
9
  * Left-drag rotates rotX / rotY around the target (orbit). Wheel zooms or
10
- * dollies. Mirrors glyphcss's createPolyOrbitControls semantics, adapted for
10
+ * dollies. Mirrors voxcss's createPolyOrbitControls semantics, adapted for
11
11
  * the ASCII rasterizer's GlyphCamera instead of the CSS matrix3d camera.
12
+ *
13
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
14
+ * Drag sensitivity: 4 px per degree (POINTER_DRAG_SPEED = 4).
15
+ * Animate speed: degrees per 60 Hz-equivalent frame.
12
16
  */
13
17
 
14
18
  interface GlyphOrbitControlsOptions {
@@ -18,6 +22,12 @@ interface GlyphOrbitControlsOptions {
18
22
  wheel?: boolean;
19
23
  /** Drag-direction inversion. Default: false. */
20
24
  invert?: boolean | number;
25
+ /**
26
+ * Clamp vertical drag to ±90° (camera stays above the equator, never
27
+ * flipping past either pole). Default: true. Set to false for globe-style
28
+ * unrestricted tumbling.
29
+ */
30
+ clampPitch?: boolean;
21
31
  /** Auto-rotate. Pass false or omit to disable. */
22
32
  animate?: false | {
23
33
  speed?: number;
@@ -37,8 +47,12 @@ declare function createGlyphOrbitControls(scene: GlyphSceneHandle, options?: Gly
37
47
  * createGlyphMapControls — map/pan-mode camera input for a GlyphScene.
38
48
  *
39
49
  * Left-drag pans the target (slippy-map semantics). Right-drag or
40
- * Shift+left-drag orbits. Wheel zooms. Mirrors glyphcss's createPolyMapControls
50
+ * Shift+left-drag orbits. Wheel zooms. Mirrors voxcss's createPolyMapControls
41
51
  * semantics, adapted for the ASCII rasterizer's GlyphCamera.
52
+ *
53
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
54
+ * Drag sensitivity: 4 px per degree (POINTER_DRAG_SPEED = 4).
55
+ * Animate speed: degrees per 60 Hz-equivalent frame.
42
56
  */
43
57
 
44
58
  interface GlyphMapControlsOptions {
@@ -68,12 +82,17 @@ declare function createGlyphMapControls(scene: GlyphSceneHandle, options?: Glyph
68
82
  * detach, restores `eyeMode = false`.
69
83
  *
70
84
  * Mouse-drag looks around (rotX/rotY). WASD or arrow keys move forward/backward/strafe.
85
+ *
86
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
87
+ * lookSpeed: degrees per pixel. Default: 0.15.
88
+ * moveSpeed: world units per frame.
71
89
  */
72
90
 
73
91
  interface GlyphFirstPersonControlsOptions {
74
92
  drag?: boolean;
75
93
  keyboard?: boolean;
76
94
  moveSpeed?: number;
95
+ /** Mouselook sensitivity in degrees per pixel. Default: 0.15. */
77
96
  lookSpeed?: number;
78
97
  invert?: boolean | number;
79
98
  }
@@ -184,6 +203,82 @@ interface RasterizeContextOptions {
184
203
  * shading; `180` smooths every shared vertex. Default `60`.
185
204
  */
186
205
  creaseAngle?: number;
206
+ /**
207
+ * Render both faces of every polygon (no backface culling). Default `false`
208
+ * (cull back faces — correct + faster for closed meshes). Set `true` for
209
+ * single-sided surfaces whose winding isn't guaranteed to face the camera —
210
+ * e.g. level geometry imported from a BSP — matching how a CSS/DOM renderer
211
+ * (polycss) shows both sides. Without it, "back-wound" faces vanish.
212
+ */
213
+ doubleSided?: boolean;
214
+ /**
215
+ * Supersampled anti-aliasing factor (solid mode). `1` (default) = off. `2`/`3`
216
+ * rasterize at N× the grid resolution and box-average down, removing the
217
+ * motion crawl where sub-cell-sized surfaces flip their per-cell winner
218
+ * frame-to-frame. Cost scales ~N². Use `2` for a big stability win at ~4× cost.
219
+ */
220
+ supersample?: number;
221
+ /**
222
+ * Temporal anti-aliasing: exponential blend of this frame with the previous
223
+ * one, weight in [0,1) (history weight). `0` (default) = off. Smooths the
224
+ * frame-to-frame crawl of edges that move faster than spatial supersampling
225
+ * can cover, at the cost of motion ghosting. Needs `temporalHistory` retained
226
+ * across renders (the scene does this).
227
+ */
228
+ temporalBlend?: number;
229
+ shadow?: GlyphShadowOptions;
230
+ /** Per-polygon cast flag (parallel to `polygons` array). True = this poly's mesh has castShadow. */
231
+ castShadowFlags?: boolean[];
232
+ /** Per-polygon receive flag (parallel to `polygons` array). True = this poly's mesh has receiveShadow. */
233
+ receiveShadowFlags?: boolean[];
234
+ /** Per-polygon relative depth bias (parallel to `polygons`). `pixelDepth *= 1 + bias`. */
235
+ depthBiases?: number[];
236
+ /**
237
+ * Global depth-test deadband (0 = exact, the default). A polygon replaces the
238
+ * current cell only when nearer by more than this relative fraction, so
239
+ * near-coplanar surfaces (overlapping brushes, decals, a translucent plane
240
+ * over its backing face) keep a STABLE winner instead of z-fighting per-cell
241
+ * as the camera moves. A CSS/DOM renderer gets this for free from stacking
242
+ * order; a projection-painted depth buffer needs the deadband. Typical 0.002–0.01.
243
+ */
244
+ depthEpsilon?: number;
245
+ }
246
+ /**
247
+ * Cross-frame per-triangle shading cache. The Lambert intensities and lit
248
+ * color depend only on world-space normals + light, never the camera — so
249
+ * during a camera-only change (orbit/zoom drag) they are identical frame to
250
+ * frame. Parallel arrays indexed by positional triangle order; lazily filled
251
+ * as triangles become visible. The scene clears it when geometry, light, or
252
+ * shading options change. Absent/null → always recompute (current behavior).
253
+ */
254
+ interface ShadeCache {
255
+ iA: number[];
256
+ iB: number[];
257
+ iC: number[];
258
+ lit: (string | null)[];
259
+ }
260
+ /**
261
+ * Retained previous-frame buffer for temporal anti-aliasing. Per output cell:
262
+ * blended ramp index + RGB. The scene keeps one and reuses it across renders;
263
+ * `rasterize` resets it when the grid size changes.
264
+ */
265
+ interface TemporalHistory {
266
+ idx: Float32Array;
267
+ r: Float32Array;
268
+ g: Float32Array;
269
+ b: Float32Array;
270
+ cols: number;
271
+ rows: number;
272
+ /** Snapshot of the camera that produced the stored frame (for reprojection). */
273
+ cam: {
274
+ rotX: number;
275
+ rotY: number;
276
+ target: [number, number, number];
277
+ zoom: number;
278
+ perspective: number;
279
+ distance: number;
280
+ stretch: number;
281
+ } | null;
187
282
  }
188
283
  interface RasterizeContext {
189
284
  camera: GlyphCamera;
@@ -198,6 +293,26 @@ interface RasterizeContext {
198
293
  useColors: boolean;
199
294
  smoothShading: boolean;
200
295
  creaseAngle: number;
296
+ doubleSided: boolean;
297
+ supersample: number;
298
+ temporalBlend: number;
299
+ shadow: GlyphShadowOptions | undefined;
300
+ castShadowFlags: boolean[];
301
+ receiveShadowFlags: boolean[];
302
+ depthBiases?: number[];
303
+ /** Global depth-test deadband — see {@link RasterizeContextOptions.depthEpsilon}. */
304
+ depthEpsilon?: number;
305
+ /** Optional cross-frame shading cache (see {@link ShadeCache}). */
306
+ shadeCache?: ShadeCache | null;
307
+ /**
308
+ * Decoded texture pixel samplers keyed by texture URL. When a polygon has a
309
+ * texture + UVs and its sampler is present here, the solid rasterizer samples
310
+ * the texture per cell (full image, glyph-resolution) instead of using the
311
+ * flat baked `poly.color`. Built by the scene via `buildTextureSamplers`.
312
+ */
313
+ textureSamplers?: Map<string, TextureSampler> | null;
314
+ /** Optional retained previous-frame buffer for temporal AA. */
315
+ temporalHistory?: TemporalHistory | null;
201
316
  }
202
317
  declare function buildRasterizeContext(opts: RasterizeContextOptions): RasterizeContext;
203
318
 
@@ -252,4 +367,4 @@ declare function getWireframeGlyphs(name: string): WireframeGlyphTiers;
252
367
 
253
368
  declare function injectGlyphBaseStyles(doc?: Document): void;
254
369
 
255
- export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
370
+ export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };