three-live 1.3.1 → 1.4.0

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.
Files changed (58) hide show
  1. package/README.md +4 -1
  2. package/dist/index.d.ts +191 -0
  3. package/dist/three-author-engine.js +179 -144
  4. package/dist/three-author.cjs +153 -144
  5. package/dist/three-author.d.ts +191 -0
  6. package/dist/three-author.js +153 -144
  7. package/dist/three-convert.cjs +150 -141
  8. package/dist/three-convert.d.ts +191 -0
  9. package/dist/three-convert.js +150 -141
  10. package/dist/three-live-ai.cjs +41 -0
  11. package/dist/three-live-ai.d.ts +759 -0
  12. package/dist/three-live-ai.js +41 -0
  13. package/dist/three-live-ai.min.js +41 -0
  14. package/dist/three-live-animation.cjs +6 -6
  15. package/dist/three-live-animation.d.ts +191 -0
  16. package/dist/three-live-animation.js +5 -5
  17. package/dist/three-live-animation.min.js +5 -5
  18. package/dist/three-live-cad.cjs +2 -2
  19. package/dist/three-live-cad.d.ts +191 -0
  20. package/dist/three-live-cad.js +2 -2
  21. package/dist/three-live-cad.min.js +2 -2
  22. package/dist/three-live-element.cjs +50 -85
  23. package/dist/three-live-element.d.ts +191 -0
  24. package/dist/three-live-element.js +50 -85
  25. package/dist/three-live-full.cjs +915 -170
  26. package/dist/three-live-full.js +917 -172
  27. package/dist/three-live-full.min.js +915 -170
  28. package/dist/three-live-procedural.cjs +16 -0
  29. package/dist/three-live-procedural.d.ts +759 -0
  30. package/dist/three-live-procedural.js +16 -0
  31. package/dist/three-live-procedural.min.js +16 -0
  32. package/dist/three-live-sandbox.html +11 -1
  33. package/dist/three-live-studio.cjs +72 -17
  34. package/dist/three-live-studio.d.ts +191 -0
  35. package/dist/three-live-studio.js +72 -17
  36. package/dist/three-live-studio.min.js +73 -18
  37. package/dist/three-live-tsl.cjs +103 -0
  38. package/dist/three-live-tsl.d.ts +759 -0
  39. package/dist/three-live-tsl.js +103 -0
  40. package/dist/three-live-tsl.min.js +103 -0
  41. package/dist/three-live-viewer.cjs +50 -85
  42. package/dist/three-live-viewer.d.ts +191 -0
  43. package/dist/three-live-viewer.js +50 -85
  44. package/dist/three-live-viewer.min.js +50 -85
  45. package/dist/three-live-webgpu.cjs +585 -0
  46. package/dist/three-live-webgpu.d.ts +759 -0
  47. package/dist/three-live-webgpu.js +585 -0
  48. package/dist/three-live-webgpu.min.js +585 -0
  49. package/dist/three-live.cjs +155 -146
  50. package/dist/three-live.js +155 -146
  51. package/dist/three-live.min.js +155 -146
  52. package/dist/three-view.cjs +49 -84
  53. package/dist/three-view.d.ts +191 -0
  54. package/dist/three-view.js +50 -85
  55. package/dist/three-xr.cjs +150 -141
  56. package/dist/three-xr.d.ts +191 -0
  57. package/dist/three-xr.js +150 -141
  58. package/package.json +39 -1
