three-live 1.3.0 → 1.3.2
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 +1 -1
- package/dist/index.d.ts +37 -0
- package/dist/three-author-engine.js +112 -61
- package/dist/three-author.cjs +110 -59
- package/dist/three-author.d.ts +37 -0
- package/dist/three-author.js +109 -58
- package/dist/three-convert.cjs +106 -59
- package/dist/three-convert.d.ts +37 -0
- package/dist/three-convert.js +105 -58
- package/dist/three-live-animation.cjs +8 -9
- package/dist/three-live-animation.d.ts +37 -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 +37 -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 +17 -20
- package/dist/three-live-element.d.ts +37 -0
- package/dist/three-live-element.js +16 -19
- package/dist/three-live-full.cjs +138 -87
- package/dist/three-live-full.js +137 -86
- package/dist/three-live-full.min.js +138 -87
- package/dist/three-live-studio.cjs +19 -20
- package/dist/three-live-studio.d.ts +37 -0
- package/dist/three-live-studio.js +18 -19
- package/dist/three-live-studio.min.js +18 -19
- package/dist/three-live-viewer.cjs +17 -20
- package/dist/three-live-viewer.d.ts +37 -0
- package/dist/three-live-viewer.js +16 -19
- package/dist/three-live-viewer.min.js +17 -20
- package/dist/three-live.cjs +115 -64
- package/dist/three-live.js +113 -62
- package/dist/three-live.min.js +115 -64
- package/dist/three-view.cjs +17 -20
- package/dist/three-view.d.ts +37 -0
- package/dist/three-view.js +16 -19
- package/dist/three-xr.cjs +105 -58
- package/dist/three-xr.d.ts +37 -0
- package/dist/three-xr.js +104 -57
- package/package.json +25 -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,ue)=>{if(L&&typeof L=="object"||typeof L=="function")for(let J of Cn(L))!Tn.call(M,J)&&J!==A&&Te(M,J,{get:()=>L[J],enumerable:!(ue=kn(L,J))||ue.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:()=>Se});module.exports=Rn(zn);var ve="__THREE_LIVE_REGISTRY__";function me(){let M=typeof globalThis<"u"?globalThis:{};if(!M[ve]){let L={plugins:[],decoders:new Map};try{Object.defineProperty(M,ve,{value:L,writable:!1,configurable:!1,enumerable:!1})}catch{M[ve]=L}}return M[ve]}var _n=me().plugins;function on(M){let L=me();L.workerExtensionInstallers||(L.workerExtensionInstallers=[]),L.workerExtensionInstallers.includes(M)||L.workerExtensionInstallers.push(M)}function rn(M){let L=me().plugins;L.some(A=>A.name===M.name)||L.push(M),M.onRegister?.()}var cn=8192,an=2048,un=128,ln=4096;function Se(M,L){if(!M||!M.BufferGeometry)return null;let A=M.Vector2,ue=M.Vector3,J=M.Quaternion,Pe=M.Matrix4,hn=M.Matrix3,mn=M.Color,Me=M.BufferAttribute,ne=M.BufferGeometry,yn=M.Material,Ee=M.MeshStandardMaterial,ye=M.Mesh,le=8192,te=2048,Re=128,we=4096,D=(n,e)=>{let t=n==null?NaN:Number(n);return Number.isFinite(t)?t:e};class fe{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 t=1;t<e.length;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){let s=Number(e)||0,r=Number(t)||0;return this.currentPoint.set(s,r),this.segments.push({type:"move",pts:[s,r]}),this}lineTo(e,t){let s=Number(e)||0,r=Number(t)||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,t,s,r){let a=this.currentPoint.x,c=this.currentPoint.y,u=Number(e)||0,l=Number(t)||0,o=Number(s)||0,m=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,c]}),this.currentPoint.set(o,m),this.segments.push({type:"quad",pts:[a,c,u,l,o,m]}),this}bezierCurveTo(e,t,s,r,a,c){let u=this.currentPoint.x,l=this.currentPoint.y,o=Number(e)||0,m=Number(t)||0,h=Number(s)||0,i=Number(r)||0,f=Number(a)||0,x=Number(c)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,l]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[u,l,o,m,h,i,f,x]}),this}absarc(e,t,s,r,a,c=!1){return this.absellipse(e,t,s,s,r,a,c,0)}arc(e,t,s,r,a,c=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),s,r,a,c)}absellipse(e,t,s,r,a,c,u=!1,l=0){let o=Number(e)||0,m=Number(t)||0,h=Math.max(0,Number(s)||0),i=Math.max(0,Number(r)||0),f=Number(a)||0,x=Number(c)||0,p=u?1:0,b=Number(l)||0;this.segments.push({type:"arc",pts:[o,m,h,i,f,x,p,b]});let y=Math.cos(b),g=Math.sin(b),S=h*Math.cos(x),d=i*Math.sin(x);return this.currentPoint.set(o+S*y-d*g,m+S*g+d*y),this}ellipse(e,t,s,r,a,c,u=!1,l=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),s,r,a,c,u,l)}closePath(){if(this.segments.length>0){let e=this.segments[0],t=0,s=0;if(e.type==="arc"){let r=e.pts[0],a=e.pts[1],c=e.pts[2],u=e.pts[3],l=e.pts[4],o=e.pts[7],m=Math.cos(o),h=Math.sin(o),i=c*Math.cos(l),f=u*Math.sin(l);t=r+i*m-f*h,s=a+i*h+f*m}else t=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-t,this.currentPoint.y-s)>1e-6&&this.lineTo(t,s)}return this}getPoints(e=12){let t=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],r=(a,c)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-a,u.y-c)<1e-6)return}s.push(new A(a,c))};for(let a of this.segments){let c=a.pts;if(a.type==="move"||a.type==="line")r(c[0],c[1]);else if(a.type==="quad"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5];r(u,l);for(let f=1;f<=t;f++){let x=f/t,p=1-x;r(p*p*u+2*p*x*o+x*x*h,p*p*l+2*p*x*m+x*x*i)}}else if(a.type==="cubic"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5],f=c[6],x=c[7];r(u,l);for(let p=1;p<=t;p++){let b=p/t,y=1-b,g=y*y,S=b*b;r(g*y*u+3*g*b*o+3*y*S*h+S*b*f,g*y*l+3*g*b*m+3*y*S*i+S*b*x)}}else if(a.type==="arc"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5],f=c[6]!==0,x=c[7],p=Math.PI*2,b=i-h,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,t);for(let w=0;w<=d;w++){let P=w/d,G=h+P*b,C=o*Math.cos(G),E=m*Math.sin(G);r(u+C*g-E*S,l+C*S+E*g)}}}if(s.length>2){let a=s[0],c=s[s.length-1];Math.hypot(a.x-c.x,a.y-c.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(t=>t.getPoints(e))}}}function be(n){let e=0,t=n.length;for(let s=0,r=t-1;s<t;r=s++)e+=n[r].x*n[s].y-n[s].x*n[r].y;return e*.5}function fn(n,e,t,s,r,a,c,u){let l=c-t,o=u-s,m=r-t,h=a-s,i=n-t,f=e-s,x=l*l+o*o,p=l*m+o*h,b=l*i+o*f,y=m*m+h*h,g=m*i+h*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(n,e){let t=n.slice();be(t)<0&&t.reverse();let s=t.map(l=>new A(l.x,l.y)),r=t.map((l,o)=>o),a=[];for(let l of e){if(!l||l.length<3)continue;let o=l.slice();be(o)>0&&o.reverse();let m=[],h=-1/0,i=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>h&&(h=x.x,i=f)}a.push({pts:o,indices:m,maxX:h,maxIdx:i})}a.sort((l,o)=>o.maxX-l.maxX);let c=(l,o,m)=>(o.x-l.x)*(m.y-l.y)-(o.y-l.y)*(m.x-l.x),u=(l,o,m)=>{for(let h=0;h<m.length;h++){let i=m[h],f=m[(h+1)%m.length];if(c(l,o,i)*c(l,o,f)<0&&c(i,f,l)*c(i,f,o)<0)return!0}return!1};for(let l of a){let o=l.pts[l.maxIdx],m=o.x,h=r.length,i=r.map(y=>s[y]),f=y=>Math.hypot(i[y].x-m,i[y].y-o.y),x=i.map((y,g)=>g).sort((y,g)=>+(i[y].x<m)-+(i[g].x<m)||f(y)-f(g)),p=x[0];for(let y of x){let g=i[y],S=i[(y+h-1)%h],d=i[(y+1)%h],w=c(g,d,o)>=0,P=c(S,g,o)>=0;if((c(S,g,d)>=0?w&&P:w||P)&&!u(o,g,i)&&!a.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<=l.indices.length;y++){let g=l.indices[(l.maxIdx+y)%l.indices.length];b.push(g)}for(let y=p;y<r.length;y++)b.push(r[y]);r=b}return{merged:r.map(l=>s[l]),mergedIndices:r,allVertices:s}}function Ie(n,e){let t=[],s=n.slice();if(s.length<3)return t;let r=s.length*s.length+64,a=0;for(;s.length>2&&r-- >0;){let c=s.length,u=s[(a+c-1)%c],l=s[a%c],o=s[(a+1)%c],m=e[u],h=e[l],i=e[o];if((h.x-m.x)*(i.y-m.y)-(h.y-m.y)*(i.x-m.x)>1e-9){let x=!0;for(let p=0;p<c;p++){let b=s[p];if(b===u||b===l||b===o)continue;let y=e[b];if(fn(y.x,y.y,m.x,m.y,h.x,h.y,i.x,i.y)&&Math.hypot(y.x-m.x,y.y-m.y)>=1e-6&&Math.hypot(y.x-h.x,y.y-h.y)>=1e-6&&Math.hypot(y.x-i.x,y.y-i.y)>=1e-6){x=!1;break}}if(x){t.push([u,l,o]),s.splice(a%c,1),a=Math.max(0,a%c-1);continue}}a++,a>=c*2&&(t.push([u,l,o]),s.splice((a-1)%c,1),a=0)}return t}function _e(n,e){let t=n instanceof xe?n.extractPoints(e):{shape:n.getPoints(e),holes:[]},s=t.shape.length;for(let r of t.holes)s+=r.length;if(s>we)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${we})`);return t}class xn extends ne{constructor(e=new xe,t=12){super();let s=Array.isArray(e)?e:[e],r=[],a=[],c=[],u=[];for(let l of s){if(!(l instanceof fe))continue;let o=_e(l,t);if(o.shape.length<3)continue;let{mergedIndices:m,allVertices:h}=ze(o.shape,o.holes),i=Ie(m,h),f=r.length/3,x=1/0,p=1/0,b=-1/0,y=-1/0;for(let d of h)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 h)r.push(d.x,d.y,0),a.push(0,0,1),c.push((d.x-x)/g,(d.y-p)/S);for(let[d,w,P]of i)u.push(f+d,f+w,f+P)}pe(this,r,a,c,u)}}function pe(n,e,t,s,r){return n.setAttribute("position",new Me(e,3)),n.setAttribute("normal",new Me(t,3)),n.setAttribute("uv",new Me(s,2)),n.setIndex(r),n}function bn(n){let e=n.length,t=[];for(let s=0;s<e;s++){let r=n[(s+e-1)%e],a=n[s],c=n[(s+1)%e],u=a.x-r.x,l=a.y-r.y,o=Math.hypot(u,l)||1;u/=o,l/=o;let m=c.x-a.x,h=c.y-a.y,i=Math.hypot(m,h)||1;m/=i,h/=i;let f=l,x=-u,p=h,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);t.push(new A(y/d,g/d))}else t.push(new A(f,x))}return t}class pn extends ne{constructor(e=new xe,t={}){super();let s=Array.isArray(e)?e:[e],r=Math.max(1,Math.min(64,Math.floor(D(t.curveSegments,12)))),a=D(t.depth??t.amount,1),c=Math.max(1,Math.min(32,Math.floor(D(t.steps,1)))),u=!!(t.bevelEnabled??!1),l=u?Math.max(0,D(t.bevelThickness,.06)):0,o=u?Math.max(0,D(t.bevelSize,l*.8)):0,m=u?D(t.bevelOffset,0):0,h=u?Math.max(1,Math.min(8,Math.floor(D(t.bevelSegments,2)))):0,i=[],f=[],x=[],p=[];for(let b of s){if(!(b instanceof fe))continue;let y=_e(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 k=v.slice();be(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,_=1/0,I=-1/0,B=-1/0;for(let v of w)v.x<E&&(E=v.x),v.y<_&&(_=v.y),v.x>I&&(I=v.x),v.y>B&&(B=v.y);let V=Math.max(1e-6,I-E),O=Math.max(1e-6,B-_),se=-l,oe=a+l,j=i.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;i.push(R,z,se),f.push(0,0,-1),x.push((R-E)/V,(z-_)/O)}for(let[v,k,T]of P)p.push(j+v,j+T,j+k);let q=i.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;i.push(R,z,oe),f.push(0,0,1),x.push((R-E)/V,(z-_)/O)}for(let[v,k,T]of P)p.push(q+v,q+k,q+T);let N=[];if(u&&h>0)for(let v=0;v<h;v++){let T=v/h*Math.PI/2;N.push({z:-l*Math.cos(T),expand:m+o*Math.sin(T)})}for(let v=0;v<=c;v++){let k=v/c;N.push({z:k*a,expand:m+o})}if(u&&h>0)for(let v=1;v<=h;v++){let T=v/h*Math.PI/2;N.push({z:a+l*Math.sin(T),expand:m+o*Math.cos(T)})}let Y=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 F=(X+1)%k,W=v[X],$=v[F],U=C[Y+X],Z=C[Y+F],K=W.x+U.x*R.expand,Q=W.y+U.y*R.expand,ee=$.x+Z.x*R.expand,H=$.y+Z.y*R.expand,wn=$.x+Z.x*z.expand,Gn=$.y+Z.y*z.expand,qe=W.x+U.x*z.expand,We=W.y+U.y*z.expand,$e=ee-K,Ue=H-Q,Ze=0,Ke=qe-K,Qe=We-Q,Je=z.z-R.z,re=Ue*Je-Ze*Qe,ie=Ze*Ke-$e*Je,ce=$e*Qe-Ue*Ke,Ce=Math.hypot(re,ie,ce)||1;re/=Ce,ie/=Ce,ce/=Ce;let ae=i.length/3;i.push(K,Q,R.z,ee,H,R.z,wn,Gn,z.z,qe,We,z.z),f.push(re,ie,ce,re,ie,ce,re,ie,ce,re,ie,ce);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(ae,ae+1,ae+2,ae,ae+2,ae+3)}}Y+=k}}pe(this,i,f,x,p)}}function Ve(n){return{x:n.x,y:n.y,z:n.z,nx:n.nx,ny:n.ny,nz:n.nz,u:n.u,v:n.v}}function gn(n){return{x:n.x,y:n.y,z:n.z,nx:-n.nx,ny:-n.ny,nz:-n.nz,u:n.u,v:n.v}}function dn(n,e,t){let s=n.nx+(e.nx-n.nx)*t,r=n.ny+(e.ny-n.ny)*t,a=n.nz+(e.nz-n.nz)*t,c=Math.hypot(s,r,a)||1;return{x:n.x+(e.x-n.x)*t,y:n.y+(e.y-n.y)*t,z:n.z+(e.z-n.z)*t,nx:s/c,ny:r/c,nz:a/c,u:n.u+(e.u-n.u)*t,v:n.v+(e.v-n.v)*t}}function vn(n){if(n.length<3)return null;let e=n[0],t=n[1],s=n[2],r=t.x-e.x,a=t.y-e.y,c=t.z-e.z,u=s.x-e.x,l=s.y-e.y,o=s.z-e.z,m=a*o-c*l,h=c*u-r*o,i=r*l-a*u,f=Math.hypot(m,h,i);if(f<1e-9)return null;m/=f,h/=f,i/=f;let x=m*e.x+h*e.y+i*e.z;return{vertices:n,nx:m,ny:h,nz:i,w:x}}function Sn(n){n.vertices.reverse();for(let e=0;e<n.vertices.length;e++)n.vertices[e]=gn(n.vertices[e]);n.nx=-n.nx,n.ny=-n.ny,n.nz=-n.nz,n.w=-n.w}let Ae=1e-5,Ne=0,Ge=1,ge=2,Xe=3;function Be(n,e,t,s,r,a,c,u,l){let o=0,m=[];for(let h=0;h<r.vertices.length;h++){let i=r.vertices[h],f=n*i.x+e*i.y+t*i.z-s,x=f<-Ae?ge:f>Ae?Ge:Ne;o|=x,m.push(x)}switch(o){case Ne:{n*r.nx+e*r.ny+t*r.nz>0?a.push(r):c.push(r);break}case Ge:u.push(r);break;case ge:l.push(r);break;case Xe:{let h=[],i=[],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!==ge&&h.push(P),d!==Ge&&i.push(d!==ge?Ve(P):P),(d|w)===Xe){let C=G.x-P.x,E=G.y-P.y,_=G.z-P.z,I=n*C+e*E+t*_,B=Math.abs(I)>1e-12?(s-(n*P.x+e*P.y+t*P.z))/I:.5,V=dn(P,G,Math.max(0,Math.min(1,B)));h.push(V),i.push(Ve(V))}}let{nx:x,ny:p,nz:b,w:y}=r;h.length>=3&&u.push({vertices:h,nx:x,ny:p,nz:b,w:y}),i.length>=3&&l.push({vertices:i,nx:x,ny:p,nz:b,w:y});break}default:break}}class he{constructor(e,t=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,t)}invert(){for(let t=0;t<this.polygons.length;t++)Sn(this.polygons[t]);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,t=0){if(!this.hasPlane||e.length===0)return e.slice();if(t>=te)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${te})`);let s=[],r=[];for(let a=0;a<e.length;a++)Be(this.nx,this.ny,this.nz,this.w,e[a],s,r,s,r);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,t+1)),this.back?r=r.length>0?this.back.clipPolygons(r,t+1):[]:r=[],s.concat(r)}clipTo(e,t=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),t<te&&(this.front&&this.front.clipTo(e,t+1),this.back&&this.back.clipTo(e,t+1))}allPolygons(e=[]){for(let t=0;t<this.polygons.length;t++)e.push(this.polygons[t]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,t=0){if(!e.length)return;if(!this.hasPlane){let a=e[e.length>>1];this.nx=a.nx,this.ny=a.ny,this.nz=a.nz,this.w=a.w,this.hasPlane=!0}if(t>=te)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${te})`);let s=[],r=[];for(let a=0;a<e.length;a++)Be(this.nx,this.ny,this.nz,this.w,e[a],this.polygons,this.polygons,s,r);s.length>0&&(this.front||(this.front=new he),this.front.build(s,t+1)),r.length>0&&(this.back||(this.back=new he),this.back.build(r,t+1))}}function De(n,e){if(!e&&n._csgPolygons)return n._csgPolygons;let t=n.attributes.position;if(!t||t.count===0)return[];let s=n.attributes.normal,r=n.attributes.uv,a=n.index?n.index.array:null,c=Math.floor(a?a.length/3:t.count/3);if(c>le)throw new RangeError(`SecurityError: CSG input triangle count (${c}) exceeds MAX_CSG_TRIANGLES (${le})`);let u=e?e.elements:null,l=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=i=>{let f=t.getX(i),x=t.getY(i),p=t.getZ(i),b=s?s.getX(i):NaN,y=s?s.getY(i):NaN,g=s?s.getZ(i):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,_=o[2]*b+o[5]*y+o[8]*g,I=Math.hypot(C,E,_)||1;b=C/I,y=E/I,g=_/I}let S=r?r.getX(i):0,d=r?r.getY(i):0;return{x:f,y:x,z:p,nx:b,ny:y,nz:g,u:S,v:d}},h=[];for(let i=0;i<c;i++){let f=a?a[i*3]:i*3,x=a?a[i*3+1]:i*3+1,p=a?a[i*3+2]:i*3+2,b=vn(l?[m(f),m(p),m(x)]:[m(f),m(x),m(p)]);b&&h.push(b)}return h}function Pn(n){let e=[],t=[],s=[],r=[];for(let c of n){let u=c.vertices;if(u.length<3)continue;let l=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?t.push(o.nx,o.ny,o.nz):t.push(c.nx,c.ny,c.nz),s.push(o.u,o.v);for(let o=1;o<u.length-1;o++)r.push(l,l+o,l+o+1)}let a=pe(new ne,e,t,s,r);return a._csgPolygons=n,a}function Mn(n,e,t){if(n.length+e.length>le)throw new RangeError(`SecurityError: Combined CSG triangle count (${n.length+e.length}) exceeds MAX_CSG_TRIANGLES (${le})`);if(n.length===0)return t==="union"?e:[];if(e.length===0)return t==="intersect"?[]:n;let s=1/0,r=1/0,a=1/0,c=-1/0,u=-1/0,l=-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<a&&(a=b.z),b.x>c&&(c=b.x),b.y>u&&(u=b.y),b.z>l&&(l=b.z)}}s-=1e-4,r-=1e-4,a-=1e-4,c+=1e-4,u+=1e-4,l+=1e-4;let o=[],m=[];for(let f=0;f<n.length;f++){let x=n[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>c||d<r||y>u||w<a||g>l?m.push(x):o.push(x)}if(o.length===0)return t==="union"?n.concat(e):t==="subtract"?n:[];let h=new he(o),i=new he(e);return t==="union"?(h.clipTo(i),i.clipTo(h),i.invert(),i.clipTo(h),i.invert(),h.build(i.allPolygons()),m.concat(h.allPolygons())):t==="subtract"?(h.invert(),h.clipTo(i),i.clipTo(h),i.invert(),i.clipTo(h),i.invert(),h.build(i.allPolygons()),h.invert(),m.concat(h.allPolygons())):(h.invert(),i.clipTo(h),i.invert(),h.clipTo(i),i.clipTo(h),h.build(i.allPolygons()),h.invert(),h.allPolygons())}function Oe(n,e,t,s=null,r=null){let a=De(n,s),c=De(e,r);return Pn(Mn(a,c,t))}function ke(n,e,t){let s=n instanceof ye||!!n?.isMesh,r=e instanceof ye||!!e?.isMesh,a=s?n.geometry:n,c=r?e.geometry:e,u=null;if(r)if(e.updateMatrix(),s){n.updateMatrix();let h=new Pe().makeScale(1/(n.scale.x||1),1/(n.scale.y||1),1/(n.scale.z||1)),i=Math.hypot(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w)||1,f=new Pe().compose(new ue(0,0,0),new J(-n.quaternion.x/i,-n.quaternion.y/i,-n.quaternion.z/i,n.quaternion.w/i),new ue(1,1,1)),x=new Pe().makeTranslation(-n.position.x,-n.position.y,-n.position.z);u=h.multiply(f).multiply(x).multiply(e.matrix)}else u=e.matrix;let l=Oe(a,c,t,null,u),o=s?n.material:new Ee,m=new ye(l,o);return s&&(m.position.copy(n.position),m.quaternion.copy(n.quaternion),m.scale.copy(n.scale),m.name=n.name),m}let de={toGeometry:Oe,subtract(n,e){return ke(n,e,"subtract")},union(n,e){return ke(n,e,"union")},intersect(n,e){return ke(n,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 Fe extends ne{constructor(e="",t={}){super();let s=String(e??"").slice(0,Re),r=Math.max(.005,Math.min(100,D(t.size,.2))),a=!!(t.bevelEnabled??!1),c=a?Math.max(0,Math.min(2,D(t.bevelThickness,r*.04))):0,u=a?Math.max(0,Math.min(2,D(t.bevelSize,r*.03))):0,l=Math.max(.001,Math.min(20,D(t.depth??t.height,r*.2)))+c*2,o=r*.085+u,m=r*.68,h=r*.82,i=[],f=[],x=[],p=[],b=(S,d,w,P,G,C,E)=>{let _=w-S,I=P-d,B=Math.hypot(_,I),V=1,O=0;B>1e-6&&(V=_/B,O=I/B);let se=-O*G,oe=V*G,j=V*G*.6,q=O*G*.6,N=S-j+se,Y=d-q+oe,v=S-j-se,k=d-q-oe,T=w+j-se,R=P+q-oe,z=w+j+se,X=P+q+oe,F=(W,$,U,Z,K,Q,ee)=>{let H=i.length/3;i.push(W[0],W[1],W[2],$[0],$[1],$[2],U[0],U[1],U[2],Z[0],Z[1],Z[2]),f.push(K,Q,ee,K,Q,ee,K,Q,ee,K,Q,ee),x.push(0,0,1,0,1,1,0,1),p.push(H,H+1,H+2,H,H+2,H+3)};F([N,Y,E],[v,k,E],[T,R,E],[z,X,E],0,0,1),F([v,k,C],[N,Y,C],[z,X,C],[T,R,C],0,0,-1),F([N,Y,C],[v,k,C],[v,k,E],[N,Y,E],-V,-O,0),F([T,R,C],[z,X,C],[z,X,E],[T,R,E],V,O,0),F([v,k,C],[T,R,C],[T,R,E],[v,k,E],O,-V,0),F([z,X,C],[N,Y,C],[N,Y,E],[z,X,E],-O,V,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+=h*(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 _ of G)for(let I=0;I<_.length-1;I++){let B=_[I],V=_[I+1];b(y+B[0]*E,g+B[1]*C,y+V[0]*E,g+V[1]*C,o,-l*.5,l*.5)}y+=P?h*.88:h}pe(this,i,f,x,p),t.center!==!1?this.center():this.computeBoundingBox()}}function He(n){if(!n)return;let e=n,t=n.userData?.xr?.text;if(t!=null&&t!==!1){let r=e.geometry?.attributes?.position;if((!r||r.count===0)&&n.userData._textApplied!==!0){let a="",c=.08,u=.015,l;if(typeof t=="string"||typeof t=="number")a=String(t);else if(typeof t=="object"){let o=t;a=String(o.text??o.value??""),o.size!==void 0&&(c=Number(o.size)||.08),(o.depth!==void 0||o.height!==void 0)&&(u=Number(o.depth??o.height)||c*.2),(typeof o.color=="string"||typeof o.color=="number")&&(l=o.color)}a.trim().length>0&&(e.geometry=new Fe(a,{size:c,depth:u}),n.userData._textApplied=!0,e.material instanceof yn?l!==void 0&&n.userData._autoTextColorApplied!==!0&&(e.material.color=new mn(l),n.userData._autoTextColorApplied=!0):e.material=new Ee({color:l??16317180}))}}let s=n.userData?.csg;if(s&&typeof s=="object"&&n.userData._csgApplied!==!0&&e.geometry instanceof ne&&e.geometry.attributes.position?.count>0){n.userData._csgApplied=!0;let r=Array.isArray(s)?s:[s],a=e.geometry;for(let c of r){if(!c||typeof c!="object")continue;let u=c,l=String(u.op??u.operation??"subtract"),o=l==="union"||l==="intersect"?l:"subtract",m=u.target??u.mesh??u.geometry;if(m instanceof ye||m instanceof ne)try{let h=o==="union"?de.union(e,m):o==="intersect"?de.intersect(e,m):de.subtract(e,m);e.geometry!==a&&e.geometry.dispose?.(),e.geometry=h.geometry}catch(h){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",h)}}}}let je={Path:fe,Shape:xe,ShapeGeometry:xn,ExtrudeGeometry:pn,TextGeometry:Fe,CSG:de,MAX_CSG_TRIANGLES:le,MAX_BSP_DEPTH:te,MAX_TEXT_GEOMETRY_CHARS:Re,MAX_SHAPE_POINTS:we,materializeDeclarativeGeometry:He};return L&&typeof L=="object"&&(L.authorNamespace||(L.authorNamespace={}),Object.assign(L.authorNamespace,je),L.materializeDeclarativeGeometry=He),je}var Le={name:"cad",onRegister(){on(Se);let M=me(),L=M.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);L&&Se(L,M)}};rn(Le);
|
|
16
|
+
*/var Te=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Sn=Object.getOwnPropertyNames,Pn=Object.prototype.hasOwnProperty,Mn=(v,S)=>{for(var D in S)Te(v,D,{get:S[D],enumerable:!0})},wn=(v,S,D,oe)=>{if(S&&typeof S=="object"||typeof S=="function")for(let W of Sn(S))!Pn.call(v,W)&&W!==D&&Te(v,W,{get:()=>S[W],enumerable:!(oe=vn(S,W))||oe.enumerable});return v},Gn=v=>wn(Te({},"__esModule",{value:!0}),v),kn={};Mn(kn,{MAX_BSP_DEPTH:()=>nn,MAX_CSG_TRIANGLES:()=>en,MAX_SHAPE_POINTS:()=>sn,MAX_TEXT_GEOMETRY_CHARS:()=>tn,cadPlugin:()=>Le,installCadExtension:()=>Se}),module.exports=Gn(kn);var ve="__THREE_LIVE_REGISTRY__";function me(){let v=typeof globalThis<"u"?globalThis:{};if(!v[ve]){let S={plugins:[],decoders:new Map};try{Object.defineProperty(v,ve,{value:S,writable:!1,configurable:!1,enumerable:!1})}catch{v[ve]=S}}return v[ve]}var Tn=me().plugins;function Qe(v){let S=me();S.workerExtensionInstallers||(S.workerExtensionInstallers=[]),S.workerExtensionInstallers.includes(v)||S.workerExtensionInstallers.push(v)}function Je(v){let S=me().plugins;S.some(D=>D.name===v.name)||S.push(v),v.onRegister?.()}var en=8192,nn=2048,tn=128,sn=4096;function Se(v,S){if(!v||!v.BufferGeometry)return null;let D=v.Vector2,oe=v.Vector3,W=v.Quaternion,de=v.Matrix4,et=v.Matrix3,tt=v.Color,ze=v.BufferAttribute,K=v.BufferGeometry,rt=v.Material,Ee=v.MeshStandardMaterial,pe=v.Mesh,he=8192,ee=2048,Ae=128,Pe=4096,q=(t,e)=>{let r=t==null?NaN:Number(t);return Number.isFinite(r)?r:e};class ye{constructor(e){this.currentPoint=new D(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 r=1;r<e.length;r++)this.lineTo(e[r].x,e[r].y);return this}moveTo(e,r){let n=Number(e)||0,s=Number(r)||0;return this.currentPoint.set(n,s),this.segments.push({type:"move",pts:[n,s]}),this}lineTo(e,r){let n=Number(e)||0,s=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(n,s),this.segments.push({type:"line",pts:[n,s]}),this}quadraticCurveTo(e,r,n,s){let l=this.currentPoint.x,h=this.currentPoint.y,u=Number(e)||0,c=Number(r)||0,i=Number(n)||0,p=Number(s)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[l,h]}),this.currentPoint.set(i,p),this.segments.push({type:"quad",pts:[l,h,u,c,i,p]}),this}bezierCurveTo(e,r,n,s,l,h){let u=this.currentPoint.x,c=this.currentPoint.y,i=Number(e)||0,p=Number(r)||0,a=Number(n)||0,o=Number(s)||0,y=Number(l)||0,x=Number(h)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,c]}),this.currentPoint.set(y,x),this.segments.push({type:"cubic",pts:[u,c,i,p,a,o,y,x]}),this}absarc(e,r,n,s,l,h=!1){return this.absellipse(e,r,n,n,s,l,h,0)}arc(e,r,n,s,l,h=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(r)||0),n,s,l,h)}absellipse(e,r,n,s,l,h,u=!1,c=0){let i=Number(e)||0,p=Number(r)||0,a=Math.max(0,Number(n)||0),o=Math.max(0,Number(s)||0),y=Number(l)||0,x=Number(h)||0,b=u?1:0,g=Number(c)||0;this.segments.push({type:"arc",pts:[i,p,a,o,y,x,b,g]});let f=Math.cos(g),m=Math.sin(g),d=a*Math.cos(x),M=o*Math.sin(x);return this.currentPoint.set(i+d*f-M*m,p+d*m+M*f),this}ellipse(e,r,n,s,l,h,u=!1,c=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(r)||0),n,s,l,h,u,c)}closePath(){if(this.segments.length>0){let e=this.segments[0],r=0,n=0;if(e.type==="arc"){let s=e.pts[0],l=e.pts[1],h=e.pts[2],u=e.pts[3],c=e.pts[4],i=e.pts[7],p=Math.cos(i),a=Math.sin(i),o=h*Math.cos(c),y=u*Math.sin(c);r=s+o*p-y*a,n=l+o*a+y*p}else r=e.pts[0],n=e.pts[1];Math.hypot(this.currentPoint.x-r,this.currentPoint.y-n)>1e-6&&this.lineTo(r,n)}return this}getPoints(e=12){let r=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),n=[],s=(l,h)=>{if(n.length>0){let u=n[n.length-1];if(Math.hypot(u.x-l,u.y-h)<1e-6)return}n.push(new D(l,h))};for(let l of this.segments){let h=l.pts;if(l.type==="move"||l.type==="line")s(h[0],h[1]);else if(l.type==="quad"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5];s(u,c);for(let y=1;y<=r;y++){let x=y/r,b=1-x;s(b*b*u+2*b*x*i+x*x*a,b*b*c+2*b*x*p+x*x*o)}}else if(l.type==="cubic"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5],y=h[6],x=h[7];s(u,c);for(let b=1;b<=r;b++){let g=b/r,f=1-g,m=f*f,d=g*g;s(m*f*u+3*m*g*i+3*f*d*a+d*g*y,m*f*c+3*m*g*p+3*f*d*o+d*g*x)}}else if(l.type==="arc"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5],y=h[6]!==0,x=h[7],b=Math.PI*2,g=o-a,f=Math.abs(g)<1e-9;for(;g<0;)g+=b;for(;g>b;)g-=b;g<1e-9&&(g=f?0:b),y&&!f&&(g=g===b?-b:g-b);let m=Math.cos(x),d=Math.sin(x),M=Math.max(2,r);for(let w=0;w<=M;w++){let z=w/M,P=a+z*g,N=i*Math.cos(P),T=p*Math.sin(P);s(u+N*m-T*d,c+N*d+T*m)}}}if(n.length>2){let l=n[0],h=n[n.length-1];Math.hypot(l.x-h.x,l.y-h.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(r=>({type:r.type,pts:[...r.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(r=>r.clone())),e}}class fe extends ye{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(r=>r.getPoints(e))}}}function xe(t){let e=0,r=t.length;for(let n=0,s=r-1;n<r;s=n++)e+=t[s].x*t[n].y-t[n].x*t[s].y;return e*.5}function nt(t,e,r,n,s,l,h,u){let c=h-r,i=u-n,p=s-r,a=l-n,o=t-r,y=e-n,x=c*c+i*i,b=c*p+i*a,g=c*o+i*y,f=p*p+a*a,m=p*o+a*y,d=x*f-b*b;if(Math.abs(d)<1e-12)return!1;let M=1/d,w=(f*g-b*m)*M,z=(x*m-b*g)*M;return w>=-1e-7&&z>=-1e-7&&w+z<=1+1e-7}function Ge(t,e){let r=t.slice();xe(r)<0&&r.reverse();let n=r.map(c=>new D(c.x,c.y)),s=r.map((c,i)=>i),l=[];for(let c of e){if(!c||c.length<3)continue;let i=c.slice();xe(i)>0&&i.reverse();let p=[],a=-1/0,o=0;for(let y=0;y<i.length;y++){let x=i[y],b=n.length;n.push(new D(x.x,x.y)),p.push(b),x.x>a&&(a=x.x,o=y)}l.push({pts:i,indices:p,maxX:a,maxIdx:o})}l.sort((c,i)=>i.maxX-c.maxX);let h=(c,i,p)=>(i.x-c.x)*(p.y-c.y)-(i.y-c.y)*(p.x-c.x),u=(c,i,p)=>{for(let a=0;a<p.length;a++){let o=p[a],y=p[(a+1)%p.length];if(h(c,i,o)*h(c,i,y)<0&&h(o,y,c)*h(o,y,i)<0)return!0}return!1};for(let c of l){let i=c.pts[c.maxIdx],p=i.x,a=s.length,o=s.map(f=>n[f]),y=f=>Math.hypot(o[f].x-p,o[f].y-i.y),x=o.map((f,m)=>m).sort((f,m)=>+(o[f].x<p)-+(o[m].x<p)||y(f)-y(m)),b=x[0];for(let f of x){let m=o[f],d=o[(f+a-1)%a],M=o[(f+1)%a],w=h(m,M,i)>=0,z=h(d,m,i)>=0;if((h(d,m,M)>=0?w&&z:w||z)&&!u(i,m,o)&&!l.some(P=>u(i,m,P.pts))){b=f;break}}let g=[];for(let f=0;f<=b;f++)g.push(s[f]);for(let f=0;f<=c.indices.length;f++){let m=c.indices[(c.maxIdx+f)%c.indices.length];g.push(m)}for(let f=b;f<s.length;f++)g.push(s[f]);s=g}return{merged:s.map(c=>n[c]),mergedIndices:s,allVertices:n}}function Ie(t,e){let r=[],n=t.slice();if(n.length<3)return r;let s=n.length*n.length+64,l=0;for(;n.length>2&&s-- >0;){let h=n.length,u=n[(l+h-1)%h],c=n[l%h],i=n[(l+1)%h],p=e[u],a=e[c],o=e[i];if((a.x-p.x)*(o.y-p.y)-(a.y-p.y)*(o.x-p.x)>1e-9){let y=!0,x=Math.min(p.x,a.x,o.x)-1e-7,b=Math.max(p.x,a.x,o.x)+1e-7,g=Math.min(p.y,a.y,o.y)-1e-7,f=Math.max(p.y,a.y,o.y)+1e-7;for(let m=0;m<h;m++){let d=n[m];if(d===u||d===c||d===i)continue;let M=e[d];if(M.x>=x&&M.x<=b&&M.y>=g&&M.y<=f&&nt(M.x,M.y,p.x,p.y,a.x,a.y,o.x,o.y)&&(M.x-p.x)*(M.x-p.x)+(M.y-p.y)*(M.y-p.y)>=1e-12&&(M.x-a.x)*(M.x-a.x)+(M.y-a.y)*(M.y-a.y)>=1e-12&&(M.x-o.x)*(M.x-o.x)+(M.y-o.y)*(M.y-o.y)>=1e-12){y=!1;break}}if(y){r.push([u,c,i]),n.splice(l%h,1),l=Math.max(0,l%h-1);continue}}l++,l>=h*2&&(r.push([u,c,i]),n.splice((l-1)%h,1),l=0)}return r}function Ce(t,e){let r=t instanceof fe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},n=r.shape.length;for(let s of r.holes)n+=s.length;if(n>Pe)throw new RangeError(`SecurityError: shape point count (${n}) exceeds MAX_SHAPE_POINTS (${Pe})`);return r}function Xe(t){let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let l of t)l.x<e&&(e=l.x),l.y<r&&(r=l.y),l.x>n&&(n=l.x),l.y>s&&(s=l.y);return[e,r,Math.max(1e-6,n-e),Math.max(1e-6,s-r)]}class st extends K{constructor(e=new fe,r=12){super();let n=Array.isArray(e)?e:[e],s=[],l=[],h=[],u=[];for(let c of n){if(!(c instanceof ye))continue;let i=Ce(c,r);if(i.shape.length<3)continue;let{mergedIndices:p,allVertices:a}=Ge(i.shape,i.holes),o=Ie(p,a),y=s.length/3,[x,b,g,f]=Xe(a);for(let m of a)s.push(m.x,m.y,0),l.push(0,0,1),h.push((m.x-x)/g,(m.y-b)/f);for(let[m,d,M]of o)u.push(y+m,y+d,y+M)}ge(this,s,l,h,u)}}function ge(t,e,r,n,s){return t.setAttribute("position",new ze(e,3)),t.setAttribute("normal",new ze(r,3)),t.setAttribute("uv",new ze(n,2)),t.setIndex(s),t}function it(t){let e=t.length,r=[];for(let n=0;n<e;n++){let s=t[(n+e-1)%e],l=t[n],h=t[(n+1)%e],u=l.x-s.x,c=l.y-s.y,i=Math.hypot(u,c)||1;u/=i,c/=i;let p=h.x-l.x,a=h.y-l.y,o=Math.hypot(p,a)||1;p/=o,a/=o;let y=c,x=-u,b=a,g=-p,f=y+b,m=x+g,d=Math.hypot(f,m);if(d>1e-6){f/=d,m/=d;let M=Math.max(.35,f*y+m*x);r.push(new D(f/M,m/M))}else r.push(new D(y,x))}return r}class lt extends K{constructor(e=new fe,r={}){super();let n=Array.isArray(e)?e:[e],s=Math.max(1,Math.min(64,Math.floor(q(r.curveSegments,12)))),l=q(r.depth??r.amount,1),h=Math.max(1,Math.min(32,Math.floor(q(r.steps,1)))),u=!!(r.bevelEnabled??!1),c=u?Math.max(0,q(r.bevelThickness,.06)):0,i=u?Math.max(0,q(r.bevelSize,c*.8)):0,p=u?q(r.bevelOffset,0):0,a=u?Math.max(1,Math.min(8,Math.floor(q(r.bevelSegments,2)))):0,o=[],y=[],x=[],b=[];for(let g of n){if(!(g instanceof ye))continue;let f=Ce(g,s);if(f.shape.length<3)continue;let m=f.shape.slice();xe(m)<0&&m.reverse();let d=[];for(let E of f.holes){if(E.length<3)continue;let _=E.slice();xe(_)>0&&_.reverse(),d.push(_)}let{mergedIndices:M,allVertices:w}=Ge(m,d),z=Ie(M,w),P=[m,...d],N=[];for(let E of P){let _=it(E);for(let X of _)N.push(X)}let[T,O,k,$]=Xe(w);for(let[E,_]of[[-c,-1],[l+c,1]]){let X=o.length/3;for(let C=0;C<w.length;C++){let G=w[C],I=N[C]??new D(0,0),j=G.x+I.x*p,R=G.y+I.y*p;o.push(j,R,E),y.push(0,0,_),x.push((j-T)/k,(R-O)/$)}for(let[C,G,I]of z)b.push(X+C,X+(_<0?I:G),X+(_<0?G:I))}let A=[];if(u&&a>0)for(let E=0;E<a;E++){let _=E/a*Math.PI/2;A.push({z:-c*Math.cos(_),expand:p+i*Math.sin(_)})}for(let E=0;E<=h;E++){let _=E/h;A.push({z:_*l,expand:p+i})}if(u&&a>0)for(let E=1;E<=a;E++){let _=E/a*Math.PI/2;A.push({z:l+c*Math.sin(_),expand:p+i*Math.cos(_)})}let H=0;for(let E of P){let _=E.length;for(let X=0;X<A.length-1;X++){let C=A[X],G=A[X+1];for(let I=0;I<_;I++){let j=(I+1)%_,R=E[I],B=E[j],L=N[H+I],V=N[H+j],Y=R.x+L.x*C.expand,F=R.y+L.y*C.expand,te=B.x+V.x*C.expand,re=B.y+V.y*C.expand,ue=B.x+V.x*G.expand,ce=B.y+V.y*G.expand,J=R.x+L.x*G.expand,Z=R.y+L.y*G.expand,Q=te-Y,U=re-F,yt=J-Y,ft=Z-F,Fe=G.z-C.z,ne=U*Fe,se=-Q*Fe,ie=Q*ft-U*yt,_e=Math.hypot(ne,se,ie)||1;ne/=_e,se/=_e,ie/=_e;let le=o.length/3;o.push(Y,F,C.z,te,re,C.z,ue,ce,G.z,J,Z,G.z),y.push(ne,se,ie,ne,se,ie,ne,se,ie,ne,se,ie);let Ue=I/_,We=(I+1)/_,Ze=X/(A.length-1),Ke=(X+1)/(A.length-1);x.push(Ue,Ze,We,Ze,We,Ke,Ue,Ke),b.push(le,le+1,le+2,le,le+2,le+3)}}H+=_}}ge(this,o,y,x,b)}}function ke(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 ot(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 ht(t,e,r){let n=t.nx+(e.nx-t.nx)*r,s=t.ny+(e.ny-t.ny)*r,l=t.nz+(e.nz-t.nz)*r,h=Math.hypot(n,s,l)||1;return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r,z:t.z+(e.z-t.z)*r,nx:n/h,ny:s/h,nz:l/h,u:t.u+(e.u-t.u)*r,v:t.v+(e.v-t.v)*r}}function at(t){if(t.length<3)return null;let e=t[0],r=t[1],n=t[2],s=r.x-e.x,l=r.y-e.y,h=r.z-e.z,u=n.x-e.x,c=n.y-e.y,i=n.z-e.z,p=l*i-h*c,a=h*u-s*i,o=s*c-l*u,y=Math.hypot(p,a,o);if(y<1e-9)return null;p/=y,a/=y,o/=y;let x=p*e.x+a*e.y+o*e.z;return{vertices:t,nx:p,ny:a,nz:o,w:x}}function ut(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=ot(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let De=1e-5,Re=0,we=1,be=2,Oe=3;function je(t,e,r,n,s,l,h,u,c){let i=0,p=[];for(let a=0;a<s.vertices.length;a++){let o=s.vertices[a],y=t*o.x+e*o.y+r*o.z-n,x=y<-De?be:y>De?we:Re;i|=x,p.push(x)}switch(i){case Re:{t*s.nx+e*s.ny+r*s.nz>0?l.push(s):h.push(s);break}case we:u.push(s);break;case be:c.push(s);break;case Oe:{let a=[],o=[],y=s.vertices.length;for(let m=0;m<y;m++){let d=(m+1)%y,M=p[m],w=p[d],z=s.vertices[m],P=s.vertices[d];if(M!==be&&a.push(z),M!==we&&o.push(M!==be?ke(z):z),(M|w)===Oe){let N=P.x-z.x,T=P.y-z.y,O=P.z-z.z,k=t*N+e*T+r*O,$=Math.abs(k)>1e-12?(n-(t*z.x+e*z.y+r*z.z))/k:.5,A=ht(z,P,Math.max(0,Math.min(1,$)));a.push(A),o.push(ke(A))}}let{nx:x,ny:b,nz:g,w:f}=s;a.length>=3&&u.push({vertices:a,nx:x,ny:b,nz:g,w:f}),o.length>=3&&c.push({vertices:o,nx:x,ny:b,nz:g,w:f});break}default:break}}class ae{constructor(e,r=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,r)}invert(){for(let r=0;r<this.polygons.length;r++)ut(this.polygons[r]);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,r=0){if(!this.hasPlane||e.length===0)return e.slice();if(r>=ee)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ee})`);let n=[],s=[];for(let l=0;l<e.length;l++)je(this.nx,this.ny,this.nz,this.w,e[l],n,s,n,s);return this.front&&n.length>0&&(n=this.front.clipPolygons(n,r+1)),this.back?s=s.length>0?this.back.clipPolygons(s,r+1):[]:s=[],n.concat(s)}clipTo(e,r=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),r<ee&&(this.front&&this.front.clipTo(e,r+1),this.back&&this.back.clipTo(e,r+1))}allPolygons(e=[]){for(let r=0;r<this.polygons.length;r++)e.push(this.polygons[r]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,r=0){if(!e.length)return;if(!this.hasPlane){let l=e[e.length>>1];this.nx=l.nx,this.ny=l.ny,this.nz=l.nz,this.w=l.w,this.hasPlane=!0}if(r>=ee)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ee})`);let n=[],s=[];for(let l=0;l<e.length;l++)je(this.nx,this.ny,this.nz,this.w,e[l],this.polygons,this.polygons,n,s);n.length>0&&(this.front||(this.front=new ae),this.front.build(n,r+1)),s.length>0&&(this.back||(this.back=new ae),this.back.build(s,r+1))}}function qe(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let r=t.attributes.position;if(!r||r.count===0)return[];let n=t.attributes.normal,s=t.attributes.uv,l=t.index?t.index.array:null,h=Math.floor(l?l.length/3:r.count/3);if(h>he)throw new RangeError(`SecurityError: CSG input triangle count (${h}) exceeds MAX_CSG_TRIANGLES (${he})`);let u=e?e.elements:null,c=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,i=u?new et().getNormalMatrix(e).elements:null,p=o=>{let y=r.getX(o),x=r.getY(o),b=r.getZ(o),g=n?n.getX(o):NaN,f=n?n.getY(o):NaN,m=n?n.getZ(o):NaN;if(u&&i){let w=u[0]*y+u[4]*x+u[8]*b+u[12],z=u[1]*y+u[5]*x+u[9]*b+u[13],P=u[2]*y+u[6]*x+u[10]*b+u[14];y=w,x=z,b=P;let N=i[0]*g+i[3]*f+i[6]*m,T=i[1]*g+i[4]*f+i[7]*m,O=i[2]*g+i[5]*f+i[8]*m,k=Math.hypot(N,T,O)||1;g=N/k,f=T/k,m=O/k}let d=s?s.getX(o):0,M=s?s.getY(o):0;return{x:y,y:x,z:b,nx:g,ny:f,nz:m,u:d,v:M}},a=[];for(let o=0;o<h;o++){let y=l?l[o*3]:o*3,x=l?l[o*3+1]:o*3+1,b=l?l[o*3+2]:o*3+2,g=at(c?[p(y),p(b),p(x)]:[p(y),p(x),p(b)]);g&&a.push(g)}return a}function ct(t){let e=[],r=[],n=[],s=[];for(let h of t){let u=h.vertices;if(u.length<3)continue;let c=e.length/3;for(let i of u)e.push(i.x,i.y,i.z),Number.isFinite(i.nx)&&i.nx*i.nx+i.ny*i.ny+i.nz*i.nz>.5?r.push(i.nx,i.ny,i.nz):r.push(h.nx,h.ny,h.nz),n.push(i.u,i.v);for(let i=1;i<u.length-1;i++)s.push(c,c+i,c+i+1)}let l=ge(new K,e,r,n,s);return l._csgPolygons=t,l}function pt(t,e,r){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 r==="union"?e:[];if(e.length===0)return r==="intersect"?[]:t;let n=1/0,s=1/0,l=1/0,h=-1/0,u=-1/0,c=-1/0;for(let y=0;y<e.length;y++){let x=e[y].vertices;for(let b=0;b<x.length;b++){let g=x[b];g.x<n&&(n=g.x),g.y<s&&(s=g.y),g.z<l&&(l=g.z),g.x>h&&(h=g.x),g.y>u&&(u=g.y),g.z>c&&(c=g.z)}}n-=1e-4,s-=1e-4,l-=1e-4,h+=1e-4,u+=1e-4,c+=1e-4;let i=[],p=[];for(let y=0;y<t.length;y++){let x=t[y],b=x.vertices,g=1/0,f=1/0,m=1/0,d=-1/0,M=-1/0,w=-1/0;for(let z=0;z<b.length;z++){let P=b[z];P.x<g&&(g=P.x),P.y<f&&(f=P.y),P.z<m&&(m=P.z),P.x>d&&(d=P.x),P.y>M&&(M=P.y),P.z>w&&(w=P.z)}d<n||g>h||M<s||f>u||w<l||m>c?p.push(x):i.push(x)}if(i.length===0)return r==="union"?t.concat(e):r==="subtract"?t:[];let a=new ae(i),o=new ae(e);return r==="union"?(a.clipTo(o),o.clipTo(a),o.invert(),o.clipTo(a),o.invert(),a.build(o.allPolygons()),p.concat(a.allPolygons())):r==="subtract"?(a.invert(),a.clipTo(o),o.clipTo(a),o.invert(),o.clipTo(a),o.invert(),a.build(o.allPolygons()),a.invert(),p.concat(a.allPolygons())):(a.invert(),o.clipTo(a),o.invert(),a.clipTo(o),o.clipTo(a),a.build(o.allPolygons()),a.invert(),a.allPolygons())}function He(t,e,r,n=null,s=null){let l=qe(t,n),h=qe(e,s);return ct(pt(l,h,r))}function Ne(t,e,r){let n=t instanceof pe||!!t?.isMesh,s=e instanceof pe||!!e?.isMesh,l=n?t.geometry:t,h=s?e.geometry:e,u=null;if(s)if(e.updateMatrix(),n){t.updateMatrix();let a=new de().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),o=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,y=new de().compose(new oe(0,0,0),new W(-t.quaternion.x/o,-t.quaternion.y/o,-t.quaternion.z/o,t.quaternion.w/o),new oe(1,1,1)),x=new de().makeTranslation(-t.position.x,-t.position.y,-t.position.z);u=a.multiply(y).multiply(x).multiply(e.matrix)}else u=e.matrix;let c=He(l,h,r,null,u),i=n?t.material:new Ee,p=new pe(c,i);return n&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let Me={toGeometry:He,subtract(t,e){return Ne(t,e,"subtract")},union(t,e){return Ne(t,e,"union")},intersect(t,e){return Ne(t,e,"intersect")}},Be={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 K{constructor(e="",r={}){super();let n=String(e??"").slice(0,Ae),s=Math.max(.005,Math.min(100,q(r.size,.2))),l=!!(r.bevelEnabled??!1),h=l?Math.max(0,Math.min(2,q(r.bevelThickness,s*.04))):0,u=l?Math.max(0,Math.min(2,q(r.bevelSize,s*.03))):0,c=Math.max(.001,Math.min(20,q(r.depth??r.height,s*.2)))+h*2,i=s*.085+u,p=s*.68,a=s*.82,o=[],y=[],x=[],b=[],g=(d,M,w,z,P,N,T)=>{let O=w-d,k=z-M,$=Math.hypot(O,k),A=1,H=0;$>1e-6&&(A=O/$,H=k/$);let E=-H*P,_=A*P,X=A*P*.6,C=H*P*.6,G=d-X+E,I=M-C+_,j=d-X-E,R=M-C-_,B=w+X-E,L=z+C-_,V=w+X+E,Y=z+C+_,F=(te,re,ue,ce,J,Z,Q)=>{let U=o.length/3;o.push(te[0],te[1],te[2],re[0],re[1],re[2],ue[0],ue[1],ue[2],ce[0],ce[1],ce[2]),y.push(J,Z,Q,J,Z,Q,J,Z,Q,J,Z,Q),x.push(0,0,1,0,1,1,0,1),b.push(U,U+1,U+2,U,U+2,U+3)};F([G,I,T],[j,R,T],[B,L,T],[V,Y,T],0,0,1),F([j,R,N],[G,I,N],[V,Y,N],[B,L,N],0,0,-1),F([G,I,N],[j,R,N],[j,R,T],[G,I,T],-A,-H,0),F([B,L,N],[V,Y,N],[V,Y,T],[B,L,T],A,H,0),F([j,R,N],[B,L,N],[B,L,T],[j,R,T],H,-A,0),F([V,Y,N],[G,I,N],[G,I,T],[V,Y,T],-H,A,0)},f=0,m=0;for(let d=0;d<n.length;d++){let M=n[d];if(M===`
|
|
17
|
+
`){f=0,m-=s*1.35;continue}if(M===" "||M===" "){f+=a*(M===" "?.75:3);continue}if(M==="\r")continue;let w=M.toUpperCase(),z=M!==w&&M>="a"&&M<="z",P=Be[w]??Be["?"],N=z?s*.76:s,T=z?p*.88:p;for(let O of P)for(let k=0;k<O.length-1;k++){let $=O[k],A=O[k+1];g(f+$[0]*T,m+$[1]*N,f+A[0]*T,m+A[1]*N,i,-c*.5,c*.5)}f+=z?a*.88:a}ge(this,o,y,x,b),r.center!==!1?this.center():this.computeBoundingBox()}}function $e(t){if(!t)return;let e=t,r=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(r!=null&&r!==!1){let s=e.geometry?.attributes?.position;if((!s||s.count===0)&&t.userData._textApplied!==!0){let l="",h=.08,u=.015,c;if(typeof r=="string"||typeof r=="number")l=String(r);else if(typeof r=="object"){let i=r;l=String(i.text??i.value??""),i.size!==void 0&&(h=Number(i.size)||.08),(i.depth!==void 0||i.height!==void 0)&&(u=Number(i.depth??i.height)||h*.2),(typeof i.color=="string"||typeof i.color=="number")&&(c=i.color)}l.trim().length>0&&(e.geometry=new Ve(l,{size:h,depth:u}),t.userData._textApplied=!0,e.material instanceof rt?c!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new tt(c),t.userData._autoTextColorApplied=!0):e.material=new Ee({color:c??16317180}))}}let n=t.userData?.csg;if(n&&typeof n=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof K&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let s=Array.isArray(n)?n:[n],l=e.geometry;for(let h of s){if(!h||typeof h!="object")continue;let u=h,c=String(u.op??u.operation??"subtract"),i=c==="union"||c==="intersect"?c:"subtract",p=u.target??u.mesh??u.geometry;if(p instanceof pe||p instanceof K)try{let a=i==="union"?Me.union(e,p):i==="intersect"?Me.intersect(e,p):Me.subtract(e,p);e.geometry!==l&&e.geometry.dispose?.(),e.geometry=a.geometry}catch(a){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",a)}}}}let Ye={Path:ye,Shape:fe,ShapeGeometry:st,ExtrudeGeometry:lt,TextGeometry:Ve,CSG:Me,MAX_CSG_TRIANGLES:he,MAX_BSP_DEPTH:ee,MAX_TEXT_GEOMETRY_CHARS:Ae,MAX_SHAPE_POINTS:Pe,materializeDeclarativeGeometry:$e};return S&&typeof S=="object"&&(S.authorNamespace||(S.authorNamespace={}),Object.assign(S.authorNamespace,Ye),S._cadMaterialize=$e,S.materializeDeclarativeGeometry=t=>{S._cadMaterialize?.(t),S._lodMaterialize?.(t)}),Ye}var Le={name:"cad",onRegister(){Qe(Se);let v=me(),S=v.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);S&&Se(S,v)}};Je(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,
|
|
@@ -112,6 +126,7 @@ export {
|
|
|
112
126
|
type VariantMapping,
|
|
113
127
|
} from './three-live/src/plugins/variants';
|
|
114
128
|
export {
|
|
129
|
+
defineModelViewer,
|
|
115
130
|
ThreeLiveElement,
|
|
116
131
|
type ARLaunchOptions,
|
|
117
132
|
type ARLaunchResult,
|
|
@@ -130,6 +145,8 @@ export {
|
|
|
130
145
|
} from './xr-live/src/xr-live-element';
|
|
131
146
|
/** Optional spatial plugins (`xr-live/spatial`, `xr-live-spatial.min.js`). */
|
|
132
147
|
export * from './xr-live/src/plugins/index';
|
|
148
|
+
/** Optional simulation plugins (`xr-live/sim`, `xr-live-sim.min.js`). */
|
|
149
|
+
export * from './xr-live/src/sim/index';
|
|
133
150
|
|
|
134
151
|
/**
|
|
135
152
|
* Declarative JSX / HTML attributes supported by the <three-live> custom element.
|
|
@@ -449,7 +466,27 @@ export interface XRLiveAttributes extends ThreeLiveAttributes {
|
|
|
449
466
|
sdpMLineIndex: number | null;
|
|
450
467
|
}>,
|
|
451
468
|
) => void;
|
|
469
|
+
onxraudioplay?: (
|
|
470
|
+
e: CustomEvent<{
|
|
471
|
+
node: string;
|
|
472
|
+
meshIndex: number;
|
|
473
|
+
preset: string | null;
|
|
474
|
+
src: string | null;
|
|
475
|
+
gain: number;
|
|
476
|
+
pan: number;
|
|
477
|
+
triggerCount: number;
|
|
478
|
+
}>,
|
|
479
|
+
) => void;
|
|
452
480
|
/** xr-live-sim events. */
|
|
481
|
+
onxrcollision?: (
|
|
482
|
+
e: CustomEvent<{
|
|
483
|
+
nodeId: string;
|
|
484
|
+
otherId: string;
|
|
485
|
+
normal: [number, number, number];
|
|
486
|
+
impactSpeed: number;
|
|
487
|
+
}>,
|
|
488
|
+
) => void;
|
|
489
|
+
onxrsleep?: (e: CustomEvent<{nodeId: string}>) => void;
|
|
453
490
|
oncharacterjump?: (
|
|
454
491
|
e: CustomEvent<{nodeId: string; position: [number, number, number]}>,
|
|
455
492
|
) => 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 ge="__THREE_LIVE_REGISTRY__";function le(){let L=typeof globalThis<"u"?globalThis:{};if(!L[ge]){let E={plugins:[],decoders:new Map};try{Object.defineProperty(L,ge,{value:E,writable:!1,configurable:!1,enumerable:!1})}catch{L[ge]=E}}return L[ge]}var Gn=le().plugins;function nn(L){let E=le();E.workerExtensionInstallers||(E.workerExtensionInstallers=[]),E.workerExtensionInstallers.includes(L)||E.workerExtensionInstallers.push(L)}function tn(L){let E=le().plugins;E.some(D=>D.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 D=L.Vector2,ke=L.Vector3,on=L.Quaternion,de=L.Matrix4,rn=L.Matrix3,cn=L.Color,ve=L.BufferAttribute,ee=L.BufferGeometry,an=L.Material,Ce=L.MeshStandardMaterial,he=L.Mesh,ae=8192,ne=2048,Te=128,Se=4096,B=(n,e)=>{let t=n==null?NaN:Number(n);return Number.isFinite(t)?t:e};class me{constructor(e){this.currentPoint=new D(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 t=1;t<e.length;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){let s=Number(e)||0,r=Number(t)||0;return this.currentPoint.set(s,r),this.segments.push({type:"move",pts:[s,r]}),this}lineTo(e,t){let s=Number(e)||0,r=Number(t)||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,t,s,r){let a=this.currentPoint.x,c=this.currentPoint.y,u=Number(e)||0,l=Number(t)||0,o=Number(s)||0,m=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,c]}),this.currentPoint.set(o,m),this.segments.push({type:"quad",pts:[a,c,u,l,o,m]}),this}bezierCurveTo(e,t,s,r,a,c){let u=this.currentPoint.x,l=this.currentPoint.y,o=Number(e)||0,m=Number(t)||0,h=Number(s)||0,i=Number(r)||0,f=Number(a)||0,x=Number(c)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,l]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[u,l,o,m,h,i,f,x]}),this}absarc(e,t,s,r,a,c=!1){return this.absellipse(e,t,s,s,r,a,c,0)}arc(e,t,s,r,a,c=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),s,r,a,c)}absellipse(e,t,s,r,a,c,u=!1,l=0){let o=Number(e)||0,m=Number(t)||0,h=Math.max(0,Number(s)||0),i=Math.max(0,Number(r)||0),f=Number(a)||0,x=Number(c)||0,p=u?1:0,b=Number(l)||0;this.segments.push({type:"arc",pts:[o,m,h,i,f,x,p,b]});let y=Math.cos(b),g=Math.sin(b),S=h*Math.cos(x),d=i*Math.sin(x);return this.currentPoint.set(o+S*y-d*g,m+S*g+d*y),this}ellipse(e,t,s,r,a,c,u=!1,l=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),s,r,a,c,u,l)}closePath(){if(this.segments.length>0){let e=this.segments[0],t=0,s=0;if(e.type==="arc"){let r=e.pts[0],a=e.pts[1],c=e.pts[2],u=e.pts[3],l=e.pts[4],o=e.pts[7],m=Math.cos(o),h=Math.sin(o),i=c*Math.cos(l),f=u*Math.sin(l);t=r+i*m-f*h,s=a+i*h+f*m}else t=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-t,this.currentPoint.y-s)>1e-6&&this.lineTo(t,s)}return this}getPoints(e=12){let t=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],r=(a,c)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-a,u.y-c)<1e-6)return}s.push(new D(a,c))};for(let a of this.segments){let c=a.pts;if(a.type==="move"||a.type==="line")r(c[0],c[1]);else if(a.type==="quad"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5];r(u,l);for(let f=1;f<=t;f++){let x=f/t,p=1-x;r(p*p*u+2*p*x*o+x*x*h,p*p*l+2*p*x*m+x*x*i)}}else if(a.type==="cubic"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5],f=c[6],x=c[7];r(u,l);for(let p=1;p<=t;p++){let b=p/t,y=1-b,g=y*y,S=b*b;r(g*y*u+3*g*b*o+3*y*S*h+S*b*f,g*y*l+3*g*b*m+3*y*S*i+S*b*x)}}else if(a.type==="arc"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5],f=c[6]!==0,x=c[7],p=Math.PI*2,b=i-h,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,t);for(let M=0;M<=d;M++){let P=M/d,w=h+P*b,k=o*Math.cos(w),T=m*Math.sin(w);r(u+k*g-T*S,l+k*S+T*g)}}}if(s.length>2){let a=s[0],c=s[s.length-1];Math.hypot(a.x-c.x,a.y-c.y)<1e-6&&s.pop()}return s}getSpacedPoints(e=12){return this.getPoints(e)}}class ye extends me{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(t=>t.getPoints(e))}}}function fe(n){let e=0,t=n.length;for(let s=0,r=t-1;s<t;r=s++)e+=n[r].x*n[s].y-n[s].x*n[r].y;return e*.5}function un(n,e,t,s,r,a,c,u){let l=c-t,o=u-s,m=r-t,h=a-s,i=n-t,f=e-s,x=l*l+o*o,p=l*m+o*h,b=l*i+o*f,y=m*m+h*h,g=m*i+h*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(n,e){let t=n.slice();fe(t)<0&&t.reverse();let s=t.map(l=>new D(l.x,l.y)),r=t.map((l,o)=>o),a=[];for(let l of e){if(!l||l.length<3)continue;let o=l.slice();fe(o)>0&&o.reverse();let m=[],h=-1/0,i=0;for(let f=0;f<o.length;f++){let x=o[f],p=s.length;s.push(new D(x.x,x.y)),m.push(p),x.x>h&&(h=x.x,i=f)}a.push({pts:o,indices:m,maxX:h,maxIdx:i})}a.sort((l,o)=>o.maxX-l.maxX);let c=(l,o,m)=>(o.x-l.x)*(m.y-l.y)-(o.y-l.y)*(m.x-l.x),u=(l,o,m)=>{for(let h=0;h<m.length;h++){let i=m[h],f=m[(h+1)%m.length];if(c(l,o,i)*c(l,o,f)<0&&c(i,f,l)*c(i,f,o)<0)return!0}return!1};for(let l of a){let o=l.pts[l.maxIdx],m=o.x,h=r.length,i=r.map(y=>s[y]),f=y=>Math.hypot(i[y].x-m,i[y].y-o.y),x=i.map((y,g)=>g).sort((y,g)=>+(i[y].x<m)-+(i[g].x<m)||f(y)-f(g)),p=x[0];for(let y of x){let g=i[y],S=i[(y+h-1)%h],d=i[(y+1)%h],M=c(g,d,o)>=0,P=c(S,g,o)>=0;if((c(S,g,d)>=0?M&&P:M||P)&&!u(o,g,i)&&!a.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<=l.indices.length;y++){let g=l.indices[(l.maxIdx+y)%l.indices.length];b.push(g)}for(let y=p;y<r.length;y++)b.push(r[y]);r=b}return{merged:r.map(l=>s[l]),mergedIndices:r,allVertices:s}}function Ee(n,e){let t=[],s=n.slice();if(s.length<3)return t;let r=s.length*s.length+64,a=0;for(;s.length>2&&r-- >0;){let c=s.length,u=s[(a+c-1)%c],l=s[a%c],o=s[(a+1)%c],m=e[u],h=e[l],i=e[o];if((h.x-m.x)*(i.y-m.y)-(h.y-m.y)*(i.x-m.x)>1e-9){let x=!0;for(let p=0;p<c;p++){let b=s[p];if(b===u||b===l||b===o)continue;let y=e[b];if(un(y.x,y.y,m.x,m.y,h.x,h.y,i.x,i.y)&&Math.hypot(y.x-m.x,y.y-m.y)>=1e-6&&Math.hypot(y.x-h.x,y.y-h.y)>=1e-6&&Math.hypot(y.x-i.x,y.y-i.y)>=1e-6){x=!1;break}}if(x){t.push([u,l,o]),s.splice(a%c,1),a=Math.max(0,a%c-1);continue}}a++,a>=c*2&&(t.push([u,l,o]),s.splice((a-1)%c,1),a=0)}return t}function Re(n,e){let t=n instanceof ye?n.extractPoints(e):{shape:n.getPoints(e),holes:[]},s=t.shape.length;for(let r of t.holes)s+=r.length;if(s>Se)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${Se})`);return t}class ln extends ee{constructor(e=new ye,t=12){super();let s=Array.isArray(e)?e:[e],r=[],a=[],c=[],u=[];for(let l of s){if(!(l instanceof me))continue;let o=Re(l,t);if(o.shape.length<3)continue;let{mergedIndices:m,allVertices:h}=Le(o.shape,o.holes),i=Ee(m,h),f=r.length/3,x=1/0,p=1/0,b=-1/0,y=-1/0;for(let d of h)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 h)r.push(d.x,d.y,0),a.push(0,0,1),c.push((d.x-x)/g,(d.y-p)/S);for(let[d,M,P]of i)u.push(f+d,f+M,f+P)}xe(this,r,a,c,u)}}function xe(n,e,t,s,r){return n.setAttribute("position",new ve(e,3)),n.setAttribute("normal",new ve(t,3)),n.setAttribute("uv",new ve(s,2)),n.setIndex(r),n}function hn(n){let e=n.length,t=[];for(let s=0;s<e;s++){let r=n[(s+e-1)%e],a=n[s],c=n[(s+1)%e],u=a.x-r.x,l=a.y-r.y,o=Math.hypot(u,l)||1;u/=o,l/=o;let m=c.x-a.x,h=c.y-a.y,i=Math.hypot(m,h)||1;m/=i,h/=i;let f=l,x=-u,p=h,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);t.push(new D(y/d,g/d))}else t.push(new D(f,x))}return t}class mn extends ee{constructor(e=new ye,t={}){super();let s=Array.isArray(e)?e:[e],r=Math.max(1,Math.min(64,Math.floor(B(t.curveSegments,12)))),a=B(t.depth??t.amount,1),c=Math.max(1,Math.min(32,Math.floor(B(t.steps,1)))),u=!!(t.bevelEnabled??!1),l=u?Math.max(0,B(t.bevelThickness,.06)):0,o=u?Math.max(0,B(t.bevelSize,l*.8)):0,m=u?B(t.bevelOffset,0):0,h=u?Math.max(1,Math.min(8,Math.floor(B(t.bevelSegments,2)))):0,i=[],f=[],x=[],p=[];for(let b of s){if(!(b instanceof me))continue;let y=Re(b,r);if(y.shape.length<3)continue;let g=y.shape.slice();fe(g)<0&&g.reverse();let S=[];for(let v of y.holes){if(v.length<3)continue;let G=v.slice();fe(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,_=1/0,I=-1/0,X=-1/0;for(let v of M)v.x<T&&(T=v.x),v.y<_&&(_=v.y),v.x>I&&(I=v.x),v.y>X&&(X=v.y);let V=Math.max(1e-6,I-T),O=Math.max(1e-6,X-_),te=-l,se=a+l,j=i.length/3;for(let v=0;v<M.length;v++){let G=M[v],C=k[v]??new D(0,0),R=G.x+C.x*m,z=G.y+C.y*m;i.push(R,z,te),f.push(0,0,-1),x.push((R-T)/V,(z-_)/O)}for(let[v,G,C]of P)p.push(j+v,j+C,j+G);let q=i.length/3;for(let v=0;v<M.length;v++){let G=M[v],C=k[v]??new D(0,0),R=G.x+C.x*m,z=G.y+C.y*m;i.push(R,z,se),f.push(0,0,1),x.push((R-T)/V,(z-_)/O)}for(let[v,G,C]of P)p.push(q+v,q+G,q+C);let A=[];if(u&&h>0)for(let v=0;v<h;v++){let C=v/h*Math.PI/2;A.push({z:-l*Math.cos(C),expand:m+o*Math.sin(C)})}for(let v=0;v<=c;v++){let G=v/c;A.push({z:G*a,expand:m+o})}if(u&&h>0)for(let v=1;v<=h;v++){let C=v/h*Math.PI/2;A.push({z:a+l*Math.sin(C),expand:m+o*Math.cos(C)})}let Y=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 F=(N+1)%G,W=v[N],$=v[F],U=k[Y+N],Z=k[Y+F],K=W.x+U.x*R.expand,Q=W.y+U.y*R.expand,J=$.x+Z.x*R.expand,H=$.y+Z.y*R.expand,dn=$.x+Z.x*z.expand,vn=$.y+Z.y*z.expand,Fe=W.x+U.x*z.expand,He=W.y+U.y*z.expand,je=J-K,qe=H-Q,We=0,$e=Fe-K,Ue=He-Q,Ze=z.z-R.z,oe=qe*Ze-We*Ue,re=We*$e-je*Ze,ie=je*Ue-qe*$e,we=Math.hypot(oe,re,ie)||1;oe/=we,re/=we,ie/=we;let ce=i.length/3;i.push(K,Q,R.z,J,H,R.z,dn,vn,z.z,Fe,He,z.z),f.push(oe,re,ie,oe,re,ie,oe,re,ie,oe,re,ie);let Ke=N/G,Qe=(N+1)/G,Je=C/(A.length-1),en=(C+1)/(A.length-1);x.push(Ke,Je,Qe,Je,Qe,en,Ke,en),p.push(ce,ce+1,ce+2,ce,ce+2,ce+3)}}Y+=G}}xe(this,i,f,x,p)}}function ze(n){return{x:n.x,y:n.y,z:n.z,nx:n.nx,ny:n.ny,nz:n.nz,u:n.u,v:n.v}}function yn(n){return{x:n.x,y:n.y,z:n.z,nx:-n.nx,ny:-n.ny,nz:-n.nz,u:n.u,v:n.v}}function fn(n,e,t){let s=n.nx+(e.nx-n.nx)*t,r=n.ny+(e.ny-n.ny)*t,a=n.nz+(e.nz-n.nz)*t,c=Math.hypot(s,r,a)||1;return{x:n.x+(e.x-n.x)*t,y:n.y+(e.y-n.y)*t,z:n.z+(e.z-n.z)*t,nx:s/c,ny:r/c,nz:a/c,u:n.u+(e.u-n.u)*t,v:n.v+(e.v-n.v)*t}}function xn(n){if(n.length<3)return null;let e=n[0],t=n[1],s=n[2],r=t.x-e.x,a=t.y-e.y,c=t.z-e.z,u=s.x-e.x,l=s.y-e.y,o=s.z-e.z,m=a*o-c*l,h=c*u-r*o,i=r*l-a*u,f=Math.hypot(m,h,i);if(f<1e-9)return null;m/=f,h/=f,i/=f;let x=m*e.x+h*e.y+i*e.z;return{vertices:n,nx:m,ny:h,nz:i,w:x}}function bn(n){n.vertices.reverse();for(let e=0;e<n.vertices.length;e++)n.vertices[e]=yn(n.vertices[e]);n.nx=-n.nx,n.ny=-n.ny,n.nz=-n.nz,n.w=-n.w}let Ie=1e-5,_e=0,Pe=1,be=2,Ve=3;function Ae(n,e,t,s,r,a,c,u,l){let o=0,m=[];for(let h=0;h<r.vertices.length;h++){let i=r.vertices[h],f=n*i.x+e*i.y+t*i.z-s,x=f<-Ie?be:f>Ie?Pe:_e;o|=x,m.push(x)}switch(o){case _e:{n*r.nx+e*r.ny+t*r.nz>0?a.push(r):c.push(r);break}case Pe:u.push(r);break;case be:l.push(r);break;case Ve:{let h=[],i=[],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!==be&&h.push(P),d!==Pe&&i.push(d!==be?ze(P):P),(d|M)===Ve){let k=w.x-P.x,T=w.y-P.y,_=w.z-P.z,I=n*k+e*T+t*_,X=Math.abs(I)>1e-12?(s-(n*P.x+e*P.y+t*P.z))/I:.5,V=fn(P,w,Math.max(0,Math.min(1,X)));h.push(V),i.push(ze(V))}}let{nx:x,ny:p,nz:b,w:y}=r;h.length>=3&&u.push({vertices:h,nx:x,ny:p,nz:b,w:y}),i.length>=3&&l.push({vertices:i,nx:x,ny:p,nz:b,w:y});break}default:break}}class ue{constructor(e,t=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,t)}invert(){for(let t=0;t<this.polygons.length;t++)bn(this.polygons[t]);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,t=0){if(!this.hasPlane||e.length===0)return e.slice();if(t>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let s=[],r=[];for(let a=0;a<e.length;a++)Ae(this.nx,this.ny,this.nz,this.w,e[a],s,r,s,r);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,t+1)),this.back?r=r.length>0?this.back.clipPolygons(r,t+1):[]:r=[],s.concat(r)}clipTo(e,t=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),t<ne&&(this.front&&this.front.clipTo(e,t+1),this.back&&this.back.clipTo(e,t+1))}allPolygons(e=[]){for(let t=0;t<this.polygons.length;t++)e.push(this.polygons[t]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,t=0){if(!e.length)return;if(!this.hasPlane){let a=e[e.length>>1];this.nx=a.nx,this.ny=a.ny,this.nz=a.nz,this.w=a.w,this.hasPlane=!0}if(t>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let s=[],r=[];for(let a=0;a<e.length;a++)Ae(this.nx,this.ny,this.nz,this.w,e[a],this.polygons,this.polygons,s,r);s.length>0&&(this.front||(this.front=new ue),this.front.build(s,t+1)),r.length>0&&(this.back||(this.back=new ue),this.back.build(r,t+1))}}function Ne(n,e){if(!e&&n._csgPolygons)return n._csgPolygons;let t=n.attributes.position;if(!t||t.count===0)return[];let s=n.attributes.normal,r=n.attributes.uv,a=n.index?n.index.array:null,c=Math.floor(a?a.length/3:t.count/3);if(c>ae)throw new RangeError(`SecurityError: CSG input triangle count (${c}) exceeds MAX_CSG_TRIANGLES (${ae})`);let u=e?e.elements:null,l=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=i=>{let f=t.getX(i),x=t.getY(i),p=t.getZ(i),b=s?s.getX(i):NaN,y=s?s.getY(i):NaN,g=s?s.getZ(i):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,_=o[2]*b+o[5]*y+o[8]*g,I=Math.hypot(k,T,_)||1;b=k/I,y=T/I,g=_/I}let S=r?r.getX(i):0,d=r?r.getY(i):0;return{x:f,y:x,z:p,nx:b,ny:y,nz:g,u:S,v:d}},h=[];for(let i=0;i<c;i++){let f=a?a[i*3]:i*3,x=a?a[i*3+1]:i*3+1,p=a?a[i*3+2]:i*3+2,b=xn(l?[m(f),m(p),m(x)]:[m(f),m(x),m(p)]);b&&h.push(b)}return h}function pn(n){let e=[],t=[],s=[],r=[];for(let c of n){let u=c.vertices;if(u.length<3)continue;let l=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?t.push(o.nx,o.ny,o.nz):t.push(c.nx,c.ny,c.nz),s.push(o.u,o.v);for(let o=1;o<u.length-1;o++)r.push(l,l+o,l+o+1)}let a=xe(new ee,e,t,s,r);return a._csgPolygons=n,a}function gn(n,e,t){if(n.length+e.length>ae)throw new RangeError(`SecurityError: Combined CSG triangle count (${n.length+e.length}) exceeds MAX_CSG_TRIANGLES (${ae})`);if(n.length===0)return t==="union"?e:[];if(e.length===0)return t==="intersect"?[]:n;let s=1/0,r=1/0,a=1/0,c=-1/0,u=-1/0,l=-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<a&&(a=b.z),b.x>c&&(c=b.x),b.y>u&&(u=b.y),b.z>l&&(l=b.z)}}s-=1e-4,r-=1e-4,a-=1e-4,c+=1e-4,u+=1e-4,l+=1e-4;let o=[],m=[];for(let f=0;f<n.length;f++){let x=n[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>c||d<r||y>u||M<a||g>l?m.push(x):o.push(x)}if(o.length===0)return t==="union"?n.concat(e):t==="subtract"?n:[];let h=new ue(o),i=new ue(e);return t==="union"?(h.clipTo(i),i.clipTo(h),i.invert(),i.clipTo(h),i.invert(),h.build(i.allPolygons()),m.concat(h.allPolygons())):t==="subtract"?(h.invert(),h.clipTo(i),i.clipTo(h),i.invert(),i.clipTo(h),i.invert(),h.build(i.allPolygons()),h.invert(),m.concat(h.allPolygons())):(h.invert(),i.clipTo(h),i.invert(),h.clipTo(i),i.clipTo(h),h.build(i.allPolygons()),h.invert(),h.allPolygons())}function Xe(n,e,t,s=null,r=null){let a=Ne(n,s),c=Ne(e,r);return pn(gn(a,c,t))}function Me(n,e,t){let s=n instanceof he||!!n?.isMesh,r=e instanceof he||!!e?.isMesh,a=s?n.geometry:n,c=r?e.geometry:e,u=null;if(r)if(e.updateMatrix(),s){n.updateMatrix();let h=new de().makeScale(1/(n.scale.x||1),1/(n.scale.y||1),1/(n.scale.z||1)),i=Math.hypot(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w)||1,f=new de().compose(new ke(0,0,0),new on(-n.quaternion.x/i,-n.quaternion.y/i,-n.quaternion.z/i,n.quaternion.w/i),new ke(1,1,1)),x=new de().makeTranslation(-n.position.x,-n.position.y,-n.position.z);u=h.multiply(f).multiply(x).multiply(e.matrix)}else u=e.matrix;let l=Xe(a,c,t,null,u),o=s?n.material:new Ce,m=new he(l,o);return s&&(m.position.copy(n.position),m.quaternion.copy(n.quaternion),m.scale.copy(n.scale),m.name=n.name),m}let pe={toGeometry:Xe,subtract(n,e){return Me(n,e,"subtract")},union(n,e){return Me(n,e,"union")},intersect(n,e){return Me(n,e,"intersect")}},Be={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 De extends ee{constructor(e="",t={}){super();let s=String(e??"").slice(0,Te),r=Math.max(.005,Math.min(100,B(t.size,.2))),a=!!(t.bevelEnabled??!1),c=a?Math.max(0,Math.min(2,B(t.bevelThickness,r*.04))):0,u=a?Math.max(0,Math.min(2,B(t.bevelSize,r*.03))):0,l=Math.max(.001,Math.min(20,B(t.depth??t.height,r*.2)))+c*2,o=r*.085+u,m=r*.68,h=r*.82,i=[],f=[],x=[],p=[],b=(S,d,M,P,w,k,T)=>{let _=M-S,I=P-d,X=Math.hypot(_,I),V=1,O=0;X>1e-6&&(V=_/X,O=I/X);let te=-O*w,se=V*w,j=V*w*.6,q=O*w*.6,A=S-j+te,Y=d-q+se,v=S-j-te,G=d-q-se,C=M+j-te,R=P+q-se,z=M+j+te,N=P+q+se,F=(W,$,U,Z,K,Q,J)=>{let H=i.length/3;i.push(W[0],W[1],W[2],$[0],$[1],$[2],U[0],U[1],U[2],Z[0],Z[1],Z[2]),f.push(K,Q,J,K,Q,J,K,Q,J,K,Q,J),x.push(0,0,1,0,1,1,0,1),p.push(H,H+1,H+2,H,H+2,H+3)};F([A,Y,T],[v,G,T],[C,R,T],[z,N,T],0,0,1),F([v,G,k],[A,Y,k],[z,N,k],[C,R,k],0,0,-1),F([A,Y,k],[v,G,k],[v,G,T],[A,Y,T],-V,-O,0),F([C,R,k],[z,N,k],[z,N,T],[C,R,T],V,O,0),F([v,G,k],[C,R,k],[C,R,T],[v,G,T],O,-V,0),F([z,N,k],[A,Y,k],[A,Y,T],[z,N,T],-O,V,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+=h*(d===" "?.75:3);continue}if(d==="\r")continue;let M=d.toUpperCase(),P=d!==M&&d>="a"&&d<="z",w=Be[M]??Be["?"],k=P?r*.76:r,T=P?m*.88:m;for(let _ of w)for(let I=0;I<_.length-1;I++){let X=_[I],V=_[I+1];b(y+X[0]*T,g+X[1]*k,y+V[0]*T,g+V[1]*k,o,-l*.5,l*.5)}y+=P?h*.88:h}xe(this,i,f,x,p),t.center!==!1?this.center():this.computeBoundingBox()}}function Oe(n){if(!n)return;let e=n,t=n.userData?.xr?.text;if(t!=null&&t!==!1){let r=e.geometry?.attributes?.position;if((!r||r.count===0)&&n.userData._textApplied!==!0){let a="",c=.08,u=.015,l;if(typeof t=="string"||typeof t=="number")a=String(t);else if(typeof t=="object"){let o=t;a=String(o.text??o.value??""),o.size!==void 0&&(c=Number(o.size)||.08),(o.depth!==void 0||o.height!==void 0)&&(u=Number(o.depth??o.height)||c*.2),(typeof o.color=="string"||typeof o.color=="number")&&(l=o.color)}a.trim().length>0&&(e.geometry=new De(a,{size:c,depth:u}),n.userData._textApplied=!0,e.material instanceof an?l!==void 0&&n.userData._autoTextColorApplied!==!0&&(e.material.color=new cn(l),n.userData._autoTextColorApplied=!0):e.material=new Ce({color:l??16317180}))}}let s=n.userData?.csg;if(s&&typeof s=="object"&&n.userData._csgApplied!==!0&&e.geometry instanceof ee&&e.geometry.attributes.position?.count>0){n.userData._csgApplied=!0;let r=Array.isArray(s)?s:[s],a=e.geometry;for(let c of r){if(!c||typeof c!="object")continue;let u=c,l=String(u.op??u.operation??"subtract"),o=l==="union"||l==="intersect"?l:"subtract",m=u.target??u.mesh??u.geometry;if(m instanceof he||m instanceof ee)try{let h=o==="union"?pe.union(e,m):o==="intersect"?pe.intersect(e,m):pe.subtract(e,m);e.geometry!==a&&e.geometry.dispose?.(),e.geometry=h.geometry}catch(h){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",h)}}}}let Ye={Path:me,Shape:ye,ShapeGeometry:ln,ExtrudeGeometry:mn,TextGeometry:De,CSG:pe,MAX_CSG_TRIANGLES:ae,MAX_BSP_DEPTH:ne,MAX_TEXT_GEOMETRY_CHARS:Te,MAX_SHAPE_POINTS:Se,materializeDeclarativeGeometry:Oe};return E&&typeof E=="object"&&(E.authorNamespace||(E.authorNamespace={}),Object.assign(E.authorNamespace,Ye),E.materializeDeclarativeGeometry=Oe),Ye}var sn={name:"cad",onRegister(){nn(Ge);let L=le(),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 S=typeof globalThis<"u"?globalThis:{};if(!S[me]){let E={plugins:[],decoders:new Map};try{Object.defineProperty(S,me,{value:E,writable:!1,configurable:!1,enumerable:!1})}catch{S[me]=E}}return S[me]}var bt=be().plugins;function pt(S){let E=be();E.workerExtensionInstallers||(E.workerExtensionInstallers=[]),E.workerExtensionInstallers.includes(S)||E.workerExtensionInstallers.push(S)}function yt(S){let E=be().plugins;E.some(L=>L.name===S.name)||E.push(S),S.onRegister?.()}var xt=8192,ft=2048,gt=128,mt=4096;function we(S,E){if(!S||!S.BufferGeometry)return null;let L=S.Vector2,Ne=S.Vector3,We=S.Quaternion,Me=S.Matrix4,Ze=S.Matrix3,Ue=S.Color,de=S.BufferAttribute,U=S.BufferGeometry,Ke=S.Material,Te=S.MeshStandardMaterial,ue=S.Mesh,le=8192,K=2048,_e=128,ze=4096,H=(t,e)=>{let r=t==null?NaN:Number(t);return Number.isFinite(r)?r:e};class ce{constructor(e){this.currentPoint=new L(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 r=1;r<e.length;r++)this.lineTo(e[r].x,e[r].y);return this}moveTo(e,r){let s=Number(e)||0,n=Number(r)||0;return this.currentPoint.set(s,n),this.segments.push({type:"move",pts:[s,n]}),this}lineTo(e,r){let s=Number(e)||0,n=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(s,n),this.segments.push({type:"line",pts:[s,n]}),this}quadraticCurveTo(e,r,s,n){let l=this.currentPoint.x,h=this.currentPoint.y,u=Number(e)||0,c=Number(r)||0,i=Number(s)||0,p=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[l,h]}),this.currentPoint.set(i,p),this.segments.push({type:"quad",pts:[l,h,u,c,i,p]}),this}bezierCurveTo(e,r,s,n,l,h){let u=this.currentPoint.x,c=this.currentPoint.y,i=Number(e)||0,p=Number(r)||0,a=Number(s)||0,o=Number(n)||0,y=Number(l)||0,f=Number(h)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,c]}),this.currentPoint.set(y,f),this.segments.push({type:"cubic",pts:[u,c,i,p,a,o,y,f]}),this}absarc(e,r,s,n,l,h=!1){return this.absellipse(e,r,s,s,n,l,h,0)}arc(e,r,s,n,l,h=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(r)||0),s,n,l,h)}absellipse(e,r,s,n,l,h,u=!1,c=0){let i=Number(e)||0,p=Number(r)||0,a=Math.max(0,Number(s)||0),o=Math.max(0,Number(n)||0),y=Number(l)||0,f=Number(h)||0,b=u?1:0,g=Number(c)||0;this.segments.push({type:"arc",pts:[i,p,a,o,y,f,b,g]});let x=Math.cos(g),m=Math.sin(g),d=a*Math.cos(f),M=o*Math.sin(f);return this.currentPoint.set(i+d*x-M*m,p+d*m+M*x),this}ellipse(e,r,s,n,l,h,u=!1,c=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(r)||0),s,n,l,h,u,c)}closePath(){if(this.segments.length>0){let e=this.segments[0],r=0,s=0;if(e.type==="arc"){let n=e.pts[0],l=e.pts[1],h=e.pts[2],u=e.pts[3],c=e.pts[4],i=e.pts[7],p=Math.cos(i),a=Math.sin(i),o=h*Math.cos(c),y=u*Math.sin(c);r=n+o*p-y*a,s=l+o*a+y*p}else r=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-r,this.currentPoint.y-s)>1e-6&&this.lineTo(r,s)}return this}getPoints(e=12){let r=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],n=(l,h)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-l,u.y-h)<1e-6)return}s.push(new L(l,h))};for(let l of this.segments){let h=l.pts;if(l.type==="move"||l.type==="line")n(h[0],h[1]);else if(l.type==="quad"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5];n(u,c);for(let y=1;y<=r;y++){let f=y/r,b=1-f;n(b*b*u+2*b*f*i+f*f*a,b*b*c+2*b*f*p+f*f*o)}}else if(l.type==="cubic"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5],y=h[6],f=h[7];n(u,c);for(let b=1;b<=r;b++){let g=b/r,x=1-g,m=x*x,d=g*g;n(m*x*u+3*m*g*i+3*x*d*a+d*g*y,m*x*c+3*m*g*p+3*x*d*o+d*g*f)}}else if(l.type==="arc"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5],y=h[6]!==0,f=h[7],b=Math.PI*2,g=o-a,x=Math.abs(g)<1e-9;for(;g<0;)g+=b;for(;g>b;)g-=b;g<1e-9&&(g=x?0:b),y&&!x&&(g=g===b?-b:g-b);let m=Math.cos(f),d=Math.sin(f),M=Math.max(2,r);for(let P=0;P<=M;P++){let z=P/M,v=a+z*g,w=i*Math.cos(v),_=p*Math.sin(v);n(u+w*m-_*d,c+w*d+_*m)}}}if(s.length>2){let l=s[0],h=s[s.length-1];Math.hypot(l.x-h.x,l.y-h.y)<1e-6&&s.pop()}return s}getSpacedPoints(e=12){return this.getPoints(e)}clone(){let e=new this.constructor;return e.currentPoint.copy(this.currentPoint),e.segments=this.segments.map(r=>({type:r.type,pts:[...r.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(r=>r.clone())),e}}class pe extends ce{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(r=>r.getPoints(e))}}}function ye(t){let e=0,r=t.length;for(let s=0,n=r-1;s<r;n=s++)e+=t[n].x*t[s].y-t[s].x*t[n].y;return e*.5}function et(t,e,r,s,n,l,h,u){let c=h-r,i=u-s,p=n-r,a=l-s,o=t-r,y=e-s,f=c*c+i*i,b=c*p+i*a,g=c*o+i*y,x=p*p+a*a,m=p*o+a*y,d=f*x-b*b;if(Math.abs(d)<1e-12)return!1;let M=1/d,P=(x*g-b*m)*M,z=(f*m-b*g)*M;return P>=-1e-7&&z>=-1e-7&&P+z<=1+1e-7}function Ee(t,e){let r=t.slice();ye(r)<0&&r.reverse();let s=r.map(c=>new L(c.x,c.y)),n=r.map((c,i)=>i),l=[];for(let c of e){if(!c||c.length<3)continue;let i=c.slice();ye(i)>0&&i.reverse();let p=[],a=-1/0,o=0;for(let y=0;y<i.length;y++){let f=i[y],b=s.length;s.push(new L(f.x,f.y)),p.push(b),f.x>a&&(a=f.x,o=y)}l.push({pts:i,indices:p,maxX:a,maxIdx:o})}l.sort((c,i)=>i.maxX-c.maxX);let h=(c,i,p)=>(i.x-c.x)*(p.y-c.y)-(i.y-c.y)*(p.x-c.x),u=(c,i,p)=>{for(let a=0;a<p.length;a++){let o=p[a],y=p[(a+1)%p.length];if(h(c,i,o)*h(c,i,y)<0&&h(o,y,c)*h(o,y,i)<0)return!0}return!1};for(let c of l){let i=c.pts[c.maxIdx],p=i.x,a=n.length,o=n.map(x=>s[x]),y=x=>Math.hypot(o[x].x-p,o[x].y-i.y),f=o.map((x,m)=>m).sort((x,m)=>+(o[x].x<p)-+(o[m].x<p)||y(x)-y(m)),b=f[0];for(let x of f){let m=o[x],d=o[(x+a-1)%a],M=o[(x+1)%a],P=h(m,M,i)>=0,z=h(d,m,i)>=0;if((h(d,m,M)>=0?P&&z:P||z)&&!u(i,m,o)&&!l.some(v=>u(i,m,v.pts))){b=x;break}}let g=[];for(let x=0;x<=b;x++)g.push(n[x]);for(let x=0;x<=c.indices.length;x++){let m=c.indices[(c.maxIdx+x)%c.indices.length];g.push(m)}for(let x=b;x<n.length;x++)g.push(n[x]);n=g}return{merged:n.map(c=>s[c]),mergedIndices:n,allVertices:s}}function Ae(t,e){let r=[],s=t.slice();if(s.length<3)return r;let n=s.length*s.length+64,l=0;for(;s.length>2&&n-- >0;){let h=s.length,u=s[(l+h-1)%h],c=s[l%h],i=s[(l+1)%h],p=e[u],a=e[c],o=e[i];if((a.x-p.x)*(o.y-p.y)-(a.y-p.y)*(o.x-p.x)>1e-9){let y=!0,f=Math.min(p.x,a.x,o.x)-1e-7,b=Math.max(p.x,a.x,o.x)+1e-7,g=Math.min(p.y,a.y,o.y)-1e-7,x=Math.max(p.y,a.y,o.y)+1e-7;for(let m=0;m<h;m++){let d=s[m];if(d===u||d===c||d===i)continue;let M=e[d];if(M.x>=f&&M.x<=b&&M.y>=g&&M.y<=x&&et(M.x,M.y,p.x,p.y,a.x,a.y,o.x,o.y)&&(M.x-p.x)*(M.x-p.x)+(M.y-p.y)*(M.y-p.y)>=1e-12&&(M.x-a.x)*(M.x-a.x)+(M.y-a.y)*(M.y-a.y)>=1e-12&&(M.x-o.x)*(M.x-o.x)+(M.y-o.y)*(M.y-o.y)>=1e-12){y=!1;break}}if(y){r.push([u,c,i]),s.splice(l%h,1),l=Math.max(0,l%h-1);continue}}l++,l>=h*2&&(r.push([u,c,i]),s.splice((l-1)%h,1),l=0)}return r}function ke(t,e){let r=t instanceof pe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},s=r.shape.length;for(let n of r.holes)s+=n.length;if(s>ze)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${ze})`);return r}function Ie(t){let e=1/0,r=1/0,s=-1/0,n=-1/0;for(let l of t)l.x<e&&(e=l.x),l.y<r&&(r=l.y),l.x>s&&(s=l.x),l.y>n&&(n=l.y);return[e,r,Math.max(1e-6,s-e),Math.max(1e-6,n-r)]}class tt extends U{constructor(e=new pe,r=12){super();let s=Array.isArray(e)?e:[e],n=[],l=[],h=[],u=[];for(let c of s){if(!(c instanceof ce))continue;let i=ke(c,r);if(i.shape.length<3)continue;let{mergedIndices:p,allVertices:a}=Ee(i.shape,i.holes),o=Ae(p,a),y=n.length/3,[f,b,g,x]=Ie(a);for(let m of a)n.push(m.x,m.y,0),l.push(0,0,1),h.push((m.x-f)/g,(m.y-b)/x);for(let[m,d,M]of o)u.push(y+m,y+d,y+M)}xe(this,n,l,h,u)}}function xe(t,e,r,s,n){return t.setAttribute("position",new de(e,3)),t.setAttribute("normal",new de(r,3)),t.setAttribute("uv",new de(s,2)),t.setIndex(n),t}function rt(t){let e=t.length,r=[];for(let s=0;s<e;s++){let n=t[(s+e-1)%e],l=t[s],h=t[(s+1)%e],u=l.x-n.x,c=l.y-n.y,i=Math.hypot(u,c)||1;u/=i,c/=i;let p=h.x-l.x,a=h.y-l.y,o=Math.hypot(p,a)||1;p/=o,a/=o;let y=c,f=-u,b=a,g=-p,x=y+b,m=f+g,d=Math.hypot(x,m);if(d>1e-6){x/=d,m/=d;let M=Math.max(.35,x*y+m*f);r.push(new L(x/M,m/M))}else r.push(new L(y,f))}return r}class st extends U{constructor(e=new pe,r={}){super();let s=Array.isArray(e)?e:[e],n=Math.max(1,Math.min(64,Math.floor(H(r.curveSegments,12)))),l=H(r.depth??r.amount,1),h=Math.max(1,Math.min(32,Math.floor(H(r.steps,1)))),u=!!(r.bevelEnabled??!1),c=u?Math.max(0,H(r.bevelThickness,.06)):0,i=u?Math.max(0,H(r.bevelSize,c*.8)):0,p=u?H(r.bevelOffset,0):0,a=u?Math.max(1,Math.min(8,Math.floor(H(r.bevelSegments,2)))):0,o=[],y=[],f=[],b=[];for(let g of s){if(!(g instanceof ce))continue;let x=ke(g,n);if(x.shape.length<3)continue;let m=x.shape.slice();ye(m)<0&&m.reverse();let d=[];for(let T of x.holes){if(T.length<3)continue;let N=T.slice();ye(N)>0&&N.reverse(),d.push(N)}let{mergedIndices:M,allVertices:P}=Ee(m,d),z=Ae(M,P),v=[m,...d],w=[];for(let T of v){let N=rt(T);for(let R of N)w.push(R)}let[_,B,D,Y]=Ie(P);for(let[T,N]of[[-c,-1],[l+c,1]]){let R=o.length/3;for(let X=0;X<P.length;X++){let k=P[X],I=w[X]??new L(0,0),C=k.x+I.x*p,q=k.y+I.y*p;o.push(C,q,T),y.push(0,0,N),f.push((C-_)/D,(q-B)/Y)}for(let[X,k,I]of z)b.push(R+X,R+(N<0?I:k),R+(N<0?k:I))}let A=[];if(u&&a>0)for(let T=0;T<a;T++){let N=T/a*Math.PI/2;A.push({z:-c*Math.cos(N),expand:p+i*Math.sin(N)})}for(let T=0;T<=h;T++){let N=T/h;A.push({z:N*l,expand:p+i})}if(u&&a>0)for(let T=1;T<=a;T++){let N=T/a*Math.PI/2;A.push({z:l+c*Math.sin(N),expand:p+i*Math.cos(N)})}let G=0;for(let T of v){let N=T.length;for(let R=0;R<A.length-1;R++){let X=A[R],k=A[R+1];for(let I=0;I<N;I++){let C=(I+1)%N,q=T[I],O=T[C],V=w[G+I],$=w[G+C],j=q.x+V.x*X.expand,F=q.y+V.y*X.expand,ee=O.x+$.x*X.expand,te=O.y+$.y*X.expand,he=O.x+$.x*k.expand,ae=O.y+$.y*k.expand,J=q.x+V.x*k.expand,W=q.y+V.y*k.expand,Z=ee-j,Q=te-F,ut=J-j,ct=W-F,Ye=k.z-X.z,re=Q*Ye,se=-Z*Ye,ne=Z*ct-Q*ut,Se=Math.hypot(re,se,ne)||1;re/=Se,se/=Se,ne/=Se;let ie=o.length/3;o.push(j,F,X.z,ee,te,X.z,he,ae,k.z,J,W,k.z),y.push(re,se,ne,re,se,ne,re,se,ne,re,se,ne);let je=I/N,Fe=(I+1)/N,Le=R/(A.length-1),Qe=(R+1)/(A.length-1);f.push(je,Le,Fe,Le,Fe,Qe,je,Qe),b.push(ie,ie+1,ie+2,ie,ie+2,ie+3)}}G+=N}}xe(this,o,y,f,b)}}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 nt(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 it(t,e,r){let s=t.nx+(e.nx-t.nx)*r,n=t.ny+(e.ny-t.ny)*r,l=t.nz+(e.nz-t.nz)*r,h=Math.hypot(s,n,l)||1;return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r,z:t.z+(e.z-t.z)*r,nx:s/h,ny:n/h,nz:l/h,u:t.u+(e.u-t.u)*r,v:t.v+(e.v-t.v)*r}}function lt(t){if(t.length<3)return null;let e=t[0],r=t[1],s=t[2],n=r.x-e.x,l=r.y-e.y,h=r.z-e.z,u=s.x-e.x,c=s.y-e.y,i=s.z-e.z,p=l*i-h*c,a=h*u-n*i,o=n*c-l*u,y=Math.hypot(p,a,o);if(y<1e-9)return null;p/=y,a/=y,o/=y;let f=p*e.x+a*e.y+o*e.z;return{vertices:t,nx:p,ny:a,nz:o,w:f}}function ot(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=nt(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Re=1e-5,De=0,ve=1,fe=2,qe=3;function Be(t,e,r,s,n,l,h,u,c){let i=0,p=[];for(let a=0;a<n.vertices.length;a++){let o=n.vertices[a],y=t*o.x+e*o.y+r*o.z-s,f=y<-Re?fe:y>Re?ve:De;i|=f,p.push(f)}switch(i){case De:{t*n.nx+e*n.ny+r*n.nz>0?l.push(n):h.push(n);break}case ve:u.push(n);break;case fe:c.push(n);break;case qe:{let a=[],o=[],y=n.vertices.length;for(let m=0;m<y;m++){let d=(m+1)%y,M=p[m],P=p[d],z=n.vertices[m],v=n.vertices[d];if(M!==fe&&a.push(z),M!==ve&&o.push(M!==fe?Xe(z):z),(M|P)===qe){let w=v.x-z.x,_=v.y-z.y,B=v.z-z.z,D=t*w+e*_+r*B,Y=Math.abs(D)>1e-12?(s-(t*z.x+e*z.y+r*z.z))/D:.5,A=it(z,v,Math.max(0,Math.min(1,Y)));a.push(A),o.push(Xe(A))}}let{nx:f,ny:b,nz:g,w:x}=n;a.length>=3&&u.push({vertices:a,nx:f,ny:b,nz:g,w:x}),o.length>=3&&c.push({vertices:o,nx:f,ny:b,nz:g,w:x});break}default:break}}class oe{constructor(e,r=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,r)}invert(){for(let r=0;r<this.polygons.length;r++)ot(this.polygons[r]);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,r=0){if(!this.hasPlane||e.length===0)return e.slice();if(r>=K)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${K})`);let s=[],n=[];for(let l=0;l<e.length;l++)Be(this.nx,this.ny,this.nz,this.w,e[l],s,n,s,n);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,r+1)),this.back?n=n.length>0?this.back.clipPolygons(n,r+1):[]:n=[],s.concat(n)}clipTo(e,r=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),r<K&&(this.front&&this.front.clipTo(e,r+1),this.back&&this.back.clipTo(e,r+1))}allPolygons(e=[]){for(let r=0;r<this.polygons.length;r++)e.push(this.polygons[r]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,r=0){if(!e.length)return;if(!this.hasPlane){let l=e[e.length>>1];this.nx=l.nx,this.ny=l.ny,this.nz=l.nz,this.w=l.w,this.hasPlane=!0}if(r>=K)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${K})`);let s=[],n=[];for(let l=0;l<e.length;l++)Be(this.nx,this.ny,this.nz,this.w,e[l],this.polygons,this.polygons,s,n);s.length>0&&(this.front||(this.front=new oe),this.front.build(s,r+1)),n.length>0&&(this.back||(this.back=new oe),this.back.build(n,r+1))}}function Ce(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let r=t.attributes.position;if(!r||r.count===0)return[];let s=t.attributes.normal,n=t.attributes.uv,l=t.index?t.index.array:null,h=Math.floor(l?l.length/3:r.count/3);if(h>le)throw new RangeError(`SecurityError: CSG input triangle count (${h}) exceeds MAX_CSG_TRIANGLES (${le})`);let u=e?e.elements:null,c=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,i=u?new Ze().getNormalMatrix(e).elements:null,p=o=>{let y=r.getX(o),f=r.getY(o),b=r.getZ(o),g=s?s.getX(o):NaN,x=s?s.getY(o):NaN,m=s?s.getZ(o):NaN;if(u&&i){let P=u[0]*y+u[4]*f+u[8]*b+u[12],z=u[1]*y+u[5]*f+u[9]*b+u[13],v=u[2]*y+u[6]*f+u[10]*b+u[14];y=P,f=z,b=v;let w=i[0]*g+i[3]*x+i[6]*m,_=i[1]*g+i[4]*x+i[7]*m,B=i[2]*g+i[5]*x+i[8]*m,D=Math.hypot(w,_,B)||1;g=w/D,x=_/D,m=B/D}let d=n?n.getX(o):0,M=n?n.getY(o):0;return{x:y,y:f,z:b,nx:g,ny:x,nz:m,u:d,v:M}},a=[];for(let o=0;o<h;o++){let y=l?l[o*3]:o*3,f=l?l[o*3+1]:o*3+1,b=l?l[o*3+2]:o*3+2,g=lt(c?[p(y),p(b),p(f)]:[p(y),p(f),p(b)]);g&&a.push(g)}return a}function ht(t){let e=[],r=[],s=[],n=[];for(let h of t){let u=h.vertices;if(u.length<3)continue;let c=e.length/3;for(let i of u)e.push(i.x,i.y,i.z),Number.isFinite(i.nx)&&i.nx*i.nx+i.ny*i.ny+i.nz*i.nz>.5?r.push(i.nx,i.ny,i.nz):r.push(h.nx,h.ny,h.nz),s.push(i.u,i.v);for(let i=1;i<u.length-1;i++)n.push(c,c+i,c+i+1)}let l=xe(new U,e,r,s,n);return l._csgPolygons=t,l}function at(t,e,r){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 r==="union"?e:[];if(e.length===0)return r==="intersect"?[]:t;let s=1/0,n=1/0,l=1/0,h=-1/0,u=-1/0,c=-1/0;for(let y=0;y<e.length;y++){let f=e[y].vertices;for(let b=0;b<f.length;b++){let g=f[b];g.x<s&&(s=g.x),g.y<n&&(n=g.y),g.z<l&&(l=g.z),g.x>h&&(h=g.x),g.y>u&&(u=g.y),g.z>c&&(c=g.z)}}s-=1e-4,n-=1e-4,l-=1e-4,h+=1e-4,u+=1e-4,c+=1e-4;let i=[],p=[];for(let y=0;y<t.length;y++){let f=t[y],b=f.vertices,g=1/0,x=1/0,m=1/0,d=-1/0,M=-1/0,P=-1/0;for(let z=0;z<b.length;z++){let v=b[z];v.x<g&&(g=v.x),v.y<x&&(x=v.y),v.z<m&&(m=v.z),v.x>d&&(d=v.x),v.y>M&&(M=v.y),v.z>P&&(P=v.z)}d<s||g>h||M<n||x>u||P<l||m>c?p.push(f):i.push(f)}if(i.length===0)return r==="union"?t.concat(e):r==="subtract"?t:[];let a=new oe(i),o=new oe(e);return r==="union"?(a.clipTo(o),o.clipTo(a),o.invert(),o.clipTo(a),o.invert(),a.build(o.allPolygons()),p.concat(a.allPolygons())):r==="subtract"?(a.invert(),a.clipTo(o),o.clipTo(a),o.invert(),o.clipTo(a),o.invert(),a.build(o.allPolygons()),a.invert(),p.concat(a.allPolygons())):(a.invert(),o.clipTo(a),o.invert(),a.clipTo(o),o.clipTo(a),a.build(o.allPolygons()),a.invert(),a.allPolygons())}function He(t,e,r,s=null,n=null){let l=Ce(t,s),h=Ce(e,n);return ht(at(l,h,r))}function Pe(t,e,r){let s=t instanceof ue||!!t?.isMesh,n=e instanceof ue||!!e?.isMesh,l=s?t.geometry:t,h=n?e.geometry:e,u=null;if(n)if(e.updateMatrix(),s){t.updateMatrix();let a=new Me().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),o=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,y=new Me().compose(new Ne(0,0,0),new We(-t.quaternion.x/o,-t.quaternion.y/o,-t.quaternion.z/o,t.quaternion.w/o),new Ne(1,1,1)),f=new Me().makeTranslation(-t.position.x,-t.position.y,-t.position.z);u=a.multiply(y).multiply(f).multiply(e.matrix)}else u=e.matrix;let c=He(l,h,r,null,u),i=s?t.material:new Te,p=new ue(c,i);return s&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let ge={toGeometry:He,subtract(t,e){return Pe(t,e,"subtract")},union(t,e){return Pe(t,e,"union")},intersect(t,e){return Pe(t,e,"intersect")}},Ge={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 U{constructor(e="",r={}){super();let s=String(e??"").slice(0,_e),n=Math.max(.005,Math.min(100,H(r.size,.2))),l=!!(r.bevelEnabled??!1),h=l?Math.max(0,Math.min(2,H(r.bevelThickness,n*.04))):0,u=l?Math.max(0,Math.min(2,H(r.bevelSize,n*.03))):0,c=Math.max(.001,Math.min(20,H(r.depth??r.height,n*.2)))+h*2,i=n*.085+u,p=n*.68,a=n*.82,o=[],y=[],f=[],b=[],g=(d,M,P,z,v,w,_)=>{let B=P-d,D=z-M,Y=Math.hypot(B,D),A=1,G=0;Y>1e-6&&(A=B/Y,G=D/Y);let T=-G*v,N=A*v,R=A*v*.6,X=G*v*.6,k=d-R+T,I=M-X+N,C=d-R-T,q=M-X-N,O=P+R-T,V=z+X-N,$=P+R+T,j=z+X+N,F=(ee,te,he,ae,J,W,Z)=>{let Q=o.length/3;o.push(ee[0],ee[1],ee[2],te[0],te[1],te[2],he[0],he[1],he[2],ae[0],ae[1],ae[2]),y.push(J,W,Z,J,W,Z,J,W,Z,J,W,Z),f.push(0,0,1,0,1,1,0,1),b.push(Q,Q+1,Q+2,Q,Q+2,Q+3)};F([k,I,_],[C,q,_],[O,V,_],[$,j,_],0,0,1),F([C,q,w],[k,I,w],[$,j,w],[O,V,w],0,0,-1),F([k,I,w],[C,q,w],[C,q,_],[k,I,_],-A,-G,0),F([O,V,w],[$,j,w],[$,j,_],[O,V,_],A,G,0),F([C,q,w],[O,V,w],[O,V,_],[C,q,_],G,-A,0),F([$,j,w],[k,I,w],[k,I,_],[$,j,_],-G,A,0)},x=0,m=0;for(let d=0;d<s.length;d++){let M=s[d];if(M===`
|
|
17
|
+
`){x=0,m-=n*1.35;continue}if(M===" "||M===" "){x+=a*(M===" "?.75:3);continue}if(M==="\r")continue;let P=M.toUpperCase(),z=M!==P&&M>="a"&&M<="z",v=Ge[P]??Ge["?"],w=z?n*.76:n,_=z?p*.88:p;for(let B of v)for(let D=0;D<B.length-1;D++){let Y=B[D],A=B[D+1];g(x+Y[0]*_,m+Y[1]*w,x+A[0]*_,m+A[1]*w,i,-c*.5,c*.5)}x+=z?a*.88:a}xe(this,o,y,f,b),r.center!==!1?this.center():this.computeBoundingBox()}}function Ve(t){if(!t)return;let e=t,r=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(r!=null&&r!==!1){let n=e.geometry?.attributes?.position;if((!n||n.count===0)&&t.userData._textApplied!==!0){let l="",h=.08,u=.015,c;if(typeof r=="string"||typeof r=="number")l=String(r);else if(typeof r=="object"){let i=r;l=String(i.text??i.value??""),i.size!==void 0&&(h=Number(i.size)||.08),(i.depth!==void 0||i.height!==void 0)&&(u=Number(i.depth??i.height)||h*.2),(typeof i.color=="string"||typeof i.color=="number")&&(c=i.color)}l.trim().length>0&&(e.geometry=new Oe(l,{size:h,depth:u}),t.userData._textApplied=!0,e.material instanceof Ke?c!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new Ue(c),t.userData._autoTextColorApplied=!0):e.material=new Te({color:c??16317180}))}}let s=t.userData?.csg;if(s&&typeof s=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof U&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let n=Array.isArray(s)?s:[s],l=e.geometry;for(let h of n){if(!h||typeof h!="object")continue;let u=h,c=String(u.op??u.operation??"subtract"),i=c==="union"||c==="intersect"?c:"subtract",p=u.target??u.mesh??u.geometry;if(p instanceof ue||p instanceof U)try{let a=i==="union"?ge.union(e,p):i==="intersect"?ge.intersect(e,p):ge.subtract(e,p);e.geometry!==l&&e.geometry.dispose?.(),e.geometry=a.geometry}catch(a){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",a)}}}}let $e={Path:ce,Shape:pe,ShapeGeometry:tt,ExtrudeGeometry:st,TextGeometry:Oe,CSG:ge,MAX_CSG_TRIANGLES:le,MAX_BSP_DEPTH:K,MAX_TEXT_GEOMETRY_CHARS:_e,MAX_SHAPE_POINTS:ze,materializeDeclarativeGeometry:Ve};return E&&typeof E=="object"&&(E.authorNamespace||(E.authorNamespace={}),Object.assign(E.authorNamespace,$e),E._cadMaterialize=Ve,E.materializeDeclarativeGeometry=t=>{E._cadMaterialize?.(t),E._lodMaterialize?.(t)}),$e}var Je={name:"cad",onRegister(){pt(we);let S=be(),E=S.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);E&&we(E,S)}};yt(Je);export{ft as MAX_BSP_DEPTH,xt as MAX_CSG_TRIANGLES,mt as MAX_SHAPE_POINTS,gt as MAX_TEXT_GEOMETRY_CHARS,Je as cadPlugin,we 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,ue)=>{if(L&&typeof L=="object"||typeof L=="function")for(let J of Cn(L))!Tn.call(M,J)&&J!==A&&Te(M,J,{get:()=>L[J],enumerable:!(ue=kn(L,J))||ue.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:()=>Se});var ve="__THREE_LIVE_REGISTRY__";function me(){let M=typeof globalThis<"u"?globalThis:{};if(!M[ve]){let L={plugins:[],decoders:new Map};try{Object.defineProperty(M,ve,{value:L,writable:!1,configurable:!1,enumerable:!1})}catch{M[ve]=L}}return M[ve]}var _n=me().plugins;function on(M){let L=me();L.workerExtensionInstallers||(L.workerExtensionInstallers=[]),L.workerExtensionInstallers.includes(M)||L.workerExtensionInstallers.push(M)}function rn(M){let L=me().plugins;L.some(A=>A.name===M.name)||L.push(M),M.onRegister?.()}var cn=8192,an=2048,un=128,ln=4096;function Se(M,L){if(!M||!M.BufferGeometry)return null;let A=M.Vector2,ue=M.Vector3,J=M.Quaternion,Pe=M.Matrix4,hn=M.Matrix3,mn=M.Color,Me=M.BufferAttribute,ne=M.BufferGeometry,yn=M.Material,Ee=M.MeshStandardMaterial,ye=M.Mesh,le=8192,te=2048,Re=128,we=4096,D=(n,e)=>{let t=n==null?NaN:Number(n);return Number.isFinite(t)?t:e};class fe{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 t=1;t<e.length;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){let s=Number(e)||0,r=Number(t)||0;return this.currentPoint.set(s,r),this.segments.push({type:"move",pts:[s,r]}),this}lineTo(e,t){let s=Number(e)||0,r=Number(t)||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,t,s,r){let a=this.currentPoint.x,c=this.currentPoint.y,u=Number(e)||0,l=Number(t)||0,o=Number(s)||0,m=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,c]}),this.currentPoint.set(o,m),this.segments.push({type:"quad",pts:[a,c,u,l,o,m]}),this}bezierCurveTo(e,t,s,r,a,c){let u=this.currentPoint.x,l=this.currentPoint.y,o=Number(e)||0,m=Number(t)||0,h=Number(s)||0,i=Number(r)||0,f=Number(a)||0,x=Number(c)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,l]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[u,l,o,m,h,i,f,x]}),this}absarc(e,t,s,r,a,c=!1){return this.absellipse(e,t,s,s,r,a,c,0)}arc(e,t,s,r,a,c=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),s,r,a,c)}absellipse(e,t,s,r,a,c,u=!1,l=0){let o=Number(e)||0,m=Number(t)||0,h=Math.max(0,Number(s)||0),i=Math.max(0,Number(r)||0),f=Number(a)||0,x=Number(c)||0,p=u?1:0,b=Number(l)||0;this.segments.push({type:"arc",pts:[o,m,h,i,f,x,p,b]});let y=Math.cos(b),g=Math.sin(b),S=h*Math.cos(x),d=i*Math.sin(x);return this.currentPoint.set(o+S*y-d*g,m+S*g+d*y),this}ellipse(e,t,s,r,a,c,u=!1,l=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),s,r,a,c,u,l)}closePath(){if(this.segments.length>0){let e=this.segments[0],t=0,s=0;if(e.type==="arc"){let r=e.pts[0],a=e.pts[1],c=e.pts[2],u=e.pts[3],l=e.pts[4],o=e.pts[7],m=Math.cos(o),h=Math.sin(o),i=c*Math.cos(l),f=u*Math.sin(l);t=r+i*m-f*h,s=a+i*h+f*m}else t=e.pts[0],s=e.pts[1];Math.hypot(this.currentPoint.x-t,this.currentPoint.y-s)>1e-6&&this.lineTo(t,s)}return this}getPoints(e=12){let t=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),s=[],r=(a,c)=>{if(s.length>0){let u=s[s.length-1];if(Math.hypot(u.x-a,u.y-c)<1e-6)return}s.push(new A(a,c))};for(let a of this.segments){let c=a.pts;if(a.type==="move"||a.type==="line")r(c[0],c[1]);else if(a.type==="quad"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5];r(u,l);for(let f=1;f<=t;f++){let x=f/t,p=1-x;r(p*p*u+2*p*x*o+x*x*h,p*p*l+2*p*x*m+x*x*i)}}else if(a.type==="cubic"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5],f=c[6],x=c[7];r(u,l);for(let p=1;p<=t;p++){let b=p/t,y=1-b,g=y*y,S=b*b;r(g*y*u+3*g*b*o+3*y*S*h+S*b*f,g*y*l+3*g*b*m+3*y*S*i+S*b*x)}}else if(a.type==="arc"){let u=c[0],l=c[1],o=c[2],m=c[3],h=c[4],i=c[5],f=c[6]!==0,x=c[7],p=Math.PI*2,b=i-h,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,t);for(let w=0;w<=d;w++){let P=w/d,G=h+P*b,C=o*Math.cos(G),E=m*Math.sin(G);r(u+C*g-E*S,l+C*S+E*g)}}}if(s.length>2){let a=s[0],c=s[s.length-1];Math.hypot(a.x-c.x,a.y-c.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(t=>t.getPoints(e))}}}function be(n){let e=0,t=n.length;for(let s=0,r=t-1;s<t;r=s++)e+=n[r].x*n[s].y-n[s].x*n[r].y;return e*.5}function fn(n,e,t,s,r,a,c,u){let l=c-t,o=u-s,m=r-t,h=a-s,i=n-t,f=e-s,x=l*l+o*o,p=l*m+o*h,b=l*i+o*f,y=m*m+h*h,g=m*i+h*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(n,e){let t=n.slice();be(t)<0&&t.reverse();let s=t.map(l=>new A(l.x,l.y)),r=t.map((l,o)=>o),a=[];for(let l of e){if(!l||l.length<3)continue;let o=l.slice();be(o)>0&&o.reverse();let m=[],h=-1/0,i=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>h&&(h=x.x,i=f)}a.push({pts:o,indices:m,maxX:h,maxIdx:i})}a.sort((l,o)=>o.maxX-l.maxX);let c=(l,o,m)=>(o.x-l.x)*(m.y-l.y)-(o.y-l.y)*(m.x-l.x),u=(l,o,m)=>{for(let h=0;h<m.length;h++){let i=m[h],f=m[(h+1)%m.length];if(c(l,o,i)*c(l,o,f)<0&&c(i,f,l)*c(i,f,o)<0)return!0}return!1};for(let l of a){let o=l.pts[l.maxIdx],m=o.x,h=r.length,i=r.map(y=>s[y]),f=y=>Math.hypot(i[y].x-m,i[y].y-o.y),x=i.map((y,g)=>g).sort((y,g)=>+(i[y].x<m)-+(i[g].x<m)||f(y)-f(g)),p=x[0];for(let y of x){let g=i[y],S=i[(y+h-1)%h],d=i[(y+1)%h],w=c(g,d,o)>=0,P=c(S,g,o)>=0;if((c(S,g,d)>=0?w&&P:w||P)&&!u(o,g,i)&&!a.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<=l.indices.length;y++){let g=l.indices[(l.maxIdx+y)%l.indices.length];b.push(g)}for(let y=p;y<r.length;y++)b.push(r[y]);r=b}return{merged:r.map(l=>s[l]),mergedIndices:r,allVertices:s}}function Ie(n,e){let t=[],s=n.slice();if(s.length<3)return t;let r=s.length*s.length+64,a=0;for(;s.length>2&&r-- >0;){let c=s.length,u=s[(a+c-1)%c],l=s[a%c],o=s[(a+1)%c],m=e[u],h=e[l],i=e[o];if((h.x-m.x)*(i.y-m.y)-(h.y-m.y)*(i.x-m.x)>1e-9){let x=!0;for(let p=0;p<c;p++){let b=s[p];if(b===u||b===l||b===o)continue;let y=e[b];if(fn(y.x,y.y,m.x,m.y,h.x,h.y,i.x,i.y)&&Math.hypot(y.x-m.x,y.y-m.y)>=1e-6&&Math.hypot(y.x-h.x,y.y-h.y)>=1e-6&&Math.hypot(y.x-i.x,y.y-i.y)>=1e-6){x=!1;break}}if(x){t.push([u,l,o]),s.splice(a%c,1),a=Math.max(0,a%c-1);continue}}a++,a>=c*2&&(t.push([u,l,o]),s.splice((a-1)%c,1),a=0)}return t}function _e(n,e){let t=n instanceof xe?n.extractPoints(e):{shape:n.getPoints(e),holes:[]},s=t.shape.length;for(let r of t.holes)s+=r.length;if(s>we)throw new RangeError(`SecurityError: shape point count (${s}) exceeds MAX_SHAPE_POINTS (${we})`);return t}class xn extends ne{constructor(e=new xe,t=12){super();let s=Array.isArray(e)?e:[e],r=[],a=[],c=[],u=[];for(let l of s){if(!(l instanceof fe))continue;let o=_e(l,t);if(o.shape.length<3)continue;let{mergedIndices:m,allVertices:h}=ze(o.shape,o.holes),i=Ie(m,h),f=r.length/3,x=1/0,p=1/0,b=-1/0,y=-1/0;for(let d of h)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 h)r.push(d.x,d.y,0),a.push(0,0,1),c.push((d.x-x)/g,(d.y-p)/S);for(let[d,w,P]of i)u.push(f+d,f+w,f+P)}pe(this,r,a,c,u)}}function pe(n,e,t,s,r){return n.setAttribute("position",new Me(e,3)),n.setAttribute("normal",new Me(t,3)),n.setAttribute("uv",new Me(s,2)),n.setIndex(r),n}function bn(n){let e=n.length,t=[];for(let s=0;s<e;s++){let r=n[(s+e-1)%e],a=n[s],c=n[(s+1)%e],u=a.x-r.x,l=a.y-r.y,o=Math.hypot(u,l)||1;u/=o,l/=o;let m=c.x-a.x,h=c.y-a.y,i=Math.hypot(m,h)||1;m/=i,h/=i;let f=l,x=-u,p=h,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);t.push(new A(y/d,g/d))}else t.push(new A(f,x))}return t}class pn extends ne{constructor(e=new xe,t={}){super();let s=Array.isArray(e)?e:[e],r=Math.max(1,Math.min(64,Math.floor(D(t.curveSegments,12)))),a=D(t.depth??t.amount,1),c=Math.max(1,Math.min(32,Math.floor(D(t.steps,1)))),u=!!(t.bevelEnabled??!1),l=u?Math.max(0,D(t.bevelThickness,.06)):0,o=u?Math.max(0,D(t.bevelSize,l*.8)):0,m=u?D(t.bevelOffset,0):0,h=u?Math.max(1,Math.min(8,Math.floor(D(t.bevelSegments,2)))):0,i=[],f=[],x=[],p=[];for(let b of s){if(!(b instanceof fe))continue;let y=_e(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 k=v.slice();be(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,_=1/0,I=-1/0,B=-1/0;for(let v of w)v.x<E&&(E=v.x),v.y<_&&(_=v.y),v.x>I&&(I=v.x),v.y>B&&(B=v.y);let V=Math.max(1e-6,I-E),O=Math.max(1e-6,B-_),se=-l,oe=a+l,j=i.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;i.push(R,z,se),f.push(0,0,-1),x.push((R-E)/V,(z-_)/O)}for(let[v,k,T]of P)p.push(j+v,j+T,j+k);let q=i.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;i.push(R,z,oe),f.push(0,0,1),x.push((R-E)/V,(z-_)/O)}for(let[v,k,T]of P)p.push(q+v,q+k,q+T);let N=[];if(u&&h>0)for(let v=0;v<h;v++){let T=v/h*Math.PI/2;N.push({z:-l*Math.cos(T),expand:m+o*Math.sin(T)})}for(let v=0;v<=c;v++){let k=v/c;N.push({z:k*a,expand:m+o})}if(u&&h>0)for(let v=1;v<=h;v++){let T=v/h*Math.PI/2;N.push({z:a+l*Math.sin(T),expand:m+o*Math.cos(T)})}let Y=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 F=(X+1)%k,W=v[X],$=v[F],U=C[Y+X],Z=C[Y+F],K=W.x+U.x*R.expand,Q=W.y+U.y*R.expand,ee=$.x+Z.x*R.expand,H=$.y+Z.y*R.expand,wn=$.x+Z.x*z.expand,Gn=$.y+Z.y*z.expand,qe=W.x+U.x*z.expand,We=W.y+U.y*z.expand,$e=ee-K,Ue=H-Q,Ze=0,Ke=qe-K,Qe=We-Q,Je=z.z-R.z,re=Ue*Je-Ze*Qe,ie=Ze*Ke-$e*Je,ce=$e*Qe-Ue*Ke,Ce=Math.hypot(re,ie,ce)||1;re/=Ce,ie/=Ce,ce/=Ce;let ae=i.length/3;i.push(K,Q,R.z,ee,H,R.z,wn,Gn,z.z,qe,We,z.z),f.push(re,ie,ce,re,ie,ce,re,ie,ce,re,ie,ce);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(ae,ae+1,ae+2,ae,ae+2,ae+3)}}Y+=k}}pe(this,i,f,x,p)}}function Ve(n){return{x:n.x,y:n.y,z:n.z,nx:n.nx,ny:n.ny,nz:n.nz,u:n.u,v:n.v}}function gn(n){return{x:n.x,y:n.y,z:n.z,nx:-n.nx,ny:-n.ny,nz:-n.nz,u:n.u,v:n.v}}function dn(n,e,t){let s=n.nx+(e.nx-n.nx)*t,r=n.ny+(e.ny-n.ny)*t,a=n.nz+(e.nz-n.nz)*t,c=Math.hypot(s,r,a)||1;return{x:n.x+(e.x-n.x)*t,y:n.y+(e.y-n.y)*t,z:n.z+(e.z-n.z)*t,nx:s/c,ny:r/c,nz:a/c,u:n.u+(e.u-n.u)*t,v:n.v+(e.v-n.v)*t}}function vn(n){if(n.length<3)return null;let e=n[0],t=n[1],s=n[2],r=t.x-e.x,a=t.y-e.y,c=t.z-e.z,u=s.x-e.x,l=s.y-e.y,o=s.z-e.z,m=a*o-c*l,h=c*u-r*o,i=r*l-a*u,f=Math.hypot(m,h,i);if(f<1e-9)return null;m/=f,h/=f,i/=f;let x=m*e.x+h*e.y+i*e.z;return{vertices:n,nx:m,ny:h,nz:i,w:x}}function Sn(n){n.vertices.reverse();for(let e=0;e<n.vertices.length;e++)n.vertices[e]=gn(n.vertices[e]);n.nx=-n.nx,n.ny=-n.ny,n.nz=-n.nz,n.w=-n.w}let Ae=1e-5,Ne=0,Ge=1,ge=2,Xe=3;function Be(n,e,t,s,r,a,c,u,l){let o=0,m=[];for(let h=0;h<r.vertices.length;h++){let i=r.vertices[h],f=n*i.x+e*i.y+t*i.z-s,x=f<-Ae?ge:f>Ae?Ge:Ne;o|=x,m.push(x)}switch(o){case Ne:{n*r.nx+e*r.ny+t*r.nz>0?a.push(r):c.push(r);break}case Ge:u.push(r);break;case ge:l.push(r);break;case Xe:{let h=[],i=[],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!==ge&&h.push(P),d!==Ge&&i.push(d!==ge?Ve(P):P),(d|w)===Xe){let C=G.x-P.x,E=G.y-P.y,_=G.z-P.z,I=n*C+e*E+t*_,B=Math.abs(I)>1e-12?(s-(n*P.x+e*P.y+t*P.z))/I:.5,V=dn(P,G,Math.max(0,Math.min(1,B)));h.push(V),i.push(Ve(V))}}let{nx:x,ny:p,nz:b,w:y}=r;h.length>=3&&u.push({vertices:h,nx:x,ny:p,nz:b,w:y}),i.length>=3&&l.push({vertices:i,nx:x,ny:p,nz:b,w:y});break}default:break}}class he{constructor(e,t=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,t)}invert(){for(let t=0;t<this.polygons.length;t++)Sn(this.polygons[t]);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,t=0){if(!this.hasPlane||e.length===0)return e.slice();if(t>=te)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${te})`);let s=[],r=[];for(let a=0;a<e.length;a++)Be(this.nx,this.ny,this.nz,this.w,e[a],s,r,s,r);return this.front&&s.length>0&&(s=this.front.clipPolygons(s,t+1)),this.back?r=r.length>0?this.back.clipPolygons(r,t+1):[]:r=[],s.concat(r)}clipTo(e,t=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),t<te&&(this.front&&this.front.clipTo(e,t+1),this.back&&this.back.clipTo(e,t+1))}allPolygons(e=[]){for(let t=0;t<this.polygons.length;t++)e.push(this.polygons[t]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,t=0){if(!e.length)return;if(!this.hasPlane){let a=e[e.length>>1];this.nx=a.nx,this.ny=a.ny,this.nz=a.nz,this.w=a.w,this.hasPlane=!0}if(t>=te)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${te})`);let s=[],r=[];for(let a=0;a<e.length;a++)Be(this.nx,this.ny,this.nz,this.w,e[a],this.polygons,this.polygons,s,r);s.length>0&&(this.front||(this.front=new he),this.front.build(s,t+1)),r.length>0&&(this.back||(this.back=new he),this.back.build(r,t+1))}}function De(n,e){if(!e&&n._csgPolygons)return n._csgPolygons;let t=n.attributes.position;if(!t||t.count===0)return[];let s=n.attributes.normal,r=n.attributes.uv,a=n.index?n.index.array:null,c=Math.floor(a?a.length/3:t.count/3);if(c>le)throw new RangeError(`SecurityError: CSG input triangle count (${c}) exceeds MAX_CSG_TRIANGLES (${le})`);let u=e?e.elements:null,l=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=i=>{let f=t.getX(i),x=t.getY(i),p=t.getZ(i),b=s?s.getX(i):NaN,y=s?s.getY(i):NaN,g=s?s.getZ(i):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,_=o[2]*b+o[5]*y+o[8]*g,I=Math.hypot(C,E,_)||1;b=C/I,y=E/I,g=_/I}let S=r?r.getX(i):0,d=r?r.getY(i):0;return{x:f,y:x,z:p,nx:b,ny:y,nz:g,u:S,v:d}},h=[];for(let i=0;i<c;i++){let f=a?a[i*3]:i*3,x=a?a[i*3+1]:i*3+1,p=a?a[i*3+2]:i*3+2,b=vn(l?[m(f),m(p),m(x)]:[m(f),m(x),m(p)]);b&&h.push(b)}return h}function Pn(n){let e=[],t=[],s=[],r=[];for(let c of n){let u=c.vertices;if(u.length<3)continue;let l=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?t.push(o.nx,o.ny,o.nz):t.push(c.nx,c.ny,c.nz),s.push(o.u,o.v);for(let o=1;o<u.length-1;o++)r.push(l,l+o,l+o+1)}let a=pe(new ne,e,t,s,r);return a._csgPolygons=n,a}function Mn(n,e,t){if(n.length+e.length>le)throw new RangeError(`SecurityError: Combined CSG triangle count (${n.length+e.length}) exceeds MAX_CSG_TRIANGLES (${le})`);if(n.length===0)return t==="union"?e:[];if(e.length===0)return t==="intersect"?[]:n;let s=1/0,r=1/0,a=1/0,c=-1/0,u=-1/0,l=-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<a&&(a=b.z),b.x>c&&(c=b.x),b.y>u&&(u=b.y),b.z>l&&(l=b.z)}}s-=1e-4,r-=1e-4,a-=1e-4,c+=1e-4,u+=1e-4,l+=1e-4;let o=[],m=[];for(let f=0;f<n.length;f++){let x=n[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>c||d<r||y>u||w<a||g>l?m.push(x):o.push(x)}if(o.length===0)return t==="union"?n.concat(e):t==="subtract"?n:[];let h=new he(o),i=new he(e);return t==="union"?(h.clipTo(i),i.clipTo(h),i.invert(),i.clipTo(h),i.invert(),h.build(i.allPolygons()),m.concat(h.allPolygons())):t==="subtract"?(h.invert(),h.clipTo(i),i.clipTo(h),i.invert(),i.clipTo(h),i.invert(),h.build(i.allPolygons()),h.invert(),m.concat(h.allPolygons())):(h.invert(),i.clipTo(h),i.invert(),h.clipTo(i),i.clipTo(h),h.build(i.allPolygons()),h.invert(),h.allPolygons())}function Oe(n,e,t,s=null,r=null){let a=De(n,s),c=De(e,r);return Pn(Mn(a,c,t))}function ke(n,e,t){let s=n instanceof ye||!!n?.isMesh,r=e instanceof ye||!!e?.isMesh,a=s?n.geometry:n,c=r?e.geometry:e,u=null;if(r)if(e.updateMatrix(),s){n.updateMatrix();let h=new Pe().makeScale(1/(n.scale.x||1),1/(n.scale.y||1),1/(n.scale.z||1)),i=Math.hypot(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w)||1,f=new Pe().compose(new ue(0,0,0),new J(-n.quaternion.x/i,-n.quaternion.y/i,-n.quaternion.z/i,n.quaternion.w/i),new ue(1,1,1)),x=new Pe().makeTranslation(-n.position.x,-n.position.y,-n.position.z);u=h.multiply(f).multiply(x).multiply(e.matrix)}else u=e.matrix;let l=Oe(a,c,t,null,u),o=s?n.material:new Ee,m=new ye(l,o);return s&&(m.position.copy(n.position),m.quaternion.copy(n.quaternion),m.scale.copy(n.scale),m.name=n.name),m}let de={toGeometry:Oe,subtract(n,e){return ke(n,e,"subtract")},union(n,e){return ke(n,e,"union")},intersect(n,e){return ke(n,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 Fe extends ne{constructor(e="",t={}){super();let s=String(e??"").slice(0,Re),r=Math.max(.005,Math.min(100,D(t.size,.2))),a=!!(t.bevelEnabled??!1),c=a?Math.max(0,Math.min(2,D(t.bevelThickness,r*.04))):0,u=a?Math.max(0,Math.min(2,D(t.bevelSize,r*.03))):0,l=Math.max(.001,Math.min(20,D(t.depth??t.height,r*.2)))+c*2,o=r*.085+u,m=r*.68,h=r*.82,i=[],f=[],x=[],p=[],b=(S,d,w,P,G,C,E)=>{let _=w-S,I=P-d,B=Math.hypot(_,I),V=1,O=0;B>1e-6&&(V=_/B,O=I/B);let se=-O*G,oe=V*G,j=V*G*.6,q=O*G*.6,N=S-j+se,Y=d-q+oe,v=S-j-se,k=d-q-oe,T=w+j-se,R=P+q-oe,z=w+j+se,X=P+q+oe,F=(W,$,U,Z,K,Q,ee)=>{let H=i.length/3;i.push(W[0],W[1],W[2],$[0],$[1],$[2],U[0],U[1],U[2],Z[0],Z[1],Z[2]),f.push(K,Q,ee,K,Q,ee,K,Q,ee,K,Q,ee),x.push(0,0,1,0,1,1,0,1),p.push(H,H+1,H+2,H,H+2,H+3)};F([N,Y,E],[v,k,E],[T,R,E],[z,X,E],0,0,1),F([v,k,C],[N,Y,C],[z,X,C],[T,R,C],0,0,-1),F([N,Y,C],[v,k,C],[v,k,E],[N,Y,E],-V,-O,0),F([T,R,C],[z,X,C],[z,X,E],[T,R,E],V,O,0),F([v,k,C],[T,R,C],[T,R,E],[v,k,E],O,-V,0),F([z,X,C],[N,Y,C],[N,Y,E],[z,X,E],-O,V,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+=h*(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 _ of G)for(let I=0;I<_.length-1;I++){let B=_[I],V=_[I+1];b(y+B[0]*E,g+B[1]*C,y+V[0]*E,g+V[1]*C,o,-l*.5,l*.5)}y+=P?h*.88:h}pe(this,i,f,x,p),t.center!==!1?this.center():this.computeBoundingBox()}}function He(n){if(!n)return;let e=n,t=n.userData?.xr?.text;if(t!=null&&t!==!1){let r=e.geometry?.attributes?.position;if((!r||r.count===0)&&n.userData._textApplied!==!0){let a="",c=.08,u=.015,l;if(typeof t=="string"||typeof t=="number")a=String(t);else if(typeof t=="object"){let o=t;a=String(o.text??o.value??""),o.size!==void 0&&(c=Number(o.size)||.08),(o.depth!==void 0||o.height!==void 0)&&(u=Number(o.depth??o.height)||c*.2),(typeof o.color=="string"||typeof o.color=="number")&&(l=o.color)}a.trim().length>0&&(e.geometry=new Fe(a,{size:c,depth:u}),n.userData._textApplied=!0,e.material instanceof yn?l!==void 0&&n.userData._autoTextColorApplied!==!0&&(e.material.color=new mn(l),n.userData._autoTextColorApplied=!0):e.material=new Ee({color:l??16317180}))}}let s=n.userData?.csg;if(s&&typeof s=="object"&&n.userData._csgApplied!==!0&&e.geometry instanceof ne&&e.geometry.attributes.position?.count>0){n.userData._csgApplied=!0;let r=Array.isArray(s)?s:[s],a=e.geometry;for(let c of r){if(!c||typeof c!="object")continue;let u=c,l=String(u.op??u.operation??"subtract"),o=l==="union"||l==="intersect"?l:"subtract",m=u.target??u.mesh??u.geometry;if(m instanceof ye||m instanceof ne)try{let h=o==="union"?de.union(e,m):o==="intersect"?de.intersect(e,m):de.subtract(e,m);e.geometry!==a&&e.geometry.dispose?.(),e.geometry=h.geometry}catch(h){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",h)}}}}let je={Path:fe,Shape:xe,ShapeGeometry:xn,ExtrudeGeometry:pn,TextGeometry:Fe,CSG:de,MAX_CSG_TRIANGLES:le,MAX_BSP_DEPTH:te,MAX_TEXT_GEOMETRY_CHARS:Re,MAX_SHAPE_POINTS:we,materializeDeclarativeGeometry:He};return L&&typeof L=="object"&&(L.authorNamespace||(L.authorNamespace={}),Object.assign(L.authorNamespace,je),L.materializeDeclarativeGeometry=He),je}var Le={name:"cad",onRegister(){on(Se);let M=me(),L=M.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);L&&Se(L,M)}};rn(Le);return Rn(zn);})();
|
|
16
|
+
*/var ThreeLiveCAD=(()=>{var ve=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyNames,tt=Object.prototype.hasOwnProperty,rt=(v,S)=>{for(var D in S)ve(v,D,{get:S[D],enumerable:!0})},nt=(v,S,D,oe)=>{if(S&&typeof S=="object"||typeof S=="function")for(let W of et(S))!tt.call(v,W)&&W!==D&&ve(v,W,{get:()=>S[W],enumerable:!(oe=Ke(S,W))||oe.enumerable});return v},st=v=>nt(ve({},"__esModule",{value:!0}),v),Te={};rt(Te,{MAX_BSP_DEPTH:()=>ht,MAX_CSG_TRIANGLES:()=>ot,MAX_SHAPE_POINTS:()=>ut,MAX_TEXT_GEOMETRY_CHARS:()=>at,cadPlugin:()=>Ae,installCadExtension:()=>ze});var pe="__THREE_LIVE_REGISTRY__";function ye(){let v=typeof globalThis<"u"?globalThis:{};if(!v[pe]){let S={plugins:[],decoders:new Map};try{Object.defineProperty(v,pe,{value:S,writable:!1,configurable:!1,enumerable:!1})}catch{v[pe]=S}}return v[pe]}var Nt=ye().plugins;function it(v){let S=ye();S.workerExtensionInstallers||(S.workerExtensionInstallers=[]),S.workerExtensionInstallers.includes(v)||S.workerExtensionInstallers.push(v)}function lt(v){let S=ye().plugins;S.some(D=>D.name===v.name)||S.push(v),v.onRegister?.()}var ot=8192,ht=2048,at=128,ut=4096;function ze(v,S){if(!v||!v.BufferGeometry)return null;let D=v.Vector2,oe=v.Vector3,W=v.Quaternion,Pe=v.Matrix4,ct=v.Matrix3,pt=v.Color,Se=v.BufferAttribute,K=v.BufferGeometry,yt=v.Material,Ce=v.MeshStandardMaterial,fe=v.Mesh,he=8192,ee=2048,Ge=128,we=4096,q=(t,e)=>{let r=t==null?NaN:Number(t);return Number.isFinite(r)?r:e};class xe{constructor(e){this.currentPoint=new D(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 r=1;r<e.length;r++)this.lineTo(e[r].x,e[r].y);return this}moveTo(e,r){let n=Number(e)||0,s=Number(r)||0;return this.currentPoint.set(n,s),this.segments.push({type:"move",pts:[n,s]}),this}lineTo(e,r){let n=Number(e)||0,s=Number(r)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(n,s),this.segments.push({type:"line",pts:[n,s]}),this}quadraticCurveTo(e,r,n,s){let l=this.currentPoint.x,h=this.currentPoint.y,u=Number(e)||0,c=Number(r)||0,i=Number(n)||0,p=Number(s)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[l,h]}),this.currentPoint.set(i,p),this.segments.push({type:"quad",pts:[l,h,u,c,i,p]}),this}bezierCurveTo(e,r,n,s,l,h){let u=this.currentPoint.x,c=this.currentPoint.y,i=Number(e)||0,p=Number(r)||0,a=Number(n)||0,o=Number(s)||0,y=Number(l)||0,x=Number(h)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[u,c]}),this.currentPoint.set(y,x),this.segments.push({type:"cubic",pts:[u,c,i,p,a,o,y,x]}),this}absarc(e,r,n,s,l,h=!1){return this.absellipse(e,r,n,n,s,l,h,0)}arc(e,r,n,s,l,h=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(r)||0),n,s,l,h)}absellipse(e,r,n,s,l,h,u=!1,c=0){let i=Number(e)||0,p=Number(r)||0,a=Math.max(0,Number(n)||0),o=Math.max(0,Number(s)||0),y=Number(l)||0,x=Number(h)||0,b=u?1:0,g=Number(c)||0;this.segments.push({type:"arc",pts:[i,p,a,o,y,x,b,g]});let f=Math.cos(g),m=Math.sin(g),d=a*Math.cos(x),M=o*Math.sin(x);return this.currentPoint.set(i+d*f-M*m,p+d*m+M*f),this}ellipse(e,r,n,s,l,h,u=!1,c=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(r)||0),n,s,l,h,u,c)}closePath(){if(this.segments.length>0){let e=this.segments[0],r=0,n=0;if(e.type==="arc"){let s=e.pts[0],l=e.pts[1],h=e.pts[2],u=e.pts[3],c=e.pts[4],i=e.pts[7],p=Math.cos(i),a=Math.sin(i),o=h*Math.cos(c),y=u*Math.sin(c);r=s+o*p-y*a,n=l+o*a+y*p}else r=e.pts[0],n=e.pts[1];Math.hypot(this.currentPoint.x-r,this.currentPoint.y-n)>1e-6&&this.lineTo(r,n)}return this}getPoints(e=12){let r=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),n=[],s=(l,h)=>{if(n.length>0){let u=n[n.length-1];if(Math.hypot(u.x-l,u.y-h)<1e-6)return}n.push(new D(l,h))};for(let l of this.segments){let h=l.pts;if(l.type==="move"||l.type==="line")s(h[0],h[1]);else if(l.type==="quad"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5];s(u,c);for(let y=1;y<=r;y++){let x=y/r,b=1-x;s(b*b*u+2*b*x*i+x*x*a,b*b*c+2*b*x*p+x*x*o)}}else if(l.type==="cubic"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5],y=h[6],x=h[7];s(u,c);for(let b=1;b<=r;b++){let g=b/r,f=1-g,m=f*f,d=g*g;s(m*f*u+3*m*g*i+3*f*d*a+d*g*y,m*f*c+3*m*g*p+3*f*d*o+d*g*x)}}else if(l.type==="arc"){let u=h[0],c=h[1],i=h[2],p=h[3],a=h[4],o=h[5],y=h[6]!==0,x=h[7],b=Math.PI*2,g=o-a,f=Math.abs(g)<1e-9;for(;g<0;)g+=b;for(;g>b;)g-=b;g<1e-9&&(g=f?0:b),y&&!f&&(g=g===b?-b:g-b);let m=Math.cos(x),d=Math.sin(x),M=Math.max(2,r);for(let w=0;w<=M;w++){let z=w/M,P=a+z*g,N=i*Math.cos(P),T=p*Math.sin(P);s(u+N*m-T*d,c+N*d+T*m)}}}if(n.length>2){let l=n[0],h=n[n.length-1];Math.hypot(l.x-h.x,l.y-h.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(r=>({type:r.type,pts:[...r.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(r=>r.clone())),e}}class ge extends xe{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(r=>r.getPoints(e))}}}function me(t){let e=0,r=t.length;for(let n=0,s=r-1;n<r;s=n++)e+=t[s].x*t[n].y-t[n].x*t[s].y;return e*.5}function ft(t,e,r,n,s,l,h,u){let c=h-r,i=u-n,p=s-r,a=l-n,o=t-r,y=e-n,x=c*c+i*i,b=c*p+i*a,g=c*o+i*y,f=p*p+a*a,m=p*o+a*y,d=x*f-b*b;if(Math.abs(d)<1e-12)return!1;let M=1/d,w=(f*g-b*m)*M,z=(x*m-b*g)*M;return w>=-1e-7&&z>=-1e-7&&w+z<=1.0000001}function Ie(t,e){let r=t.slice();me(r)<0&&r.reverse();let n=r.map(c=>new D(c.x,c.y)),s=r.map((c,i)=>i),l=[];for(let c of e){if(!c||c.length<3)continue;let i=c.slice();me(i)>0&&i.reverse();let p=[],a=-1/0,o=0;for(let y=0;y<i.length;y++){let x=i[y],b=n.length;n.push(new D(x.x,x.y)),p.push(b),x.x>a&&(a=x.x,o=y)}l.push({pts:i,indices:p,maxX:a,maxIdx:o})}l.sort((c,i)=>i.maxX-c.maxX);let h=(c,i,p)=>(i.x-c.x)*(p.y-c.y)-(i.y-c.y)*(p.x-c.x),u=(c,i,p)=>{for(let a=0;a<p.length;a++){let o=p[a],y=p[(a+1)%p.length];if(h(c,i,o)*h(c,i,y)<0&&h(o,y,c)*h(o,y,i)<0)return!0}return!1};for(let c of l){let i=c.pts[c.maxIdx],p=i.x,a=s.length,o=s.map(f=>n[f]),y=f=>Math.hypot(o[f].x-p,o[f].y-i.y),x=o.map((f,m)=>m).sort((f,m)=>+(o[f].x<p)-+(o[m].x<p)||y(f)-y(m)),b=x[0];for(let f of x){let m=o[f],d=o[(f+a-1)%a],M=o[(f+1)%a],w=h(m,M,i)>=0,z=h(d,m,i)>=0;if((h(d,m,M)>=0?w&&z:w||z)&&!u(i,m,o)&&!l.some(P=>u(i,m,P.pts))){b=f;break}}let g=[];for(let f=0;f<=b;f++)g.push(s[f]);for(let f=0;f<=c.indices.length;f++){let m=c.indices[(c.maxIdx+f)%c.indices.length];g.push(m)}for(let f=b;f<s.length;f++)g.push(s[f]);s=g}return{merged:s.map(c=>n[c]),mergedIndices:s,allVertices:n}}function Xe(t,e){let r=[],n=t.slice();if(n.length<3)return r;let s=n.length*n.length+64,l=0;for(;n.length>2&&s-- >0;){let h=n.length,u=n[(l+h-1)%h],c=n[l%h],i=n[(l+1)%h],p=e[u],a=e[c],o=e[i];if((a.x-p.x)*(o.y-p.y)-(a.y-p.y)*(o.x-p.x)>1e-9){let y=!0,x=Math.min(p.x,a.x,o.x)-1e-7,b=Math.max(p.x,a.x,o.x)+1e-7,g=Math.min(p.y,a.y,o.y)-1e-7,f=Math.max(p.y,a.y,o.y)+1e-7;for(let m=0;m<h;m++){let d=n[m];if(d===u||d===c||d===i)continue;let M=e[d];if(M.x>=x&&M.x<=b&&M.y>=g&&M.y<=f&&ft(M.x,M.y,p.x,p.y,a.x,a.y,o.x,o.y)&&(M.x-p.x)*(M.x-p.x)+(M.y-p.y)*(M.y-p.y)>=1e-12&&(M.x-a.x)*(M.x-a.x)+(M.y-a.y)*(M.y-a.y)>=1e-12&&(M.x-o.x)*(M.x-o.x)+(M.y-o.y)*(M.y-o.y)>=1e-12){y=!1;break}}if(y){r.push([u,c,i]),n.splice(l%h,1),l=Math.max(0,l%h-1);continue}}l++,l>=h*2&&(r.push([u,c,i]),n.splice((l-1)%h,1),l=0)}return r}function ke(t,e){let r=t instanceof ge?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},n=r.shape.length;for(let s of r.holes)n+=s.length;if(n>we)throw new RangeError(`SecurityError: shape point count (${n}) exceeds MAX_SHAPE_POINTS (${we})`);return r}function De(t){let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let l of t)l.x<e&&(e=l.x),l.y<r&&(r=l.y),l.x>n&&(n=l.x),l.y>s&&(s=l.y);return[e,r,Math.max(1e-6,n-e),Math.max(1e-6,s-r)]}class xt extends K{constructor(e=new ge,r=12){super();let n=Array.isArray(e)?e:[e],s=[],l=[],h=[],u=[];for(let c of n){if(!(c instanceof xe))continue;let i=ke(c,r);if(i.shape.length<3)continue;let{mergedIndices:p,allVertices:a}=Ie(i.shape,i.holes),o=Xe(p,a),y=s.length/3,[x,b,g,f]=De(a);for(let m of a)s.push(m.x,m.y,0),l.push(0,0,1),h.push((m.x-x)/g,(m.y-b)/f);for(let[m,d,M]of o)u.push(y+m,y+d,y+M)}be(this,s,l,h,u)}}function be(t,e,r,n,s){return t.setAttribute("position",new Se(e,3)),t.setAttribute("normal",new Se(r,3)),t.setAttribute("uv",new Se(n,2)),t.setIndex(s),t}function gt(t){let e=t.length,r=[];for(let n=0;n<e;n++){let s=t[(n+e-1)%e],l=t[n],h=t[(n+1)%e],u=l.x-s.x,c=l.y-s.y,i=Math.hypot(u,c)||1;u/=i,c/=i;let p=h.x-l.x,a=h.y-l.y,o=Math.hypot(p,a)||1;p/=o,a/=o;let y=c,x=-u,b=a,g=-p,f=y+b,m=x+g,d=Math.hypot(f,m);if(d>1e-6){f/=d,m/=d;let M=Math.max(.35,f*y+m*x);r.push(new D(f/M,m/M))}else r.push(new D(y,x))}return r}class mt extends K{constructor(e=new ge,r={}){super();let n=Array.isArray(e)?e:[e],s=Math.max(1,Math.min(64,Math.floor(q(r.curveSegments,12)))),l=q(r.depth??r.amount,1),h=Math.max(1,Math.min(32,Math.floor(q(r.steps,1)))),u=!!(r.bevelEnabled??!1),c=u?Math.max(0,q(r.bevelThickness,.06)):0,i=u?Math.max(0,q(r.bevelSize,c*.8)):0,p=u?q(r.bevelOffset,0):0,a=u?Math.max(1,Math.min(8,Math.floor(q(r.bevelSegments,2)))):0,o=[],y=[],x=[],b=[];for(let g of n){if(!(g instanceof xe))continue;let f=ke(g,s);if(f.shape.length<3)continue;let m=f.shape.slice();me(m)<0&&m.reverse();let d=[];for(let E of f.holes){if(E.length<3)continue;let _=E.slice();me(_)>0&&_.reverse(),d.push(_)}let{mergedIndices:M,allVertices:w}=Ie(m,d),z=Xe(M,w),P=[m,...d],N=[];for(let E of P){let _=gt(E);for(let X of _)N.push(X)}let[T,O,k,$]=De(w);for(let[E,_]of[[-c,-1],[l+c,1]]){let X=o.length/3;for(let I=0;I<w.length;I++){let C=w[I],G=N[I]??new D(0,0),j=C.x+G.x*p,R=C.y+G.y*p;o.push(j,R,E),y.push(0,0,_),x.push((j-T)/k,(R-O)/$)}for(let[I,C,G]of z)b.push(X+I,X+(_<0?G:C),X+(_<0?C:G))}let A=[];if(u&&a>0)for(let E=0;E<a;E++){let _=E/a*Math.PI/2;A.push({z:-c*Math.cos(_),expand:p+i*Math.sin(_)})}for(let E=0;E<=h;E++){let _=E/h;A.push({z:_*l,expand:p+i})}if(u&&a>0)for(let E=1;E<=a;E++){let _=E/a*Math.PI/2;A.push({z:l+c*Math.sin(_),expand:p+i*Math.cos(_)})}let H=0;for(let E of P){let _=E.length;for(let X=0;X<A.length-1;X++){let I=A[X],C=A[X+1];for(let G=0;G<_;G++){let j=(G+1)%_,R=E[G],L=E[j],B=N[H+G],V=N[H+j],Y=R.x+B.x*I.expand,F=R.y+B.y*I.expand,te=L.x+V.x*I.expand,re=L.y+V.y*I.expand,ue=L.x+V.x*C.expand,ce=L.y+V.y*C.expand,J=R.x+B.x*C.expand,Z=R.y+B.y*C.expand,Q=te-Y,U=re-F,St=J-Y,wt=Z-F,Ue=C.z-I.z,ne=U*Ue,se=-Q*Ue,ie=Q*wt-U*St,Ee=Math.hypot(ne,se,ie)||1;ne/=Ee,se/=Ee,ie/=Ee;let le=o.length/3;o.push(Y,F,I.z,te,re,I.z,ue,ce,C.z,J,Z,C.z),y.push(ne,se,ie,ne,se,ie,ne,se,ie,ne,se,ie);let We=G/_,Je=(G+1)/_,Ze=X/(A.length-1),Qe=(X+1)/(A.length-1);x.push(We,Ze,Je,Ze,Je,Qe,We,Qe),b.push(le,le+1,le+2,le,le+2,le+3)}}H+=_}}be(this,o,y,x,b)}}function Re(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 bt(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 Mt(t,e,r){let n=t.nx+(e.nx-t.nx)*r,s=t.ny+(e.ny-t.ny)*r,l=t.nz+(e.nz-t.nz)*r,h=Math.hypot(n,s,l)||1;return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r,z:t.z+(e.z-t.z)*r,nx:n/h,ny:s/h,nz:l/h,u:t.u+(e.u-t.u)*r,v:t.v+(e.v-t.v)*r}}function dt(t){if(t.length<3)return null;let e=t[0],r=t[1],n=t[2],s=r.x-e.x,l=r.y-e.y,h=r.z-e.z,u=n.x-e.x,c=n.y-e.y,i=n.z-e.z,p=l*i-h*c,a=h*u-s*i,o=s*c-l*u,y=Math.hypot(p,a,o);if(y<1e-9)return null;p/=y,a/=y,o/=y;let x=p*e.x+a*e.y+o*e.z;return{vertices:t,nx:p,ny:a,nz:o,w:x}}function vt(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=bt(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Oe=1e-5,je=0,Ne=1,Me=2,qe=3;function He(t,e,r,n,s,l,h,u,c){let i=0,p=[];for(let a=0;a<s.vertices.length;a++){let o=s.vertices[a],y=t*o.x+e*o.y+r*o.z-n,x=y<-Oe?Me:y>Oe?Ne:je;i|=x,p.push(x)}switch(i){case je:{t*s.nx+e*s.ny+r*s.nz>0?l.push(s):h.push(s);break}case Ne:u.push(s);break;case Me:c.push(s);break;case qe:{let a=[],o=[],y=s.vertices.length;for(let m=0;m<y;m++){let d=(m+1)%y,M=p[m],w=p[d],z=s.vertices[m],P=s.vertices[d];if(M!==Me&&a.push(z),M!==Ne&&o.push(M!==Me?Re(z):z),(M|w)===qe){let N=P.x-z.x,T=P.y-z.y,O=P.z-z.z,k=t*N+e*T+r*O,$=Math.abs(k)>1e-12?(n-(t*z.x+e*z.y+r*z.z))/k:.5,A=Mt(z,P,Math.max(0,Math.min(1,$)));a.push(A),o.push(Re(A))}}let{nx:x,ny:b,nz:g,w:f}=s;a.length>=3&&u.push({vertices:a,nx:x,ny:b,nz:g,w:f}),o.length>=3&&c.push({vertices:o,nx:x,ny:b,nz:g,w:f});break}default:break}}class ae{constructor(e,r=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,r)}invert(){for(let r=0;r<this.polygons.length;r++)vt(this.polygons[r]);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,r=0){if(!this.hasPlane||e.length===0)return e.slice();if(r>=ee)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ee})`);let n=[],s=[];for(let l=0;l<e.length;l++)He(this.nx,this.ny,this.nz,this.w,e[l],n,s,n,s);return this.front&&n.length>0&&(n=this.front.clipPolygons(n,r+1)),this.back?s=s.length>0?this.back.clipPolygons(s,r+1):[]:s=[],n.concat(s)}clipTo(e,r=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),r<ee&&(this.front&&this.front.clipTo(e,r+1),this.back&&this.back.clipTo(e,r+1))}allPolygons(e=[]){for(let r=0;r<this.polygons.length;r++)e.push(this.polygons[r]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,r=0){if(!e.length)return;if(!this.hasPlane){let l=e[e.length>>1];this.nx=l.nx,this.ny=l.ny,this.nz=l.nz,this.w=l.w,this.hasPlane=!0}if(r>=ee)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ee})`);let n=[],s=[];for(let l=0;l<e.length;l++)He(this.nx,this.ny,this.nz,this.w,e[l],this.polygons,this.polygons,n,s);n.length>0&&(this.front||(this.front=new ae),this.front.build(n,r+1)),s.length>0&&(this.back||(this.back=new ae),this.back.build(s,r+1))}}function Le(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let r=t.attributes.position;if(!r||r.count===0)return[];let n=t.attributes.normal,s=t.attributes.uv,l=t.index?t.index.array:null,h=Math.floor(l?l.length/3:r.count/3);if(h>he)throw new RangeError(`SecurityError: CSG input triangle count (${h}) exceeds MAX_CSG_TRIANGLES (${he})`);let u=e?e.elements:null,c=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,i=u?new ct().getNormalMatrix(e).elements:null,p=o=>{let y=r.getX(o),x=r.getY(o),b=r.getZ(o),g=n?n.getX(o):NaN,f=n?n.getY(o):NaN,m=n?n.getZ(o):NaN;if(u&&i){let w=u[0]*y+u[4]*x+u[8]*b+u[12],z=u[1]*y+u[5]*x+u[9]*b+u[13],P=u[2]*y+u[6]*x+u[10]*b+u[14];y=w,x=z,b=P;let N=i[0]*g+i[3]*f+i[6]*m,T=i[1]*g+i[4]*f+i[7]*m,O=i[2]*g+i[5]*f+i[8]*m,k=Math.hypot(N,T,O)||1;g=N/k,f=T/k,m=O/k}let d=s?s.getX(o):0,M=s?s.getY(o):0;return{x:y,y:x,z:b,nx:g,ny:f,nz:m,u:d,v:M}},a=[];for(let o=0;o<h;o++){let y=l?l[o*3]:o*3,x=l?l[o*3+1]:o*3+1,b=l?l[o*3+2]:o*3+2,g=dt(c?[p(y),p(b),p(x)]:[p(y),p(x),p(b)]);g&&a.push(g)}return a}function zt(t){let e=[],r=[],n=[],s=[];for(let h of t){let u=h.vertices;if(u.length<3)continue;let c=e.length/3;for(let i of u)e.push(i.x,i.y,i.z),Number.isFinite(i.nx)&&i.nx*i.nx+i.ny*i.ny+i.nz*i.nz>.5?r.push(i.nx,i.ny,i.nz):r.push(h.nx,h.ny,h.nz),n.push(i.u,i.v);for(let i=1;i<u.length-1;i++)s.push(c,c+i,c+i+1)}let l=be(new K,e,r,n,s);return l._csgPolygons=t,l}function Pt(t,e,r){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 r==="union"?e:[];if(e.length===0)return r==="intersect"?[]:t;let n=1/0,s=1/0,l=1/0,h=-1/0,u=-1/0,c=-1/0;for(let y=0;y<e.length;y++){let x=e[y].vertices;for(let b=0;b<x.length;b++){let g=x[b];g.x<n&&(n=g.x),g.y<s&&(s=g.y),g.z<l&&(l=g.z),g.x>h&&(h=g.x),g.y>u&&(u=g.y),g.z>c&&(c=g.z)}}n-=1e-4,s-=1e-4,l-=1e-4,h+=1e-4,u+=1e-4,c+=1e-4;let i=[],p=[];for(let y=0;y<t.length;y++){let x=t[y],b=x.vertices,g=1/0,f=1/0,m=1/0,d=-1/0,M=-1/0,w=-1/0;for(let z=0;z<b.length;z++){let P=b[z];P.x<g&&(g=P.x),P.y<f&&(f=P.y),P.z<m&&(m=P.z),P.x>d&&(d=P.x),P.y>M&&(M=P.y),P.z>w&&(w=P.z)}d<n||g>h||M<s||f>u||w<l||m>c?p.push(x):i.push(x)}if(i.length===0)return r==="union"?t.concat(e):r==="subtract"?t:[];let a=new ae(i),o=new ae(e);return r==="union"?(a.clipTo(o),o.clipTo(a),o.invert(),o.clipTo(a),o.invert(),a.build(o.allPolygons()),p.concat(a.allPolygons())):r==="subtract"?(a.invert(),a.clipTo(o),o.clipTo(a),o.invert(),o.clipTo(a),o.invert(),a.build(o.allPolygons()),a.invert(),p.concat(a.allPolygons())):(a.invert(),o.clipTo(a),o.invert(),a.clipTo(o),o.clipTo(a),a.build(o.allPolygons()),a.invert(),a.allPolygons())}function Be(t,e,r,n=null,s=null){let l=Le(t,n),h=Le(e,s);return zt(Pt(l,h,r))}function _e(t,e,r){let n=t instanceof fe||!!t?.isMesh,s=e instanceof fe||!!e?.isMesh,l=n?t.geometry:t,h=s?e.geometry:e,u=null;if(s)if(e.updateMatrix(),n){t.updateMatrix();let a=new Pe().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),o=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,y=new Pe().compose(new oe(0,0,0),new W(-t.quaternion.x/o,-t.quaternion.y/o,-t.quaternion.z/o,t.quaternion.w/o),new oe(1,1,1)),x=new Pe().makeTranslation(-t.position.x,-t.position.y,-t.position.z);u=a.multiply(y).multiply(x).multiply(e.matrix)}else u=e.matrix;let c=Be(l,h,r,null,u),i=n?t.material:new Ce,p=new fe(c,i);return n&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let de={toGeometry:Be,subtract(t,e){return _e(t,e,"subtract")},union(t,e){return _e(t,e,"union")},intersect(t,e){return _e(t,e,"intersect")}},Ve={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 $e extends K{constructor(e="",r={}){super();let n=String(e??"").slice(0,Ge),s=Math.max(.005,Math.min(100,q(r.size,.2))),l=!!(r.bevelEnabled??!1),h=l?Math.max(0,Math.min(2,q(r.bevelThickness,s*.04))):0,u=l?Math.max(0,Math.min(2,q(r.bevelSize,s*.03))):0,c=Math.max(.001,Math.min(20,q(r.depth??r.height,s*.2)))+h*2,i=s*.085+u,p=s*.68,a=s*.82,o=[],y=[],x=[],b=[],g=(d,M,w,z,P,N,T)=>{let O=w-d,k=z-M,$=Math.hypot(O,k),A=1,H=0;$>1e-6&&(A=O/$,H=k/$);let E=-H*P,_=A*P,X=A*P*.6,I=H*P*.6,C=d-X+E,G=M-I+_,j=d-X-E,R=M-I-_,L=w+X-E,B=z+I-_,V=w+X+E,Y=z+I+_,F=(te,re,ue,ce,J,Z,Q)=>{let U=o.length/3;o.push(te[0],te[1],te[2],re[0],re[1],re[2],ue[0],ue[1],ue[2],ce[0],ce[1],ce[2]),y.push(J,Z,Q,J,Z,Q,J,Z,Q,J,Z,Q),x.push(0,0,1,0,1,1,0,1),b.push(U,U+1,U+2,U,U+2,U+3)};F([C,G,T],[j,R,T],[L,B,T],[V,Y,T],0,0,1),F([j,R,N],[C,G,N],[V,Y,N],[L,B,N],0,0,-1),F([C,G,N],[j,R,N],[j,R,T],[C,G,T],-A,-H,0),F([L,B,N],[V,Y,N],[V,Y,T],[L,B,T],A,H,0),F([j,R,N],[L,B,N],[L,B,T],[j,R,T],H,-A,0),F([V,Y,N],[C,G,N],[C,G,T],[V,Y,T],-H,A,0)},f=0,m=0;for(let d=0;d<n.length;d++){let M=n[d];if(M===`
|
|
17
|
+
`){f=0,m-=s*1.35;continue}if(M===" "||M===" "){f+=a*(M===" "?.75:3);continue}if(M==="\r")continue;let w=M.toUpperCase(),z=M!==w&&M>="a"&&M<="z",P=Ve[w]??Ve["?"],N=z?s*.76:s,T=z?p*.88:p;for(let O of P)for(let k=0;k<O.length-1;k++){let $=O[k],A=O[k+1];g(f+$[0]*T,m+$[1]*N,f+A[0]*T,m+A[1]*N,i,-c*.5,c*.5)}f+=z?a*.88:a}be(this,o,y,x,b),r.center!==!1?this.center():this.computeBoundingBox()}}function Ye(t){if(!t)return;let e=t,r=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(r!=null&&r!==!1){let s=e.geometry?.attributes?.position;if((!s||s.count===0)&&t.userData._textApplied!==!0){let l="",h=.08,u=.015,c;if(typeof r=="string"||typeof r=="number")l=String(r);else if(typeof r=="object"){let i=r;l=String(i.text??i.value??""),i.size!==void 0&&(h=Number(i.size)||.08),(i.depth!==void 0||i.height!==void 0)&&(u=Number(i.depth??i.height)||h*.2),(typeof i.color=="string"||typeof i.color=="number")&&(c=i.color)}l.trim().length>0&&(e.geometry=new $e(l,{size:h,depth:u}),t.userData._textApplied=!0,e.material instanceof yt?c!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new pt(c),t.userData._autoTextColorApplied=!0):e.material=new Ce({color:c??16317180}))}}let n=t.userData?.csg;if(n&&typeof n=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof K&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let s=Array.isArray(n)?n:[n],l=e.geometry;for(let h of s){if(!h||typeof h!="object")continue;let u=h,c=String(u.op??u.operation??"subtract"),i=c==="union"||c==="intersect"?c:"subtract",p=u.target??u.mesh??u.geometry;if(p instanceof fe||p instanceof K)try{let a=i==="union"?de.union(e,p):i==="intersect"?de.intersect(e,p):de.subtract(e,p);e.geometry!==l&&e.geometry.dispose?.(),e.geometry=a.geometry}catch(a){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",a)}}}}let Fe={Path:xe,Shape:ge,ShapeGeometry:xt,ExtrudeGeometry:mt,TextGeometry:$e,CSG:de,MAX_CSG_TRIANGLES:he,MAX_BSP_DEPTH:ee,MAX_TEXT_GEOMETRY_CHARS:Ge,MAX_SHAPE_POINTS:we,materializeDeclarativeGeometry:Ye};return S&&typeof S=="object"&&(S.authorNamespace||(S.authorNamespace={}),Object.assign(S.authorNamespace,Fe),S._cadMaterialize=Ye,S.materializeDeclarativeGeometry=t=>{S._cadMaterialize?.(t),S._lodMaterialize?.(t)}),Fe}var Ae={name:"cad",onRegister(){it(ze);let v=ye(),S=v.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);S&&ze(S,v)}};return lt(Ae),st(Te)})();
|