three-live 1.2.4 → 1.3.1
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/README.md +2 -2
- package/dist/index.d.ts +58 -0
- package/dist/three-author-engine.js +89 -63
- package/dist/three-author.cjs +88 -62
- package/dist/three-author.d.ts +58 -0
- package/dist/three-author.js +87 -61
- package/dist/three-convert.cjs +81 -59
- package/dist/three-convert.d.ts +58 -0
- package/dist/three-convert.js +80 -58
- package/dist/three-live-animation.cjs +8 -9
- package/dist/three-live-animation.d.ts +58 -0
- package/dist/three-live-animation.js +7 -8
- package/dist/three-live-animation.min.js +6 -7
- package/dist/three-live-cad.cjs +3 -4
- package/dist/three-live-cad.d.ts +58 -0
- package/dist/three-live-cad.js +2 -3
- package/dist/three-live-cad.min.js +3 -4
- package/dist/three-live-cli.js +231 -0
- package/dist/three-live-element.cjs +20 -21
- package/dist/three-live-element.d.ts +58 -0
- package/dist/three-live-element.js +19 -20
- package/dist/three-live-full.cjs +113 -87
- package/dist/three-live-full.js +110 -84
- package/dist/three-live-full.min.js +113 -87
- package/dist/three-live-studio.cjs +19 -20
- package/dist/three-live-studio.d.ts +58 -0
- package/dist/three-live-studio.js +18 -19
- package/dist/three-live-studio.min.js +18 -19
- package/dist/three-live-viewer.cjs +20 -21
- package/dist/three-live-viewer.d.ts +58 -0
- package/dist/three-live-viewer.js +19 -20
- package/dist/three-live-viewer.min.js +20 -21
- package/dist/three-live.cjs +90 -64
- package/dist/three-live.js +89 -63
- package/dist/three-live.min.js +89 -63
- package/dist/three-view.cjs +18 -19
- package/dist/three-view.d.ts +58 -0
- package/dist/three-view.js +19 -20
- package/dist/three-xr.cjs +81 -59
- package/dist/three-xr.d.ts +58 -0
- package/dist/three-xr.js +80 -58
- package/package.json +7 -1
package/dist/three-live-cad.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
*
|
|
@@ -13,6 +13,5 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
"use strict";var Te=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Tn=Object.prototype.hasOwnProperty;var Ln=(M,L)=>{for(var A in L)Te(M,A,{get:L[A],enumerable:!0})},En=(M,L,A,he)=>{if(L&&typeof L=="object"||typeof L=="function")for(let ne of Cn(L))!Tn.call(M,ne)&&ne!==A&&Te(M,ne,{get:()=>L[ne],enumerable:!(he=kn(L,ne))||he.enumerable});return M};var Rn=M=>En(Te({},"__esModule",{value:!0}),M);var zn={};Ln(zn,{MAX_BSP_DEPTH:()=>an,MAX_CSG_TRIANGLES:()=>cn,MAX_SHAPE_POINTS:()=>ln,MAX_TEXT_GEOMETRY_CHARS:()=>un,cadPlugin:()=>Le,installCadExtension:()=>Pe});module.exports=Rn(zn);var Se="__THREE_LIVE_REGISTRY__";function fe(){let M=typeof globalThis<"u"?globalThis:{};if(!M[Se]){let L={plugins:[],decoders:new Map};try{Object.defineProperty(M,Se,{value:L,writable:!1,configurable:!1,enumerable:!1})}catch{M[Se]=L}}return M[Se]}var Vn=fe().plugins;function on(M){let L=fe();L.workerExtensionInstallers||(L.workerExtensionInstallers=[]),L.workerExtensionInstallers.includes(M)||L.workerExtensionInstallers.push(M)}function rn(M){let L=fe().plugins;L.some(A=>A.name===M.name)||L.push(M),M.onRegister?.()}var cn=8192,an=2048,un=128,ln=4096;function Pe(M,L){if(!M||!M.BufferGeometry)return null;let A=M.Vector2,he=M.Vector3,ne=M.Quaternion,Me=M.Matrix4,hn=M.Matrix3,mn=M.Color,D=M.BufferAttribute,se=M.BufferGeometry,yn=M.Material,Ee=M.MeshStandardMaterial,xe=M.Mesh,me=8192,oe=2048,Re=128,we=4096,Y=(t,e)=>{let n=t==null?NaN:Number(t);return Number.isFinite(n)?n:e};class be{constructor(e){this.currentPoint=new A(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){let s=Number(e)||0,r=Number(n)||0;return this.currentPoint.set(s,r),this.segments.push({type:"move",pts:[s,r]}),this}lineTo(e,n){let s=Number(e)||0,r=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(s,r),this.segments.push({type:"line",pts:[s,r]}),this}quadraticCurveTo(e,n,s,r){let i=this.currentPoint.x,a=this.currentPoint.y,u=Number(e)||0,h=Number(n)||0,o=Number(s)||0,m=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[i,a]}),this.currentPoint.set(o,m),this.segments.push({type:"quad",pts:[i,a,u,h,o,m]}),this}bezierCurveTo(e,n,s,r,i,a){let u=this.currentPoint.x,h=this.currentPoint.y,o=Number(e)||0,m=Number(n)||0,l=Number(s)||0,c=Number(r)||0,f=Number(i)||0,x=Number(a)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,h]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[u,h,o,m,l,c,f,x]}),this}absarc(e,n,s,r,i,a=!1){return this.absellipse(e,n,s,s,r,i,a,0)}arc(e,n,s,r,i,a=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),s,r,i,a)}absellipse(e,n,s,r,i,a,u=!1,h=0){let o=Number(e)||0,m=Number(n)||0,l=Math.max(0,Number(s)||0),c=Math.max(0,Number(r)||0),f=Number(i)||0,x=Number(a)||0,p=u?1:0,b=Number(h)||0;this.segments.push({type:"arc",pts:[o,m,l,c,f,x,p,b]});let y=Math.cos(b),g=Math.sin(b),S=l*Math.cos(x),d=c*Math.sin(x);return this.currentPoint.set(o+S*y-d*g,m+S*g+d*y),this}ellipse(e,n,s,r,i,a,u=!1,h=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),s,r,i,a,u,h)}closePath(){if(this.segments.length>0){let e=this.segments[0],n=0,s=0;if(e.type==="arc"){let r=e.pts[0],i=e.pts[1],a=e.pts[2],u=e.pts[3],h=e.pts[4],o=e.pts[7],m=Math.cos(o),l=Math.sin(o),c=a*Math.cos(h),f=u*Math.sin(h);n=r+c*m-f*l,s=i+c*l+f*m}else n=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-n,this.currentPoint.y-s)>1e-6&&this.lineTo(n,s)}return this}getPoints(e=12){let n=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],r=(i,a)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-i,u.y-a)<1e-6)return}s.push(new A(i,a))};for(let i of this.segments){let a=i.pts;if(i.type==="move"||i.type==="line")r(a[0],a[1]);else if(i.type==="quad"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5];r(u,h);for(let f=1;f<=n;f++){let x=f/n,p=1-x;r(p*p*u+2*p*x*o+x*x*l,p*p*h+2*p*x*m+x*x*c)}}else if(i.type==="cubic"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5],f=a[6],x=a[7];r(u,h);for(let p=1;p<=n;p++){let b=p/n,y=1-b,g=y*y,S=b*b;r(g*y*u+3*g*b*o+3*y*S*l+S*b*f,g*y*h+3*g*b*m+3*y*S*c+S*b*x)}}else if(i.type==="arc"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5],f=a[6]!==0,x=a[7],p=Math.PI*2,b=c-l,y=Math.abs(b)<1e-9;for(;b<0;)b+=p;for(;b>p;)b-=p;b<1e-9&&(b=y?0:p),f&&!y&&(b=b===p?-p:b-p);let g=Math.cos(x),S=Math.sin(x),d=Math.max(2,n);for(let w=0;w<=d;w++){let P=w/d,G=l+P*b,C=o*Math.cos(G),E=m*Math.sin(G);r(u+C*g-E*S,h+C*S+E*g)}}}if(s.length>2){let i=s[0],a=s[s.length-1];Math.hypot(i.x-a.x,i.y-a.y)<1e-6&&s.pop()}return s}getSpacedPoints(e=12){return this.getPoints(e)}}class pe extends be{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(n=>n.getPoints(e))}}}function ge(t){let e=0,n=t.length;for(let s=0,r=n-1;s<n;r=s++)e+=t[r].x*t[s].y-t[s].x*t[r].y;return e*.5}function fn(t,e,n,s,r,i,a,u){let h=a-n,o=u-s,m=r-n,l=i-s,c=t-n,f=e-s,x=h*h+o*o,p=h*m+o*l,b=h*c+o*f,y=m*m+l*l,g=m*c+l*f,S=x*y-p*p;if(Math.abs(S)<1e-12)return!1;let d=1/S,w=(y*b-p*g)*d,P=(x*g-p*b)*d;return w>=-1e-7&&P>=-1e-7&&w+P<=1+1e-7}function ze(t,e){let n=t.slice();ge(n)<0&&n.reverse();let s=n.map(h=>new A(h.x,h.y)),r=n.map((h,o)=>o),i=[];for(let h of e){if(!h||h.length<3)continue;let o=h.slice();ge(o)>0&&o.reverse();let m=[],l=-1/0,c=0;for(let f=0;f<o.length;f++){let x=o[f],p=s.length;s.push(new A(x.x,x.y)),m.push(p),x.x>l&&(l=x.x,c=f)}i.push({pts:o,indices:m,maxX:l,maxIdx:c})}i.sort((h,o)=>o.maxX-h.maxX);let a=(h,o,m)=>(o.x-h.x)*(m.y-h.y)-(o.y-h.y)*(m.x-h.x),u=(h,o,m)=>{for(let l=0;l<m.length;l++){let c=m[l],f=m[(l+1)%m.length];if(a(h,o,c)*a(h,o,f)<0&&a(c,f,h)*a(c,f,o)<0)return!0}return!1};for(let h of i){let o=h.pts[h.maxIdx],m=o.x,l=r.length,c=r.map(y=>s[y]),f=y=>Math.hypot(c[y].x-m,c[y].y-o.y),x=c.map((y,g)=>g).sort((y,g)=>+(c[y].x<m)-+(c[g].x<m)||f(y)-f(g)),p=x[0];for(let y of x){let g=c[y],S=c[(y+l-1)%l],d=c[(y+1)%l],w=a(g,d,o)>=0,P=a(S,g,o)>=0;if((a(S,g,d)>=0?w&&P:w||P)&&!u(o,g,c)&&!i.some(C=>u(o,g,C.pts))){p=y;break}}let b=[];for(let y=0;y<=p;y++)b.push(r[y]);for(let y=0;y<=h.indices.length;y++){let g=h.indices[(h.maxIdx+y)%h.indices.length];b.push(g)}for(let y=p;y<r.length;y++)b.push(r[y]);r=b}return{merged:r.map(h=>s[h]),mergedIndices:r,allVertices:s}}function Ie(t,e){let n=[],s=t.slice();if(s.length<3)return n;let r=s.length*s.length+64,i=0;for(;s.length>2&&r-- >0;){let a=s.length,u=s[(i+a-1)%a],h=s[i%a],o=s[(i+1)%a],m=e[u],l=e[h],c=e[o];if((l.x-m.x)*(c.y-m.y)-(l.y-m.y)*(c.x-m.x)>1e-9){let x=!0;for(let p=0;p<a;p++){let b=s[p];if(b===u||b===h||b===o)continue;let y=e[b];if(fn(y.x,y.y,m.x,m.y,l.x,l.y,c.x,c.y)&&Math.hypot(y.x-m.x,y.y-m.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6){x=!1;break}}if(x){n.push([u,h,o]),s.splice(i%a,1),i=Math.max(0,i%a-1);continue}}i++,i>=a*2&&(n.push([u,h,o]),s.splice((i-1)%a,1),i=0)}return n}function Ve(t,e){let n=t instanceof pe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},s=n.shape.length;for(let r of n.holes)s+=r.length;if(s>we)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${we})`);return n}class xn extends se{constructor(e=new pe,n=12){super();let s=Array.isArray(e)?e:[e],r=[],i=[],a=[],u=[];for(let h of s){if(!(h instanceof be))continue;let o=Ve(h,n);if(o.shape.length<3)continue;let{mergedIndices:m,allVertices:l}=ze(o.shape,o.holes),c=Ie(m,l),f=r.length/3,x=1/0,p=1/0,b=-1/0,y=-1/0;for(let d of l)d.x<x&&(x=d.x),d.y<p&&(p=d.y),d.x>b&&(b=d.x),d.y>y&&(y=d.y);let g=Math.max(1e-6,b-x),S=Math.max(1e-6,y-p);for(let d of l)r.push(d.x,d.y,0),i.push(0,0,1),a.push((d.x-x)/g,(d.y-p)/S);for(let[d,w,P]of c)u.push(f+d,f+w,f+P)}this.setAttribute("position",new D(O(r),3)),this.setAttribute("normal",new D(O(i),3)),this.setAttribute("uv",new D(O(a),2)),this.setIndex(u)}}function O(t){let e=t.length,n=new Float32Array(e);for(let s=0;s<e;s++)n[s]=t[s];return n}function bn(t){let e=t.length,n=[];for(let s=0;s<e;s++){let r=t[(s+e-1)%e],i=t[s],a=t[(s+1)%e],u=i.x-r.x,h=i.y-r.y,o=Math.hypot(u,h)||1;u/=o,h/=o;let m=a.x-i.x,l=a.y-i.y,c=Math.hypot(m,l)||1;m/=c,l/=c;let f=h,x=-u,p=l,b=-m,y=f+p,g=x+b,S=Math.hypot(y,g);if(S>1e-6){y/=S,g/=S;let d=Math.max(.35,y*f+g*x);n.push(new A(y/d,g/d))}else n.push(new A(f,x))}return n}class pn extends se{constructor(e=new pe,n={}){super();let s=Array.isArray(e)?e:[e],r=Math.max(1,Math.min(64,Math.floor(Y(n.curveSegments,12)))),i=Y(n.depth??n.amount,1),a=Math.max(1,Math.min(32,Math.floor(Y(n.steps,1)))),u=!!(n.bevelEnabled??!1),h=u?Math.max(0,Y(n.bevelThickness,.06)):0,o=u?Math.max(0,Y(n.bevelSize,h*.8)):0,m=u?Y(n.bevelOffset,0):0,l=u?Math.max(1,Math.min(8,Math.floor(Y(n.bevelSegments,2)))):0,c=[],f=[],x=[],p=[];for(let b of s){if(!(b instanceof be))continue;let y=Ve(b,r);if(y.shape.length<3)continue;let g=y.shape.slice();ge(g)<0&&g.reverse();let S=[];for(let v of y.holes){if(v.length<3)continue;let k=v.slice();ge(k)>0&&k.reverse(),S.push(k)}let{mergedIndices:d,allVertices:w}=ze(g,S),P=Ie(d,w),G=[g,...S],C=[];for(let v of G){let k=bn(v);for(let T of k)C.push(T)}let E=1/0,V=1/0,I=-1/0,B=-1/0;for(let v of w)v.x<E&&(E=v.x),v.y<V&&(V=v.y),v.x>I&&(I=v.x),v.y>B&&(B=v.y);let _=Math.max(1e-6,I-E),H=Math.max(1e-6,B-V),re=-h,ie=i+h,j=c.length/3;for(let v=0;v<w.length;v++){let k=w[v],T=C[v]??new A(0,0),R=k.x+T.x*m,z=k.y+T.y*m;c.push(R,z,re),f.push(0,0,-1),x.push((R-E)/_,(z-V)/H)}for(let[v,k,T]of P)p.push(j+v,j+T,j+k);let $=c.length/3;for(let v=0;v<w.length;v++){let k=w[v],T=C[v]??new A(0,0),R=k.x+T.x*m,z=k.y+T.y*m;c.push(R,z,ie),f.push(0,0,1),x.push((R-E)/_,(z-V)/H)}for(let[v,k,T]of P)p.push($+v,$+k,$+T);let N=[];if(u&&l>0)for(let v=0;v<l;v++){let T=v/l*Math.PI/2;N.push({z:-h*Math.cos(T),expand:m+o*Math.sin(T)})}for(let v=0;v<=a;v++){let k=v/a;N.push({z:k*i,expand:m+o})}if(u&&l>0)for(let v=1;v<=l;v++){let T=v/l*Math.PI/2;N.push({z:i+h*Math.sin(T),expand:m+o*Math.cos(T)})}let F=0;for(let v of G){let k=v.length;for(let T=0;T<N.length-1;T++){let R=N[T],z=N[T+1];for(let X=0;X<k;X++){let q=(X+1)%k,Z=v[X],U=v[q],Q=C[F+X],K=C[F+q],J=Z.x+Q.x*R.expand,ee=Z.y+Q.y*R.expand,te=U.x+K.x*R.expand,W=U.y+K.y*R.expand,wn=U.x+K.x*z.expand,Gn=U.y+K.y*z.expand,We=Z.x+Q.x*z.expand,je=Z.y+Q.y*z.expand,$e=te-J,Ze=W-ee,Ue=0,Qe=We-J,Ke=je-ee,Je=z.z-R.z,ce=Ze*Je-Ue*Ke,ae=Ue*Qe-$e*Je,ue=$e*Ke-Ze*Qe,Ce=Math.hypot(ce,ae,ue)||1;ce/=Ce,ae/=Ce,ue/=Ce;let le=c.length/3;c.push(J,ee,R.z,te,W,R.z,wn,Gn,z.z,We,je,z.z),f.push(ce,ae,ue,ce,ae,ue,ce,ae,ue,ce,ae,ue);let en=X/k,nn=(X+1)/k,tn=T/(N.length-1),sn=(T+1)/(N.length-1);x.push(en,tn,nn,tn,nn,sn,en,sn),p.push(le,le+1,le+2,le,le+2,le+3)}}F+=k}}this.setAttribute("position",new D(O(c),3)),this.setAttribute("normal",new D(O(f),3)),this.setAttribute("uv",new D(O(x),2)),this.setIndex(p)}}function _e(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function gn(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function dn(t,e,n){let s=t.nx+(e.nx-t.nx)*n,r=t.ny+(e.ny-t.ny)*n,i=t.nz+(e.nz-t.nz)*n,a=Math.hypot(s,r,i)||1;return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z+(e.z-t.z)*n,nx:s/a,ny:r/a,nz:i/a,u:t.u+(e.u-t.u)*n,v:t.v+(e.v-t.v)*n}}function vn(t){if(t.length<3)return null;let e=t[0],n=t[1],s=t[2],r=n.x-e.x,i=n.y-e.y,a=n.z-e.z,u=s.x-e.x,h=s.y-e.y,o=s.z-e.z,m=i*o-a*h,l=a*u-r*o,c=r*h-i*u,f=Math.hypot(m,l,c);if(f<1e-9)return null;m/=f,l/=f,c/=f;let x=m*e.x+l*e.y+c*e.z;return{vertices:t,nx:m,ny:l,nz:c,w:x}}function Sn(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=gn(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Ae=1e-5,Ne=0,Ge=1,de=2,Xe=3;function De(t,e,n,s,r,i,a,u,h){let o=0,m=[];for(let l=0;l<r.vertices.length;l++){let c=r.vertices[l],f=t*c.x+e*c.y+n*c.z-s,x=f<-Ae?de:f>Ae?Ge:Ne;o|=x,m.push(x)}switch(o){case Ne:{t*r.nx+e*r.ny+n*r.nz>0?i.push(r):a.push(r);break}case Ge:u.push(r);break;case de:h.push(r);break;case Xe:{let l=[],c=[],f=r.vertices.length;for(let g=0;g<f;g++){let S=(g+1)%f,d=m[g],w=m[S],P=r.vertices[g],G=r.vertices[S];if(d!==de&&l.push(P),d!==Ge&&c.push(d!==de?_e(P):P),(d|w)===Xe){let C=G.x-P.x,E=G.y-P.y,V=G.z-P.z,I=t*C+e*E+n*V,B=Math.abs(I)>1e-12?(s-(t*P.x+e*P.y+n*P.z))/I:.5,_=dn(P,G,Math.max(0,Math.min(1,B)));l.push(_),c.push(_e(_))}}let{nx:x,ny:p,nz:b,w:y}=r;l.length>=3&&u.push({vertices:l,nx:x,ny:p,nz:b,w:y}),c.length>=3&&h.push({vertices:c,nx:x,ny:p,nz:b,w:y});break}default:break}}class ye{constructor(e,n=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,n)}invert(){for(let n=0;n<this.polygons.length;n++)Sn(this.polygons[n]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,n=0){if(!this.hasPlane||e.length===0)return e.slice();if(n>=oe)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${oe})`);let s=[],r=[];for(let i=0;i<e.length;i++)De(this.nx,this.ny,this.nz,this.w,e[i],s,r,s,r);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,n+1)),this.back?r=r.length>0?this.back.clipPolygons(r,n+1):[]:r=[],s.concat(r)}clipTo(e,n=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),n<oe&&(this.front&&this.front.clipTo(e,n+1),this.back&&this.back.clipTo(e,n+1))}allPolygons(e=[]){for(let n=0;n<this.polygons.length;n++)e.push(this.polygons[n]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,n=0){if(!e.length)return;if(!this.hasPlane){let i=e[e.length>>1];this.nx=i.nx,this.ny=i.ny,this.nz=i.nz,this.w=i.w,this.hasPlane=!0}if(n>=oe)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${oe})`);let s=[],r=[];for(let i=0;i<e.length;i++)De(this.nx,this.ny,this.nz,this.w,e[i],this.polygons,this.polygons,s,r);s.length>0&&(this.front||(this.front=new ye),this.front.build(s,n+1)),r.length>0&&(this.back||(this.back=new ye),this.back.build(r,n+1))}}function Oe(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let n=t.attributes.position;if(!n||n.count===0)return[];let s=t.attributes.normal,r=t.attributes.uv,i=t.index?t.index.array:null,a=Math.floor(i?i.length/3:n.count/3);if(a>me)throw new RangeError(`SecurityError: CSG input triangle count (${a}) exceeds MAX_CSG_TRIANGLES (${me})`);let u=e?e.elements:null,h=u?u[0]*(u[5]*u[10]-u[9]*u[6])-u[4]*(u[1]*u[10]-u[9]*u[2])+u[8]*(u[1]*u[6]-u[5]*u[2])<0:!1,o=u?new hn().getNormalMatrix(e).elements:null,m=c=>{let f=n.getX(c),x=n.getY(c),p=n.getZ(c),b=s?s.getX(c):NaN,y=s?s.getY(c):NaN,g=s?s.getZ(c):NaN;if(u&&o){let w=u[0]*f+u[4]*x+u[8]*p+u[12],P=u[1]*f+u[5]*x+u[9]*p+u[13],G=u[2]*f+u[6]*x+u[10]*p+u[14];f=w,x=P,p=G;let C=o[0]*b+o[3]*y+o[6]*g,E=o[1]*b+o[4]*y+o[7]*g,V=o[2]*b+o[5]*y+o[8]*g,I=Math.hypot(C,E,V)||1;b=C/I,y=E/I,g=V/I}let S=r?r.getX(c):0,d=r?r.getY(c):0;return{x:f,y:x,z:p,nx:b,ny:y,nz:g,u:S,v:d}},l=[];for(let c=0;c<a;c++){let f=i?i[c*3]:c*3,x=i?i[c*3+1]:c*3+1,p=i?i[c*3+2]:c*3+2,b=vn(h?[m(f),m(p),m(x)]:[m(f),m(x),m(p)]);b&&l.push(b)}return l}function Pn(t){let e=[],n=[],s=[],r=[];for(let a of t){let u=a.vertices;if(u.length<3)continue;let h=e.length/3;for(let o of u)e.push(o.x,o.y,o.z),Number.isFinite(o.nx)&&o.nx*o.nx+o.ny*o.ny+o.nz*o.nz>.5?n.push(o.nx,o.ny,o.nz):n.push(a.nx,a.ny,a.nz),s.push(o.u,o.v);for(let o=1;o<u.length-1;o++)r.push(h,h+o,h+o+1)}let i=new se;return i.setAttribute("position",new D(O(e),3)),i.setAttribute("normal",new D(O(n),3)),i.setAttribute("uv",new D(O(s),2)),i.setIndex(r),i._csgPolygons=t,i}function Mn(t,e,n){if(t.length+e.length>me)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${me})`);if(t.length===0)return n==="union"?e:[];if(e.length===0)return n==="intersect"?[]:t;let s=1/0,r=1/0,i=1/0,a=-1/0,u=-1/0,h=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let p=0;p<x.length;p++){let b=x[p];b.x<s&&(s=b.x),b.y<r&&(r=b.y),b.z<i&&(i=b.z),b.x>a&&(a=b.x),b.y>u&&(u=b.y),b.z>h&&(h=b.z)}}s-=1e-4,r-=1e-4,i-=1e-4,a+=1e-4,u+=1e-4,h+=1e-4;let o=[],m=[];for(let f=0;f<t.length;f++){let x=t[f],p=x.vertices,b=1/0,y=1/0,g=1/0,S=-1/0,d=-1/0,w=-1/0;for(let P=0;P<p.length;P++){let G=p[P];G.x<b&&(b=G.x),G.y<y&&(y=G.y),G.z<g&&(g=G.z),G.x>S&&(S=G.x),G.y>d&&(d=G.y),G.z>w&&(w=G.z)}S<s||b>a||d<r||y>u||w<i||g>h?m.push(x):o.push(x)}if(o.length===0)return n==="union"?t.concat(e):n==="subtract"?t:[];let l=new ye(o),c=new ye(e);return n==="union"?(l.clipTo(c),c.clipTo(l),c.invert(),c.clipTo(l),c.invert(),l.build(c.allPolygons()),m.concat(l.allPolygons())):n==="subtract"?(l.invert(),l.clipTo(c),c.clipTo(l),c.invert(),c.clipTo(l),c.invert(),l.build(c.allPolygons()),l.invert(),m.concat(l.allPolygons())):(l.invert(),c.clipTo(l),c.invert(),l.clipTo(c),c.clipTo(l),l.build(c.allPolygons()),l.invert(),l.allPolygons())}function Be(t,e,n,s=null,r=null){let i=Oe(t,s),a=Oe(e,r);return Pn(Mn(i,a,n))}function ke(t,e,n){let s=t instanceof xe||!!t?.isMesh,r=e instanceof xe||!!e?.isMesh,i=s?t.geometry:t,a=r?e.geometry:e,u=null;if(r)if(e.updateMatrix(),s){t.updateMatrix();let l=new Me().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),c=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new Me().compose(new he(0,0,0),new ne(-t.quaternion.x/c,-t.quaternion.y/c,-t.quaternion.z/c,t.quaternion.w/c),new he(1,1,1)),x=new Me().makeTranslation(-t.position.x,-t.position.y,-t.position.z);u=l.multiply(f).multiply(x).multiply(e.matrix)}else u=e.matrix;let h=Be(i,a,n,null,u),o=s?t.material:new Ee,m=new xe(h,o);return s&&(m.position.copy(t.position),m.quaternion.copy(t.quaternion),m.scale.copy(t.scale),m.name=t.name),m}let ve={toGeometry:Be,subtract(t,e){return ke(t,e,"subtract")},union(t,e){return ke(t,e,"union")},intersect(t,e){return ke(t,e,"intersect")}},Ye={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class He extends se{constructor(e="",n={}){super();let s=String(e??"").slice(0,Re),r=Math.max(.005,Math.min(100,Y(n.size,.2))),i=!!(n.bevelEnabled??!1),a=i?Math.max(0,Math.min(2,Y(n.bevelThickness,r*.04))):0,u=i?Math.max(0,Math.min(2,Y(n.bevelSize,r*.03))):0,h=Math.max(.001,Math.min(20,Y(n.depth??n.height,r*.2)))+a*2,o=r*.085+u,m=r*.68,l=r*.82,c=[],f=[],x=[],p=[],b=(S,d,w,P,G,C,E)=>{let V=w-S,I=P-d,B=Math.hypot(V,I),_=1,H=0;B>1e-6&&(_=V/B,H=I/B);let re=-H*G,ie=_*G,j=_*G*.6,$=H*G*.6,N=S-j+re,F=d-$+ie,v=S-j-re,k=d-$-ie,T=w+j-re,R=P+$-ie,z=w+j+re,X=P+$+ie,q=(Z,U,Q,K,J,ee,te)=>{let W=c.length/3;c.push(Z[0],Z[1],Z[2],U[0],U[1],U[2],Q[0],Q[1],Q[2],K[0],K[1],K[2]),f.push(J,ee,te,J,ee,te,J,ee,te,J,ee,te),x.push(0,0,1,0,1,1,0,1),p.push(W,W+1,W+2,W,W+2,W+3)};q([N,F,E],[v,k,E],[T,R,E],[z,X,E],0,0,1),q([v,k,C],[N,F,C],[z,X,C],[T,R,C],0,0,-1),q([N,F,C],[v,k,C],[v,k,E],[N,F,E],-_,-H,0),q([T,R,C],[z,X,C],[z,X,E],[T,R,E],_,H,0),q([v,k,C],[T,R,C],[T,R,E],[v,k,E],H,-_,0),q([z,X,C],[N,F,C],[N,F,E],[z,X,E],-H,_,0)},y=0,g=0;for(let S=0;S<s.length;S++){let d=s[S];if(d===`
|
|
18
|
-
`){y=0,g-=r*1.35;continue}if(d===" "||d===" "){y+=l*(d===" "?.75:3);continue}if(d==="\r")continue;let w=d.toUpperCase(),P=d!==w&&d>="a"&&d<="z",G=Ye[w]??Ye["?"],C=P?r*.76:r,E=P?m*.88:m;for(let V of G)for(let I=0;I<V.length-1;I++){let B=V[I],_=V[I+1];b(y+B[0]*E,g+B[1]*C,y+_[0]*E,g+_[1]*C,o,-h*.5,h*.5)}y+=P?l*.88:l}this.setAttribute("position",new D(O(c),3)),this.setAttribute("normal",new D(O(f),3)),this.setAttribute("uv",new D(O(x),2)),this.setIndex(p),n.center!==!1?this.center():this.computeBoundingBox()}}function Fe(t){if(!t)return;let e=t,n=t.userData?.xr?.text;if(n!=null&&n!==!1){let r=e.geometry?.attributes?.position;if((!r||r.count===0)&&t.userData._textApplied!==!0){let i="",a=.08,u=.015,h;if(typeof n=="string"||typeof n=="number")i=String(n);else if(typeof n=="object"){let o=n;i=String(o.text??o.value??""),o.size!==void 0&&(a=Number(o.size)||.08),(o.depth!==void 0||o.height!==void 0)&&(u=Number(o.depth??o.height)||a*.2),(typeof o.color=="string"||typeof o.color=="number")&&(h=o.color)}i.trim().length>0&&(e.geometry=new He(i,{size:a,depth:u}),t.userData._textApplied=!0,e.material instanceof yn?h!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new mn(h),t.userData._autoTextColorApplied=!0):e.material=new Ee({color:h??16317180}))}}let s=t.userData?.csg;if(s&&typeof s=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof se&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let r=Array.isArray(s)?s:[s],i=e.geometry;for(let a of r){if(!a||typeof a!="object")continue;let u=a,h=String(u.op??u.operation??"subtract"),o=h==="union"||h==="intersect"?h:"subtract",m=u.target??u.mesh??u.geometry;if(m instanceof xe||m instanceof se)try{let l=o==="union"?ve.union(e,m):o==="intersect"?ve.intersect(e,m):ve.subtract(e,m);e.geometry!==i&&e.geometry.dispose?.(),e.geometry=l.geometry}catch(l){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",l)}}}}let qe={Path:be,Shape:pe,ShapeGeometry:xn,ExtrudeGeometry:pn,TextGeometry:He,CSG:ve,MAX_CSG_TRIANGLES:me,MAX_BSP_DEPTH:oe,MAX_TEXT_GEOMETRY_CHARS:Re,MAX_SHAPE_POINTS:we,materializeDeclarativeGeometry:Fe};return L&&typeof L=="object"&&(L.authorNamespace||(L.authorNamespace={}),Object.assign(L.authorNamespace,qe),L.materializeDeclarativeGeometry=Fe),qe}var Le={name:"cad",onRegister(){on(Pe);let M=fe(),L=M.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);L&&Pe(L,M)}};rn(Le);
|
|
16
|
+
*/var Te=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Cn=Object.getOwnPropertyNames,Tn=Object.prototype.hasOwnProperty,Ln=(z,N)=>{for(var X in N)Te(z,X,{get:N[X],enumerable:!0})},En=(z,N,X,ae)=>{if(N&&typeof N=="object"||typeof N=="function")for(let K of Cn(N))!Tn.call(z,K)&&K!==X&&Te(z,K,{get:()=>N[K],enumerable:!(ae=kn(N,K))||ae.enumerable});return z},zn=z=>En(Te({},"__esModule",{value:!0}),z),_n={};Ln(_n,{MAX_BSP_DEPTH:()=>an,MAX_CSG_TRIANGLES:()=>cn,MAX_SHAPE_POINTS:()=>ln,MAX_TEXT_GEOMETRY_CHARS:()=>un,cadPlugin:()=>Le,installCadExtension:()=>Se}),module.exports=zn(_n);var ve="__THREE_LIVE_REGISTRY__";function me(){let z=typeof globalThis<"u"?globalThis:{};if(!z[ve]){let N={plugins:[],decoders:new Map};try{Object.defineProperty(z,ve,{value:N,writable:!1,configurable:!1,enumerable:!1})}catch{z[ve]=N}}return z[ve]}var In=me().plugins;function on(z){let N=me();N.workerExtensionInstallers||(N.workerExtensionInstallers=[]),N.workerExtensionInstallers.includes(z)||N.workerExtensionInstallers.push(z)}function rn(z){let N=me().plugins;N.some(X=>X.name===z.name)||N.push(z),z.onRegister?.()}var cn=8192,an=2048,un=128,ln=4096;function Se(z,N){if(!z||!z.BufferGeometry)return null;let X=z.Vector2,ae=z.Vector3,K=z.Quaternion,Me=z.Matrix4,st=z.Matrix3,it=z.Color,Pe=z.BufferAttribute,te=z.BufferGeometry,lt=z.Material,Ae=z.MeshStandardMaterial,pe=z.Mesh,ue=8192,ne=2048,Ee=128,ze=4096,B=(t,e)=>{let n=t==null?NaN:Number(t);return Number.isFinite(n)?n:e};class ye{constructor(e){this.currentPoint=new X(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){let r=Number(e)||0,i=Number(n)||0;return this.currentPoint.set(r,i),this.segments.push({type:"move",pts:[r,i]}),this}lineTo(e,n){let r=Number(e)||0,i=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(r,i),this.segments.push({type:"line",pts:[r,i]}),this}quadraticCurveTo(e,n,r,i){let h=this.currentPoint.x,o=this.currentPoint.y,a=Number(e)||0,u=Number(n)||0,s=Number(r)||0,p=Number(i)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[h,o]}),this.currentPoint.set(s,p),this.segments.push({type:"quad",pts:[h,o,a,u,s,p]}),this}bezierCurveTo(e,n,r,i,h,o){let a=this.currentPoint.x,u=this.currentPoint.y,s=Number(e)||0,p=Number(n)||0,c=Number(r)||0,l=Number(i)||0,f=Number(h)||0,x=Number(o)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,u]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[a,u,s,p,c,l,f,x]}),this}absarc(e,n,r,i,h,o=!1){return this.absellipse(e,n,r,r,i,h,o,0)}arc(e,n,r,i,h,o=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),r,i,h,o)}absellipse(e,n,r,i,h,o,a=!1,u=0){let s=Number(e)||0,p=Number(n)||0,c=Math.max(0,Number(r)||0),l=Math.max(0,Number(i)||0),f=Number(h)||0,x=Number(o)||0,m=a?1:0,y=Number(u)||0;this.segments.push({type:"arc",pts:[s,p,c,l,f,x,m,y]});let g=Math.cos(y),b=Math.sin(y),M=c*Math.cos(x),d=l*Math.sin(x);return this.currentPoint.set(s+M*g-d*b,p+M*b+d*g),this}ellipse(e,n,r,i,h,o,a=!1,u=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),r,i,h,o,a,u)}closePath(){if(this.segments.length>0){let e=this.segments[0],n=0,r=0;if(e.type==="arc"){let i=e.pts[0],h=e.pts[1],o=e.pts[2],a=e.pts[3],u=e.pts[4],s=e.pts[7],p=Math.cos(s),c=Math.sin(s),l=o*Math.cos(u),f=a*Math.sin(u);n=i+l*p-f*c,r=h+l*c+f*p}else n=e.pts[0],r=e.pts[1];Math.hypot(this.currentPoint.x-n,this.currentPoint.y-r)>1e-6&&this.lineTo(n,r)}return this}getPoints(e=12){let n=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),r=[],i=(h,o)=>{if(r.length>0){let a=r[r.length-1];if(Math.hypot(a.x-h,a.y-o)<1e-6)return}r.push(new X(h,o))};for(let h of this.segments){let o=h.pts;if(h.type==="move"||h.type==="line")i(o[0],o[1]);else if(h.type==="quad"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5];i(a,u);for(let f=1;f<=n;f++){let x=f/n,m=1-x;i(m*m*a+2*m*x*s+x*x*c,m*m*u+2*m*x*p+x*x*l)}}else if(h.type==="cubic"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5],f=o[6],x=o[7];i(a,u);for(let m=1;m<=n;m++){let y=m/n,g=1-y,b=g*g,M=y*y;i(b*g*a+3*b*y*s+3*g*M*c+M*y*f,b*g*u+3*b*y*p+3*g*M*l+M*y*x)}}else if(h.type==="arc"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5],f=o[6]!==0,x=o[7],m=Math.PI*2,y=l-c,g=Math.abs(y)<1e-9;for(;y<0;)y+=m;for(;y>m;)y-=m;y<1e-9&&(y=g?0:m),f&&!g&&(y=y===m?-m:y-m);let b=Math.cos(x),M=Math.sin(x),d=Math.max(2,n);for(let _=0;_<=d;_++){let P=_/d,S=c+P*y,T=s*Math.cos(S),A=p*Math.sin(S);i(a+T*b-A*M,u+T*M+A*b)}}}if(r.length>2){let h=r[0],o=r[r.length-1];Math.hypot(h.x-o.x,h.y-o.y)<1e-6&&r.pop()}return r}getSpacedPoints(e=12){return this.getPoints(e)}clone(){let e=new this.constructor;return e.currentPoint.copy(this.currentPoint),e.segments=this.segments.map(n=>({type:n.type,pts:[...n.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(n=>n.clone())),e}}class fe extends ye{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(n=>n.getPoints(e))}}}function xe(t){let e=0,n=t.length;for(let r=0,i=n-1;r<n;i=r++)e+=t[i].x*t[r].y-t[r].x*t[i].y;return e*.5}function ot(t,e,n,r,i,h,o,a){let u=o-n,s=a-r,p=i-n,c=h-r,l=t-n,f=e-r,x=u*u+s*s,m=u*p+s*c,y=u*l+s*f,g=p*p+c*c,b=p*l+c*f,M=x*g-m*m;if(Math.abs(M)<1e-12)return!1;let d=1/M,_=(g*y-m*b)*d,P=(x*b-m*y)*d;return _>=-1e-7&&P>=-1e-7&&_+P<=1+1e-7}function ke(t,e){let n=t.slice();xe(n)<0&&n.reverse();let r=n.map(u=>new X(u.x,u.y)),i=n.map((u,s)=>s),h=[];for(let u of e){if(!u||u.length<3)continue;let s=u.slice();xe(s)>0&&s.reverse();let p=[],c=-1/0,l=0;for(let f=0;f<s.length;f++){let x=s[f],m=r.length;r.push(new X(x.x,x.y)),p.push(m),x.x>c&&(c=x.x,l=f)}h.push({pts:s,indices:p,maxX:c,maxIdx:l})}h.sort((u,s)=>s.maxX-u.maxX);let o=(u,s,p)=>(s.x-u.x)*(p.y-u.y)-(s.y-u.y)*(p.x-u.x),a=(u,s,p)=>{for(let c=0;c<p.length;c++){let l=p[c],f=p[(c+1)%p.length];if(o(u,s,l)*o(u,s,f)<0&&o(l,f,u)*o(l,f,s)<0)return!0}return!1};for(let u of h){let s=u.pts[u.maxIdx],p=s.x,c=i.length,l=i.map(g=>r[g]),f=g=>Math.hypot(l[g].x-p,l[g].y-s.y),x=l.map((g,b)=>b).sort((g,b)=>+(l[g].x<p)-+(l[b].x<p)||f(g)-f(b)),m=x[0];for(let g of x){let b=l[g],M=l[(g+c-1)%c],d=l[(g+1)%c],_=o(b,d,s)>=0,P=o(M,b,s)>=0;if((o(M,b,d)>=0?_&&P:_||P)&&!a(s,b,l)&&!h.some(S=>a(s,b,S.pts))){m=g;break}}let y=[];for(let g=0;g<=m;g++)y.push(i[g]);for(let g=0;g<=u.indices.length;g++){let b=u.indices[(u.maxIdx+g)%u.indices.length];y.push(b)}for(let g=m;g<i.length;g++)y.push(i[g]);i=y}return{merged:i.map(u=>r[u]),mergedIndices:i,allVertices:r}}function Ge(t,e){let n=[],r=t.slice();if(r.length<3)return n;let i=r.length*r.length+64,h=0;for(;r.length>2&&i-- >0;){let o=r.length,a=r[(h+o-1)%o],u=r[h%o],s=r[(h+1)%o],p=e[a],c=e[u],l=e[s];if((c.x-p.x)*(l.y-p.y)-(c.y-p.y)*(l.x-p.x)>1e-9){let f=!0;for(let x=0;x<o;x++){let m=r[x];if(m===a||m===u||m===s)continue;let y=e[m];if(ot(y.x,y.y,p.x,p.y,c.x,c.y,l.x,l.y)&&Math.hypot(y.x-p.x,y.y-p.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6){f=!1;break}}if(f){n.push([a,u,s]),r.splice(h%o,1),h=Math.max(0,h%o-1);continue}}h++,h>=o*2&&(n.push([a,u,s]),r.splice((h-1)%o,1),h=0)}return n}function Ce(t,e){let n=t instanceof fe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},r=n.shape.length;for(let i of n.holes)r+=i.length;if(r>ze)throw new RangeError(`SecurityError: shape point count (${r}) exceeds MAX_SHAPE_POINTS (${ze})`);return n}class ht extends te{constructor(e=new fe,n=12){super();let r=Array.isArray(e)?e:[e],i=[],h=[],o=[],a=[];for(let u of r){if(!(u instanceof ye))continue;let s=Ce(u,n);if(s.shape.length<3)continue;let{mergedIndices:p,allVertices:c}=ke(s.shape,s.holes),l=Ge(p,c),f=i.length/3,x=1/0,m=1/0,y=-1/0,g=-1/0;for(let d of c)d.x<x&&(x=d.x),d.y<m&&(m=d.y),d.x>y&&(y=d.x),d.y>g&&(g=d.y);let b=Math.max(1e-6,y-x),M=Math.max(1e-6,g-m);for(let d of c)i.push(d.x,d.y,0),h.push(0,0,1),o.push((d.x-x)/b,(d.y-m)/M);for(let[d,_,P]of l)a.push(f+d,f+_,f+P)}ge(this,i,h,o,a)}}function ge(t,e,n,r,i){return t.setAttribute("position",new Pe(e,3)),t.setAttribute("normal",new Pe(n,3)),t.setAttribute("uv",new Pe(r,2)),t.setIndex(i),t}function at(t){let e=t.length,n=[];for(let r=0;r<e;r++){let i=t[(r+e-1)%e],h=t[r],o=t[(r+1)%e],a=h.x-i.x,u=h.y-i.y,s=Math.hypot(a,u)||1;a/=s,u/=s;let p=o.x-h.x,c=o.y-h.y,l=Math.hypot(p,c)||1;p/=l,c/=l;let f=u,x=-a,m=c,y=-p,g=f+m,b=x+y,M=Math.hypot(g,b);if(M>1e-6){g/=M,b/=M;let d=Math.max(.35,g*f+b*x);n.push(new X(g/d,b/d))}else n.push(new X(f,x))}return n}class ut extends te{constructor(e=new fe,n={}){super();let r=Array.isArray(e)?e:[e],i=Math.max(1,Math.min(64,Math.floor(B(n.curveSegments,12)))),h=B(n.depth??n.amount,1),o=Math.max(1,Math.min(32,Math.floor(B(n.steps,1)))),a=!!(n.bevelEnabled??!1),u=a?Math.max(0,B(n.bevelThickness,.06)):0,s=a?Math.max(0,B(n.bevelSize,u*.8)):0,p=a?B(n.bevelOffset,0):0,c=a?Math.max(1,Math.min(8,Math.floor(B(n.bevelSegments,2)))):0,l=[],f=[],x=[],m=[];for(let y of r){if(!(y instanceof ye))continue;let g=Ce(y,i);if(g.shape.length<3)continue;let b=g.shape.slice();xe(b)<0&&b.reverse();let M=[];for(let v of g.holes){if(v.length<3)continue;let w=v.slice();xe(w)>0&&w.reverse(),M.push(w)}let{mergedIndices:d,allVertices:_}=ke(b,M),P=Ge(d,_),S=[b,...M],T=[];for(let v of S){let w=at(v);for(let E of w)T.push(E)}let A=1/0,I=1/0,C=-1/0,L=-1/0;for(let v of _)v.x<A&&(A=v.x),v.y<I&&(I=v.y),v.x>C&&(C=v.x),v.y>L&&(L=v.y);let R=Math.max(1e-6,C-A),q=Math.max(1e-6,L-I),re=-u,se=h+u,Y=l.length/3;for(let v=0;v<_.length;v++){let w=_[v],E=T[v]??new X(0,0),k=w.x+E.x*p,G=w.y+E.y*p;l.push(k,G,re),f.push(0,0,-1),x.push((k-A)/R,(G-I)/q)}for(let[v,w,E]of P)m.push(Y+v,Y+E,Y+w);let $=l.length/3;for(let v=0;v<_.length;v++){let w=_[v],E=T[v]??new X(0,0),k=w.x+E.x*p,G=w.y+E.y*p;l.push(k,G,se),f.push(0,0,1),x.push((k-A)/R,(G-I)/q)}for(let[v,w,E]of P)m.push($+v,$+w,$+E);let D=[];if(a&&c>0)for(let v=0;v<c;v++){let w=v/c*Math.PI/2;D.push({z:-u*Math.cos(w),expand:p+s*Math.sin(w)})}for(let v=0;v<=o;v++){let w=v/o;D.push({z:w*h,expand:p+s})}if(a&&c>0)for(let v=1;v<=c;v++){let w=v/c*Math.PI/2;D.push({z:h+u*Math.sin(w),expand:p+s*Math.cos(w)})}let H=0;for(let v of S){let w=v.length;for(let E=0;E<D.length-1;E++){let k=D[E],G=D[E+1];for(let O=0;O<w;O++){let j=(O+1)%w,F=v[O],J=v[j],Z=T[H+O],U=T[H+j],Q=F.x+Z.x*k.expand,W=F.y+Z.y*k.expand,ee=J.x+U.x*k.expand,V=J.y+U.y*k.expand,mt=J.x+U.x*G.expand,bt=J.y+U.y*G.expand,$e=F.x+Z.x*G.expand,Fe=F.y+Z.y*G.expand,Je=ee-Q,Ze=V-W,Ue=0,Qe=$e-Q,We=Fe-W,Ke=G.z-k.z,ie=Ze*Ke-Ue*We,le=Ue*Qe-Je*Ke,oe=Je*We-Ze*Qe,_e=Math.hypot(ie,le,oe)||1;ie/=_e,le/=_e,oe/=_e;let he=l.length/3;l.push(Q,W,k.z,ee,V,k.z,mt,bt,G.z,$e,Fe,G.z),f.push(ie,le,oe,ie,le,oe,ie,le,oe,ie,le,oe);let et=O/w,tt=(O+1)/w,nt=E/(D.length-1),rt=(E+1)/(D.length-1);x.push(et,nt,tt,nt,tt,rt,et,rt),m.push(he,he+1,he+2,he,he+2,he+3)}}H+=w}}ge(this,l,f,x,m)}}function Ie(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function ct(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function pt(t,e,n){let r=t.nx+(e.nx-t.nx)*n,i=t.ny+(e.ny-t.ny)*n,h=t.nz+(e.nz-t.nz)*n,o=Math.hypot(r,i,h)||1;return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z+(e.z-t.z)*n,nx:r/o,ny:i/o,nz:h/o,u:t.u+(e.u-t.u)*n,v:t.v+(e.v-t.v)*n}}function yt(t){if(t.length<3)return null;let e=t[0],n=t[1],r=t[2],i=n.x-e.x,h=n.y-e.y,o=n.z-e.z,a=r.x-e.x,u=r.y-e.y,s=r.z-e.z,p=h*s-o*u,c=o*a-i*s,l=i*u-h*a,f=Math.hypot(p,c,l);if(f<1e-9)return null;p/=f,c/=f,l/=f;let x=p*e.x+c*e.y+l*e.z;return{vertices:t,nx:p,ny:c,nz:l,w:x}}function ft(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=ct(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Re=1e-5,Xe=0,we=1,be=2,De=3;function Oe(t,e,n,r,i,h,o,a,u){let s=0,p=[];for(let c=0;c<i.vertices.length;c++){let l=i.vertices[c],f=t*l.x+e*l.y+n*l.z-r,x=f<-Re?be:f>Re?we:Xe;s|=x,p.push(x)}switch(s){case Xe:{t*i.nx+e*i.ny+n*i.nz>0?h.push(i):o.push(i);break}case we:a.push(i);break;case be:u.push(i);break;case De:{let c=[],l=[],f=i.vertices.length;for(let b=0;b<f;b++){let M=(b+1)%f,d=p[b],_=p[M],P=i.vertices[b],S=i.vertices[M];if(d!==be&&c.push(P),d!==we&&l.push(d!==be?Ie(P):P),(d|_)===De){let T=S.x-P.x,A=S.y-P.y,I=S.z-P.z,C=t*T+e*A+n*I,L=Math.abs(C)>1e-12?(r-(t*P.x+e*P.y+n*P.z))/C:.5,R=pt(P,S,Math.max(0,Math.min(1,L)));c.push(R),l.push(Ie(R))}}let{nx:x,ny:m,nz:y,w:g}=i;c.length>=3&&a.push({vertices:c,nx:x,ny:m,nz:y,w:g}),l.length>=3&&u.push({vertices:l,nx:x,ny:m,nz:y,w:g});break}default:break}}class ce{constructor(e,n=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,n)}invert(){for(let n=0;n<this.polygons.length;n++)ft(this.polygons[n]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,n=0){if(!this.hasPlane||e.length===0)return e.slice();if(n>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let r=[],i=[];for(let h=0;h<e.length;h++)Oe(this.nx,this.ny,this.nz,this.w,e[h],r,i,r,i);return this.front&&r.length>0&&(r=this.front.clipPolygons(r,n+1)),this.back?i=i.length>0?this.back.clipPolygons(i,n+1):[]:i=[],r.concat(i)}clipTo(e,n=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),n<ne&&(this.front&&this.front.clipTo(e,n+1),this.back&&this.back.clipTo(e,n+1))}allPolygons(e=[]){for(let n=0;n<this.polygons.length;n++)e.push(this.polygons[n]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,n=0){if(!e.length)return;if(!this.hasPlane){let h=e[e.length>>1];this.nx=h.nx,this.ny=h.ny,this.nz=h.nz,this.w=h.w,this.hasPlane=!0}if(n>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let r=[],i=[];for(let h=0;h<e.length;h++)Oe(this.nx,this.ny,this.nz,this.w,e[h],this.polygons,this.polygons,r,i);r.length>0&&(this.front||(this.front=new ce),this.front.build(r,n+1)),i.length>0&&(this.back||(this.back=new ce),this.back.build(i,n+1))}}function Be(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let n=t.attributes.position;if(!n||n.count===0)return[];let r=t.attributes.normal,i=t.attributes.uv,h=t.index?t.index.array:null,o=Math.floor(h?h.length/3:n.count/3);if(o>ue)throw new RangeError(`SecurityError: CSG input triangle count (${o}) exceeds MAX_CSG_TRIANGLES (${ue})`);let a=e?e.elements:null,u=a?a[0]*(a[5]*a[10]-a[9]*a[6])-a[4]*(a[1]*a[10]-a[9]*a[2])+a[8]*(a[1]*a[6]-a[5]*a[2])<0:!1,s=a?new st().getNormalMatrix(e).elements:null,p=l=>{let f=n.getX(l),x=n.getY(l),m=n.getZ(l),y=r?r.getX(l):NaN,g=r?r.getY(l):NaN,b=r?r.getZ(l):NaN;if(a&&s){let _=a[0]*f+a[4]*x+a[8]*m+a[12],P=a[1]*f+a[5]*x+a[9]*m+a[13],S=a[2]*f+a[6]*x+a[10]*m+a[14];f=_,x=P,m=S;let T=s[0]*y+s[3]*g+s[6]*b,A=s[1]*y+s[4]*g+s[7]*b,I=s[2]*y+s[5]*g+s[8]*b,C=Math.hypot(T,A,I)||1;y=T/C,g=A/C,b=I/C}let M=i?i.getX(l):0,d=i?i.getY(l):0;return{x:f,y:x,z:m,nx:y,ny:g,nz:b,u:M,v:d}},c=[];for(let l=0;l<o;l++){let f=h?h[l*3]:l*3,x=h?h[l*3+1]:l*3+1,m=h?h[l*3+2]:l*3+2,y=yt(u?[p(f),p(m),p(x)]:[p(f),p(x),p(m)]);y&&c.push(y)}return c}function xt(t){let e=[],n=[],r=[],i=[];for(let o of t){let a=o.vertices;if(a.length<3)continue;let u=e.length/3;for(let s of a)e.push(s.x,s.y,s.z),Number.isFinite(s.nx)&&s.nx*s.nx+s.ny*s.ny+s.nz*s.nz>.5?n.push(s.nx,s.ny,s.nz):n.push(o.nx,o.ny,o.nz),r.push(s.u,s.v);for(let s=1;s<a.length-1;s++)i.push(u,u+s,u+s+1)}let h=ge(new te,e,n,r,i);return h._csgPolygons=t,h}function gt(t,e,n){if(t.length+e.length>ue)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${ue})`);if(t.length===0)return n==="union"?e:[];if(e.length===0)return n==="intersect"?[]:t;let r=1/0,i=1/0,h=1/0,o=-1/0,a=-1/0,u=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let m=0;m<x.length;m++){let y=x[m];y.x<r&&(r=y.x),y.y<i&&(i=y.y),y.z<h&&(h=y.z),y.x>o&&(o=y.x),y.y>a&&(a=y.y),y.z>u&&(u=y.z)}}r-=1e-4,i-=1e-4,h-=1e-4,o+=1e-4,a+=1e-4,u+=1e-4;let s=[],p=[];for(let f=0;f<t.length;f++){let x=t[f],m=x.vertices,y=1/0,g=1/0,b=1/0,M=-1/0,d=-1/0,_=-1/0;for(let P=0;P<m.length;P++){let S=m[P];S.x<y&&(y=S.x),S.y<g&&(g=S.y),S.z<b&&(b=S.z),S.x>M&&(M=S.x),S.y>d&&(d=S.y),S.z>_&&(_=S.z)}M<r||y>o||d<i||g>a||_<h||b>u?p.push(x):s.push(x)}if(s.length===0)return n==="union"?t.concat(e):n==="subtract"?t:[];let c=new ce(s),l=new ce(e);return n==="union"?(c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),p.concat(c.allPolygons())):n==="subtract"?(c.invert(),c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),c.invert(),p.concat(c.allPolygons())):(c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.build(l.allPolygons()),c.invert(),c.allPolygons())}function qe(t,e,n,r=null,i=null){let h=Be(t,r),o=Be(e,i);return xt(gt(h,o,n))}function Ne(t,e,n){let r=t instanceof pe||!!t?.isMesh,i=e instanceof pe||!!e?.isMesh,h=r?t.geometry:t,o=i?e.geometry:e,a=null;if(i)if(e.updateMatrix(),r){t.updateMatrix();let c=new Me().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),l=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new Me().compose(new ae(0,0,0),new K(-t.quaternion.x/l,-t.quaternion.y/l,-t.quaternion.z/l,t.quaternion.w/l),new ae(1,1,1)),x=new Me().makeTranslation(-t.position.x,-t.position.y,-t.position.z);a=c.multiply(f).multiply(x).multiply(e.matrix)}else a=e.matrix;let u=qe(h,o,n,null,a),s=r?t.material:new Ae,p=new pe(u,s);return r&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let de={toGeometry:qe,subtract(t,e){return Ne(t,e,"subtract")},union(t,e){return Ne(t,e,"union")},intersect(t,e){return Ne(t,e,"intersect")}},He={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class je extends te{constructor(e="",n={}){super();let r=String(e??"").slice(0,Ee),i=Math.max(.005,Math.min(100,B(n.size,.2))),h=!!(n.bevelEnabled??!1),o=h?Math.max(0,Math.min(2,B(n.bevelThickness,i*.04))):0,a=h?Math.max(0,Math.min(2,B(n.bevelSize,i*.03))):0,u=Math.max(.001,Math.min(20,B(n.depth??n.height,i*.2)))+o*2,s=i*.085+a,p=i*.68,c=i*.82,l=[],f=[],x=[],m=[],y=(M,d,_,P,S,T,A)=>{let I=_-M,C=P-d,L=Math.hypot(I,C),R=1,q=0;L>1e-6&&(R=I/L,q=C/L);let re=-q*S,se=R*S,Y=R*S*.6,$=q*S*.6,D=M-Y+re,H=d-$+se,v=M-Y-re,w=d-$-se,E=_+Y-re,k=P+$-se,G=_+Y+re,O=P+$+se,j=(F,J,Z,U,Q,W,ee)=>{let V=l.length/3;l.push(F[0],F[1],F[2],J[0],J[1],J[2],Z[0],Z[1],Z[2],U[0],U[1],U[2]),f.push(Q,W,ee,Q,W,ee,Q,W,ee,Q,W,ee),x.push(0,0,1,0,1,1,0,1),m.push(V,V+1,V+2,V,V+2,V+3)};j([D,H,A],[v,w,A],[E,k,A],[G,O,A],0,0,1),j([v,w,T],[D,H,T],[G,O,T],[E,k,T],0,0,-1),j([D,H,T],[v,w,T],[v,w,A],[D,H,A],-R,-q,0),j([E,k,T],[G,O,T],[G,O,A],[E,k,A],R,q,0),j([v,w,T],[E,k,T],[E,k,A],[v,w,A],q,-R,0),j([G,O,T],[D,H,T],[D,H,A],[G,O,A],-q,R,0)},g=0,b=0;for(let M=0;M<r.length;M++){let d=r[M];if(d===`
|
|
17
|
+
`){g=0,b-=i*1.35;continue}if(d===" "||d===" "){g+=c*(d===" "?.75:3);continue}if(d==="\r")continue;let _=d.toUpperCase(),P=d!==_&&d>="a"&&d<="z",S=He[_]??He["?"],T=P?i*.76:i,A=P?p*.88:p;for(let I of S)for(let C=0;C<I.length-1;C++){let L=I[C],R=I[C+1];y(g+L[0]*A,b+L[1]*T,g+R[0]*A,b+R[1]*T,s,-u*.5,u*.5)}g+=P?c*.88:c}ge(this,l,f,x,m),n.center!==!1?this.center():this.computeBoundingBox()}}function Ve(t){if(!t)return;let e=t,n=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(n!=null&&n!==!1){let i=e.geometry?.attributes?.position;if((!i||i.count===0)&&t.userData._textApplied!==!0){let h="",o=.08,a=.015,u;if(typeof n=="string"||typeof n=="number")h=String(n);else if(typeof n=="object"){let s=n;h=String(s.text??s.value??""),s.size!==void 0&&(o=Number(s.size)||.08),(s.depth!==void 0||s.height!==void 0)&&(a=Number(s.depth??s.height)||o*.2),(typeof s.color=="string"||typeof s.color=="number")&&(u=s.color)}h.trim().length>0&&(e.geometry=new je(h,{size:o,depth:a}),t.userData._textApplied=!0,e.material instanceof lt?u!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new it(u),t.userData._autoTextColorApplied=!0):e.material=new Ae({color:u??16317180}))}}let r=t.userData?.csg;if(r&&typeof r=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof te&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let i=Array.isArray(r)?r:[r],h=e.geometry;for(let o of i){if(!o||typeof o!="object")continue;let a=o,u=String(a.op??a.operation??"subtract"),s=u==="union"||u==="intersect"?u:"subtract",p=a.target??a.mesh??a.geometry;if(p instanceof pe||p instanceof te)try{let c=s==="union"?de.union(e,p):s==="intersect"?de.intersect(e,p):de.subtract(e,p);e.geometry!==h&&e.geometry.dispose?.(),e.geometry=c.geometry}catch(c){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",c)}}}}let Ye={Path:ye,Shape:fe,ShapeGeometry:ht,ExtrudeGeometry:ut,TextGeometry:je,CSG:de,MAX_CSG_TRIANGLES:ue,MAX_BSP_DEPTH:ne,MAX_TEXT_GEOMETRY_CHARS:Ee,MAX_SHAPE_POINTS:ze,materializeDeclarativeGeometry:Ve};return N&&typeof N=="object"&&(N.authorNamespace||(N.authorNamespace={}),Object.assign(N.authorNamespace,Ye),N._cadMaterialize=Ve,N.materializeDeclarativeGeometry=t=>{N._cadMaterialize?.(t),N._lodMaterialize?.(t)}),Ye}var Le={name:"cad",onRegister(){on(Se);let z=me(),N=z.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);N&&Se(N,z)}};rn(Le);
|
package/dist/three-live-cad.d.ts
CHANGED
|
@@ -87,6 +87,20 @@ export {
|
|
|
87
87
|
type InteractivityValueSocket,
|
|
88
88
|
type InteractivityVariableDef,
|
|
89
89
|
} from './three-live/src/plugins/interactivity';
|
|
90
|
+
export {
|
|
91
|
+
decimateGeometry,
|
|
92
|
+
getLodController,
|
|
93
|
+
installLodExtension,
|
|
94
|
+
LOD,
|
|
95
|
+
LodController,
|
|
96
|
+
lodPlugin,
|
|
97
|
+
materializeLodGeometry,
|
|
98
|
+
parseLod,
|
|
99
|
+
selectLodLevelIndex,
|
|
100
|
+
type LodGroupState,
|
|
101
|
+
type LodLevel,
|
|
102
|
+
type LodOptions,
|
|
103
|
+
} from './three-live/src/plugins/lod';
|
|
90
104
|
export {
|
|
91
105
|
applyMeshoptFilter,
|
|
92
106
|
decodeMeshoptBuffer,
|
|
@@ -130,6 +144,8 @@ export {
|
|
|
130
144
|
} from './xr-live/src/xr-live-element';
|
|
131
145
|
/** Optional spatial plugins (`xr-live/spatial`, `xr-live-spatial.min.js`). */
|
|
132
146
|
export * from './xr-live/src/plugins/index';
|
|
147
|
+
/** Optional simulation plugins (`xr-live/sim`, `xr-live-sim.min.js`). */
|
|
148
|
+
export * from './xr-live/src/sim/index';
|
|
133
149
|
|
|
134
150
|
/**
|
|
135
151
|
* Declarative JSX / HTML attributes supported by the <three-live> custom element.
|
|
@@ -169,6 +185,18 @@ export interface ThreeLiveAttributes {
|
|
|
169
185
|
'shadow-softness'?: number | string;
|
|
170
186
|
/** Tone mapping mode ("neutral", "aces", "agx", "reinhard", "none"). */
|
|
171
187
|
'tone-mapping'?: string;
|
|
188
|
+
/** Dual-Kawase bloom intensity (0.0 to 5.0). */
|
|
189
|
+
'bloom'?: number | string;
|
|
190
|
+
/** Luminance threshold for bloom extraction (default: 0.8). */
|
|
191
|
+
'bloom-threshold'?: number | string;
|
|
192
|
+
/** Blur radius multiplier for bloom passes (default: 0.5). */
|
|
193
|
+
'bloom-radius'?: number | string;
|
|
194
|
+
/** Declarative silhouette outline toggle or config. */
|
|
195
|
+
'outline'?: boolean | string;
|
|
196
|
+
/** Highlight the currently `selected-mesh` with a silhouette outline. */
|
|
197
|
+
'outline-selected'?: boolean | string;
|
|
198
|
+
/** Silhouette outline CSS hex color (default: "#38bdf8"). */
|
|
199
|
+
'outline-color'?: string;
|
|
172
200
|
/** Enable or disable interactive camera orbit/pan/zoom controls (default: true). */
|
|
173
201
|
'camera-controls'?: boolean | string;
|
|
174
202
|
/** Automatically start keyframe animation playback. */
|
|
@@ -210,6 +238,16 @@ export interface ThreeLiveAttributes {
|
|
|
210
238
|
// React 19 / JSX Event Listeners
|
|
211
239
|
onload?: (e: CustomEvent<{model: GLBData}>) => void;
|
|
212
240
|
onerror?: (e: CustomEvent<{error: any}>) => void;
|
|
241
|
+
'onthree-load'?: (
|
|
242
|
+
e: CustomEvent<{model: GLBData; source?: 'src' | 'model'}>,
|
|
243
|
+
) => void;
|
|
244
|
+
'onthree-error'?: (
|
|
245
|
+
e: CustomEvent<{error: any; message: string; stage: string}>,
|
|
246
|
+
) => void;
|
|
247
|
+
'onthree-context-lost'?: (e: CustomEvent<{originalEvent?: Event}>) => void;
|
|
248
|
+
'onthree-context-restored'?: (
|
|
249
|
+
e: CustomEvent<{originalEvent?: Event}>,
|
|
250
|
+
) => void;
|
|
213
251
|
onmeshclick?: (e: CustomEvent<HitDetail>) => void;
|
|
214
252
|
'oncamera-change'?: (e: CustomEvent<CameraDetail>) => void;
|
|
215
253
|
'onvariant-applied'?: (e: CustomEvent<{variantName: string | null}>) => void;
|
|
@@ -427,7 +465,27 @@ export interface XRLiveAttributes extends ThreeLiveAttributes {
|
|
|
427
465
|
sdpMLineIndex: number | null;
|
|
428
466
|
}>,
|
|
429
467
|
) => void;
|
|
468
|
+
onxraudioplay?: (
|
|
469
|
+
e: CustomEvent<{
|
|
470
|
+
node: string;
|
|
471
|
+
meshIndex: number;
|
|
472
|
+
preset: string | null;
|
|
473
|
+
src: string | null;
|
|
474
|
+
gain: number;
|
|
475
|
+
pan: number;
|
|
476
|
+
triggerCount: number;
|
|
477
|
+
}>,
|
|
478
|
+
) => void;
|
|
430
479
|
/** xr-live-sim events. */
|
|
480
|
+
onxrcollision?: (
|
|
481
|
+
e: CustomEvent<{
|
|
482
|
+
nodeId: string;
|
|
483
|
+
otherId: string;
|
|
484
|
+
normal: [number, number, number];
|
|
485
|
+
impactSpeed: number;
|
|
486
|
+
}>,
|
|
487
|
+
) => void;
|
|
488
|
+
onxrsleep?: (e: CustomEvent<{nodeId: string}>) => void;
|
|
431
489
|
oncharacterjump?: (
|
|
432
490
|
e: CustomEvent<{nodeId: string; position: [number, number, number]}>,
|
|
433
491
|
) => void;
|
package/dist/three-live-cad.js
CHANGED
|
@@ -13,6 +13,5 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var de="__THREE_LIVE_REGISTRY__";function me(){let L=typeof globalThis<"u"?globalThis:{};if(!L[de]){let E={plugins:[],decoders:new Map};try{Object.defineProperty(L,de,{value:E,writable:!1,configurable:!1,enumerable:!1})}catch{L[de]=E}}return L[de]}var Gn=me().plugins;function nn(L){let E=me();E.workerExtensionInstallers||(E.workerExtensionInstallers=[]),E.workerExtensionInstallers.includes(L)||E.workerExtensionInstallers.push(L)}function tn(L){let E=me().plugins;E.some(Y=>Y.name===L.name)||E.push(L),L.onRegister?.()}var Sn=8192,Pn=2048,Mn=128,wn=4096;function Ge(L,E){if(!L||!L.BufferGeometry)return null;let Y=L.Vector2,ke=L.Vector3,on=L.Quaternion,ve=L.Matrix4,rn=L.Matrix3,cn=L.Color,X=L.BufferAttribute,te=L.BufferGeometry,an=L.Material,Ce=L.MeshStandardMaterial,ye=L.Mesh,le=8192,se=2048,Te=128,Se=4096,B=(t,e)=>{let n=t==null?NaN:Number(t);return Number.isFinite(n)?n:e};class fe{constructor(e){this.currentPoint=new Y(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){let s=Number(e)||0,r=Number(n)||0;return this.currentPoint.set(s,r),this.segments.push({type:"move",pts:[s,r]}),this}lineTo(e,n){let s=Number(e)||0,r=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(s,r),this.segments.push({type:"line",pts:[s,r]}),this}quadraticCurveTo(e,n,s,r){let i=this.currentPoint.x,a=this.currentPoint.y,u=Number(e)||0,h=Number(n)||0,o=Number(s)||0,m=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[i,a]}),this.currentPoint.set(o,m),this.segments.push({type:"quad",pts:[i,a,u,h,o,m]}),this}bezierCurveTo(e,n,s,r,i,a){let u=this.currentPoint.x,h=this.currentPoint.y,o=Number(e)||0,m=Number(n)||0,l=Number(s)||0,c=Number(r)||0,f=Number(i)||0,x=Number(a)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,h]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[u,h,o,m,l,c,f,x]}),this}absarc(e,n,s,r,i,a=!1){return this.absellipse(e,n,s,s,r,i,a,0)}arc(e,n,s,r,i,a=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),s,r,i,a)}absellipse(e,n,s,r,i,a,u=!1,h=0){let o=Number(e)||0,m=Number(n)||0,l=Math.max(0,Number(s)||0),c=Math.max(0,Number(r)||0),f=Number(i)||0,x=Number(a)||0,p=u?1:0,b=Number(h)||0;this.segments.push({type:"arc",pts:[o,m,l,c,f,x,p,b]});let y=Math.cos(b),g=Math.sin(b),S=l*Math.cos(x),d=c*Math.sin(x);return this.currentPoint.set(o+S*y-d*g,m+S*g+d*y),this}ellipse(e,n,s,r,i,a,u=!1,h=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),s,r,i,a,u,h)}closePath(){if(this.segments.length>0){let e=this.segments[0],n=0,s=0;if(e.type==="arc"){let r=e.pts[0],i=e.pts[1],a=e.pts[2],u=e.pts[3],h=e.pts[4],o=e.pts[7],m=Math.cos(o),l=Math.sin(o),c=a*Math.cos(h),f=u*Math.sin(h);n=r+c*m-f*l,s=i+c*l+f*m}else n=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-n,this.currentPoint.y-s)>1e-6&&this.lineTo(n,s)}return this}getPoints(e=12){let n=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],r=(i,a)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-i,u.y-a)<1e-6)return}s.push(new Y(i,a))};for(let i of this.segments){let a=i.pts;if(i.type==="move"||i.type==="line")r(a[0],a[1]);else if(i.type==="quad"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5];r(u,h);for(let f=1;f<=n;f++){let x=f/n,p=1-x;r(p*p*u+2*p*x*o+x*x*l,p*p*h+2*p*x*m+x*x*c)}}else if(i.type==="cubic"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5],f=a[6],x=a[7];r(u,h);for(let p=1;p<=n;p++){let b=p/n,y=1-b,g=y*y,S=b*b;r(g*y*u+3*g*b*o+3*y*S*l+S*b*f,g*y*h+3*g*b*m+3*y*S*c+S*b*x)}}else if(i.type==="arc"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5],f=a[6]!==0,x=a[7],p=Math.PI*2,b=c-l,y=Math.abs(b)<1e-9;for(;b<0;)b+=p;for(;b>p;)b-=p;b<1e-9&&(b=y?0:p),f&&!y&&(b=b===p?-p:b-p);let g=Math.cos(x),S=Math.sin(x),d=Math.max(2,n);for(let M=0;M<=d;M++){let P=M/d,w=l+P*b,k=o*Math.cos(w),T=m*Math.sin(w);r(u+k*g-T*S,h+k*S+T*g)}}}if(s.length>2){let i=s[0],a=s[s.length-1];Math.hypot(i.x-a.x,i.y-a.y)<1e-6&&s.pop()}return s}getSpacedPoints(e=12){return this.getPoints(e)}}class xe extends fe{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(n=>n.getPoints(e))}}}function be(t){let e=0,n=t.length;for(let s=0,r=n-1;s<n;r=s++)e+=t[r].x*t[s].y-t[s].x*t[r].y;return e*.5}function un(t,e,n,s,r,i,a,u){let h=a-n,o=u-s,m=r-n,l=i-s,c=t-n,f=e-s,x=h*h+o*o,p=h*m+o*l,b=h*c+o*f,y=m*m+l*l,g=m*c+l*f,S=x*y-p*p;if(Math.abs(S)<1e-12)return!1;let d=1/S,M=(y*b-p*g)*d,P=(x*g-p*b)*d;return M>=-1e-7&&P>=-1e-7&&M+P<=1+1e-7}function Le(t,e){let n=t.slice();be(n)<0&&n.reverse();let s=n.map(h=>new Y(h.x,h.y)),r=n.map((h,o)=>o),i=[];for(let h of e){if(!h||h.length<3)continue;let o=h.slice();be(o)>0&&o.reverse();let m=[],l=-1/0,c=0;for(let f=0;f<o.length;f++){let x=o[f],p=s.length;s.push(new Y(x.x,x.y)),m.push(p),x.x>l&&(l=x.x,c=f)}i.push({pts:o,indices:m,maxX:l,maxIdx:c})}i.sort((h,o)=>o.maxX-h.maxX);let a=(h,o,m)=>(o.x-h.x)*(m.y-h.y)-(o.y-h.y)*(m.x-h.x),u=(h,o,m)=>{for(let l=0;l<m.length;l++){let c=m[l],f=m[(l+1)%m.length];if(a(h,o,c)*a(h,o,f)<0&&a(c,f,h)*a(c,f,o)<0)return!0}return!1};for(let h of i){let o=h.pts[h.maxIdx],m=o.x,l=r.length,c=r.map(y=>s[y]),f=y=>Math.hypot(c[y].x-m,c[y].y-o.y),x=c.map((y,g)=>g).sort((y,g)=>+(c[y].x<m)-+(c[g].x<m)||f(y)-f(g)),p=x[0];for(let y of x){let g=c[y],S=c[(y+l-1)%l],d=c[(y+1)%l],M=a(g,d,o)>=0,P=a(S,g,o)>=0;if((a(S,g,d)>=0?M&&P:M||P)&&!u(o,g,c)&&!i.some(k=>u(o,g,k.pts))){p=y;break}}let b=[];for(let y=0;y<=p;y++)b.push(r[y]);for(let y=0;y<=h.indices.length;y++){let g=h.indices[(h.maxIdx+y)%h.indices.length];b.push(g)}for(let y=p;y<r.length;y++)b.push(r[y]);r=b}return{merged:r.map(h=>s[h]),mergedIndices:r,allVertices:s}}function Ee(t,e){let n=[],s=t.slice();if(s.length<3)return n;let r=s.length*s.length+64,i=0;for(;s.length>2&&r-- >0;){let a=s.length,u=s[(i+a-1)%a],h=s[i%a],o=s[(i+1)%a],m=e[u],l=e[h],c=e[o];if((l.x-m.x)*(c.y-m.y)-(l.y-m.y)*(c.x-m.x)>1e-9){let x=!0;for(let p=0;p<a;p++){let b=s[p];if(b===u||b===h||b===o)continue;let y=e[b];if(un(y.x,y.y,m.x,m.y,l.x,l.y,c.x,c.y)&&Math.hypot(y.x-m.x,y.y-m.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6){x=!1;break}}if(x){n.push([u,h,o]),s.splice(i%a,1),i=Math.max(0,i%a-1);continue}}i++,i>=a*2&&(n.push([u,h,o]),s.splice((i-1)%a,1),i=0)}return n}function Re(t,e){let n=t instanceof xe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},s=n.shape.length;for(let r of n.holes)s+=r.length;if(s>Se)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${Se})`);return n}class ln extends te{constructor(e=new xe,n=12){super();let s=Array.isArray(e)?e:[e],r=[],i=[],a=[],u=[];for(let h of s){if(!(h instanceof fe))continue;let o=Re(h,n);if(o.shape.length<3)continue;let{mergedIndices:m,allVertices:l}=Le(o.shape,o.holes),c=Ee(m,l),f=r.length/3,x=1/0,p=1/0,b=-1/0,y=-1/0;for(let d of l)d.x<x&&(x=d.x),d.y<p&&(p=d.y),d.x>b&&(b=d.x),d.y>y&&(y=d.y);let g=Math.max(1e-6,b-x),S=Math.max(1e-6,y-p);for(let d of l)r.push(d.x,d.y,0),i.push(0,0,1),a.push((d.x-x)/g,(d.y-p)/S);for(let[d,M,P]of c)u.push(f+d,f+M,f+P)}this.setAttribute("position",new X(D(r),3)),this.setAttribute("normal",new X(D(i),3)),this.setAttribute("uv",new X(D(a),2)),this.setIndex(u)}}function D(t){let e=t.length,n=new Float32Array(e);for(let s=0;s<e;s++)n[s]=t[s];return n}function hn(t){let e=t.length,n=[];for(let s=0;s<e;s++){let r=t[(s+e-1)%e],i=t[s],a=t[(s+1)%e],u=i.x-r.x,h=i.y-r.y,o=Math.hypot(u,h)||1;u/=o,h/=o;let m=a.x-i.x,l=a.y-i.y,c=Math.hypot(m,l)||1;m/=c,l/=c;let f=h,x=-u,p=l,b=-m,y=f+p,g=x+b,S=Math.hypot(y,g);if(S>1e-6){y/=S,g/=S;let d=Math.max(.35,y*f+g*x);n.push(new Y(y/d,g/d))}else n.push(new Y(f,x))}return n}class mn extends te{constructor(e=new xe,n={}){super();let s=Array.isArray(e)?e:[e],r=Math.max(1,Math.min(64,Math.floor(B(n.curveSegments,12)))),i=B(n.depth??n.amount,1),a=Math.max(1,Math.min(32,Math.floor(B(n.steps,1)))),u=!!(n.bevelEnabled??!1),h=u?Math.max(0,B(n.bevelThickness,.06)):0,o=u?Math.max(0,B(n.bevelSize,h*.8)):0,m=u?B(n.bevelOffset,0):0,l=u?Math.max(1,Math.min(8,Math.floor(B(n.bevelSegments,2)))):0,c=[],f=[],x=[],p=[];for(let b of s){if(!(b instanceof fe))continue;let y=Re(b,r);if(y.shape.length<3)continue;let g=y.shape.slice();be(g)<0&&g.reverse();let S=[];for(let v of y.holes){if(v.length<3)continue;let G=v.slice();be(G)>0&&G.reverse(),S.push(G)}let{mergedIndices:d,allVertices:M}=Le(g,S),P=Ee(d,M),w=[g,...S],k=[];for(let v of w){let G=hn(v);for(let C of G)k.push(C)}let T=1/0,V=1/0,I=-1/0,O=-1/0;for(let v of M)v.x<T&&(T=v.x),v.y<V&&(V=v.y),v.x>I&&(I=v.x),v.y>O&&(O=v.y);let _=Math.max(1e-6,I-T),H=Math.max(1e-6,O-V),oe=-h,re=i+h,j=c.length/3;for(let v=0;v<M.length;v++){let G=M[v],C=k[v]??new Y(0,0),R=G.x+C.x*m,z=G.y+C.y*m;c.push(R,z,oe),f.push(0,0,-1),x.push((R-T)/_,(z-V)/H)}for(let[v,G,C]of P)p.push(j+v,j+C,j+G);let $=c.length/3;for(let v=0;v<M.length;v++){let G=M[v],C=k[v]??new Y(0,0),R=G.x+C.x*m,z=G.y+C.y*m;c.push(R,z,re),f.push(0,0,1),x.push((R-T)/_,(z-V)/H)}for(let[v,G,C]of P)p.push($+v,$+G,$+C);let A=[];if(u&&l>0)for(let v=0;v<l;v++){let C=v/l*Math.PI/2;A.push({z:-h*Math.cos(C),expand:m+o*Math.sin(C)})}for(let v=0;v<=a;v++){let G=v/a;A.push({z:G*i,expand:m+o})}if(u&&l>0)for(let v=1;v<=l;v++){let C=v/l*Math.PI/2;A.push({z:i+h*Math.sin(C),expand:m+o*Math.cos(C)})}let F=0;for(let v of w){let G=v.length;for(let C=0;C<A.length-1;C++){let R=A[C],z=A[C+1];for(let N=0;N<G;N++){let q=(N+1)%G,Z=v[N],U=v[q],Q=k[F+N],K=k[F+q],J=Z.x+Q.x*R.expand,ee=Z.y+Q.y*R.expand,ne=U.x+K.x*R.expand,W=U.y+K.y*R.expand,dn=U.x+K.x*z.expand,vn=U.y+K.y*z.expand,He=Z.x+Q.x*z.expand,Fe=Z.y+Q.y*z.expand,qe=ne-J,We=W-ee,je=0,$e=He-J,Ze=Fe-ee,Ue=z.z-R.z,ie=We*Ue-je*Ze,ce=je*$e-qe*Ue,ae=qe*Ze-We*$e,we=Math.hypot(ie,ce,ae)||1;ie/=we,ce/=we,ae/=we;let ue=c.length/3;c.push(J,ee,R.z,ne,W,R.z,dn,vn,z.z,He,Fe,z.z),f.push(ie,ce,ae,ie,ce,ae,ie,ce,ae,ie,ce,ae);let Qe=N/G,Ke=(N+1)/G,Je=C/(A.length-1),en=(C+1)/(A.length-1);x.push(Qe,Je,Ke,Je,Ke,en,Qe,en),p.push(ue,ue+1,ue+2,ue,ue+2,ue+3)}}F+=G}}this.setAttribute("position",new X(D(c),3)),this.setAttribute("normal",new X(D(f),3)),this.setAttribute("uv",new X(D(x),2)),this.setIndex(p)}}function ze(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function yn(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function fn(t,e,n){let s=t.nx+(e.nx-t.nx)*n,r=t.ny+(e.ny-t.ny)*n,i=t.nz+(e.nz-t.nz)*n,a=Math.hypot(s,r,i)||1;return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z+(e.z-t.z)*n,nx:s/a,ny:r/a,nz:i/a,u:t.u+(e.u-t.u)*n,v:t.v+(e.v-t.v)*n}}function xn(t){if(t.length<3)return null;let e=t[0],n=t[1],s=t[2],r=n.x-e.x,i=n.y-e.y,a=n.z-e.z,u=s.x-e.x,h=s.y-e.y,o=s.z-e.z,m=i*o-a*h,l=a*u-r*o,c=r*h-i*u,f=Math.hypot(m,l,c);if(f<1e-9)return null;m/=f,l/=f,c/=f;let x=m*e.x+l*e.y+c*e.z;return{vertices:t,nx:m,ny:l,nz:c,w:x}}function bn(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=yn(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Ie=1e-5,Ve=0,Pe=1,pe=2,_e=3;function Ae(t,e,n,s,r,i,a,u,h){let o=0,m=[];for(let l=0;l<r.vertices.length;l++){let c=r.vertices[l],f=t*c.x+e*c.y+n*c.z-s,x=f<-Ie?pe:f>Ie?Pe:Ve;o|=x,m.push(x)}switch(o){case Ve:{t*r.nx+e*r.ny+n*r.nz>0?i.push(r):a.push(r);break}case Pe:u.push(r);break;case pe:h.push(r);break;case _e:{let l=[],c=[],f=r.vertices.length;for(let g=0;g<f;g++){let S=(g+1)%f,d=m[g],M=m[S],P=r.vertices[g],w=r.vertices[S];if(d!==pe&&l.push(P),d!==Pe&&c.push(d!==pe?ze(P):P),(d|M)===_e){let k=w.x-P.x,T=w.y-P.y,V=w.z-P.z,I=t*k+e*T+n*V,O=Math.abs(I)>1e-12?(s-(t*P.x+e*P.y+n*P.z))/I:.5,_=fn(P,w,Math.max(0,Math.min(1,O)));l.push(_),c.push(ze(_))}}let{nx:x,ny:p,nz:b,w:y}=r;l.length>=3&&u.push({vertices:l,nx:x,ny:p,nz:b,w:y}),c.length>=3&&h.push({vertices:c,nx:x,ny:p,nz:b,w:y});break}default:break}}class he{constructor(e,n=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,n)}invert(){for(let n=0;n<this.polygons.length;n++)bn(this.polygons[n]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,n=0){if(!this.hasPlane||e.length===0)return e.slice();if(n>=se)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${se})`);let s=[],r=[];for(let i=0;i<e.length;i++)Ae(this.nx,this.ny,this.nz,this.w,e[i],s,r,s,r);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,n+1)),this.back?r=r.length>0?this.back.clipPolygons(r,n+1):[]:r=[],s.concat(r)}clipTo(e,n=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),n<se&&(this.front&&this.front.clipTo(e,n+1),this.back&&this.back.clipTo(e,n+1))}allPolygons(e=[]){for(let n=0;n<this.polygons.length;n++)e.push(this.polygons[n]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,n=0){if(!e.length)return;if(!this.hasPlane){let i=e[e.length>>1];this.nx=i.nx,this.ny=i.ny,this.nz=i.nz,this.w=i.w,this.hasPlane=!0}if(n>=se)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${se})`);let s=[],r=[];for(let i=0;i<e.length;i++)Ae(this.nx,this.ny,this.nz,this.w,e[i],this.polygons,this.polygons,s,r);s.length>0&&(this.front||(this.front=new he),this.front.build(s,n+1)),r.length>0&&(this.back||(this.back=new he),this.back.build(r,n+1))}}function Ne(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let n=t.attributes.position;if(!n||n.count===0)return[];let s=t.attributes.normal,r=t.attributes.uv,i=t.index?t.index.array:null,a=Math.floor(i?i.length/3:n.count/3);if(a>le)throw new RangeError(`SecurityError: CSG input triangle count (${a}) exceeds MAX_CSG_TRIANGLES (${le})`);let u=e?e.elements:null,h=u?u[0]*(u[5]*u[10]-u[9]*u[6])-u[4]*(u[1]*u[10]-u[9]*u[2])+u[8]*(u[1]*u[6]-u[5]*u[2])<0:!1,o=u?new rn().getNormalMatrix(e).elements:null,m=c=>{let f=n.getX(c),x=n.getY(c),p=n.getZ(c),b=s?s.getX(c):NaN,y=s?s.getY(c):NaN,g=s?s.getZ(c):NaN;if(u&&o){let M=u[0]*f+u[4]*x+u[8]*p+u[12],P=u[1]*f+u[5]*x+u[9]*p+u[13],w=u[2]*f+u[6]*x+u[10]*p+u[14];f=M,x=P,p=w;let k=o[0]*b+o[3]*y+o[6]*g,T=o[1]*b+o[4]*y+o[7]*g,V=o[2]*b+o[5]*y+o[8]*g,I=Math.hypot(k,T,V)||1;b=k/I,y=T/I,g=V/I}let S=r?r.getX(c):0,d=r?r.getY(c):0;return{x:f,y:x,z:p,nx:b,ny:y,nz:g,u:S,v:d}},l=[];for(let c=0;c<a;c++){let f=i?i[c*3]:c*3,x=i?i[c*3+1]:c*3+1,p=i?i[c*3+2]:c*3+2,b=xn(h?[m(f),m(p),m(x)]:[m(f),m(x),m(p)]);b&&l.push(b)}return l}function pn(t){let e=[],n=[],s=[],r=[];for(let a of t){let u=a.vertices;if(u.length<3)continue;let h=e.length/3;for(let o of u)e.push(o.x,o.y,o.z),Number.isFinite(o.nx)&&o.nx*o.nx+o.ny*o.ny+o.nz*o.nz>.5?n.push(o.nx,o.ny,o.nz):n.push(a.nx,a.ny,a.nz),s.push(o.u,o.v);for(let o=1;o<u.length-1;o++)r.push(h,h+o,h+o+1)}let i=new te;return i.setAttribute("position",new X(D(e),3)),i.setAttribute("normal",new X(D(n),3)),i.setAttribute("uv",new X(D(s),2)),i.setIndex(r),i._csgPolygons=t,i}function gn(t,e,n){if(t.length+e.length>le)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${le})`);if(t.length===0)return n==="union"?e:[];if(e.length===0)return n==="intersect"?[]:t;let s=1/0,r=1/0,i=1/0,a=-1/0,u=-1/0,h=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let p=0;p<x.length;p++){let b=x[p];b.x<s&&(s=b.x),b.y<r&&(r=b.y),b.z<i&&(i=b.z),b.x>a&&(a=b.x),b.y>u&&(u=b.y),b.z>h&&(h=b.z)}}s-=1e-4,r-=1e-4,i-=1e-4,a+=1e-4,u+=1e-4,h+=1e-4;let o=[],m=[];for(let f=0;f<t.length;f++){let x=t[f],p=x.vertices,b=1/0,y=1/0,g=1/0,S=-1/0,d=-1/0,M=-1/0;for(let P=0;P<p.length;P++){let w=p[P];w.x<b&&(b=w.x),w.y<y&&(y=w.y),w.z<g&&(g=w.z),w.x>S&&(S=w.x),w.y>d&&(d=w.y),w.z>M&&(M=w.z)}S<s||b>a||d<r||y>u||M<i||g>h?m.push(x):o.push(x)}if(o.length===0)return n==="union"?t.concat(e):n==="subtract"?t:[];let l=new he(o),c=new he(e);return n==="union"?(l.clipTo(c),c.clipTo(l),c.invert(),c.clipTo(l),c.invert(),l.build(c.allPolygons()),m.concat(l.allPolygons())):n==="subtract"?(l.invert(),l.clipTo(c),c.clipTo(l),c.invert(),c.clipTo(l),c.invert(),l.build(c.allPolygons()),l.invert(),m.concat(l.allPolygons())):(l.invert(),c.clipTo(l),c.invert(),l.clipTo(c),c.clipTo(l),l.build(c.allPolygons()),l.invert(),l.allPolygons())}function Xe(t,e,n,s=null,r=null){let i=Ne(t,s),a=Ne(e,r);return pn(gn(i,a,n))}function Me(t,e,n){let s=t instanceof ye||!!t?.isMesh,r=e instanceof ye||!!e?.isMesh,i=s?t.geometry:t,a=r?e.geometry:e,u=null;if(r)if(e.updateMatrix(),s){t.updateMatrix();let l=new ve().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),c=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new ve().compose(new ke(0,0,0),new on(-t.quaternion.x/c,-t.quaternion.y/c,-t.quaternion.z/c,t.quaternion.w/c),new ke(1,1,1)),x=new ve().makeTranslation(-t.position.x,-t.position.y,-t.position.z);u=l.multiply(f).multiply(x).multiply(e.matrix)}else u=e.matrix;let h=Xe(i,a,n,null,u),o=s?t.material:new Ce,m=new ye(h,o);return s&&(m.position.copy(t.position),m.quaternion.copy(t.quaternion),m.scale.copy(t.scale),m.name=t.name),m}let ge={toGeometry:Xe,subtract(t,e){return Me(t,e,"subtract")},union(t,e){return Me(t,e,"union")},intersect(t,e){return Me(t,e,"intersect")}},De={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class Oe extends te{constructor(e="",n={}){super();let s=String(e??"").slice(0,Te),r=Math.max(.005,Math.min(100,B(n.size,.2))),i=!!(n.bevelEnabled??!1),a=i?Math.max(0,Math.min(2,B(n.bevelThickness,r*.04))):0,u=i?Math.max(0,Math.min(2,B(n.bevelSize,r*.03))):0,h=Math.max(.001,Math.min(20,B(n.depth??n.height,r*.2)))+a*2,o=r*.085+u,m=r*.68,l=r*.82,c=[],f=[],x=[],p=[],b=(S,d,M,P,w,k,T)=>{let V=M-S,I=P-d,O=Math.hypot(V,I),_=1,H=0;O>1e-6&&(_=V/O,H=I/O);let oe=-H*w,re=_*w,j=_*w*.6,$=H*w*.6,A=S-j+oe,F=d-$+re,v=S-j-oe,G=d-$-re,C=M+j-oe,R=P+$-re,z=M+j+oe,N=P+$+re,q=(Z,U,Q,K,J,ee,ne)=>{let W=c.length/3;c.push(Z[0],Z[1],Z[2],U[0],U[1],U[2],Q[0],Q[1],Q[2],K[0],K[1],K[2]),f.push(J,ee,ne,J,ee,ne,J,ee,ne,J,ee,ne),x.push(0,0,1,0,1,1,0,1),p.push(W,W+1,W+2,W,W+2,W+3)};q([A,F,T],[v,G,T],[C,R,T],[z,N,T],0,0,1),q([v,G,k],[A,F,k],[z,N,k],[C,R,k],0,0,-1),q([A,F,k],[v,G,k],[v,G,T],[A,F,T],-_,-H,0),q([C,R,k],[z,N,k],[z,N,T],[C,R,T],_,H,0),q([v,G,k],[C,R,k],[C,R,T],[v,G,T],H,-_,0),q([z,N,k],[A,F,k],[A,F,T],[z,N,T],-H,_,0)},y=0,g=0;for(let S=0;S<s.length;S++){let d=s[S];if(d===`
|
|
18
|
-
`){y=0,g-=r*1.35;continue}if(d===" "||d===" "){y+=l*(d===" "?.75:3);continue}if(d==="\r")continue;let M=d.toUpperCase(),P=d!==M&&d>="a"&&d<="z",w=De[M]??De["?"],k=P?r*.76:r,T=P?m*.88:m;for(let V of w)for(let I=0;I<V.length-1;I++){let O=V[I],_=V[I+1];b(y+O[0]*T,g+O[1]*k,y+_[0]*T,g+_[1]*k,o,-h*.5,h*.5)}y+=P?l*.88:l}this.setAttribute("position",new X(D(c),3)),this.setAttribute("normal",new X(D(f),3)),this.setAttribute("uv",new X(D(x),2)),this.setIndex(p),n.center!==!1?this.center():this.computeBoundingBox()}}function Be(t){if(!t)return;let e=t,n=t.userData?.xr?.text;if(n!=null&&n!==!1){let r=e.geometry?.attributes?.position;if((!r||r.count===0)&&t.userData._textApplied!==!0){let i="",a=.08,u=.015,h;if(typeof n=="string"||typeof n=="number")i=String(n);else if(typeof n=="object"){let o=n;i=String(o.text??o.value??""),o.size!==void 0&&(a=Number(o.size)||.08),(o.depth!==void 0||o.height!==void 0)&&(u=Number(o.depth??o.height)||a*.2),(typeof o.color=="string"||typeof o.color=="number")&&(h=o.color)}i.trim().length>0&&(e.geometry=new Oe(i,{size:a,depth:u}),t.userData._textApplied=!0,e.material instanceof an?h!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new cn(h),t.userData._autoTextColorApplied=!0):e.material=new Ce({color:h??16317180}))}}let s=t.userData?.csg;if(s&&typeof s=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof te&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let r=Array.isArray(s)?s:[s],i=e.geometry;for(let a of r){if(!a||typeof a!="object")continue;let u=a,h=String(u.op??u.operation??"subtract"),o=h==="union"||h==="intersect"?h:"subtract",m=u.target??u.mesh??u.geometry;if(m instanceof ye||m instanceof te)try{let l=o==="union"?ge.union(e,m):o==="intersect"?ge.intersect(e,m):ge.subtract(e,m);e.geometry!==i&&e.geometry.dispose?.(),e.geometry=l.geometry}catch(l){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",l)}}}}let Ye={Path:fe,Shape:xe,ShapeGeometry:ln,ExtrudeGeometry:mn,TextGeometry:Oe,CSG:ge,MAX_CSG_TRIANGLES:le,MAX_BSP_DEPTH:se,MAX_TEXT_GEOMETRY_CHARS:Te,MAX_SHAPE_POINTS:Se,materializeDeclarativeGeometry:Be};return E&&typeof E=="object"&&(E.authorNamespace||(E.authorNamespace={}),Object.assign(E.authorNamespace,Ye),E.materializeDeclarativeGeometry=Be),Ye}var sn={name:"cad",onRegister(){nn(Ge);let L=me(),E=L.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);E&&Ge(E,L)}};tn(sn);export{Pn as MAX_BSP_DEPTH,Sn as MAX_CSG_TRIANGLES,wn as MAX_SHAPE_POINTS,Mn as MAX_TEXT_GEOMETRY_CHARS,sn as cadPlugin,Ge as installCadExtension};
|
|
16
|
+
*/var me="__THREE_LIVE_REGISTRY__";function be(){let A=typeof globalThis<"u"?globalThis:{};if(!A[me]){let E={plugins:[],decoders:new Map};try{Object.defineProperty(A,me,{value:E,writable:!1,configurable:!1,enumerable:!1})}catch{A[me]=E}}return A[me]}var wt=be().plugins;function bt(A){let E=be();E.workerExtensionInstallers||(E.workerExtensionInstallers=[]),E.workerExtensionInstallers.includes(A)||E.workerExtensionInstallers.push(A)}function Mt(A){let E=be().plugins;E.some(B=>B.name===A.name)||E.push(A),A.onRegister?.()}var dt=8192,vt=2048,zt=128,Pt=4096;function Se(A,E){if(!A||!A.BufferGeometry)return null;let B=A.Vector2,Ne=A.Vector3,st=A.Quaternion,Me=A.Matrix4,nt=A.Matrix3,rt=A.Color,de=A.BufferAttribute,ee=A.BufferGeometry,it=A.Material,_e=A.MeshStandardMaterial,ue=A.Mesh,he=8192,te=2048,Ae=128,ve=4096,H=(t,e)=>{let s=t==null?NaN:Number(t);return Number.isFinite(s)?s:e};class ce{constructor(e){this.currentPoint=new B(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let s=1;s<e.length;s++)this.lineTo(e[s].x,e[s].y);return this}moveTo(e,s){let n=Number(e)||0,i=Number(s)||0;return this.currentPoint.set(n,i),this.segments.push({type:"move",pts:[n,i]}),this}lineTo(e,s){let n=Number(e)||0,i=Number(s)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(n,i),this.segments.push({type:"line",pts:[n,i]}),this}quadraticCurveTo(e,s,n,i){let h=this.currentPoint.x,o=this.currentPoint.y,a=Number(e)||0,u=Number(s)||0,r=Number(n)||0,p=Number(i)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[h,o]}),this.currentPoint.set(r,p),this.segments.push({type:"quad",pts:[h,o,a,u,r,p]}),this}bezierCurveTo(e,s,n,i,h,o){let a=this.currentPoint.x,u=this.currentPoint.y,r=Number(e)||0,p=Number(s)||0,c=Number(n)||0,l=Number(i)||0,f=Number(h)||0,x=Number(o)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,u]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[a,u,r,p,c,l,f,x]}),this}absarc(e,s,n,i,h,o=!1){return this.absellipse(e,s,n,n,i,h,o,0)}arc(e,s,n,i,h,o=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(s)||0),n,i,h,o)}absellipse(e,s,n,i,h,o,a=!1,u=0){let r=Number(e)||0,p=Number(s)||0,c=Math.max(0,Number(n)||0),l=Math.max(0,Number(i)||0),f=Number(h)||0,x=Number(o)||0,m=a?1:0,y=Number(u)||0;this.segments.push({type:"arc",pts:[r,p,c,l,f,x,m,y]});let g=Math.cos(y),b=Math.sin(y),v=c*Math.cos(x),M=l*Math.sin(x);return this.currentPoint.set(r+v*g-M*b,p+v*b+M*g),this}ellipse(e,s,n,i,h,o,a=!1,u=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(s)||0),n,i,h,o,a,u)}closePath(){if(this.segments.length>0){let e=this.segments[0],s=0,n=0;if(e.type==="arc"){let i=e.pts[0],h=e.pts[1],o=e.pts[2],a=e.pts[3],u=e.pts[4],r=e.pts[7],p=Math.cos(r),c=Math.sin(r),l=o*Math.cos(u),f=a*Math.sin(u);s=i+l*p-f*c,n=h+l*c+f*p}else s=e.pts[0],n=e.pts[1];Math.hypot(this.currentPoint.x-s,this.currentPoint.y-n)>1e-6&&this.lineTo(s,n)}return this}getPoints(e=12){let s=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),n=[],i=(h,o)=>{if(n.length>0){let a=n[n.length-1];if(Math.hypot(a.x-h,a.y-o)<1e-6)return}n.push(new B(h,o))};for(let h of this.segments){let o=h.pts;if(h.type==="move"||h.type==="line")i(o[0],o[1]);else if(h.type==="quad"){let a=o[0],u=o[1],r=o[2],p=o[3],c=o[4],l=o[5];i(a,u);for(let f=1;f<=s;f++){let x=f/s,m=1-x;i(m*m*a+2*m*x*r+x*x*c,m*m*u+2*m*x*p+x*x*l)}}else if(h.type==="cubic"){let a=o[0],u=o[1],r=o[2],p=o[3],c=o[4],l=o[5],f=o[6],x=o[7];i(a,u);for(let m=1;m<=s;m++){let y=m/s,g=1-y,b=g*g,v=y*y;i(b*g*a+3*b*y*r+3*g*v*c+v*y*f,b*g*u+3*b*y*p+3*g*v*l+v*y*x)}}else if(h.type==="arc"){let a=o[0],u=o[1],r=o[2],p=o[3],c=o[4],l=o[5],f=o[6]!==0,x=o[7],m=Math.PI*2,y=l-c,g=Math.abs(y)<1e-9;for(;y<0;)y+=m;for(;y>m;)y-=m;y<1e-9&&(y=g?0:m),f&&!g&&(y=y===m?-m:y-m);let b=Math.cos(x),v=Math.sin(x),M=Math.max(2,s);for(let S=0;S<=M;S++){let z=S/M,w=c+z*y,N=r*Math.cos(w),_=p*Math.sin(w);i(a+N*b-_*v,u+N*v+_*b)}}}if(n.length>2){let h=n[0],o=n[n.length-1];Math.hypot(h.x-o.x,h.y-o.y)<1e-6&&n.pop()}return n}getSpacedPoints(e=12){return this.getPoints(e)}clone(){let e=new this.constructor;return e.currentPoint.copy(this.currentPoint),e.segments=this.segments.map(s=>({type:s.type,pts:[...s.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(s=>s.clone())),e}}class pe extends ce{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(s=>s.getPoints(e))}}}function ye(t){let e=0,s=t.length;for(let n=0,i=s-1;n<s;i=n++)e+=t[i].x*t[n].y-t[n].x*t[i].y;return e*.5}function lt(t,e,s,n,i,h,o,a){let u=o-s,r=a-n,p=i-s,c=h-n,l=t-s,f=e-n,x=u*u+r*r,m=u*p+r*c,y=u*l+r*f,g=p*p+c*c,b=p*l+c*f,v=x*g-m*m;if(Math.abs(v)<1e-12)return!1;let M=1/v,S=(g*y-m*b)*M,z=(x*b-m*y)*M;return S>=-1e-7&&z>=-1e-7&&S+z<=1+1e-7}function Te(t,e){let s=t.slice();ye(s)<0&&s.reverse();let n=s.map(u=>new B(u.x,u.y)),i=s.map((u,r)=>r),h=[];for(let u of e){if(!u||u.length<3)continue;let r=u.slice();ye(r)>0&&r.reverse();let p=[],c=-1/0,l=0;for(let f=0;f<r.length;f++){let x=r[f],m=n.length;n.push(new B(x.x,x.y)),p.push(m),x.x>c&&(c=x.x,l=f)}h.push({pts:r,indices:p,maxX:c,maxIdx:l})}h.sort((u,r)=>r.maxX-u.maxX);let o=(u,r,p)=>(r.x-u.x)*(p.y-u.y)-(r.y-u.y)*(p.x-u.x),a=(u,r,p)=>{for(let c=0;c<p.length;c++){let l=p[c],f=p[(c+1)%p.length];if(o(u,r,l)*o(u,r,f)<0&&o(l,f,u)*o(l,f,r)<0)return!0}return!1};for(let u of h){let r=u.pts[u.maxIdx],p=r.x,c=i.length,l=i.map(g=>n[g]),f=g=>Math.hypot(l[g].x-p,l[g].y-r.y),x=l.map((g,b)=>b).sort((g,b)=>+(l[g].x<p)-+(l[b].x<p)||f(g)-f(b)),m=x[0];for(let g of x){let b=l[g],v=l[(g+c-1)%c],M=l[(g+1)%c],S=o(b,M,r)>=0,z=o(v,b,r)>=0;if((o(v,b,M)>=0?S&&z:S||z)&&!a(r,b,l)&&!h.some(w=>a(r,b,w.pts))){m=g;break}}let y=[];for(let g=0;g<=m;g++)y.push(i[g]);for(let g=0;g<=u.indices.length;g++){let b=u.indices[(u.maxIdx+g)%u.indices.length];y.push(b)}for(let g=m;g<i.length;g++)y.push(i[g]);i=y}return{merged:i.map(u=>n[u]),mergedIndices:i,allVertices:n}}function Ee(t,e){let s=[],n=t.slice();if(n.length<3)return s;let i=n.length*n.length+64,h=0;for(;n.length>2&&i-- >0;){let o=n.length,a=n[(h+o-1)%o],u=n[h%o],r=n[(h+1)%o],p=e[a],c=e[u],l=e[r];if((c.x-p.x)*(l.y-p.y)-(c.y-p.y)*(l.x-p.x)>1e-9){let f=!0;for(let x=0;x<o;x++){let m=n[x];if(m===a||m===u||m===r)continue;let y=e[m];if(lt(y.x,y.y,p.x,p.y,c.x,c.y,l.x,l.y)&&Math.hypot(y.x-p.x,y.y-p.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6){f=!1;break}}if(f){s.push([a,u,r]),n.splice(h%o,1),h=Math.max(0,h%o-1);continue}}h++,h>=o*2&&(s.push([a,u,r]),n.splice((h-1)%o,1),h=0)}return s}function Ge(t,e){let s=t instanceof pe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},n=s.shape.length;for(let i of s.holes)n+=i.length;if(n>ve)throw new RangeError(`SecurityError: shape point count (${n}) exceeds MAX_SHAPE_POINTS (${ve})`);return s}class ot extends ee{constructor(e=new pe,s=12){super();let n=Array.isArray(e)?e:[e],i=[],h=[],o=[],a=[];for(let u of n){if(!(u instanceof ce))continue;let r=Ge(u,s);if(r.shape.length<3)continue;let{mergedIndices:p,allVertices:c}=Te(r.shape,r.holes),l=Ee(p,c),f=i.length/3,x=1/0,m=1/0,y=-1/0,g=-1/0;for(let M of c)M.x<x&&(x=M.x),M.y<m&&(m=M.y),M.x>y&&(y=M.x),M.y>g&&(g=M.y);let b=Math.max(1e-6,y-x),v=Math.max(1e-6,g-m);for(let M of c)i.push(M.x,M.y,0),h.push(0,0,1),o.push((M.x-x)/b,(M.y-m)/v);for(let[M,S,z]of l)a.push(f+M,f+S,f+z)}fe(this,i,h,o,a)}}function fe(t,e,s,n,i){return t.setAttribute("position",new de(e,3)),t.setAttribute("normal",new de(s,3)),t.setAttribute("uv",new de(n,2)),t.setIndex(i),t}function ht(t){let e=t.length,s=[];for(let n=0;n<e;n++){let i=t[(n+e-1)%e],h=t[n],o=t[(n+1)%e],a=h.x-i.x,u=h.y-i.y,r=Math.hypot(a,u)||1;a/=r,u/=r;let p=o.x-h.x,c=o.y-h.y,l=Math.hypot(p,c)||1;p/=l,c/=l;let f=u,x=-a,m=c,y=-p,g=f+m,b=x+y,v=Math.hypot(g,b);if(v>1e-6){g/=v,b/=v;let M=Math.max(.35,g*f+b*x);s.push(new B(g/M,b/M))}else s.push(new B(f,x))}return s}class at extends ee{constructor(e=new pe,s={}){super();let n=Array.isArray(e)?e:[e],i=Math.max(1,Math.min(64,Math.floor(H(s.curveSegments,12)))),h=H(s.depth??s.amount,1),o=Math.max(1,Math.min(32,Math.floor(H(s.steps,1)))),a=!!(s.bevelEnabled??!1),u=a?Math.max(0,H(s.bevelThickness,.06)):0,r=a?Math.max(0,H(s.bevelSize,u*.8)):0,p=a?H(s.bevelOffset,0):0,c=a?Math.max(1,Math.min(8,Math.floor(H(s.bevelSegments,2)))):0,l=[],f=[],x=[],m=[];for(let y of n){if(!(y instanceof ce))continue;let g=Ge(y,i);if(g.shape.length<3)continue;let b=g.shape.slice();ye(b)<0&&b.reverse();let v=[];for(let d of g.holes){if(d.length<3)continue;let P=d.slice();ye(P)>0&&P.reverse(),v.push(P)}let{mergedIndices:M,allVertices:S}=Te(b,v),z=Ee(M,S),w=[b,...v],N=[];for(let d of w){let P=ht(d);for(let T of P)N.push(T)}let _=1/0,X=1/0,I=-1/0,q=-1/0;for(let d of S)d.x<_&&(_=d.x),d.y<X&&(X=d.y),d.x>I&&(I=d.x),d.y>q&&(q=d.y);let R=Math.max(1e-6,I-_),O=Math.max(1e-6,q-X),se=-u,ne=h+u,$=l.length/3;for(let d=0;d<S.length;d++){let P=S[d],T=N[d]??new B(0,0),G=P.x+T.x*p,C=P.y+T.y*p;l.push(G,C,se),f.push(0,0,-1),x.push((G-_)/R,(C-X)/O)}for(let[d,P,T]of z)m.push($+d,$+T,$+P);let F=l.length/3;for(let d=0;d<S.length;d++){let P=S[d],T=N[d]??new B(0,0),G=P.x+T.x*p,C=P.y+T.y*p;l.push(G,C,ne),f.push(0,0,1),x.push((G-_)/R,(C-X)/O)}for(let[d,P,T]of z)m.push(F+d,F+P,F+T);let k=[];if(a&&c>0)for(let d=0;d<c;d++){let P=d/c*Math.PI/2;k.push({z:-u*Math.cos(P),expand:p+r*Math.sin(P)})}for(let d=0;d<=o;d++){let P=d/o;k.push({z:P*h,expand:p+r})}if(a&&c>0)for(let d=1;d<=c;d++){let P=d/c*Math.PI/2;k.push({z:h+u*Math.sin(P),expand:p+r*Math.cos(P)})}let V=0;for(let d of w){let P=d.length;for(let T=0;T<k.length-1;T++){let G=k[T],C=k[T+1];for(let D=0;D<P;D++){let Y=(D+1)%P,Z=d[D],U=d[Y],Q=N[V+D],W=N[V+Y],J=Z.x+Q.x*G.expand,K=Z.y+Q.y*G.expand,L=U.x+W.x*G.expand,j=U.y+W.y*G.expand,gt=U.x+W.x*C.expand,mt=U.y+W.y*C.expand,Ye=Z.x+Q.x*C.expand,je=Z.y+Q.y*C.expand,$e=L-J,Fe=j-K,Ze=0,Ue=Ye-J,Qe=je-K,We=C.z-G.z,re=Fe*We-Ze*Qe,ie=Ze*Ue-$e*We,le=$e*Qe-Fe*Ue,we=Math.hypot(re,ie,le)||1;re/=we,ie/=we,le/=we;let oe=l.length/3;l.push(J,K,G.z,L,j,G.z,gt,mt,C.z,Ye,je,C.z),f.push(re,ie,le,re,ie,le,re,ie,le,re,ie,le);let Je=D/P,Ke=(D+1)/P,Le=T/(k.length-1),et=(T+1)/(k.length-1);x.push(Je,Le,Ke,Le,Ke,et,Je,et),m.push(oe,oe+1,oe+2,oe,oe+2,oe+3)}}V+=P}}fe(this,l,f,x,m)}}function Ce(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function ut(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function ct(t,e,s){let n=t.nx+(e.nx-t.nx)*s,i=t.ny+(e.ny-t.ny)*s,h=t.nz+(e.nz-t.nz)*s,o=Math.hypot(n,i,h)||1;return{x:t.x+(e.x-t.x)*s,y:t.y+(e.y-t.y)*s,z:t.z+(e.z-t.z)*s,nx:n/o,ny:i/o,nz:h/o,u:t.u+(e.u-t.u)*s,v:t.v+(e.v-t.v)*s}}function pt(t){if(t.length<3)return null;let e=t[0],s=t[1],n=t[2],i=s.x-e.x,h=s.y-e.y,o=s.z-e.z,a=n.x-e.x,u=n.y-e.y,r=n.z-e.z,p=h*r-o*u,c=o*a-i*r,l=i*u-h*a,f=Math.hypot(p,c,l);if(f<1e-9)return null;p/=f,c/=f,l/=f;let x=p*e.x+c*e.y+l*e.z;return{vertices:t,nx:p,ny:c,nz:l,w:x}}function yt(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=ut(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Ie=1e-5,Xe=0,ze=1,xe=2,Re=3;function ke(t,e,s,n,i,h,o,a,u){let r=0,p=[];for(let c=0;c<i.vertices.length;c++){let l=i.vertices[c],f=t*l.x+e*l.y+s*l.z-n,x=f<-Ie?xe:f>Ie?ze:Xe;r|=x,p.push(x)}switch(r){case Xe:{t*i.nx+e*i.ny+s*i.nz>0?h.push(i):o.push(i);break}case ze:a.push(i);break;case xe:u.push(i);break;case Re:{let c=[],l=[],f=i.vertices.length;for(let b=0;b<f;b++){let v=(b+1)%f,M=p[b],S=p[v],z=i.vertices[b],w=i.vertices[v];if(M!==xe&&c.push(z),M!==ze&&l.push(M!==xe?Ce(z):z),(M|S)===Re){let N=w.x-z.x,_=w.y-z.y,X=w.z-z.z,I=t*N+e*_+s*X,q=Math.abs(I)>1e-12?(n-(t*z.x+e*z.y+s*z.z))/I:.5,R=ct(z,w,Math.max(0,Math.min(1,q)));c.push(R),l.push(Ce(R))}}let{nx:x,ny:m,nz:y,w:g}=i;c.length>=3&&a.push({vertices:c,nx:x,ny:m,nz:y,w:g}),l.length>=3&&u.push({vertices:l,nx:x,ny:m,nz:y,w:g});break}default:break}}class ae{constructor(e,s=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,s)}invert(){for(let s=0;s<this.polygons.length;s++)yt(this.polygons[s]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,s=0){if(!this.hasPlane||e.length===0)return e.slice();if(s>=te)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${te})`);let n=[],i=[];for(let h=0;h<e.length;h++)ke(this.nx,this.ny,this.nz,this.w,e[h],n,i,n,i);return this.front&&n.length>0&&(n=this.front.clipPolygons(n,s+1)),this.back?i=i.length>0?this.back.clipPolygons(i,s+1):[]:i=[],n.concat(i)}clipTo(e,s=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),s<te&&(this.front&&this.front.clipTo(e,s+1),this.back&&this.back.clipTo(e,s+1))}allPolygons(e=[]){for(let s=0;s<this.polygons.length;s++)e.push(this.polygons[s]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,s=0){if(!e.length)return;if(!this.hasPlane){let h=e[e.length>>1];this.nx=h.nx,this.ny=h.ny,this.nz=h.nz,this.w=h.w,this.hasPlane=!0}if(s>=te)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${te})`);let n=[],i=[];for(let h=0;h<e.length;h++)ke(this.nx,this.ny,this.nz,this.w,e[h],this.polygons,this.polygons,n,i);n.length>0&&(this.front||(this.front=new ae),this.front.build(n,s+1)),i.length>0&&(this.back||(this.back=new ae),this.back.build(i,s+1))}}function De(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let s=t.attributes.position;if(!s||s.count===0)return[];let n=t.attributes.normal,i=t.attributes.uv,h=t.index?t.index.array:null,o=Math.floor(h?h.length/3:s.count/3);if(o>he)throw new RangeError(`SecurityError: CSG input triangle count (${o}) exceeds MAX_CSG_TRIANGLES (${he})`);let a=e?e.elements:null,u=a?a[0]*(a[5]*a[10]-a[9]*a[6])-a[4]*(a[1]*a[10]-a[9]*a[2])+a[8]*(a[1]*a[6]-a[5]*a[2])<0:!1,r=a?new nt().getNormalMatrix(e).elements:null,p=l=>{let f=s.getX(l),x=s.getY(l),m=s.getZ(l),y=n?n.getX(l):NaN,g=n?n.getY(l):NaN,b=n?n.getZ(l):NaN;if(a&&r){let S=a[0]*f+a[4]*x+a[8]*m+a[12],z=a[1]*f+a[5]*x+a[9]*m+a[13],w=a[2]*f+a[6]*x+a[10]*m+a[14];f=S,x=z,m=w;let N=r[0]*y+r[3]*g+r[6]*b,_=r[1]*y+r[4]*g+r[7]*b,X=r[2]*y+r[5]*g+r[8]*b,I=Math.hypot(N,_,X)||1;y=N/I,g=_/I,b=X/I}let v=i?i.getX(l):0,M=i?i.getY(l):0;return{x:f,y:x,z:m,nx:y,ny:g,nz:b,u:v,v:M}},c=[];for(let l=0;l<o;l++){let f=h?h[l*3]:l*3,x=h?h[l*3+1]:l*3+1,m=h?h[l*3+2]:l*3+2,y=pt(u?[p(f),p(m),p(x)]:[p(f),p(x),p(m)]);y&&c.push(y)}return c}function ft(t){let e=[],s=[],n=[],i=[];for(let o of t){let a=o.vertices;if(a.length<3)continue;let u=e.length/3;for(let r of a)e.push(r.x,r.y,r.z),Number.isFinite(r.nx)&&r.nx*r.nx+r.ny*r.ny+r.nz*r.nz>.5?s.push(r.nx,r.ny,r.nz):s.push(o.nx,o.ny,o.nz),n.push(r.u,r.v);for(let r=1;r<a.length-1;r++)i.push(u,u+r,u+r+1)}let h=fe(new ee,e,s,n,i);return h._csgPolygons=t,h}function xt(t,e,s){if(t.length+e.length>he)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${he})`);if(t.length===0)return s==="union"?e:[];if(e.length===0)return s==="intersect"?[]:t;let n=1/0,i=1/0,h=1/0,o=-1/0,a=-1/0,u=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let m=0;m<x.length;m++){let y=x[m];y.x<n&&(n=y.x),y.y<i&&(i=y.y),y.z<h&&(h=y.z),y.x>o&&(o=y.x),y.y>a&&(a=y.y),y.z>u&&(u=y.z)}}n-=1e-4,i-=1e-4,h-=1e-4,o+=1e-4,a+=1e-4,u+=1e-4;let r=[],p=[];for(let f=0;f<t.length;f++){let x=t[f],m=x.vertices,y=1/0,g=1/0,b=1/0,v=-1/0,M=-1/0,S=-1/0;for(let z=0;z<m.length;z++){let w=m[z];w.x<y&&(y=w.x),w.y<g&&(g=w.y),w.z<b&&(b=w.z),w.x>v&&(v=w.x),w.y>M&&(M=w.y),w.z>S&&(S=w.z)}v<n||y>o||M<i||g>a||S<h||b>u?p.push(x):r.push(x)}if(r.length===0)return s==="union"?t.concat(e):s==="subtract"?t:[];let c=new ae(r),l=new ae(e);return s==="union"?(c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),p.concat(c.allPolygons())):s==="subtract"?(c.invert(),c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),c.invert(),p.concat(c.allPolygons())):(c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.build(l.allPolygons()),c.invert(),c.allPolygons())}function qe(t,e,s,n=null,i=null){let h=De(t,n),o=De(e,i);return ft(xt(h,o,s))}function Pe(t,e,s){let n=t instanceof ue||!!t?.isMesh,i=e instanceof ue||!!e?.isMesh,h=n?t.geometry:t,o=i?e.geometry:e,a=null;if(i)if(e.updateMatrix(),n){t.updateMatrix();let c=new Me().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),l=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new Me().compose(new Ne(0,0,0),new st(-t.quaternion.x/l,-t.quaternion.y/l,-t.quaternion.z/l,t.quaternion.w/l),new Ne(1,1,1)),x=new Me().makeTranslation(-t.position.x,-t.position.y,-t.position.z);a=c.multiply(f).multiply(x).multiply(e.matrix)}else a=e.matrix;let u=qe(h,o,s,null,a),r=n?t.material:new _e,p=new ue(u,r);return n&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let ge={toGeometry:qe,subtract(t,e){return Pe(t,e,"subtract")},union(t,e){return Pe(t,e,"union")},intersect(t,e){return Pe(t,e,"intersect")}},He={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class Be extends ee{constructor(e="",s={}){super();let n=String(e??"").slice(0,Ae),i=Math.max(.005,Math.min(100,H(s.size,.2))),h=!!(s.bevelEnabled??!1),o=h?Math.max(0,Math.min(2,H(s.bevelThickness,i*.04))):0,a=h?Math.max(0,Math.min(2,H(s.bevelSize,i*.03))):0,u=Math.max(.001,Math.min(20,H(s.depth??s.height,i*.2)))+o*2,r=i*.085+a,p=i*.68,c=i*.82,l=[],f=[],x=[],m=[],y=(v,M,S,z,w,N,_)=>{let X=S-v,I=z-M,q=Math.hypot(X,I),R=1,O=0;q>1e-6&&(R=X/q,O=I/q);let se=-O*w,ne=R*w,$=R*w*.6,F=O*w*.6,k=v-$+se,V=M-F+ne,d=v-$-se,P=M-F-ne,T=S+$-se,G=z+F-ne,C=S+$+se,D=z+F+ne,Y=(Z,U,Q,W,J,K,L)=>{let j=l.length/3;l.push(Z[0],Z[1],Z[2],U[0],U[1],U[2],Q[0],Q[1],Q[2],W[0],W[1],W[2]),f.push(J,K,L,J,K,L,J,K,L,J,K,L),x.push(0,0,1,0,1,1,0,1),m.push(j,j+1,j+2,j,j+2,j+3)};Y([k,V,_],[d,P,_],[T,G,_],[C,D,_],0,0,1),Y([d,P,N],[k,V,N],[C,D,N],[T,G,N],0,0,-1),Y([k,V,N],[d,P,N],[d,P,_],[k,V,_],-R,-O,0),Y([T,G,N],[C,D,N],[C,D,_],[T,G,_],R,O,0),Y([d,P,N],[T,G,N],[T,G,_],[d,P,_],O,-R,0),Y([C,D,N],[k,V,N],[k,V,_],[C,D,_],-O,R,0)},g=0,b=0;for(let v=0;v<n.length;v++){let M=n[v];if(M===`
|
|
17
|
+
`){g=0,b-=i*1.35;continue}if(M===" "||M===" "){g+=c*(M===" "?.75:3);continue}if(M==="\r")continue;let S=M.toUpperCase(),z=M!==S&&M>="a"&&M<="z",w=He[S]??He["?"],N=z?i*.76:i,_=z?p*.88:p;for(let X of w)for(let I=0;I<X.length-1;I++){let q=X[I],R=X[I+1];y(g+q[0]*_,b+q[1]*N,g+R[0]*_,b+R[1]*N,r,-u*.5,u*.5)}g+=z?c*.88:c}fe(this,l,f,x,m),s.center!==!1?this.center():this.computeBoundingBox()}}function Oe(t){if(!t)return;let e=t,s=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(s!=null&&s!==!1){let i=e.geometry?.attributes?.position;if((!i||i.count===0)&&t.userData._textApplied!==!0){let h="",o=.08,a=.015,u;if(typeof s=="string"||typeof s=="number")h=String(s);else if(typeof s=="object"){let r=s;h=String(r.text??r.value??""),r.size!==void 0&&(o=Number(r.size)||.08),(r.depth!==void 0||r.height!==void 0)&&(a=Number(r.depth??r.height)||o*.2),(typeof r.color=="string"||typeof r.color=="number")&&(u=r.color)}h.trim().length>0&&(e.geometry=new Be(h,{size:o,depth:a}),t.userData._textApplied=!0,e.material instanceof it?u!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new rt(u),t.userData._autoTextColorApplied=!0):e.material=new _e({color:u??16317180}))}}let n=t.userData?.csg;if(n&&typeof n=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof ee&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let i=Array.isArray(n)?n:[n],h=e.geometry;for(let o of i){if(!o||typeof o!="object")continue;let a=o,u=String(a.op??a.operation??"subtract"),r=u==="union"||u==="intersect"?u:"subtract",p=a.target??a.mesh??a.geometry;if(p instanceof ue||p instanceof ee)try{let c=r==="union"?ge.union(e,p):r==="intersect"?ge.intersect(e,p):ge.subtract(e,p);e.geometry!==h&&e.geometry.dispose?.(),e.geometry=c.geometry}catch(c){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",c)}}}}let Ve={Path:ce,Shape:pe,ShapeGeometry:ot,ExtrudeGeometry:at,TextGeometry:Be,CSG:ge,MAX_CSG_TRIANGLES:he,MAX_BSP_DEPTH:te,MAX_TEXT_GEOMETRY_CHARS:Ae,MAX_SHAPE_POINTS:ve,materializeDeclarativeGeometry:Oe};return E&&typeof E=="object"&&(E.authorNamespace||(E.authorNamespace={}),Object.assign(E.authorNamespace,Ve),E._cadMaterialize=Oe,E.materializeDeclarativeGeometry=t=>{E._cadMaterialize?.(t),E._lodMaterialize?.(t)}),Ve}var tt={name:"cad",onRegister(){bt(Se);let A=be(),E=A.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);E&&Se(E,A)}};Mt(tt);export{vt as MAX_BSP_DEPTH,dt as MAX_CSG_TRIANGLES,Pt as MAX_SHAPE_POINTS,zt as MAX_TEXT_GEOMETRY_CHARS,tt as cadPlugin,Se as installCadExtension};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
*
|
|
@@ -13,6 +13,5 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
"use strict";var ThreeLiveCAD=(()=>{var Te=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Tn=Object.prototype.hasOwnProperty;var Ln=(M,L)=>{for(var A in L)Te(M,A,{get:L[A],enumerable:!0})},En=(M,L,A,he)=>{if(L&&typeof L=="object"||typeof L=="function")for(let ne of Cn(L))!Tn.call(M,ne)&&ne!==A&&Te(M,ne,{get:()=>L[ne],enumerable:!(he=kn(L,ne))||he.enumerable});return M};var Rn=M=>En(Te({},"__esModule",{value:!0}),M);var zn={};Ln(zn,{MAX_BSP_DEPTH:()=>an,MAX_CSG_TRIANGLES:()=>cn,MAX_SHAPE_POINTS:()=>ln,MAX_TEXT_GEOMETRY_CHARS:()=>un,cadPlugin:()=>Le,installCadExtension:()=>Pe});var Se="__THREE_LIVE_REGISTRY__";function fe(){let M=typeof globalThis<"u"?globalThis:{};if(!M[Se]){let L={plugins:[],decoders:new Map};try{Object.defineProperty(M,Se,{value:L,writable:!1,configurable:!1,enumerable:!1})}catch{M[Se]=L}}return M[Se]}var Vn=fe().plugins;function on(M){let L=fe();L.workerExtensionInstallers||(L.workerExtensionInstallers=[]),L.workerExtensionInstallers.includes(M)||L.workerExtensionInstallers.push(M)}function rn(M){let L=fe().plugins;L.some(A=>A.name===M.name)||L.push(M),M.onRegister?.()}var cn=8192,an=2048,un=128,ln=4096;function Pe(M,L){if(!M||!M.BufferGeometry)return null;let A=M.Vector2,he=M.Vector3,ne=M.Quaternion,Me=M.Matrix4,hn=M.Matrix3,mn=M.Color,D=M.BufferAttribute,se=M.BufferGeometry,yn=M.Material,Ee=M.MeshStandardMaterial,xe=M.Mesh,me=8192,oe=2048,Re=128,we=4096,Y=(t,e)=>{let n=t==null?NaN:Number(t);return Number.isFinite(n)?n:e};class be{constructor(e){this.currentPoint=new A(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){let s=Number(e)||0,r=Number(n)||0;return this.currentPoint.set(s,r),this.segments.push({type:"move",pts:[s,r]}),this}lineTo(e,n){let s=Number(e)||0,r=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(s,r),this.segments.push({type:"line",pts:[s,r]}),this}quadraticCurveTo(e,n,s,r){let i=this.currentPoint.x,a=this.currentPoint.y,u=Number(e)||0,h=Number(n)||0,o=Number(s)||0,m=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[i,a]}),this.currentPoint.set(o,m),this.segments.push({type:"quad",pts:[i,a,u,h,o,m]}),this}bezierCurveTo(e,n,s,r,i,a){let u=this.currentPoint.x,h=this.currentPoint.y,o=Number(e)||0,m=Number(n)||0,l=Number(s)||0,c=Number(r)||0,f=Number(i)||0,x=Number(a)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,h]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[u,h,o,m,l,c,f,x]}),this}absarc(e,n,s,r,i,a=!1){return this.absellipse(e,n,s,s,r,i,a,0)}arc(e,n,s,r,i,a=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),s,r,i,a)}absellipse(e,n,s,r,i,a,u=!1,h=0){let o=Number(e)||0,m=Number(n)||0,l=Math.max(0,Number(s)||0),c=Math.max(0,Number(r)||0),f=Number(i)||0,x=Number(a)||0,p=u?1:0,b=Number(h)||0;this.segments.push({type:"arc",pts:[o,m,l,c,f,x,p,b]});let y=Math.cos(b),g=Math.sin(b),S=l*Math.cos(x),d=c*Math.sin(x);return this.currentPoint.set(o+S*y-d*g,m+S*g+d*y),this}ellipse(e,n,s,r,i,a,u=!1,h=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),s,r,i,a,u,h)}closePath(){if(this.segments.length>0){let e=this.segments[0],n=0,s=0;if(e.type==="arc"){let r=e.pts[0],i=e.pts[1],a=e.pts[2],u=e.pts[3],h=e.pts[4],o=e.pts[7],m=Math.cos(o),l=Math.sin(o),c=a*Math.cos(h),f=u*Math.sin(h);n=r+c*m-f*l,s=i+c*l+f*m}else n=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-n,this.currentPoint.y-s)>1e-6&&this.lineTo(n,s)}return this}getPoints(e=12){let n=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],r=(i,a)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-i,u.y-a)<1e-6)return}s.push(new A(i,a))};for(let i of this.segments){let a=i.pts;if(i.type==="move"||i.type==="line")r(a[0],a[1]);else if(i.type==="quad"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5];r(u,h);for(let f=1;f<=n;f++){let x=f/n,p=1-x;r(p*p*u+2*p*x*o+x*x*l,p*p*h+2*p*x*m+x*x*c)}}else if(i.type==="cubic"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5],f=a[6],x=a[7];r(u,h);for(let p=1;p<=n;p++){let b=p/n,y=1-b,g=y*y,S=b*b;r(g*y*u+3*g*b*o+3*y*S*l+S*b*f,g*y*h+3*g*b*m+3*y*S*c+S*b*x)}}else if(i.type==="arc"){let u=a[0],h=a[1],o=a[2],m=a[3],l=a[4],c=a[5],f=a[6]!==0,x=a[7],p=Math.PI*2,b=c-l,y=Math.abs(b)<1e-9;for(;b<0;)b+=p;for(;b>p;)b-=p;b<1e-9&&(b=y?0:p),f&&!y&&(b=b===p?-p:b-p);let g=Math.cos(x),S=Math.sin(x),d=Math.max(2,n);for(let w=0;w<=d;w++){let P=w/d,G=l+P*b,C=o*Math.cos(G),E=m*Math.sin(G);r(u+C*g-E*S,h+C*S+E*g)}}}if(s.length>2){let i=s[0],a=s[s.length-1];Math.hypot(i.x-a.x,i.y-a.y)<1e-6&&s.pop()}return s}getSpacedPoints(e=12){return this.getPoints(e)}}class pe extends be{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(n=>n.getPoints(e))}}}function ge(t){let e=0,n=t.length;for(let s=0,r=n-1;s<n;r=s++)e+=t[r].x*t[s].y-t[s].x*t[r].y;return e*.5}function fn(t,e,n,s,r,i,a,u){let h=a-n,o=u-s,m=r-n,l=i-s,c=t-n,f=e-s,x=h*h+o*o,p=h*m+o*l,b=h*c+o*f,y=m*m+l*l,g=m*c+l*f,S=x*y-p*p;if(Math.abs(S)<1e-12)return!1;let d=1/S,w=(y*b-p*g)*d,P=(x*g-p*b)*d;return w>=-1e-7&&P>=-1e-7&&w+P<=1+1e-7}function ze(t,e){let n=t.slice();ge(n)<0&&n.reverse();let s=n.map(h=>new A(h.x,h.y)),r=n.map((h,o)=>o),i=[];for(let h of e){if(!h||h.length<3)continue;let o=h.slice();ge(o)>0&&o.reverse();let m=[],l=-1/0,c=0;for(let f=0;f<o.length;f++){let x=o[f],p=s.length;s.push(new A(x.x,x.y)),m.push(p),x.x>l&&(l=x.x,c=f)}i.push({pts:o,indices:m,maxX:l,maxIdx:c})}i.sort((h,o)=>o.maxX-h.maxX);let a=(h,o,m)=>(o.x-h.x)*(m.y-h.y)-(o.y-h.y)*(m.x-h.x),u=(h,o,m)=>{for(let l=0;l<m.length;l++){let c=m[l],f=m[(l+1)%m.length];if(a(h,o,c)*a(h,o,f)<0&&a(c,f,h)*a(c,f,o)<0)return!0}return!1};for(let h of i){let o=h.pts[h.maxIdx],m=o.x,l=r.length,c=r.map(y=>s[y]),f=y=>Math.hypot(c[y].x-m,c[y].y-o.y),x=c.map((y,g)=>g).sort((y,g)=>+(c[y].x<m)-+(c[g].x<m)||f(y)-f(g)),p=x[0];for(let y of x){let g=c[y],S=c[(y+l-1)%l],d=c[(y+1)%l],w=a(g,d,o)>=0,P=a(S,g,o)>=0;if((a(S,g,d)>=0?w&&P:w||P)&&!u(o,g,c)&&!i.some(C=>u(o,g,C.pts))){p=y;break}}let b=[];for(let y=0;y<=p;y++)b.push(r[y]);for(let y=0;y<=h.indices.length;y++){let g=h.indices[(h.maxIdx+y)%h.indices.length];b.push(g)}for(let y=p;y<r.length;y++)b.push(r[y]);r=b}return{merged:r.map(h=>s[h]),mergedIndices:r,allVertices:s}}function Ie(t,e){let n=[],s=t.slice();if(s.length<3)return n;let r=s.length*s.length+64,i=0;for(;s.length>2&&r-- >0;){let a=s.length,u=s[(i+a-1)%a],h=s[i%a],o=s[(i+1)%a],m=e[u],l=e[h],c=e[o];if((l.x-m.x)*(c.y-m.y)-(l.y-m.y)*(c.x-m.x)>1e-9){let x=!0;for(let p=0;p<a;p++){let b=s[p];if(b===u||b===h||b===o)continue;let y=e[b];if(fn(y.x,y.y,m.x,m.y,l.x,l.y,c.x,c.y)&&Math.hypot(y.x-m.x,y.y-m.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6){x=!1;break}}if(x){n.push([u,h,o]),s.splice(i%a,1),i=Math.max(0,i%a-1);continue}}i++,i>=a*2&&(n.push([u,h,o]),s.splice((i-1)%a,1),i=0)}return n}function Ve(t,e){let n=t instanceof pe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},s=n.shape.length;for(let r of n.holes)s+=r.length;if(s>we)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${we})`);return n}class xn extends se{constructor(e=new pe,n=12){super();let s=Array.isArray(e)?e:[e],r=[],i=[],a=[],u=[];for(let h of s){if(!(h instanceof be))continue;let o=Ve(h,n);if(o.shape.length<3)continue;let{mergedIndices:m,allVertices:l}=ze(o.shape,o.holes),c=Ie(m,l),f=r.length/3,x=1/0,p=1/0,b=-1/0,y=-1/0;for(let d of l)d.x<x&&(x=d.x),d.y<p&&(p=d.y),d.x>b&&(b=d.x),d.y>y&&(y=d.y);let g=Math.max(1e-6,b-x),S=Math.max(1e-6,y-p);for(let d of l)r.push(d.x,d.y,0),i.push(0,0,1),a.push((d.x-x)/g,(d.y-p)/S);for(let[d,w,P]of c)u.push(f+d,f+w,f+P)}this.setAttribute("position",new D(O(r),3)),this.setAttribute("normal",new D(O(i),3)),this.setAttribute("uv",new D(O(a),2)),this.setIndex(u)}}function O(t){let e=t.length,n=new Float32Array(e);for(let s=0;s<e;s++)n[s]=t[s];return n}function bn(t){let e=t.length,n=[];for(let s=0;s<e;s++){let r=t[(s+e-1)%e],i=t[s],a=t[(s+1)%e],u=i.x-r.x,h=i.y-r.y,o=Math.hypot(u,h)||1;u/=o,h/=o;let m=a.x-i.x,l=a.y-i.y,c=Math.hypot(m,l)||1;m/=c,l/=c;let f=h,x=-u,p=l,b=-m,y=f+p,g=x+b,S=Math.hypot(y,g);if(S>1e-6){y/=S,g/=S;let d=Math.max(.35,y*f+g*x);n.push(new A(y/d,g/d))}else n.push(new A(f,x))}return n}class pn extends se{constructor(e=new pe,n={}){super();let s=Array.isArray(e)?e:[e],r=Math.max(1,Math.min(64,Math.floor(Y(n.curveSegments,12)))),i=Y(n.depth??n.amount,1),a=Math.max(1,Math.min(32,Math.floor(Y(n.steps,1)))),u=!!(n.bevelEnabled??!1),h=u?Math.max(0,Y(n.bevelThickness,.06)):0,o=u?Math.max(0,Y(n.bevelSize,h*.8)):0,m=u?Y(n.bevelOffset,0):0,l=u?Math.max(1,Math.min(8,Math.floor(Y(n.bevelSegments,2)))):0,c=[],f=[],x=[],p=[];for(let b of s){if(!(b instanceof be))continue;let y=Ve(b,r);if(y.shape.length<3)continue;let g=y.shape.slice();ge(g)<0&&g.reverse();let S=[];for(let v of y.holes){if(v.length<3)continue;let k=v.slice();ge(k)>0&&k.reverse(),S.push(k)}let{mergedIndices:d,allVertices:w}=ze(g,S),P=Ie(d,w),G=[g,...S],C=[];for(let v of G){let k=bn(v);for(let T of k)C.push(T)}let E=1/0,V=1/0,I=-1/0,B=-1/0;for(let v of w)v.x<E&&(E=v.x),v.y<V&&(V=v.y),v.x>I&&(I=v.x),v.y>B&&(B=v.y);let _=Math.max(1e-6,I-E),H=Math.max(1e-6,B-V),re=-h,ie=i+h,j=c.length/3;for(let v=0;v<w.length;v++){let k=w[v],T=C[v]??new A(0,0),R=k.x+T.x*m,z=k.y+T.y*m;c.push(R,z,re),f.push(0,0,-1),x.push((R-E)/_,(z-V)/H)}for(let[v,k,T]of P)p.push(j+v,j+T,j+k);let $=c.length/3;for(let v=0;v<w.length;v++){let k=w[v],T=C[v]??new A(0,0),R=k.x+T.x*m,z=k.y+T.y*m;c.push(R,z,ie),f.push(0,0,1),x.push((R-E)/_,(z-V)/H)}for(let[v,k,T]of P)p.push($+v,$+k,$+T);let N=[];if(u&&l>0)for(let v=0;v<l;v++){let T=v/l*Math.PI/2;N.push({z:-h*Math.cos(T),expand:m+o*Math.sin(T)})}for(let v=0;v<=a;v++){let k=v/a;N.push({z:k*i,expand:m+o})}if(u&&l>0)for(let v=1;v<=l;v++){let T=v/l*Math.PI/2;N.push({z:i+h*Math.sin(T),expand:m+o*Math.cos(T)})}let F=0;for(let v of G){let k=v.length;for(let T=0;T<N.length-1;T++){let R=N[T],z=N[T+1];for(let X=0;X<k;X++){let q=(X+1)%k,Z=v[X],U=v[q],Q=C[F+X],K=C[F+q],J=Z.x+Q.x*R.expand,ee=Z.y+Q.y*R.expand,te=U.x+K.x*R.expand,W=U.y+K.y*R.expand,wn=U.x+K.x*z.expand,Gn=U.y+K.y*z.expand,We=Z.x+Q.x*z.expand,je=Z.y+Q.y*z.expand,$e=te-J,Ze=W-ee,Ue=0,Qe=We-J,Ke=je-ee,Je=z.z-R.z,ce=Ze*Je-Ue*Ke,ae=Ue*Qe-$e*Je,ue=$e*Ke-Ze*Qe,Ce=Math.hypot(ce,ae,ue)||1;ce/=Ce,ae/=Ce,ue/=Ce;let le=c.length/3;c.push(J,ee,R.z,te,W,R.z,wn,Gn,z.z,We,je,z.z),f.push(ce,ae,ue,ce,ae,ue,ce,ae,ue,ce,ae,ue);let en=X/k,nn=(X+1)/k,tn=T/(N.length-1),sn=(T+1)/(N.length-1);x.push(en,tn,nn,tn,nn,sn,en,sn),p.push(le,le+1,le+2,le,le+2,le+3)}}F+=k}}this.setAttribute("position",new D(O(c),3)),this.setAttribute("normal",new D(O(f),3)),this.setAttribute("uv",new D(O(x),2)),this.setIndex(p)}}function _e(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function gn(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function dn(t,e,n){let s=t.nx+(e.nx-t.nx)*n,r=t.ny+(e.ny-t.ny)*n,i=t.nz+(e.nz-t.nz)*n,a=Math.hypot(s,r,i)||1;return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z+(e.z-t.z)*n,nx:s/a,ny:r/a,nz:i/a,u:t.u+(e.u-t.u)*n,v:t.v+(e.v-t.v)*n}}function vn(t){if(t.length<3)return null;let e=t[0],n=t[1],s=t[2],r=n.x-e.x,i=n.y-e.y,a=n.z-e.z,u=s.x-e.x,h=s.y-e.y,o=s.z-e.z,m=i*o-a*h,l=a*u-r*o,c=r*h-i*u,f=Math.hypot(m,l,c);if(f<1e-9)return null;m/=f,l/=f,c/=f;let x=m*e.x+l*e.y+c*e.z;return{vertices:t,nx:m,ny:l,nz:c,w:x}}function Sn(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=gn(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Ae=1e-5,Ne=0,Ge=1,de=2,Xe=3;function De(t,e,n,s,r,i,a,u,h){let o=0,m=[];for(let l=0;l<r.vertices.length;l++){let c=r.vertices[l],f=t*c.x+e*c.y+n*c.z-s,x=f<-Ae?de:f>Ae?Ge:Ne;o|=x,m.push(x)}switch(o){case Ne:{t*r.nx+e*r.ny+n*r.nz>0?i.push(r):a.push(r);break}case Ge:u.push(r);break;case de:h.push(r);break;case Xe:{let l=[],c=[],f=r.vertices.length;for(let g=0;g<f;g++){let S=(g+1)%f,d=m[g],w=m[S],P=r.vertices[g],G=r.vertices[S];if(d!==de&&l.push(P),d!==Ge&&c.push(d!==de?_e(P):P),(d|w)===Xe){let C=G.x-P.x,E=G.y-P.y,V=G.z-P.z,I=t*C+e*E+n*V,B=Math.abs(I)>1e-12?(s-(t*P.x+e*P.y+n*P.z))/I:.5,_=dn(P,G,Math.max(0,Math.min(1,B)));l.push(_),c.push(_e(_))}}let{nx:x,ny:p,nz:b,w:y}=r;l.length>=3&&u.push({vertices:l,nx:x,ny:p,nz:b,w:y}),c.length>=3&&h.push({vertices:c,nx:x,ny:p,nz:b,w:y});break}default:break}}class ye{constructor(e,n=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,n)}invert(){for(let n=0;n<this.polygons.length;n++)Sn(this.polygons[n]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,n=0){if(!this.hasPlane||e.length===0)return e.slice();if(n>=oe)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${oe})`);let s=[],r=[];for(let i=0;i<e.length;i++)De(this.nx,this.ny,this.nz,this.w,e[i],s,r,s,r);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,n+1)),this.back?r=r.length>0?this.back.clipPolygons(r,n+1):[]:r=[],s.concat(r)}clipTo(e,n=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),n<oe&&(this.front&&this.front.clipTo(e,n+1),this.back&&this.back.clipTo(e,n+1))}allPolygons(e=[]){for(let n=0;n<this.polygons.length;n++)e.push(this.polygons[n]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,n=0){if(!e.length)return;if(!this.hasPlane){let i=e[e.length>>1];this.nx=i.nx,this.ny=i.ny,this.nz=i.nz,this.w=i.w,this.hasPlane=!0}if(n>=oe)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${oe})`);let s=[],r=[];for(let i=0;i<e.length;i++)De(this.nx,this.ny,this.nz,this.w,e[i],this.polygons,this.polygons,s,r);s.length>0&&(this.front||(this.front=new ye),this.front.build(s,n+1)),r.length>0&&(this.back||(this.back=new ye),this.back.build(r,n+1))}}function Oe(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let n=t.attributes.position;if(!n||n.count===0)return[];let s=t.attributes.normal,r=t.attributes.uv,i=t.index?t.index.array:null,a=Math.floor(i?i.length/3:n.count/3);if(a>me)throw new RangeError(`SecurityError: CSG input triangle count (${a}) exceeds MAX_CSG_TRIANGLES (${me})`);let u=e?e.elements:null,h=u?u[0]*(u[5]*u[10]-u[9]*u[6])-u[4]*(u[1]*u[10]-u[9]*u[2])+u[8]*(u[1]*u[6]-u[5]*u[2])<0:!1,o=u?new hn().getNormalMatrix(e).elements:null,m=c=>{let f=n.getX(c),x=n.getY(c),p=n.getZ(c),b=s?s.getX(c):NaN,y=s?s.getY(c):NaN,g=s?s.getZ(c):NaN;if(u&&o){let w=u[0]*f+u[4]*x+u[8]*p+u[12],P=u[1]*f+u[5]*x+u[9]*p+u[13],G=u[2]*f+u[6]*x+u[10]*p+u[14];f=w,x=P,p=G;let C=o[0]*b+o[3]*y+o[6]*g,E=o[1]*b+o[4]*y+o[7]*g,V=o[2]*b+o[5]*y+o[8]*g,I=Math.hypot(C,E,V)||1;b=C/I,y=E/I,g=V/I}let S=r?r.getX(c):0,d=r?r.getY(c):0;return{x:f,y:x,z:p,nx:b,ny:y,nz:g,u:S,v:d}},l=[];for(let c=0;c<a;c++){let f=i?i[c*3]:c*3,x=i?i[c*3+1]:c*3+1,p=i?i[c*3+2]:c*3+2,b=vn(h?[m(f),m(p),m(x)]:[m(f),m(x),m(p)]);b&&l.push(b)}return l}function Pn(t){let e=[],n=[],s=[],r=[];for(let a of t){let u=a.vertices;if(u.length<3)continue;let h=e.length/3;for(let o of u)e.push(o.x,o.y,o.z),Number.isFinite(o.nx)&&o.nx*o.nx+o.ny*o.ny+o.nz*o.nz>.5?n.push(o.nx,o.ny,o.nz):n.push(a.nx,a.ny,a.nz),s.push(o.u,o.v);for(let o=1;o<u.length-1;o++)r.push(h,h+o,h+o+1)}let i=new se;return i.setAttribute("position",new D(O(e),3)),i.setAttribute("normal",new D(O(n),3)),i.setAttribute("uv",new D(O(s),2)),i.setIndex(r),i._csgPolygons=t,i}function Mn(t,e,n){if(t.length+e.length>me)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${me})`);if(t.length===0)return n==="union"?e:[];if(e.length===0)return n==="intersect"?[]:t;let s=1/0,r=1/0,i=1/0,a=-1/0,u=-1/0,h=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let p=0;p<x.length;p++){let b=x[p];b.x<s&&(s=b.x),b.y<r&&(r=b.y),b.z<i&&(i=b.z),b.x>a&&(a=b.x),b.y>u&&(u=b.y),b.z>h&&(h=b.z)}}s-=1e-4,r-=1e-4,i-=1e-4,a+=1e-4,u+=1e-4,h+=1e-4;let o=[],m=[];for(let f=0;f<t.length;f++){let x=t[f],p=x.vertices,b=1/0,y=1/0,g=1/0,S=-1/0,d=-1/0,w=-1/0;for(let P=0;P<p.length;P++){let G=p[P];G.x<b&&(b=G.x),G.y<y&&(y=G.y),G.z<g&&(g=G.z),G.x>S&&(S=G.x),G.y>d&&(d=G.y),G.z>w&&(w=G.z)}S<s||b>a||d<r||y>u||w<i||g>h?m.push(x):o.push(x)}if(o.length===0)return n==="union"?t.concat(e):n==="subtract"?t:[];let l=new ye(o),c=new ye(e);return n==="union"?(l.clipTo(c),c.clipTo(l),c.invert(),c.clipTo(l),c.invert(),l.build(c.allPolygons()),m.concat(l.allPolygons())):n==="subtract"?(l.invert(),l.clipTo(c),c.clipTo(l),c.invert(),c.clipTo(l),c.invert(),l.build(c.allPolygons()),l.invert(),m.concat(l.allPolygons())):(l.invert(),c.clipTo(l),c.invert(),l.clipTo(c),c.clipTo(l),l.build(c.allPolygons()),l.invert(),l.allPolygons())}function Be(t,e,n,s=null,r=null){let i=Oe(t,s),a=Oe(e,r);return Pn(Mn(i,a,n))}function ke(t,e,n){let s=t instanceof xe||!!t?.isMesh,r=e instanceof xe||!!e?.isMesh,i=s?t.geometry:t,a=r?e.geometry:e,u=null;if(r)if(e.updateMatrix(),s){t.updateMatrix();let l=new Me().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),c=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new Me().compose(new he(0,0,0),new ne(-t.quaternion.x/c,-t.quaternion.y/c,-t.quaternion.z/c,t.quaternion.w/c),new he(1,1,1)),x=new Me().makeTranslation(-t.position.x,-t.position.y,-t.position.z);u=l.multiply(f).multiply(x).multiply(e.matrix)}else u=e.matrix;let h=Be(i,a,n,null,u),o=s?t.material:new Ee,m=new xe(h,o);return s&&(m.position.copy(t.position),m.quaternion.copy(t.quaternion),m.scale.copy(t.scale),m.name=t.name),m}let ve={toGeometry:Be,subtract(t,e){return ke(t,e,"subtract")},union(t,e){return ke(t,e,"union")},intersect(t,e){return ke(t,e,"intersect")}},Ye={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class He extends se{constructor(e="",n={}){super();let s=String(e??"").slice(0,Re),r=Math.max(.005,Math.min(100,Y(n.size,.2))),i=!!(n.bevelEnabled??!1),a=i?Math.max(0,Math.min(2,Y(n.bevelThickness,r*.04))):0,u=i?Math.max(0,Math.min(2,Y(n.bevelSize,r*.03))):0,h=Math.max(.001,Math.min(20,Y(n.depth??n.height,r*.2)))+a*2,o=r*.085+u,m=r*.68,l=r*.82,c=[],f=[],x=[],p=[],b=(S,d,w,P,G,C,E)=>{let V=w-S,I=P-d,B=Math.hypot(V,I),_=1,H=0;B>1e-6&&(_=V/B,H=I/B);let re=-H*G,ie=_*G,j=_*G*.6,$=H*G*.6,N=S-j+re,F=d-$+ie,v=S-j-re,k=d-$-ie,T=w+j-re,R=P+$-ie,z=w+j+re,X=P+$+ie,q=(Z,U,Q,K,J,ee,te)=>{let W=c.length/3;c.push(Z[0],Z[1],Z[2],U[0],U[1],U[2],Q[0],Q[1],Q[2],K[0],K[1],K[2]),f.push(J,ee,te,J,ee,te,J,ee,te,J,ee,te),x.push(0,0,1,0,1,1,0,1),p.push(W,W+1,W+2,W,W+2,W+3)};q([N,F,E],[v,k,E],[T,R,E],[z,X,E],0,0,1),q([v,k,C],[N,F,C],[z,X,C],[T,R,C],0,0,-1),q([N,F,C],[v,k,C],[v,k,E],[N,F,E],-_,-H,0),q([T,R,C],[z,X,C],[z,X,E],[T,R,E],_,H,0),q([v,k,C],[T,R,C],[T,R,E],[v,k,E],H,-_,0),q([z,X,C],[N,F,C],[N,F,E],[z,X,E],-H,_,0)},y=0,g=0;for(let S=0;S<s.length;S++){let d=s[S];if(d===`
|
|
18
|
-
`){y=0,g-=r*1.35;continue}if(d===" "||d===" "){y+=l*(d===" "?.75:3);continue}if(d==="\r")continue;let w=d.toUpperCase(),P=d!==w&&d>="a"&&d<="z",G=Ye[w]??Ye["?"],C=P?r*.76:r,E=P?m*.88:m;for(let V of G)for(let I=0;I<V.length-1;I++){let B=V[I],_=V[I+1];b(y+B[0]*E,g+B[1]*C,y+_[0]*E,g+_[1]*C,o,-h*.5,h*.5)}y+=P?l*.88:l}this.setAttribute("position",new D(O(c),3)),this.setAttribute("normal",new D(O(f),3)),this.setAttribute("uv",new D(O(x),2)),this.setIndex(p),n.center!==!1?this.center():this.computeBoundingBox()}}function Fe(t){if(!t)return;let e=t,n=t.userData?.xr?.text;if(n!=null&&n!==!1){let r=e.geometry?.attributes?.position;if((!r||r.count===0)&&t.userData._textApplied!==!0){let i="",a=.08,u=.015,h;if(typeof n=="string"||typeof n=="number")i=String(n);else if(typeof n=="object"){let o=n;i=String(o.text??o.value??""),o.size!==void 0&&(a=Number(o.size)||.08),(o.depth!==void 0||o.height!==void 0)&&(u=Number(o.depth??o.height)||a*.2),(typeof o.color=="string"||typeof o.color=="number")&&(h=o.color)}i.trim().length>0&&(e.geometry=new He(i,{size:a,depth:u}),t.userData._textApplied=!0,e.material instanceof yn?h!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new mn(h),t.userData._autoTextColorApplied=!0):e.material=new Ee({color:h??16317180}))}}let s=t.userData?.csg;if(s&&typeof s=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof se&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let r=Array.isArray(s)?s:[s],i=e.geometry;for(let a of r){if(!a||typeof a!="object")continue;let u=a,h=String(u.op??u.operation??"subtract"),o=h==="union"||h==="intersect"?h:"subtract",m=u.target??u.mesh??u.geometry;if(m instanceof xe||m instanceof se)try{let l=o==="union"?ve.union(e,m):o==="intersect"?ve.intersect(e,m):ve.subtract(e,m);e.geometry!==i&&e.geometry.dispose?.(),e.geometry=l.geometry}catch(l){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",l)}}}}let qe={Path:be,Shape:pe,ShapeGeometry:xn,ExtrudeGeometry:pn,TextGeometry:He,CSG:ve,MAX_CSG_TRIANGLES:me,MAX_BSP_DEPTH:oe,MAX_TEXT_GEOMETRY_CHARS:Re,MAX_SHAPE_POINTS:we,materializeDeclarativeGeometry:Fe};return L&&typeof L=="object"&&(L.authorNamespace||(L.authorNamespace={}),Object.assign(L.authorNamespace,qe),L.materializeDeclarativeGeometry=Fe),qe}var Le={name:"cad",onRegister(){on(Pe);let M=fe(),L=M.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);L&&Pe(L,M)}};rn(Le);return Rn(zn);})();
|
|
16
|
+
*/var ThreeLiveCAD=(()=>{var Me=Object.defineProperty,it=Object.getOwnPropertyDescriptor,lt=Object.getOwnPropertyNames,ot=Object.prototype.hasOwnProperty,ht=(z,N)=>{for(var X in N)Me(z,X,{get:N[X],enumerable:!0})},at=(z,N,X,ae)=>{if(N&&typeof N=="object"||typeof N=="function")for(let K of lt(N))!ot.call(z,K)&&K!==X&&Me(z,K,{get:()=>N[K],enumerable:!(ae=it(N,K))||ae.enumerable});return z},ut=z=>at(Me({},"__esModule",{value:!0}),z),Ae={};ht(Ae,{MAX_BSP_DEPTH:()=>ft,MAX_CSG_TRIANGLES:()=>yt,MAX_SHAPE_POINTS:()=>gt,MAX_TEXT_GEOMETRY_CHARS:()=>xt,cadPlugin:()=>Ee,installCadExtension:()=>Pe});var pe="__THREE_LIVE_REGISTRY__";function ye(){let z=typeof globalThis<"u"?globalThis:{};if(!z[pe]){let N={plugins:[],decoders:new Map};try{Object.defineProperty(z,pe,{value:N,writable:!1,configurable:!1,enumerable:!1})}catch{z[pe]=N}}return z[pe]}var Gt=ye().plugins;function ct(z){let N=ye();N.workerExtensionInstallers||(N.workerExtensionInstallers=[]),N.workerExtensionInstallers.includes(z)||N.workerExtensionInstallers.push(z)}function pt(z){let N=ye().plugins;N.some(X=>X.name===z.name)||N.push(z),z.onRegister?.()}var yt=8192,ft=2048,xt=128,gt=4096;function Pe(z,N){if(!z||!z.BufferGeometry)return null;let X=z.Vector2,ae=z.Vector3,K=z.Quaternion,ze=z.Matrix4,mt=z.Matrix3,bt=z.Color,we=z.BufferAttribute,te=z.BufferGeometry,dt=z.Material,ke=z.MeshStandardMaterial,fe=z.Mesh,ue=8192,ne=2048,Ge=128,Se=4096,B=(t,e)=>{let n=t==null?NaN:Number(t);return Number.isFinite(n)?n:e};class xe{constructor(e){this.currentPoint=new X(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){let r=Number(e)||0,i=Number(n)||0;return this.currentPoint.set(r,i),this.segments.push({type:"move",pts:[r,i]}),this}lineTo(e,n){let r=Number(e)||0,i=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(r,i),this.segments.push({type:"line",pts:[r,i]}),this}quadraticCurveTo(e,n,r,i){let h=this.currentPoint.x,o=this.currentPoint.y,a=Number(e)||0,u=Number(n)||0,s=Number(r)||0,p=Number(i)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[h,o]}),this.currentPoint.set(s,p),this.segments.push({type:"quad",pts:[h,o,a,u,s,p]}),this}bezierCurveTo(e,n,r,i,h,o){let a=this.currentPoint.x,u=this.currentPoint.y,s=Number(e)||0,p=Number(n)||0,c=Number(r)||0,l=Number(i)||0,f=Number(h)||0,x=Number(o)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,u]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[a,u,s,p,c,l,f,x]}),this}absarc(e,n,r,i,h,o=!1){return this.absellipse(e,n,r,r,i,h,o,0)}arc(e,n,r,i,h,o=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),r,i,h,o)}absellipse(e,n,r,i,h,o,a=!1,u=0){let s=Number(e)||0,p=Number(n)||0,c=Math.max(0,Number(r)||0),l=Math.max(0,Number(i)||0),f=Number(h)||0,x=Number(o)||0,m=a?1:0,y=Number(u)||0;this.segments.push({type:"arc",pts:[s,p,c,l,f,x,m,y]});let g=Math.cos(y),b=Math.sin(y),M=c*Math.cos(x),d=l*Math.sin(x);return this.currentPoint.set(s+M*g-d*b,p+M*b+d*g),this}ellipse(e,n,r,i,h,o,a=!1,u=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),r,i,h,o,a,u)}closePath(){if(this.segments.length>0){let e=this.segments[0],n=0,r=0;if(e.type==="arc"){let i=e.pts[0],h=e.pts[1],o=e.pts[2],a=e.pts[3],u=e.pts[4],s=e.pts[7],p=Math.cos(s),c=Math.sin(s),l=o*Math.cos(u),f=a*Math.sin(u);n=i+l*p-f*c,r=h+l*c+f*p}else n=e.pts[0],r=e.pts[1];Math.hypot(this.currentPoint.x-n,this.currentPoint.y-r)>1e-6&&this.lineTo(n,r)}return this}getPoints(e=12){let n=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),r=[],i=(h,o)=>{if(r.length>0){let a=r[r.length-1];if(Math.hypot(a.x-h,a.y-o)<1e-6)return}r.push(new X(h,o))};for(let h of this.segments){let o=h.pts;if(h.type==="move"||h.type==="line")i(o[0],o[1]);else if(h.type==="quad"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5];i(a,u);for(let f=1;f<=n;f++){let x=f/n,m=1-x;i(m*m*a+2*m*x*s+x*x*c,m*m*u+2*m*x*p+x*x*l)}}else if(h.type==="cubic"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5],f=o[6],x=o[7];i(a,u);for(let m=1;m<=n;m++){let y=m/n,g=1-y,b=g*g,M=y*y;i(b*g*a+3*b*y*s+3*g*M*c+M*y*f,b*g*u+3*b*y*p+3*g*M*l+M*y*x)}}else if(h.type==="arc"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5],f=o[6]!==0,x=o[7],m=Math.PI*2,y=l-c,g=Math.abs(y)<1e-9;for(;y<0;)y+=m;for(;y>m;)y-=m;y<1e-9&&(y=g?0:m),f&&!g&&(y=y===m?-m:y-m);let b=Math.cos(x),M=Math.sin(x),d=Math.max(2,n);for(let _=0;_<=d;_++){let P=_/d,S=c+P*y,T=s*Math.cos(S),A=p*Math.sin(S);i(a+T*b-A*M,u+T*M+A*b)}}}if(r.length>2){let h=r[0],o=r[r.length-1];Math.hypot(h.x-o.x,h.y-o.y)<1e-6&&r.pop()}return r}getSpacedPoints(e=12){return this.getPoints(e)}clone(){let e=new this.constructor;return e.currentPoint.copy(this.currentPoint),e.segments=this.segments.map(n=>({type:n.type,pts:[...n.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(n=>n.clone())),e}}class ge extends xe{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(n=>n.getPoints(e))}}}function me(t){let e=0,n=t.length;for(let r=0,i=n-1;r<n;i=r++)e+=t[i].x*t[r].y-t[r].x*t[i].y;return e*.5}function vt(t,e,n,r,i,h,o,a){let u=o-n,s=a-r,p=i-n,c=h-r,l=t-n,f=e-r,x=u*u+s*s,m=u*p+s*c,y=u*l+s*f,g=p*p+c*c,b=p*l+c*f,M=x*g-m*m;if(Math.abs(M)<1e-12)return!1;let d=1/M,_=(g*y-m*b)*d,P=(x*b-m*y)*d;return _>=-1e-7&&P>=-1e-7&&_+P<=1.0000001}function Ce(t,e){let n=t.slice();me(n)<0&&n.reverse();let r=n.map(u=>new X(u.x,u.y)),i=n.map((u,s)=>s),h=[];for(let u of e){if(!u||u.length<3)continue;let s=u.slice();me(s)>0&&s.reverse();let p=[],c=-1/0,l=0;for(let f=0;f<s.length;f++){let x=s[f],m=r.length;r.push(new X(x.x,x.y)),p.push(m),x.x>c&&(c=x.x,l=f)}h.push({pts:s,indices:p,maxX:c,maxIdx:l})}h.sort((u,s)=>s.maxX-u.maxX);let o=(u,s,p)=>(s.x-u.x)*(p.y-u.y)-(s.y-u.y)*(p.x-u.x),a=(u,s,p)=>{for(let c=0;c<p.length;c++){let l=p[c],f=p[(c+1)%p.length];if(o(u,s,l)*o(u,s,f)<0&&o(l,f,u)*o(l,f,s)<0)return!0}return!1};for(let u of h){let s=u.pts[u.maxIdx],p=s.x,c=i.length,l=i.map(g=>r[g]),f=g=>Math.hypot(l[g].x-p,l[g].y-s.y),x=l.map((g,b)=>b).sort((g,b)=>+(l[g].x<p)-+(l[b].x<p)||f(g)-f(b)),m=x[0];for(let g of x){let b=l[g],M=l[(g+c-1)%c],d=l[(g+1)%c],_=o(b,d,s)>=0,P=o(M,b,s)>=0;if((o(M,b,d)>=0?_&&P:_||P)&&!a(s,b,l)&&!h.some(S=>a(s,b,S.pts))){m=g;break}}let y=[];for(let g=0;g<=m;g++)y.push(i[g]);for(let g=0;g<=u.indices.length;g++){let b=u.indices[(u.maxIdx+g)%u.indices.length];y.push(b)}for(let g=m;g<i.length;g++)y.push(i[g]);i=y}return{merged:i.map(u=>r[u]),mergedIndices:i,allVertices:r}}function Ie(t,e){let n=[],r=t.slice();if(r.length<3)return n;let i=r.length*r.length+64,h=0;for(;r.length>2&&i-- >0;){let o=r.length,a=r[(h+o-1)%o],u=r[h%o],s=r[(h+1)%o],p=e[a],c=e[u],l=e[s];if((c.x-p.x)*(l.y-p.y)-(c.y-p.y)*(l.x-p.x)>1e-9){let f=!0;for(let x=0;x<o;x++){let m=r[x];if(m===a||m===u||m===s)continue;let y=e[m];if(vt(y.x,y.y,p.x,p.y,c.x,c.y,l.x,l.y)&&Math.hypot(y.x-p.x,y.y-p.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6){f=!1;break}}if(f){n.push([a,u,s]),r.splice(h%o,1),h=Math.max(0,h%o-1);continue}}h++,h>=o*2&&(n.push([a,u,s]),r.splice((h-1)%o,1),h=0)}return n}function Re(t,e){let n=t instanceof ge?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},r=n.shape.length;for(let i of n.holes)r+=i.length;if(r>Se)throw new RangeError(`SecurityError: shape point count (${r}) exceeds MAX_SHAPE_POINTS (${Se})`);return n}class Mt extends te{constructor(e=new ge,n=12){super();let r=Array.isArray(e)?e:[e],i=[],h=[],o=[],a=[];for(let u of r){if(!(u instanceof xe))continue;let s=Re(u,n);if(s.shape.length<3)continue;let{mergedIndices:p,allVertices:c}=Ce(s.shape,s.holes),l=Ie(p,c),f=i.length/3,x=1/0,m=1/0,y=-1/0,g=-1/0;for(let d of c)d.x<x&&(x=d.x),d.y<m&&(m=d.y),d.x>y&&(y=d.x),d.y>g&&(g=d.y);let b=Math.max(1e-6,y-x),M=Math.max(1e-6,g-m);for(let d of c)i.push(d.x,d.y,0),h.push(0,0,1),o.push((d.x-x)/b,(d.y-m)/M);for(let[d,_,P]of l)a.push(f+d,f+_,f+P)}be(this,i,h,o,a)}}function be(t,e,n,r,i){return t.setAttribute("position",new we(e,3)),t.setAttribute("normal",new we(n,3)),t.setAttribute("uv",new we(r,2)),t.setIndex(i),t}function Pt(t){let e=t.length,n=[];for(let r=0;r<e;r++){let i=t[(r+e-1)%e],h=t[r],o=t[(r+1)%e],a=h.x-i.x,u=h.y-i.y,s=Math.hypot(a,u)||1;a/=s,u/=s;let p=o.x-h.x,c=o.y-h.y,l=Math.hypot(p,c)||1;p/=l,c/=l;let f=u,x=-a,m=c,y=-p,g=f+m,b=x+y,M=Math.hypot(g,b);if(M>1e-6){g/=M,b/=M;let d=Math.max(.35,g*f+b*x);n.push(new X(g/d,b/d))}else n.push(new X(f,x))}return n}class zt extends te{constructor(e=new ge,n={}){super();let r=Array.isArray(e)?e:[e],i=Math.max(1,Math.min(64,Math.floor(B(n.curveSegments,12)))),h=B(n.depth??n.amount,1),o=Math.max(1,Math.min(32,Math.floor(B(n.steps,1)))),a=!!(n.bevelEnabled??!1),u=a?Math.max(0,B(n.bevelThickness,.06)):0,s=a?Math.max(0,B(n.bevelSize,u*.8)):0,p=a?B(n.bevelOffset,0):0,c=a?Math.max(1,Math.min(8,Math.floor(B(n.bevelSegments,2)))):0,l=[],f=[],x=[],m=[];for(let y of r){if(!(y instanceof xe))continue;let g=Re(y,i);if(g.shape.length<3)continue;let b=g.shape.slice();me(b)<0&&b.reverse();let M=[];for(let v of g.holes){if(v.length<3)continue;let w=v.slice();me(w)>0&&w.reverse(),M.push(w)}let{mergedIndices:d,allVertices:_}=Ce(b,M),P=Ie(d,_),S=[b,...M],T=[];for(let v of S){let w=Pt(v);for(let E of w)T.push(E)}let A=1/0,I=1/0,C=-1/0,O=-1/0;for(let v of _)v.x<A&&(A=v.x),v.y<I&&(I=v.y),v.x>C&&(C=v.x),v.y>O&&(O=v.y);let R=Math.max(1e-6,C-A),q=Math.max(1e-6,O-I),re=-u,se=h+u,Y=l.length/3;for(let v=0;v<_.length;v++){let w=_[v],E=T[v]??new X(0,0),k=w.x+E.x*p,G=w.y+E.y*p;l.push(k,G,re),f.push(0,0,-1),x.push((k-A)/R,(G-I)/q)}for(let[v,w,E]of P)m.push(Y+v,Y+E,Y+w);let $=l.length/3;for(let v=0;v<_.length;v++){let w=_[v],E=T[v]??new X(0,0),k=w.x+E.x*p,G=w.y+E.y*p;l.push(k,G,se),f.push(0,0,1),x.push((k-A)/R,(G-I)/q)}for(let[v,w,E]of P)m.push($+v,$+w,$+E);let D=[];if(a&&c>0)for(let v=0;v<c;v++){let w=v/c*Math.PI/2;D.push({z:-u*Math.cos(w),expand:p+s*Math.sin(w)})}for(let v=0;v<=o;v++){let w=v/o;D.push({z:w*h,expand:p+s})}if(a&&c>0)for(let v=1;v<=c;v++){let w=v/c*Math.PI/2;D.push({z:h+u*Math.sin(w),expand:p+s*Math.cos(w)})}let H=0;for(let v of S){let w=v.length;for(let E=0;E<D.length-1;E++){let k=D[E],G=D[E+1];for(let L=0;L<w;L++){let j=(L+1)%w,F=v[L],J=v[j],Z=T[H+L],U=T[H+j],Q=F.x+Z.x*k.expand,W=F.y+Z.y*k.expand,ee=J.x+U.x*k.expand,V=J.y+U.y*k.expand,Et=J.x+U.x*G.expand,kt=J.y+U.y*G.expand,Fe=F.x+Z.x*G.expand,Je=F.y+Z.y*G.expand,Ze=ee-Q,Ue=V-W,Qe=0,We=Fe-Q,Ke=Je-W,et=G.z-k.z,ie=Ue*et-Qe*Ke,le=Qe*We-Ze*et,oe=Ze*Ke-Ue*We,Te=Math.hypot(ie,le,oe)||1;ie/=Te,le/=Te,oe/=Te;let he=l.length/3;l.push(Q,W,k.z,ee,V,k.z,Et,kt,G.z,Fe,Je,G.z),f.push(ie,le,oe,ie,le,oe,ie,le,oe,ie,le,oe);let tt=L/w,nt=(L+1)/w,rt=E/(D.length-1),st=(E+1)/(D.length-1);x.push(tt,rt,nt,rt,nt,st,tt,st),m.push(he,he+1,he+2,he,he+2,he+3)}}H+=w}}be(this,l,f,x,m)}}function Xe(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function wt(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function St(t,e,n){let r=t.nx+(e.nx-t.nx)*n,i=t.ny+(e.ny-t.ny)*n,h=t.nz+(e.nz-t.nz)*n,o=Math.hypot(r,i,h)||1;return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z+(e.z-t.z)*n,nx:r/o,ny:i/o,nz:h/o,u:t.u+(e.u-t.u)*n,v:t.v+(e.v-t.v)*n}}function Nt(t){if(t.length<3)return null;let e=t[0],n=t[1],r=t[2],i=n.x-e.x,h=n.y-e.y,o=n.z-e.z,a=r.x-e.x,u=r.y-e.y,s=r.z-e.z,p=h*s-o*u,c=o*a-i*s,l=i*u-h*a,f=Math.hypot(p,c,l);if(f<1e-9)return null;p/=f,c/=f,l/=f;let x=p*e.x+c*e.y+l*e.z;return{vertices:t,nx:p,ny:c,nz:l,w:x}}function _t(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=wt(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let De=1e-5,Le=0,Ne=1,de=2,Oe=3;function Be(t,e,n,r,i,h,o,a,u){let s=0,p=[];for(let c=0;c<i.vertices.length;c++){let l=i.vertices[c],f=t*l.x+e*l.y+n*l.z-r,x=f<-De?de:f>De?Ne:Le;s|=x,p.push(x)}switch(s){case Le:{t*i.nx+e*i.ny+n*i.nz>0?h.push(i):o.push(i);break}case Ne:a.push(i);break;case de:u.push(i);break;case Oe:{let c=[],l=[],f=i.vertices.length;for(let b=0;b<f;b++){let M=(b+1)%f,d=p[b],_=p[M],P=i.vertices[b],S=i.vertices[M];if(d!==de&&c.push(P),d!==Ne&&l.push(d!==de?Xe(P):P),(d|_)===Oe){let T=S.x-P.x,A=S.y-P.y,I=S.z-P.z,C=t*T+e*A+n*I,O=Math.abs(C)>1e-12?(r-(t*P.x+e*P.y+n*P.z))/C:.5,R=St(P,S,Math.max(0,Math.min(1,O)));c.push(R),l.push(Xe(R))}}let{nx:x,ny:m,nz:y,w:g}=i;c.length>=3&&a.push({vertices:c,nx:x,ny:m,nz:y,w:g}),l.length>=3&&u.push({vertices:l,nx:x,ny:m,nz:y,w:g});break}default:break}}class ce{constructor(e,n=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,n)}invert(){for(let n=0;n<this.polygons.length;n++)_t(this.polygons[n]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,n=0){if(!this.hasPlane||e.length===0)return e.slice();if(n>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let r=[],i=[];for(let h=0;h<e.length;h++)Be(this.nx,this.ny,this.nz,this.w,e[h],r,i,r,i);return this.front&&r.length>0&&(r=this.front.clipPolygons(r,n+1)),this.back?i=i.length>0?this.back.clipPolygons(i,n+1):[]:i=[],r.concat(i)}clipTo(e,n=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),n<ne&&(this.front&&this.front.clipTo(e,n+1),this.back&&this.back.clipTo(e,n+1))}allPolygons(e=[]){for(let n=0;n<this.polygons.length;n++)e.push(this.polygons[n]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,n=0){if(!e.length)return;if(!this.hasPlane){let h=e[e.length>>1];this.nx=h.nx,this.ny=h.ny,this.nz=h.nz,this.w=h.w,this.hasPlane=!0}if(n>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let r=[],i=[];for(let h=0;h<e.length;h++)Be(this.nx,this.ny,this.nz,this.w,e[h],this.polygons,this.polygons,r,i);r.length>0&&(this.front||(this.front=new ce),this.front.build(r,n+1)),i.length>0&&(this.back||(this.back=new ce),this.back.build(i,n+1))}}function qe(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let n=t.attributes.position;if(!n||n.count===0)return[];let r=t.attributes.normal,i=t.attributes.uv,h=t.index?t.index.array:null,o=Math.floor(h?h.length/3:n.count/3);if(o>ue)throw new RangeError(`SecurityError: CSG input triangle count (${o}) exceeds MAX_CSG_TRIANGLES (${ue})`);let a=e?e.elements:null,u=a?a[0]*(a[5]*a[10]-a[9]*a[6])-a[4]*(a[1]*a[10]-a[9]*a[2])+a[8]*(a[1]*a[6]-a[5]*a[2])<0:!1,s=a?new mt().getNormalMatrix(e).elements:null,p=l=>{let f=n.getX(l),x=n.getY(l),m=n.getZ(l),y=r?r.getX(l):NaN,g=r?r.getY(l):NaN,b=r?r.getZ(l):NaN;if(a&&s){let _=a[0]*f+a[4]*x+a[8]*m+a[12],P=a[1]*f+a[5]*x+a[9]*m+a[13],S=a[2]*f+a[6]*x+a[10]*m+a[14];f=_,x=P,m=S;let T=s[0]*y+s[3]*g+s[6]*b,A=s[1]*y+s[4]*g+s[7]*b,I=s[2]*y+s[5]*g+s[8]*b,C=Math.hypot(T,A,I)||1;y=T/C,g=A/C,b=I/C}let M=i?i.getX(l):0,d=i?i.getY(l):0;return{x:f,y:x,z:m,nx:y,ny:g,nz:b,u:M,v:d}},c=[];for(let l=0;l<o;l++){let f=h?h[l*3]:l*3,x=h?h[l*3+1]:l*3+1,m=h?h[l*3+2]:l*3+2,y=Nt(u?[p(f),p(m),p(x)]:[p(f),p(x),p(m)]);y&&c.push(y)}return c}function Tt(t){let e=[],n=[],r=[],i=[];for(let o of t){let a=o.vertices;if(a.length<3)continue;let u=e.length/3;for(let s of a)e.push(s.x,s.y,s.z),Number.isFinite(s.nx)&&s.nx*s.nx+s.ny*s.ny+s.nz*s.nz>.5?n.push(s.nx,s.ny,s.nz):n.push(o.nx,o.ny,o.nz),r.push(s.u,s.v);for(let s=1;s<a.length-1;s++)i.push(u,u+s,u+s+1)}let h=be(new te,e,n,r,i);return h._csgPolygons=t,h}function At(t,e,n){if(t.length+e.length>ue)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${ue})`);if(t.length===0)return n==="union"?e:[];if(e.length===0)return n==="intersect"?[]:t;let r=1/0,i=1/0,h=1/0,o=-1/0,a=-1/0,u=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let m=0;m<x.length;m++){let y=x[m];y.x<r&&(r=y.x),y.y<i&&(i=y.y),y.z<h&&(h=y.z),y.x>o&&(o=y.x),y.y>a&&(a=y.y),y.z>u&&(u=y.z)}}r-=1e-4,i-=1e-4,h-=1e-4,o+=1e-4,a+=1e-4,u+=1e-4;let s=[],p=[];for(let f=0;f<t.length;f++){let x=t[f],m=x.vertices,y=1/0,g=1/0,b=1/0,M=-1/0,d=-1/0,_=-1/0;for(let P=0;P<m.length;P++){let S=m[P];S.x<y&&(y=S.x),S.y<g&&(g=S.y),S.z<b&&(b=S.z),S.x>M&&(M=S.x),S.y>d&&(d=S.y),S.z>_&&(_=S.z)}M<r||y>o||d<i||g>a||_<h||b>u?p.push(x):s.push(x)}if(s.length===0)return n==="union"?t.concat(e):n==="subtract"?t:[];let c=new ce(s),l=new ce(e);return n==="union"?(c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),p.concat(c.allPolygons())):n==="subtract"?(c.invert(),c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),c.invert(),p.concat(c.allPolygons())):(c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.build(l.allPolygons()),c.invert(),c.allPolygons())}function He(t,e,n,r=null,i=null){let h=qe(t,r),o=qe(e,i);return Tt(At(h,o,n))}function _e(t,e,n){let r=t instanceof fe||!!t?.isMesh,i=e instanceof fe||!!e?.isMesh,h=r?t.geometry:t,o=i?e.geometry:e,a=null;if(i)if(e.updateMatrix(),r){t.updateMatrix();let c=new ze().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),l=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new ze().compose(new ae(0,0,0),new K(-t.quaternion.x/l,-t.quaternion.y/l,-t.quaternion.z/l,t.quaternion.w/l),new ae(1,1,1)),x=new ze().makeTranslation(-t.position.x,-t.position.y,-t.position.z);a=c.multiply(f).multiply(x).multiply(e.matrix)}else a=e.matrix;let u=He(h,o,n,null,a),s=r?t.material:new ke,p=new fe(u,s);return r&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let ve={toGeometry:He,subtract(t,e){return _e(t,e,"subtract")},union(t,e){return _e(t,e,"union")},intersect(t,e){return _e(t,e,"intersect")}},je={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class Ve extends te{constructor(e="",n={}){super();let r=String(e??"").slice(0,Ge),i=Math.max(.005,Math.min(100,B(n.size,.2))),h=!!(n.bevelEnabled??!1),o=h?Math.max(0,Math.min(2,B(n.bevelThickness,i*.04))):0,a=h?Math.max(0,Math.min(2,B(n.bevelSize,i*.03))):0,u=Math.max(.001,Math.min(20,B(n.depth??n.height,i*.2)))+o*2,s=i*.085+a,p=i*.68,c=i*.82,l=[],f=[],x=[],m=[],y=(M,d,_,P,S,T,A)=>{let I=_-M,C=P-d,O=Math.hypot(I,C),R=1,q=0;O>1e-6&&(R=I/O,q=C/O);let re=-q*S,se=R*S,Y=R*S*.6,$=q*S*.6,D=M-Y+re,H=d-$+se,v=M-Y-re,w=d-$-se,E=_+Y-re,k=P+$-se,G=_+Y+re,L=P+$+se,j=(F,J,Z,U,Q,W,ee)=>{let V=l.length/3;l.push(F[0],F[1],F[2],J[0],J[1],J[2],Z[0],Z[1],Z[2],U[0],U[1],U[2]),f.push(Q,W,ee,Q,W,ee,Q,W,ee,Q,W,ee),x.push(0,0,1,0,1,1,0,1),m.push(V,V+1,V+2,V,V+2,V+3)};j([D,H,A],[v,w,A],[E,k,A],[G,L,A],0,0,1),j([v,w,T],[D,H,T],[G,L,T],[E,k,T],0,0,-1),j([D,H,T],[v,w,T],[v,w,A],[D,H,A],-R,-q,0),j([E,k,T],[G,L,T],[G,L,A],[E,k,A],R,q,0),j([v,w,T],[E,k,T],[E,k,A],[v,w,A],q,-R,0),j([G,L,T],[D,H,T],[D,H,A],[G,L,A],-q,R,0)},g=0,b=0;for(let M=0;M<r.length;M++){let d=r[M];if(d===`
|
|
17
|
+
`){g=0,b-=i*1.35;continue}if(d===" "||d===" "){g+=c*(d===" "?.75:3);continue}if(d==="\r")continue;let _=d.toUpperCase(),P=d!==_&&d>="a"&&d<="z",S=je[_]??je["?"],T=P?i*.76:i,A=P?p*.88:p;for(let I of S)for(let C=0;C<I.length-1;C++){let O=I[C],R=I[C+1];y(g+O[0]*A,b+O[1]*T,g+R[0]*A,b+R[1]*T,s,-u*.5,u*.5)}g+=P?c*.88:c}be(this,l,f,x,m),n.center!==!1?this.center():this.computeBoundingBox()}}function Ye(t){if(!t)return;let e=t,n=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(n!=null&&n!==!1){let i=e.geometry?.attributes?.position;if((!i||i.count===0)&&t.userData._textApplied!==!0){let h="",o=.08,a=.015,u;if(typeof n=="string"||typeof n=="number")h=String(n);else if(typeof n=="object"){let s=n;h=String(s.text??s.value??""),s.size!==void 0&&(o=Number(s.size)||.08),(s.depth!==void 0||s.height!==void 0)&&(a=Number(s.depth??s.height)||o*.2),(typeof s.color=="string"||typeof s.color=="number")&&(u=s.color)}h.trim().length>0&&(e.geometry=new Ve(h,{size:o,depth:a}),t.userData._textApplied=!0,e.material instanceof dt?u!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new bt(u),t.userData._autoTextColorApplied=!0):e.material=new ke({color:u??16317180}))}}let r=t.userData?.csg;if(r&&typeof r=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof te&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let i=Array.isArray(r)?r:[r],h=e.geometry;for(let o of i){if(!o||typeof o!="object")continue;let a=o,u=String(a.op??a.operation??"subtract"),s=u==="union"||u==="intersect"?u:"subtract",p=a.target??a.mesh??a.geometry;if(p instanceof fe||p instanceof te)try{let c=s==="union"?ve.union(e,p):s==="intersect"?ve.intersect(e,p):ve.subtract(e,p);e.geometry!==h&&e.geometry.dispose?.(),e.geometry=c.geometry}catch(c){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",c)}}}}let $e={Path:xe,Shape:ge,ShapeGeometry:Mt,ExtrudeGeometry:zt,TextGeometry:Ve,CSG:ve,MAX_CSG_TRIANGLES:ue,MAX_BSP_DEPTH:ne,MAX_TEXT_GEOMETRY_CHARS:Ge,MAX_SHAPE_POINTS:Se,materializeDeclarativeGeometry:Ye};return N&&typeof N=="object"&&(N.authorNamespace||(N.authorNamespace={}),Object.assign(N.authorNamespace,$e),N._cadMaterialize=Ye,N.materializeDeclarativeGeometry=t=>{N._cadMaterialize?.(t),N._lodMaterialize?.(t)}),$e}var Ee={name:"cad",onRegister(){ct(Pe);let z=ye(),N=z.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);N&&Pe(N,z)}};return pt(Ee),ut(Ae)})();
|