@@ -13,18 +13,18 @@
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
- */var ThreeLiveAnimation=(()=>{var tt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Kt=Object.getOwnPropertyNames,Ut=Object.prototype.hasOwnProperty,Jt=(t,e)=>{for(var r in e)tt(t,r,{get:e[r],enumerable:!0})},$t=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Kt(e))!Ut.call(t,i)&&i!==r&&tt(t,i,{get:()=>e[i],enumerable:!(o=Bt(e,i))||o.enumerable});return t},jt=t=>$t(tt({},"__esModule",{value:!0}),t),dt={};Jt(dt,{IKSolver:()=>Gt,crossFadeTo:()=>_t,ikPlugin:()=>xt,keyframeAnimationPlugin:()=>Ft,morphPlugin:()=>St,parseAnimations:()=>kt,quatFromUnitVectors:()=>it,sampleChannel:()=>U,setMorphTargetWeight:()=>ae,skinningPlugin:()=>Vt,solveFABRIK:()=>bt,solveTwoBoneIK:()=>Mt});var q="__THREE_LIVE_REGISTRY__";function z(){let t=typeof globalThis<"u"?globalThis:{};if(!t[q]){let e={plugins:[],decoders:new Map};try{Object.defineProperty(t,q,{value:e,writable:!1,configurable:!1,enumerable:!1})}catch{t[q]=e}}return t[q]}var fe=z().plugins;function Ct(t){let e=z();e.workerExtensionInstallers||(e.workerExtensionInstallers=[]),e.workerExtensionInstallers.includes(t)||e.workerExtensionInstallers.push(t)}function G(t){let e=z().plugins;e.some(r=>r.name===t.name)||e.push(t),t.onRegister?.()}function E(){let t=new Float32Array(16);return t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function pt(t,e,r){let o=e[0],i=e[1],a=e[2],g=e[3],p=e[4],n=e[5],s=e[6],l=e[7],u=e[8],h=e[9],f=e[10],M=e[11],c=e[12],d=e[13],b=e[14],v=e[15],m=r[0],A=r[1],x=r[2],k=r[3];return t[0]=m*o+A*p+x*u+k*c,t[1]=m*i+A*n+x*h+k*d,t[2]=m*a+A*s+x*f+k*b,t[3]=m*g+A*l+x*M+k*v,m=r[4],A=r[5],x=r[6],k=r[7],t[4]=m*o+A*p+x*u+k*c,t[5]=m*i+A*n+x*h+k*d,t[6]=m*a+A*s+x*f+k*b,t[7]=m*g+A*l+x*M+k*v,m=r[8],A=r[9],x=r[10],k=r[11],t[8]=m*o+A*p+x*u+k*c,t[9]=m*i+A*n+x*h+k*d,t[10]=m*a+A*s+x*f+k*b,t[11]=m*g+A*l+x*M+k*v,m=r[12],A=r[13],x=r[14],k=r[15],t[12]=m*o+A*p+x*u+k*c,t[13]=m*i+A*n+x*h+k*d,t[14]=m*a+A*s+x*f+k*b,t[15]=m*g+A*l+x*M+k*v,t}function et(t,e,r,o){let i=e[0],a=e[1],g=e[2],p=e[3],n=i+i,s=a+a,l=g+g,u=i*n,h=i*s,f=i*l,M=a*s,c=a*l,d=g*l,b=p*n,v=p*s,m=p*l,A=o[0],x=o[1],k=o[2];return t[0]=(1-(M+d))*A,t[1]=(h+m)*A,t[2]=(f-v)*A,t[3]=0,t[4]=(h-m)*x,t[5]=(1-(u+d))*x,t[6]=(c+b)*x,t[7]=0,t[8]=(f+v)*k,t[9]=(c-b)*k,t[10]=(1-(u+M))*k,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function gt(t,e,r=0){let o=e[0],i=e[1],a=e[2],g=e[4],p=e[5],n=e[6],s=e[8],l=e[9],u=e[10],h=u*p-n*l,f=-u*g+n*s,M=l*g-p*s,c=o*h+i*f+a*M;return!c||r>0&&(!Number.isFinite(c)||Math.abs(c)<=r)||(c=1/c,t[0]=h*c,t[1]=f*c,t[2]=M*c,t[3]=(-u*i+a*l)*c,t[4]=(u*o-a*s)*c,t[5]=(-l*o+i*s)*c,t[6]=(n*i-a*p)*c,t[7]=(-n*o+a*g)*c,t[8]=(p*o-i*g)*c),t}function Lt(t,e){let r=e[0],o=e[1],i=e[2],a=e[3],g=e[4],p=e[5],n=e[6],s=e[7],l=e[8],u=e[9],h=e[10],f=e[11],M=e[12],c=e[13],d=e[14],b=e[15],v=r*p-o*g,m=r*n-i*g,A=r*s-a*g,x=o*n-i*p,k=o*s-a*p,F=i*s-a*n,V=l*c-u*M,T=l*d-h*M,y=l*b-f*M,w=u*d-h*c,_=u*b-f*c,I=h*b-f*d,P=v*I-m*_+A*w+x*y-k*T+F*V;return P?(P=1/P,t[0]=(p*I-n*_+s*w)*P,t[1]=(i*_-o*I-a*w)*P,t[2]=(c*F-d*k+b*x)*P,t[3]=(h*k-u*F-f*x)*P,t[4]=(n*y-g*I-s*T)*P,t[5]=(r*I-i*y+a*T)*P,t[6]=(d*A-M*F-b*m)*P,t[7]=(l*F-h*A+f*m)*P,t[8]=(g*_-p*y+s*V)*P,t[9]=(o*y-r*_-a*V)*P,t[10]=(M*k-c*A+b*v)*P,t[11]=(u*A-l*k-f*v)*P,t[12]=(p*T-g*w-n*V)*P,t[13]=(r*w-o*T+i*V)*P,t[14]=(c*m-M*x-d*v)*P,t[15]=(l*x-u*m+h*v)*P,t):null}function qt(t,e){let r=Array.isArray(t?.nodes)?t.nodes.length:0,o=[];for(let l=0;l<r;l++)o.push(E());if(r===0)return o;let i=new Set;for(let l of t.nodes)if(Array.isArray(l.children))for(let u of l.children)i.add(u);let a=new Set,g=128,p=(l,u,h=0)=>{if(h>g||l<0||l>=r||a.has(l))return;a.add(l);let f=t.nodes[l];if(!f)return;let M=E();if(e&&e[l])M.set(e[l]);else if(f.matrix&&f.matrix.length===16)M.set(f.matrix);else{let d=f.translation||[0,0,0],b=f.rotation||[0,0,0,1],v=f.scale||[1,1,1];et(M,b,d,v)}let c=o[l];if(u?pt(c,u,M):c.set(M),Array.isArray(f.children))for(let d of f.children)typeof d=="number"&&p(d,c,h+1)},n=[],s=t.scenes&&t.scenes[t.scene!==void 0?t.scene:0];if(s&&Array.isArray(s.nodes))n.push(...s.nodes);else for(let l=0;l<r;l++)i.has(l)||n.push(l);for(let l of n)p(l,null);for(let l=0;l<r;l++)!i.has(l)&&!n.includes(l)&&p(l,null);return o}function rt(t,e){function r(n,s,l,u){let h=typeof n=="number"?n:Number(n);return Number.isFinite(h)?Math.max(s,Math.min(l,h)):u}function o(n,s){let l=n[0]*s[0]+n[1]*s[1]+n[2]*s[2]+1;if(l<1e-6){if(Math.abs(n[0])>Math.abs(n[2])){let d=Math.hypot(n[1],n[0])||1;return[-n[1]/d,n[0]/d,0,0]}let c=Math.hypot(n[2],n[1])||1;return[0,-n[2]/c,n[1]/c,0]}let u=n[1]*s[2]-n[2]*s[1],h=n[2]*s[0]-n[0]*s[2],f=n[0]*s[1]-n[1]*s[0],M=Math.hypot(u,h,f,l)||1;return[u/M,h/M,f/M,l/M]}function i(n,s,l,u,h){let f=s[0]-n[0],M=s[1]-n[1],c=s[2]-n[2],d=Math.hypot(f,M,c),b=l[0]-s[0],v=l[1]-s[1],m=l[2]-s[2],A=Math.hypot(b,v,m);if(d<1e-6||A<1e-6)return{rootPos:[n[0],n[1],n[2]],midPos:[s[0],s[1],s[2]],effectorPos:[l[0],l[1],l[2]],rootRotation:[0,0,0,1],midRotation:[0,0,0,1]};let x=[f/d,M/d,c/d],k=[b/A,v/A,m/A],F=u[0]-n[0],V=u[1]-n[1],T=u[2]-n[2],y=Math.hypot(F,V,T),w=y>1e-6?[F/y,V/y,T/y]:x,_=Math.abs(d-A)+1e-5,I=Math.max(_,d+A-1e-5),P=Math.max(_,Math.min(I,y>1e-6?y:_)),S=r((d*d+P*P-A*A)/(2*d*P),-1,1,1),R=Math.sqrt(Math.max(0,1-S*S)),N=h?h[0]-n[0]:f,j=h?h[1]-n[1]:M,C=h?h[2]-n[2]:c,K=N*w[0]+j*w[1]+C*w[2],W=N-w[0]*K,D=j-w[1]*K,Z=C-w[2]*K,L=Math.hypot(W,D,Z);if(L<=1e-6){let Dt=Math.abs(w[1])<.99?0:1,Et=Math.abs(w[1])<.99?1:0,Wt=0;W=w[1]*Wt-w[2]*Et,D=w[2]*Dt-w[0]*Wt,Z=w[0]*Et-w[1]*Dt,L=Math.hypot(W,D,Z)||1}let mt=[W/L,D/L,Z/L],O=[n[0]+w[0]*(d*S)+mt[0]*(d*R),n[1]+w[1]*(d*S)+mt[1]*(d*R),n[2]+w[2]*(d*S)+mt[2]*(d*R)],ct=[n[0]+w[0]*P,n[1]+w[1]*P,n[2]+w[2]*P],Rt=ct[0]-O[0],Ot=ct[1]-O[1],Nt=ct[2]-O[2],Q=Math.hypot(Rt,Ot,Nt),X=Q>1e-6?[Rt/Q,Ot/Q,Nt/Q]:w,le=[O[0]+X[0]*A,O[1]+X[1]*A,O[2]+X[2]*A],se=[(O[0]-n[0])/d,(O[1]-n[1])/d,(O[2]-n[2])/d];return{rootPos:[n[0],n[1],n[2]],midPos:O,effectorPos:le,rootRotation:o(x,se),midRotation:o(k,X)}}function a(n,s,l=8,u=.001){let h=n.length;if(h<2)return{positions:n.map(y=>[y[0],y[1],y[2]]),rotations:[],iterations:0};let f=n.map(y=>[y[0],y[1],y[2]]),M=[],c=[],d=0;for(let y=0;y<h-1;y++){let w=f[y+1][0]-f[y][0],_=f[y+1][1]-f[y][1],I=f[y+1][2]-f[y][2],P=Math.hypot(w,_,I);M.push(P),d+=P,c.push(P>1e-6?[w/P,_/P,I/P]:[0,1,0])}let b=[f[0][0],f[0][1],f[0][2]],v=Math.round(r(l,1,32,8)),m=r(u,1e-5,.1,.001),A=s[0]-b[0],x=s[1]-b[1],k=s[2]-b[2],F=Math.hypot(A,x,k),V=0;if(F>=d&&d>1e-6){let y=F>1e-6?[A/F,x/F,k/F]:c[0];f[0]=[b[0],b[1],b[2]];for(let w=0;w<h-1;w++){let _=M[w];f[w+1]=[f[w][0]+y[0]*_,f[w][1]+y[1]*_,f[w][2]+y[2]*_]}V=1}else for(let y=1;y<=v;y++){let w=f[h-1];if(Math.hypot(w[0]-s[0],w[1]-s[1],w[2]-s[2])<=m)break;V=y;let _=(I,P,S,R,N)=>{let j=P[0]-I[0],C=P[1]-I[1],K=P[2]-I[2],W=Math.hypot(j,C,K);if(W>1e-6){let D=S/W;return[I[0]+j*D,I[1]+C*D,I[2]+K*D]}return[I[0]+R[0]*S*N,I[1]+R[1]*S*N,I[2]+R[2]*S*N]};f[h-1]=[s[0],s[1],s[2]];for(let I=h-2;I>=0;I--)f[I]=_(f[I+1],f[I],M[I],c[I],-1);f[0]=[b[0],b[1],b[2]];for(let I=0;I<h-1;I++)f[I+1]=_(f[I],f[I+1],M[I],c[I],1)}let T=[];for(let y=0;y<h-1;y++){let w=f[y+1][0]-f[y][0],_=f[y+1][1]-f[y][1],I=f[y+1][2]-f[y][2],P=Math.hypot(w,_,I),S=P>1e-6?[w/P,_/P,I/P]:c[y];T.push(o(c[y],S))}return{positions:f,rotations:T,iterations:V}}function g(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let s=n;if(s.enabled===!1)return null;let l=m=>{if(typeof m!="string")return;let A=m.trim().slice(0,64);return/^[A-Za-z0-9_.:-]+$/.test(A)?A:void 0},u=m=>Array.isArray(m)&&m.length===3&&m.every(A=>typeof A=="number"&&Number.isFinite(A))?[r(m[0],-1e3,1e3,0),r(m[1],-1e3,1e3,0),r(m[2],-1e3,1e3,0)]:void 0,h=l(s.root),f=l(s.effector);if(!h||!f)return null;let M=l(s.mid),c=u(s.target)??l(s.target);if(!c)return null;let d=s.pole??s.poleTarget,b=u(d)??l(d),v=s.solver==="fabrik"?"fabrik":s.solver==="two-bone"||M?"two-bone":"fabrik";return{root:h,...M?{mid:M}:{},effector:f,target:c,...b?{pole:b}:{},solver:v,iterations:Math.round(r(s.iterations,1,32,8)),tolerance:r(s.tolerance,1e-5,.1,.001),weight:r(s.weight,0,1,1)}}let p=Object.freeze({solveTwoBone:i,solveFABRIK:a,parseIKTrait:g});return e&&typeof e=="object"&&(e.authorNamespace=e.authorNamespace||{},e.authorNamespace.IKSolver=p),{clampNum:r,parseIKTrait:g,quatFromUnitVectors:o,solveTwoBoneIK:i,solveFABRIK:a,IKSolver:p}}var B=rt(),yt=B.clampNum,zt=B.parseIKTrait,it=B.quatFromUnitVectors,Mt=B.solveTwoBoneIK,bt=B.solveFABRIK,Gt=B.IKSolver;function ot(t){let e=t?.transform??t?.modelMatrix;return e&&e.length>=16?[e[12]||0,e[13]||0,e[14]||0]:[0,0,0]}function Ht(t,e){let r=t?.transform??t?.modelMatrix;!r||r.length<16||(r[12]=e[0],r[13]=e[1],r[14]=e[2])}function Yt(t,e,r,o,i){let a=yt(i,0,1,1),g=e[0]+(r[0]-e[0])*a,p=e[1]+(r[1]-e[1])*a,n=e[2]+(r[2]-e[2])*a,s=g-t[0],l=p-t[1],u=n-t[2],h=Math.hypot(s,l,u);if(h>1e-6&&o>1e-6){let b=o/h;return[t[0]+s*b,t[1]+l*b,t[2]+u*b]}let f=r[0]-t[0],M=r[1]-t[1],c=r[2]-t[2],d=Math.hypot(f,M,c);if(d>1e-6&&o>1e-6){let b=o/d;return[t[0]+f*b,t[1]+M*b,t[2]+c*b]}return[g,p,n]}function Zt(t,e){let r=t?.modelRootMatrix;if(!r||r.length!==16)return e;let o=new Float32Array(16);return Lt(o,r instanceof Float32Array?r:Float32Array.from(r))?[o[0]*e[0]+o[4]*e[1]+o[8]*e[2]+o[12],o[1]*e[0]+o[5]*e[1]+o[9]*e[2]+o[13],o[2]*e[0]+o[6]*e[1]+o[10]*e[2]+o[14]]:e}function nt(t,e){t.__ikWarned||(t.__ikWarned=new Set);let r=t.__ikWarned;r.has(e)||(r.add(e),console.warn(`[three-live] ik: joint '${e}' on '${t?.name??""}' not found among scene nodes or meshes.`))}function at(t,e,r){if(Array.isArray(t))return[t[0],t[1],t[2]];let o=e.get(t);if(o)return ot(o);let i;if(t==="head"?i=r?.headPose?.position??r?.headPose??r?.cameraPosition:t==="hand-left"?i=r?.handPoses?.left?.position??r?.handPoses?.left??r?.hands?.left?.position??r?.hands?.left:t==="hand-right"&&(i=r?.handPoses?.right?.position??r?.handPoses?.right??r?.hands?.right?.position??r?.hands?.right),(Array.isArray(i)||ArrayBuffer.isView(i))&&i.length>=3){let a=i;return Zt(r,[a[0],a[1],a[2]])}return null}function lt(t,e){return[t[3]*e[0]+t[0]*e[3]+t[1]*e[2]-t[2]*e[1],t[3]*e[1]-t[0]*e[2]+t[1]*e[3]+t[2]*e[0],t[3]*e[2]+t[0]*e[1]-t[1]*e[0]+t[2]*e[3],t[3]*e[3]-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]}function Qt(t){return[-t[0],-t[1],-t[2],t[3]]}function st(t){let e=Math.hypot(t[0],t[1],t[2],t[3]);return e>1e-12?[t[0]/e,t[1]/e,t[2]/e,t[3]/e]:[0,0,0,1]}function Xt(t,e){if(e>=1)return t;if(e<=0)return[0,0,0,1];let[r,o,i,a]=t;a<0&&(r=-r,o=-o,i=-i,a=-a);let g=Math.acos(Math.min(1,a)),p=Math.sin(g);if(p<1e-9)return[0,0,0,1];let n=Math.sin(g*e)/p;return st([r*n,o*n,i*n,Math.cos(g*e)])}function te(t){let e=Math.hypot(t[0],t[1],t[2])||1,r=Math.hypot(t[4],t[5],t[6])||1,o=Math.hypot(t[8],t[9],t[10])||1,i=t[0]/e,a=t[1]/e,g=t[2]/e,p=t[4]/r,n=t[5]/r,s=t[6]/r,l=t[8]/o,u=t[9]/o,h=t[10]/o,f=i+n+h,M;if(f>0){let c=Math.sqrt(f+1)*2;M=[(s-u)/c,(l-g)/c,(a-p)/c,.25*c]}else if(i>n&&i>h){let c=Math.sqrt(1+i-n-h)*2;M=[.25*c,(p+a)/c,(l+g)/c,(s-u)/c]}else if(n>h){let c=Math.sqrt(1+n-i-h)*2;M=[(p+a)/c,.25*c,(u+s)/c,(l-g)/c]}else{let c=Math.sqrt(1+h-i-n)*2;M=[(l+g)/c,(u+s)/c,.25*c,(a-p)/c]}return st(M)}function ee(t,e,r){let[o,i,a,g]=r,p=1-2*(i*i+a*a),n=2*(o*i-a*g),s=2*(o*a+i*g),l=2*(o*i+a*g),u=1-2*(o*o+a*a),h=2*(i*a-o*g),f=2*(o*a-i*g),M=2*(i*a+o*g),c=1-2*(o*o+i*i);for(let d=0;d<3;d++){let b=e[d*4],v=e[d*4+1],m=e[d*4+2];t[d*4]=p*b+n*v+s*m,t[d*4+1]=l*b+u*v+h*m,t[d*4+2]=f*b+M*v+c*m}}function H(t,e){let r=e[0]-t[0],o=e[1]-t[1],i=e[2]-t[2],a=Math.hypot(r,o,i);return a>1e-9?[r/a,o/a,i/a]:null}function vt(t){t?.normalMatrix&&t?.transform&&gt(t.normalMatrix,t.transform)}var wt=new WeakMap;function re(t){let e=wt.get(t);return e||(e=new Int32Array(t.nodes.length).fill(-1),t.nodes.forEach((r,o)=>{for(let i of Array.isArray(r?.children)?r.children:[])typeof i=="number"&&i>=0&&i<e.length&&(e[i]=o)}),wt.set(t,e)),e}function ie(t,e,r){let o=t?.gltf,i=o?.nodes;if(!Array.isArray(i)||i.length===0)return!1;let a=new Map;i.forEach((T,y)=>{typeof T?.name=="string"&&T.name&&!a.has(T.name)&&a.set(T.name,y)});let g=(e.mid?[e.root,e.mid,e.effector]:[e.root,e.effector]).map(T=>a.get(T));if(g.some(T=>T===void 0))return!1;let p=g,n=re(o);for(let T=1;T<p.length;T++){let y=n[p[T]],w=0;for(;y>=0&&y!==p[T-1]&&w++<256;)y=n[y];if(y!==p[T-1])return!1}let s=p[0],l=t.initialNodeTransforms,u=new Map,h=[],f=[s];for(;f.length&&h.length<4096;){let T=f.pop();if(u.has(T))continue;let y=l?.[T],w=i[T];u.set(T,{t:y?[y.t[0],y.t[1],y.t[2]]:w?.translation?[...w.translation]:[0,0,0],r:y?[y.r[0],y.r[1],y.r[2],y.r[3]]:w?.rotation?[...w.rotation]:[0,0,0,1],s:y?[y.s[0],y.s[1],y.s[2]]:w?.scale?[...w.scale]:[1,1,1]}),h.push(T);for(let _ of Array.isArray(w?.children)?w.children:[])typeof _=="number"&&f.push(_)}let M=n[s],c=M>=0&&t.worldMatrices?.[M]?.length===16?Float32Array.from(t.worldMatrices[M]):E(),d=new Map,b=()=>{let T=(y,w)=>{let _=u.get(y);if(!_)return;let I=E();et(I,_.r,_.t,_.s);let P=E();pt(P,w,I),d.set(y,P);for(let S of Array.isArray(i[y]?.children)?i[y].children:[])typeof S=="number"&&T(S,P)};T(s,c)},v=T=>{let y=d.get(T);return[y[12],y[13],y[14]]};b();let m=p.map(v),A=T=>{if(typeof T=="string"&&!r.has(T)){let y=a.get(T),w=y!==void 0?d.get(y)??t.worldMatrices?.[y]:void 0;if(w&&w.length===16)return[w[12],w[13],w[14]]}return at(T,r,t)},x=A(e.target);if(!x)return!0;let k=e.pole?A(e.pole)??void 0:void 0,F=At(m,e,x,k),V=yt(e.weight,0,1,1);for(let T=0;T<p.length-1;T++){let y=H(v(p[T]),v(p[T+1])),w=H(F[T],F[T+1]);if(!y||!w)continue;let _=Xt(it(y,w),V),I=p[T],P=n[I],S=P===M||P<0?c:d.get(P)??c,R=te(S),N=u.get(I);N.r=st(lt(Qt(R),lt(_,lt(R,N.r)))),b()}if(Array.isArray(t.worldMatrices))for(let[T,y]of d)t.worldMatrices[T]?.set&&t.worldMatrices[T].set(y);for(let T of t.meshes??[]){let y=d.get(T?.nodeIndex);y&&T.transform?.set&&(T.transform.set(y),vt(T))}return!0}function At(t,e,r,o){if(e.solver==="two-bone"&&t.length===3){let i=Mt(t[0],t[1],t[2],r,o);return[t[0],i.midPos,i.effectorPos]}return bt(t,r,e.iterations,e.tolerance).positions}function oe(t,e,r){let o=t.__ikRestOffsets,i=t.__ikRestMats;if(!(!o||!i))for(let a=0;a<e.length-1;a++){let g=e[a]?.transform??e[a]?.modelMatrix,p=i[a],n=H([0,0,0],o[a]),s=H(r[a],r[a+1]);!g||g.length<16||!p||p.length<16||!n||!s||(ee(g,p,it(n,s)),vt(e[a]))}}var xt={name:"ik",onRegister(){let t=z();Ct(rt),rt(t.threeNamespace,t)},onUpdate(t){let e=t?.meshes;if(!Array.isArray(e)||e.length===0)return;let r=null;for(let o of e){let i=o?.userData?.xr?.ik??o?.extras?.xr?.ik??o?.extensions?.ANDROID_xr_scenecore?.ik;if(!i)continue;let a=zt(i);if(!a||a.weight<=0)continue;if(!r){r=new Map;for(let m of e)m&&typeof m.name=="string"&&m.name&&r.set(m.name,m)}if(ie(t,a,r))continue;let g=r.get(a.root),p=r.get(a.effector),n=a.mid?r.get(a.mid):void 0;if(g||nt(o,a.root),p||nt(o,a.effector),a.mid&&!n&&nt(o,a.mid),!g||!p)continue;let s=at(a.target,r,t);if(!s)continue;let l=a.pole?at(a.pole,r,t)??void 0:void 0,u=n?[g,n,p]:[g,p],h=u.map(m=>m.name||"").join(">");if(!o.__ikRestOffsets||o.__ikRestKey!==h){let m=u.map(ot),A=[];for(let x=0;x<m.length-1;x++)A.push([m[x+1][0]-m[x][0],m[x+1][1]-m[x][1],m[x+1][2]-m[x][2]]);o.__ikRestOffsets=A,o.__ikRestKey=h,o.__ikRestMats=u.map(x=>Array.from(x.transform??x.modelMatrix??[]))}let f=o.__ikRestOffsets,M=[ot(g)],c=[];for(let m=0;m<f.length;m++){let A=M[m],x=f[m];M.push([A[0]+x[0],A[1]+x[1],A[2]+x[2]]),c.push(Math.hypot(x[0],x[1],x[2]))}let d=At(M,a,s,l),b=M[0],v=[M[0]];for(let m=1;m<u.length;m++){let A=f[m-1],x=[b[0]+A[0],b[1]+A[1],b[2]+A[2]],k=[b[0]+(d[m][0]-d[m-1][0]),b[1]+(d[m][1]-d[m-1][1]),b[2]+(d[m][2]-d[m-1][2])],F=Yt(b,x,k,c[m-1],a.weight);Ht(u[m],F),b=F,v.push(F)}oe(o,u,v)}}},ne={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};function Y(t,e,r,o){if(!r||r.bufferView===void 0)return null;let i=t.bufferViews?.[r.bufferView];if(!i)return null;let a=Number(r.count??0);if(!Number.isInteger(a)||a<=0)return null;let g=r.componentType??5126,p=ne[g];if(!p)throw new RangeError(`glTF accessor has unsupported componentType ${g}`);let n=p*o,s=i.byteStride&&i.byteStride>0?i.byteStride:n,l=(i.byteOffset||0)+(r.byteOffset||0);if(!Number.isInteger(l)||l<0||s<n||l+(a-1)*s+n>e.byteLength)throw new RangeError(`glTF accessor reads past the end of the binary buffer (${e.byteLength} bytes)`);if(g===5126&&s===n&&l%4===0)return new Float32Array(e,l,a*o);let u=new DataView(e),h=r.normalized===!0,f=new Float32Array(a*o);for(let M=0;M<a;M++){let c=l+M*s;for(let d=0;d<o;d++){let b=c+d*p,v;switch(g){case 5126:v=u.getFloat32(b,!0);break;case 5120:v=u.getInt8(b),h&&(v=Math.max(v/127,-1));break;case 5121:v=u.getUint8(b),h&&(v/=255);break;case 5122:v=u.getInt16(b,!0),h&&(v=Math.max(v/32767,-1));break;case 5123:v=u.getUint16(b,!0),h&&(v/=65535);break;default:v=u.getUint32(b,!0),h&&(v/=4294967295)}f[M*o+d]=v}}return f}function Tt(t,e,r){return e%4===0?new Float32Array(t,e,r):new Float32Array(t.slice(e,e+r*4))}function Pt(t,e,r,o){let i=e[0],a=e[1],g=e[2],p=e[3],n=r[0],s=r[1],l=r[2],u=r[3],h=i*n+a*s+g*l+p*u;if(h<0&&(n=-n,s=-s,l=-l,u=-u,h=-h),Math.abs(h)>=1)return t[0]=i,t[1]=a,t[2]=g,t[3]=p,t;let f=Math.acos(h),M=Math.sqrt(1-h*h);if(Math.abs(M)<.001)return t[0]=.5*(i+n),t[1]=.5*(a+s),t[2]=.5*(g+l),t[3]=.5*(p+u),t;let c=Math.sin((1-o)*f)/M,d=Math.sin(o*f)/M;return t[0]=i*c+n*d,t[1]=a*c+s*d,t[2]=g*c+l*d,t[3]=p*c+u*d,t}function It(t,e,r,o){return t[0]=e[0]+o*(r[0]-e[0]),t[1]=e[1]+o*(r[1]-e[1]),t[2]=e[2]+o*(r[2]-e[2]),t}function kt(t,e){if(!Array.isArray(t?.animations))return[];let r=[];for(let o=0;o<t.animations.length;o++){let i=t.animations[o],a=i.name||`Animation_${o}`,g=[],p=0;if(Array.isArray(i.channels)&&Array.isArray(i.samplers))for(let n of i.channels){if(!n.target||n.target.node===void 0||!n.target.path)continue;let s=i.samplers[n.sampler];if(!s)continue;let l=t.accessors?.[s.input],u=t.accessors?.[s.output];if(!l||!u)continue;let h=t.bufferViews?.[l.bufferView],f=t.bufferViews?.[u.bufferView];if(!h||!f)continue;let M=(h.byteOffset||0)+(l.byteOffset||0),c=(f.byteOffset||0)+(u.byteOffset||0),d=Y(t,e,l,1)??Tt(e,M,l.count);d.length>0&&d[d.length-1]>p&&(p=d[d.length-1]);let b=n.target.path==="rotation"?4:n.target.path==="weights"?Math.max(1,Math.round(u.count/Math.max(1,l.count))):3,v=n.target.path==="weights"?1:b,m=Y(t,e,u,v)??Tt(e,c,u.count*v),A=s.interpolation==="STEP"?"STEP":"LINEAR";g.push({nodeIndex:n.target.node,path:n.target.path,times:d,values:m,interpolation:A})}g.length>0&&r.push({name:a,duration:p,channels:g})}return r}function U(t,e,r){let{times:o,values:i,path:a,interpolation:g}=t,p=o.length;if(p===0)return;let n=a==="rotation"?4:a==="weights"?Math.max(1,Math.round(i.length/p)):3;if(e<=o[0]){for(let v=0;v<n;v++)r[v]=i[v];return}if(e>=o[p-1]){let v=(p-1)*n;for(let m=0;m<n;m++)r[m]=i[v+m];return}let s=0,l=p-1;for(;s<=l;){let v=s+l>>1;o[v]<=e?s=v+1:l=v-1}let u=Math.max(0,l),h=Math.min(p-1,u+1);if(g==="STEP"||u===h){let v=u*n;for(let m=0;m<n;m++)r[m]=i[v+m];return}let f=o[u],M=o[h],c=(e-f)/Math.max(1e-5,M-f),d=u*n,b=h*n;if(a==="rotation"){let v=[i[d],i[d+1],i[d+2],i[d+3]],m=[i[b],i[b+1],i[b+2],i[b+3]];Pt(r,v,m,c)}else for(let v=0;v<n;v++)r[v]=i[d+v]+c*(i[b+v]-i[d+v])}var J=new WeakMap;function _t(t,e,r=.3){if(!t?.animations)return;let o=t.animations.find(p=>p.name===e);if(!o)return;let i=J.get(t);i||(i=[],t.currentClip&&i.push({clip:t.currentClip,time:t.animationTime||0,weight:1,fadeSpeed:0}),J.set(t,i));let a=r>0?1/r:1e3;for(let p of i)p.clip.name!==e&&(p.fadeSpeed=-a);let g=i.find(p=>p.clip.name===e);g?g.fadeSpeed=a:i.push({clip:o,time:0,weight:r>0?0:1,fadeSpeed:a}),t.currentClip=o,t.isPlayingAnimation=!0}function ft(t,e){if(!t.gltf||!Array.isArray(t.gltf.nodes))return;let r=J.get(t);if(!r||r.length===0){if(!t.currentClip)return;r=[{clip:t.currentClip,time:e,weight:1,fadeSpeed:0}]}let o=t.gltf.nodes.length,i=[];for(let u=0;u<o;u++){let h=t.initialNodeTransforms[u];h?i.push({t:[h.t[0],h.t[1],h.t[2]],r:[h.r[0],h.r[1],h.r[2],h.r[3]],s:[h.s[0],h.s[1],h.s[2]]}):i.push({t:[0,0,0],r:[0,0,0,1],s:[1,1,1]})}let a=[0,0,0],g=[0,0,0,1],p=[1,1,1],n=new Float32Array(64);for(let u of r){let h=Math.max(0,Math.min(1,u.weight));if(!(h<=1e-4))for(let f of u.clip.channels){if(f.nodeIndex<0||f.nodeIndex>=o)continue;let M=i[f.nodeIndex];if(f.path==="translation")U(f,u.time,a),It(M.t,M.t,a,h);else if(f.path==="rotation")U(f,u.time,g),Pt(M.r,M.r,g,h);else if(f.path==="scale")U(f,u.time,p),It(M.s,M.s,p,h);else if(f.path==="weights"&&(U(f,u.time,n),t.meshes)){for(let c of t.meshes)if(c.nodeIndex===f.nodeIndex){for(let d of c.primitives)if(d.pluginData?.morph?.weights){let b=d.pluginData.morph.weights,v=d.pluginData.morph.numTargets||b.length;for(let m=0;m<v;m++)b[m]=b[m]*(1-h)+n[m]*h}}}}}let s=[];for(let u=0;u<o;u++){let h=E(),{t:f,r:M,s:c}=i[u];et(h,M,f,c),s.push(h)}let l=qt(t.gltf,s);t.worldMatrices=l;for(let u of t.meshes)u.nodeIndex>=0&&u.nodeIndex<l.length&&(u.transform.set(l[u.nodeIndex]),gt(u.normalMatrix,u.transform))}var ut=t=>{J.delete(t)},Ft={name:"keyframes",evaluateAnimation:ft,crossFadeTo:_t,onParseGLB(t){!t.animations&&t.gltf?.animations&&(t.animations=kt(t.gltf,t.bin))},onLoadModel:ut,onClearScene:ut,onDestroy:(t,e)=>ut(e),onUpdate(t,e){if(!t.isPlayingAnimation)return;let r=J.get(t);if(r&&r.length>0){for(let o=r.length-1;o>=0;o--){let i=r[o];if(i.time+=e,i.clip.duration>0&&(i.time%=i.clip.duration),i.fadeSpeed!==0)if(i.weight+=i.fadeSpeed*e,i.weight<=0){r.splice(o,1);continue}else i.weight>=1&&(i.weight=1,i.fadeSpeed=0)}r.length>0&&(t.animationTime=r[r.length-1].time),ft(t,t.animationTime)}else t.currentClip&&(t.animationTime+=e,t.currentClip.duration>0&&(t.animationTime%=t.currentClip.duration),ft(t,t.animationTime))}},$=64;function ae(t,e,r){if(!(!t?.meshes||e<0||e>=$))for(let o of t.meshes)for(let i of o.primitives){let a=i.pluginData?.morph;a?.weights&&(a.weights[e]=r)}}var St={name:"morph",onResolveShader(t,e,r,o){if(!Array.isArray(t?.targets)||t.targets.length===0)return null;let i=r.replace("uniform mat4 uMVP,uModel;",`uniform mat4 uMVP,uModel;
16
+ */var ThreeLiveAnimation=(()=>{var tt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Ut=Object.getOwnPropertyNames,Kt=Object.prototype.hasOwnProperty,Jt=(t,e)=>{for(var r in e)tt(t,r,{get:e[r],enumerable:!0})},Lt=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ut(e))!Kt.call(t,i)&&i!==r&&tt(t,i,{get:()=>e[i],enumerable:!(o=Wt(e,i))||o.enumerable});return t},$t=t=>Lt(tt({},"__esModule",{value:!0}),t),pt={};Jt(pt,{IKSolver:()=>Gt,crossFadeTo:()=>_t,ikPlugin:()=>xt,keyframeAnimationPlugin:()=>St,morphPlugin:()=>Ft,parseAnimations:()=>kt,quatFromUnitVectors:()=>it,sampleChannel:()=>K,setMorphTargetWeight:()=>ae,skinningPlugin:()=>Rt,solveFABRIK:()=>wt,solveTwoBoneIK:()=>Mt});var q="__THREE_LIVE_REGISTRY__";function z(){let t=typeof globalThis<"u"?globalThis:{};if(!t[q]){let e={plugins:[],decoders:new Map};try{Object.defineProperty(t,q,{value:e,writable:!1,configurable:!1,enumerable:!1})}catch{t[q]=e}}return t[q]}var fe=z().plugins;function jt(t){let e=z();e.workerExtensionInstallers||(e.workerExtensionInstallers=[]),e.workerExtensionInstallers.includes(t)||e.workerExtensionInstallers.push(t)}function G(t){let e=z().plugins;e.some(r=>r.name===t.name)||e.push(t),t.onRegister?.()}function E(){let t=new Float32Array(16);return t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function dt(t,e,r){let o=e[0],i=e[1],a=e[2],g=e[3],d=e[4],n=e[5],s=e[6],l=e[7],u=e[8],h=e[9],f=e[10],M=e[11],c=e[12],p=e[13],w=e[14],b=e[15],m=r[0],A=r[1],x=r[2],k=r[3];return t[0]=m*o+A*d+x*u+k*c,t[1]=m*i+A*n+x*h+k*p,t[2]=m*a+A*s+x*f+k*w,t[3]=m*g+A*l+x*M+k*b,m=r[4],A=r[5],x=r[6],k=r[7],t[4]=m*o+A*d+x*u+k*c,t[5]=m*i+A*n+x*h+k*p,t[6]=m*a+A*s+x*f+k*w,t[7]=m*g+A*l+x*M+k*b,m=r[8],A=r[9],x=r[10],k=r[11],t[8]=m*o+A*d+x*u+k*c,t[9]=m*i+A*n+x*h+k*p,t[10]=m*a+A*s+x*f+k*w,t[11]=m*g+A*l+x*M+k*b,m=r[12],A=r[13],x=r[14],k=r[15],t[12]=m*o+A*d+x*u+k*c,t[13]=m*i+A*n+x*h+k*p,t[14]=m*a+A*s+x*f+k*w,t[15]=m*g+A*l+x*M+k*b,t}function et(t,e,r,o){let i=e[0],a=e[1],g=e[2],d=e[3],n=i+i,s=a+a,l=g+g,u=i*n,h=i*s,f=i*l,M=a*s,c=a*l,p=g*l,w=d*n,b=d*s,m=d*l,A=o[0],x=o[1],k=o[2];return t[0]=(1-(M+p))*A,t[1]=(h+m)*A,t[2]=(f-b)*A,t[3]=0,t[4]=(h-m)*x,t[5]=(1-(u+p))*x,t[6]=(c+w)*x,t[7]=0,t[8]=(f+b)*k,t[9]=(c-w)*k,t[10]=(1-(u+M))*k,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function gt(t,e,r=0){let o=e[0],i=e[1],a=e[2],g=e[4],d=e[5],n=e[6],s=e[8],l=e[9],u=e[10],h=u*d-n*l,f=-u*g+n*s,M=l*g-d*s,c=o*h+i*f+a*M;return!c||r>0&&(!Number.isFinite(c)||Math.abs(c)<=r)||(c=1/c,t[0]=h*c,t[1]=f*c,t[2]=M*c,t[3]=(-u*i+a*l)*c,t[4]=(u*o-a*s)*c,t[5]=(-l*o+i*s)*c,t[6]=(n*i-a*d)*c,t[7]=(-n*o+a*g)*c,t[8]=(d*o-i*g)*c),t}function Ct(t,e){let r=e[0],o=e[1],i=e[2],a=e[3],g=e[4],d=e[5],n=e[6],s=e[7],l=e[8],u=e[9],h=e[10],f=e[11],M=e[12],c=e[13],p=e[14],w=e[15],b=r*d-o*g,m=r*n-i*g,A=r*s-a*g,x=o*n-i*d,k=o*s-a*d,S=i*s-a*n,R=l*c-u*M,T=l*p-h*M,y=l*w-f*M,v=u*p-h*c,_=u*w-f*c,I=h*w-f*p,P=b*I-m*_+A*v+x*y-k*T+S*R;return P?(P=1/P,t[0]=(d*I-n*_+s*v)*P,t[1]=(i*_-o*I-a*v)*P,t[2]=(c*S-p*k+w*x)*P,t[3]=(h*k-u*S-f*x)*P,t[4]=(n*y-g*I-s*T)*P,t[5]=(r*I-i*y+a*T)*P,t[6]=(p*A-M*S-w*m)*P,t[7]=(l*S-h*A+f*m)*P,t[8]=(g*_-d*y+s*R)*P,t[9]=(o*y-r*_-a*R)*P,t[10]=(M*k-c*A+w*b)*P,t[11]=(u*A-l*k-f*b)*P,t[12]=(d*T-g*v-n*R)*P,t[13]=(r*v-o*T+i*R)*P,t[14]=(c*m-M*x-p*b)*P,t[15]=(l*x-u*m+h*b)*P,t):null}function qt(t,e){let r=Array.isArray(t?.nodes)?t.nodes.length:0,o=[];for(let l=0;l<r;l++)o.push(E());if(r===0)return o;let i=new Set;for(let l of t.nodes)if(Array.isArray(l.children))for(let u of l.children)i.add(u);let a=new Set,g=128,d=(l,u,h=0)=>{if(h>g||l<0||l>=r||a.has(l))return;a.add(l);let f=t.nodes[l];if(!f)return;let M=E();if(e&&e[l])M.set(e[l]);else if(f.matrix&&f.matrix.length===16)M.set(f.matrix);else{let p=f.translation||[0,0,0],w=f.rotation||[0,0,0,1],b=f.scale||[1,1,1];et(M,w,p,b)}let c=o[l];if(u?dt(c,u,M):c.set(M),Array.isArray(f.children))for(let p of f.children)typeof p=="number"&&d(p,c,h+1)},n=[],s=t.scenes&&t.scenes[t.scene!==void 0?t.scene:0];if(s&&Array.isArray(s.nodes))n.push(...s.nodes);else for(let l=0;l<r;l++)i.has(l)||n.push(l);for(let l of n)d(l,null);for(let l=0;l<r;l++)!i.has(l)&&!n.includes(l)&&d(l,null);return o}function rt(t,e){function r(n,s,l,u){let h=typeof n=="number"?n:Number(n);return Number.isFinite(h)?Math.max(s,Math.min(l,h)):u}function o(n,s){let l=n[0]*s[0]+n[1]*s[1]+n[2]*s[2]+1;if(l<1e-6){if(Math.abs(n[0])>Math.abs(n[2])){let p=Math.hypot(n[1],n[0])||1;return[-n[1]/p,n[0]/p,0,0]}let c=Math.hypot(n[2],n[1])||1;return[0,-n[2]/c,n[1]/c,0]}let u=n[1]*s[2]-n[2]*s[1],h=n[2]*s[0]-n[0]*s[2],f=n[0]*s[1]-n[1]*s[0],M=Math.hypot(u,h,f,l)||1;return[u/M,h/M,f/M,l/M]}function i(n,s,l,u,h){let f=s[0]-n[0],M=s[1]-n[1],c=s[2]-n[2],p=Math.hypot(f,M,c),w=l[0]-s[0],b=l[1]-s[1],m=l[2]-s[2],A=Math.hypot(w,b,m);if(p<1e-6||A<1e-6)return{rootPos:[n[0],n[1],n[2]],midPos:[s[0],s[1],s[2]],effectorPos:[l[0],l[1],l[2]],rootRotation:[0,0,0,1],midRotation:[0,0,0,1]};let x=[f/p,M/p,c/p],k=[w/A,b/A,m/A],S=u[0]-n[0],R=u[1]-n[1],T=u[2]-n[2],y=Math.hypot(S,R,T),v=y>1e-6?[S/y,R/y,T/y]:x,_=Math.abs(p-A)+1e-5,I=Math.max(_,p+A-1e-5),P=Math.max(_,Math.min(I,y>1e-6?y:_)),F=r((p*p+P*P-A*A)/(2*p*P),-1,1,1),O=Math.sqrt(Math.max(0,1-F*F)),N=h?h[0]-n[0]:f,$=h?h[1]-n[1]:M,j=h?h[2]-n[2]:c,U=N*v[0]+$*v[1]+j*v[2],B=N-v[0]*U,D=$-v[1]*U,Z=j-v[2]*U,C=Math.hypot(B,D,Z);if(C<=1e-6){let Dt=Math.abs(v[1])<.99?0:1,Et=Math.abs(v[1])<.99?1:0,Bt=0;B=v[1]*Bt-v[2]*Et,D=v[2]*Dt-v[0]*Bt,Z=v[0]*Et-v[1]*Dt,C=Math.hypot(B,D,Z)||1}let mt=[B/C,D/C,Z/C],V=[n[0]+v[0]*(p*F)+mt[0]*(p*O),n[1]+v[1]*(p*F)+mt[1]*(p*O),n[2]+v[2]*(p*F)+mt[2]*(p*O)],ct=[n[0]+v[0]*P,n[1]+v[1]*P,n[2]+v[2]*P],Ot=ct[0]-V[0],Vt=ct[1]-V[1],Nt=ct[2]-V[2],Q=Math.hypot(Ot,Vt,Nt),X=Q>1e-6?[Ot/Q,Vt/Q,Nt/Q]:v,le=[V[0]+X[0]*A,V[1]+X[1]*A,V[2]+X[2]*A],se=[(V[0]-n[0])/p,(V[1]-n[1])/p,(V[2]-n[2])/p];return{rootPos:[n[0],n[1],n[2]],midPos:V,effectorPos:le,rootRotation:o(x,se),midRotation:o(k,X)}}function a(n,s,l=8,u=.001){let h=n.length;if(h<2)return{positions:n.map(y=>[y[0],y[1],y[2]]),rotations:[],iterations:0};let f=n.map(y=>[y[0],y[1],y[2]]),M=[],c=[],p=0;for(let y=0;y<h-1;y++){let v=f[y+1][0]-f[y][0],_=f[y+1][1]-f[y][1],I=f[y+1][2]-f[y][2],P=Math.hypot(v,_,I);M.push(P),p+=P,c.push(P>1e-6?[v/P,_/P,I/P]:[0,1,0])}let w=[f[0][0],f[0][1],f[0][2]],b=Math.round(r(l,1,32,8)),m=r(u,1e-5,.1,.001),A=s[0]-w[0],x=s[1]-w[1],k=s[2]-w[2],S=Math.hypot(A,x,k),R=0;if(S>=p&&p>1e-6){let y=S>1e-6?[A/S,x/S,k/S]:c[0];f[0]=[w[0],w[1],w[2]];for(let v=0;v<h-1;v++){let _=M[v];f[v+1]=[f[v][0]+y[0]*_,f[v][1]+y[1]*_,f[v][2]+y[2]*_]}R=1}else for(let y=1;y<=b;y++){let v=f[h-1];if(Math.hypot(v[0]-s[0],v[1]-s[1],v[2]-s[2])<=m)break;R=y;let _=(I,P,F,O,N)=>{let $=P[0]-I[0],j=P[1]-I[1],U=P[2]-I[2],B=Math.hypot($,j,U);if(B>1e-6){let D=F/B;return[I[0]+$*D,I[1]+j*D,I[2]+U*D]}return[I[0]+O[0]*F*N,I[1]+O[1]*F*N,I[2]+O[2]*F*N]};f[h-1]=[s[0],s[1],s[2]];for(let I=h-2;I>=0;I--)f[I]=_(f[I+1],f[I],M[I],c[I],-1);f[0]=[w[0],w[1],w[2]];for(let I=0;I<h-1;I++)f[I+1]=_(f[I],f[I+1],M[I],c[I],1)}let T=[];for(let y=0;y<h-1;y++){let v=f[y+1][0]-f[y][0],_=f[y+1][1]-f[y][1],I=f[y+1][2]-f[y][2],P=Math.hypot(v,_,I),F=P>1e-6?[v/P,_/P,I/P]:c[y];T.push(o(c[y],F))}return{positions:f,rotations:T,iterations:R}}function g(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let s=n;if(s.enabled===!1)return null;let l=m=>{if(typeof m!="string")return;let A=m.trim().slice(0,64);return/^[A-Za-z0-9_.:-]+$/.test(A)?A:void 0},u=m=>Array.isArray(m)&&m.length===3&&m.every(A=>typeof A=="number"&&Number.isFinite(A))?[r(m[0],-1e3,1e3,0),r(m[1],-1e3,1e3,0),r(m[2],-1e3,1e3,0)]:void 0,h=l(s.root),f=l(s.effector);if(!h||!f)return null;let M=l(s.mid),c=u(s.target)??l(s.target);if(!c)return null;let p=s.pole??s.poleTarget,w=u(p)??l(p),b=s.solver==="fabrik"?"fabrik":s.solver==="two-bone"||M?"two-bone":"fabrik";return{root:h,...M?{mid:M}:{},effector:f,target:c,...w?{pole:w}:{},solver:b,iterations:Math.round(r(s.iterations,1,32,8)),tolerance:r(s.tolerance,1e-5,.1,.001),weight:r(s.weight,0,1,1)}}let d=Object.freeze({solveTwoBone:i,solveFABRIK:a,parseIKTrait:g});return e&&typeof e=="object"&&(e.authorNamespace=e.authorNamespace||{},e.authorNamespace.IKSolver=d),{clampNum:r,parseIKTrait:g,quatFromUnitVectors:o,solveTwoBoneIK:i,solveFABRIK:a,IKSolver:d}}var W=rt(),yt=W.clampNum,zt=W.parseIKTrait,it=W.quatFromUnitVectors,Mt=W.solveTwoBoneIK,wt=W.solveFABRIK,Gt=W.IKSolver;function ot(t){let e=t?.transform??t?.modelMatrix;return e&&e.length>=16?[e[12]||0,e[13]||0,e[14]||0]:[0,0,0]}function Ht(t,e){let r=t?.transform??t?.modelMatrix;!r||r.length<16||(r[12]=e[0],r[13]=e[1],r[14]=e[2])}function Yt(t,e,r,o,i){let a=yt(i,0,1,1),g=e[0]+(r[0]-e[0])*a,d=e[1]+(r[1]-e[1])*a,n=e[2]+(r[2]-e[2])*a,s=g-t[0],l=d-t[1],u=n-t[2],h=Math.hypot(s,l,u);if(h>1e-6&&o>1e-6){let w=o/h;return[t[0]+s*w,t[1]+l*w,t[2]+u*w]}let f=r[0]-t[0],M=r[1]-t[1],c=r[2]-t[2],p=Math.hypot(f,M,c);if(p>1e-6&&o>1e-6){let w=o/p;return[t[0]+f*w,t[1]+M*w,t[2]+c*w]}return[g,d,n]}function Zt(t,e){let r=t?.modelRootMatrix;if(!r||r.length!==16)return e;let o=new Float32Array(16);return Ct(o,r instanceof Float32Array?r:Float32Array.from(r))?[o[0]*e[0]+o[4]*e[1]+o[8]*e[2]+o[12],o[1]*e[0]+o[5]*e[1]+o[9]*e[2]+o[13],o[2]*e[0]+o[6]*e[1]+o[10]*e[2]+o[14]]:e}function nt(t,e){t.__ikWarned||(t.__ikWarned=new Set);let r=t.__ikWarned;r.has(e)||(r.add(e),console.warn(`[three-live] ik: joint '${e}' on '${t?.name??""}' not found among scene nodes or meshes.`))}function at(t,e,r){if(Array.isArray(t))return[t[0],t[1],t[2]];let o=e.get(t);if(o)return ot(o);let i;if(t==="head"?i=r?.headPose?.position??r?.headPose??r?.cameraPosition:t==="hand-left"?i=r?.handPoses?.left?.position??r?.handPoses?.left??r?.hands?.left?.position??r?.hands?.left:t==="hand-right"&&(i=r?.handPoses?.right?.position??r?.handPoses?.right??r?.hands?.right?.position??r?.hands?.right),(Array.isArray(i)||ArrayBuffer.isView(i))&&i.length>=3){let a=i;return Zt(r,[a[0],a[1],a[2]])}return null}function lt(t,e){return[t[3]*e[0]+t[0]*e[3]+t[1]*e[2]-t[2]*e[1],t[3]*e[1]-t[0]*e[2]+t[1]*e[3]+t[2]*e[0],t[3]*e[2]+t[0]*e[1]-t[1]*e[0]+t[2]*e[3],t[3]*e[3]-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]}function Qt(t){return[-t[0],-t[1],-t[2],t[3]]}function st(t){let e=Math.hypot(t[0],t[1],t[2],t[3]);return e>1e-12?[t[0]/e,t[1]/e,t[2]/e,t[3]/e]:[0,0,0,1]}function Xt(t,e){if(e>=1)return t;if(e<=0)return[0,0,0,1];let[r,o,i,a]=t;a<0&&(r=-r,o=-o,i=-i,a=-a);let g=Math.acos(Math.min(1,a)),d=Math.sin(g);if(d<1e-9)return[0,0,0,1];let n=Math.sin(g*e)/d;return st([r*n,o*n,i*n,Math.cos(g*e)])}function te(t){let e=Math.hypot(t[0],t[1],t[2])||1,r=Math.hypot(t[4],t[5],t[6])||1,o=Math.hypot(t[8],t[9],t[10])||1,i=t[0]/e,a=t[1]/e,g=t[2]/e,d=t[4]/r,n=t[5]/r,s=t[6]/r,l=t[8]/o,u=t[9]/o,h=t[10]/o,f=i+n+h,M;if(f>0){let c=Math.sqrt(f+1)*2;M=[(s-u)/c,(l-g)/c,(a-d)/c,.25*c]}else if(i>n&&i>h){let c=Math.sqrt(1+i-n-h)*2;M=[.25*c,(d+a)/c,(l+g)/c,(s-u)/c]}else if(n>h){let c=Math.sqrt(1+n-i-h)*2;M=[(d+a)/c,.25*c,(u+s)/c,(l-g)/c]}else{let c=Math.sqrt(1+h-i-n)*2;M=[(l+g)/c,(u+s)/c,.25*c,(a-d)/c]}return st(M)}function ee(t,e,r){let[o,i,a,g]=r,d=1-2*(i*i+a*a),n=2*(o*i-a*g),s=2*(o*a+i*g),l=2*(o*i+a*g),u=1-2*(o*o+a*a),h=2*(i*a-o*g),f=2*(o*a-i*g),M=2*(i*a+o*g),c=1-2*(o*o+i*i);for(let p=0;p<3;p++){let w=e[p*4],b=e[p*4+1],m=e[p*4+2];t[p*4]=d*w+n*b+s*m,t[p*4+1]=l*w+u*b+h*m,t[p*4+2]=f*w+M*b+c*m}}function H(t,e){let r=e[0]-t[0],o=e[1]-t[1],i=e[2]-t[2],a=Math.hypot(r,o,i);return a>1e-9?[r/a,o/a,i/a]:null}function bt(t){t?.normalMatrix&&t?.transform&&gt(t.normalMatrix,t.transform)}var vt=new WeakMap;function re(t){let e=vt.get(t);return e||(e=new Int32Array(t.nodes.length).fill(-1),t.nodes.forEach((r,o)=>{for(let i of Array.isArray(r?.children)?r.children:[])typeof i=="number"&&i>=0&&i<e.length&&(e[i]=o)}),vt.set(t,e)),e}function ie(t,e,r){let o=t?.gltf,i=o?.nodes;if(!Array.isArray(i)||i.length===0)return!1;let a=new Map;i.forEach((T,y)=>{typeof T?.name=="string"&&T.name&&!a.has(T.name)&&a.set(T.name,y)});let g=(e.mid?[e.root,e.mid,e.effector]:[e.root,e.effector]).map(T=>a.get(T));if(g.some(T=>T===void 0))return!1;let d=g,n=re(o);for(let T=1;T<d.length;T++){let y=n[d[T]],v=0;for(;y>=0&&y!==d[T-1]&&v++<256;)y=n[y];if(y!==d[T-1])return!1}let s=d[0],l=t.initialNodeTransforms,u=new Map,h=[],f=[s];for(;f.length&&h.length<4096;){let T=f.pop();if(u.has(T))continue;let y=l?.[T],v=i[T];u.set(T,{t:y?[y.t[0],y.t[1],y.t[2]]:v?.translation?[...v.translation]:[0,0,0],r:y?[y.r[0],y.r[1],y.r[2],y.r[3]]:v?.rotation?[...v.rotation]:[0,0,0,1],s:y?[y.s[0],y.s[1],y.s[2]]:v?.scale?[...v.scale]:[1,1,1]}),h.push(T);for(let _ of Array.isArray(v?.children)?v.children:[])typeof _=="number"&&f.push(_)}let M=n[s],c=M>=0&&t.worldMatrices?.[M]?.length===16?Float32Array.from(t.worldMatrices[M]):E(),p=new Map,w=()=>{let T=(y,v)=>{let _=u.get(y);if(!_)return;let I=E();et(I,_.r,_.t,_.s);let P=E();dt(P,v,I),p.set(y,P);for(let F of Array.isArray(i[y]?.children)?i[y].children:[])typeof F=="number"&&T(F,P)};T(s,c)},b=T=>{let y=p.get(T);return[y[12],y[13],y[14]]};w();let m=d.map(b),A=T=>{if(typeof T=="string"&&!r.has(T)){let y=a.get(T),v=y!==void 0?p.get(y)??t.worldMatrices?.[y]:void 0;if(v&&v.length===16)return[v[12],v[13],v[14]]}return at(T,r,t)},x=A(e.target);if(!x)return!0;let k=e.pole?A(e.pole)??void 0:void 0,S=At(m,e,x,k),R=yt(e.weight,0,1,1);for(let T=0;T<d.length-1;T++){let y=H(b(d[T]),b(d[T+1])),v=H(S[T],S[T+1]);if(!y||!v)continue;let _=Xt(it(y,v),R),I=d[T],P=n[I],F=P===M||P<0?c:p.get(P)??c,O=te(F),N=u.get(I);N.r=st(lt(Qt(O),lt(_,lt(O,N.r)))),w()}if(Array.isArray(t.worldMatrices))for(let[T,y]of p)t.worldMatrices[T]?.set&&t.worldMatrices[T].set(y);for(let T of t.meshes??[]){let y=p.get(T?.nodeIndex);y&&T.transform?.set&&(T.transform.set(y),bt(T))}return!0}function At(t,e,r,o){if(e.solver==="two-bone"&&t.length===3){let i=Mt(t[0],t[1],t[2],r,o);return[t[0],i.midPos,i.effectorPos]}return wt(t,r,e.iterations,e.tolerance).positions}function oe(t,e,r){let o=t.__ikRestOffsets,i=t.__ikRestMats;if(!(!o||!i))for(let a=0;a<e.length-1;a++){let g=e[a]?.transform??e[a]?.modelMatrix,d=i[a],n=H([0,0,0],o[a]),s=H(r[a],r[a+1]);!g||g.length<16||!d||d.length<16||!n||!s||(ee(g,d,it(n,s)),bt(e[a]))}}var xt={name:"ik",onRegister(){let t=z();jt(rt),rt(t.threeNamespace,t)},onUpdate(t){let e=t?.meshes;if(!Array.isArray(e)||e.length===0)return;let r=null;for(let o of e){let i=o?.userData?.xr?.ik??o?.extras?.xr?.ik??o?.extensions?.ANDROID_xr_scenecore?.ik;if(!i)continue;let a=zt(i);if(!a||a.weight<=0)continue;if(!r){r=new Map;for(let m of e)m&&typeof m.name=="string"&&m.name&&r.set(m.name,m)}if(ie(t,a,r))continue;let g=r.get(a.root),d=r.get(a.effector),n=a.mid?r.get(a.mid):void 0;if(g||nt(o,a.root),d||nt(o,a.effector),a.mid&&!n&&nt(o,a.mid),!g||!d)continue;let s=at(a.target,r,t);if(!s)continue;let l=a.pole?at(a.pole,r,t)??void 0:void 0,u=n?[g,n,d]:[g,d],h=u.map(m=>m.name||"").join(">");if(!o.__ikRestOffsets||o.__ikRestKey!==h){let m=u.map(ot),A=[];for(let x=0;x<m.length-1;x++)A.push([m[x+1][0]-m[x][0],m[x+1][1]-m[x][1],m[x+1][2]-m[x][2]]);o.__ikRestOffsets=A,o.__ikRestKey=h,o.__ikRestMats=u.map(x=>Array.from(x.transform??x.modelMatrix??[]))}let f=o.__ikRestOffsets,M=[ot(g)],c=[];for(let m=0;m<f.length;m++){let A=M[m],x=f[m];M.push([A[0]+x[0],A[1]+x[1],A[2]+x[2]]),c.push(Math.hypot(x[0],x[1],x[2]))}let p=At(M,a,s,l),w=M[0],b=[M[0]];for(let m=1;m<u.length;m++){let A=f[m-1],x=[w[0]+A[0],w[1]+A[1],w[2]+A[2]],k=[w[0]+(p[m][0]-p[m-1][0]),w[1]+(p[m][1]-p[m-1][1]),w[2]+(p[m][2]-p[m-1][2])],S=Yt(w,x,k,c[m-1],a.weight);Ht(u[m],S),w=S,b.push(S)}oe(o,u,b)}}},ne={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};function Y(t,e,r,o){if(!r||r.bufferView===void 0)return null;let i=t.bufferViews?.[r.bufferView];if(!i)return null;let a=Number(r.count??0);if(!Number.isInteger(a)||a<=0)return null;let g=r.componentType??5126,d=ne[g];if(!d)throw new RangeError(`glTF accessor has unsupported componentType ${g}`);let n=d*o,s=i.byteStride&&i.byteStride>0?i.byteStride:n,l=(i.byteOffset||0)+(r.byteOffset||0);if(!Number.isInteger(l)||l<0||s<n||l+(a-1)*s+n>e.byteLength)throw new RangeError(`glTF accessor reads past the end of the binary buffer (${e.byteLength} bytes)`);if(g===5126&&s===n&&l%4===0)return new Float32Array(e,l,a*o);let u=new DataView(e),h=r.normalized===!0,f=new Float32Array(a*o);for(let M=0;M<a;M++){let c=l+M*s;for(let p=0;p<o;p++){let w=c+p*d,b;switch(g){case 5126:b=u.getFloat32(w,!0);break;case 5120:b=u.getInt8(w),h&&(b=Math.max(b/127,-1));break;case 5121:b=u.getUint8(w),h&&(b/=255);break;case 5122:b=u.getInt16(w,!0),h&&(b=Math.max(b/32767,-1));break;case 5123:b=u.getUint16(w,!0),h&&(b/=65535);break;default:b=u.getUint32(w,!0),h&&(b/=4294967295)}f[M*o+p]=b}}return f}function Tt(t,e,r){return e%4===0?new Float32Array(t,e,r):new Float32Array(t.slice(e,e+r*4))}function Pt(t,e,r,o){let i=e[0],a=e[1],g=e[2],d=e[3],n=r[0],s=r[1],l=r[2],u=r[3],h=i*n+a*s+g*l+d*u;if(h<0&&(n=-n,s=-s,l=-l,u=-u,h=-h),Math.abs(h)>=1)return t[0]=i,t[1]=a,t[2]=g,t[3]=d,t;let f=Math.acos(h),M=Math.sqrt(1-h*h);if(Math.abs(M)<.001)return t[0]=.5*(i+n),t[1]=.5*(a+s),t[2]=.5*(g+l),t[3]=.5*(d+u),t;let c=Math.sin((1-o)*f)/M,p=Math.sin(o*f)/M;return t[0]=i*c+n*p,t[1]=a*c+s*p,t[2]=g*c+l*p,t[3]=d*c+u*p,t}function It(t,e,r,o){return t[0]=e[0]+o*(r[0]-e[0]),t[1]=e[1]+o*(r[1]-e[1]),t[2]=e[2]+o*(r[2]-e[2]),t}function kt(t,e){if(!Array.isArray(t?.animations))return[];let r=[];for(let o=0;o<t.animations.length;o++){let i=t.animations[o],a=i.name||`Animation_${o}`,g=[],d=0;if(Array.isArray(i.channels)&&Array.isArray(i.samplers))for(let n of i.channels){if(!n.target||n.target.node===void 0||!n.target.path)continue;let s=i.samplers[n.sampler];if(!s)continue;let l=t.accessors?.[s.input],u=t.accessors?.[s.output];if(!l||!u)continue;let h=t.bufferViews?.[l.bufferView],f=t.bufferViews?.[u.bufferView];if(!h||!f)continue;let M=(h.byteOffset||0)+(l.byteOffset||0),c=(f.byteOffset||0)+(u.byteOffset||0),p=Y(t,e,l,1)??Tt(e,M,l.count);p.length>0&&p[p.length-1]>d&&(d=p[p.length-1]);let w=n.target.path==="rotation"?4:n.target.path==="weights"?Math.max(1,Math.round(u.count/Math.max(1,l.count))):3,b=n.target.path==="weights"?1:w,m=Y(t,e,u,b)??Tt(e,c,u.count*b),A=s.interpolation==="STEP"?"STEP":"LINEAR";g.push({nodeIndex:n.target.node,path:n.target.path,times:p,values:m,interpolation:A})}g.length>0&&r.push({name:a,duration:d,channels:g})}return r}function K(t,e,r){let{times:o,values:i,path:a,interpolation:g}=t,d=o.length;if(d===0)return;let n=a==="rotation"?4:a==="weights"?Math.max(1,Math.round(i.length/d)):3;if(e<=o[0]){for(let b=0;b<n;b++)r[b]=i[b];return}if(e>=o[d-1]){let b=(d-1)*n;for(let m=0;m<n;m++)r[m]=i[b+m];return}let s=0,l=d-1;for(;s<=l;){let b=s+l>>1;o[b]<=e?s=b+1:l=b-1}let u=Math.max(0,l),h=Math.min(d-1,u+1);if(g==="STEP"||u===h){let b=u*n;for(let m=0;m<n;m++)r[m]=i[b+m];return}let f=o[u],M=o[h],c=(e-f)/Math.max(1e-5,M-f),p=u*n,w=h*n;if(a==="rotation"){let b=[i[p],i[p+1],i[p+2],i[p+3]],m=[i[w],i[w+1],i[w+2],i[w+3]];Pt(r,b,m,c)}else for(let b=0;b<n;b++)r[b]=i[p+b]+c*(i[w+b]-i[p+b])}var J=new WeakMap;function _t(t,e,r=.3){if(!t?.animations)return;let o=t.animations.find(d=>d.name===e);if(!o)return;let i=J.get(t);i||(i=[],t.currentClip&&i.push({clip:t.currentClip,time:t.animationTime||0,weight:1,fadeSpeed:0}),J.set(t,i));let a=r>0?1/r:1e3;for(let d of i)d.clip.name!==e&&(d.fadeSpeed=-a);let g=i.find(d=>d.clip.name===e);g?g.fadeSpeed=a:i.push({clip:o,time:0,weight:r>0?0:1,fadeSpeed:a}),t.currentClip=o,t.isPlayingAnimation=!0}function ft(t,e){if(!t.gltf||!Array.isArray(t.gltf.nodes))return;let r=J.get(t);if(!r||r.length===0){if(!t.currentClip)return;r=[{clip:t.currentClip,time:e,weight:1,fadeSpeed:0}]}let o=t.gltf.nodes.length,i=[];for(let u=0;u<o;u++){let h=t.initialNodeTransforms[u];h?i.push({t:[h.t[0],h.t[1],h.t[2]],r:[h.r[0],h.r[1],h.r[2],h.r[3]],s:[h.s[0],h.s[1],h.s[2]]}):i.push({t:[0,0,0],r:[0,0,0,1],s:[1,1,1]})}let a=[0,0,0],g=[0,0,0,1],d=[1,1,1],n=new Float32Array(64);for(let u of r){let h=Math.max(0,Math.min(1,u.weight));if(!(h<=1e-4))for(let f of u.clip.channels){if(f.nodeIndex<0||f.nodeIndex>=o)continue;let M=i[f.nodeIndex];if(f.path==="translation")K(f,u.time,a),It(M.t,M.t,a,h);else if(f.path==="rotation")K(f,u.time,g),Pt(M.r,M.r,g,h);else if(f.path==="scale")K(f,u.time,d),It(M.s,M.s,d,h);else if(f.path==="weights"&&(K(f,u.time,n),t.meshes)){for(let c of t.meshes)if(c.nodeIndex===f.nodeIndex){for(let p of c.primitives)if(p.pluginData?.morph?.weights){let w=p.pluginData.morph.weights,b=p.pluginData.morph.numTargets||w.length;for(let m=0;m<b;m++)w[m]=w[m]*(1-h)+n[m]*h}}}}}let s=[];for(let u=0;u<o;u++){let h=E(),{t:f,r:M,s:c}=i[u];et(h,M,f,c),s.push(h)}let l=qt(t.gltf,s);t.worldMatrices=l;for(let u of t.meshes)u.nodeIndex>=0&&u.nodeIndex<l.length&&(u.transform.set(l[u.nodeIndex]),gt(u.normalMatrix,u.transform))}var ut=t=>{J.delete(t)},St={name:"keyframes",evaluateAnimation:ft,crossFadeTo:_t,onParseGLB(t){(t.animationsParsed===!1||!t.animations)&&(t.animations=kt(t.gltf,t.bin),t.animationsParsed=!0)},onLoadModel:ut,onClearScene:ut,onDestroy:(t,e)=>ut(e),onUpdate(t,e){if(!t.isPlayingAnimation)return;let r=J.get(t);if(r&&r.length>0){for(let o=r.length-1;o>=0;o--){let i=r[o];if(i.time+=e,i.clip.duration>0&&(i.time%=i.clip.duration),i.fadeSpeed!==0)if(i.weight+=i.fadeSpeed*e,i.weight<=0){r.splice(o,1);continue}else i.weight>=1&&(i.weight=1,i.fadeSpeed=0)}r.length>0&&(t.animationTime=r[r.length-1].time),ft(t,t.animationTime)}else t.currentClip&&(t.animationTime+=e,t.currentClip.duration>0&&(t.animationTime%=t.currentClip.duration),ft(t,t.animationTime))}},L=64;function ae(t,e,r){if(!(!t?.meshes||e<0||e>=L))for(let o of t.meshes)for(let i of o.primitives){let a=i.pluginData?.morph;a?.weights&&(a.weights[e]=r)}}var Ft={name:"morph",onResolveShader(t,e,r,o){if(!Array.isArray(t?.targets)||t.targets.length===0)return null;let i=r.replace("uniform mat4 uMVP,uModel;",`uniform mat4 uMVP,uModel;
17
17
  uniform sampler2D uMorphDeltasTex;
18
- uniform float uMorphWeights[${$}];
18
+ uniform float uMorphWeights[${L}];
19
19
  uniform int uNumMorphTargets;`);return i=i.replace("vec4 world=uModel*vec4(aPosition,1.0);",`vec3 morphedPos = aPosition;
20
- for (int m = 0; m < ${$}; m++) {
20
+ for (int m = 0; m < ${L}; m++) {
21
21
  if (m >= uNumMorphTargets) break;
22
22
  float w = uMorphWeights[m];
23
23
  if (abs(w) > 0.0001) {
24
24
  morphedPos += texelFetch(uMorphDeltasTex, ivec2(gl_VertexID, m), 0).xyz * w;
25
25
  }
26
26
  }
27
- vec4 world=uModel*vec4(morphedPos,1.0);`).replace("gl_Position=uMVP*vec4(aPosition,1.0);","gl_Position=uMVP*vec4(morphedPos,1.0);"),{vs:i,fs:o}},onBuildPrimitiveVAO(t,e,r,o,i){let a=r?.targets;if(!Array.isArray(a)||a.length===0)return null;let g=r.attributes?.POSITION,p=o?.accessors?.[g];if(!p)return null;let n=p.count,s=Math.min(a.length,$),l=new Float32Array(n*s*4);for(let f=0;f<s;f++){let M=a[f].POSITION;if(M===void 0)continue;let c=o.accessors?.[M],d=o.bufferViews?.[c?.bufferView];if(!c||!d)continue;let b=Y(o,i,c,3);if(!b||b.length<n*3)continue;let v=f*n*4;for(let m=0;m<n;m++)l[v+m*4]=b[m*3],l[v+m*4+1]=b[m*3+1],l[v+m*4+2]=b[m*3+2],l[v+m*4+3]=0}let u=t.createTexture();t.bindTexture(3553,u),t.texImage2D(3553,0,34836,n,s,0,6408,5126,l),t.texParameteri(3553,10242,33071),t.texParameteri(3553,10243,33071),t.texParameteri(3553,10241,9728),t.texParameteri(3553,10240,9728);let h=new Float32Array($);return{hasMorph:!0,morphTex:u,numTargets:s,vertexCount:n,weights:h}},onBeforeDrawPrimitive(t,e,r,o,i,a){let g=r.pluginData?.morph;if(!g?.hasMorph||!g.morphTex)return;t.activeTexture(33989),t.bindTexture(3553,g.morphTex);let p=t.getUniformLocation(e,"uMorphDeltasTex");p&&t.uniform1i(p,5);let n=t.getUniformLocation(e,"uNumMorphTargets");n&&t.uniform1i(n,g.numTargets);let s=t.getUniformLocation(e,"uMorphWeights[0]");s&&t.uniform1fv(s,g.weights)}},ht=64,Vt={name:"skinning",onResolveShader(t,e,r,o){if(t?.attributes?.JOINTS_0===void 0||t?.attributes?.WEIGHTS_0===void 0)return null;let i=r.replace("layout(location=2) in vec2 aUV;",`layout(location=2) in vec2 aUV;
27
+ vec4 world=uModel*vec4(morphedPos,1.0);`).replace("gl_Position=uMVP*vec4(aPosition,1.0);","gl_Position=uMVP*vec4(morphedPos,1.0);"),{vs:i,fs:o}},onBuildPrimitiveVAO(t,e,r,o,i){let a=r?.targets;if(!Array.isArray(a)||a.length===0)return null;let g=r.attributes?.POSITION,d=o?.accessors?.[g];if(!d)return null;let n=d.count,s=Math.min(a.length,L),l=new Float32Array(n*s*4);for(let f=0;f<s;f++){let M=a[f].POSITION;if(M===void 0)continue;let c=o.accessors?.[M],p=o.bufferViews?.[c?.bufferView];if(!c||!p)continue;let w=Y(o,i,c,3);if(!w||w.length<n*3)continue;let b=f*n*4;for(let m=0;m<n;m++)l[b+m*4]=w[m*3],l[b+m*4+1]=w[m*3+1],l[b+m*4+2]=w[m*3+2],l[b+m*4+3]=0}let u=t.createTexture();t.bindTexture(3553,u),t.texImage2D(3553,0,34836,n,s,0,6408,5126,l),t.texParameteri(3553,10242,33071),t.texParameteri(3553,10243,33071),t.texParameteri(3553,10241,9728),t.texParameteri(3553,10240,9728);let h=new Float32Array(L);return{hasMorph:!0,morphTex:u,numTargets:s,vertexCount:n,weights:h}},onBeforeDrawPrimitive(t,e,r,o,i,a){let g=r.pluginData?.morph;if(!g?.hasMorph||!g.morphTex)return;t.activeTexture(33989),t.bindTexture(3553,g.morphTex);let d=t.getUniformLocation(e,"uMorphDeltasTex");d&&t.uniform1i(d,5);let n=t.getUniformLocation(e,"uNumMorphTargets");n&&t.uniform1i(n,g.numTargets);let s=t.getUniformLocation(e,"uMorphWeights[0]");s&&t.uniform1fv(s,g.weights)}},ht=64,Rt={name:"skinning",onResolveShader(t,e,r,o){if(t?.attributes?.JOINTS_0===void 0||t?.attributes?.WEIGHTS_0===void 0)return null;let i=r.replace("layout(location=2) in vec2 aUV;",`layout(location=2) in vec2 aUV;
28
28
  layout(location=4) in uvec4 aJoints;
29
29
  layout(location=5) in vec4 aWeights;
30
30
  uniform mat4 uJointMatrix[${ht}];`),a=i.includes("morphedPos")?"morphedPos":"aPosition";return i=i.replace(`vec4 world=uModel*vec4(${a},1.0);`,`mat4 skinMatrix =
@@ -32,4 +32,4 @@ uniform mat4 uJointMatrix[${ht}];`),a=i.includes("morphedPos")?"morphedPos":"aPo
32
32
  aWeights.y * uJointMatrix[int(aJoints.y)] +
33
33
  aWeights.z * uJointMatrix[int(aJoints.z)] +
34
34
  aWeights.w * uJointMatrix[int(aJoints.w)];
35
- vec4 world=uModel*(skinMatrix*vec4(${a},1.0));`).replace(`gl_Position=uMVP*vec4(${a},1.0);`,`gl_Position=uMVP*(skinMatrix*vec4(${a},1.0));`),{vs:i,fs:o}},onBuildPrimitiveVAO(t,e,r,o,i){let a=r?.attributes;if(!a||a.JOINTS_0===void 0||a.WEIGHTS_0===void 0)return null;let g=o.accessors[a.JOINTS_0],p=o.accessors[a.WEIGHTS_0];if(!g||!p)return null;let n=o.bufferViews[g.bufferView],s=o.bufferViews[p.bufferView];if(!n||!s)return null;let l=(n.byteOffset||0)+(g.byteOffset||0),u=(s.byteOffset||0)+(p.byteOffset||0),h=t.createBuffer();t.bindBuffer(34962,h);let f=g.componentType===5121?5121:5123,M=f===5121?new Uint8Array(i,l,g.count*4):new Uint16Array(i,l,g.count*4);t.bufferData(34962,M,35044),t.enableVertexAttribArray(4),t.vertexAttribIPointer(4,4,f,0,0);let c=t.createBuffer();t.bindBuffer(34962,c);let d=Y(o,i,p,4)??new Float32Array(i,u,p.count*4);return t.bufferData(34962,d,35044),t.enableVertexAttribArray(5),t.vertexAttribPointer(5,4,5126,!1,0,0),{hasSkin:!0,buffers:[h,c]}},onBeforeDrawPrimitive(t,e,r,o,i,a){if(!r.pluginData?.skinning?.hasSkin)return;let g=a?.nodes?.[o.nodeIndex]?.skin;if(g===void 0||!a.skins||!a.skins[g])return;let p=a.skins[g].joints||[],n=new Float32Array(ht*16);for(let l=0;l<p.length&&l<ht;l++){let u=p[l],h=i[u]||E();n.subarray(l*16,(l+1)*16).set(h)}let s=t.getUniformLocation(e,"uJointMatrix[0]");s&&t.uniformMatrix4fv(s,!1,n)}};return G(St),G(Ft),G(Vt),G(xt),jt(dt)})();
35
+ vec4 world=uModel*(skinMatrix*vec4(${a},1.0));`).replace(`gl_Position=uMVP*vec4(${a},1.0);`,`gl_Position=uMVP*(skinMatrix*vec4(${a},1.0));`),{vs:i,fs:o}},onBuildPrimitiveVAO(t,e,r,o,i){let a=r?.attributes;if(!a||a.JOINTS_0===void 0||a.WEIGHTS_0===void 0)return null;let g=o.accessors[a.JOINTS_0],d=o.accessors[a.WEIGHTS_0];if(!g||!d)return null;let n=o.bufferViews[g.bufferView],s=o.bufferViews[d.bufferView];if(!n||!s)return null;let l=(n.byteOffset||0)+(g.byteOffset||0),u=(s.byteOffset||0)+(d.byteOffset||0),h=t.createBuffer();t.bindBuffer(34962,h);let f=g.componentType===5121?5121:5123,M=f===5121?new Uint8Array(i,l,g.count*4):new Uint16Array(i,l,g.count*4);t.bufferData(34962,M,35044),t.enableVertexAttribArray(4),t.vertexAttribIPointer(4,4,f,0,0);let c=t.createBuffer();t.bindBuffer(34962,c);let p=Y(o,i,d,4)??new Float32Array(i,u,d.count*4);return t.bufferData(34962,p,35044),t.enableVertexAttribArray(5),t.vertexAttribPointer(5,4,5126,!1,0,0),{hasSkin:!0,buffers:[h,c]}},onBeforeDrawPrimitive(t,e,r,o,i,a){if(!r.pluginData?.skinning?.hasSkin)return;let g=a?.nodes?.[o.nodeIndex]?.skin;if(g===void 0||!a.skins||!a.skins[g])return;let d=a.skins[g].joints||[],n=new Float32Array(ht*16);for(let l=0;l<d.length&&l<ht;l++){let u=d[l],h=i[u]||E();n.subarray(l*16,(l+1)*16).set(h)}let s=t.getUniformLocation(e,"uJointMatrix[0]");s&&t.uniformMatrix4fv(s,!1,n)}};return G(Ft),G(St),G(Rt),G(xt),$t(pt)})();
@@ -13,5 +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
- */var Te=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Cn=Object.getOwnPropertyNames,Tn=Object.prototype.hasOwnProperty,Ln=(z,N)=>{for(var X in N)Te(z,X,{get:N[X],enumerable:!0})},En=(z,N,X,ae)=>{if(N&&typeof N=="object"||typeof N=="function")for(let K of Cn(N))!Tn.call(z,K)&&K!==X&&Te(z,K,{get:()=>N[K],enumerable:!(ae=kn(N,K))||ae.enumerable});return z},zn=z=>En(Te({},"__esModule",{value:!0}),z),_n={};Ln(_n,{MAX_BSP_DEPTH:()=>an,MAX_CSG_TRIANGLES:()=>cn,MAX_SHAPE_POINTS:()=>ln,MAX_TEXT_GEOMETRY_CHARS:()=>un,cadPlugin:()=>Le,installCadExtension:()=>Se}),module.exports=zn(_n);var ve="__THREE_LIVE_REGISTRY__";function me(){let z=typeof globalThis<"u"?globalThis:{};if(!z[ve]){let N={plugins:[],decoders:new Map};try{Object.defineProperty(z,ve,{value:N,writable:!1,configurable:!1,enumerable:!1})}catch{z[ve]=N}}return z[ve]}var In=me().plugins;function on(z){let N=me();N.workerExtensionInstallers||(N.workerExtensionInstallers=[]),N.workerExtensionInstallers.includes(z)||N.workerExtensionInstallers.push(z)}function rn(z){let N=me().plugins;N.some(X=>X.name===z.name)||N.push(z),z.onRegister?.()}var cn=8192,an=2048,un=128,ln=4096;function Se(z,N){if(!z||!z.BufferGeometry)return null;let X=z.Vector2,ae=z.Vector3,K=z.Quaternion,Me=z.Matrix4,st=z.Matrix3,it=z.Color,Pe=z.BufferAttribute,te=z.BufferGeometry,lt=z.Material,Ae=z.MeshStandardMaterial,pe=z.Mesh,ue=8192,ne=2048,Ee=128,ze=4096,B=(t,e)=>{let n=t==null?NaN:Number(t);return Number.isFinite(n)?n:e};class ye{constructor(e){this.currentPoint=new X(0,0),this.segments=[],Array.isArray(e)&&e.length>0&&this.fromPoints(e)}fromPoints(e){if(!e.length)return this;this.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){let r=Number(e)||0,i=Number(n)||0;return this.currentPoint.set(r,i),this.segments.push({type:"move",pts:[r,i]}),this}lineTo(e,n){let r=Number(e)||0,i=Number(n)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(r,i),this.segments.push({type:"line",pts:[r,i]}),this}quadraticCurveTo(e,n,r,i){let h=this.currentPoint.x,o=this.currentPoint.y,a=Number(e)||0,u=Number(n)||0,s=Number(r)||0,p=Number(i)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[h,o]}),this.currentPoint.set(s,p),this.segments.push({type:"quad",pts:[h,o,a,u,s,p]}),this}bezierCurveTo(e,n,r,i,h,o){let a=this.currentPoint.x,u=this.currentPoint.y,s=Number(e)||0,p=Number(n)||0,c=Number(r)||0,l=Number(i)||0,f=Number(h)||0,x=Number(o)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,u]}),this.currentPoint.set(f,x),this.segments.push({type:"cubic",pts:[a,u,s,p,c,l,f,x]}),this}absarc(e,n,r,i,h,o=!1){return this.absellipse(e,n,r,r,i,h,o,0)}arc(e,n,r,i,h,o=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),r,i,h,o)}absellipse(e,n,r,i,h,o,a=!1,u=0){let s=Number(e)||0,p=Number(n)||0,c=Math.max(0,Number(r)||0),l=Math.max(0,Number(i)||0),f=Number(h)||0,x=Number(o)||0,m=a?1:0,y=Number(u)||0;this.segments.push({type:"arc",pts:[s,p,c,l,f,x,m,y]});let g=Math.cos(y),b=Math.sin(y),M=c*Math.cos(x),d=l*Math.sin(x);return this.currentPoint.set(s+M*g-d*b,p+M*b+d*g),this}ellipse(e,n,r,i,h,o,a=!1,u=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(n)||0),r,i,h,o,a,u)}closePath(){if(this.segments.length>0){let e=this.segments[0],n=0,r=0;if(e.type==="arc"){let i=e.pts[0],h=e.pts[1],o=e.pts[2],a=e.pts[3],u=e.pts[4],s=e.pts[7],p=Math.cos(s),c=Math.sin(s),l=o*Math.cos(u),f=a*Math.sin(u);n=i+l*p-f*c,r=h+l*c+f*p}else n=e.pts[0],r=e.pts[1];Math.hypot(this.currentPoint.x-n,this.currentPoint.y-r)>1e-6&&this.lineTo(n,r)}return this}getPoints(e=12){let n=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),r=[],i=(h,o)=>{if(r.length>0){let a=r[r.length-1];if(Math.hypot(a.x-h,a.y-o)<1e-6)return}r.push(new X(h,o))};for(let h of this.segments){let o=h.pts;if(h.type==="move"||h.type==="line")i(o[0],o[1]);else if(h.type==="quad"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5];i(a,u);for(let f=1;f<=n;f++){let x=f/n,m=1-x;i(m*m*a+2*m*x*s+x*x*c,m*m*u+2*m*x*p+x*x*l)}}else if(h.type==="cubic"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5],f=o[6],x=o[7];i(a,u);for(let m=1;m<=n;m++){let y=m/n,g=1-y,b=g*g,M=y*y;i(b*g*a+3*b*y*s+3*g*M*c+M*y*f,b*g*u+3*b*y*p+3*g*M*l+M*y*x)}}else if(h.type==="arc"){let a=o[0],u=o[1],s=o[2],p=o[3],c=o[4],l=o[5],f=o[6]!==0,x=o[7],m=Math.PI*2,y=l-c,g=Math.abs(y)<1e-9;for(;y<0;)y+=m;for(;y>m;)y-=m;y<1e-9&&(y=g?0:m),f&&!g&&(y=y===m?-m:y-m);let b=Math.cos(x),M=Math.sin(x),d=Math.max(2,n);for(let _=0;_<=d;_++){let P=_/d,S=c+P*y,T=s*Math.cos(S),A=p*Math.sin(S);i(a+T*b-A*M,u+T*M+A*b)}}}if(r.length>2){let h=r[0],o=r[r.length-1];Math.hypot(h.x-o.x,h.y-o.y)<1e-6&&r.pop()}return r}getSpacedPoints(e=12){return this.getPoints(e)}clone(){let e=new this.constructor;return e.currentPoint.copy(this.currentPoint),e.segments=this.segments.map(n=>({type:n.type,pts:[...n.pts]})),Array.isArray(this.holes)&&(e.holes=this.holes.map(n=>n.clone())),e}}class fe extends ye{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(n=>n.getPoints(e))}}}function xe(t){let e=0,n=t.length;for(let r=0,i=n-1;r<n;i=r++)e+=t[i].x*t[r].y-t[r].x*t[i].y;return e*.5}function ot(t,e,n,r,i,h,o,a){let u=o-n,s=a-r,p=i-n,c=h-r,l=t-n,f=e-r,x=u*u+s*s,m=u*p+s*c,y=u*l+s*f,g=p*p+c*c,b=p*l+c*f,M=x*g-m*m;if(Math.abs(M)<1e-12)return!1;let d=1/M,_=(g*y-m*b)*d,P=(x*b-m*y)*d;return _>=-1e-7&&P>=-1e-7&&_+P<=1+1e-7}function ke(t,e){let n=t.slice();xe(n)<0&&n.reverse();let r=n.map(u=>new X(u.x,u.y)),i=n.map((u,s)=>s),h=[];for(let u of e){if(!u||u.length<3)continue;let s=u.slice();xe(s)>0&&s.reverse();let p=[],c=-1/0,l=0;for(let f=0;f<s.length;f++){let x=s[f],m=r.length;r.push(new X(x.x,x.y)),p.push(m),x.x>c&&(c=x.x,l=f)}h.push({pts:s,indices:p,maxX:c,maxIdx:l})}h.sort((u,s)=>s.maxX-u.maxX);let o=(u,s,p)=>(s.x-u.x)*(p.y-u.y)-(s.y-u.y)*(p.x-u.x),a=(u,s,p)=>{for(let c=0;c<p.length;c++){let l=p[c],f=p[(c+1)%p.length];if(o(u,s,l)*o(u,s,f)<0&&o(l,f,u)*o(l,f,s)<0)return!0}return!1};for(let u of h){let s=u.pts[u.maxIdx],p=s.x,c=i.length,l=i.map(g=>r[g]),f=g=>Math.hypot(l[g].x-p,l[g].y-s.y),x=l.map((g,b)=>b).sort((g,b)=>+(l[g].x<p)-+(l[b].x<p)||f(g)-f(b)),m=x[0];for(let g of x){let b=l[g],M=l[(g+c-1)%c],d=l[(g+1)%c],_=o(b,d,s)>=0,P=o(M,b,s)>=0;if((o(M,b,d)>=0?_&&P:_||P)&&!a(s,b,l)&&!h.some(S=>a(s,b,S.pts))){m=g;break}}let y=[];for(let g=0;g<=m;g++)y.push(i[g]);for(let g=0;g<=u.indices.length;g++){let b=u.indices[(u.maxIdx+g)%u.indices.length];y.push(b)}for(let g=m;g<i.length;g++)y.push(i[g]);i=y}return{merged:i.map(u=>r[u]),mergedIndices:i,allVertices:r}}function Ge(t,e){let n=[],r=t.slice();if(r.length<3)return n;let i=r.length*r.length+64,h=0;for(;r.length>2&&i-- >0;){let o=r.length,a=r[(h+o-1)%o],u=r[h%o],s=r[(h+1)%o],p=e[a],c=e[u],l=e[s];if((c.x-p.x)*(l.y-p.y)-(c.y-p.y)*(l.x-p.x)>1e-9){let f=!0;for(let x=0;x<o;x++){let m=r[x];if(m===a||m===u||m===s)continue;let y=e[m];if(ot(y.x,y.y,p.x,p.y,c.x,c.y,l.x,l.y)&&Math.hypot(y.x-p.x,y.y-p.y)>=1e-6&&Math.hypot(y.x-c.x,y.y-c.y)>=1e-6&&Math.hypot(y.x-l.x,y.y-l.y)>=1e-6){f=!1;break}}if(f){n.push([a,u,s]),r.splice(h%o,1),h=Math.max(0,h%o-1);continue}}h++,h>=o*2&&(n.push([a,u,s]),r.splice((h-1)%o,1),h=0)}return n}function Ce(t,e){let n=t instanceof fe?t.extractPoints(e):{shape:t.getPoints(e),holes:[]},r=n.shape.length;for(let i of n.holes)r+=i.length;if(r>ze)throw new RangeError(`SecurityError: shape point count (${r}) exceeds MAX_SHAPE_POINTS (${ze})`);return n}class ht extends te{constructor(e=new fe,n=12){super();let r=Array.isArray(e)?e:[e],i=[],h=[],o=[],a=[];for(let u of r){if(!(u instanceof ye))continue;let s=Ce(u,n);if(s.shape.length<3)continue;let{mergedIndices:p,allVertices:c}=ke(s.shape,s.holes),l=Ge(p,c),f=i.length/3,x=1/0,m=1/0,y=-1/0,g=-1/0;for(let d of c)d.x<x&&(x=d.x),d.y<m&&(m=d.y),d.x>y&&(y=d.x),d.y>g&&(g=d.y);let b=Math.max(1e-6,y-x),M=Math.max(1e-6,g-m);for(let d of c)i.push(d.x,d.y,0),h.push(0,0,1),o.push((d.x-x)/b,(d.y-m)/M);for(let[d,_,P]of l)a.push(f+d,f+_,f+P)}ge(this,i,h,o,a)}}function ge(t,e,n,r,i){return t.setAttribute("position",new Pe(e,3)),t.setAttribute("normal",new Pe(n,3)),t.setAttribute("uv",new Pe(r,2)),t.setIndex(i),t}function at(t){let e=t.length,n=[];for(let r=0;r<e;r++){let i=t[(r+e-1)%e],h=t[r],o=t[(r+1)%e],a=h.x-i.x,u=h.y-i.y,s=Math.hypot(a,u)||1;a/=s,u/=s;let p=o.x-h.x,c=o.y-h.y,l=Math.hypot(p,c)||1;p/=l,c/=l;let f=u,x=-a,m=c,y=-p,g=f+m,b=x+y,M=Math.hypot(g,b);if(M>1e-6){g/=M,b/=M;let d=Math.max(.35,g*f+b*x);n.push(new X(g/d,b/d))}else n.push(new X(f,x))}return n}class ut extends te{constructor(e=new fe,n={}){super();let r=Array.isArray(e)?e:[e],i=Math.max(1,Math.min(64,Math.floor(B(n.curveSegments,12)))),h=B(n.depth??n.amount,1),o=Math.max(1,Math.min(32,Math.floor(B(n.steps,1)))),a=!!(n.bevelEnabled??!1),u=a?Math.max(0,B(n.bevelThickness,.06)):0,s=a?Math.max(0,B(n.bevelSize,u*.8)):0,p=a?B(n.bevelOffset,0):0,c=a?Math.max(1,Math.min(8,Math.floor(B(n.bevelSegments,2)))):0,l=[],f=[],x=[],m=[];for(let y of r){if(!(y instanceof ye))continue;let g=Ce(y,i);if(g.shape.length<3)continue;let b=g.shape.slice();xe(b)<0&&b.reverse();let M=[];for(let v of g.holes){if(v.length<3)continue;let w=v.slice();xe(w)>0&&w.reverse(),M.push(w)}let{mergedIndices:d,allVertices:_}=ke(b,M),P=Ge(d,_),S=[b,...M],T=[];for(let v of S){let w=at(v);for(let E of w)T.push(E)}let A=1/0,I=1/0,C=-1/0,L=-1/0;for(let v of _)v.x<A&&(A=v.x),v.y<I&&(I=v.y),v.x>C&&(C=v.x),v.y>L&&(L=v.y);let R=Math.max(1e-6,C-A),q=Math.max(1e-6,L-I),re=-u,se=h+u,Y=l.length/3;for(let v=0;v<_.length;v++){let w=_[v],E=T[v]??new X(0,0),k=w.x+E.x*p,G=w.y+E.y*p;l.push(k,G,re),f.push(0,0,-1),x.push((k-A)/R,(G-I)/q)}for(let[v,w,E]of P)m.push(Y+v,Y+E,Y+w);let $=l.length/3;for(let v=0;v<_.length;v++){let w=_[v],E=T[v]??new X(0,0),k=w.x+E.x*p,G=w.y+E.y*p;l.push(k,G,se),f.push(0,0,1),x.push((k-A)/R,(G-I)/q)}for(let[v,w,E]of P)m.push($+v,$+w,$+E);let D=[];if(a&&c>0)for(let v=0;v<c;v++){let w=v/c*Math.PI/2;D.push({z:-u*Math.cos(w),expand:p+s*Math.sin(w)})}for(let v=0;v<=o;v++){let w=v/o;D.push({z:w*h,expand:p+s})}if(a&&c>0)for(let v=1;v<=c;v++){let w=v/c*Math.PI/2;D.push({z:h+u*Math.sin(w),expand:p+s*Math.cos(w)})}let H=0;for(let v of S){let w=v.length;for(let E=0;E<D.length-1;E++){let k=D[E],G=D[E+1];for(let O=0;O<w;O++){let j=(O+1)%w,F=v[O],J=v[j],Z=T[H+O],U=T[H+j],Q=F.x+Z.x*k.expand,W=F.y+Z.y*k.expand,ee=J.x+U.x*k.expand,V=J.y+U.y*k.expand,mt=J.x+U.x*G.expand,bt=J.y+U.y*G.expand,$e=F.x+Z.x*G.expand,Fe=F.y+Z.y*G.expand,Je=ee-Q,Ze=V-W,Ue=0,Qe=$e-Q,We=Fe-W,Ke=G.z-k.z,ie=Ze*Ke-Ue*We,le=Ue*Qe-Je*Ke,oe=Je*We-Ze*Qe,_e=Math.hypot(ie,le,oe)||1;ie/=_e,le/=_e,oe/=_e;let he=l.length/3;l.push(Q,W,k.z,ee,V,k.z,mt,bt,G.z,$e,Fe,G.z),f.push(ie,le,oe,ie,le,oe,ie,le,oe,ie,le,oe);let et=O/w,tt=(O+1)/w,nt=E/(D.length-1),rt=(E+1)/(D.length-1);x.push(et,nt,tt,nt,tt,rt,et,rt),m.push(he,he+1,he+2,he,he+2,he+3)}}H+=w}}ge(this,l,f,x,m)}}function Ie(t){return{x:t.x,y:t.y,z:t.z,nx:t.nx,ny:t.ny,nz:t.nz,u:t.u,v:t.v}}function ct(t){return{x:t.x,y:t.y,z:t.z,nx:-t.nx,ny:-t.ny,nz:-t.nz,u:t.u,v:t.v}}function pt(t,e,n){let r=t.nx+(e.nx-t.nx)*n,i=t.ny+(e.ny-t.ny)*n,h=t.nz+(e.nz-t.nz)*n,o=Math.hypot(r,i,h)||1;return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n,z:t.z+(e.z-t.z)*n,nx:r/o,ny:i/o,nz:h/o,u:t.u+(e.u-t.u)*n,v:t.v+(e.v-t.v)*n}}function yt(t){if(t.length<3)return null;let e=t[0],n=t[1],r=t[2],i=n.x-e.x,h=n.y-e.y,o=n.z-e.z,a=r.x-e.x,u=r.y-e.y,s=r.z-e.z,p=h*s-o*u,c=o*a-i*s,l=i*u-h*a,f=Math.hypot(p,c,l);if(f<1e-9)return null;p/=f,c/=f,l/=f;let x=p*e.x+c*e.y+l*e.z;return{vertices:t,nx:p,ny:c,nz:l,w:x}}function ft(t){t.vertices.reverse();for(let e=0;e<t.vertices.length;e++)t.vertices[e]=ct(t.vertices[e]);t.nx=-t.nx,t.ny=-t.ny,t.nz=-t.nz,t.w=-t.w}let Re=1e-5,Xe=0,we=1,be=2,De=3;function Oe(t,e,n,r,i,h,o,a,u){let s=0,p=[];for(let c=0;c<i.vertices.length;c++){let l=i.vertices[c],f=t*l.x+e*l.y+n*l.z-r,x=f<-Re?be:f>Re?we:Xe;s|=x,p.push(x)}switch(s){case Xe:{t*i.nx+e*i.ny+n*i.nz>0?h.push(i):o.push(i);break}case we:a.push(i);break;case be:u.push(i);break;case De:{let c=[],l=[],f=i.vertices.length;for(let b=0;b<f;b++){let M=(b+1)%f,d=p[b],_=p[M],P=i.vertices[b],S=i.vertices[M];if(d!==be&&c.push(P),d!==we&&l.push(d!==be?Ie(P):P),(d|_)===De){let T=S.x-P.x,A=S.y-P.y,I=S.z-P.z,C=t*T+e*A+n*I,L=Math.abs(C)>1e-12?(r-(t*P.x+e*P.y+n*P.z))/C:.5,R=pt(P,S,Math.max(0,Math.min(1,L)));c.push(R),l.push(Ie(R))}}let{nx:x,ny:m,nz:y,w:g}=i;c.length>=3&&a.push({vertices:c,nx:x,ny:m,nz:y,w:g}),l.length>=3&&u.push({vertices:l,nx:x,ny:m,nz:y,w:g});break}default:break}}class ce{constructor(e,n=0){this.nx=0,this.ny=0,this.nz=0,this.w=0,this.hasPlane=!1,this.polygons=[],this.front=null,this.back=null,e&&e.length>0&&this.build(e,n)}invert(){for(let n=0;n<this.polygons.length;n++)ft(this.polygons[n]);this.nx=-this.nx,this.ny=-this.ny,this.nz=-this.nz,this.w=-this.w,this.front&&this.front.invert(),this.back&&this.back.invert();let e=this.front;this.front=this.back,this.back=e}clipPolygons(e,n=0){if(!this.hasPlane||e.length===0)return e.slice();if(n>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let r=[],i=[];for(let h=0;h<e.length;h++)Oe(this.nx,this.ny,this.nz,this.w,e[h],r,i,r,i);return this.front&&r.length>0&&(r=this.front.clipPolygons(r,n+1)),this.back?i=i.length>0?this.back.clipPolygons(i,n+1):[]:i=[],r.concat(i)}clipTo(e,n=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),n<ne&&(this.front&&this.front.clipTo(e,n+1),this.back&&this.back.clipTo(e,n+1))}allPolygons(e=[]){for(let n=0;n<this.polygons.length;n++)e.push(this.polygons[n]);return this.front&&this.front.allPolygons(e),this.back&&this.back.allPolygons(e),e}build(e,n=0){if(!e.length)return;if(!this.hasPlane){let h=e[e.length>>1];this.nx=h.nx,this.ny=h.ny,this.nz=h.nz,this.w=h.w,this.hasPlane=!0}if(n>=ne)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ne})`);let r=[],i=[];for(let h=0;h<e.length;h++)Oe(this.nx,this.ny,this.nz,this.w,e[h],this.polygons,this.polygons,r,i);r.length>0&&(this.front||(this.front=new ce),this.front.build(r,n+1)),i.length>0&&(this.back||(this.back=new ce),this.back.build(i,n+1))}}function Be(t,e){if(!e&&t._csgPolygons)return t._csgPolygons;let n=t.attributes.position;if(!n||n.count===0)return[];let r=t.attributes.normal,i=t.attributes.uv,h=t.index?t.index.array:null,o=Math.floor(h?h.length/3:n.count/3);if(o>ue)throw new RangeError(`SecurityError: CSG input triangle count (${o}) exceeds MAX_CSG_TRIANGLES (${ue})`);let a=e?e.elements:null,u=a?a[0]*(a[5]*a[10]-a[9]*a[6])-a[4]*(a[1]*a[10]-a[9]*a[2])+a[8]*(a[1]*a[6]-a[5]*a[2])<0:!1,s=a?new st().getNormalMatrix(e).elements:null,p=l=>{let f=n.getX(l),x=n.getY(l),m=n.getZ(l),y=r?r.getX(l):NaN,g=r?r.getY(l):NaN,b=r?r.getZ(l):NaN;if(a&&s){let _=a[0]*f+a[4]*x+a[8]*m+a[12],P=a[1]*f+a[5]*x+a[9]*m+a[13],S=a[2]*f+a[6]*x+a[10]*m+a[14];f=_,x=P,m=S;let T=s[0]*y+s[3]*g+s[6]*b,A=s[1]*y+s[4]*g+s[7]*b,I=s[2]*y+s[5]*g+s[8]*b,C=Math.hypot(T,A,I)||1;y=T/C,g=A/C,b=I/C}let M=i?i.getX(l):0,d=i?i.getY(l):0;return{x:f,y:x,z:m,nx:y,ny:g,nz:b,u:M,v:d}},c=[];for(let l=0;l<o;l++){let f=h?h[l*3]:l*3,x=h?h[l*3+1]:l*3+1,m=h?h[l*3+2]:l*3+2,y=yt(u?[p(f),p(m),p(x)]:[p(f),p(x),p(m)]);y&&c.push(y)}return c}function xt(t){let e=[],n=[],r=[],i=[];for(let o of t){let a=o.vertices;if(a.length<3)continue;let u=e.length/3;for(let s of a)e.push(s.x,s.y,s.z),Number.isFinite(s.nx)&&s.nx*s.nx+s.ny*s.ny+s.nz*s.nz>.5?n.push(s.nx,s.ny,s.nz):n.push(o.nx,o.ny,o.nz),r.push(s.u,s.v);for(let s=1;s<a.length-1;s++)i.push(u,u+s,u+s+1)}let h=ge(new te,e,n,r,i);return h._csgPolygons=t,h}function gt(t,e,n){if(t.length+e.length>ue)throw new RangeError(`SecurityError: Combined CSG triangle count (${t.length+e.length}) exceeds MAX_CSG_TRIANGLES (${ue})`);if(t.length===0)return n==="union"?e:[];if(e.length===0)return n==="intersect"?[]:t;let r=1/0,i=1/0,h=1/0,o=-1/0,a=-1/0,u=-1/0;for(let f=0;f<e.length;f++){let x=e[f].vertices;for(let m=0;m<x.length;m++){let y=x[m];y.x<r&&(r=y.x),y.y<i&&(i=y.y),y.z<h&&(h=y.z),y.x>o&&(o=y.x),y.y>a&&(a=y.y),y.z>u&&(u=y.z)}}r-=1e-4,i-=1e-4,h-=1e-4,o+=1e-4,a+=1e-4,u+=1e-4;let s=[],p=[];for(let f=0;f<t.length;f++){let x=t[f],m=x.vertices,y=1/0,g=1/0,b=1/0,M=-1/0,d=-1/0,_=-1/0;for(let P=0;P<m.length;P++){let S=m[P];S.x<y&&(y=S.x),S.y<g&&(g=S.y),S.z<b&&(b=S.z),S.x>M&&(M=S.x),S.y>d&&(d=S.y),S.z>_&&(_=S.z)}M<r||y>o||d<i||g>a||_<h||b>u?p.push(x):s.push(x)}if(s.length===0)return n==="union"?t.concat(e):n==="subtract"?t:[];let c=new ce(s),l=new ce(e);return n==="union"?(c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),p.concat(c.allPolygons())):n==="subtract"?(c.invert(),c.clipTo(l),l.clipTo(c),l.invert(),l.clipTo(c),l.invert(),c.build(l.allPolygons()),c.invert(),p.concat(c.allPolygons())):(c.invert(),l.clipTo(c),l.invert(),c.clipTo(l),l.clipTo(c),c.build(l.allPolygons()),c.invert(),c.allPolygons())}function qe(t,e,n,r=null,i=null){let h=Be(t,r),o=Be(e,i);return xt(gt(h,o,n))}function Ne(t,e,n){let r=t instanceof pe||!!t?.isMesh,i=e instanceof pe||!!e?.isMesh,h=r?t.geometry:t,o=i?e.geometry:e,a=null;if(i)if(e.updateMatrix(),r){t.updateMatrix();let c=new Me().makeScale(1/(t.scale.x||1),1/(t.scale.y||1),1/(t.scale.z||1)),l=Math.hypot(t.quaternion.x,t.quaternion.y,t.quaternion.z,t.quaternion.w)||1,f=new Me().compose(new ae(0,0,0),new K(-t.quaternion.x/l,-t.quaternion.y/l,-t.quaternion.z/l,t.quaternion.w/l),new ae(1,1,1)),x=new Me().makeTranslation(-t.position.x,-t.position.y,-t.position.z);a=c.multiply(f).multiply(x).multiply(e.matrix)}else a=e.matrix;let u=qe(h,o,n,null,a),s=r?t.material:new Ae,p=new pe(u,s);return r&&(p.position.copy(t.position),p.quaternion.copy(t.quaternion),p.scale.copy(t.scale),p.name=t.name),p}let de={toGeometry:qe,subtract(t,e){return Ne(t,e,"subtract")},union(t,e){return Ne(t,e,"union")},intersect(t,e){return Ne(t,e,"intersect")}},He={0:[[[.15,0],[.85,0],[.85,1],[.15,1],[.15,0]]],1:[[[.3,.8],[.5,1],[.5,0]],[[.2,0],[.8,0]]],2:[[[.15,.8],[.3,1],[.7,1],[.85,.8],[.85,.55],[.15,0],[.85,0]]],3:[[[.15,.85],[.3,1],[.75,1],[.85,.75],[.5,.5],[.85,.25],[.75,0],[.3,0],[.15,.15]]],4:[[[.7,0],[.7,1],[.15,.35],[.9,.35]]],5:[[[.85,1],[.2,1],[.15,.55],[.75,.55],[.85,.3],[.75,0],[.2,0]]],6:[[[.8,.9],[.5,1],[.15,.7],[.15,.15],[.5,0],[.85,.2],[.85,.45],[.5,.55],[.15,.45]]],7:[[[.15,1],[.85,1],[.35,0]]],8:[[[.2,.5],[.15,.75],[.3,1],[.7,1],[.85,.75],[.8,.5],[.2,.5],[.15,.2],[.3,0],[.7,0],[.85,.2],[.8,.5]]],9:[[[.85,.55],[.5,.45],[.15,.55],[.15,.85],[.5,1],[.85,.85],[.85,.2],[.5,0],[.2,.1]]],A:[[[.1,0],[.5,1],[.9,0]],[[.25,.35],[.75,.35]]],B:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.7,.5],[.85,.25],[.7,0],[.15,0]]],C:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.65,0],[.85,.2]]],D:[[[.15,0],[.15,1],[.65,1],[.85,.75],[.85,.25],[.65,0],[.15,0]]],E:[[[.85,1],[.15,1],[.15,0],[.85,0]],[[.15,.5],[.7,.5]]],F:[[[.85,1],[.15,1],[.15,0]],[[.15,.5],[.7,.5]]],G:[[[.85,.8],[.65,1],[.3,1],[.15,.75],[.15,.25],[.3,0],[.85,0],[.85,.45],[.55,.45]]],H:[[[.15,0],[.15,1]],[[.85,0],[.85,1]],[[.15,.5],[.85,.5]]],I:[[[.25,1],[.75,1]],[[.5,1],[.5,0]],[[.25,0],[.75,0]]],J:[[[.8,1],[.8,.25],[.6,0],[.3,0],[.15,.25]]],K:[[[.15,0],[.15,1]],[[.85,1],[.15,.45],[.85,0]]],L:[[[.15,1],[.15,0],[.85,0]]],M:[[[.1,0],[.1,1],[.5,.35],[.9,1],[.9,0]]],N:[[[.15,0],[.15,1],[.85,0],[.85,1]]],O:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]]],P:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]]],Q:[[[.3,0],[.7,0],[.85,.25],[.85,.75],[.7,1],[.3,1],[.15,.75],[.15,.25],[.3,0]],[[.55,.3],[.9,-.05]]],R:[[[.15,0],[.15,1],[.7,1],[.85,.75],[.7,.5],[.15,.5]],[[.55,.5],[.85,0]]],S:[[[.85,.85],[.65,1],[.3,1],[.15,.75],[.85,.25],[.7,0],[.3,0],[.15,.15]]],T:[[[.1,1],[.9,1]],[[.5,1],[.5,0]]],U:[[[.15,1],[.15,.25],[.35,0],[.65,0],[.85,.25],[.85,1]]],V:[[[.1,1],[.5,0],[.9,1]]],W:[[[.05,1],[.25,0],[.5,.65],[.75,0],[.95,1]]],X:[[[.15,1],[.85,0]],[[.85,1],[.15,0]]],Y:[[[.15,1],[.5,.5],[.85,1]],[[.5,.5],[.5,0]]],Z:[[[.15,1],[.85,1],[.15,0],[.85,0]]],".":[[[.45,0],[.55,0],[.55,.12],[.45,.12],[.45,0]]],",":[[[.5,.15],[.4,-.1]]],":":[[[.45,.1],[.55,.1]],[[.45,.7],[.55,.7]]],"-":[[[.2,.5],[.8,.5]]],"+":[[[.2,.5],[.8,.5]],[[.5,.2],[.5,.8]]],"=":[[[.2,.35],[.8,.35]],[[.2,.65],[.8,.65]]],"/":[[[.2,0],[.8,1]]],"!":[[[.5,1],[.5,.28]],[[.5,.1],[.5,0]]],"?":[[[.2,.8],[.35,1],[.7,1],[.85,.75],[.5,.45],[.5,.28]],[[.5,.1],[.5,0]]],"(":[[[.65,1],[.35,.65],[.35,.35],[.65,0]]],")":[[[.35,1],[.65,.65],[.65,.35],[.35,0]]],"%":[[[.2,0],[.8,1]],[[.2,.8],[.35,.8],[.35,.95],[.2,.95],[.2,.8]],[[.65,.05],[.8,.05],[.8,.2],[.65,.2],[.65,.05]]],"#":[[[.32,0],[.32,1]],[[.68,0],[.68,1]],[[.12,.35],[.88,.35]],[[.12,.65],[.88,.65]]],$:[[[.8,.8],[.6,.92],[.3,.92],[.18,.72],[.82,.28],[.7,.08],[.4,.08],[.2,.2]],[[.5,1],[.5,0]]],_:[[[.1,0],[.9,0]]],"[":[[[.65,1],[.3,1],[.3,0],[.65,0]]],"]":[[[.35,1],[.7,1],[.7,0],[.35,0]]],"<":[[[.75,.85],[.25,.5],[.75,.15]]],">":[[[.25,.85],[.75,.5],[.25,.15]]],"*":[[[.5,.2],[.5,.8]],[[.2,.35],[.8,.65]],[[.2,.65],[.8,.35]]],"\\":[[[.2,1],[.8,0]]]};class je extends te{constructor(e="",n={}){super();let r=String(e??"").slice(0,Ee),i=Math.max(.005,Math.min(100,B(n.size,.2))),h=!!(n.bevelEnabled??!1),o=h?Math.max(0,Math.min(2,B(n.bevelThickness,i*.04))):0,a=h?Math.max(0,Math.min(2,B(n.bevelSize,i*.03))):0,u=Math.max(.001,Math.min(20,B(n.depth??n.height,i*.2)))+o*2,s=i*.085+a,p=i*.68,c=i*.82,l=[],f=[],x=[],m=[],y=(M,d,_,P,S,T,A)=>{let I=_-M,C=P-d,L=Math.hypot(I,C),R=1,q=0;L>1e-6&&(R=I/L,q=C/L);let re=-q*S,se=R*S,Y=R*S*.6,$=q*S*.6,D=M-Y+re,H=d-$+se,v=M-Y-re,w=d-$-se,E=_+Y-re,k=P+$-se,G=_+Y+re,O=P+$+se,j=(F,J,Z,U,Q,W,ee)=>{let V=l.length/3;l.push(F[0],F[1],F[2],J[0],J[1],J[2],Z[0],Z[1],Z[2],U[0],U[1],U[2]),f.push(Q,W,ee,Q,W,ee,Q,W,ee,Q,W,ee),x.push(0,0,1,0,1,1,0,1),m.push(V,V+1,V+2,V,V+2,V+3)};j([D,H,A],[v,w,A],[E,k,A],[G,O,A],0,0,1),j([v,w,T],[D,H,T],[G,O,T],[E,k,T],0,0,-1),j([D,H,T],[v,w,T],[v,w,A],[D,H,A],-R,-q,0),j([E,k,T],[G,O,T],[G,O,A],[E,k,A],R,q,0),j([v,w,T],[E,k,T],[E,k,A],[v,w,A],q,-R,0),j([G,O,T],[D,H,T],[D,H,A],[G,O,A],-q,R,0)},g=0,b=0;for(let M=0;M<r.length;M++){let d=r[M];if(d===`
17
- `){g=0,b-=i*1.35;continue}if(d===" "||d===" "){g+=c*(d===" "?.75:3);continue}if(d==="\r")continue;let _=d.toUpperCase(),P=d!==_&&d>="a"&&d<="z",S=He[_]??He["?"],T=P?i*.76:i,A=P?p*.88:p;for(let I of S)for(let C=0;C<I.length-1;C++){let L=I[C],R=I[C+1];y(g+L[0]*A,b+L[1]*T,g+R[0]*A,b+R[1]*T,s,-u*.5,u*.5)}g+=P?c*.88:c}ge(this,l,f,x,m),n.center!==!1?this.center():this.computeBoundingBox()}}function Ve(t){if(!t)return;let e=t,n=t.userData?.xr?.text??t.userData?.xr?.label??t.userData?.xr?.title??t.userData?.xr?.caption??t.userData?.xr?.spatialLabel;if(n!=null&&n!==!1){let i=e.geometry?.attributes?.position;if((!i||i.count===0)&&t.userData._textApplied!==!0){let h="",o=.08,a=.015,u;if(typeof n=="string"||typeof n=="number")h=String(n);else if(typeof n=="object"){let s=n;h=String(s.text??s.value??""),s.size!==void 0&&(o=Number(s.size)||.08),(s.depth!==void 0||s.height!==void 0)&&(a=Number(s.depth??s.height)||o*.2),(typeof s.color=="string"||typeof s.color=="number")&&(u=s.color)}h.trim().length>0&&(e.geometry=new je(h,{size:o,depth:a}),t.userData._textApplied=!0,e.material instanceof lt?u!==void 0&&t.userData._autoTextColorApplied!==!0&&(e.material.color=new it(u),t.userData._autoTextColorApplied=!0):e.material=new Ae({color:u??16317180}))}}let r=t.userData?.csg;if(r&&typeof r=="object"&&t.userData._csgApplied!==!0&&e.geometry instanceof te&&e.geometry.attributes.position?.count>0){t.userData._csgApplied=!0;let i=Array.isArray(r)?r:[r],h=e.geometry;for(let o of i){if(!o||typeof o!="object")continue;let a=o,u=String(a.op??a.operation??"subtract"),s=u==="union"||u==="intersect"?u:"subtract",p=a.target??a.mesh??a.geometry;if(p instanceof pe||p instanceof te)try{let c=s==="union"?de.union(e,p):s==="intersect"?de.intersect(e,p):de.subtract(e,p);e.geometry!==h&&e.geometry.dispose?.(),e.geometry=c.geometry}catch(c){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",c)}}}}let Ye={Path:ye,Shape:fe,ShapeGeometry:ht,ExtrudeGeometry:ut,TextGeometry:je,CSG:de,MAX_CSG_TRIANGLES:ue,MAX_BSP_DEPTH:ne,MAX_TEXT_GEOMETRY_CHARS:Ee,MAX_SHAPE_POINTS:ze,materializeDeclarativeGeometry:Ve};return N&&typeof N=="object"&&(N.authorNamespace||(N.authorNamespace={}),Object.assign(N.authorNamespace,Ye),N._cadMaterialize=Ve,N.materializeDeclarativeGeometry=t=>{N._cadMaterialize?.(t),N._lodMaterialize?.(t)}),Ye}var Le={name:"cad",onRegister(){on(Se);let z=me(),N=z.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);N&&Se(N,z)}};rn(Le);
16
+ */var Te=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,Sn=Object.getOwnPropertyNames,Pn=Object.prototype.hasOwnProperty,wn=(v,z)=>{for(var I in z)Te(v,I,{get:z[I],enumerable:!0})},Mn=(v,z,I,oe)=>{if(z&&typeof z=="object"||typeof z=="function")for(let W of Sn(z))!Pn.call(v,W)&&W!==I&&Te(v,W,{get:()=>z[W],enumerable:!(oe=vn(z,W))||oe.enumerable});return v},Gn=v=>Mn(Te({},"__esModule",{value:!0}),v),kn={};wn(kn,{MAX_BSP_DEPTH:()=>nn,MAX_CSG_TRIANGLES:()=>en,MAX_SHAPE_POINTS:()=>on,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 z={plugins:[],decoders:new Map};try{Object.defineProperty(v,ve,{value:z,writable:!1,configurable:!1,enumerable:!1})}catch{v[ve]=z}}return v[ve]}var Tn=me().plugins;function Ke(v){let z=me();z.workerExtensionInstallers||(z.workerExtensionInstallers=[]),z.workerExtensionInstallers.includes(v)||z.workerExtensionInstallers.push(v)}function Je(v){let z=me().plugins;z.some(I=>I.name===v.name)||z.push(v),v.onRegister?.()}var en=8192,nn=2048,tn=128,on=4096;function Se(v,z){if(!v||!v.BufferGeometry)return null;let I=v.Vector2,oe=v.Vector3,W=v.Quaternion,Me=v.Matrix4,et=v.Matrix3,tt=v.Color,ze=v.BufferAttribute,K=v.BufferGeometry,nt=v.Material,Ae=v.MeshStandardMaterial,pe=v.Mesh,he=8192,ee=2048,Ee=128,Pe=4096,H=(n,e)=>{let t=n==null?NaN:Number(n);return Number.isFinite(t)?t:e};class ye{constructor(e){this.currentPoint=new I(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 r=Number(e)||0,s=Number(t)||0;return this.currentPoint.set(r,s),this.segments.push({type:"move",pts:[r,s]}),this}lineTo(e,t){let r=Number(e)||0,s=Number(t)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[this.currentPoint.x,this.currentPoint.y]}),this.currentPoint.set(r,s),this.segments.push({type:"line",pts:[r,s]}),this}quadraticCurveTo(e,t,r,s){let l=this.currentPoint.x,h=this.currentPoint.y,a=Number(e)||0,c=Number(t)||0,i=Number(r)||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,a,c,i,p]}),this}bezierCurveTo(e,t,r,s,l,h){let a=this.currentPoint.x,c=this.currentPoint.y,i=Number(e)||0,p=Number(t)||0,u=Number(r)||0,o=Number(s)||0,y=Number(l)||0,x=Number(h)||0;return this.segments.length===0&&this.segments.push({type:"move",pts:[a,c]}),this.currentPoint.set(y,x),this.segments.push({type:"cubic",pts:[a,c,i,p,u,o,y,x]}),this}absarc(e,t,r,s,l,h=!1){return this.absellipse(e,t,r,r,s,l,h,0)}arc(e,t,r,s,l,h=!1){return this.absarc(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),r,s,l,h)}absellipse(e,t,r,s,l,h,a=!1,c=0){let i=Number(e)||0,p=Number(t)||0,u=Math.max(0,Number(r)||0),o=Math.max(0,Number(s)||0),y=Number(l)||0,x=Number(h)||0,b=a?1:0,g=Number(c)||0;this.segments.push({type:"arc",pts:[i,p,u,o,y,x,b,g]});let f=Math.cos(g),m=Math.sin(g),M=u*Math.cos(x),d=o*Math.sin(x);return this.currentPoint.set(i+M*f-d*m,p+M*m+d*f),this}ellipse(e,t,r,s,l,h,a=!1,c=0){return this.absellipse(this.currentPoint.x+(Number(e)||0),this.currentPoint.y+(Number(t)||0),r,s,l,h,a,c)}add(e){if(e&&typeof e.getPoints=="function"){this.segments.push({type:"curve",pts:[],curve:e});let t=e.getPoint?.(1);t&&this.currentPoint.set(Number(t.x)||0,Number(t.y)||0)}return this}splineThru(e){if(!Array.isArray(e)||e.length===0)return this;let t=v.SplineCurve||z?.authorNamespace?.SplineCurve;if(t)return this.add(new t([this.currentPoint.clone(),...e]));for(let r of e)r&&this.lineTo(Number(r.x)||0,Number(r.y)||0);return this}closePath(){if(this.segments.length>0){let e=this.segments[0],t=0,r=0;if(e.type==="curve"&&e.curve?.getPoint){let s=e.curve.getPoint(0);t=Number(s?.x)||0,r=Number(s?.y)||0}else if(e.type==="arc"){let s=e.pts[0],l=e.pts[1],h=e.pts[2],a=e.pts[3],c=e.pts[4],i=e.pts[7],p=Math.cos(i),u=Math.sin(i),o=h*Math.cos(c),y=a*Math.sin(c);t=s+o*p-y*u,r=l+o*u+y*p}else t=e.pts[0],r=e.pts[1];Math.hypot(this.currentPoint.x-t,this.currentPoint.y-r)>1e-6&&this.lineTo(t,r)}return this}getPoints(e=12){let t=Math.max(1,Math.min(128,Math.floor(Number(e)||12))),r=[],s=(l,h)=>{if(r.length>0){let a=r[r.length-1];if(Math.hypot(a.x-l,a.y-h)<1e-6)return}r.push(new I(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 a=h[0],c=h[1],i=h[2],p=h[3],u=h[4],o=h[5];s(a,c);for(let y=1;y<=t;y++){let x=y/t,b=1-x;s(b*b*a+2*b*x*i+x*x*u,b*b*c+2*b*x*p+x*x*o)}}else if(l.type==="cubic"){let a=h[0],c=h[1],i=h[2],p=h[3],u=h[4],o=h[5],y=h[6],x=h[7];s(a,c);for(let b=1;b<=t;b++){let g=b/t,f=1-g,m=f*f,M=g*g;s(m*f*a+3*m*g*i+3*f*M*u+M*g*y,m*f*c+3*m*g*p+3*f*M*o+M*g*x)}}else if(l.type==="arc"){let a=h[0],c=h[1],i=h[2],p=h[3],u=h[4],o=h[5],y=h[6]!==0,x=h[7],b=Math.PI*2,g=o-u,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),M=Math.sin(x),d=Math.max(2,t);for(let S=0;S<=d;S++){let P=S/d,N=u+P*g,w=i*Math.cos(N),T=p*Math.sin(N);s(a+w*m-T*M,c+w*M+T*m)}}else if(l.type==="curve"&&l.curve?.getPoints)for(let a of l.curve.getPoints(t))a&&s(Number(a.x)||0,Number(a.y)||0)}if(r.length>2){let l=r[0],h=r[r.length-1];Math.hypot(l.x-h.x,l.y-h.y)<1e-6&&r.pop()}return r}getSpacedPoints(e=12){return this.getPoints(e)}clone(){let e=new this.constructor;return e.currentPoint.copy(this.currentPoint),e.segments=this.segments.map(t=>({type:t.type,pts:[...t.pts],...t.curve?{curve:t.curve.clone?t.curve.clone():t.curve}:{}})),Array.isArray(this.holes)&&(e.holes=this.holes.map(t=>t.clone())),e}}class fe extends ye{constructor(e){super(e),this.holes=[]}extractPoints(e=12){return{shape:this.getPoints(e),holes:this.holes.map(t=>t.getPoints(e))}}}function xe(n){let e=0,t=n.length;for(let r=0,s=t-1;r<t;s=r++)e+=n[s].x*n[r].y-n[r].x*n[s].y;return e*.5}function rt(n,e,t,r,s,l,h,a){let c=h-t,i=a-r,p=s-t,u=l-r,o=n-t,y=e-r,x=c*c+i*i,b=c*p+i*u,g=c*o+i*y,f=p*p+u*u,m=p*o+u*y,M=x*f-b*b;if(Math.abs(M)<1e-12)return!1;let d=1/M,S=(f*g-b*m)*d,P=(x*m-b*g)*d;return S>=-1e-7&&P>=-1e-7&&S+P<=1+1e-7}function Ce(n,e){let t=n.slice();xe(t)<0&&t.reverse();let r=t.map(c=>new I(c.x,c.y)),s=t.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=[],u=-1/0,o=0;for(let y=0;y<i.length;y++){let x=i[y],b=r.length;r.push(new I(x.x,x.y)),p.push(b),x.x>u&&(u=x.x,o=y)}l.push({pts:i,indices:p,maxX:u,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),a=(c,i,p)=>{for(let u=0;u<p.length;u++){let o=p[u],y=p[(u+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,u=s.length,o=s.map(f=>r[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],M=o[(f+u-1)%u],d=o[(f+1)%u],S=h(m,d,i)>=0,P=h(M,m,i)>=0;if((h(M,m,d)>=0?S&&P:S||P)&&!a(i,m,o)&&!l.some(N=>a(i,m,N.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=>r[c]),mergedIndices:s,allVertices:r}}function Ge(n,e){let t=[],r=n.slice();if(r.length<3)return t;let s=r.length*r.length+64,l=0;for(;r.length>2&&s-- >0;){let h=r.length,a=r[(l+h-1)%h],c=r[l%h],i=r[(l+1)%h],p=e[a],u=e[c],o=e[i];if((u.x-p.x)*(o.y-p.y)-(u.y-p.y)*(o.x-p.x)>1e-9){let y=!0,x=Math.min(p.x,u.x,o.x)-1e-7,b=Math.max(p.x,u.x,o.x)+1e-7,g=Math.min(p.y,u.y,o.y)-1e-7,f=Math.max(p.y,u.y,o.y)+1e-7;for(let m=0;m<h;m++){let M=r[m];if(M===a||M===c||M===i)continue;let d=e[M];if(d.x>=x&&d.x<=b&&d.y>=g&&d.y<=f&&rt(d.x,d.y,p.x,p.y,u.x,u.y,o.x,o.y)&&(d.x-p.x)*(d.x-p.x)+(d.y-p.y)*(d.y-p.y)>=1e-12&&(d.x-u.x)*(d.x-u.x)+(d.y-u.y)*(d.y-u.y)>=1e-12&&(d.x-o.x)*(d.x-o.x)+(d.y-o.y)*(d.y-o.y)>=1e-12){y=!1;break}}if(y){t.push([a,c,i]),r.splice(l%h,1),l=Math.max(0,l%h-1);continue}}l++,l>=h*2&&(t.push([a,c,i]),r.splice((l-1)%h,1),l=0)}return t}function De(n,e){let t=n instanceof fe?n.extractPoints(e):{shape:n.getPoints(e),holes:[]},r=t.shape.length;for(let s of t.holes)r+=s.length;if(r>Pe)throw new RangeError(`SecurityError: shape point count (${r}) exceeds MAX_SHAPE_POINTS (${Pe})`);return t}function ke(n){let e=1/0,t=1/0,r=-1/0,s=-1/0;for(let l of n)l.x<e&&(e=l.x),l.y<t&&(t=l.y),l.x>r&&(r=l.x),l.y>s&&(s=l.y);return[e,t,Math.max(1e-6,r-e),Math.max(1e-6,s-t)]}class st extends K{constructor(e=new fe,t=12){super();let r=Array.isArray(e)?e:[e],s=[],l=[],h=[],a=[];for(let c of r){if(!(c instanceof ye))continue;let i=De(c,t);if(i.shape.length<3)continue;let{mergedIndices:p,allVertices:u}=Ce(i.shape,i.holes),o=Ge(p,u),y=s.length/3,[x,b,g,f]=ke(u);for(let m of u)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,M,d]of o)a.push(y+m,y+M,y+d)}ge(this,s,l,h,a)}}function ge(n,e,t,r,s){return n.setAttribute("position",new ze(e,3)),n.setAttribute("normal",new ze(t,3)),n.setAttribute("uv",new ze(r,2)),n.setIndex(s),n}function it(n){let e=n.length,t=[];for(let r=0;r<e;r++){let s=n[(r+e-1)%e],l=n[r],h=n[(r+1)%e],a=l.x-s.x,c=l.y-s.y,i=Math.hypot(a,c)||1;a/=i,c/=i;let p=h.x-l.x,u=h.y-l.y,o=Math.hypot(p,u)||1;p/=o,u/=o;let y=c,x=-a,b=u,g=-p,f=y+b,m=x+g,M=Math.hypot(f,m);if(M>1e-6){f/=M,m/=M;let d=Math.max(.35,f*y+m*x);t.push(new I(f/d,m/d))}else t.push(new I(y,x))}return t}class lt extends K{constructor(e=new fe,t={}){super();let r=Array.isArray(e)?e:[e],s=Math.max(1,Math.min(64,Math.floor(H(t.curveSegments,12)))),l=H(t.depth??t.amount,1),h=Math.max(1,Math.min(32,Math.floor(H(t.steps,1)))),a=!!(t.bevelEnabled??!1),c=a?Math.max(0,H(t.bevelThickness,.06)):0,i=a?Math.max(0,H(t.bevelSize,c*.8)):0,p=a?H(t.bevelOffset,0):0,u=a?Math.max(1,Math.min(8,Math.floor(H(t.bevelSegments,2)))):0,o=[],y=[],x=[],b=[];for(let g of r){if(!(g instanceof ye))continue;let f=De(g,s);if(f.shape.length<3)continue;let m=f.shape.slice();xe(m)<0&&m.reverse();let M=[];for(let A of f.holes){if(A.length<3)continue;let _=A.slice();xe(_)>0&&_.reverse(),M.push(_)}let{mergedIndices:d,allVertices:S}=Ce(m,M),P=Ge(d,S),N=[m,...M],w=[];for(let A of N){let _=it(A);for(let k of _)w.push(k)}let[T,O,X,Y]=ke(S);for(let[A,_]of[[-c,-1],[l+c,1]]){let k=o.length/3;for(let D=0;D<S.length;D++){let C=S[D],G=w[D]??new I(0,0),q=C.x+G.x*p,R=C.y+G.y*p;o.push(q,R,A),y.push(0,0,_),x.push((q-T)/X,(R-O)/Y)}for(let[D,C,G]of P)b.push(k+D,k+(_<0?G:C),k+(_<0?C:G))}let E=[];if(a&&u>0)for(let A=0;A<u;A++){let _=A/u*Math.PI/2;E.push({z:-c*Math.cos(_),expand:p+i*Math.sin(_)})}for(let A=0;A<=h;A++){let _=A/h;E.push({z:_*l,expand:p+i})}if(a&&u>0)for(let A=1;A<=u;A++){let _=A/u*Math.PI/2;E.push({z:l+c*Math.sin(_),expand:p+i*Math.cos(_)})}let j=0;for(let A of N){let _=A.length;for(let k=0;k<E.length-1;k++){let D=E[k],C=E[k+1];for(let G=0;G<_;G++){let q=(G+1)%_,R=A[G],B=A[q],L=w[j+G],V=w[j+q],$=R.x+L.x*D.expand,F=R.y+L.y*D.expand,te=B.x+V.x*D.expand,ne=B.y+V.y*D.expand,ue=B.x+V.x*C.expand,ce=B.y+V.y*C.expand,J=R.x+L.x*C.expand,Z=R.y+L.y*C.expand,Q=te-$,U=ne-F,yt=J-$,ft=Z-F,Fe=C.z-D.z,re=U*Fe,se=-Q*Fe,ie=Q*ft-U*yt,_e=Math.hypot(re,se,ie)||1;re/=_e,se/=_e,ie/=_e;let le=o.length/3;o.push($,F,D.z,te,ne,D.z,ue,ce,C.z,J,Z,C.z),y.push(re,se,ie,re,se,ie,re,se,ie,re,se,ie);let Ue=G/_,We=(G+1)/_,Ze=k/(E.length-1),Qe=(k+1)/(E.length-1);x.push(Ue,Ze,We,Ze,We,Qe,Ue,Qe),b.push(le,le+1,le+2,le,le+2,le+3)}}j+=_}}ge(this,o,y,x,b)}}function Xe(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 ot(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 ht(n,e,t){let r=n.nx+(e.nx-n.nx)*t,s=n.ny+(e.ny-n.ny)*t,l=n.nz+(e.nz-n.nz)*t,h=Math.hypot(r,s,l)||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:r/h,ny:s/h,nz:l/h,u:n.u+(e.u-n.u)*t,v:n.v+(e.v-n.v)*t}}function at(n){if(n.length<3)return null;let e=n[0],t=n[1],r=n[2],s=t.x-e.x,l=t.y-e.y,h=t.z-e.z,a=r.x-e.x,c=r.y-e.y,i=r.z-e.z,p=l*i-h*c,u=h*a-s*i,o=s*c-l*a,y=Math.hypot(p,u,o);if(y<1e-9)return null;p/=y,u/=y,o/=y;let x=p*e.x+u*e.y+o*e.z;return{vertices:n,nx:p,ny:u,nz:o,w:x}}function ut(n){n.vertices.reverse();for(let e=0;e<n.vertices.length;e++)n.vertices[e]=ot(n.vertices[e]);n.nx=-n.nx,n.ny=-n.ny,n.nz=-n.nz,n.w=-n.w}let Ie=1e-5,Re=0,Ne=1,be=2,Oe=3;function qe(n,e,t,r,s,l,h,a,c){let i=0,p=[];for(let u=0;u<s.vertices.length;u++){let o=s.vertices[u],y=n*o.x+e*o.y+t*o.z-r,x=y<-Ie?be:y>Ie?Ne:Re;i|=x,p.push(x)}switch(i){case Re:{n*s.nx+e*s.ny+t*s.nz>0?l.push(s):h.push(s);break}case Ne:a.push(s);break;case be:c.push(s);break;case Oe:{let u=[],o=[],y=s.vertices.length;for(let m=0;m<y;m++){let M=(m+1)%y,d=p[m],S=p[M],P=s.vertices[m],N=s.vertices[M];if(d!==be&&u.push(P),d!==Ne&&o.push(d!==be?Xe(P):P),(d|S)===Oe){let w=N.x-P.x,T=N.y-P.y,O=N.z-P.z,X=n*w+e*T+t*O,Y=Math.abs(X)>1e-12?(r-(n*P.x+e*P.y+t*P.z))/X:.5,E=ht(P,N,Math.max(0,Math.min(1,Y)));u.push(E),o.push(Xe(E))}}let{nx:x,ny:b,nz:g,w:f}=s;u.length>=3&&a.push({vertices:u,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,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++)ut(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>=ee)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ee})`);let r=[],s=[];for(let l=0;l<e.length;l++)qe(this.nx,this.ny,this.nz,this.w,e[l],r,s,r,s);return this.front&&r.length>0&&(r=this.front.clipPolygons(r,t+1)),this.back?s=s.length>0?this.back.clipPolygons(s,t+1):[]:s=[],r.concat(s)}clipTo(e,t=0){this.polygons.length>0&&(this.polygons=e.clipPolygons(this.polygons,0)),t<ee&&(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 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(t>=ee)throw new RangeError(`SecurityError: CSG BSP depth exceeds MAX_BSP_DEPTH (${ee})`);let r=[],s=[];for(let l=0;l<e.length;l++)qe(this.nx,this.ny,this.nz,this.w,e[l],this.polygons,this.polygons,r,s);r.length>0&&(this.front||(this.front=new ae),this.front.build(r,t+1)),s.length>0&&(this.back||(this.back=new ae),this.back.build(s,t+1))}}function He(n,e){if(!e&&n._csgPolygons)return n._csgPolygons;let t=n.attributes.position;if(!t||t.count===0)return[];let r=n.attributes.normal,s=n.attributes.uv,l=n.index?n.index.array:null,h=Math.floor(l?l.length/3:t.count/3);if(h>he)throw new RangeError(`SecurityError: CSG input triangle count (${h}) exceeds MAX_CSG_TRIANGLES (${he})`);let a=e?e.elements:null,c=a?a[0]*(a[5]*a[10]-a[9]*a[6])-a[4]*(a[1]*a[10]-a[9]*a[2])+a[8]*(a[1]*a[6]-a[5]*a[2])<0:!1,i=a?new et().getNormalMatrix(e).elements:null,p=o=>{let y=t.getX(o),x=t.getY(o),b=t.getZ(o),g=r?r.getX(o):NaN,f=r?r.getY(o):NaN,m=r?r.getZ(o):NaN;if(a&&i){let S=a[0]*y+a[4]*x+a[8]*b+a[12],P=a[1]*y+a[5]*x+a[9]*b+a[13],N=a[2]*y+a[6]*x+a[10]*b+a[14];y=S,x=P,b=N;let w=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,X=Math.hypot(w,T,O)||1;g=w/X,f=T/X,m=O/X}let M=s?s.getX(o):0,d=s?s.getY(o):0;return{x:y,y:x,z:b,nx:g,ny:f,nz:m,u:M,v:d}},u=[];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&&u.push(g)}return u}function ct(n){let e=[],t=[],r=[],s=[];for(let h of n){let a=h.vertices;if(a.length<3)continue;let c=e.length/3;for(let i of a)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?t.push(i.nx,i.ny,i.nz):t.push(h.nx,h.ny,h.nz),r.push(i.u,i.v);for(let i=1;i<a.length-1;i++)s.push(c,c+i,c+i+1)}let l=ge(new K,e,t,r,s);return l._csgPolygons=n,l}function pt(n,e,t){if(n.length+e.length>he)throw new RangeError(`SecurityError: Combined CSG triangle count (${n.length+e.length}) exceeds MAX_CSG_TRIANGLES (${he})`);if(n.length===0)return t==="union"?e:[];if(e.length===0)return t==="intersect"?[]:n;let r=1/0,s=1/0,l=1/0,h=-1/0,a=-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<r&&(r=g.x),g.y<s&&(s=g.y),g.z<l&&(l=g.z),g.x>h&&(h=g.x),g.y>a&&(a=g.y),g.z>c&&(c=g.z)}}r-=1e-4,s-=1e-4,l-=1e-4,h+=1e-4,a+=1e-4,c+=1e-4;let i=[],p=[];for(let y=0;y<n.length;y++){let x=n[y],b=x.vertices,g=1/0,f=1/0,m=1/0,M=-1/0,d=-1/0,S=-1/0;for(let P=0;P<b.length;P++){let N=b[P];N.x<g&&(g=N.x),N.y<f&&(f=N.y),N.z<m&&(m=N.z),N.x>M&&(M=N.x),N.y>d&&(d=N.y),N.z>S&&(S=N.z)}M<r||g>h||d<s||f>a||S<l||m>c?p.push(x):i.push(x)}if(i.length===0)return t==="union"?n.concat(e):t==="subtract"?n:[];let u=new ae(i),o=new ae(e);return t==="union"?(u.clipTo(o),o.clipTo(u),o.invert(),o.clipTo(u),o.invert(),u.build(o.allPolygons()),p.concat(u.allPolygons())):t==="subtract"?(u.invert(),u.clipTo(o),o.clipTo(u),o.invert(),o.clipTo(u),o.invert(),u.build(o.allPolygons()),u.invert(),p.concat(u.allPolygons())):(u.invert(),o.clipTo(u),o.invert(),u.clipTo(o),o.clipTo(u),u.build(o.allPolygons()),u.invert(),u.allPolygons())}function je(n,e,t,r=null,s=null){let l=He(n,r),h=He(e,s);return ct(pt(l,h,t))}function we(n,e,t){let r=n instanceof pe||!!n?.isMesh,s=e instanceof pe||!!e?.isMesh,l=r?n.geometry:n,h=s?e.geometry:e,a=null;if(s)if(e.updateMatrix(),r){n.updateMatrix();let u=new Me().makeScale(1/(n.scale.x||1),1/(n.scale.y||1),1/(n.scale.z||1)),o=Math.hypot(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w)||1,y=new Me().compose(new oe(0,0,0),new W(-n.quaternion.x/o,-n.quaternion.y/o,-n.quaternion.z/o,n.quaternion.w/o),new oe(1,1,1)),x=new Me().makeTranslation(-n.position.x,-n.position.y,-n.position.z);a=u.multiply(y).multiply(x).multiply(e.matrix)}else a=e.matrix;let c=je(l,h,t,null,a),i=r?n.material:new Ae,p=new pe(c,i);return r&&(p.position.copy(n.position),p.quaternion.copy(n.quaternion),p.scale.copy(n.scale),p.name=n.name),p}let de={toGeometry:je,subtract(n,e){return we(n,e,"subtract")},union(n,e){return we(n,e,"union")},intersect(n,e){return we(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 Ve extends K{constructor(e="",t={}){super();let r=String(e??"").slice(0,Ee),s=Math.max(.005,Math.min(100,H(t.size,.2))),l=!!(t.bevelEnabled??!1),h=l?Math.max(0,Math.min(2,H(t.bevelThickness,s*.04))):0,a=l?Math.max(0,Math.min(2,H(t.bevelSize,s*.03))):0,c=Math.max(.001,Math.min(20,H(t.depth??t.height,s*.2)))+h*2,i=s*.085+a,p=s*.68,u=s*.82,o=[],y=[],x=[],b=[],g=(M,d,S,P,N,w,T)=>{let O=S-M,X=P-d,Y=Math.hypot(O,X),E=1,j=0;Y>1e-6&&(E=O/Y,j=X/Y);let A=-j*N,_=E*N,k=E*N*.6,D=j*N*.6,C=M-k+A,G=d-D+_,q=M-k-A,R=d-D-_,B=S+k-A,L=P+D-_,V=S+k+A,$=P+D+_,F=(te,ne,ue,ce,J,Z,Q)=>{let U=o.length/3;o.push(te[0],te[1],te[2],ne[0],ne[1],ne[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],[q,R,T],[B,L,T],[V,$,T],0,0,1),F([q,R,w],[C,G,w],[V,$,w],[B,L,w],0,0,-1),F([C,G,w],[q,R,w],[q,R,T],[C,G,T],-E,-j,0),F([B,L,w],[V,$,w],[V,$,T],[B,L,T],E,j,0),F([q,R,w],[B,L,w],[B,L,T],[q,R,T],j,-E,0),F([V,$,w],[C,G,w],[C,G,T],[V,$,T],-j,E,0)},f=0,m=0;for(let M=0;M<r.length;M++){let d=r[M];if(d===`
17
+ `){f=0,m-=s*1.35;continue}if(d===" "||d===" "){f+=u*(d===" "?.75:3);continue}if(d==="\r")continue;let S=d.toUpperCase(),P=d!==S&&d>="a"&&d<="z",N=Be[S]??Be["?"],w=P?s*.76:s,T=P?p*.88:p;for(let O of N)for(let X=0;X<O.length-1;X++){let Y=O[X],E=O[X+1];g(f+Y[0]*T,m+Y[1]*w,f+E[0]*T,m+E[1]*w,i,-c*.5,c*.5)}f+=P?u*.88:u}ge(this,o,y,x,b),t.center!==!1?this.center():this.computeBoundingBox()}}function Ye(n){if(!n)return;let e=n,t=n.userData?.xr?.text??n.userData?.xr?.label??n.userData?.xr?.title??n.userData?.xr?.caption??n.userData?.xr?.spatialLabel;if(t!=null&&t!==!1){let s=e.geometry?.attributes?.position;if((!s||s.count===0)&&n.userData._textApplied!==!0){let l="",h=.08,a=.015,c;if(typeof t=="string"||typeof t=="number")l=String(t);else if(typeof t=="object"){let i=t;l=String(i.text??i.value??""),i.size!==void 0&&(h=Number(i.size)||.08),(i.depth!==void 0||i.height!==void 0)&&(a=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:a}),n.userData._textApplied=!0,e.material instanceof nt?c!==void 0&&n.userData._autoTextColorApplied!==!0&&(e.material.color=new tt(c),n.userData._autoTextColorApplied=!0):e.material=new Ae({color:c??16317180}))}}let r=n.userData?.csg;if(r&&typeof r=="object"&&n.userData._csgApplied!==!0&&e.geometry instanceof K&&e.geometry.attributes.position?.count>0){n.userData._csgApplied=!0;let s=Array.isArray(r)?r:[r],l=e.geometry;for(let h of s){if(!h||typeof h!="object")continue;let a=h,c=String(a.op??a.operation??"subtract"),i=c==="union"||c==="intersect"?c:"subtract",p=a.target??a.mesh??a.geometry;if(p instanceof pe||p instanceof K)try{let u=i==="union"?de.union(e,p):i==="intersect"?de.intersect(e,p):de.subtract(e,p);e.geometry!==l&&e.geometry.dispose?.(),e.geometry=u.geometry}catch(u){typeof console<"u"&&console.warn("[three-live] userData.csg skipped:",u)}}}}let $e={Path:ye,Shape:fe,ShapeGeometry:st,ExtrudeGeometry:lt,TextGeometry:Ve,CSG:de,MAX_CSG_TRIANGLES:he,MAX_BSP_DEPTH:ee,MAX_TEXT_GEOMETRY_CHARS:Ee,MAX_SHAPE_POINTS:Pe,materializeDeclarativeGeometry:Ye};return z&&typeof z=="object"&&(z.authorNamespace||(z.authorNamespace={}),Object.assign(z.authorNamespace,$e),z._cadMaterialize=Ye,z.materializeDeclarativeGeometry=n=>{z._cadMaterialize?.(n),z._lodMaterialize?.(n),z._procMaterialize?.(n)}),$e}var Le={name:"cad",onRegister(){Ke(Se);let v=me(),z=v.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);z&&Se(z,v)}};Je(Le);
@@ -20,6 +20,7 @@
20
20
 
21
21
  import type {
22
22
  CameraState,
23
+ ShadowMapsMode,
23
24
  ThreeLiveElement,
24
25
  } from './three-live/src/three-live-element';
25
26
  import type {
@@ -118,6 +119,27 @@ export {
118
119
  postprocessingPlugin,
119
120
  resolveViewerBloom,
120
121
  } from './three-live/src/plugins/postprocessing';
122
+ export {
123
+ installProceduralExtension,
124
+ proceduralPlugin,
125
+ } from './three-live/src/plugins/procedural';
126
+ export {
127
+ computeWorldSceneBounds,
128
+ doesMeshCastShadow,
129
+ doesMeshReceiveShadow,
130
+ fitDirectionalShadowMatrix,
131
+ fitSpotShadowMatrix,
132
+ getShadowMapStats,
133
+ MAX_SHADOW_LIGHTS,
134
+ normalizeShadowMapsMode,
135
+ resolveActiveShadowLights,
136
+ SHADOW_MAP_TEXTURE_UNIT,
137
+ shadowMapsPlugin,
138
+ type ResolvedShadowPlan,
139
+ type ResolvedShadowSlice,
140
+ type ShadowMapStats,
141
+ type WorldSceneBounds,
142
+ } from './three-live/src/plugins/shadow-maps';
121
143
  export {
122
144
  extractMaterialVariants,
123
145
  extractPrimitiveVariantMappings,
@@ -126,6 +148,7 @@ export {
126
148
  type VariantMapping,
127
149
  } from './three-live/src/plugins/variants';
128
150
  export {
151
+ defineModelViewer,
129
152
  ThreeLiveElement,
130
153
  type ARLaunchOptions,
131
154
  type ARLaunchResult,
@@ -142,10 +165,144 @@ export {
142
165
  type XRProfile,
143
166
  type XRSimulatorRoom,
144
167
  } from './xr-live/src/xr-live-element';
168
+ /** Opt-in bring-your-own-LLM scene editing (`three-live/ai`, `three-live-ai.min.js`). */
169
+ export {
170
+ aiPlugin,
171
+ createAIChatProvider,
172
+ editScene,
173
+ extractScript,
174
+ undoEdit,
175
+ } from './three-live/src/plugins/ai';
176
+ export type {
177
+ AIChatContentPart,
178
+ AIChatMessage,
179
+ AIChatProviderOptions,
180
+ EditSceneOptions,
181
+ EditSceneResult,
182
+ ThreeLiveAIProvider,
183
+ } from './three-live/src/plugins/ai';
184
+ export {
185
+ buildImageMessages,
186
+ buildImageUserText,
187
+ compileFromImage,
188
+ detectImageMime,
189
+ formatSpatialPriors,
190
+ IMAGE_SYSTEM_PROMPT,
191
+ imageRepairMessage,
192
+ isAllowedImageUrl,
193
+ normalizeImageInput,
194
+ } from './three-live/src/plugins/ai-image';
195
+ export type {
196
+ AIImageInput,
197
+ AISpatialCamera,
198
+ AISpatialObject,
199
+ AISpatialPlane,
200
+ AISpatialPriors,
201
+ CompileFromImageOptions,
202
+ } from './three-live/src/plugins/ai-image';
203
+ /** AI PBR textures: texture packs and image providers (part of `three-live-ai.min.js`). */
204
+ export {
205
+ browserImageCodec,
206
+ createAIImageProvider,
207
+ indexedDbTextureCache,
208
+ parseTexturePack,
209
+ prepareAlbedo,
210
+ serializeTexturePack,
211
+ TEXTURE_PROMPT_SUFFIX,
212
+ textureRequests,
213
+ } from './three-live/src/plugins/ai-texture';
214
+ export type {
215
+ AIImageProviderOptions,
216
+ AITextureSpec,
217
+ GenerateTexturesOptions,
218
+ GenerateTexturesResult,
219
+ TextureCache,
220
+ TextureCacheRecord,
221
+ TextureImageCodec,
222
+ TextureMiss,
223
+ TexturePackEntry,
224
+ TexturePackJSON,
225
+ ThreeLiveImageProvider,
226
+ } from './three-live/src/plugins/ai-texture';
227
+ /** "Tap & Speak" voice editing (part of `three-live-ai.min.js`). */
228
+ export {
229
+ hideSelectionChips,
230
+ showSelectionChips,
231
+ } from './three-live/src/plugins/ai-select-chips';
232
+ export type {AISelectChipsState} from './three-live/src/plugins/ai-select-chips';
233
+ export {
234
+ AIVoiceSession,
235
+ connectVoice,
236
+ createWebSpeechRecognizer,
237
+ describeEditResult,
238
+ describeVoiceSelection,
239
+ geminiLiveAdapter,
240
+ realtimeAdapter,
241
+ selectByVoice,
242
+ selectNamesByVoice,
243
+ setSelectOnTap,
244
+ speakableName,
245
+ startVoiceEdit,
246
+ } from './three-live/src/plugins/ai-voice';
247
+ /** Multi-select for Tap & Speak / Talk-to-Select (part of `three-live-ai.min.js`). */
248
+ export {
249
+ describeSelection,
250
+ getSelection,
251
+ parseSelectReply,
252
+ resolveSelection,
253
+ resolveSelectionWithModel,
254
+ sceneSelectEntries,
255
+ selectCamera,
256
+ selectMessages,
257
+ setSelection,
258
+ } from './three-live/src/plugins/ai-select';
259
+ export type {
260
+ AIModelSelection,
261
+ AISelectProvider,
262
+ } from './three-live/src/plugins/ai-select';
263
+ /** Talk-to-Select tier-1 matcher and push-to-talk grammar (mirrors the Rust core). */
264
+ export type {
265
+ AISelectionEventDetail,
266
+ AISelectionMode,
267
+ AISelectionSource,
268
+ } from './three-live/src/plugins/ai-select';
269
+ export {
270
+ buildSelectIndex,
271
+ matchSelection,
272
+ parseVoiceCommand,
273
+ } from './three-live/src/plugins/ai-select-match';
274
+ export type {
275
+ SelectCamera,
276
+ SelectConfidence,
277
+ SelectIndexEntry,
278
+ SelectMatch,
279
+ SelectRawEntry,
280
+ VoiceCommand,
281
+ } from './three-live/src/plugins/ai-select-match';
282
+ export type {
283
+ AIAudioSink,
284
+ AIMicrophoneSource,
285
+ AISpeechRecognizer,
286
+ AIVoiceAdapter,
287
+ AIVoiceEditOptions,
288
+ AIVoiceEditResult,
289
+ AIVoiceEventDetail,
290
+ AIVoiceProviderName,
291
+ AIVoiceSelection,
292
+ AIVoiceSessionOptions,
293
+ AIVoiceState,
294
+ AIVoiceTransport,
295
+ } from './three-live/src/plugins/ai-voice';
145
296
  /** Optional spatial plugins (`xr-live/spatial`, `xr-live-spatial.min.js`). */
146
297
  export * from './xr-live/src/plugins/index';
147
298
  /** Optional simulation plugins (`xr-live/sim`, `xr-live-sim.min.js`). */
148
299
  export * from './xr-live/src/sim/index';
300
+ /** Optional WebGPU Gaussian Splatting compute & render accelerator (`xr-live/webgpu`, `xr-live-webgpu.min.js`). */
301
+ export * from './xr-live/src/webgpu';
302
+ /** Optional WebGPU `GPURenderBundle` scene accelerator (`three-live/webgpu`, `three-live-webgpu.min.js`). */
303
+ export * from './three-live/src/webgpu';
304
+ /** Optional Loop-Free `THREE.TSL` & `MeshStandardNodeMaterial` compiler (`three-live/tsl`, `three-live-tsl.min.js`). */
305
+ export * from './three-live/src/tsl';
149
306
 
150
307
  /**
151
308
  * Declarative JSX / HTML attributes supported by the <three-live> custom element.
@@ -234,6 +391,40 @@ export interface ThreeLiveAttributes {
234
391
  * Server-generated scripts (`script-src`) are enabled by default.
235
392
  */
236
393
  'allow-client-scripts'?: boolean | string;
394
+ /** `three-live-ai`: Chat Completions-compatible endpoint (your proxy or a local model) for `editScene()`. */
395
+ 'ai-endpoint'?: string;
396
+ /** `three-live-ai`: model name sent to `ai-endpoint`. */
397
+ 'ai-model'?: string;
398
+ /** `three-live-ai`: provider protocol for `ai-endpoint` (`'ai-chat'`, the default). */
399
+ 'ai-provider'?: 'ai-chat';
400
+ /** `three-live-ai`: OpenAI-compatible Images endpoint (`/v1/images/generations`) for AI textures (`userData.xr.material.prompt`). */
401
+ 'ai-image-endpoint'?: string;
402
+ /** `three-live-ai`: model name sent to `ai-image-endpoint`. */
403
+ 'ai-image-model'?: string;
404
+ /** `three-live-ai`: `'auto'` (default) generates missing AI textures when an image endpoint is configured; `'manual'` waits for `el.generateTextures()`. */
405
+ 'ai-textures'?: 'auto' | 'manual';
406
+ /** `three-live-ai`: URL of a texture pack (`scene.textures.json`) for AI textures. */
407
+ 'texture-pack'?: string;
408
+ /** `three-live-webgpu`: scene rendering backend (`'auto'`, `'webgpu'`, or `'webgl2'`). */
409
+ renderer?: 'auto' | 'webgpu' | 'webgl2' | string;
410
+ /** `three-live-studio` / `shadowMapsPlugin`: multi-light depth shadow maps (`'auto'`, `'pcf'`, or `'off'`). */
411
+ 'shadow-maps'?: ShadowMapsMode | string;
412
+ /** `xr-live-webgpu`: Gaussian splatting backend (`'auto'`, `'webgpu'`, `'hybrid'`, or `'webgl2'`). */
413
+ 'splat-renderer'?: 'auto' | 'webgpu' | 'hybrid' | 'webgl2' | string;
414
+ /** `xr-live-spatial` / `xr-live-webgpu`: Spherical Harmonics view-dependent color quality (`'normal'` or `'high'`). */
415
+ 'splat-quality'?: 'normal' | 'high' | string;
416
+ /** Allow cross-origin `.splat` / `.spz` URLs on `userData.xr.splatUrl`. */
417
+ 'allow-remote-splats'?: boolean | string;
418
+ /** `three-live-ai`: tapping a mesh selects it (tap again to clear; Shift/Ctrl/Cmd-tap or long-press adds to `el.selectedMeshes`). */
419
+ 'ai-select-on-tap'?: boolean | string;
420
+ /** `three-live-ai`: show a mic button (push-to-talk, or a realtime session when `ai-voice-url` is set). */
421
+ 'ai-voice-button'?: boolean | string;
422
+ /** `three-live-ai`: `wss://` realtime voice endpoint (your proxy or an ephemeral-token URL) for the mic button. */
423
+ 'ai-voice-url'?: string;
424
+ /** `three-live-ai`: realtime voice protocol for `ai-voice-url` (`'ai-realtime'`, the default, or `'gemini-live'`). */
425
+ 'ai-voice-provider'?: 'ai-realtime' | 'gemini-live';
426
+ /** `three-live-ai`: model name sent in the realtime session setup. */
427
+ 'ai-voice-model'?: string;
237
428
 
238
429
  // React 19 / JSX Event Listeners
239
430
  onload?: (e: CustomEvent<{model: GLBData}>) => void;