@fleox/agent3d 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +10 -10
  2. package/changelog.json +11 -0
  3. package/dist/agent/agent3d.mjs +11 -11
  4. package/dist/agent/chunks/{depth-Dih8jLqx.mjs → depth-BZT4gseQ.mjs} +1 -1
  5. package/dist/agent/chunks/{depth-0bZsQn6N.mjs → depth-CD_ql3QJ.mjs} +1 -1
  6. package/dist/agent/chunks/{export-Cdqt3mt_.mjs → export-bJwh2SqG.mjs} +4 -2
  7. package/dist/agent/chunks/{package-d5e08XSG.mjs → package-fMbw9UGh.mjs} +1 -1
  8. package/dist/agent/chunks/{tools-Cv6N_YBI.mjs → tools-Cm4BqDkO.mjs} +4 -4
  9. package/dist/runtime/agent3d-runtime.js +2 -2
  10. package/dist/runtime/agent3d-runtime.single.js +75 -75
  11. package/dist/runtime/chunks/{photo-BlDYgYFM.js → photo-DNf14X7B.js} +9 -9
  12. package/dist/studio/assets/{assets-BFJsr9Oo.js → assets-BW5lQkYR.js} +1 -1
  13. package/dist/studio/assets/{camera-DT0xHipx.js → camera-BgzPVnn-.js} +1 -1
  14. package/dist/studio/assets/{editor-BjgHj9g8.js → editor-NkBUKsDB.js} +1 -1
  15. package/dist/studio/assets/{game-BXZEc9HN.js → game-DARpu0ah.js} +3 -3
  16. package/dist/studio/assets/{generators-DqkPMEzm.js → generators-BjIs-kHx.js} +1 -1
  17. package/dist/studio/assets/{index-DVTzVcBD.js → index-L-N-e2KM.js} +8 -8
  18. package/dist/studio/assets/{model-BqQW4Dg-.js → model-CqI8j03Z.js} +1 -1
  19. package/dist/studio/assets/{params-gVpEEiSK.js → params-DhsDKSDs.js} +1 -1
  20. package/dist/studio/assets/{photo-DRoVO5iZ.js → photo-DAHd1yNF.js} +9 -9
  21. package/dist/studio/assets/{physicsHost-DNdZ7AsT.js → physicsHost-tEUto2-_.js} +1 -1
  22. package/dist/studio/assets/{postfx-JFUGdY0d.js → postfx-BGu30OJK.js} +1 -1
  23. package/dist/studio/assets/{runtime-CMAP4azF.js → runtime-C_qkIpAK.js} +4 -4
  24. package/dist/studio/assets/{shaders-C7u6rN_6.js → shaders-Dt6FGXH_.js} +1 -1
  25. package/dist/studio/assets/{svg-DkIOJjzS.js → svg-ZZt5MdNf.js} +1 -1
  26. package/dist/studio/assets/{text-LISSAism.js → text-B-HM422i.js} +1 -1
  27. package/dist/studio/index.html +1 -1
  28. package/package.json +1 -1
  29. package/plugin/.claude-plugin/plugin.json +1 -1
  30. package/plugin/skills/agent3d-assets/SKILL.md +27 -27
  31. package/plugin/skills/agent3d-create/SKILL.md +28 -27
  32. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  33. package/plugin/skills/agent3d-create/references/recipes.md +6 -6
  34. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  35. package/plugin/skills/agent3d-edit/references/patch-ops.md +2 -2
  36. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  37. package/plugin/skills/agent3d-publish/SKILL.md +21 -21
  38. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  39. package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
  40. package/templates/hero-photo-3d/assets/manifest.json +3 -3
  41. package/templates/hero-photo-3d/assets/textures/street.webp +0 -0
  42. package/templates/hero-photo-3d/scene.json +1 -1
  43. package/templates/hero-photo-3d/assets/textures/street.jpg +0 -0
@@ -1,4 +1,4 @@
1
- import{Dt as e,H as t,Mn as n,Nn as r,Rt as i,b as a,bt as o,d as s,dn as c,en as l,m as u,ot as d,p as f,rn as p,yt as m}from"./three.module-DnaBiDAJ.js";import{i as h}from"./assets-qnxDnVkj.js";import{c as g,r as _,t as v}from"./util-CyaW1fcW.js";var y={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function b(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??y.width;return{width:o,height:o/r}}function x(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:{let e=Math.min(1,r/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(r),y:t*Math.cos(r),zoom:0}}case`zoom`:return{x:0,y:0,zoom:.5-.5*Math.cos(r)};default:return{x:0,y:0,zoom:0}}}function ee(e){let t=_(g(e?.pointer,1),0,1);return{pointer:t,scroll:_(g(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,g(e?.speed,y.speed)),smoothing:_(g(e?.smoothing,y.smoothing),0,.99)}}function te(e,t){let n=t.reduced?{x:0,y:0,zoom:0}:x(e.auto,e.speed,t.t),r=e.pointer*(t.reduced?.5:1),i=0,a=0,o=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(i=t.gyro.x,a=t.gyro.y,o=+(r>0)):r>0&&(i=t.pointer.x,a=t.pointer.y,o=_(t.pointer.weight,0,1));let s=n.x*(1-o)+i*r*o,c=n.y*(1-o)+a*r*o;return e.scroll>0&&(c+=(_(t.scroll,0,1)*2-1)*e.scroll),{x:_(s,-1,1),y:_(c,-1,1),zoom:n.zoom*(1-o)}}function S(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-_(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function C(e,t,n){let r=_(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function ne(e,t,n){let r=Math.round(_(g(e,y.segments),2,1024));return t>=n?[r,Math.max(1,Math.round(r*n/t))]:[Math.max(1,Math.round(r*t/n)),r]}function w(e,t){return _(e,0,1)*t*.25}function re(e,t,n,r){let i=Math.round(_(g(e,y.layers),2,16)),a=[],o=_(n,0,1)*r*.1;for(let e=0;e<i;e++){let n=e/i,s=(e+1)/i,c=(n+s)/2;a.push({lo:n,hi:s,center:c,feather:.35/i,z:(c-t)*o+e*.001*r,background:e===0})}return a}function ie(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:_(i/20,-1,1),y:_(-a/20,-1,1)}}var T=`
1
+ import{Dt as e,H as t,Mn as n,Nn as r,Rt as i,b as a,bt as o,d as s,dn as c,en as l,m as u,ot as d,p as f,rn as p,yt as m}from"./three.module-DnaBiDAJ.js";import{i as h}from"./assets-qnxDnVkj.js";import{c as g,r as _,t as v}from"./util-CyaW1fcW.js";var y={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function ee(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??y.width;return{width:o,height:o/r}}function b(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:{let e=Math.min(1,r/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(r),y:t*Math.cos(r),zoom:0}}case`zoom`:return{x:0,y:0,zoom:.5-.5*Math.cos(r)};default:return{x:0,y:0,zoom:0}}}function te(e){let t=_(g(e?.pointer,1),0,1);return{pointer:t,scroll:_(g(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,g(e?.speed,y.speed)),smoothing:_(g(e?.smoothing,y.smoothing),0,.99)}}function x(e,t){let n=t.reduced?{x:0,y:0,zoom:0}:b(e.auto,e.speed,t.t),r=e.pointer*(t.reduced?.5:1),i=0,a=0,o=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(i=t.gyro.x,a=t.gyro.y,o=+(r>0)):r>0&&(i=t.pointer.x,a=t.pointer.y,o=_(t.pointer.weight,0,1));let s=n.x*(1-o)+i*r*o,c=n.y*(1-o)+a*r*o;return e.scroll>0&&(c+=(_(t.scroll,0,1)*2-1)*e.scroll),{x:_(s,-1,1),y:_(c,-1,1),zoom:n.zoom*(1-o)}}function S(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-_(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function C(e,t,n){let r=_(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function ne(e,t,n){let r=Math.round(_(g(e,y.segments),2,1024));return t>=n?[r,Math.max(1,Math.round(r*n/t))]:[Math.max(1,Math.round(r*t/n)),r]}function w(e,t){return _(e,0,1)*t*.25}function re(e,t,n,r){let i=Math.round(_(g(e,y.layers),2,16)),a=[],o=_(n,0,1)*r*.1;for(let e=0;e<i;e++){let n=e/i,s=(e+1)/i,c=(n+s)/2;a.push({lo:n,hi:s,center:c,feather:.35/i,z:(c-t)*o+e*.001*r,background:e===0})}return a}function ie(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:_(i/20,-1,1),y:_(-a/20,-1,1)}}var T=`
2
2
  uniform sampler2D uMap;
3
3
  uniform vec3 uTint;
4
4
  uniform float uOpacity;
@@ -12,7 +12,7 @@ void main() {
12
12
  vUv = uv;
13
13
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
14
14
  }
15
- `,ae=`
15
+ `,D=`
16
16
  ${T}
17
17
  uniform sampler2D uDepth;
18
18
  uniform vec2 uView;
@@ -22,7 +22,7 @@ uniform vec2 uInset;
22
22
  uniform float uFocus;
23
23
  uniform float uWallSlope;
24
24
  varying vec2 vUv;
25
- const int STEPS = 32;
25
+ const int STEPS = __STEPS__;
26
26
  void main() {
27
27
  // the zoom drift also pushes in slightly (stays inside the inset margin)
28
28
  vec2 base = 0.5 + (vUv - 0.5) * uInset * (1.0 - 0.06 * uZoom);
@@ -77,7 +77,7 @@ void main() {
77
77
  #include <tonemapping_fragment>
78
78
  #include <colorspace_fragment>
79
79
  }
80
- `,oe=`
80
+ `,ae=`
81
81
  uniform sampler2D uDepth;
82
82
  uniform float uRange;
83
83
  uniform float uFocus;
@@ -112,7 +112,7 @@ void main() {
112
112
  }
113
113
  gl_Position = c;
114
114
  }
115
- `,se=`
115
+ `,oe=`
116
116
  ${T}
117
117
  uniform sampler2D uDepth;
118
118
  varying vec2 vUv;
@@ -130,7 +130,7 @@ void main() {
130
130
  #include <tonemapping_fragment>
131
131
  #include <colorspace_fragment>
132
132
  }
133
- `,ce=`
133
+ `,se=`
134
134
  uniform sampler2D uDepth;
135
135
  uniform float uRange;
136
136
  uniform float uFocus;
@@ -160,7 +160,7 @@ void main() {
160
160
  p.z = z;
161
161
  gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
162
162
  }
163
- `,le=`
163
+ `,O=`
164
164
  ${T}
165
165
  uniform sampler2D uDepth;
166
166
  varying vec2 vUv;
@@ -187,7 +187,7 @@ void main() {
187
187
  #include <tonemapping_fragment>
188
188
  #include <colorspace_fragment>
189
189
  }
190
- `,D=`
190
+ `,ce=`
191
191
  ${T}
192
192
  uniform sampler2D uDepth;
193
193
  uniform vec2 uView;
@@ -247,4 +247,4 @@ void main() {
247
247
  #include <tonemapping_fragment>
248
248
  #include <colorspace_fragment>
249
249
  }
250
- `;function O(e){let t=e.image;return{w:t?.naturalWidth||t?.width||1,h:t?.naturalHeight||t?.height||1}}function k(e,t,n){let r=t.material??{};return{uMap:{value:e},uTint:{value:r.color?n.color(r.color):new a(1,1,1)},uOpacity:{value:_(g(r.opacity,1),0,1)},uIntensity:{value:Math.max(0,g(r.emissiveIntensity,1))}}}function A(e,t,n,r){let i=new p({vertexShader:e,fragmentShader:t,uniforms:n,transparent:r,toneMapped:!1,fog:!1,side:0});return i.depthWrite=!r,i}function ue(e,t,n,r){let i=n*r*2,a=new Float32Array(i*9),o=new Float32Array(i*6),s=new Float32Array(i*12),c=0,l=(n,r,i)=>{let l=[n,r,i];for(let n=0;n<3;n++){let[r,i]=l[n],u=l[(n+1)%3],d=l[(n+2)%3];a.set([(r-.5)*e,(i-.5)*t,0],c*3),o.set([r,i],c*2),s.set([u[0],u[1],d[0],d[1]],c*4),c++}};for(let e=0;e<r;e++)for(let t=0;t<n;t++){let i=t/n,a=(t+1)/n,o=e/r,s=(e+1)/r;l([i,o],[a,o],[a,s]),l([i,o],[a,s],[i,s])}let d=new u;return d.setAttribute(`position`,new f(a,3)),d.setAttribute(`uv`,new f(o,2)),d.setAttribute(`uvOther`,new f(s,4)),d}async function j(a,u){let[f,p]=await Promise.all([h(u.resolveAsset(a.src)),a.depth?h(u.resolveAsset(a.depth)).catch(e=>(u.issue(`asset-load`,`${a.id}: depth map: ${e.message} — showing the photo flat`,`objects#${a.id}.depth`),null)):Promise.resolve(null)]);f.colorSpace=l,f.wrapS=f.wrapT=e,f.anisotropy=4,f.needsUpdate=!0,p&&(p.colorSpace=``,p.premultiplyAlpha=!1,p.wrapS=p.wrapT=e,p.generateMipmaps=!1,p.minFilter=d,p.magFilter=d,p.needsUpdate=!0);let x=O(f),{width:T,height:j}=b(a,x.w,x.h),M=_(g(a.strength,y.strength),0,1),N=_(g(a.focus,y.focus),0,1),P=_(g(a.material?.opacity,1),0,1),F=P<1||/\.(png|webp)$/i.test(a.src),I=ee(a.motion),L=p?a.mode??`parallax`:`flat`,R=new t,z=new t;R.add(z);let B=[],V=[],H=[],U=[],W=null,G=()=>{let e=new i(T,j);return V.push(e),e};if(L===`flat`){let e=a.material??{},t=new o({map:f,transparent:F,opacity:P,toneMapped:!1,fog:!1});e.color&&t.color.copy(u.color(e.color)),t.color.multiplyScalar(Math.max(0,g(e.emissiveIntensity,1))),F&&(t.alphaTest=P<1?0:.004),B.push(t),z.add(new m(G(),t))}else if(L===`parallax`){let e=C(M,T,j),t=A(E,ae,{...k(f,a,u),uDepth:{value:p},uView:{value:new n},uZoom:{value:0},uMaxOffset:{value:new n(...e.maxOffset)},uInset:{value:new n(...e.inset)},uFocus:{value:N},uWallSlope:{value:.02}},F);B.push(t),H.push(t),z.add(new m(G(),t))}else if(L===`mesh`){let[e,t]=ne(g(a.segments,y.segments),T,j),o=w(M,T),l=ue(T,j,e,t);l.boundingBox=new s(new r(-T/2,-j/2,-N*o),new r(T/2,j/2,(1-N)*o)),l.boundingSphere=l.boundingBox.getBoundingSphere(new c),V.push(l);let d={...k(f,a,u),uDepth:{value:p},uRange:{value:o},uFocus:{value:N},uEdgeCut:{value:_(g(a.edgeCut,y.edgeCut),0,1)},uCam:{value:new r(0,0,1e6)},uPerspective:{value:0}};W=d;let h=A(oe,se,d,P<1);h.side=2,B.push(h);let v=new m(l,h);v.renderOrder=1,z.add(v);{let r=new i(T,j,Math.max(1,Math.round(e/2)),Math.max(1,Math.round(t/2)));r.boundingBox=l.boundingBox.clone(),r.boundingSphere=l.boundingSphere.clone(),V.push(r);let a=new n(6/e,6/t),o=A(ce,le,{...d,uReach:{value:a}},P<1);o.side=2,B.push(o);let s=new m(r,o);s.renderOrder=0,s.raycast=()=>void 0,z.add(s)}}else{let e=C(M,T,j),t=G(),r=re(g(a.layers,y.layers),N,M,T),i=_(g(a.edgeCut,y.edgeCut),0,1);r.forEach((r,o)=>{let s=A(E,D,{...k(f,a,u),uDepth:{value:p},uView:{value:new n},uZoom:{value:0},uMaxOffset:{value:new n(...e.maxOffset)},uInset:{value:new n(...e.inset)},uFocus:{value:N},uCenter:{value:r.center},uLo:{value:r.lo},uHi:{value:r.hi},uFeather:{value:i>0?Math.min(r.feather,i):.002},uBackground:{value:+!!r.background}},!r.background||F);B.push(s),H.push(s);let c=new m(t,s);c.position.z=r.z,c.renderOrder=o,c.userData.a3dPhotoLayer=o,z.add(c),U.push({mesh:c,band:r})})}let K=!u.deterministic,q={x:0,y:0,weight:0,init:!1},J=null,Y=null,X=null;if(K&&I.gyro&&I.pointer>0&&L!==`flat`&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;Y??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;J=ie(e.beta,e.gamma,Y,t)};window.addEventListener(`deviceorientation`,e),X=()=>window.removeEventListener(`deviceorientation`,e)}let Z=new r,Q=!1,$=M*8*v;return{object:R,update:(e,t,n)=>{if(L===`flat`)return;let r=n.pointer,i=r.inside?_(r.x,-1,1):0,a=r.inside?_(r.y,-1,1):0,o=+!!r.inside;!K||!q.init?(q.x=i,q.y=a,q.weight=o,q.init=K):(q.x=S(q.x,i,t,I.smoothing),q.y=S(q.y,a,t,I.smoothing),q.weight=S(q.weight,o,t,I.smoothing));let s=te(I,{t:e,pointer:q,gyro:K?J:null,scroll:n.scroll,reduced:n.reduced});for(let e of H)e.uniforms.uView.value.set(s.x,s.y),e.uniforms.uZoom.value=s.zoom;let c=!!n.camera&&!!n.camera.isPerspectiveCamera;if(n.camera&&!Q&&L!==`parallax`&&(n.camera.updateMatrixWorld(),R.updateWorldMatrix(!0,!1),Z.setFromMatrixPosition(n.camera.matrixWorld),R.worldToLocal(Z),Q=!0),L===`mesh`)z.rotation.set(s.y*$,-s.x*$,0),z.position.z=s.zoom*w(M,T)*.5,W&&(W.uCam.value.copy(Z),W.uPerspective.value=c&&Z.z>0?1:0);else if(L===`layers`&&Q){let e=Z.z;for(let{mesh:t,band:n}of U)if(c&&e>n.z+.001){let r=(e-n.z)/e;t.scale.set(r,r,1),t.position.set(Z.x*n.z/e,Z.y*n.z/e,n.z)}else t.scale.set(1,1,1),t.position.set(0,0,n.z)}},dispose(){X?.(),X=null;for(let e of B)e.dispose();for(let e of V)e.dispose();f.dispose(),p?.dispose()}}}export{j as buildPhoto};
250
+ `;function le(e){let t=e.image;return{w:t?.naturalWidth||t?.width||1,h:t?.naturalHeight||t?.height||1}}function k(e,t,n){let r=t.material??{};return{uMap:{value:e},uTint:{value:r.color?n.color(r.color):new a(1,1,1)},uOpacity:{value:_(g(r.opacity,1),0,1)},uIntensity:{value:Math.max(0,g(r.emissiveIntensity,1))}}}function A(e,t,n,r){let i=new p({vertexShader:e,fragmentShader:t,uniforms:n,transparent:r,toneMapped:!1,fog:!1,side:0});return i.depthWrite=!r,i}function ue(e,t,n,r){let i=n*r*2,a=new Float32Array(i*9),o=new Float32Array(i*6),s=new Float32Array(i*12),c=0,l=(n,r,i)=>{let l=[n,r,i];for(let n=0;n<3;n++){let[r,i]=l[n],u=l[(n+1)%3],d=l[(n+2)%3];a.set([(r-.5)*e,(i-.5)*t,0],c*3),o.set([r,i],c*2),s.set([u[0],u[1],d[0],d[1]],c*4),c++}};for(let e=0;e<r;e++)for(let t=0;t<n;t++){let i=t/n,a=(t+1)/n,o=e/r,s=(e+1)/r;l([i,o],[a,o],[a,s]),l([i,o],[a,s],[i,s])}let d=new u;return d.setAttribute(`position`,new f(a,3)),d.setAttribute(`uv`,new f(o,2)),d.setAttribute(`uvOther`,new f(s,4)),d}function de(e,t){return Math.max(8,Math.round((e===`low`?12:e===`medium`?20:e===`ultra`?48:32)*(.5+.5*Math.min(1,Math.max(0,t)/.6))))}async function j(a,u){let[f,p]=await Promise.all([h(u.resolveAsset(a.src)),a.depth?h(u.resolveAsset(a.depth)).catch(e=>(u.issue(`asset-load`,`${a.id}: depth map: ${e.message} — showing the photo flat`,`objects#${a.id}.depth`),null)):Promise.resolve(null)]);f.colorSpace=l,f.wrapS=f.wrapT=e,f.anisotropy=4,f.needsUpdate=!0,p&&(p.colorSpace=``,p.premultiplyAlpha=!1,p.wrapS=p.wrapT=e,p.generateMipmaps=!1,p.minFilter=d,p.magFilter=d,p.needsUpdate=!0);let b=le(f),{width:T,height:j}=ee(a,b.w,b.h),M=_(g(a.strength,y.strength),0,1),N=_(g(a.focus,y.focus),0,1),P=_(g(a.material?.opacity,1),0,1),F=P<1||/\.(png|webp)$/i.test(a.src),I=te(a.motion),L=p?a.mode??`parallax`:`flat`,R=new t,z=new t;R.add(z);let B=[],V=[],H=[],U=[],W=null,G=()=>{let e=new i(T,j);return V.push(e),e};if(L===`flat`){let e=a.material??{},t=new o({map:f,transparent:F,opacity:P,toneMapped:!1,fog:!1});e.color&&t.color.copy(u.color(e.color)),t.color.multiplyScalar(Math.max(0,g(e.emissiveIntensity,1))),F&&(t.alphaTest=P<1?0:.004),B.push(t),z.add(new m(G(),t))}else if(L===`parallax`){let e=C(M,T,j),t={...k(f,a,u),uDepth:{value:p},uView:{value:new n},uZoom:{value:0},uMaxOffset:{value:new n(...e.maxOffset)},uInset:{value:new n(...e.inset)},uFocus:{value:N},uWallSlope:{value:.02}},r=A(E,D.replace(`__STEPS__`,String(de(u.quality,M))),t,F);B.push(r),H.push(r),z.add(new m(G(),r))}else if(L===`mesh`){let[e,t]=ne(g(a.segments,y.segments),T,j),o=w(M,T),l=ue(T,j,e,t);l.boundingBox=new s(new r(-T/2,-j/2,-N*o),new r(T/2,j/2,(1-N)*o)),l.boundingSphere=l.boundingBox.getBoundingSphere(new c),V.push(l);let d={...k(f,a,u),uDepth:{value:p},uRange:{value:o},uFocus:{value:N},uEdgeCut:{value:_(g(a.edgeCut,y.edgeCut),0,1)},uCam:{value:new r(0,0,1e6)},uPerspective:{value:0}};W=d;let h=A(ae,oe,d,P<1);h.side=2,B.push(h);let v=new m(l,h);v.renderOrder=1,z.add(v);{let r=new i(T,j,Math.max(1,Math.round(e/2)),Math.max(1,Math.round(t/2)));r.boundingBox=l.boundingBox.clone(),r.boundingSphere=l.boundingSphere.clone(),V.push(r);let a=new n(6/e,6/t),o=A(se,O,{...d,uReach:{value:a}},P<1);o.side=2,B.push(o);let s=new m(r,o);s.renderOrder=0,s.raycast=()=>void 0,z.add(s)}}else{let e=C(M,T,j),t=G(),r=re(g(a.layers,y.layers),N,M,T),i=_(g(a.edgeCut,y.edgeCut),0,1);r.forEach((r,o)=>{let s=A(E,ce,{...k(f,a,u),uDepth:{value:p},uView:{value:new n},uZoom:{value:0},uMaxOffset:{value:new n(...e.maxOffset)},uInset:{value:new n(...e.inset)},uFocus:{value:N},uCenter:{value:r.center},uLo:{value:r.lo},uHi:{value:r.hi},uFeather:{value:i>0?Math.min(r.feather,i):.002},uBackground:{value:+!!r.background}},!r.background||F);B.push(s),H.push(s);let c=new m(t,s);c.position.z=r.z,c.renderOrder=o,c.userData.a3dPhotoLayer=o,z.add(c),U.push({mesh:c,band:r})})}let K=!u.deterministic,q={x:0,y:0,weight:0,init:!1},J=null,Y=null,X=null;if(K&&I.gyro&&I.pointer>0&&L!==`flat`&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;Y??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;J=ie(e.beta,e.gamma,Y,t)};window.addEventListener(`deviceorientation`,e),X=()=>window.removeEventListener(`deviceorientation`,e)}let Z=new r,Q=!1,$=M*8*v;return{object:R,update:(e,t,n)=>{if(L===`flat`)return;let r=n.pointer,i=r.inside?_(r.x,-1,1):0,a=r.inside?_(r.y,-1,1):0,o=+!!r.inside;!K||!q.init?(q.x=i,q.y=a,q.weight=o,q.init=K):(q.x=S(q.x,i,t,I.smoothing),q.y=S(q.y,a,t,I.smoothing),q.weight=S(q.weight,o,t,I.smoothing));let s=x(I,{t:e,pointer:q,gyro:K?J:null,scroll:n.scroll,reduced:n.reduced});for(let e of H)e.uniforms.uView.value.set(s.x,s.y),e.uniforms.uZoom.value=s.zoom;let c=!!n.camera&&!!n.camera.isPerspectiveCamera;if(n.camera&&!Q&&L!==`parallax`&&(n.camera.updateMatrixWorld(),R.updateWorldMatrix(!0,!1),Z.setFromMatrixPosition(n.camera.matrixWorld),R.worldToLocal(Z),Q=!0),L===`mesh`)z.rotation.set(s.y*$,-s.x*$,0),z.position.z=s.zoom*w(M,T)*.5,W&&(W.uCam.value.copy(Z),W.uPerspective.value=c&&Z.z>0?1:0);else if(L===`layers`&&Q){let e=Z.z;for(let{mesh:t,band:n}of U)if(c&&e>n.z+.001){let r=(e-n.z)/e;t.scale.set(r,r,1),t.position.set(Z.x*n.z/e,Z.y*n.z/e,n.z)}else t.scale.set(1,1,1),t.position.set(0,0,n.z)}},dispose(){X?.(),X=null;for(let e of B)e.dispose();for(let e of V)e.dispose();f.dispose(),p?.dispose()}}}export{j as buildPhoto};
@@ -1 +1 @@
1
- import{h as e}from"./index-DVTzVcBD.js";function t(e){return e.endsWith(`/`)?e:e+`/`}function n(e){let n=t(e.assetBase??`./`),r=t(e.libraryBase??n+`assets/library/`),i=e.assetUrls??{};return e=>{if(i[e])return i[e];if(/^(https?:|data:|blob:|\/)/.test(e))return e;if(e.startsWith(`library:`)){let t=e.slice(8);return t.startsWith(`fonts/`)&&!/\.json$/.test(t)&&(t+=`.typeface.json`),i[`library:`+t]?i[`library:`+t]:r+t}return n+e.replace(/^\.\//,``)}}var r=new Map;function i(e){let t=r.get(e);return t||(t=fetch(e).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return t.text()}),t.catch(()=>r.delete(e)),r.set(e,t)),t}async function a(e){return JSON.parse(await i(e))}var o=new Map;function s(t){let n=o.get(t);return n||(n=e(()=>import(`./three.module-CnI50X0U.js`).then(e=>e.a).then(e=>new Promise((n,r)=>{new e.TextureLoader().load(t,n,void 0,()=>r(Error(`Cannot load texture ${t}`)))})),[],import.meta.url),n.catch(()=>o.delete(t)),o.set(t,n)),n.then(e=>{let t=e.clone();return t.needsUpdate=!0,t})}export{s as i,a as n,i as r,n as t};
1
+ import{h as e}from"./index-L-N-e2KM.js";function t(e){return e.endsWith(`/`)?e:e+`/`}function n(e){let n=t(e.assetBase??`./`),r=t(e.libraryBase??n+`assets/library/`),i=e.assetUrls??{};return e=>{if(i[e])return i[e];if(/^(https?:|data:|blob:|\/)/.test(e))return e;if(e.startsWith(`library:`)){let t=e.slice(8);return t.startsWith(`fonts/`)&&!/\.json$/.test(t)&&(t+=`.typeface.json`),i[`library:`+t]?i[`library:`+t]:r+t}return n+e.replace(/^\.\//,``)}}var r=new Map;function i(e){let t=r.get(e);return t||(t=fetch(e).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return t.text()}),t.catch(()=>r.delete(e)),r.set(e,t)),t}async function a(e){return JSON.parse(await i(e))}var o=new Map;function s(t){let n=o.get(t);return n||(n=e(()=>import(`./three.module-CnI50X0U.js`).then(e=>e.a).then(e=>new Promise((n,r)=>{new e.TextureLoader().load(t,n,void 0,()=>r(Error(`Cannot load texture ${t}`)))})),[],import.meta.url),n.catch(()=>o.delete(t)),o.set(t,n)),n.then(e=>{let t=e.clone();return t.needsUpdate=!0,t})}export{s as i,a as n,i as r,n as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./OrbitControls-MlE9XiCg.js","./three.module-CnI50X0U.js"])))=>i.map(i=>d[i]);
2
- import{In as e,It as t,Ln as n,Rt as r,wn as i,x as a}from"./three.module-CnI50X0U.js";import{h as o}from"./index-DVTzVcBD.js";var s=Math.PI/180;function c(e,t,n){return e<t?t:e>n?n:e}function l(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function u(e,t){return typeof e==`boolean`?e:t}function d(e,t){return typeof e==`string`?e:t}function f(e,t){return Array.isArray(e)&&e.length>=3&&e.every(e=>typeof e==`number`)?[e[0],e[1],e[2]]:t}function p(e,t){return typeof e==`string`?[e]:Array.isArray(e)&&e.length&&e.every(e=>typeof e==`string`)?e:t}var m=new Map;function h(e,t=`#ffffff`){let n=typeof e==`string`&&e?e:t,r=m.get(n);if(!r){r=new a;try{r.setStyle(n)}catch{r.setStyle(t)}m.size>512&&m.clear(),m.set(n,r)}return r.clone()}function g(e,t){let n={};if(e)for(let t of e.params)t.default!==void 0&&(n[t.name]=t.default);for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function _(e,t){let n=c(e,0,.999);return n<=0?1:1-n**(t*60)}function v(e){let t=Math.sin(e*127.1+311.7)*43758.5453123;return t-Math.floor(t)}function y(e){e.traverse(e=>{let t=e;t.geometry&&t.geometry.dispose();let n=t.material;if(n)for(let e of Array.isArray(n)?n:[n])b(e)})}function b(e){for(let t of Object.values(e))t instanceof i&&t.dispose();e.dispose()}function x(e){let t=new Set;return e.traverse(e=>{let n=e.material;if(n&&!e.userData.depthTwin)for(let e of Array.isArray(n)?n:[n])t.add(e)}),[...t]}function S(e){let t=(Math.floor(e)|0)^2654435769,n=()=>{t=t+2654435769|0;let e=t;return e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),(e^e>>>16)>>>0},r=n(),i=n(),a=n(),o=n(),s=()=>{r>>>=0,i>>>=0,a>>>=0,o>>>=0;let e=(r+i|0)+o|0;return o=o+1|0,r=i^i>>>9,i=a+(a<<3)|0,a=a<<21|a>>>11,a=a+e|0,(e>>>0)/4294967296};for(let e=0;e<12;e++)s();return{next:s,range:(e,t)=>e+(t-e)*s(),int:(e,t)=>e+Math.floor(s()*(t-e+1)),pick:e=>e[Math.floor(s()*e.length)]}}function C(e,t){let n=(e|0)^2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}var w=new Uint8Array(512),T=new Uint8Array(512);{let e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;let t=S(1337);for(let n=255;n>0;n--){let r=Math.floor(t.next()*(n+1)),i=e[n];e[n]=e[r],e[r]=i}for(let t=0;t<512;t++)w[t]=e[t&255],T[t]=w[t]%12}var E=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),D=.5*(Math.sqrt(3)-1),O=(3-Math.sqrt(3))/6;function k(e,t){let n=(e+t)*D,r=Math.floor(e+n),i=Math.floor(t+n),a=(r+i)*O,o=e-(r-a),s=t-(i-a),c=+(o>s),l=o>s?0:1,u=o-c+O,d=s-l+O,f=o-1+2*O,p=s-1+2*O,m=r&255,h=i&255,g=0,_=.5-o*o-s*s;if(_>0){let e=T[m+w[h]]*3;_*=_,g+=_*_*(E[e]*o+E[e+1]*s)}let v=.5-u*u-d*d;if(v>0){let e=T[m+c+w[h+l]]*3;v*=v,g+=v*v*(E[e]*u+E[e+1]*d)}let y=.5-f*f-p*p;if(y>0){let e=T[m+1+w[h+1]]*3;y*=y,g+=y*y*(E[e]*f+E[e+1]*p)}return 70*g}var A=1/3,j=1/6;function M(e,t,n){let r=(e+t+n)*A,i=Math.floor(e+r),a=Math.floor(t+r),o=Math.floor(n+r),s=(i+a+o)*j,c=e-(i-s),l=t-(a-s),u=n-(o-s),d,f,p,m,h,g;c>=l?l>=u?[d,f,p,m,h,g]=[1,0,0,1,1,0]:c>=u?[d,f,p,m,h,g]=[1,0,0,1,0,1]:[d,f,p,m,h,g]=[0,0,1,1,0,1]:l<u?[d,f,p,m,h,g]=[0,0,1,0,1,1]:c<u?[d,f,p,m,h,g]=[0,1,0,0,1,1]:[d,f,p,m,h,g]=[0,1,0,1,1,0];let _=c-d+j,v=l-f+j,y=u-p+j,b=c-m+2*j,x=l-h+2*j,S=u-g+2*j,C=c-1+3*j,D=l-1+3*j,O=u-1+3*j,k=i&255,M=a&255,N=o&255,P=0,F=(e,t,n,r)=>{let i=.6-e*e-t*t-n*n;if(i>0){let a=r*3;i*=i,P+=i*i*(E[a]*e+E[a+1]*t+E[a+2]*n)}};return F(c,l,u,T[k+w[M+w[N]]]),F(_,v,y,T[k+d+w[M+f+w[N+p]]]),F(b,x,S,T[k+m+w[M+h+w[N+g]]]),F(C,D,O,T[k+1+w[M+1+w[N+1]]]),32*P}function N(e,t,n,r=2,i=.5){let a=0,o=1,s=1,c=0;for(let l=0;l<n;l++)a+=o*k(e*s+l*17.31,t*s-l*9.17),c+=o,o*=i,s*=r;return c>0?a/c:0}function P(e,t,n,r,i=2,a=.5){let o=0,s=1,c=1,l=0;for(let u=0;u<r;u++)o+=s*M(e*c+u*17.31,t*c-u*9.17,n*c+u*3.7),l+=s,s*=a,c*=i;return l>0?o/l:0}function F(e,t,n,r=2,i=.5){let a=0,o=1,s=1,c=0;for(let l=0;l<n;l++){let n=1-Math.abs(k(e*s+l*31.7,t*s+l*11.3));a+=o*n*n,c+=o,o*=i,s*=r}return c>0?a/c:0}function I(e,i){let a=l(e.near,.1),o=l(e.far,1e3),s;if(e.type===`orthographic`){let n=l(e.zoom,10)/2;s=new t(-n*i,n*i,n,-n,a,o)}else s=new r(l(e.fov,45),i,a,o);s.position.set(...e.position);let c=e.target??[0,0,0];return B(s.position,new n(c[0],c[1],c[2])),s.lookAt(c[0],c[1],c[2]),s}function L(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function R(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*s/2)*t)/s)}function z(e,n,i,a){let o=L(i,a);if(e.userData.fitScale=o,e instanceof r)e.aspect=i,e.fov=R(l(e.userData.restFov,l(n.fov,45)),o),e.updateProjectionMatrix();else if(e instanceof t){let t=(e.userData.zoomHeight??l(n.zoom,10))/2*o;e.left=-t*i,e.right=t*i,e.top=t,e.bottom=-t,e.updateProjectionMatrix()}}function B(e,t){let n=t.x-e.x,r=t.y-e.y,i=t.z-e.z,a=Math.hypot(n,r,i);if(a<1e-9)return;let o=-1e-4/a;e.set(e.x+n*o,e.y+r*o,e.z+i*o)}async function V(i,a,u,d){let f=new n(...i.target??[0,0,0]),p={position:new n(...i.position),target:f.clone(),fov:l(i.fov,45),zoom:l(i.zoom,10)},m=i.controls??`none`,h=p.position.clone(),g=p.target.clone(),v=new e,y=new n,b=!0,x=null;if(m===`orbit`&&u&&!d){let{OrbitControls:e}=await o(async()=>{let{OrbitControls:e}=await import(`./OrbitControls-MlE9XiCg.js`);return{OrbitControls:e}},__vite__mapDeps([0,1]),import.meta.url),t=new e(a,u);t.target.copy(p.target),t.enableDamping=!0,t.dampingFactor=.08,t.enableZoom=i.orbitZoom!==!1,t.enablePan=!1;let n=i.orbitLimits??{};n.minDistance!==void 0&&(t.minDistance=n.minDistance),n.maxDistance!==void 0&&(t.maxDistance=n.maxDistance),n.minPolar!==void 0&&(t.minPolarAngle=n.minPolar*s),n.maxPolar!==void 0&&(t.maxPolarAngle=n.maxPolar*s),n.minAzimuth!==void 0&&(t.minAzimuthAngle=n.minAzimuth*s),n.maxAzimuth!==void 0&&(t.maxAzimuthAngle=n.maxAzimuth*s),i.autoRotate&&(t.autoRotate=!0,t.autoRotateSpeed=i.autoRotate/360*60),x=t}let S=new n,C=new n;return{rest:p,shake:y,orbit:x,update(e,o,u){if(a instanceof r){a.userData.restFov=p.fov;let e=R(p.fov,l(a.userData.fitScale,1));a.fov!==e&&(a.fov=e,a.updateProjectionMatrix())}else if(a instanceof t&&l(a.userData.zoomHeight,l(i.zoom,10))!==p.zoom){a.userData.zoomHeight=p.zoom;let e=(a.right-a.left)/Math.max(a.top-a.bottom,1e-6),t=p.zoom/2*l(a.userData.fitScale,1);a.left=-t*e,a.right=t*e,a.top=t,a.bottom=-t,a.updateProjectionMatrix()}if(x){x.update(),a.position.add(y);return}let d=S.copy(p.position),f=g;if(m===`scroll`&&i.scrollPath?.length){let e=i.scrollPath,t=c(u.scroll,0,1)*(e.length-1),r=Math.min(Math.floor(t),e.length-2),a=e.length===1?0:t-Math.max(r,0),o=a*a*(3-2*a),s=e[Math.max(r,0)],l=e[Math.min(Math.max(r,0)+1,e.length-1)];d.set(...s.position).lerp(new n(...l.position),o);let p=new n(...s.target??i.target??[0,0,0]),m=new n(...l.target??i.target??[0,0,0]);f.copy(p.lerp(m,o))}else if(m===`follow`&&u.followTarget){let e=i.follow??{target:``},t=u.followTarget.getWorldPosition(new n),r=new n(...e.offset??[0,4,8]),a=t.clone().add(r),s=t.clone().add(new n(0,0,-l(e.lookAhead,0))),c=b?1:_(l(e.smoothing,.85),o);h.lerp(a,c),f.lerp(s,c),d=S.copy(h)}else f.copy(p.target);if(u.lookAt&&f.copy(u.lookAt),i.autoRotate&&m!==`follow`){let t=i.autoRotate*s*e,r=d.clone().sub(f);r.applyAxisAngle(new n(0,1,0),t),d.copy(f).add(r)}if(m===`parallax`){let e=i.parallax??{},t=l(e.strength,.5),r=_(l(e.smoothing,.92),o);v.x+=(u.pointer.x*t-v.x)*r,v.y+=(u.pointer.y*t*.6-v.y)*r;let s=f.clone().sub(d).normalize(),c=new n().crossVectors(s,a.up).normalize(),p=new n().crossVectors(c,s).normalize();d.addScaledVector(c,v.x).addScaledVector(p,v.y)}if(i.shake){let t=i.shake,r=l(t.speed,.5),o=l(t.amount,.03),c=l(t.rotation,.4)*s,u=l(t.seed,1)*17.31,p=t=>k(e*r+u,t*7.13)*.75+k(e*r*2.7+u,t*7.13+3.1)*.25,m=f.clone().sub(d),h=m.length()||1;m.divideScalar(h);let g=new n().crossVectors(m,a.up).normalize(),_=new n().crossVectors(g,m).normalize();d.addScaledVector(g,p(0)*o).addScaledVector(_,p(1)*o),C.copy(f).addScaledVector(g,Math.tan(p(2)*c)*h).addScaledVector(_,Math.tan(p(3)*c)*h)}else C.copy(f);a.position.copy(d).add(y),B(a.position,C),a.lookAt(C),b=!1},dispose(){x?.dispose()}}}export{g as C,f as S,x as _,N as a,d as b,k as c,s as d,u as f,v as g,y as h,S as i,M as l,p as m,V as n,P as o,c as p,z as r,C as s,I as t,F as u,l as v,h as x,_ as y};
2
+ import{In as e,It as t,Ln as n,Rt as r,wn as i,x as a}from"./three.module-CnI50X0U.js";import{h as o}from"./index-L-N-e2KM.js";var s=Math.PI/180;function c(e,t,n){return e<t?t:e>n?n:e}function l(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function u(e,t){return typeof e==`boolean`?e:t}function d(e,t){return typeof e==`string`?e:t}function f(e,t){return Array.isArray(e)&&e.length>=3&&e.every(e=>typeof e==`number`)?[e[0],e[1],e[2]]:t}function p(e,t){return typeof e==`string`?[e]:Array.isArray(e)&&e.length&&e.every(e=>typeof e==`string`)?e:t}var m=new Map;function h(e,t=`#ffffff`){let n=typeof e==`string`&&e?e:t,r=m.get(n);if(!r){r=new a;try{r.setStyle(n)}catch{r.setStyle(t)}m.size>512&&m.clear(),m.set(n,r)}return r.clone()}function g(e,t){let n={};if(e)for(let t of e.params)t.default!==void 0&&(n[t.name]=t.default);for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function _(e,t){let n=c(e,0,.999);return n<=0?1:1-n**(t*60)}function v(e){let t=Math.sin(e*127.1+311.7)*43758.5453123;return t-Math.floor(t)}function y(e){e.traverse(e=>{let t=e;t.geometry&&t.geometry.dispose();let n=t.material;if(n)for(let e of Array.isArray(n)?n:[n])b(e)})}function b(e){for(let t of Object.values(e))t instanceof i&&t.dispose();e.dispose()}function x(e){let t=new Set;return e.traverse(e=>{let n=e.material;if(n&&!e.userData.depthTwin)for(let e of Array.isArray(n)?n:[n])t.add(e)}),[...t]}function S(e){let t=(Math.floor(e)|0)^2654435769,n=()=>{t=t+2654435769|0;let e=t;return e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),(e^e>>>16)>>>0},r=n(),i=n(),a=n(),o=n(),s=()=>{r>>>=0,i>>>=0,a>>>=0,o>>>=0;let e=(r+i|0)+o|0;return o=o+1|0,r=i^i>>>9,i=a+(a<<3)|0,a=a<<21|a>>>11,a=a+e|0,(e>>>0)/4294967296};for(let e=0;e<12;e++)s();return{next:s,range:(e,t)=>e+(t-e)*s(),int:(e,t)=>e+Math.floor(s()*(t-e+1)),pick:e=>e[Math.floor(s()*e.length)]}}function C(e,t){let n=(e|0)^2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}var w=new Uint8Array(512),T=new Uint8Array(512);{let e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;let t=S(1337);for(let n=255;n>0;n--){let r=Math.floor(t.next()*(n+1)),i=e[n];e[n]=e[r],e[r]=i}for(let t=0;t<512;t++)w[t]=e[t&255],T[t]=w[t]%12}var E=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),D=.5*(Math.sqrt(3)-1),O=(3-Math.sqrt(3))/6;function k(e,t){let n=(e+t)*D,r=Math.floor(e+n),i=Math.floor(t+n),a=(r+i)*O,o=e-(r-a),s=t-(i-a),c=+(o>s),l=o>s?0:1,u=o-c+O,d=s-l+O,f=o-1+2*O,p=s-1+2*O,m=r&255,h=i&255,g=0,_=.5-o*o-s*s;if(_>0){let e=T[m+w[h]]*3;_*=_,g+=_*_*(E[e]*o+E[e+1]*s)}let v=.5-u*u-d*d;if(v>0){let e=T[m+c+w[h+l]]*3;v*=v,g+=v*v*(E[e]*u+E[e+1]*d)}let y=.5-f*f-p*p;if(y>0){let e=T[m+1+w[h+1]]*3;y*=y,g+=y*y*(E[e]*f+E[e+1]*p)}return 70*g}var A=1/3,j=1/6;function M(e,t,n){let r=(e+t+n)*A,i=Math.floor(e+r),a=Math.floor(t+r),o=Math.floor(n+r),s=(i+a+o)*j,c=e-(i-s),l=t-(a-s),u=n-(o-s),d,f,p,m,h,g;c>=l?l>=u?[d,f,p,m,h,g]=[1,0,0,1,1,0]:c>=u?[d,f,p,m,h,g]=[1,0,0,1,0,1]:[d,f,p,m,h,g]=[0,0,1,1,0,1]:l<u?[d,f,p,m,h,g]=[0,0,1,0,1,1]:c<u?[d,f,p,m,h,g]=[0,1,0,0,1,1]:[d,f,p,m,h,g]=[0,1,0,1,1,0];let _=c-d+j,v=l-f+j,y=u-p+j,b=c-m+2*j,x=l-h+2*j,S=u-g+2*j,C=c-1+3*j,D=l-1+3*j,O=u-1+3*j,k=i&255,M=a&255,N=o&255,P=0,F=(e,t,n,r)=>{let i=.6-e*e-t*t-n*n;if(i>0){let a=r*3;i*=i,P+=i*i*(E[a]*e+E[a+1]*t+E[a+2]*n)}};return F(c,l,u,T[k+w[M+w[N]]]),F(_,v,y,T[k+d+w[M+f+w[N+p]]]),F(b,x,S,T[k+m+w[M+h+w[N+g]]]),F(C,D,O,T[k+1+w[M+1+w[N+1]]]),32*P}function N(e,t,n,r=2,i=.5){let a=0,o=1,s=1,c=0;for(let l=0;l<n;l++)a+=o*k(e*s+l*17.31,t*s-l*9.17),c+=o,o*=i,s*=r;return c>0?a/c:0}function P(e,t,n,r,i=2,a=.5){let o=0,s=1,c=1,l=0;for(let u=0;u<r;u++)o+=s*M(e*c+u*17.31,t*c-u*9.17,n*c+u*3.7),l+=s,s*=a,c*=i;return l>0?o/l:0}function F(e,t,n,r=2,i=.5){let a=0,o=1,s=1,c=0;for(let l=0;l<n;l++){let n=1-Math.abs(k(e*s+l*31.7,t*s+l*11.3));a+=o*n*n,c+=o,o*=i,s*=r}return c>0?a/c:0}function I(e,i){let a=l(e.near,.1),o=l(e.far,1e3),s;if(e.type===`orthographic`){let n=l(e.zoom,10)/2;s=new t(-n*i,n*i,n,-n,a,o)}else s=new r(l(e.fov,45),i,a,o);s.position.set(...e.position);let c=e.target??[0,0,0];return B(s.position,new n(c[0],c[1],c[2])),s.lookAt(c[0],c[1],c[2]),s}function L(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function R(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*s/2)*t)/s)}function z(e,n,i,a){let o=L(i,a);if(e.userData.fitScale=o,e instanceof r)e.aspect=i,e.fov=R(l(e.userData.restFov,l(n.fov,45)),o),e.updateProjectionMatrix();else if(e instanceof t){let t=(e.userData.zoomHeight??l(n.zoom,10))/2*o;e.left=-t*i,e.right=t*i,e.top=t,e.bottom=-t,e.updateProjectionMatrix()}}function B(e,t){let n=t.x-e.x,r=t.y-e.y,i=t.z-e.z,a=Math.hypot(n,r,i);if(a<1e-9)return;let o=-1e-4/a;e.set(e.x+n*o,e.y+r*o,e.z+i*o)}async function V(i,a,u,d){let f=new n(...i.target??[0,0,0]),p={position:new n(...i.position),target:f.clone(),fov:l(i.fov,45),zoom:l(i.zoom,10)},m=i.controls??`none`,h=p.position.clone(),g=p.target.clone(),v=new e,y=new n,b=!0,x=null;if(m===`orbit`&&u&&!d){let{OrbitControls:e}=await o(async()=>{let{OrbitControls:e}=await import(`./OrbitControls-MlE9XiCg.js`);return{OrbitControls:e}},__vite__mapDeps([0,1]),import.meta.url),t=new e(a,u);t.target.copy(p.target),t.enableDamping=!0,t.dampingFactor=.08,t.enableZoom=i.orbitZoom!==!1,t.enablePan=!1;let n=i.orbitLimits??{};n.minDistance!==void 0&&(t.minDistance=n.minDistance),n.maxDistance!==void 0&&(t.maxDistance=n.maxDistance),n.minPolar!==void 0&&(t.minPolarAngle=n.minPolar*s),n.maxPolar!==void 0&&(t.maxPolarAngle=n.maxPolar*s),n.minAzimuth!==void 0&&(t.minAzimuthAngle=n.minAzimuth*s),n.maxAzimuth!==void 0&&(t.maxAzimuthAngle=n.maxAzimuth*s),i.autoRotate&&(t.autoRotate=!0,t.autoRotateSpeed=i.autoRotate/360*60),x=t}let S=new n,C=new n;return{rest:p,shake:y,orbit:x,update(e,o,u){if(a instanceof r){a.userData.restFov=p.fov;let e=R(p.fov,l(a.userData.fitScale,1));a.fov!==e&&(a.fov=e,a.updateProjectionMatrix())}else if(a instanceof t&&l(a.userData.zoomHeight,l(i.zoom,10))!==p.zoom){a.userData.zoomHeight=p.zoom;let e=(a.right-a.left)/Math.max(a.top-a.bottom,1e-6),t=p.zoom/2*l(a.userData.fitScale,1);a.left=-t*e,a.right=t*e,a.top=t,a.bottom=-t,a.updateProjectionMatrix()}if(x){x.update(),a.position.add(y);return}let d=S.copy(p.position),f=g;if(m===`scroll`&&i.scrollPath?.length){let e=i.scrollPath,t=c(u.scroll,0,1)*(e.length-1),r=Math.min(Math.floor(t),e.length-2),a=e.length===1?0:t-Math.max(r,0),o=a*a*(3-2*a),s=e[Math.max(r,0)],l=e[Math.min(Math.max(r,0)+1,e.length-1)];d.set(...s.position).lerp(new n(...l.position),o);let p=new n(...s.target??i.target??[0,0,0]),m=new n(...l.target??i.target??[0,0,0]);f.copy(p.lerp(m,o))}else if(m===`follow`&&u.followTarget){let e=i.follow??{target:``},t=u.followTarget.getWorldPosition(new n),r=new n(...e.offset??[0,4,8]),a=t.clone().add(r),s=t.clone().add(new n(0,0,-l(e.lookAhead,0))),c=b?1:_(l(e.smoothing,.85),o);h.lerp(a,c),f.lerp(s,c),d=S.copy(h)}else f.copy(p.target);if(u.lookAt&&f.copy(u.lookAt),i.autoRotate&&m!==`follow`){let t=i.autoRotate*s*e,r=d.clone().sub(f);r.applyAxisAngle(new n(0,1,0),t),d.copy(f).add(r)}if(m===`parallax`){let e=i.parallax??{},t=l(e.strength,.5),r=_(l(e.smoothing,.92),o);v.x+=(u.pointer.x*t-v.x)*r,v.y+=(u.pointer.y*t*.6-v.y)*r;let s=f.clone().sub(d).normalize(),c=new n().crossVectors(s,a.up).normalize(),p=new n().crossVectors(c,s).normalize();d.addScaledVector(c,v.x).addScaledVector(p,v.y)}if(i.shake){let t=i.shake,r=l(t.speed,.5),o=l(t.amount,.03),c=l(t.rotation,.4)*s,u=l(t.seed,1)*17.31,p=t=>k(e*r+u,t*7.13)*.75+k(e*r*2.7+u,t*7.13+3.1)*.25,m=f.clone().sub(d),h=m.length()||1;m.divideScalar(h);let g=new n().crossVectors(m,a.up).normalize(),_=new n().crossVectors(g,m).normalize();d.addScaledVector(g,p(0)*o).addScaledVector(_,p(1)*o),C.copy(f).addScaledVector(g,Math.tan(p(2)*c)*h).addScaledVector(_,Math.tan(p(3)*c)*h)}else C.copy(f);a.position.copy(d).add(y),B(a.position,C),a.lookAt(C),b=!1},dispose(){x?.dispose()}}}export{g as C,f as S,x as _,N as a,d as b,k as c,s as d,u as f,v as g,y as h,S as i,M as l,p as m,V as n,P as o,c as p,z as r,C as s,I as t,F as u,l as v,h as x,_ as y};
@@ -1,4 +1,4 @@
1
- import{OrbitControls as e}from"./OrbitControls-MlE9XiCg.js";import{Bt as t,En as n,Ft as r,Ht as i,I as a,In as o,It as s,Kt as c,Ln as l,N as u,Pt as d,Qt as f,Rt as p,St as m,T as h,an as g,at as _,bt as v,d as y,f as b,h as x,hn as ee,it as te,m as S,mn as C,nt as w,on as T,p as E,st as D,vt as O,w as ne,x as k,xt as A,yn as re,zt as ie}from"./three.module-CnI50X0U.js";import{r as ae}from"./camera-DT0xHipx.js";import{a as j,i as M,n as N,o as oe}from"./index-DVTzVcBD.js";var P=new f,F=new l,I=new l,L=new c,se={X:new l(1,0,0),Y:new l(0,1,0),Z:new l(0,0,1)},R={type:`change`},z={type:`mouseDown`,mode:null},ce={type:`mouseUp`,mode:null},le={type:`objectChange`},ue=class extends ne{constructor(e,t=null){super(void 0,t);let n=new ve(this);this._root=n;let r=new ye;this._gizmo=r,n.add(r);let i=new be;this._plane=i,n.add(i);let a=this;function o(e,t){let n=t;Object.defineProperty(a,e,{get:function(){return n===void 0?t:n},set:function(t){n!==t&&(n=t,i[e]=t,r[e]=t,a.dispatchEvent({type:e+`-changed`,value:t}),a.dispatchEvent(R))}}),a[e]=t,i[e]=t,r[e]=t}o(`camera`,e),o(`object`,void 0),o(`enabled`,!0),o(`axis`,null),o(`mode`,`translate`),o(`translationSnap`,null),o(`rotationSnap`,null),o(`scaleSnap`,null),o(`space`,`world`),o(`size`,1),this.viewport=null,o(`dragging`,!1),o(`showX`,!0),o(`showY`,!0),o(`showZ`,!0),o(`showXY`,!0),o(`showYZ`,!0),o(`showXZ`,!0),o(`showXYZE`,!0),o(`showE`,!0),o(`minX`,-1/0),o(`maxX`,1/0),o(`minY`,-1/0),o(`maxY`,1/0),o(`minZ`,-1/0),o(`maxZ`,1/0);let s=new l,u=new l,d=new c,f=new c,p=new l,m=new c,h=new l,g=new l,_=new l,v=new l;o(`worldPosition`,s),o(`worldPositionStart`,u),o(`worldQuaternion`,d),o(`worldQuaternionStart`,f),o(`cameraPosition`,p),o(`cameraQuaternion`,m),o(`pointStart`,h),o(`pointEnd`,g),o(`rotationAxis`,_),o(`rotationAngle`,0),o(`eye`,v),this._offset=new l,this._startNorm=new l,this._endNorm=new l,this._cameraScale=new l,this._parentPosition=new l,this._parentQuaternion=new c,this._parentQuaternionInv=new c,this._parentScale=new l,this._worldScaleStart=new l,this._worldQuaternionInv=new c,this._worldScale=new l,this._positionStart=new l,this._quaternionStart=new c,this._scaleStart=new l,this._getPointer=de.bind(this),this._onPointerDown=pe.bind(this),this._onPointerHover=fe.bind(this),this._onPointerMove=me.bind(this),this._onPointerUp=he.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointermove`,this._onPointerHover),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerHover),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=``}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&P.setFromCamera(e,this.camera);let t=B(this._gizmo.picker[this.mode],P);this.axis=t?t.object.name:null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&P.setFromCamera(e,this.camera);let t=B(this._plane,P,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,z.mode=this.mode,this.dispatchEvent(z)}}pointerMove(e){let t=this.axis,n=this.mode,r=this.object,i=this.space;if(n===`scale`?i=`local`:(t===`E`||t===`XYZE`||t===`XYZ`)&&(i=`world`),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&P.setFromCamera(e,this.camera);let a=B(this._plane,P,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n===`translate`)this._offset.copy(this.pointEnd).sub(this.pointStart),i===`local`&&t!==`XYZ`&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf(`X`)===-1&&(this._offset.x=0),t.indexOf(`Y`)===-1&&(this._offset.y=0),t.indexOf(`Z`)===-1&&(this._offset.z=0),i===`local`&&t!==`XYZ`?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i===`local`&&(r.position.applyQuaternion(L.copy(this._quaternionStart).invert()),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i===`world`&&(r.getWorldPosition(F),t.search(`X`)!==-1&&(F.x=Math.round(F.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(F.y=Math.round(F.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(F.z=Math.round(F.z/this.translationSnap)*this.translationSnap),r.position.copy(r.parent.worldToLocal(F)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(n===`scale`){if(t.search(`XYZ`)!==-1){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),I.set(e,e,e)}else F.copy(this.pointStart),I.copy(this.pointEnd),F.applyQuaternion(this._worldQuaternionInv),I.applyQuaternion(this._worldQuaternionInv),I.divide(F),t.search(`X`)===-1&&(I.x=1),t.search(`Y`)===-1&&(I.y=1),t.search(`Z`)===-1&&(I.z=1);r.scale.copy(this._scaleStart).multiply(I),this.scaleSnap&&(t.search(`X`)!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Y`)!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Z`)!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n===`rotate`){this._offset.copy(this.pointEnd).sub(this.pointStart);let e=20/this.worldPosition.distanceTo(F.setFromMatrixPosition(this.camera.matrixWorld)),n=!1;t===`XYZE`?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(F.copy(this.rotationAxis).cross(this.eye))*e):(t===`X`||t===`Y`||t===`Z`)&&(this.rotationAxis.copy(se[t]),F.copy(se[t]),i===`local`&&F.applyQuaternion(this.worldQuaternion),F.cross(this.eye),F.length()===0?n=!0:this.rotationAngle=this._offset.dot(F.normalize())*e),(t===`E`||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i===`local`&&t!==`E`&&t!==`XYZE`?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(L.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(L.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(R),this.dispatchEvent(le)}}pointerUp(e){(e===null||e.button===0)&&(this.dragging&&this.axis!==null&&(ce.mode=this.mode,this.dispatchEvent(ce)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(R),this.dispatchEvent(le),this.pointStart.copy(this.pointEnd))}getRaycaster(){return P}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,r){let i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(n),i.active.color.set(r),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(n),i.activeTransparent.color.set(r),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(n),i.active._color&&i.active._color.set(r),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(n),i.activeTransparent._color&&i.activeTransparent._color.set(r)}};function de(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{let t=this.domElement.getBoundingClientRect(),n=this.viewport,r,i,a,o;return n===null?(r=0,i=0,a=t.width,o=t.height):(r=n.x,i=t.height-n.y-n.w,a=n.z,o=n.w),{x:(e.clientX-t.left-r)/a*2-1,y:-(e.clientY-t.top-i)/o*2+1,button:e.button}}}function fe(e){if(this.enabled)switch(e.pointerType){case`mouse`:case`pen`:this.pointerHover(this._getPointer(e))}}function pe(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function me(e){this.enabled&&this.pointerMove(this._getPointer(e))}function he(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.pointerUp(this._getPointer(e)))}function B(e,t,n){let r=t.intersectObject(e,!0);for(let e=0;e<r.length;e++)if(r[e].object.visible||n)return r[e];return!1}var V=new u,H=new l(0,1,0),ge=new l(0,0,0),_e=new v,U=new c,W=new c,G=new l,K=new v,q=new l(1,0,0),J=new l(0,1,0),Y=new l(0,0,1),X=new l,Z=new l,Q=new l,ve=class extends d{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){let t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error(`TransformControls: The attached 3D object must be a part of the scene graph.`):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),this.parent&&(K.copy(this.parent.matrixWorld).invert(),K.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}},ye=class extends d{constructor(){super(),this.isTransformControlsGizmo=!0,this.type=`TransformControlsGizmo`;let e=new m({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new te({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;let o=t.clone();o.opacity=.5;let s=e.clone();s.color.setHex(16711680);let c=e.clone();c.color.setHex(65280);let l=e.clone();l.color.setHex(255);let u=e.clone();u.color.setHex(16711680),u.opacity=.5;let f=e.clone();f.color.setHex(65280),f.opacity=.5;let p=e.clone();p.color.setHex(255),p.opacity=.5;let g=e.clone();g.opacity=.25;let _=e.clone();_.color.setHex(16776960),_.opacity=.25;let v=e.clone();v.color.setHex(16776960);let y=e.clone();y.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:c,zAxis:l,active:v,xAxisTransparent:u,yAxisTransparent:f,zAxisTransparent:p,activeTransparent:_};let b=new h(0,.04,.1,12);b.translate(0,.05,0);let S=new E(.08,.08,.08);S.translate(0,.04,0);let C=new x;C.setAttribute(`position`,new a([0,0,0,1,0,0],3));let T=new h(.0075,.0075,.5,3);T.translate(0,.25,0);function D(e,t){let r=new n(e,.0075,3,64,t*Math.PI*2);return r.rotateY(Math.PI/2),r.rotateX(Math.PI/2),r}function O(){let e=new x;return e.setAttribute(`position`,new a([0,0,0,1,1,1],3)),e}let ne={X:[[new A(b,s),[.5,0,0],[0,0,-Math.PI/2]],[new A(b,s),[-.5,0,0],[0,0,Math.PI/2]],[new A(T,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new A(b,c),[0,.5,0]],[new A(b,c),[0,-.5,0],[Math.PI,0,0]],[new A(T,c)]],Z:[[new A(b,l),[0,0,.5],[Math.PI/2,0,0]],[new A(b,l),[0,0,-.5],[-Math.PI/2,0,0]],[new A(T,l),null,[Math.PI/2,0,0]]],XYZ:[[new A(new r(.1,0),g),[0,0,0]]],XY:[[new A(new E(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new A(new E(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.15,.15,.01),f),[.15,0,.15],[-Math.PI/2,0,0]]]},k={X:[[new A(new h(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new A(new h(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new A(new h(.2,0,.6,4),i),[0,.3,0]],[new A(new h(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new A(new h(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new A(new h(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new A(new r(.2,0),i)]],XY:[[new A(new E(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new A(new E(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},re={START:[[new A(new r(.01,2),o),null,null,null,`helper`]],END:[[new A(new r(.01,2),o),null,null,null,`helper`]],DELTA:[[new w(O(),o),null,null,null,`helper`]],X:[[new w(C,o),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new w(C,o),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new w(C,o),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},ie={XYZE:[[new A(D(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new A(D(.5,.5),s)]],Y:[[new A(D(.5,.5),c),null,[0,0,-Math.PI/2]]],Z:[[new A(D(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new A(D(.75,1),_),null,[0,Math.PI/2,0]]]},ae={AXIS:[[new w(C,o),[-1e3,0,0],null,[1e6,1,1],`helper`]]},j={XYZE:[[new A(new ee(.25,10,8),i)]],X:[[new A(new n(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new A(new n(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new A(new n(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new A(new n(.75,.1,2,24),i)]]},M={X:[[new A(S,s),[.5,0,0],[0,0,-Math.PI/2]],[new A(T,s),[0,0,0],[0,0,-Math.PI/2]],[new A(S,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new A(S,c),[0,.5,0]],[new A(T,c)],[new A(S,c),[0,-.5,0],[0,0,Math.PI]]],Z:[[new A(S,l),[0,0,.5],[Math.PI/2,0,0]],[new A(T,l),[0,0,0],[Math.PI/2,0,0]],[new A(S,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new A(new E(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new A(new E(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.15,.15,.01),f),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new A(new E(.1,.1,.1),g)]]},N={X:[[new A(new h(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new A(new h(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new A(new h(.2,0,.6,4),i),[0,.3,0]],[new A(new h(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new A(new h(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new A(new h(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new A(new E(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new A(new E(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new A(new E(.2,.2,.2),i),[0,0,0]]]},oe={X:[[new w(C,o),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new w(C,o),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new w(C,o),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]};function P(e){let t=new d;for(let n in e)for(let r=e[n].length;r--;){let i=e[n][r][0].clone(),a=e[n][r][1],o=e[n][r][2],s=e[n][r][3],c=e[n][r][4];i.name=n,i.tag=c,a&&i.position.set(a[0],a[1],a[2]),o&&i.rotation.set(o[0],o[1],o[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix();let l=i.geometry.clone();l.applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),t.add(i)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=P(ne)),this.add(this.gizmo.rotate=P(ie)),this.add(this.gizmo.scale=P(M)),this.add(this.picker.translate=P(k)),this.add(this.picker.rotate=P(j)),this.add(this.picker.scale=P(N)),this.add(this.helper.translate=P(re)),this.add(this.helper.rotate=P(ae)),this.add(this.helper.scale=P(oe)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){let t=(this.mode===`scale`?`local`:this.space)===`local`?this.worldQuaternion:W;this.gizmo.translate.visible=this.mode===`translate`,this.gizmo.rotate.visible=this.mode===`rotate`,this.gizmo.scale.visible=this.mode===`scale`,this.helper.translate.visible=this.mode===`translate`,this.helper.rotate.visible=this.mode===`rotate`,this.helper.scale.visible=this.mode===`scale`;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e<n.length;e++){let r=n[e];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let i;if(i=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(i*this.size/4),r.tag===`helper`)r.visible=!1,r.name===`AXIS`?(r.visible=!!this.axis,this.axis===`X`&&(L.setFromEuler(V.set(0,0,0)),r.quaternion.copy(t).multiply(L),Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Y`&&(L.setFromEuler(V.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(L),Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Z`&&(L.setFromEuler(V.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(L),Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`XYZE`&&(L.setFromEuler(V.set(0,Math.PI/2,0)),H.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(_e.lookAt(ge,H,J)),r.quaternion.multiply(L),r.visible=this.dragging),this.axis===`E`&&(r.visible=!1)):r.name===`START`?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name===`END`?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name===`DELTA`?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),F.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),F.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(F),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));else{if(r.quaternion.copy(t),this.mode===`translate`||this.mode===`scale`){let e=.99,n=.2;r.name===`X`&&Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Y`&&Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Z`&&Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XY`&&Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`YZ`&&Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XZ`&&Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)}else this.mode===`rotate`&&(U.copy(t),H.copy(this.eye).applyQuaternion(L.copy(t).invert()),r.name.search(`E`)!==-1&&r.quaternion.setFromRotationMatrix(_e.lookAt(this.eye,ge,J)),r.name===`X`&&(L.setFromAxisAngle(q,Math.atan2(-H.y,H.z)),L.multiplyQuaternions(U,L),r.quaternion.copy(L)),r.name===`Y`&&(L.setFromAxisAngle(J,Math.atan2(H.x,H.z)),L.multiplyQuaternions(U,L),r.quaternion.copy(L)),r.name===`Z`&&(L.setFromAxisAngle(Y,Math.atan2(H.y,H.x)),L.multiplyQuaternions(U,L),r.quaternion.copy(L)));r.visible=r.visible&&(r.name.indexOf(`X`)===-1||this.showX),r.visible=r.visible&&(r.name.indexOf(`Y`)===-1||this.showY),r.visible=r.visible&&(r.name.indexOf(`Z`)===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf(`E`)===-1||this.showX&&this.showY&&this.showZ),r.visible=r.visible&&(r.name.indexOf(`XY`)===-1||this.showXY),r.visible=r.visible&&(r.name.indexOf(`YZ`)===-1||this.showYZ),r.visible=r.visible&&(r.name.indexOf(`XZ`)===-1||this.showXZ),r.visible=r.visible&&(r.name!==`E`||this.showE),r.visible=r.visible&&(r.name!==`XYZE`||this.showXYZE),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split(``).some(function(e){return r.name===e}))&&(r.material.color.copy(this.materialLib.active.color),r.material.opacity=1)}}super.updateMatrixWorld(e)}},be=class extends A{constructor(){super(new t(1e5,1e5,2,2),new m({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type=`TransformControlsPlane`}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode===`scale`&&(t=`local`),X.copy(q).applyQuaternion(t===`local`?this.worldQuaternion:W),Z.copy(J).applyQuaternion(t===`local`?this.worldQuaternion:W),Q.copy(Y).applyQuaternion(t===`local`?this.worldQuaternion:W),H.copy(Z),this.mode){case`translate`:case`scale`:switch(this.axis){case`X`:H.copy(this.eye).cross(X),G.copy(X).cross(H);break;case`Y`:H.copy(this.eye).cross(Z),G.copy(Z).cross(H);break;case`Z`:H.copy(this.eye).cross(Q),G.copy(Q).cross(H);break;case`XY`:G.copy(Q);break;case`YZ`:G.copy(X);break;case`XZ`:H.copy(Q),G.copy(Z);break;case`XYZ`:case`E`:G.set(0,0,0)}break;default:G.set(0,0,0)}G.length()===0?this.quaternion.copy(this.cameraQuaternion):(K.lookAt(F.set(0,0,0),G,H),this.quaternion.setFromRotationMatrix(K)),super.updateMatrixWorld(e)}},xe=`
1
+ import{OrbitControls as e}from"./OrbitControls-MlE9XiCg.js";import{Bt as t,En as n,Ft as r,Ht as i,I as a,In as o,It as s,Kt as c,Ln as l,N as u,Pt as d,Qt as f,Rt as p,St as m,T as h,an as g,at as _,bt as v,d as y,f as b,h as x,hn as ee,it as te,m as S,mn as C,nt as w,on as T,p as E,st as D,vt as O,w as ne,x as k,xt as A,yn as re,zt as ie}from"./three.module-CnI50X0U.js";import{r as ae}from"./camera-BgzPVnn-.js";import{a as j,i as M,n as N,o as oe}from"./index-L-N-e2KM.js";var P=new f,F=new l,I=new l,L=new c,se={X:new l(1,0,0),Y:new l(0,1,0),Z:new l(0,0,1)},R={type:`change`},z={type:`mouseDown`,mode:null},ce={type:`mouseUp`,mode:null},le={type:`objectChange`},ue=class extends ne{constructor(e,t=null){super(void 0,t);let n=new ve(this);this._root=n;let r=new ye;this._gizmo=r,n.add(r);let i=new be;this._plane=i,n.add(i);let a=this;function o(e,t){let n=t;Object.defineProperty(a,e,{get:function(){return n===void 0?t:n},set:function(t){n!==t&&(n=t,i[e]=t,r[e]=t,a.dispatchEvent({type:e+`-changed`,value:t}),a.dispatchEvent(R))}}),a[e]=t,i[e]=t,r[e]=t}o(`camera`,e),o(`object`,void 0),o(`enabled`,!0),o(`axis`,null),o(`mode`,`translate`),o(`translationSnap`,null),o(`rotationSnap`,null),o(`scaleSnap`,null),o(`space`,`world`),o(`size`,1),this.viewport=null,o(`dragging`,!1),o(`showX`,!0),o(`showY`,!0),o(`showZ`,!0),o(`showXY`,!0),o(`showYZ`,!0),o(`showXZ`,!0),o(`showXYZE`,!0),o(`showE`,!0),o(`minX`,-1/0),o(`maxX`,1/0),o(`minY`,-1/0),o(`maxY`,1/0),o(`minZ`,-1/0),o(`maxZ`,1/0);let s=new l,u=new l,d=new c,f=new c,p=new l,m=new c,h=new l,g=new l,_=new l,v=new l;o(`worldPosition`,s),o(`worldPositionStart`,u),o(`worldQuaternion`,d),o(`worldQuaternionStart`,f),o(`cameraPosition`,p),o(`cameraQuaternion`,m),o(`pointStart`,h),o(`pointEnd`,g),o(`rotationAxis`,_),o(`rotationAngle`,0),o(`eye`,v),this._offset=new l,this._startNorm=new l,this._endNorm=new l,this._cameraScale=new l,this._parentPosition=new l,this._parentQuaternion=new c,this._parentQuaternionInv=new c,this._parentScale=new l,this._worldScaleStart=new l,this._worldQuaternionInv=new c,this._worldScale=new l,this._positionStart=new l,this._quaternionStart=new c,this._scaleStart=new l,this._getPointer=de.bind(this),this._onPointerDown=pe.bind(this),this._onPointerHover=fe.bind(this),this._onPointerMove=me.bind(this),this._onPointerUp=he.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointermove`,this._onPointerHover),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerHover),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=``}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&P.setFromCamera(e,this.camera);let t=B(this._gizmo.picker[this.mode],P);this.axis=t?t.object.name:null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&P.setFromCamera(e,this.camera);let t=B(this._plane,P,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,z.mode=this.mode,this.dispatchEvent(z)}}pointerMove(e){let t=this.axis,n=this.mode,r=this.object,i=this.space;if(n===`scale`?i=`local`:(t===`E`||t===`XYZE`||t===`XYZ`)&&(i=`world`),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&P.setFromCamera(e,this.camera);let a=B(this._plane,P,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n===`translate`)this._offset.copy(this.pointEnd).sub(this.pointStart),i===`local`&&t!==`XYZ`&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf(`X`)===-1&&(this._offset.x=0),t.indexOf(`Y`)===-1&&(this._offset.y=0),t.indexOf(`Z`)===-1&&(this._offset.z=0),i===`local`&&t!==`XYZ`?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i===`local`&&(r.position.applyQuaternion(L.copy(this._quaternionStart).invert()),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i===`world`&&(r.getWorldPosition(F),t.search(`X`)!==-1&&(F.x=Math.round(F.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(F.y=Math.round(F.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(F.z=Math.round(F.z/this.translationSnap)*this.translationSnap),r.position.copy(r.parent.worldToLocal(F)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(n===`scale`){if(t.search(`XYZ`)!==-1){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),I.set(e,e,e)}else F.copy(this.pointStart),I.copy(this.pointEnd),F.applyQuaternion(this._worldQuaternionInv),I.applyQuaternion(this._worldQuaternionInv),I.divide(F),t.search(`X`)===-1&&(I.x=1),t.search(`Y`)===-1&&(I.y=1),t.search(`Z`)===-1&&(I.z=1);r.scale.copy(this._scaleStart).multiply(I),this.scaleSnap&&(t.search(`X`)!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Y`)!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Z`)!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n===`rotate`){this._offset.copy(this.pointEnd).sub(this.pointStart);let e=20/this.worldPosition.distanceTo(F.setFromMatrixPosition(this.camera.matrixWorld)),n=!1;t===`XYZE`?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(F.copy(this.rotationAxis).cross(this.eye))*e):(t===`X`||t===`Y`||t===`Z`)&&(this.rotationAxis.copy(se[t]),F.copy(se[t]),i===`local`&&F.applyQuaternion(this.worldQuaternion),F.cross(this.eye),F.length()===0?n=!0:this.rotationAngle=this._offset.dot(F.normalize())*e),(t===`E`||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i===`local`&&t!==`E`&&t!==`XYZE`?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(L.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(L.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(R),this.dispatchEvent(le)}}pointerUp(e){(e===null||e.button===0)&&(this.dragging&&this.axis!==null&&(ce.mode=this.mode,this.dispatchEvent(ce)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(R),this.dispatchEvent(le),this.pointStart.copy(this.pointEnd))}getRaycaster(){return P}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,r){let i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(n),i.active.color.set(r),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(n),i.activeTransparent.color.set(r),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(n),i.active._color&&i.active._color.set(r),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(n),i.activeTransparent._color&&i.activeTransparent._color.set(r)}};function de(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{let t=this.domElement.getBoundingClientRect(),n=this.viewport,r,i,a,o;return n===null?(r=0,i=0,a=t.width,o=t.height):(r=n.x,i=t.height-n.y-n.w,a=n.z,o=n.w),{x:(e.clientX-t.left-r)/a*2-1,y:-(e.clientY-t.top-i)/o*2+1,button:e.button}}}function fe(e){if(this.enabled)switch(e.pointerType){case`mouse`:case`pen`:this.pointerHover(this._getPointer(e))}}function pe(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function me(e){this.enabled&&this.pointerMove(this._getPointer(e))}function he(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.pointerUp(this._getPointer(e)))}function B(e,t,n){let r=t.intersectObject(e,!0);for(let e=0;e<r.length;e++)if(r[e].object.visible||n)return r[e];return!1}var V=new u,H=new l(0,1,0),ge=new l(0,0,0),_e=new v,U=new c,W=new c,G=new l,K=new v,q=new l(1,0,0),J=new l(0,1,0),Y=new l(0,0,1),X=new l,Z=new l,Q=new l,ve=class extends d{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){let t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error(`TransformControls: The attached 3D object must be a part of the scene graph.`):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),this.parent&&(K.copy(this.parent.matrixWorld).invert(),K.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}},ye=class extends d{constructor(){super(),this.isTransformControlsGizmo=!0,this.type=`TransformControlsGizmo`;let e=new m({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new te({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;let o=t.clone();o.opacity=.5;let s=e.clone();s.color.setHex(16711680);let c=e.clone();c.color.setHex(65280);let l=e.clone();l.color.setHex(255);let u=e.clone();u.color.setHex(16711680),u.opacity=.5;let f=e.clone();f.color.setHex(65280),f.opacity=.5;let p=e.clone();p.color.setHex(255),p.opacity=.5;let g=e.clone();g.opacity=.25;let _=e.clone();_.color.setHex(16776960),_.opacity=.25;let v=e.clone();v.color.setHex(16776960);let y=e.clone();y.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:c,zAxis:l,active:v,xAxisTransparent:u,yAxisTransparent:f,zAxisTransparent:p,activeTransparent:_};let b=new h(0,.04,.1,12);b.translate(0,.05,0);let S=new E(.08,.08,.08);S.translate(0,.04,0);let C=new x;C.setAttribute(`position`,new a([0,0,0,1,0,0],3));let T=new h(.0075,.0075,.5,3);T.translate(0,.25,0);function D(e,t){let r=new n(e,.0075,3,64,t*Math.PI*2);return r.rotateY(Math.PI/2),r.rotateX(Math.PI/2),r}function O(){let e=new x;return e.setAttribute(`position`,new a([0,0,0,1,1,1],3)),e}let ne={X:[[new A(b,s),[.5,0,0],[0,0,-Math.PI/2]],[new A(b,s),[-.5,0,0],[0,0,Math.PI/2]],[new A(T,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new A(b,c),[0,.5,0]],[new A(b,c),[0,-.5,0],[Math.PI,0,0]],[new A(T,c)]],Z:[[new A(b,l),[0,0,.5],[Math.PI/2,0,0]],[new A(b,l),[0,0,-.5],[-Math.PI/2,0,0]],[new A(T,l),null,[Math.PI/2,0,0]]],XYZ:[[new A(new r(.1,0),g),[0,0,0]]],XY:[[new A(new E(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new A(new E(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.15,.15,.01),f),[.15,0,.15],[-Math.PI/2,0,0]]]},k={X:[[new A(new h(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new A(new h(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new A(new h(.2,0,.6,4),i),[0,.3,0]],[new A(new h(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new A(new h(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new A(new h(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new A(new r(.2,0),i)]],XY:[[new A(new E(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new A(new E(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},re={START:[[new A(new r(.01,2),o),null,null,null,`helper`]],END:[[new A(new r(.01,2),o),null,null,null,`helper`]],DELTA:[[new w(O(),o),null,null,null,`helper`]],X:[[new w(C,o),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new w(C,o),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new w(C,o),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},ie={XYZE:[[new A(D(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new A(D(.5,.5),s)]],Y:[[new A(D(.5,.5),c),null,[0,0,-Math.PI/2]]],Z:[[new A(D(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new A(D(.75,1),_),null,[0,Math.PI/2,0]]]},ae={AXIS:[[new w(C,o),[-1e3,0,0],null,[1e6,1,1],`helper`]]},j={XYZE:[[new A(new ee(.25,10,8),i)]],X:[[new A(new n(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new A(new n(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new A(new n(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new A(new n(.75,.1,2,24),i)]]},M={X:[[new A(S,s),[.5,0,0],[0,0,-Math.PI/2]],[new A(T,s),[0,0,0],[0,0,-Math.PI/2]],[new A(S,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new A(S,c),[0,.5,0]],[new A(T,c)],[new A(S,c),[0,-.5,0],[0,0,Math.PI]]],Z:[[new A(S,l),[0,0,.5],[Math.PI/2,0,0]],[new A(T,l),[0,0,0],[Math.PI/2,0,0]],[new A(S,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new A(new E(.15,.15,.01),p),[.15,.15,0]]],YZ:[[new A(new E(.15,.15,.01),u),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.15,.15,.01),f),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new A(new E(.1,.1,.1),g)]]},N={X:[[new A(new h(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new A(new h(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new A(new h(.2,0,.6,4),i),[0,.3,0]],[new A(new h(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new A(new h(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new A(new h(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new A(new E(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new A(new E(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new A(new E(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new A(new E(.2,.2,.2),i),[0,0,0]]]},oe={X:[[new w(C,o),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new w(C,o),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new w(C,o),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]};function P(e){let t=new d;for(let n in e)for(let r=e[n].length;r--;){let i=e[n][r][0].clone(),a=e[n][r][1],o=e[n][r][2],s=e[n][r][3],c=e[n][r][4];i.name=n,i.tag=c,a&&i.position.set(a[0],a[1],a[2]),o&&i.rotation.set(o[0],o[1],o[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix();let l=i.geometry.clone();l.applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),t.add(i)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=P(ne)),this.add(this.gizmo.rotate=P(ie)),this.add(this.gizmo.scale=P(M)),this.add(this.picker.translate=P(k)),this.add(this.picker.rotate=P(j)),this.add(this.picker.scale=P(N)),this.add(this.helper.translate=P(re)),this.add(this.helper.rotate=P(ae)),this.add(this.helper.scale=P(oe)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){let t=(this.mode===`scale`?`local`:this.space)===`local`?this.worldQuaternion:W;this.gizmo.translate.visible=this.mode===`translate`,this.gizmo.rotate.visible=this.mode===`rotate`,this.gizmo.scale.visible=this.mode===`scale`,this.helper.translate.visible=this.mode===`translate`,this.helper.rotate.visible=this.mode===`rotate`,this.helper.scale.visible=this.mode===`scale`;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e<n.length;e++){let r=n[e];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let i;if(i=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(i*this.size/4),r.tag===`helper`)r.visible=!1,r.name===`AXIS`?(r.visible=!!this.axis,this.axis===`X`&&(L.setFromEuler(V.set(0,0,0)),r.quaternion.copy(t).multiply(L),Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Y`&&(L.setFromEuler(V.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(L),Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Z`&&(L.setFromEuler(V.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(L),Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`XYZE`&&(L.setFromEuler(V.set(0,Math.PI/2,0)),H.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(_e.lookAt(ge,H,J)),r.quaternion.multiply(L),r.visible=this.dragging),this.axis===`E`&&(r.visible=!1)):r.name===`START`?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name===`END`?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name===`DELTA`?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),F.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),F.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(F),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));else{if(r.quaternion.copy(t),this.mode===`translate`||this.mode===`scale`){let e=.99,n=.2;r.name===`X`&&Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Y`&&Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Z`&&Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XY`&&Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`YZ`&&Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XZ`&&Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)}else this.mode===`rotate`&&(U.copy(t),H.copy(this.eye).applyQuaternion(L.copy(t).invert()),r.name.search(`E`)!==-1&&r.quaternion.setFromRotationMatrix(_e.lookAt(this.eye,ge,J)),r.name===`X`&&(L.setFromAxisAngle(q,Math.atan2(-H.y,H.z)),L.multiplyQuaternions(U,L),r.quaternion.copy(L)),r.name===`Y`&&(L.setFromAxisAngle(J,Math.atan2(H.x,H.z)),L.multiplyQuaternions(U,L),r.quaternion.copy(L)),r.name===`Z`&&(L.setFromAxisAngle(Y,Math.atan2(H.y,H.x)),L.multiplyQuaternions(U,L),r.quaternion.copy(L)));r.visible=r.visible&&(r.name.indexOf(`X`)===-1||this.showX),r.visible=r.visible&&(r.name.indexOf(`Y`)===-1||this.showY),r.visible=r.visible&&(r.name.indexOf(`Z`)===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf(`E`)===-1||this.showX&&this.showY&&this.showZ),r.visible=r.visible&&(r.name.indexOf(`XY`)===-1||this.showXY),r.visible=r.visible&&(r.name.indexOf(`YZ`)===-1||this.showYZ),r.visible=r.visible&&(r.name.indexOf(`XZ`)===-1||this.showXZ),r.visible=r.visible&&(r.name!==`E`||this.showE),r.visible=r.visible&&(r.name!==`XYZE`||this.showXYZE),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split(``).some(function(e){return r.name===e}))&&(r.material.color.copy(this.materialLib.active.color),r.material.opacity=1)}}super.updateMatrixWorld(e)}},be=class extends A{constructor(){super(new t(1e5,1e5,2,2),new m({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type=`TransformControlsPlane`}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode===`scale`&&(t=`local`),X.copy(q).applyQuaternion(t===`local`?this.worldQuaternion:W),Z.copy(J).applyQuaternion(t===`local`?this.worldQuaternion:W),Q.copy(Y).applyQuaternion(t===`local`?this.worldQuaternion:W),H.copy(Z),this.mode){case`translate`:case`scale`:switch(this.axis){case`X`:H.copy(this.eye).cross(X),G.copy(X).cross(H);break;case`Y`:H.copy(this.eye).cross(Z),G.copy(Z).cross(H);break;case`Z`:H.copy(this.eye).cross(Q),G.copy(Q).cross(H);break;case`XY`:G.copy(Q);break;case`YZ`:G.copy(X);break;case`XZ`:H.copy(Q),G.copy(Z);break;case`XYZ`:case`E`:G.set(0,0,0)}break;default:G.set(0,0,0)}G.length()===0?this.quaternion.copy(this.cameraQuaternion):(K.lookAt(F.set(0,0,0),G,H),this.quaternion.setFromRotationMatrix(K)),super.updateMatrixWorld(e)}},xe=`
2
2
  varying vec3 vWorld;
3
3
  void main() {
4
4
  vec4 w = modelMatrix * vec4(position, 1.0);
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./physicsHost-DNdZ7AsT.js","./camera-DT0xHipx.js","./three.module-CnI50X0U.js","./index-DVTzVcBD.js","./index-BQT0otii.css"])))=>i.map(i=>d[i]);
2
- import{In as e,Ln as t,Qt as n,zt as r}from"./three.module-CnI50X0U.js";import{_ as i,d as a,i as o,x as s}from"./camera-DT0xHipx.js";import{S as c,h as l}from"./index-DVTzVcBD.js";function u(e,t,n){let r=null,i=null,a=!!e?.muted,o=null,s=new Map,c=null,u=!!e?.music,d=()=>l(()=>import(`./audio-JD1kyX0A.js`).then(e=>o=e.SOUND_IMPLS),[],import.meta.url).catch(()=>o={}),f=e=>{let i=s.get(e);if(!i&&r){let a=r;i=fetch(t(e)).then(e=>e.arrayBuffer()).then(e=>a.decodeAudioData(e)).catch(t=>(n(t.message,e),null)),s.set(e,i)}return i??Promise.resolve(null)},p=(e,t=!1)=>{if(!r||!i)return null;let n=e.volume??1;if(e.preset){let t=o?.[e.preset];return t?t.play(r,i,n):null}if(e.src){let a=r,o=i,s=null,c=!1;return f(e.src).then(e=>{if(!e||c)return;s=a.createBufferSource(),s.buffer=e,s.loop=t;let r=a.createGain();r.gain.value=n,s.connect(r).connect(o),s.start()}),{stop(){c=!0;try{s?.stop()}catch{}}}}return null},m=()=>{!c&&e?.music&&!a&&r&&(c=p(e.music,e.music.loop!==!1))};return d(),{play(t){if(a||!r)return;let n=e?.sounds?.[t];n?p(n):o?.[t]&&o[t].play(r,i,1)},music(e){u=e,e?m():(c?.stop(),c=null)},muted:()=>a,setMuted(t){a=t,i&&r&&i.gain.setTargetAtTime(+!t,r.currentTime,.02),t?(c?.stop(),c=null):(u||e?.music)&&(u=!0,m())},unlock(){if(r){r.state===`suspended`&&r.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{r=new e,i=r.createGain(),i.gain.value=+!a,i.connect(r.destination),u&&m()}catch(e){n(e.message)}},dispose(){c?.stop(),r?.close().catch(()=>void 0),r=null}}}function d(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(/[0-9]/.test(r)||r===`-`&&/[0-9]/.test(e[n+1]??``)&&(t.length===0||t[t.length-1].t===`op`)){let r=n+1;for(;r<e.length&&/[0-9.]/.test(e[r]);)r++;t.push({t:`num`,v:Number(e.slice(n,r))}),n=r;continue}if(r===`'`||r===`"`){let i=n+1,a=``;for(;i<e.length&&e[i]!==r;)e[i]===`\\`&&i+1<e.length&&i++,a+=e[i++];if(i>=e.length)throw Error(`Unterminated string`);t.push({t:`str`,v:a}),n=i+1;continue}if(/[A-Za-z_$]/.test(r)){let r=n+1;for(;r<e.length&&/[A-Za-z0-9_$.]/.test(e[r]);)r++;t.push({t:`id`,v:e.slice(n,r)}),n=r;continue}let i=e.slice(n,n+3),a=e.slice(n,n+2);if(i===`===`||i===`!==`)t.push({t:`op`,v:i.slice(0,2)}),n+=3;else if([`==`,`!=`,`>=`,`<=`,`&&`,`||`].includes(a))t.push({t:`op`,v:a}),n+=2;else if(`!<>()`.includes(r))t.push({t:`op`,v:r}),n++;else throw Error(`Unexpected "${r}"`)}return t}var f=new Set([`__proto__`,`prototype`,`constructor`]);function p(e,t){let n=t.split(`.`);n[0]===`state`&&n.shift();let r=e;for(let e of n){if(f.has(e)||typeof r!=`object`||!r||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e]}return r}function m(e,t){let n=d(e),r=0,i=()=>n[r],a=e=>i()?.t===`op`&&i().v===e;function o(){let e=n[r++];if(!e)throw Error(`Unexpected end`);if(e.t===`num`||e.t===`str`)return e.v;if(e.t===`id`)return e.v===`true`?!0:e.v===`false`?!1:e.v===`null`||e.v===`undefined`?null:p(t,e.v);if(e.v===`(`){let e=u();if(!a(`)`))throw Error(`Missing )`);return r++,e}throw Error(`Unexpected "${e.v}"`)}function s(){let e=o(),t=i();if(t?.t===`op`&&[`==`,`!=`,`>`,`<`,`>=`,`<=`].includes(t.v)){r++;let n=o(),i=e,a=n;switch(t.v){case`==`:return e==n||e==null&&n==null;case`!=`:return e!=n;case`>`:return i>a;case`<`:return i<a;case`>=`:return i>=a;default:return i<=a}}return e}function c(){return a(`!`)?(r++,!c()):s()}function l(){let e=c();for(;a(`&&`);){r++;let t=c();e&&=t}return e}function u(){let e=l();for(;a(`||`);){r++;let t=l();e||=t}return e}let f=u();if(r<n.length)throw Error(`Unexpected "${n[r].v}"`);return f}function h(e,t){if(e===void 0)return!0;if(typeof e==`boolean`)return e;try{return!!m(e,t)}catch{return!1}}function g(e,t){return e.replace(/\{([^{}]+)\}/g,(e,n)=>{let r=n.trim(),i;try{i=/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(r)?p(t,r):m(r,t)}catch{i=void 0}return i==null?``:String(typeof i==`number`?Number.isInteger(i)?i:Math.round(i*100)/100:i)})}var _={"top-left":`grid-row:1;grid-column:1;align-items:flex-start;align-self:start;`,top:`grid-row:1;grid-column:2;align-items:center;align-self:start;text-align:center;`,"top-right":`grid-row:1;grid-column:3;align-items:flex-end;align-self:start;text-align:right;`,left:`grid-row:2;grid-column:1;align-items:flex-start;align-self:center;`,center:`grid-row:2;grid-column:2;align-items:center;align-self:center;text-align:center;`,right:`grid-row:2;grid-column:3;align-items:flex-end;align-self:center;text-align:right;`,"bottom-left":`grid-row:3;grid-column:1;align-items:flex-start;align-self:end;`,bottom:`grid-row:3;grid-column:2;align-items:center;align-self:end;text-align:center;`,"bottom-right":`grid-row:3;grid-column:3;align-items:flex-end;align-self:end;text-align:right;`},v=(e,t,n)=>`font-size:${n}px;font-size:clamp(${e}px,min(${t}cqw,${(t*1.6).toFixed(1)}cqh),${n}px)`,y=(e,t,n,r)=>`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./physicsHost-tEUto2-_.js","./camera-BgzPVnn-.js","./three.module-CnI50X0U.js","./index-L-N-e2KM.js","./index-BQT0otii.css"])))=>i.map(i=>d[i]);
2
+ import{In as e,Ln as t,Qt as n,zt as r}from"./three.module-CnI50X0U.js";import{_ as i,d as a,i as o,x as s}from"./camera-BgzPVnn-.js";import{S as c,h as l}from"./index-L-N-e2KM.js";function u(e,t,n){let r=null,i=null,a=!!e?.muted,o=null,s=new Map,c=null,u=!!e?.music,d=()=>l(()=>import(`./audio-JD1kyX0A.js`).then(e=>o=e.SOUND_IMPLS),[],import.meta.url).catch(()=>o={}),f=e=>{let i=s.get(e);if(!i&&r){let a=r;i=fetch(t(e)).then(e=>e.arrayBuffer()).then(e=>a.decodeAudioData(e)).catch(t=>(n(t.message,e),null)),s.set(e,i)}return i??Promise.resolve(null)},p=(e,t=!1)=>{if(!r||!i)return null;let n=e.volume??1;if(e.preset){let t=o?.[e.preset];return t?t.play(r,i,n):null}if(e.src){let a=r,o=i,s=null,c=!1;return f(e.src).then(e=>{if(!e||c)return;s=a.createBufferSource(),s.buffer=e,s.loop=t;let r=a.createGain();r.gain.value=n,s.connect(r).connect(o),s.start()}),{stop(){c=!0;try{s?.stop()}catch{}}}}return null},m=()=>{!c&&e?.music&&!a&&r&&(c=p(e.music,e.music.loop!==!1))};return d(),{play(t){if(a||!r)return;let n=e?.sounds?.[t];n?p(n):o?.[t]&&o[t].play(r,i,1)},music(e){u=e,e?m():(c?.stop(),c=null)},muted:()=>a,setMuted(t){a=t,i&&r&&i.gain.setTargetAtTime(+!t,r.currentTime,.02),t?(c?.stop(),c=null):(u||e?.music)&&(u=!0,m())},unlock(){if(r){r.state===`suspended`&&r.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{r=new e,i=r.createGain(),i.gain.value=+!a,i.connect(r.destination),u&&m()}catch(e){n(e.message)}},dispose(){c?.stop(),r?.close().catch(()=>void 0),r=null}}}function d(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(/[0-9]/.test(r)||r===`-`&&/[0-9]/.test(e[n+1]??``)&&(t.length===0||t[t.length-1].t===`op`)){let r=n+1;for(;r<e.length&&/[0-9.]/.test(e[r]);)r++;t.push({t:`num`,v:Number(e.slice(n,r))}),n=r;continue}if(r===`'`||r===`"`){let i=n+1,a=``;for(;i<e.length&&e[i]!==r;)e[i]===`\\`&&i+1<e.length&&i++,a+=e[i++];if(i>=e.length)throw Error(`Unterminated string`);t.push({t:`str`,v:a}),n=i+1;continue}if(/[A-Za-z_$]/.test(r)){let r=n+1;for(;r<e.length&&/[A-Za-z0-9_$.]/.test(e[r]);)r++;t.push({t:`id`,v:e.slice(n,r)}),n=r;continue}let i=e.slice(n,n+3),a=e.slice(n,n+2);if(i===`===`||i===`!==`)t.push({t:`op`,v:i.slice(0,2)}),n+=3;else if([`==`,`!=`,`>=`,`<=`,`&&`,`||`].includes(a))t.push({t:`op`,v:a}),n+=2;else if(`!<>()`.includes(r))t.push({t:`op`,v:r}),n++;else throw Error(`Unexpected "${r}"`)}return t}var f=new Set([`__proto__`,`prototype`,`constructor`]);function p(e,t){let n=t.split(`.`);n[0]===`state`&&n.shift();let r=e;for(let e of n){if(f.has(e)||typeof r!=`object`||!r||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e]}return r}function m(e,t){let n=d(e),r=0,i=()=>n[r],a=e=>i()?.t===`op`&&i().v===e;function o(){let e=n[r++];if(!e)throw Error(`Unexpected end`);if(e.t===`num`||e.t===`str`)return e.v;if(e.t===`id`)return e.v===`true`?!0:e.v===`false`?!1:e.v===`null`||e.v===`undefined`?null:p(t,e.v);if(e.v===`(`){let e=u();if(!a(`)`))throw Error(`Missing )`);return r++,e}throw Error(`Unexpected "${e.v}"`)}function s(){let e=o(),t=i();if(t?.t===`op`&&[`==`,`!=`,`>`,`<`,`>=`,`<=`].includes(t.v)){r++;let n=o(),i=e,a=n;switch(t.v){case`==`:return e==n||e==null&&n==null;case`!=`:return e!=n;case`>`:return i>a;case`<`:return i<a;case`>=`:return i>=a;default:return i<=a}}return e}function c(){return a(`!`)?(r++,!c()):s()}function l(){let e=c();for(;a(`&&`);){r++;let t=c();e&&=t}return e}function u(){let e=l();for(;a(`||`);){r++;let t=l();e||=t}return e}let f=u();if(r<n.length)throw Error(`Unexpected "${n[r].v}"`);return f}function h(e,t){if(e===void 0)return!0;if(typeof e==`boolean`)return e;try{return!!m(e,t)}catch{return!1}}function g(e,t){return e.replace(/\{([^{}]+)\}/g,(e,n)=>{let r=n.trim(),i;try{i=/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(r)?p(t,r):m(r,t)}catch{i=void 0}return i==null?``:String(typeof i==`number`?Number.isInteger(i)?i:Math.round(i*100)/100:i)})}var _={"top-left":`grid-row:1;grid-column:1;align-items:flex-start;align-self:start;`,top:`grid-row:1;grid-column:2;align-items:center;align-self:start;text-align:center;`,"top-right":`grid-row:1;grid-column:3;align-items:flex-end;align-self:start;text-align:right;`,left:`grid-row:2;grid-column:1;align-items:flex-start;align-self:center;`,center:`grid-row:2;grid-column:2;align-items:center;align-self:center;text-align:center;`,right:`grid-row:2;grid-column:3;align-items:flex-end;align-self:center;text-align:right;`,"bottom-left":`grid-row:3;grid-column:1;align-items:flex-start;align-self:end;`,bottom:`grid-row:3;grid-column:2;align-items:center;align-self:end;text-align:center;`,"bottom-right":`grid-row:3;grid-column:3;align-items:flex-end;align-self:end;text-align:right;`},v=(e,t,n)=>`font-size:${n}px;font-size:clamp(${e}px,min(${t}cqw,${(t*1.6).toFixed(1)}cqh),${n}px)`,y=(e,t,n,r)=>`
3
3
  .a3d-hud{position:absolute;inset:0;pointer-events:none;font-family:${e};color:${t};z-index:2;overflow:hidden;user-select:none;-webkit-user-select:none;container-type:size;display:grid;grid-template-columns:minmax(min-content,1fr) fit-content(56%) minmax(min-content,1fr);grid-template-rows:auto minmax(0,1fr) auto}
4
4
  .a3d-zone{display:flex;flex-direction:column;gap:8px;gap:clamp(4px,1.6cqw,8px);padding:14px;padding:clamp(8px,2.6cqw,14px);min-width:0;max-width:100%;box-sizing:border-box}
5
5
  .a3d-el{line-height:1.2;text-shadow:0 1px 3px rgba(0,0,0,.45);white-space:pre-line;overflow-wrap:break-word}
@@ -16,4 +16,4 @@ import{In as e,Ln as t,Qt as n,zt as r}from"./three.module-CnI50X0U.js";import{_
16
16
  .a3d-toast{position:absolute;left:50%;bottom:18%;transform:translateX(-50%);max-width:86%;box-sizing:border-box;text-align:center;padding:.53em 1.2em;border-radius:999px;background:rgba(0,0,0,.6);color:#fff;font-weight:700;${v(12,3.4,15)};transition:opacity .25s ease;text-shadow:none}
17
17
  .a3d-mute{pointer-events:auto;width:34px;height:34px;width:clamp(28px,8cqw,34px);height:clamp(28px,8cqw,34px);border-radius:50%;border:0;background:rgba(0,0,0,.4);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;flex:none}
18
18
  .a3d-mute svg{width:55%;height:55%}
19
- `,b=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M19 5a10 10 0 0 1 0 14"/></svg>`,x=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="m23 9-6 6"/><path d="m17 9 6 6"/></svg>`;function S(e,t,n){let r=e.ownerDocument,i=r.createElement(`div`);i.className=`a3d-hud`,i.setAttribute(`aria-live`,`polite`);let a=r.createElement(`style`),o=t?.accent??`#ff006e`;a.textContent=y(t?.font??`system-ui,-apple-system,'Segoe UI',Roboto,sans-serif`,t?.color??`#ffffff`,o,t?.buttonText??c(o)),i.appendChild(a);let s=new Map,l=e=>{let t=s.get(e);return t||(t=r.createElement(`div`),t.className=`a3d-zone`,t.style.cssText=_[e]??_[`top-left`],t.dataset.anchor=e,i.appendChild(t),s.set(e,t)),t},u=[[`top-left`,`top`,`top-right`],[`left`,`center`,`right`],[`bottom-left`,`bottom`,`bottom-right`]],d=()=>{for(let[e,t,n]of u){let r=s.get(t);r&&(r.style.gridColumn=s.has(e)||s.has(n)?`2`:`1 / -1`)}},f=new Map;for(let e of t?.elements??[]){let t,i;if(e.type===`button`){let i=r.createElement(`button`);i.type=`button`,i.className=`a3d-btn`,i.addEventListener(`click`,t=>{t.stopPropagation(),e.action&&n(e.action)}),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),t=i}else e.type===`bar`?(t=r.createElement(`div`),t.className=`a3d-bar`,i=r.createElement(`i`),t.appendChild(i)):(t=r.createElement(`div`),t.className=`a3d-el a3d-${e.style??`plain`}`);e.color&&(t.style.color=e.color,e.type===`bar`&&i&&(i.style.background=e.color)),e.background&&(t.style.background=e.background),e.type===`button`&&e.background&&!e.color&&(t.style.color=c(e.background)),t.dataset.id=e.id,l(e.anchor??`top-left`).appendChild(t),f.set(e.id,{def:e,node:t,fill:i,override:{},last:``})}d(),e.appendChild(i);let m=null,v=0,S=null,C=null,w=null;return{root:i,setTimeline(e){w=e},set(e,t){let n=f.get(e);n&&Object.assign(n.override,t)},toast(e,t=2){S={text:e,seconds:t}},update(e,t){let n=w&&!Object.prototype.hasOwnProperty.call(e,`timeline`)?{...e,timeline:w}:e;for(let e of f.values()){let t=e.override.visible??h(e.def.visible,n);if(e.node.style.display=t?``:`none`,!t)continue;if(e.def.type===`bar`){let t=e.override.value??Number(e.def.value?p(n,e.def.value):0),r=Math.max(0,Math.min(1,Number.isFinite(t)?t:0));e.fill.style.width=`${(r*100).toFixed(1)}%`;continue}let r=e.override.text??g(e.def.text??``,n);r!==e.last&&(e.node.textContent=r,e.last=r)}S&&=(m||(m=r.createElement(`div`),m.className=`a3d-toast`,i.appendChild(m)),m.textContent=S.text,m.style.opacity=`1`,v=t+S.seconds,null),m&&t>v&&(m.style.opacity=`0`)},setMuteButton(e,t){e===null?(C?.remove(),C=null):(C||(C=r.createElement(`button`),C.type=`button`,C.className=`a3d-mute`,C.addEventListener(`pointerdown`,e=>e.stopPropagation()),C.addEventListener(`click`,e=>{e.stopPropagation(),t?.()}),l(`bottom-right`).appendChild(C),d()),C.innerHTML=e?x:b,C.setAttribute(`aria-label`,e?`Unmute sound`:`Mute sound`))},dispose(){i.remove()}}}var C=null,w=()=>C??=l(()=>import(`./physicsHost-DNdZ7AsT.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url);function T(e,t=1,n){return{get x(){return e().x/t},set x(r){e().x=r*t,n?.()},get y(){return e().y/t},set y(r){e().y=r*t,n?.()},get z(){return e().z/t},set z(r){e().z=r*t,n?.()},set(r,i,a){e().set(r*t,i*t,a*t),n?.()}}}var E=new Map,D=class c{opts;world;physics=null;state={};hud=null;audio;instances=[];factories=[];objCache=new Map;handlers=new Map;collisionHandlers=[];collisionEndHandlers=[];triggerEnterHandlers=[];triggerExitHandlers=[];rng;simTime=0;acc=0;stepDt;pendingPressed=new Set;pendingJust=!1;pendingSwipe=null;stepPressed=new Set;stepJust=!1;stepSwipe=null;shake={intensity:0,duration:0,until:0};restartRequested=!1;cloneCounter=0;unlockListeners=null;api;constructor(e){this.opts=e,this.stepDt=Math.min(Math.max(e.scene.physics?.step??1/60,1/480),1/10),this.rng=o(e.scene.seed??1),this.audio=u(e.scene.audio,e.resolveAsset,(t,n)=>e.issue({code:`asset-load`,message:t,path:n})),this.api=this.createApi()}static async create(e,t){let n=new c(e);if(n.hud=e.scene.ui?.elements?.length||e.scene.audio?S(e.container,e.scene.ui,e=>n.emit(e)):null,e.scene.audio&&n.hud){let e=()=>n.hud.setMuteButton(n.audio.muted(),()=>{n.audio.unlock(),n.audio.setMuted(!n.audio.muted()),e()});e()}if(!e.deterministic){let t=()=>n.audio.unlock();e.container.addEventListener(`pointerdown`,t),e.container.addEventListener(`keydown`,t),n.unlockListeners=()=>{e.container.removeEventListener(`pointerdown`,t),e.container.removeEventListener(`keydown`,t)}}return await n.loadScripts(),await n.attach(t),n}async loadScripts(){let{scene:e,scriptSources:t,resolveAsset:n,issue:r}=this.opts;for(let i of e.scripts??[]){let e=t?.[i],a=e===void 0?n(i):`src:${i}:${e.length}:${e.slice(0,64)}`,o=E.get(a);o||(o=(async()=>{let t,r=null;e===void 0?t=n(i):(t=URL.createObjectURL(new Blob([e],{type:`text/javascript`})),r=t);try{let e=await import(t);if(typeof e.default!=`function`)throw Error(`the default export must be a function (api) => ({ start, update })`);return e.default}finally{r&&URL.revokeObjectURL(r)}})(),o.catch(()=>E.delete(a)),E.set(a,o));try{let e=await o;e&&this.factories.push({path:i,factory:e})}catch(e){r({code:`script-error`,message:`${i}: ${e.message}`,path:i})}}}async attach(e){this.world=e,this.objCache.clear(),this.physics?.dispose(),this.physics=null,e.scene.updateMatrixWorld(!0),this.needsPhysics(e)&&await this.ensurePhysics(),this.instances=[];for(let{path:e,factory:t}of this.factories)try{this.instances.push({path:e,inst:t(this.api)??{},failed:!1})}catch(t){this.opts.issue({code:`script-error`,message:`${e}: ${t.message}`,path:e})}for(let e of this.instances)try{await e.inst.start?.()}catch(t){e.failed=!0,this.opts.issue({code:`script-error`,message:`${e.path} start(): ${t.message}`,path:e.path})}this.hud?.update(this.state,0)}needsPhysics(e){if(this.opts.scene.physics?.joints?.length)return!0;for(let t of e.entries.values())if(t.kind!==`light`&&(t.def.body||Array.isArray(t.object.userData.bodies)))return!0;return!1}async ensurePhysics(){if(this.physics)return this.physics;let{PhysicsBridge:e}=await w(),t=new e(this.opts.scene.physics,this.world,e=>this.opts.issue(e));return t.engine.onCollision((e,t,n)=>this.dispatchContact(e.id,t.id,n)),t.engine.onCollisionEnd((e,t)=>this.dispatchContact(e.id,t.id,null)),this.physics=t,t.attachAll(),t}dispatchContact(e,t,n){let r=this.api.get(e),i=this.api.get(t);if(!r||!i||!this.physics)return;let a=this.physics.engine.get(e)?.type===`trigger`,o=this.physics.engine.get(t)?.type===`trigger`;if(n){for(let e of this.collisionHandlers)this.safe(()=>e(r,i,n),`onCollision`);for(let e of this.triggerEnterHandlers)a&&this.safe(()=>e(r,i),`onTriggerEnter`),o&&this.safe(()=>e(i,r),`onTriggerEnter`)}else{for(let e of this.collisionEndHandlers)this.safe(()=>e(r,i),`onCollisionEnd`);for(let e of this.triggerExitHandlers)a&&this.safe(()=>e(r,i),`onTriggerExit`),o&&this.safe(()=>e(i,r),`onTriggerExit`)}}async addBodies(e,t){let n=[];e.object.traverse(e=>{let t=e.userData.a3dId;t&&!n.includes(t)&&n.push(t)});let r=n.map(e=>this.world.entries.get(e)).filter(e=>!!e).filter(n=>n===e&&t||n.def.body);if(!r.length)return;let i=await this.ensurePhysics();for(let n of r)i.has(n.id)||i.addEntry(n,n===e?t:void 0)}requestRestart(){this.restartRequested=!0}get pendingRestart(){return this.restartRequested}async restart(){this.restartRequested=!1;for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);for(let e of Object.keys(this.state))delete this.state[e];this.handlers.clear(),this.collisionHandlers=[],this.collisionEndHandlers=[],this.triggerEnterHandlers=[],this.triggerExitHandlers=[],this.rng=o(this.opts.scene.seed??1),this.simTime=0,this.acc=0,this.shake={intensity:0,duration:0,until:0};let e=await this.opts.rebuild();return await this.attach(e),e}time(){return this.simTime}advance(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe),this.acc+=Math.min(e,.25);let n=0;for(;this.acc>=this.stepDt-1e-9&&n<30;)this.fixedStep(),this.acc-=this.stepDt,n++}advanceTo(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);for(t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe);this.simTime+this.stepDt<=e+1e-9;)this.fixedStep()}fixedStep(){this.stepPressed=this.pendingPressed,this.pendingPressed=new Set,this.stepJust=this.pendingJust,this.pendingJust=!1,this.stepSwipe=this.pendingSwipe,this.pendingSwipe=null;let e=this.stepDt;this.simTime+=e;for(let t of this.instances)if(!t.failed&&t.inst.update)try{t.inst.update(e,this.simTime)}catch(e){t.failed=!0,this.opts.issue({code:`script-error`,message:`${t.path} update(): ${e.message}`,path:t.path})}this.physics?.step(e),this.stepPressed=new Set,this.stepJust=!1,this.stepSwipe=null}afterFrame(){let e=this.world.rig,t=this.simTime;if(t<this.shake.until&&this.shake.duration>0){let n=(this.shake.until-t)/this.shake.duration*this.shake.intensity;e.shake.set((this.rng.next()-.5)*2*n,(this.rng.next()-.5)*2*n,(this.rng.next()-.5)*n)}else e.shake.set(0,0,0);this.hud?.update(this.state,t)}emit(e,t){for(let n of this.handlers.get(e)??[])this.safe(()=>n(t),`on(${e})`);for(let n of this.instances)!n.failed&&n.inst.onEvent&&this.safe(()=>n.inst.onEvent(e,t),`onEvent`)}safe(e,t){try{e()}catch(e){this.opts.issue({code:`script-error`,message:`${t}: ${e.message}`})}}dispose(){for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);this.instances=[],this.physics?.dispose(),this.hud?.dispose(),this.audio.dispose(),this.unlockListeners?.()}wrap(e){let n=this.objCache.get(e.id);if(n)return n;let r=this,o=e.id,c=()=>r.world.entries.get(o)??e,l=()=>{let e=c();e.animated&&(e.rest.position.copy(e.object.position),e.rest.quaternion.copy(e.object.quaternion),e.rest.scale.copy(e.object.scale)),r.physics?.moved(o)},u=()=>r.physics?.engine.get(o)?.velocity??[0,0,0],d=(e,t)=>{let n=u();n[e]=t,r.physics?.engine.setVelocity(o,n)},f={id:o,position:T(()=>c().object.position,1,l),rotation:T(()=>c().object.rotation,a,l),scale:T(()=>c().object.scale,1,l),get visible(){return c().object.visible},set visible(e){let t=c();t.object.visible=e,t.rest.visible=e},velocity:{get x(){return u()[0]},set x(e){d(0,e)},get y(){return u()[1]},set y(e){d(1,e)},get z(){return u()[2]},set z(e){d(2,e)},set(e,t,n){r.physics?.engine.setVelocity(o,[e,t,n])}},get userData(){return c().object.userData},get tags(){return c().object.userData.tags??[]},setColor(e){let t=s(e);for(let e of i(c().object))e.color?.copy(t)},setOpacity(e){for(let t of i(c().object))t.opacity=e,e<1&&!t.transparent&&(t.transparent=!0,t.needsUpdate=!0)},playAnimation(e,t){c().animator?.play(e,t)},distanceTo(e){let n=c().object.getWorldPosition(new t),i=r.world.entries.get(e.id);return i?n.distanceTo(i.object.getWorldPosition(new t)):1/0},remove(){r.world.entries.get(o)?.object.traverse(e=>{let t=e.userData.a3dId;t&&r.physics?.remove(t)}),r.physics?.remove(o),r.world.removeEntry(o),r.objCache.delete(o)}};return this.objCache.set(o,f),f}idOf(e){return typeof e==`string`?e:e.id}createApi(){let i=this,o=()=>i.opts.input,s={id:`camera`,position:T(()=>i.world.rig.rest.position),rotation:T(()=>i.world.camera.rotation,a),scale:T(()=>i.world.camera.scale),visible:!0,velocity:T(()=>new t),userData:{},tags:[],setColor(){},setOpacity(){},playAnimation(){},distanceTo(e){let n=i.world.entries.get(e.id);return n?i.world.camera.position.distanceTo(n.object.getWorldPosition(new t)):1/0},remove(){},lookAt(e,t,n){i.world.rig.rest.target.set(e,t,n)},shake(e,t){i.shake={intensity:e,duration:t,until:i.simTime+t}}},c=new n,l={get:e=>{let t=i.world.entries.get(e);return t&&t.kind!==`light`?i.wrap(t):null},findByTag:e=>{let t=[];for(let n of i.world.entries.values())n.kind!==`light`&&(n.object.userData.tags??[]).includes(e)&&t.push(i.wrap(n));return t},spawn:async(e,t)=>{let n=t?i.world.entries.get(t):void 0,r=await i.world.addObject(e,n?.object??i.world.scene,n?.id,new Map);if(!r)throw Error(`spawn(${e.id}) failed`);return i.world.scene.updateMatrixWorld(!0),await i.addBodies(r),i.wrap(r)},clone:(e,t)=>{let n=i.world.entries.get(e);if(!n||n.kind===`light`)throw Error(`clone: unknown object "${e}"`);let r=t?.id;for(;!r||i.world.entries.has(r);)r=`${e}_${++i.cloneCounter}`;let a=n.object.clone(!0);a.traverse(e=>{let t=e;t.isMesh&&t.material&&(t.material=Array.isArray(t.material)?t.material.map(e=>e.clone()):t.material.clone()),e.userData.a3dId&&(e.userData={...e.userData})}),a.userData.a3dId=r,t?.position&&a.position.set(...t.position),(n.object.parent??i.world.scene).add(a);let o={...n.def,id:r,children:void 0},s={...n,id:r,def:o,object:a,rest:{position:a.position.clone(),quaternion:a.quaternion.clone(),scale:a.scale.clone(),visible:a.visible},runners:[],animator:void 0};return i.world.entries.set(r,s),i.world.scene.updateMatrixWorld(!0),o.body&&i.physics&&i.physics.addEntry(s),i.wrap(s)},camera:s,time:()=>i.simTime,random:()=>i.rng.next(),randomRange:(e,t)=>i.rng.range(e,t),input:{isDown:e=>o().keys.has(e),pressed:e=>i.stepPressed.has(e),get pointer(){let e=o().pointer;return{x:e.x,y:e.y,down:e.down,justPressed:i.stepJust}},swipe:()=>i.stepSwipe,pointerWorld:()=>{let n=o().pointer;c.setFromCamera(new e(n.x,n.y),i.world.camera);let a=[];for(let e of i.physics?.engine.bodies??[]){let t=i.world.entries.get(e.id);t&&a.push(t.object)}let s=a.length?c.intersectObjects(a,!0)[0]:void 0;if(s){let e=i.world.idsFor(s.object);return{x:s.point.x,y:s.point.y,z:s.point.z,objectId:e[0]}}let l=new t;return c.ray.intersectPlane(new r(new t(0,1,0),0),l)?{x:l.x,y:l.y,z:l.z}:null}},physics:{overlaps:(e,t)=>i.physics?.engine.overlaps(i.idOf(e),i.idOf(t))??!1,contacts:e=>(i.physics?.engine.contactsOf(i.idOf(e))??[]).map(e=>l.get(e.id)).filter(e=>!!e),raycast:(e,t,n,r)=>{let a=i.physics?.engine;if(!a)return null;let o=new Set((r?.ignore??[]).map(e=>i.idOf(e))),s=a.raycast(e,t,n??1/0,{ignore:o.size?e=>o.has(e.id):void 0,mask:r?.layers?a.layerMask(r.layers):void 0,triggers:r?.triggers});return s?{objectId:s.body.id,distance:s.distance,point:s.point,normal:s.normal}:null},applyImpulse:(e,t,n)=>i.physics?.engine.applyImpulse(i.idOf(e),t,n),applyForce:(e,t,n)=>i.physics?.engine.applyForce(i.idOf(e),t,n),applyTorque:(e,t)=>i.physics?.engine.applyTorque(i.idOf(e),t),setVelocity:(e,t)=>i.physics?.engine.setVelocity(i.idOf(e),t),getVelocity:e=>i.physics?.engine.get(i.idOf(e))?.velocity??[0,0,0],setAngularVelocity:(e,t)=>i.physics?.engine.setAngularVelocity(i.idOf(e),[t[0]*a,t[1]*a,t[2]*a]),getAngularVelocity:e=>{let t=i.physics?.engine.get(i.idOf(e))?.angularVelocity??[0,0,0];return[t[0]/a,t[1]/a,t[2]/a]},grounded:e=>i.physics?.engine.grounded(i.idOf(e))??!1,moveCharacter:(e,t,n)=>{let r=Array.isArray(t)?[t[0],t[1]]:[t.x,t.z];i.physics?.engine.moveCharacter(i.idOf(e),r,n)},jump:(e,t)=>i.physics?.engine.jump(i.idOf(e),t)??!1,wake:e=>i.physics?.engine.wake(i.idOf(e)),setMotorSpeed:(e,t)=>i.physics?.engine.setMotorSpeed(e,t*a),onCollision:e=>void i.collisionHandlers.push(e),onCollisionEnd:e=>void i.collisionEndHandlers.push(e),onTriggerEnter:e=>void i.triggerEnterHandlers.push(e),onTriggerExit:e=>void i.triggerExitHandlers.push(e)},state:i.state,ui:{set:(e,t)=>i.hud?.set(e,t),toast:(e,t)=>i.hud?.toast(e,t)},audio:{play:e=>i.audio.play(e),music:e=>i.audio.music(e)},on:(e,t)=>{let n=i.handlers.get(e)??[];n.push(t),i.handlers.set(e,n)},emit:(e,t)=>i.emit(e,t),storage:{get(e){try{let t=globalThis.localStorage?.getItem(`agent3d:${i.opts.scene.id}:${e}`);return t==null?void 0:JSON.parse(t)}catch{return}},set(e,t){try{globalThis.localStorage?.setItem(`agent3d:${i.opts.scene.id}:${e}`,JSON.stringify(t))}catch{}}},data:i.opts.scene.data??{},restart:()=>i.requestRestart(),log:(...e)=>console.log(`[agent3d]`,...e)};return l}};export{D as GameHost};
19
+ `,b=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M19 5a10 10 0 0 1 0 14"/></svg>`,x=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="m23 9-6 6"/><path d="m17 9 6 6"/></svg>`;function S(e,t,n){let r=e.ownerDocument,i=r.createElement(`div`);i.className=`a3d-hud`,i.setAttribute(`aria-live`,`polite`);let a=r.createElement(`style`),o=t?.accent??`#ff006e`;a.textContent=y(t?.font??`system-ui,-apple-system,'Segoe UI',Roboto,sans-serif`,t?.color??`#ffffff`,o,t?.buttonText??c(o)),i.appendChild(a);let s=new Map,l=e=>{let t=s.get(e);return t||(t=r.createElement(`div`),t.className=`a3d-zone`,t.style.cssText=_[e]??_[`top-left`],t.dataset.anchor=e,i.appendChild(t),s.set(e,t)),t},u=[[`top-left`,`top`,`top-right`],[`left`,`center`,`right`],[`bottom-left`,`bottom`,`bottom-right`]],d=()=>{for(let[e,t,n]of u){let r=s.get(t);r&&(r.style.gridColumn=s.has(e)||s.has(n)?`2`:`1 / -1`)}},f=new Map;for(let e of t?.elements??[]){let t,i;if(e.type===`button`){let i=r.createElement(`button`);i.type=`button`,i.className=`a3d-btn`,i.addEventListener(`click`,t=>{t.stopPropagation(),e.action&&n(e.action)}),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),t=i}else e.type===`bar`?(t=r.createElement(`div`),t.className=`a3d-bar`,i=r.createElement(`i`),t.appendChild(i)):(t=r.createElement(`div`),t.className=`a3d-el a3d-${e.style??`plain`}`);e.color&&(t.style.color=e.color,e.type===`bar`&&i&&(i.style.background=e.color)),e.background&&(t.style.background=e.background),e.type===`button`&&e.background&&!e.color&&(t.style.color=c(e.background)),t.dataset.id=e.id,l(e.anchor??`top-left`).appendChild(t),f.set(e.id,{def:e,node:t,fill:i,override:{},last:``})}d(),e.appendChild(i);let m=null,v=0,S=null,C=null,w=null;return{root:i,setTimeline(e){w=e},set(e,t){let n=f.get(e);n&&Object.assign(n.override,t)},toast(e,t=2){S={text:e,seconds:t}},update(e,t){let n=w&&!Object.prototype.hasOwnProperty.call(e,`timeline`)?{...e,timeline:w}:e;for(let e of f.values()){let t=e.override.visible??h(e.def.visible,n);if(e.node.style.display=t?``:`none`,!t)continue;if(e.def.type===`bar`){let t=e.override.value??Number(e.def.value?p(n,e.def.value):0),r=Math.max(0,Math.min(1,Number.isFinite(t)?t:0));e.fill.style.width=`${(r*100).toFixed(1)}%`;continue}let r=e.override.text??g(e.def.text??``,n);r!==e.last&&(e.node.textContent=r,e.last=r)}S&&=(m||(m=r.createElement(`div`),m.className=`a3d-toast`,i.appendChild(m)),m.textContent=S.text,m.style.opacity=`1`,v=t+S.seconds,null),m&&t>v&&(m.style.opacity=`0`)},setMuteButton(e,t){e===null?(C?.remove(),C=null):(C||(C=r.createElement(`button`),C.type=`button`,C.className=`a3d-mute`,C.addEventListener(`pointerdown`,e=>e.stopPropagation()),C.addEventListener(`click`,e=>{e.stopPropagation(),t?.()}),l(`bottom-right`).appendChild(C),d()),C.innerHTML=e?x:b,C.setAttribute(`aria-label`,e?`Unmute sound`:`Mute sound`))},dispose(){i.remove()}}}var C=null,w=()=>C??=l(()=>import(`./physicsHost-tEUto2-_.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url);function T(e,t=1,n){return{get x(){return e().x/t},set x(r){e().x=r*t,n?.()},get y(){return e().y/t},set y(r){e().y=r*t,n?.()},get z(){return e().z/t},set z(r){e().z=r*t,n?.()},set(r,i,a){e().set(r*t,i*t,a*t),n?.()}}}var E=new Map,D=class c{opts;world;physics=null;state={};hud=null;audio;instances=[];factories=[];objCache=new Map;handlers=new Map;collisionHandlers=[];collisionEndHandlers=[];triggerEnterHandlers=[];triggerExitHandlers=[];rng;simTime=0;acc=0;stepDt;pendingPressed=new Set;pendingJust=!1;pendingSwipe=null;stepPressed=new Set;stepJust=!1;stepSwipe=null;shake={intensity:0,duration:0,until:0};restartRequested=!1;cloneCounter=0;unlockListeners=null;api;constructor(e){this.opts=e,this.stepDt=Math.min(Math.max(e.scene.physics?.step??1/60,1/480),1/10),this.rng=o(e.scene.seed??1),this.audio=u(e.scene.audio,e.resolveAsset,(t,n)=>e.issue({code:`asset-load`,message:t,path:n})),this.api=this.createApi()}static async create(e,t){let n=new c(e);if(n.hud=e.scene.ui?.elements?.length||e.scene.audio?S(e.container,e.scene.ui,e=>n.emit(e)):null,e.scene.audio&&n.hud){let e=()=>n.hud.setMuteButton(n.audio.muted(),()=>{n.audio.unlock(),n.audio.setMuted(!n.audio.muted()),e()});e()}if(!e.deterministic){let t=()=>n.audio.unlock();e.container.addEventListener(`pointerdown`,t),e.container.addEventListener(`keydown`,t),n.unlockListeners=()=>{e.container.removeEventListener(`pointerdown`,t),e.container.removeEventListener(`keydown`,t)}}return await n.loadScripts(),await n.attach(t),n}async loadScripts(){let{scene:e,scriptSources:t,resolveAsset:n,issue:r}=this.opts;for(let i of e.scripts??[]){let e=t?.[i],a=e===void 0?n(i):`src:${i}:${e.length}:${e.slice(0,64)}`,o=E.get(a);o||(o=(async()=>{let t,r=null;e===void 0?t=n(i):(t=URL.createObjectURL(new Blob([e],{type:`text/javascript`})),r=t);try{let e=await import(t);if(typeof e.default!=`function`)throw Error(`the default export must be a function (api) => ({ start, update })`);return e.default}finally{r&&URL.revokeObjectURL(r)}})(),o.catch(()=>E.delete(a)),E.set(a,o));try{let e=await o;e&&this.factories.push({path:i,factory:e})}catch(e){r({code:`script-error`,message:`${i}: ${e.message}`,path:i})}}}async attach(e){this.world=e,this.objCache.clear(),this.physics?.dispose(),this.physics=null,e.scene.updateMatrixWorld(!0),this.needsPhysics(e)&&await this.ensurePhysics(),this.instances=[];for(let{path:e,factory:t}of this.factories)try{this.instances.push({path:e,inst:t(this.api)??{},failed:!1})}catch(t){this.opts.issue({code:`script-error`,message:`${e}: ${t.message}`,path:e})}for(let e of this.instances)try{await e.inst.start?.()}catch(t){e.failed=!0,this.opts.issue({code:`script-error`,message:`${e.path} start(): ${t.message}`,path:e.path})}this.hud?.update(this.state,0)}needsPhysics(e){if(this.opts.scene.physics?.joints?.length)return!0;for(let t of e.entries.values())if(t.kind!==`light`&&(t.def.body||Array.isArray(t.object.userData.bodies)))return!0;return!1}async ensurePhysics(){if(this.physics)return this.physics;let{PhysicsBridge:e}=await w(),t=new e(this.opts.scene.physics,this.world,e=>this.opts.issue(e));return t.engine.onCollision((e,t,n)=>this.dispatchContact(e.id,t.id,n)),t.engine.onCollisionEnd((e,t)=>this.dispatchContact(e.id,t.id,null)),this.physics=t,t.attachAll(),t}dispatchContact(e,t,n){let r=this.api.get(e),i=this.api.get(t);if(!r||!i||!this.physics)return;let a=this.physics.engine.get(e)?.type===`trigger`,o=this.physics.engine.get(t)?.type===`trigger`;if(n){for(let e of this.collisionHandlers)this.safe(()=>e(r,i,n),`onCollision`);for(let e of this.triggerEnterHandlers)a&&this.safe(()=>e(r,i),`onTriggerEnter`),o&&this.safe(()=>e(i,r),`onTriggerEnter`)}else{for(let e of this.collisionEndHandlers)this.safe(()=>e(r,i),`onCollisionEnd`);for(let e of this.triggerExitHandlers)a&&this.safe(()=>e(r,i),`onTriggerExit`),o&&this.safe(()=>e(i,r),`onTriggerExit`)}}async addBodies(e,t){let n=[];e.object.traverse(e=>{let t=e.userData.a3dId;t&&!n.includes(t)&&n.push(t)});let r=n.map(e=>this.world.entries.get(e)).filter(e=>!!e).filter(n=>n===e&&t||n.def.body);if(!r.length)return;let i=await this.ensurePhysics();for(let n of r)i.has(n.id)||i.addEntry(n,n===e?t:void 0)}requestRestart(){this.restartRequested=!0}get pendingRestart(){return this.restartRequested}async restart(){this.restartRequested=!1;for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);for(let e of Object.keys(this.state))delete this.state[e];this.handlers.clear(),this.collisionHandlers=[],this.collisionEndHandlers=[],this.triggerEnterHandlers=[],this.triggerExitHandlers=[],this.rng=o(this.opts.scene.seed??1),this.simTime=0,this.acc=0,this.shake={intensity:0,duration:0,until:0};let e=await this.opts.rebuild();return await this.attach(e),e}time(){return this.simTime}advance(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe),this.acc+=Math.min(e,.25);let n=0;for(;this.acc>=this.stepDt-1e-9&&n<30;)this.fixedStep(),this.acc-=this.stepDt,n++}advanceTo(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);for(t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe);this.simTime+this.stepDt<=e+1e-9;)this.fixedStep()}fixedStep(){this.stepPressed=this.pendingPressed,this.pendingPressed=new Set,this.stepJust=this.pendingJust,this.pendingJust=!1,this.stepSwipe=this.pendingSwipe,this.pendingSwipe=null;let e=this.stepDt;this.simTime+=e;for(let t of this.instances)if(!t.failed&&t.inst.update)try{t.inst.update(e,this.simTime)}catch(e){t.failed=!0,this.opts.issue({code:`script-error`,message:`${t.path} update(): ${e.message}`,path:t.path})}this.physics?.step(e),this.stepPressed=new Set,this.stepJust=!1,this.stepSwipe=null}afterFrame(){let e=this.world.rig,t=this.simTime;if(t<this.shake.until&&this.shake.duration>0){let n=(this.shake.until-t)/this.shake.duration*this.shake.intensity;e.shake.set((this.rng.next()-.5)*2*n,(this.rng.next()-.5)*2*n,(this.rng.next()-.5)*n)}else e.shake.set(0,0,0);this.hud?.update(this.state,t)}emit(e,t){for(let n of this.handlers.get(e)??[])this.safe(()=>n(t),`on(${e})`);for(let n of this.instances)!n.failed&&n.inst.onEvent&&this.safe(()=>n.inst.onEvent(e,t),`onEvent`)}safe(e,t){try{e()}catch(e){this.opts.issue({code:`script-error`,message:`${t}: ${e.message}`})}}dispose(){for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);this.instances=[],this.physics?.dispose(),this.hud?.dispose(),this.audio.dispose(),this.unlockListeners?.()}wrap(e){let n=this.objCache.get(e.id);if(n)return n;let r=this,o=e.id,c=()=>r.world.entries.get(o)??e,l=()=>{let e=c();e.animated&&(e.rest.position.copy(e.object.position),e.rest.quaternion.copy(e.object.quaternion),e.rest.scale.copy(e.object.scale)),r.physics?.moved(o)},u=()=>r.physics?.engine.get(o)?.velocity??[0,0,0],d=(e,t)=>{let n=u();n[e]=t,r.physics?.engine.setVelocity(o,n)},f={id:o,position:T(()=>c().object.position,1,l),rotation:T(()=>c().object.rotation,a,l),scale:T(()=>c().object.scale,1,l),get visible(){return c().object.visible},set visible(e){let t=c();t.object.visible=e,t.rest.visible=e},velocity:{get x(){return u()[0]},set x(e){d(0,e)},get y(){return u()[1]},set y(e){d(1,e)},get z(){return u()[2]},set z(e){d(2,e)},set(e,t,n){r.physics?.engine.setVelocity(o,[e,t,n])}},get userData(){return c().object.userData},get tags(){return c().object.userData.tags??[]},setColor(e){let t=s(e);for(let e of i(c().object))e.color?.copy(t)},setOpacity(e){for(let t of i(c().object))t.opacity=e,e<1&&!t.transparent&&(t.transparent=!0,t.needsUpdate=!0)},playAnimation(e,t){c().animator?.play(e,t)},distanceTo(e){let n=c().object.getWorldPosition(new t),i=r.world.entries.get(e.id);return i?n.distanceTo(i.object.getWorldPosition(new t)):1/0},remove(){r.world.entries.get(o)?.object.traverse(e=>{let t=e.userData.a3dId;t&&r.physics?.remove(t)}),r.physics?.remove(o),r.world.removeEntry(o),r.objCache.delete(o)}};return this.objCache.set(o,f),f}idOf(e){return typeof e==`string`?e:e.id}createApi(){let i=this,o=()=>i.opts.input,s={id:`camera`,position:T(()=>i.world.rig.rest.position),rotation:T(()=>i.world.camera.rotation,a),scale:T(()=>i.world.camera.scale),visible:!0,velocity:T(()=>new t),userData:{},tags:[],setColor(){},setOpacity(){},playAnimation(){},distanceTo(e){let n=i.world.entries.get(e.id);return n?i.world.camera.position.distanceTo(n.object.getWorldPosition(new t)):1/0},remove(){},lookAt(e,t,n){i.world.rig.rest.target.set(e,t,n)},shake(e,t){i.shake={intensity:e,duration:t,until:i.simTime+t}}},c=new n,l={get:e=>{let t=i.world.entries.get(e);return t&&t.kind!==`light`?i.wrap(t):null},findByTag:e=>{let t=[];for(let n of i.world.entries.values())n.kind!==`light`&&(n.object.userData.tags??[]).includes(e)&&t.push(i.wrap(n));return t},spawn:async(e,t)=>{let n=t?i.world.entries.get(t):void 0,r=await i.world.addObject(e,n?.object??i.world.scene,n?.id,new Map);if(!r)throw Error(`spawn(${e.id}) failed`);return i.world.scene.updateMatrixWorld(!0),await i.addBodies(r),i.wrap(r)},clone:(e,t)=>{let n=i.world.entries.get(e);if(!n||n.kind===`light`)throw Error(`clone: unknown object "${e}"`);let r=t?.id;for(;!r||i.world.entries.has(r);)r=`${e}_${++i.cloneCounter}`;let a=n.object.clone(!0);a.traverse(e=>{let t=e;t.isMesh&&t.material&&(t.material=Array.isArray(t.material)?t.material.map(e=>e.clone()):t.material.clone()),e.userData.a3dId&&(e.userData={...e.userData})}),a.userData.a3dId=r,t?.position&&a.position.set(...t.position),(n.object.parent??i.world.scene).add(a);let o={...n.def,id:r,children:void 0},s={...n,id:r,def:o,object:a,rest:{position:a.position.clone(),quaternion:a.quaternion.clone(),scale:a.scale.clone(),visible:a.visible},runners:[],animator:void 0};return i.world.entries.set(r,s),i.world.scene.updateMatrixWorld(!0),o.body&&i.physics&&i.physics.addEntry(s),i.wrap(s)},camera:s,time:()=>i.simTime,random:()=>i.rng.next(),randomRange:(e,t)=>i.rng.range(e,t),input:{isDown:e=>o().keys.has(e),pressed:e=>i.stepPressed.has(e),get pointer(){let e=o().pointer;return{x:e.x,y:e.y,down:e.down,justPressed:i.stepJust}},swipe:()=>i.stepSwipe,pointerWorld:()=>{let n=o().pointer;c.setFromCamera(new e(n.x,n.y),i.world.camera);let a=[];for(let e of i.physics?.engine.bodies??[]){let t=i.world.entries.get(e.id);t&&a.push(t.object)}let s=a.length?c.intersectObjects(a,!0)[0]:void 0;if(s){let e=i.world.idsFor(s.object);return{x:s.point.x,y:s.point.y,z:s.point.z,objectId:e[0]}}let l=new t;return c.ray.intersectPlane(new r(new t(0,1,0),0),l)?{x:l.x,y:l.y,z:l.z}:null}},physics:{overlaps:(e,t)=>i.physics?.engine.overlaps(i.idOf(e),i.idOf(t))??!1,contacts:e=>(i.physics?.engine.contactsOf(i.idOf(e))??[]).map(e=>l.get(e.id)).filter(e=>!!e),raycast:(e,t,n,r)=>{let a=i.physics?.engine;if(!a)return null;let o=new Set((r?.ignore??[]).map(e=>i.idOf(e))),s=a.raycast(e,t,n??1/0,{ignore:o.size?e=>o.has(e.id):void 0,mask:r?.layers?a.layerMask(r.layers):void 0,triggers:r?.triggers});return s?{objectId:s.body.id,distance:s.distance,point:s.point,normal:s.normal}:null},applyImpulse:(e,t,n)=>i.physics?.engine.applyImpulse(i.idOf(e),t,n),applyForce:(e,t,n)=>i.physics?.engine.applyForce(i.idOf(e),t,n),applyTorque:(e,t)=>i.physics?.engine.applyTorque(i.idOf(e),t),setVelocity:(e,t)=>i.physics?.engine.setVelocity(i.idOf(e),t),getVelocity:e=>i.physics?.engine.get(i.idOf(e))?.velocity??[0,0,0],setAngularVelocity:(e,t)=>i.physics?.engine.setAngularVelocity(i.idOf(e),[t[0]*a,t[1]*a,t[2]*a]),getAngularVelocity:e=>{let t=i.physics?.engine.get(i.idOf(e))?.angularVelocity??[0,0,0];return[t[0]/a,t[1]/a,t[2]/a]},grounded:e=>i.physics?.engine.grounded(i.idOf(e))??!1,moveCharacter:(e,t,n)=>{let r=Array.isArray(t)?[t[0],t[1]]:[t.x,t.z];i.physics?.engine.moveCharacter(i.idOf(e),r,n)},jump:(e,t)=>i.physics?.engine.jump(i.idOf(e),t)??!1,wake:e=>i.physics?.engine.wake(i.idOf(e)),setMotorSpeed:(e,t)=>i.physics?.engine.setMotorSpeed(e,t*a),onCollision:e=>void i.collisionHandlers.push(e),onCollisionEnd:e=>void i.collisionEndHandlers.push(e),onTriggerEnter:e=>void i.triggerEnterHandlers.push(e),onTriggerExit:e=>void i.triggerExitHandlers.push(e)},state:i.state,ui:{set:(e,t)=>i.hud?.set(e,t),toast:(e,t)=>i.hud?.toast(e,t)},audio:{play:e=>i.audio.play(e),music:e=>i.audio.music(e)},on:(e,t)=>{let n=i.handlers.get(e)??[];n.push(t),i.handlers.set(e,n)},emit:(e,t)=>i.emit(e,t),storage:{get(e){try{let t=globalThis.localStorage?.getItem(`agent3d:${i.opts.scene.id}:${e}`);return t==null?void 0:JSON.parse(t)}catch{return}},set(e,t){try{globalThis.localStorage?.setItem(`agent3d:${i.opts.scene.id}:${e}`,JSON.stringify(t))}catch{}}},data:i.opts.scene.data??{},restart:()=>i.requestRestart(),log:(...e)=>console.log(`[agent3d]`,...e)};return l}};export{D as GameHost};
@@ -1,4 +1,4 @@
1
- import{c as e,i as t}from"./runtime-CMAP4azF.js";import{t as n}from"./params-gVpEEiSK.js";import{a as r,c as i,l as a,o,u as s}from"./camera-DT0xHipx.js";import{n as c}from"./BufferGeometryUtils-CAlXAboW.js";import{An as l,Bn as u,Bt as d,C as f,Dt as p,E as m,En as h,I as g,In as _,J as v,Jt as y,K as b,Kt as x,Ln as S,M as C,Mn as w,N as T,Ot as E,P as D,Rn as O,St as k,T as A,U as j,Ut as M,W as N,Y as P,_ as F,_n as I,bn as L,bt as R,cn as z,ct as B,d as ee,fn as te,h as ne,hn as re,it as ie,jn as ae,kn as oe,lt as se,m as V,mn as ce,nn as le,on as ue,p as de,pn as fe,rn as pe,st as me,tn as he,tt as ge,v as _e,wn as ve,x as H,xn as ye,xt as U,y as be,yt as xe,zt as Se}from"./three.module-CnI50X0U.js";var Ce=class{pos=[];col=[];uv=[];wind=[];useUv=!1;useWind=!1;windFn=null;pushVertex(e,t,n,r,i=0,a=0){if(this.pos.push(e,t,n),this.col.push(r.r,r.g,r.b),this.useUv&&this.uv.push(i,a),this.useWind){let r=this.windFn?this.windFn(e,t,n):[0,0];this.wind.push(r[0],r[1])}}tri(e,t,n,r,i){this.pushVertex(e[0],e[1],e[2],r,i?.[0],i?.[1]),this.pushVertex(t[0],t[1],t[2],r,i?.[2],i?.[3]),this.pushVertex(n[0],n[1],n[2],r,i?.[4],i?.[5])}quad(e,t,n,r,i,a){this.tri(e,t,n,i,a?[a[0],a[1],a[2],a[3],a[4],a[5]]:void 0),this.tri(e,n,r,i,a?[a[0],a[1],a[4],a[5],a[6],a[7]]:void 0)}box(e,t,n,r=n,i={}){let[a,o,s]=e,[c,l,u]=t,d=(e,t,n)=>{if(!i.uv)return;let[r,a,o,s]=i.uv(e,t,n);return[r,a,o,a,o,s,r,s]},f=c-a,p=l-o,m=u-s;this.quad([a,o,u],[c,o,u],[c,l,u],[a,l,u],n,d(`z`,f,p)),this.quad([c,o,s],[a,o,s],[a,l,s],[c,l,s],n,d(`z`,f,p)),this.quad([c,o,u],[c,o,s],[c,l,s],[c,l,u],n,d(`x`,m,p)),this.quad([a,o,s],[a,o,u],[a,l,u],[a,l,s],n,d(`x`,m,p)),this.quad([a,l,u],[c,l,u],[c,l,s],[a,l,s],r,d(`y`,f,m)),i.bottom&&this.quad([a,o,s],[c,o,s],[c,o,u],[a,o,u],n,d(`y`,f,m))}add(e,t,n){let r=e.index?e.toNonIndexed():e,i=r.getAttribute(`position`),a=new S,o=[[0,0,0],[0,0,0],[0,0,0]],s=[[0,0,0],[0,0,0],[0,0,0]];for(let e=0;e<i.count/3;e++){for(let n=0;n<3;n++)a.fromBufferAttribute(i,e*3+n),s[n]=[a.x,a.y,a.z],a.applyMatrix4(t),o[n]=[a.x,a.y,a.z];let r=typeof n==`function`?n((s[0][0]+s[1][0]+s[2][0])/3,(s[0][1]+s[1][1]+s[2][1])/3,(s[0][2]+s[1][2]+s[2][2])/3,e):n;this.tri(o[0],o[1],o[2],r)}r!==e&&r.dispose()}get triangles(){return this.pos.length/9}build(){let e=new ne;return e.setAttribute(`position`,new g(this.pos,3)),e.setAttribute(`color`,new g(this.col,3)),this.useUv&&e.setAttribute(`uv`,new g(this.uv,2)),this.useWind&&e.setAttribute(`aWind`,new g(this.wind,2)),e.computeVertexNormals(),e.computeBoundingBox(),e.computeBoundingSphere(),e}};function we(e,t,n){let r=e.getAttribute(`position`),i=new Map;for(let e=0;e<r.count;e++){let a=`${r.getX(e).toFixed(4)},${r.getY(e).toFixed(4)},${r.getZ(e).toFixed(4)}`,o=i.get(a);o||(o=[(n()-.5)*t,(n()-.5)*t,(n()-.5)*t],i.set(a,o)),r.setXYZ(e,r.getX(e)+o[0],r.getY(e)+o[1],r.getZ(e)+o[2])}return r.needsUpdate=!0,e}var Te=(e,t,n,r=1,i=r,a=r,o=0,s=0,c=0)=>new R().compose(new S(e,t,n),new x().setFromEuler(new T(o,s,c)),new S(r,i,a)),Ee=(e,t)=>e.clone().multiplyScalar(t);function De(e,t,n=new H){if(e.length===1)return n.copy(e[0]);let r=Math.min(1,Math.max(0,t))*(e.length-1),i=Math.min(e.length-2,Math.floor(r));return n.copy(e[i]).lerp(e[i+1],r-i)}var W=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function Oe(e){let t=[...e.siblings.values()].filter(e=>e.heightAt&&e.object.userData.surface!==`water`),n=e.placement?.position??[0,0,0],r=e=>{let t=e.object.userData.size;if(typeof t!=`number`)return 1/0;let r=e.object.position,i=e.object.scale,a=t/2*Math.abs(i.x||1),o=t/2*Math.abs(i.z||1);return Math.abs(n[0]-r.x)<=a&&Math.abs(n[2]-r.z)<=o?a*o:-1},i=e=>{let t=r(e);return(t<0?2:0)+(e.object.userData.surface===`terrain`?0:1)+(t>0&&Number.isFinite(t)?t/1e9:.5)};t.sort((e,t)=>i(e)-i(t));for(let n of t){if(!n.heightAt)continue;let t=n.object.position,r=n.object.scale,i=e.placement?.position??[0,0,0],a=e.placement?.scale??[1,1,1],o=n.heightAt.bind(n),s=e=>(e-i[1])/(a[1]||1),c=typeof n.object.userData.waterLevel==`number`?s(n.object.userData.waterLevel*r.y+t.y):null;return{snow:typeof n.object.userData.snowLevel==`number`?s(n.object.userData.snowLevel*r.y+t.y):null,height:(e,n)=>{let c=i[0]+e*a[0],l=i[2]+n*a[2];return s(o((c-t.x)/(r.x||1),(l-t.z)/(r.z||1))*r.y+t.y)},water:c}}return null}function ke(e,t,n,r=.15,i=!0){let a=null,o={x:0,y:0,z:0};for(let s=0;s<12;s++){let c=(e.next()-.5)*t[0],l=(e.next()-.5)*t[2],u=n?n.height(c,l):(e.next()-.5)*t[1];if(s===0&&(o={x:c,y:u,z:l}),!n)return{x:c,y:u,z:l};let d=n.water===null||u>n.water+r,f=!i||n.snow===null||n.snow===void 0||u<n.snow;if(d&&f)return{x:c,y:u,z:l};d&&(!a||u<a.y)&&(a={x:c,y:u,z:l})}return a??o}function Ae(e={}){return new E({vertexColors:!0,flatShading:e.flat??!0,roughness:e.roughness??.9,metalness:e.metalness??0,side:e.side??0})}function je(e){e.traverse(e=>{let t=e;t.geometry&&t.geometry.dispose();let n=t.material?Array.isArray(t.material)?t.material:[t.material]:[];for(let e of n){for(let t of Object.values(e))t instanceof ve&&t.dispose();e.dispose()}})}function G(e,t={}){return{object:e,dispose:()=>je(e),...t}}var Me=[`sphere`,`torus`,`ring`,`pill`,`cone`,`cube`,`halfDisc`,`squiggle`,`triangle`,`star`];function Ne(e){switch(e){case`sphere`:return new re(.5,40,28);case`torus`:return new h(.38,.14,24,64);case`ring`:return new h(.42,.045,12,64);case`pill`:return new F(.2,.6,10,24).rotateZ(Math.PI/2);case`cone`:return new f(.4,.8,40);case`cube`:return new t(.7,.7,.7,4,.08);case`halfDisc`:{let e=new A(.5,.5,.18,40,1,!1,0,Math.PI);return e.rotateX(Math.PI/2),e}case`squiggle`:{let e=Array.from({length:9},(e,t)=>new S((t/8-.5)*1.3,Math.sin(t*1.4)*.16,0));return new oe(new _e(e),80,.06,12,!1)}case`triangle`:{let e=new z;for(let t=0;t<3;t++){let n=Math.PI/2+t/3*Math.PI*2;t===0?e.moveTo(Math.cos(n)*.5,Math.sin(n)*.5):e.lineTo(Math.cos(n)*.5,Math.sin(n)*.5)}let t=new D(e,{depth:.16,bevelEnabled:!0,bevelThickness:.04,bevelSize:.04,bevelSegments:4});return t.center(),t}case`star`:{let e=new z;for(let t=0;t<10;t++){let n=Math.PI/2+t/10*Math.PI*2,r=t%2?.22:.5;t===0?e.moveTo(Math.cos(n)*r,Math.sin(n)*r):e.lineTo(Math.cos(n)*r,Math.sin(n)*r)}let t=new D(e,{depth:.14,bevelEnabled:!0,bevelThickness:.04,bevelSize:.03,bevelSegments:3});return t.center(),t}}}var Pe=(t,r)=>{let i=n(`abstractShapes`,t,r),a=i.int(`count`),o=i.vec3(`area`),s=i.colors(`colors`),c=i.num(`minSize`),l=Math.max(c,i.num(`maxSize`)),u=i.str(`style`),d=i.num(`motion`),f=i.raw(`shapes`),m=Array.isArray(f)?f.filter(e=>Me.includes(e)):[],h=m.length?m:[...Me],g=r.rng,_=[];for(let e=0;e<a;e++){let t=new S,n=-1;for(let e=0;e<14;e++){let e=new S((g.next()-.5)*o[0],(g.next()-.5)*o[1],(g.next()-.5)*o[2]),r=1/0;for(let t of _)r=Math.min(r,e.distanceTo(t.pos)-t.s*.6);r>n&&(n=r,t=e)}let r=c+(l-c)*(1-e/Math.max(1,a))**1.5*g.range(.7,1);_.push({pos:t,s:r,kind:h[e%h.length],color:s[e%s.length],rot:new T(g.range(-.6,.6),g.next()*Math.PI*2,g.range(-.8,.8)),spin:new S(g.range(-.25,.25),g.range(-.35,.35),g.range(-.2,.2)),ph:g.next()*Math.PI*2})}for(let e=_.length-1;e>0;e--){let t=Math.floor(g.next()*(e+1)),n=_[e].color;_[e].color=_[t].color,_[t].color=n}let v=u===`toon`?e({color:16777215}):u===`glossy`?new p({color:16777215,roughness:.18,clearcoat:1,clearcoatRoughness:.08}):new E({color:16777215,roughness:.62,metalness:0}),y=new j;y.name=`abstractShapes`;let b=[];for(let e of h){let t=_.filter(t=>t.kind===e);if(!t.length)continue;let n=new P(Ne(e),v,t.length);n.name=`shapes-${e}`,n.castShadow=!0,n.receiveShadow=!0,n.userData.materialTarget=!0,t.forEach((e,t)=>n.setColorAt(t,e.color)),n.frustumCulled=!1,y.add(n),b.push({mesh:n,list:t})}let C=new R,w=new x,D=new T,O=new S,k=new S,A=e=>{for(let{mesh:t,list:n}of b)n.forEach((n,r)=>{O.copy(n.pos),O.y+=Math.sin(e*.8+n.ph)*.12*d*(.5+n.s*.5),D.set(n.rot.x+n.spin.x*e*d,n.rot.y+n.spin.y*e*d,n.rot.z+n.spin.z*e*d),w.setFromEuler(D),k.setScalar(n.s),t.setMatrixAt(r,C.compose(O,w,k))}),t.instanceMatrix.needsUpdate=!0};return A(0),G(y,{update:e=>A(e)})},Fe=e=>1+2.4*(e-1)**3+1.4*(e-1)**2;function Ie(e){if(!Array.isArray(e)||e.length===0)return[[3,5,4,7,6,9,8]];let t=e=>typeof e==`number`&&Number.isFinite(e)?e:e&&typeof e==`object`&&typeof e.value==`number`?e.value:0;return e.every(e=>Array.isArray(e))?e.map(e=>e.map(t)):[e.map(t)]}var Le=(e,r)=>{let i=n(`bars3d`,e,r),a=Ie(i.raw(`data`)),o=a.length,s=Math.max(...a.map(e=>e.length),1),c=i.num(`barWidth`),l=i.num(`gap`),u=i.num(`maxHeight`),d=i.colors(`colors`),f=i.str(`colorBy`),m=i.str(`shape`),h=i.str(`animation`),g=i.num(`duration`),_=Math.max(1e-6,...a.flat().map(e=>Math.abs(e))),v=c+l,y;y=m===`cylinder`?new A(.5,.5,1,32):m===`box`?new de(1,1,1):new t(1,1,1,4,.12),y.translate(0,.5,0);let b=o*s,C=new p({roughness:.32,metalness:0,clearcoat:.6,clearcoatRoughness:.25}),w=new P(y,C,b);w.name=`bars`,w.castShadow=!0,w.receiveShadow=!0,w.userData.materialTarget=!0;let T=[],D=new H,O=0;for(let e=0;e<o;e++)for(let t=0;t<s;t++){let n=a[e][t]??0,r=Math.max(1e-4,Math.abs(n)/_*u),i=(t-(s-1)/2)*v,c=(e-(o-1)/2)*v,l=f===`row`?o>1?e/(o-1):0:f===`column`?s>1?t/(s-1):0:Math.abs(n)/_;f===`value`?De(d,l,D):D.copy(d[(f===`row`?e:t)%d.length]),w.setColorAt(O,D),T.push({x:i,z:c,h:r,i:O,delay:(t+e*.6)/Math.max(1,s+o*.6)}),O++}let k=new R,M=new x,N=new S,F=new S,I=e=>{for(let t of T){let n=1;if(h===`grow`){let r=(e-t.delay*g*.6)/(g*.5);n=r<=0?1e-4:r>=1?1:Fe(Math.min(1,r)),r>0&&r<1&&(n=Math.max(1e-4,n))}else h===`wave`&&(n=.55+.45*(.5+.5*Math.sin(e*1.6-t.x*.9-t.z*.7)));N.set(t.x,0,t.z),F.set(c,t.h*n,c),w.setMatrixAt(t.i,k.compose(N,M,F))}w.instanceMatrix.needsUpdate=!0};I(0),w.computeBoundingSphere(),w.frustumCulled=!1;let L=new j;if(L.name=`bars3d`,L.add(w),i.bool(`base`)){let e=s*v+l,n=o*v+l,r=new U(new t(e,.12,n,3,.05),new E({color:i.color(`baseColor`),roughness:.6}));r.position.y=-.06,r.receiveShadow=!0,r.castShadow=!0,r.name=`bars-base`,L.add(r)}return G(L,{update:e=>I(e)})};function Re(){let e=[],t=[],n=(n,r,i,a)=>{e.push(...n,...r,...i),t.push(a,a,a)},r=[0,0,.42],i=[0,.01,-.34],a=[0,.07,.04],o=[0,-.06,.02],s=[-.075,0,.04],c=[.075,0,.04];for(let[e,t]of[[s,a],[a,c],[c,o],[o,s]])n(r,e,t,0),n(i,t,e,0);n([0,.01,-.3],[-.14,.02,-.58],[.14,.02,-.58],0);for(let e of[-1,1]){let t=[e*.05,.01,.14],r=[e*.05,.01,-.12],i=[e*.48,0,.1],a=[e*.48,0,-.14],o=[e*1,-.01,-.26];n(t,i,a,1),n(t,a,r,1),n(i,o,a,1)}let l=new ne;return l.setAttribute(`position`,new g(e,3)),l.setAttribute(`aWing`,new g(t,1)),l.computeVertexNormals(),l}var ze=(e,t)=>{let r=n(`birds`,e,t),a=r.int(`count`),o=r.str(`mode`),s=r.vec3(`area`),c=r.num(`speed`),l=r.num(`size`),u=r.num(`spread`),d=r.str(`formation`),f=r.num(`flapSpeed`),p=r.num(`heading`)*Math.PI/180,m=r.color(`color`),h=t.rng,g=Re();g.scale(l/2,l/2,l/2);let _=new Float32Array(a),y=new Float32Array(a);for(let e=0;e<a;e++)_[e]=h.next()*Math.PI*2,y[e]=f*h.range(.82,1.18);g.setAttribute(`aPhase`,new v(_,1)),g.setAttribute(`aRate`,new v(y,1));let b=new E({color:16777215,roughness:.9,metalness:0,flatShading:!0,side:2}),C={uTime:{value:0}};b.onBeforeCompile=e=>{Object.assign(e.uniforms,C),e.vertexShader=`uniform float uTime;
1
+ import{c as e,i as t}from"./runtime-C_qkIpAK.js";import{t as n}from"./params-DhsDKSDs.js";import{a as r,c as i,l as a,o,u as s}from"./camera-BgzPVnn-.js";import{n as c}from"./BufferGeometryUtils-CAlXAboW.js";import{An as l,Bn as u,Bt as d,C as f,Dt as p,E as m,En as h,I as g,In as _,J as v,Jt as y,K as b,Kt as x,Ln as S,M as C,Mn as w,N as T,Ot as E,P as D,Rn as O,St as k,T as A,U as j,Ut as M,W as N,Y as P,_ as F,_n as I,bn as L,bt as R,cn as z,ct as B,d as ee,fn as te,h as ne,hn as re,it as ie,jn as ae,kn as oe,lt as se,m as V,mn as ce,nn as le,on as ue,p as de,pn as fe,rn as pe,st as me,tn as he,tt as ge,v as _e,wn as ve,x as H,xn as ye,xt as U,y as be,yt as xe,zt as Se}from"./three.module-CnI50X0U.js";var Ce=class{pos=[];col=[];uv=[];wind=[];useUv=!1;useWind=!1;windFn=null;pushVertex(e,t,n,r,i=0,a=0){if(this.pos.push(e,t,n),this.col.push(r.r,r.g,r.b),this.useUv&&this.uv.push(i,a),this.useWind){let r=this.windFn?this.windFn(e,t,n):[0,0];this.wind.push(r[0],r[1])}}tri(e,t,n,r,i){this.pushVertex(e[0],e[1],e[2],r,i?.[0],i?.[1]),this.pushVertex(t[0],t[1],t[2],r,i?.[2],i?.[3]),this.pushVertex(n[0],n[1],n[2],r,i?.[4],i?.[5])}quad(e,t,n,r,i,a){this.tri(e,t,n,i,a?[a[0],a[1],a[2],a[3],a[4],a[5]]:void 0),this.tri(e,n,r,i,a?[a[0],a[1],a[4],a[5],a[6],a[7]]:void 0)}box(e,t,n,r=n,i={}){let[a,o,s]=e,[c,l,u]=t,d=(e,t,n)=>{if(!i.uv)return;let[r,a,o,s]=i.uv(e,t,n);return[r,a,o,a,o,s,r,s]},f=c-a,p=l-o,m=u-s;this.quad([a,o,u],[c,o,u],[c,l,u],[a,l,u],n,d(`z`,f,p)),this.quad([c,o,s],[a,o,s],[a,l,s],[c,l,s],n,d(`z`,f,p)),this.quad([c,o,u],[c,o,s],[c,l,s],[c,l,u],n,d(`x`,m,p)),this.quad([a,o,s],[a,o,u],[a,l,u],[a,l,s],n,d(`x`,m,p)),this.quad([a,l,u],[c,l,u],[c,l,s],[a,l,s],r,d(`y`,f,m)),i.bottom&&this.quad([a,o,s],[c,o,s],[c,o,u],[a,o,u],n,d(`y`,f,m))}add(e,t,n){let r=e.index?e.toNonIndexed():e,i=r.getAttribute(`position`),a=new S,o=[[0,0,0],[0,0,0],[0,0,0]],s=[[0,0,0],[0,0,0],[0,0,0]];for(let e=0;e<i.count/3;e++){for(let n=0;n<3;n++)a.fromBufferAttribute(i,e*3+n),s[n]=[a.x,a.y,a.z],a.applyMatrix4(t),o[n]=[a.x,a.y,a.z];let r=typeof n==`function`?n((s[0][0]+s[1][0]+s[2][0])/3,(s[0][1]+s[1][1]+s[2][1])/3,(s[0][2]+s[1][2]+s[2][2])/3,e):n;this.tri(o[0],o[1],o[2],r)}r!==e&&r.dispose()}get triangles(){return this.pos.length/9}build(){let e=new ne;return e.setAttribute(`position`,new g(this.pos,3)),e.setAttribute(`color`,new g(this.col,3)),this.useUv&&e.setAttribute(`uv`,new g(this.uv,2)),this.useWind&&e.setAttribute(`aWind`,new g(this.wind,2)),e.computeVertexNormals(),e.computeBoundingBox(),e.computeBoundingSphere(),e}};function we(e,t,n){let r=e.getAttribute(`position`),i=new Map;for(let e=0;e<r.count;e++){let a=`${r.getX(e).toFixed(4)},${r.getY(e).toFixed(4)},${r.getZ(e).toFixed(4)}`,o=i.get(a);o||(o=[(n()-.5)*t,(n()-.5)*t,(n()-.5)*t],i.set(a,o)),r.setXYZ(e,r.getX(e)+o[0],r.getY(e)+o[1],r.getZ(e)+o[2])}return r.needsUpdate=!0,e}var Te=(e,t,n,r=1,i=r,a=r,o=0,s=0,c=0)=>new R().compose(new S(e,t,n),new x().setFromEuler(new T(o,s,c)),new S(r,i,a)),Ee=(e,t)=>e.clone().multiplyScalar(t);function De(e,t,n=new H){if(e.length===1)return n.copy(e[0]);let r=Math.min(1,Math.max(0,t))*(e.length-1),i=Math.min(e.length-2,Math.floor(r));return n.copy(e[i]).lerp(e[i+1],r-i)}var W=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)};function Oe(e){let t=[...e.siblings.values()].filter(e=>e.heightAt&&e.object.userData.surface!==`water`),n=e.placement?.position??[0,0,0],r=e=>{let t=e.object.userData.size;if(typeof t!=`number`)return 1/0;let r=e.object.position,i=e.object.scale,a=t/2*Math.abs(i.x||1),o=t/2*Math.abs(i.z||1);return Math.abs(n[0]-r.x)<=a&&Math.abs(n[2]-r.z)<=o?a*o:-1},i=e=>{let t=r(e);return(t<0?2:0)+(e.object.userData.surface===`terrain`?0:1)+(t>0&&Number.isFinite(t)?t/1e9:.5)};t.sort((e,t)=>i(e)-i(t));for(let n of t){if(!n.heightAt)continue;let t=n.object.position,r=n.object.scale,i=e.placement?.position??[0,0,0],a=e.placement?.scale??[1,1,1],o=n.heightAt.bind(n),s=e=>(e-i[1])/(a[1]||1),c=typeof n.object.userData.waterLevel==`number`?s(n.object.userData.waterLevel*r.y+t.y):null;return{snow:typeof n.object.userData.snowLevel==`number`?s(n.object.userData.snowLevel*r.y+t.y):null,height:(e,n)=>{let c=i[0]+e*a[0],l=i[2]+n*a[2];return s(o((c-t.x)/(r.x||1),(l-t.z)/(r.z||1))*r.y+t.y)},water:c}}return null}function ke(e,t,n,r=.15,i=!0){let a=null,o={x:0,y:0,z:0};for(let s=0;s<12;s++){let c=(e.next()-.5)*t[0],l=(e.next()-.5)*t[2],u=n?n.height(c,l):(e.next()-.5)*t[1];if(s===0&&(o={x:c,y:u,z:l}),!n)return{x:c,y:u,z:l};let d=n.water===null||u>n.water+r,f=!i||n.snow===null||n.snow===void 0||u<n.snow;if(d&&f)return{x:c,y:u,z:l};d&&(!a||u<a.y)&&(a={x:c,y:u,z:l})}return a??o}function Ae(e={}){return new E({vertexColors:!0,flatShading:e.flat??!0,roughness:e.roughness??.9,metalness:e.metalness??0,side:e.side??0})}function je(e){e.traverse(e=>{let t=e;t.geometry&&t.geometry.dispose();let n=t.material?Array.isArray(t.material)?t.material:[t.material]:[];for(let e of n){for(let t of Object.values(e))t instanceof ve&&t.dispose();e.dispose()}})}function G(e,t={}){return{object:e,dispose:()=>je(e),...t}}var Me=[`sphere`,`torus`,`ring`,`pill`,`cone`,`cube`,`halfDisc`,`squiggle`,`triangle`,`star`];function Ne(e){switch(e){case`sphere`:return new re(.5,40,28);case`torus`:return new h(.38,.14,24,64);case`ring`:return new h(.42,.045,12,64);case`pill`:return new F(.2,.6,10,24).rotateZ(Math.PI/2);case`cone`:return new f(.4,.8,40);case`cube`:return new t(.7,.7,.7,4,.08);case`halfDisc`:{let e=new A(.5,.5,.18,40,1,!1,0,Math.PI);return e.rotateX(Math.PI/2),e}case`squiggle`:{let e=Array.from({length:9},(e,t)=>new S((t/8-.5)*1.3,Math.sin(t*1.4)*.16,0));return new oe(new _e(e),80,.06,12,!1)}case`triangle`:{let e=new z;for(let t=0;t<3;t++){let n=Math.PI/2+t/3*Math.PI*2;t===0?e.moveTo(Math.cos(n)*.5,Math.sin(n)*.5):e.lineTo(Math.cos(n)*.5,Math.sin(n)*.5)}let t=new D(e,{depth:.16,bevelEnabled:!0,bevelThickness:.04,bevelSize:.04,bevelSegments:4});return t.center(),t}case`star`:{let e=new z;for(let t=0;t<10;t++){let n=Math.PI/2+t/10*Math.PI*2,r=t%2?.22:.5;t===0?e.moveTo(Math.cos(n)*r,Math.sin(n)*r):e.lineTo(Math.cos(n)*r,Math.sin(n)*r)}let t=new D(e,{depth:.14,bevelEnabled:!0,bevelThickness:.04,bevelSize:.03,bevelSegments:3});return t.center(),t}}}var Pe=(t,r)=>{let i=n(`abstractShapes`,t,r),a=i.int(`count`),o=i.vec3(`area`),s=i.colors(`colors`),c=i.num(`minSize`),l=Math.max(c,i.num(`maxSize`)),u=i.str(`style`),d=i.num(`motion`),f=i.raw(`shapes`),m=Array.isArray(f)?f.filter(e=>Me.includes(e)):[],h=m.length?m:[...Me],g=r.rng,_=[];for(let e=0;e<a;e++){let t=new S,n=-1;for(let e=0;e<14;e++){let e=new S((g.next()-.5)*o[0],(g.next()-.5)*o[1],(g.next()-.5)*o[2]),r=1/0;for(let t of _)r=Math.min(r,e.distanceTo(t.pos)-t.s*.6);r>n&&(n=r,t=e)}let r=c+(l-c)*(1-e/Math.max(1,a))**1.5*g.range(.7,1);_.push({pos:t,s:r,kind:h[e%h.length],color:s[e%s.length],rot:new T(g.range(-.6,.6),g.next()*Math.PI*2,g.range(-.8,.8)),spin:new S(g.range(-.25,.25),g.range(-.35,.35),g.range(-.2,.2)),ph:g.next()*Math.PI*2})}for(let e=_.length-1;e>0;e--){let t=Math.floor(g.next()*(e+1)),n=_[e].color;_[e].color=_[t].color,_[t].color=n}let v=u===`toon`?e({color:16777215}):u===`glossy`?new p({color:16777215,roughness:.18,clearcoat:1,clearcoatRoughness:.08}):new E({color:16777215,roughness:.62,metalness:0}),y=new j;y.name=`abstractShapes`;let b=[];for(let e of h){let t=_.filter(t=>t.kind===e);if(!t.length)continue;let n=new P(Ne(e),v,t.length);n.name=`shapes-${e}`,n.castShadow=!0,n.receiveShadow=!0,n.userData.materialTarget=!0,t.forEach((e,t)=>n.setColorAt(t,e.color)),n.frustumCulled=!1,y.add(n),b.push({mesh:n,list:t})}let C=new R,w=new x,D=new T,O=new S,k=new S,A=e=>{for(let{mesh:t,list:n}of b)n.forEach((n,r)=>{O.copy(n.pos),O.y+=Math.sin(e*.8+n.ph)*.12*d*(.5+n.s*.5),D.set(n.rot.x+n.spin.x*e*d,n.rot.y+n.spin.y*e*d,n.rot.z+n.spin.z*e*d),w.setFromEuler(D),k.setScalar(n.s),t.setMatrixAt(r,C.compose(O,w,k))}),t.instanceMatrix.needsUpdate=!0};return A(0),G(y,{update:e=>A(e)})},Fe=e=>1+2.4*(e-1)**3+1.4*(e-1)**2;function Ie(e){if(!Array.isArray(e)||e.length===0)return[[3,5,4,7,6,9,8]];let t=e=>typeof e==`number`&&Number.isFinite(e)?e:e&&typeof e==`object`&&typeof e.value==`number`?e.value:0;return e.every(e=>Array.isArray(e))?e.map(e=>e.map(t)):[e.map(t)]}var Le=(e,r)=>{let i=n(`bars3d`,e,r),a=Ie(i.raw(`data`)),o=a.length,s=Math.max(...a.map(e=>e.length),1),c=i.num(`barWidth`),l=i.num(`gap`),u=i.num(`maxHeight`),d=i.colors(`colors`),f=i.str(`colorBy`),m=i.str(`shape`),h=i.str(`animation`),g=i.num(`duration`),_=Math.max(1e-6,...a.flat().map(e=>Math.abs(e))),v=c+l,y;y=m===`cylinder`?new A(.5,.5,1,32):m===`box`?new de(1,1,1):new t(1,1,1,4,.12),y.translate(0,.5,0);let b=o*s,C=new p({roughness:.32,metalness:0,clearcoat:.6,clearcoatRoughness:.25}),w=new P(y,C,b);w.name=`bars`,w.castShadow=!0,w.receiveShadow=!0,w.userData.materialTarget=!0;let T=[],D=new H,O=0;for(let e=0;e<o;e++)for(let t=0;t<s;t++){let n=a[e][t]??0,r=Math.max(1e-4,Math.abs(n)/_*u),i=(t-(s-1)/2)*v,c=(e-(o-1)/2)*v,l=f===`row`?o>1?e/(o-1):0:f===`column`?s>1?t/(s-1):0:Math.abs(n)/_;f===`value`?De(d,l,D):D.copy(d[(f===`row`?e:t)%d.length]),w.setColorAt(O,D),T.push({x:i,z:c,h:r,i:O,delay:(t+e*.6)/Math.max(1,s+o*.6)}),O++}let k=new R,M=new x,N=new S,F=new S,I=e=>{for(let t of T){let n=1;if(h===`grow`){let r=(e-t.delay*g*.6)/(g*.5);n=r<=0?1e-4:r>=1?1:Fe(Math.min(1,r)),r>0&&r<1&&(n=Math.max(1e-4,n))}else h===`wave`&&(n=.55+.45*(.5+.5*Math.sin(e*1.6-t.x*.9-t.z*.7)));N.set(t.x,0,t.z),F.set(c,t.h*n,c),w.setMatrixAt(t.i,k.compose(N,M,F))}w.instanceMatrix.needsUpdate=!0};I(0),w.computeBoundingSphere(),w.frustumCulled=!1;let L=new j;if(L.name=`bars3d`,L.add(w),i.bool(`base`)){let e=s*v+l,n=o*v+l,r=new U(new t(e,.12,n,3,.05),new E({color:i.color(`baseColor`),roughness:.6}));r.position.y=-.06,r.receiveShadow=!0,r.castShadow=!0,r.name=`bars-base`,L.add(r)}return G(L,{update:e=>I(e)})};function Re(){let e=[],t=[],n=(n,r,i,a)=>{e.push(...n,...r,...i),t.push(a,a,a)},r=[0,0,.42],i=[0,.01,-.34],a=[0,.07,.04],o=[0,-.06,.02],s=[-.075,0,.04],c=[.075,0,.04];for(let[e,t]of[[s,a],[a,c],[c,o],[o,s]])n(r,e,t,0),n(i,t,e,0);n([0,.01,-.3],[-.14,.02,-.58],[.14,.02,-.58],0);for(let e of[-1,1]){let t=[e*.05,.01,.14],r=[e*.05,.01,-.12],i=[e*.48,0,.1],a=[e*.48,0,-.14],o=[e*1,-.01,-.26];n(t,i,a,1),n(t,a,r,1),n(i,o,a,1)}let l=new ne;return l.setAttribute(`position`,new g(e,3)),l.setAttribute(`aWing`,new g(t,1)),l.computeVertexNormals(),l}var ze=(e,t)=>{let r=n(`birds`,e,t),a=r.int(`count`),o=r.str(`mode`),s=r.vec3(`area`),c=r.num(`speed`),l=r.num(`size`),u=r.num(`spread`),d=r.str(`formation`),f=r.num(`flapSpeed`),p=r.num(`heading`)*Math.PI/180,m=r.color(`color`),h=t.rng,g=Re();g.scale(l/2,l/2,l/2);let _=new Float32Array(a),y=new Float32Array(a);for(let e=0;e<a;e++)_[e]=h.next()*Math.PI*2,y[e]=f*h.range(.82,1.18);g.setAttribute(`aPhase`,new v(_,1)),g.setAttribute(`aRate`,new v(y,1));let b=new E({color:16777215,roughness:.9,metalness:0,flatShading:!0,side:2}),C={uTime:{value:0}};b.onBeforeCompile=e=>{Object.assign(e.uniforms,C),e.vertexShader=`uniform float uTime;
2
2
  attribute float aWing;
3
3
  attribute float aPhase;
4
4
  attribute float aRate;