@fleox/agent3d 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -10
- package/changelog.json +9 -0
- package/dist/agent/agent3d.mjs +2 -2
- package/dist/agent/chunks/{package-DzXqX5Oe.mjs → package-Bn7PKfXn.mjs} +1 -1
- package/dist/runtime/agent3d-runtime.js +1 -1
- package/dist/runtime/agent3d-runtime.single.js +1 -1
- package/dist/studio/assets/{assets-DnOt59SU.js → assets-DICv7P37.js} +1 -1
- package/dist/studio/assets/{camera-DrubOxWu.js → camera-HsMeC1mn.js} +1 -1
- package/dist/studio/assets/{editor-V--luWVq.js → editor-BZLIZJC8.js} +1 -1
- package/dist/studio/assets/{game-43BhY_EE.js → game-DnnuBk26.js} +1 -1
- package/dist/studio/assets/{generators-lG93qWTO.js → generators-C4n9MsXd.js} +1 -1
- package/dist/studio/assets/{index-BPVRhKVV.js → index-cDbmaVDl.js} +4 -4
- package/dist/studio/assets/{model-D8-inS_D.js → model-CkPfLOl0.js} +1 -1
- package/dist/studio/assets/{photo-BuVK-UvQ.js → photo-CPGGCRa-.js} +1 -1
- package/dist/studio/assets/{postfx-Bcnem9ci.js → postfx-Dp7mgfGJ.js} +1 -1
- package/dist/studio/assets/{runtime-5Ti8UJJR.js → runtime-ByR4qfyV.js} +4 -4
- package/dist/studio/assets/{shaders-WM5brr9C.js → shaders-DoRMwJE_.js} +1 -1
- package/dist/studio/assets/{svg-CJ_RtiER.js → svg-n3rkKAm5.js} +1 -1
- package/dist/studio/assets/{text-NO7lyCoH.js → text-BkPPDghK.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/agent3d-assets/SKILL.md +28 -28
- package/plugin/skills/agent3d-create/SKILL.md +30 -30
- package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
- package/plugin/skills/agent3d-create/references/recipes.md +6 -6
- package/plugin/skills/agent3d-edit/SKILL.md +22 -22
- package/plugin/skills/agent3d-edit/references/patch-ops.md +2 -2
- package/plugin/skills/agent3d-game/SKILL.md +7 -7
- package/plugin/skills/agent3d-publish/SKILL.md +23 -23
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./GLTFLoader-bl1eymL4.js","./three.module-B9FlcKtd.js","./rolldown-runtime-4tVxZq34.js","./BufferGeometryUtils-BbzK4rCj.js","./SkeletonUtils-CG5akqME.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./num-CQNAlL82.js";import{Ln as t,U as n,c as r,d as i,ht as a,mt as o}from"./three.module-B9FlcKtd.js";import{o as s}from"./runtime-
|
|
2
|
+
import{r as e}from"./num-CQNAlL82.js";import{Ln as t,U as n,c as r,d as i,ht as a,mt as o}from"./three.module-B9FlcKtd.js";import{o as s}from"./runtime-ByR4qfyV.js";import{g as c}from"./index-cDbmaVDl.js";var l=new Map;function u(e){let t=new Uint8Array(e),n;if(t.byteLength>=20&&new DataView(e).getUint32(0,!0)===1179937895){let r=new DataView(e).getUint32(12,!0);n=new TextDecoder().decode(t.subarray(20,20+r))}else n=new TextDecoder().decode(t);try{let e=JSON.parse(n);return Array.isArray(e.extensionsUsed)?e.extensionsUsed.filter(e=>typeof e==`string`):[]}catch{return[]}}async function d(e){let t=l.get(e);return t||(t=(async()=>{let[{GLTFLoader:t},n]=await Promise.all([c(()=>import(`./GLTFLoader-bl1eymL4.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url),fetch(e)]);if(!n.ok)throw Error(`HTTP ${n.status} for ${e}`);let r=await n.arrayBuffer(),i=u(r);if(i.includes(`KHR_draco_mesh_compression`))throw Error(`${e} uses Draco compression (KHR_draco_mesh_compression), which the Agent3D runtime does not decode. Re-export it without Draco (Blender: uncheck "Compression"), or convert it to meshopt with gltfpack (\`gltfpack -i in.glb -o out.glb -cc\`), then run \`agent3d assets optimize\`.`);let a=new t;if(i.includes(`EXT_meshopt_compression`)){let{MeshoptDecoder:e}=await c(async()=>{let{MeshoptDecoder:e}=await import(`./meshopt_decoder.module-DXTYc6wn.js`);return{MeshoptDecoder:e}},[],import.meta.url);await e.ready,a.setMeshoptDecoder(e)}let o=e.slice(0,e.lastIndexOf(`/`)+1);return a.parseAsync(r,/^data:/.test(e)?``:o)})(),t.catch(()=>l.delete(e)),l.set(e,t)),t}function f(e,t){e.traverse(e=>{let n=e;if(n.isMesh&&n.morphTargetDictionary&&n.morphTargetInfluences)for(let[e,r]of Object.entries(t)){let t=n.morphTargetDictionary[e];t!==void 0&&typeof r==`number`&&(n.morphTargetInfluences[t]=r)}})}async function p(l,u){let p=await d(u.resolveAsset(l.src)),{clone:m}=await c(async()=>{let{clone:e}=await import(`./SkeletonUtils-CG5akqME.js`);return{clone:e}},[],import.meta.url),h=m(p.scene),g=new n;g.add(h),h.updateMatrixWorld(!0);let _=new i().setFromObject(h);if(!_.isEmpty()){let e=_.getSize(new t),n=Math.max(e.x,e.y,e.z),r=l.fit&&n>0?l.fit/n:1;if(h.scale.multiplyScalar(r),l.center!==!1){let e=_.getCenter(new t);h.position.set(-e.x*r,-_.min.y*r,-e.z*r)}}h.traverse(e=>{let t=e;t.isMesh&&(t.castShadow=l.castShadow??!0,t.receiveShadow=l.receiveShadow??!1)}),l.material&&await s(h,l.material,u),l.morph&&f(h,l.morph);let v;if(p.animations.length){let t=new r(h),n=null,i=e=>typeof e==`number`||/^\d+$/.test(String(e))?p.animations[Number(e)]:p.animations.find(t=>t.name===e)??p.animations.find(t=>t.name.toLowerCase().includes(String(e).toLowerCase())),s=new Set,c=e=>{let t=i(e);return!t&&!s.has(String(e))&&(s.add(String(e)),u.issue(`asset-load`,`Model ${l.id} has no animation clip "${e}" (clips: ${p.animations.map(e=>e.name).join(`, `)})`,`objects#${l.id}.animation.clip`)),t},d=(r,i={})=>{let s=c(r);if(!s)return;let l=t.clipAction(s);l.setLoop(i.loop===!1?o:a,1/0),l.clampWhenFinished=i.loop===!1,l.timeScale=e(i.speed,1),l.enabled=!0,n&&n!==l?(l.reset().setEffectiveWeight(1).play(),n.crossFadeTo(l,e(i.crossfade,.3),!1)):l.setEffectiveWeight(1).play(),n=l},f=e=>{let n=c(e);if(!n)return null;let r=t.clipAction(n);return r.isRunning()||(r.enabled=!0,r.setLoop(a,1/0),r.play()),r},m={weight(e,t){f(e)?.setEffectiveWeight(Math.max(0,t))},speed(e,t){let n=f(e);n&&(n.timeScale=t)},time(e,t){let n=f(e);n&&(n.paused=!0,n.time=Math.max(0,t))}},g=l.animation??{},_=()=>{t.stopAllAction(),n=null,d(g.clip??0,g),g.offset&&n&&(n.time=Math.max(0,g.offset));for(let[e,t]of Object.entries(g.blend??{}))m.weight(e,t);t.update(0)};v={mixer:t,clips:p.animations,play:d,control:m,reset:_},_()}return{object:g,animator:v}}export{p as buildModel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./assets-
|
|
1
|
+
import{r as e}from"./assets-DICv7P37.js";import{Bt as t,In as n,Ln as r,Rn as i,St as a,U as o,bt as s,ct as c,d as l,h as u,kt as d,lt as f,m as p,mn as ee,on as m,rn as te,x as ne,xt as h,yt as re}from"./three.module-B9FlcKtd.js";import{n as g,r as _,t as ie}from"./num-CQNAlL82.js";import{C as v,f as y,w as b}from"./index-cDbmaVDl.js";var x={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function ae(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??x.width;return{width:o,height:o/r}}var S=[`zoom`,`dolly`,`pan`,`rise`,`vertigo`],C=[`pan`,`rise`];function w(e,t){let n=g(t,0,1),r=2*Math.PI*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:return{x:.8*Math.sin(r),y:.8*Math.cos(r),zoom:0};case`zoom`:return{x:0,y:0,zoom:n};case`dolly`:return{x:0,y:.12*n,zoom:1.1*n,push:.12*n};case`pan`:return{x:.85*(2*n-1),y:0,zoom:.15,push:.03};case`rise`:return{x:0,y:.8*(2*n-1),zoom:.2+.25*n,push:.03+.03*n};case`vertigo`:return{x:0,y:0,zoom:0,push:.03*n,vertigo:n};default:return{x:0,y:0,zoom:0}}}function oe(e,t,n,r={}){let i=e??`sway`;if(i===`none`)return{x:0,y:0,zoom:0};let a=Math.max(0,t);if(r.loop===!1){let e=r.duration&&r.duration>0?r.duration:a>0?10/a:0,t=e>0?g(n/e,0,1):0;return w(i,.5-.5*Math.cos(Math.PI*t))}let o=2*Math.PI*a/10*n;if(i===`orbit`){let e=Math.min(1,o/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(o),y:t*Math.cos(o),zoom:0}}return S.includes(i)?w(i,C.includes(i)?.5+.5*Math.sin(o):.5-.5*Math.cos(o)):w(i,o/(2*Math.PI)%1)}function se(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,_(e?.speed,x.speed)),smoothing:g(_(e?.smoothing,x.smoothing),0,.99),loop:e?.loop!==!1,duration:Math.max(0,_(e?.duration,0)),progress:typeof e?.progress==`number`&&Number.isFinite(e.progress)?g(e.progress,0,1):null}}function T(e,t){let n=t.progress??e.progress,r=n!==null,i=t.reduced?{x:0,y:0,zoom:0}:r?w(e.auto,n):oe(e.auto,e.speed,t.t,e),a=e.pointer*(t.reduced?.5:1),o=0,s=0,c=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(o=t.gyro.x,s=t.gyro.y,c=+(a>0)):a>0&&(o=t.pointer.x,s=t.pointer.y,c=g(t.pointer.weight,0,1));let l=i.x*(1-c)+o*a*c,u=i.y*(1-c)+s*a*c;e.scroll>0&&(u+=(g(t.scroll,0,1)*2-1)*e.scroll);let d=r?1:1-c,f={x:g(l,-1,1),y:g(u,-1,1),zoom:i.zoom*d};return i.push&&(f.push=i.push*d),i.vertigo&&(f.vertigo=i.vertigo*d),f}var E=1.5;function ce(e,t){let n=e.zoom-E*(e.vertigo??0),r=(1-.06*e.zoom)/((1+(e.push??0))*(1-.06*n));return{zoom:n,inset:[t[0]*r,t[1]*r]}}function D(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-g(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function O(e,t,n){let r=g(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 k(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:g(i/20,-1,1),y:g(-a/20,-1,1)}}function le(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))))}function ue(e,t){let{live:n}=t,r={x:0,y:0,weight:0,init:!1},i=null,a=null,o=null;if(n&&e.gyro&&e.pointer>0&&!t.flat&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;a??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;i=k(e.beta,e.gamma,a,t)};window.addEventListener(`deviceorientation`,e),o=()=>window.removeEventListener(`deviceorientation`,e)}return{offset(t,a,o){let s=o.pointer,c=s.inside?g(s.x,-1,1):0,l=s.inside?g(s.y,-1,1):0,u=+!!s.inside;return!n||!r.init?(r.x=c,r.y=l,r.weight=u,r.init=n):(r.x=D(r.x,c,a,e.smoothing),r.y=D(r.y,l,a,e.smoothing),r.weight=D(r.weight,u,a,e.smoothing)),T(e,{t,pointer:r,gyro:n?i:null,scroll:o.scroll,reduced:o.reduced,progress:o.progress})},dispose(){o?.(),o=null}}}var A=`
|
|
2
2
|
uniform sampler2D uMap;
|
|
3
3
|
uniform vec3 uTint;
|
|
4
4
|
uniform float uOpacity;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,At as t,Bn as n,Bt as r,E as i,Et as a,Fn as o,I as s,In as c,It as l,Jt as u,Ln as d,Mn as f,Nn as p,Pn as m,S as h,V as g,W as _,Xt as v,an as y,bt as b,ct as x,d as S,h as C,k as w,on as T,tn as E,vt as D,wn as O,x as k,xt as A}from"./three.module-B9FlcKtd.js";import{_ as ee,b as te,x as j}from"./index-
|
|
1
|
+
import{A as e,At as t,Bn as n,Bt as r,E as i,Et as a,Fn as o,I as s,In as c,It as l,Jt as u,Ln as d,Mn as f,Nn as p,Pn as m,S as h,V as g,W as _,Xt as v,an as y,bt as b,ct as x,d as S,h as C,k as w,on as T,tn as E,vt as D,wn as O,x as k,xt as A}from"./three.module-B9FlcKtd.js";import{_ as ee,b as te,x as j}from"./index-cDbmaVDl.js";import{r as M}from"./num-CQNAlL82.js";import{f as N,y as P}from"./camera-HsMeC1mn.js";var F=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},ne=new l(-1,1,1,-1,0,1),I=new class extends C{constructor(){super(),this.setAttribute(`position`,new s([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new s([0,2,0,0,2,0],2))}},L=class{constructor(e){this._mesh=new A(I,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ne)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},R={1:`LINEAR_TONE_MAPPING`,2:`REINHARD_TONE_MAPPING`,3:`CINEON_TONE_MAPPING`,4:`ACES_FILMIC_TONE_MAPPING`,6:`AGX_TONE_MAPPING`,7:`NEUTRAL_TONE_MAPPING`,5:`CUSTOM_TONE_MAPPING`},z=`
|
|
2
2
|
vec4 a3dSanitize(vec4 c) {
|
|
3
3
|
bvec4 bad = bvec4(isnan(c.r) || isinf(c.r), isnan(c.g) || isinf(c.g), isnan(c.b) || isinf(c.b), isnan(c.a) || isinf(c.a));
|
|
4
4
|
c = vec4(bad.r ? 0.0 : c.r, bad.g ? 0.0 : c.g, bad.b ? 0.0 : c.b, bad.a ? 1.0 : c.a);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./shaders-
|
|
2
|
-
import{n as e}from"./rolldown-runtime-4tVxZq34.js";import{E as t,S as n,b as r,g as i,h as a,m as o,p as s,t as c,v as l,y as u}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./shaders-DoRMwJE_.js","./three.module-B9FlcKtd.js","./rolldown-runtime-4tVxZq34.js","./params-BZqUA__U.js","./catalog-DDg904x2.js","./generators-C4n9MsXd.js","./camera-HsMeC1mn.js","./num-CQNAlL82.js","./index-cDbmaVDl.js","./index-D-TPNQMQ.css","./BufferGeometryUtils-BbzK4rCj.js","./RectAreaLightUniformsLib-S0AelTmO.js","./Sky-D8Lp9Zh3.js","./HDRLoader-8EiZoQQP.js","./EXRLoader-CuDOo1xG.js","./GroundedSkybox-cLn9JVlt.js","./RoomEnvironment-v4QurKxu.js","./text-BkPPDghK.js","./assets-DICv7P37.js","./extrude-BpJda0hq.js","./svg-n3rkKAm5.js","./photo-CPGGCRa-.js","./model-CkPfLOl0.js","./game-DnnuBk26.js","./postfx-Dp7mgfGJ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e}from"./rolldown-runtime-4tVxZq34.js";import{E as t,S as n,b as r,g as i,h as a,m as o,p as s,t as c,v as l,y as u}from"./index-cDbmaVDl.js";import{$t as d,B as f,Bn as p,Bt as m,C as h,Cn as g,Ct as _,Dn as v,Dt as y,E as b,En as x,Et as S,Ft as C,G as ee,H as te,In as w,It as ne,Jt as re,K as ie,Kt as T,Ln as E,M as ae,Mn as oe,N as D,Nn as se,Ot as O,P as ce,Pt as le,Qt as ue,R as de,St as fe,T as pe,Tt as me,U as he,Ut as ge,Vt as _e,W as ve,Y as ye,_ as be,_t as xe,an as Se,bt as k,cn as Ce,ct as we,d as A,dt as Te,g as Ee,gn as De,h as Oe,hn as ke,i as Ae,j,kn as je,lt as Me,m as Ne,mn as Pe,n as Fe,nn as Ie,o as Le,on as M,p as Re,r as ze,rn as N,sn as Be,t as Ve,tn as He,tt as Ue,v as We,vn as P,wn as Ge,wt as Ke,x as F,xt as I,y as qe,z as Je}from"./three.module-B9FlcKtd.js";import{_ as Ye,a as Xe,c as Ze,i as Qe,s as $e}from"./catalog-DDg904x2.js";import{_ as L,a as et,b as R,c as tt,f as z,g as nt,h as rt,i as it,l as at,m as ot,n as st,p as ct,r as lt,t as ut,v as dt,x as ft,y as B}from"./camera-HsMeC1mn.js";import{n as pt,r as V,t as H}from"./num-CQNAlL82.js";import{r as mt}from"./assets-DICv7P37.js";import{n as ht}from"./params-BZqUA__U.js";function gt(e){return e.endsWith(`/`)?e:e+`/`}function _t(e){let t=gt(e.assetBase??`./`),n=gt(e.libraryBase??t+`assets/library/`),r=e.assetUrls??{};return e=>{if(r[e])return r[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`),r[`library:`+t]?r[`library:`+t]:n+t}return t+e.replace(/^\.\//,``)}}var vt={map:`color`,emissiveMap:`color`,normalMap:`normal`,roughnessMap:`data`,metalnessMap:`data`,aoMap:`data`,bumpMap:`data`,displacementMap:`data`,alphaMap:`data`},yt=class{perm=new Uint16Array(512);grads=new Float32Array(512);constructor(e){let t=et(e),n=Array.from({length:256},(e,t)=>t);for(let e=255;e>0;e--){let r=Math.floor(t.next()*(e+1));[n[e],n[r]]=[n[r],n[e]]}for(let e=0;e<512;e++)this.perm[e]=n[e&255];for(let e=0;e<256;e++){let n=t.next()*Math.PI*2;this.grads[e*2]=Math.cos(n),this.grads[e*2+1]=Math.sin(n)}}g(e,t,n,r,i,a){let o=(e%n+n)%n,s=(t%r+r)%r,c=this.perm[this.perm[o&255]+s&511]&255;return this.grads[c*2]*i+this.grads[c*2+1]*a}noise(e,t,n,r){let i=Math.floor(e),a=Math.floor(t),o=e-i,s=t-a,c=o*o*o*(o*(o*6-15)+10),l=s*s*s*(s*(s*6-15)+10),u=this.g(i,a,n,r,o,s),d=this.g(i+1,a,n,r,o-1,s),f=this.g(i,a+1,n,r,o,s-1),p=this.g(i+1,a+1,n,r,o-1,s-1);return(u+(d-u)*c+(f-u)*l+(u-d-f+p)*c*l)*1.4}fbm(e,t,n,r,i=n){let a=0,o=.5,s=0,c=n,l=i;for(let n=0;n<r;n++)a+=o*this.noise(e*c,t*l,c,l),s+=o,o*=.5,c*=2,l*=2;return a/s}},U=(e,t,n)=>{let r=Math.imul(e|0,374761393)+Math.imul(t|0,668265263)+Math.imul(n|0,2246822519)|0;return r=Math.imul(r^r>>>13,1274126177),r^=r>>>16,(r>>>0)/4294967296},W=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e||1e-6)));return r*r*(3-2*r)},G=e=>e-Math.floor(e);function bt(e,t,n,r,i){let a=e*n,o=t*n,s=Math.floor(a),c=Math.floor(o),l=9,u=9,d=0,f=0;for(let e=-1;e<=1;e++)for(let t=-1;t<=1;t++){let p=s+t,m=c+e,h=(p%n+n)%n,g=(m%n+n)%n,_=p+.5+(U(h,g,i)-.5)*r,v=m+.5+(U(h,g,i+17)-.5)*r,y=Math.hypot(_-a,v-o);y<l?(u=l,l=y,d=h,f=g):y<u&&(u=y)}return{f1:l,f2:u,cx:d,cy:f}}var xt={marble(e,t){let n=e.num(`scale`),r=Math.max(1,Math.round(2*n)),i=2+e.num(`veins`)*22,a=e.num(`turbulence`);return{h(e,n){let o=t.fbm(e,n,r*2,5),s=t.fbm(e+.37,n+.71,r*2,5),c=t.fbm(e+o*.12*a,n+s*.12*a,r*3,6),l=(e*.6+n)*r+a*2.6*c,u=(1-Math.abs(Math.sin(Math.PI*l)))**i,d=t.fbm(e+.5,n,r*6,5),f=(1-Math.abs(Math.sin(Math.PI*(l*2.3+d*3))))**(i*2.5)*.45,p=(t.fbm(e,n+.3,r*2,4)*.5+.5)*.18;return Math.min(1,u*.9+f+p)}}},wood(e,t){let n=e.num(`scale`),r=e.num(`rings`),i=e.num(`grain`),a=Math.max(1,Math.round(n));return{h(e,o){let s=t.fbm(e,o,2*a,4,1*a),c=G(e*Math.round(r*n)+s*1.8),l=W(0,.7,c)*(1-W(.85,1,c)),u=t.noise(e*64*a,o*3*a,64*a,3*a)*.5+.5;return Math.min(1,Math.max(0,l*.75+u*i*.35+(s*.5+.5)*.15))}}},terrazzo(e,t,n){let r=Math.max(2,Math.round(10*e.num(`scale`)/e.num(`chipSize`))),i=e.num(`density`),a=Math.max(1,e.colors(`colors`).length-1),o=(e,o)=>{let s=bt(e,o,r,1,n);if(U(s.cx,s.cy,n+5)>i)return{m:0,idx:-1};let c=.18+U(s.cx,s.cy,n+9)*.3,l=s.f1+t.noise(e*r*4,o*r*4,r*4,r*4)*.08;return{m:1-W(c-.03,c+.01,l),idx:1+Math.floor(U(s.cx,s.cy,n+3)*a)}};return{h(e,t){return o(e,t).m},pick(e,t){let n=o(e,t);return n.m>.5?n.idx:-1}}},carbon(e,t){let n=Math.max(2,Math.round(8*e.num(`scale`)));return{h(e,r){let i=e*n,a=r*n,o=Math.floor(i),s=Math.floor(a),c=i-o,l=a-s,u=((o+s)%4+4)%4<2,d=u?l:c,f=u?e:r,p=Math.sin(Math.PI*d),m=t.noise(f*n*2,d*40,n*2,40)*.5+.5;return Math.min(1,p*(u?.85:.45)*(.75+m*.25))}}},noise(e,t){let n=Math.max(1,Math.round(4*e.num(`scale`))),r=e.int(`octaves`),i=e.num(`contrast`);return{h:(e,a)=>Math.min(1,Math.max(0,.5+t.fbm(e,a,n,r)*.5*i*1.6))}},voronoi(e,t,n){let r=Math.max(1,Math.round(8*e.num(`scale`))),i=e.num(`jitter`);return{h(e,t){let a=bt(e,t,r,i,n);return W(0,.25,a.f2-a.f1)}}},flakes(e,t,n){let r=Math.max(4,Math.round(64*e.num(`scale`))),i=e.num(`strength`);return{h(e,t){return U(Math.floor(e*r),Math.floor(t*r),n)},normal(e,t,a){let o=bt(e,t,r,1,n),s=U(o.cx,o.cy,n+1)*Math.PI*2,c=Math.sqrt(U(o.cx,o.cy,n+2))*i,l=Math.cos(s)*c,u=Math.sin(s)*c;a[0]=l,a[1]=u,a[2]=Math.sqrt(Math.max(0,1-l*l-u*u))}}},brushed(e,t){let n=Math.max(1,Math.round(e.num(`scale`))),r=e.num(`streaks`),i=Math.max(8,Math.round(300*r*n));return{h(e,r){let a=t.noise(e*2*n,r*i,2*n,i)*.5+.5,o=t.noise(e*6*n,r*i*2.5,6*n,Math.round(i*2.5))*.5+.5,s=t.fbm(e,r,3*n,3)*.5+.5;return Math.min(1,Math.max(0,a*.5+o*.3+s*.2))}}},grid(e,t,n,r){let i=Math.max(1,Math.round(e.int(`cells`)*e.num(`scale`))),a=i/r,o=Math.max(e.num(`lineWidth`)*.5,a*.75);return{h(e,t){let n=G(e*i),r=G(t*i),s=Math.min(n,1-n,r,1-r);return 1-W(o-a*.5,o+a*.5,s)}}},checker(e){let t=Math.max(1,Math.round(e.int(`cells`)*e.num(`scale`)));return{h:(e,n)=>Math.floor(e*t)+Math.floor(n*t)&1?1:0}},stripes(e){let t=Math.max(1,Math.round(e.int(`count`)*e.num(`scale`))),n=e.num(`angle`)*Math.PI/180,r=Math.round(Math.cos(n)*t),i=Math.round(Math.sin(n)*t),a=Math.max(.002,e.num(`softness`));return{h(e,t){let n=Math.abs(G(e*r+t*i)-.5)*2;return W(.5-a*2,.5+a*2,n)}}},dots(e){let t=Math.max(1,Math.round(e.int(`cells`)*e.num(`scale`))),n=e.num(`radius`);return{h(e,r){let i=G(e*t)-.5,a=G(r*t)-.5;return 1-W(n-.02,n+.01,Math.hypot(i,a))}}}};Object.keys(xt);var St=e=>{let t=e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;return Math.max(0,Math.min(255,Math.round(t*255)))},Ct=new Map;function wt(e){return 2**Math.round(Math.log2(Math.max(32,Math.min(2048,e))))}function Tt(e,t){let n=t+`:`+JSON.stringify(e),r=Ct.get(n);if(r)return r;let i=Ye.find(t=>t.id===e.procedural),a=xt[e.procedural];if(!i||!a)throw Error(`Unknown procedural texture "${e.procedural}"`);let o=ht(i,e),s=o.int(`seed`),c=wt(o.int(`resolution`)),l=a(o,new yt(s),s,c),u=new Uint8Array(c*c*4),d=new Float32Array(c*c);for(let e=0;e<c;e++){let t=(e+.5)/c;for(let n=0;n<c;n++)d[e*c+n]=l.h((n+.5)/c,t)}if(t===`color`){let e=o.colors(`colors`).map(e=>[e.r,e.g,e.b]),t=e.length;for(let n=0;n<c;n++)for(let r=0;r<c;r++){let i=n*c+r,a,o,s,f=l.pick?l.pick((r+.5)/c,(n+.5)/c):-1;if(f>=0)[a,o,s]=e[Math.min(f,t-1)];else if(l.pick)[a,o,s]=e[0];else{let n=Math.min(1,Math.max(0,d[i]))*(t-1),r=Math.min(t-2,Math.floor(n)),c=t>1?n-r:0,l=e[Math.max(0,r)],u=e[Math.min(t-1,r+1)];a=l[0]+(u[0]-l[0])*c,o=l[1]+(u[1]-l[1])*c,s=l[2]+(u[2]-l[2])*c}u[i*4]=St(a),u[i*4+1]=St(o),u[i*4+2]=St(s),u[i*4+3]=255}}else if(t===`normal`){let e=[0,0,1],t=c/256*2;for(let n=0;n<c;n++)for(let r=0;r<c;r++){let i=n*c+r,a,o,s;if(l.normal)l.normal((r+.5)/c,(n+.5)/c,e),[a,o,s]=e;else{let e=(e,t)=>d[(t+c)%c*c+(e+c)%c],i=(e(r+1,n-1)+2*e(r+1,n)+e(r+1,n+1)-e(r-1,n-1)-2*e(r-1,n)-e(r-1,n+1))/8,l=(e(r-1,n+1)+2*e(r,n+1)+e(r+1,n+1)-e(r-1,n-1)-2*e(r,n-1)-e(r+1,n-1))/8;a=-i*t,o=-l*t,s=1;let u=Math.hypot(a,o,s);a/=u,o/=u,s/=u}u[i*4]=Math.round((a*.5+.5)*255),u[i*4+1]=Math.round((o*.5+.5)*255),u[i*4+2]=Math.round((s*.5+.5)*255),u[i*4+3]=255}}else for(let e=0;e<c*c;e++){let t=Math.round(Math.min(1,Math.max(0,d[e]))*255);u[e*4]=u[e*4+1]=u[e*4+2]=t,u[e*4+3]=255}let f={data:u,size:c};return Ct.size>64&&Ct.clear(),Ct.set(n,f),f}function Et(e,t){let n=Tt(e,t),r=new b(n.data,n.size,n.size,re,se);return r.colorSpace=t===`color`?N:``,r.wrapS=r.wrapT=He,r.magFilter=we,r.minFilter=Me,r.generateMipmaps=!0,r.anisotropy=4,r.needsUpdate=!0,r.name=`procedural:${e.procedural}`,r}var Dt=`
|
|
3
3
|
float a3dToonBand( float x ) {
|
|
4
4
|
float w = max( fwidth( x ), 1e-3 ) * 0.75;
|
|
5
5
|
return 0.5 * smoothstep( - w, w, x ) + 0.5 * smoothstep( 0.42 - w, 0.42 + w, x );
|
|
@@ -129,7 +129,7 @@ uniform float uA3dGemIor; uniform float uA3dGemDisp; uniform vec3 uA3dGemTint; u
|
|
|
129
129
|
:host([status="unsupported"]) .poster,:host([status="error"]) .poster{opacity:1}
|
|
130
130
|
@media (prefers-reduced-motion:reduce){.loading.indeterminate .bar{animation:none;width:100%;opacity:.3}.poster{transition:none}}
|
|
131
131
|
@media print{::slotted(canvas),::slotted(img){visibility:hidden}.print{display:block}.loading{display:none}.poster{opacity:1}}
|
|
132
|
-
`,rn=null;function an(e){try{return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`}catch{return!1}}function on(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``);return!t||!(Number(t[1])>0)||!(Number(t[2])>0)?null:`${t[1]} / ${t[2]}`}function sn(){let e=typeof navigator<`u`?navigator:{};if(e.connection?.saveData)return`low`;let t=e.hardwareConcurrency??8,n=e.deviceMemory??8;return t<=2||n<=2?`low`:t<=4||n<=4?`medium`:`high`}function cn(e,t){let n=e;if(t.data&&Object.keys(t.data).length&&(n={...n,data:{...n.data??{},...t.data}}),t.loop!=null&&n.timeline){let e=t.loop.trim().toLowerCase(),r=e===`pingpong`?`pingpong`:e!==`false`&&e!==`0`&&e!==`no`;n={...n,timeline:{...n.timeline,loop:r}}}let r=t.quality?t.quality===`auto`?sn():t.quality:null;if((t.quality===`low`||t.quality===`medium`||t.quality===`high`||t.quality===`ultra`)&&(n={...n,target:{...n.target,quality:t.quality}}),r===`low`||r===`medium`||r===`high`){let e=r===`low`?1:r===`medium`?1.5:2,t={...n.target,maxDpr:Math.min(n.target?.maxDpr??2,e)};r===`low`&&Object.assign(t,{antialias:!1,shadows:!1}),n={...n,target:t,...r===`low`?{postfx:void 0}:{}}}return J(n)}var ln=class extends tn{static get observedAttributes(){return[`src`,`poster`,`aspect`,`alt`,`paused`,`loop`,`quality`,`library-base`]}player=null;ready;resolveReady;root=null;posterEl=null;posterBox=null;printEl=null;loadingEl=null;barEl=null;fallbackEl=null;sizeStyle=null;sizeSheet=null;sizeCssText=``;loadToken=0;connected=!1;source=null;dataOverrides={};dataObserver=null;interObs=null;inView=!0;lostTimer=null;wantPlay=null;autoAriaLabel=null;constructor(){super(),this.resetReady()}readySettled=!1;resetReady(){this.readySettled=!1,this.ready=new Promise(e=>this.resolveReady=e)}connectedCallback(){this.connected=!0,this.ensureShadow(),this.updatePoster(),this.applyAspect(null),this.ownerDocument.defaultView?.addEventListener(`beforeprint`,this.onBeforePrint),this.addEventListener(`webglcontextlost`,this.onContextLost,!0),this.addEventListener(`webglcontextrestored`,this.onContextRestored,!0),typeof MutationObserver<`u`&&(this.dataObserver=new MutationObserver(e=>{e.some(e=>e.attributeName?.startsWith(`data-`))&&this.refreshData()}),this.dataObserver.observe(this,{attributes:!0})),typeof IntersectionObserver<`u`&&(this.interObs=new IntersectionObserver(e=>this.inView=e.some(e=>e.isIntersecting)),this.interObs.observe(this)),this.load()}disconnectedCallback(){this.connected=!1,this.loadToken++,this.ownerDocument.defaultView?.removeEventListener(`beforeprint`,this.onBeforePrint),this.removeEventListener(`webglcontextlost`,this.onContextLost,!0),this.removeEventListener(`webglcontextrestored`,this.onContextRestored,!0),this.dataObserver?.disconnect(),this.dataObserver=null,this.interObs?.disconnect(),this.interObs=null,this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null,this.player?.dispose(),this.player=null,this.setStatus(`idle`)}attributeChangedCallback(e,t,n){this.connected&&t!==n&&(e===`poster`||e===`alt`?this.updatePoster():e===`aspect`?this.applyAspect(this.source):e===`paused`?n===null?this.getAttribute(`status`)===`ready`&&this.player?.play():this.player?.pause():e===`src`?(this.source=null,this.load()):this.rebuild())}play(){this.wantPlay=!0,this.hasAttribute(`paused`)&&this.removeAttribute(`paused`),this.player?.play()}pause(){this.wantPlay=!1,this.player?.pause()}async seek(e){await(this.player??await this.ready).seek(e)}get data(){return{...this.source?.data??{},...this.attrData(),...this.dataOverrides}}async setData(e,t={}){this.dataOverrides=t.replace?{...e}:{...this.dataOverrides,...e},await this.rebuild()}trigger(e,t){this.player?.emit?this.player.emit(e,t):this.ready.then(n=>n.emit?.(e,t))}reload(){return this.source=null,this.load()}ensureShadow(){if(this.root||typeof this.attachShadow!=`function`)return;let e=this.ownerDocument;this.root=this.shadowRoot??this.attachShadow({mode:`open`});let t=[];if(an(this.root))rn||(rn=new CSSStyleSheet,rn.replaceSync(nn)),this.sizeSheet=new CSSStyleSheet,this.root.adoptedStyleSheets=[rn,this.sizeSheet];else{let n=e.createElement(`style`);n.textContent=nn,this.sizeStyle=e.createElement(`style`),t=[n,this.sizeStyle]}let n=e.createElement(`slot`);this.posterBox=e.createElement(`div`),this.posterBox.className=`poster`,this.posterBox.setAttribute(`part`,`poster`);let r=e.createElement(`slot`);r.name=`poster`,this.posterEl=e.createElement(`img`),this.posterEl.setAttribute(`part`,`poster-image`),this.posterEl.decoding=`async`,r.appendChild(this.posterEl),this.posterBox.appendChild(r),this.printEl=e.createElement(`img`),this.printEl.className=`print`,this.printEl.alt=``,this.loadingEl=e.createElement(`div`),this.loadingEl.className=`loading indeterminate`,this.loadingEl.setAttribute(`part`,`loading`),this.loadingEl.setAttribute(`aria-hidden`,`true`),this.barEl=e.createElement(`div`),this.barEl.className=`bar`,this.barEl.setAttribute(`part`,`loading-bar`),this.loadingEl.appendChild(this.barEl),this.fallbackEl=e.createElement(`div`),this.fallbackEl.className=`fallback`,this.fallbackEl.setAttribute(`part`,`fallback`);let i=e.createElement(`slot`);i.name=`fallback`,this.fallbackEl.appendChild(i),this.root.append(...t,n,this.posterBox,this.printEl,this.loadingEl,this.fallbackEl)}updatePoster(){let e=this.posterEl;if(!e)return;let t=this.getAttribute(`poster`);e.alt=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``,t?e.getAttribute(`src`)!==t&&(e.src=t):e.removeAttribute(`src`),this.posterBox&&(this.posterBox.hidden=!this.posterSrc()),this.updateFallbackText()}posterSrc(){let e=this.querySelector(`[slot="poster"]`),t=e?.tagName===`IMG`?e:e?.querySelector(`img`);return t?.currentSrc||t?.getAttribute(`src`)||this.getAttribute(`poster`)}updateFallbackText(){let e=this.fallbackEl;if(!e)return;let t=e.querySelector(`slot`),n=!!this.querySelector(`[slot="fallback"]`),r=!!this.posterSrc();e.classList.toggle(`show`,n||!r),t&&!n&&(t.textContent=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``)}setStatus(e){e===`idle`?this.removeAttribute(`status`):this.setAttribute(`status`,e),(e===`unsupported`||e===`error`)&&this.updateFallbackText()}progress(e,t){this.loadingEl&&this.barEl&&t>0&&(this.loadingEl.classList.remove(`indeterminate`),this.barEl.style.width=`${Math.round(Math.min(e,t)/t*100)}%`),this.emit(`agent3d:progress`,{loaded:e,total:t})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}fail(e){this.emit(`agent3d:error`,e),this.emit(`agent3d-error`,e)}onBeforePrint=()=>{let e=this.printEl;if(!e)return;let t=``;try{this.player&&this.getAttribute(`status`)===`ready`&&(t=this.player.snapshot(`image/png`))}catch{}(!t||t.length<32)&&(t=this.posterSrc()??``),t?e.src=t:e.removeAttribute(`src`)};onContextLost=e=>{this.player&&this.inView&&this.getAttribute(`status`)===`ready`&&(e.preventDefault(),this.fail({code:`context-lost`,message:`The WebGL context was lost; restoring.`}),this.setStatus(`loading`),this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{this.lostTimer=null,this.rebuild(!0)},3e3))};onContextRestored=()=>{this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null;let e=this.player;e&&e.update(e.scene).then(()=>this.setStatus(`ready`),()=>void this.rebuild(!0))};childJson(e){let t=this.querySelector(e);if(t?.textContent)try{return JSON.parse(t.textContent)}catch(e){this.fail({code:`invalid-scene`,message:`Invalid inline JSON: ${e.message}`});return}}attrData(){return en(this.dataset??{})}refreshData(){this.source&&this.rebuild()}base(){let e=this.getAttribute(`src`);return e?new URL(`.`,new URL(e,this.ownerDocument.baseURI)).href:this.ownerDocument.baseURI}async fetchScene(){let e=this.childJson(`script[type="application/json"]:not([data-assets])`);if(e)return e;let t=this.getAttribute(`src`);if(!t)return;let n=new URL(t,this.ownerDocument.baseURI).href,r=await fetch(n);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()}async load(){let e=++this.loadToken;if(!this.source){this.setStatus(`loading`);let t;try{if(t=await this.fetchScene(),!t&&this.ownerDocument.readyState===`loading`){if(await new Promise(e=>this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})),e!==this.loadToken)return;t=await this.fetchScene()}}catch(t){if(e!==this.loadToken)return;this.setStatus(`error`),this.fail({code:`scene-load`,message:`Cannot load ${this.getAttribute(`src`)}: ${t.message}`,path:this.getAttribute(`src`)??void 0});return}if(e!==this.loadToken)return;if(!t){this.setStatus(`idle`);return}this.source=t}await this.mount(e)}async rebuild(e=!1){if(!this.connected||!this.source)return;let t=this.player;if(t&&!e&&this.getAttribute(`status`)===`ready`&&this.getAttribute(`library-base`)===this.mountedLibraryBase){let e=this.sceneForMount();this.applySizing(e),await t.update(e)}else await this.mount(++this.loadToken)}sceneForMount(){return cn(this.source,{data:{...this.attrData(),...this.dataOverrides},loop:this.getAttribute(`loop`),quality:this.getAttribute(`quality`)})}mountedLibraryBase=null;async mount(e){this.player?.dispose(),this.player=null,this.readySettled&&this.resetReady(),this.setStatus(`loading`);let t=this.sceneForMount();this.applySizing(t);let n=this.childJson(`script[data-assets]`),r={};this.querySelectorAll(`script[type="text/agent3d-script"][data-path]`).forEach(e=>{r[e.getAttribute(`data-path`)]=e.textContent??``});let i=this.getAttribute(`library-base`);this.mountedLibraryBase=i;let a=this.mountPlayer(this,t,{assetBase:this.base(),libraryBase:i?new URL(i,this.ownerDocument.baseURI).href:void 0,assetUrls:n,scriptSources:Object.keys(r).length?r:void 0,onError:t=>{e===this.loadToken&&(t.code===`webgl-unavailable`&&this.setStatus(`unsupported`),this.fail(t))},onEvent:(t,n)=>e===this.loadToken&&this.emit(`agent3d:event`,{name:t,payload:n}),onClick:(t,n)=>e===this.loadToken&&this.emit(`agent3d:click`,{id:t,x:n.x,y:n.y}),onProgress:(t,n)=>e===this.loadToken&&this.progress(t,n)});this.player=a;try{await a.ready}catch{e===this.loadToken&&this.getAttribute(`status`)!==`unsupported`&&this.setStatus(`error`);return}if(e!==this.loadToken)return;let o=(this.getAttribute(`autoplay`)??``).toLowerCase();(this.hasAttribute(`paused`)||this.wantPlay===!1||this.wantPlay!==!0&&(o===`false`||o===`0`||o===`no`))&&a.pause(),this.setStatus(`ready`),this.readySettled=!0,this.resolveReady(a),this.emit(`agent3d:ready`,{player:a}),this.emit(`agent3d-ready`,{player:a})}applyAspect(e){if(!this.sizeStyle&&!this.sizeSheet)return;let t=e?.target,n;n=t?.height?`:host{height:${t.height}}`:t?.kind===`fullscreen`?`:host{height:100vh;height:100dvh}`:`:host{aspect-ratio:${on(e?t?.aspect??this.getAttribute(`aspect`):this.getAttribute(`aspect`)??`16:9`)??`16 / 9`}}`,this.sizeCssText!==n&&(this.sizeCssText=n,this.sizeSheet?this.sizeSheet.replaceSync(n):this.sizeStyle&&(this.sizeStyle.textContent=n))}applySizing(e){if(this.sizeStyle||this.sizeSheet)this.applyAspect(e);else{this.style.display||(this.style.display=`block`),this.style.width||(this.style.width=`100%`),this.style.position||(this.style.position=`relative`);let t=on(e.target?.aspect)??`16 / 9`;e.target?.height?this.style.height=e.target.height:this.style.aspectRatio=t}let t=e.target?.kind===`game`;this.setAttribute(`role`,t?`application`:`img`);let n=this.getAttribute(`aria-label`);(n===null||n===this.autoAriaLabel)&&(this.autoAriaLabel=e.ariaLabel||e.title||`3D scene`,this.setAttribute(`aria-label`,this.autoAriaLabel)),t&&!this.hasAttribute(`tabindex`)&&(this.tabIndex=0),this.updatePoster()}};function un(e,t=`agent3d-scene`){typeof customElements<`u`&&(customElements.get(t)||customElements.define(t,e))}var dn=null,fn=null;function pn(){return dn??=i(()=>import(`./shaders-WM5brr9C.js`).then(e=>e.SHADER_IMPLS),__vite__mapDeps([0,1,2,3,4]),import.meta.url),dn}function mn(){return fn??=i(()=>import(`./generators-lG93qWTO.js`).then(e=>e.GENERATOR_IMPLS),__vite__mapDeps([5,3,4,1,2,6,7,8,9,10]),import.meta.url),fn}function hn(e,t=[0,1,0]){let n=new E(...R(e,t));return n.lengthSq()<1e-9&&n.set(0,1,0),n.normalize()}function gn(e){return nt(e)}var Y=Math.PI*2,_n=(e,t)=>{let n=dt(e.effect,`scale`),r=Math.max(V(e.duration,.8),.001),i=dt(e.ease,`outBack`),a=n===`fade`?gn(t.object):[];for(let e of a)e.userData.baseOpacity===void 0&&(e.userData.baseOpacity=e.opacity),e.transparent=!0;return{update(e){let o=Math.min(Math.max(e/r,0),1),s=c(i,o),l=t.object;switch(n){case`fade`:for(let e of a)e.opacity=e.userData.baseOpacity*c(`outCubic`,o);break;case`rise`:l.position.y-=(1-s)*1,l.scale.multiplyScalar(Math.max(1e-4,Math.min(1,o*3)));break;case`drop`:l.position.y+=(1-s)*3,o<=0&&(l.visible=!1);break;case`spin`:l.rotation.y+=(1-s)*Y,l.scale.multiplyScalar(Math.max(1e-4,s));break;default:l.scale.multiplyScalar(Math.max(1e-4,s))}}}},vn=(e,t)=>{let n=z(e.lockY,!0),r=new E,i=new E;return{update(){t.object.getWorldPosition(r),t.camera.getWorldPosition(i),n?t.object.rotation.set(0,Math.atan2(i.x-r.x,i.z-r.z),0):t.camera.getWorldQuaternion(t.object.quaternion)}}},yn=(e,t)=>{let n=Math.max(V(e.interval,3),.05),r=V(e.duration,.15),i=z(e.random,!0);return{update(e){let a=Math.floor(e/n),o=i?rt(a+t.object.id)*(n-r)*.8:n-r,s=e-a*n;s>=o&&s<o+r&&(t.object.visible=!1)}}},bn=(e,t)=>{let n=V(e.amount,.04),r=Math.max(V(e.period,4),.1),i=V(e.phase,0),a=V(e.rise,.02);return{update(e){let o=(e/r+i)%1,s=o<.6?.5-.5*Math.cos(o/.6*Math.PI):.5+.5*Math.cos((o-.6)/.4*Math.PI);t.object.scale.x*=1+n*.5*s,t.object.scale.z*=1+n*.5*s,t.object.scale.y*=1+n*s,t.object.position.y+=a*s}}},xn=(e,t)=>{let n=V(e.height,.3),r=V(e.speed,1.5);return{update(e){let i=Math.abs(Math.sin(Math.PI*r*e));t.object.position.y+=n*i;let a=(1-i)*(1-i)*.08;t.object.scale.y*=1-a,t.object.scale.x*=1+a*.5,t.object.scale.z*=1+a*.5}}},Sn=(e,t)=>{let n=V(e.amount,.25),r=-1;return{update(e){if(t.clicked()&&(r=e),r<0)return;let i=e-r;if(i>1.5)return;let a=n*Math.exp(-5*i)*Math.sin(i*22);t.object.scale.y*=1-a,t.object.scale.x*=1+a*.5,t.object.scale.z*=1+a*.5}}};function Cn(e,t,n){if(t<=0||e<=0)return 0;if(n===`pingpong`){let n=e%(2*t);return n<=t?n:2*t-n}return n?e%t:Math.min(e,t)}var wn=new Map;function Tn(e){let t=wn.get(e);if(!t){t=new F;try{t.setStyle(e)}catch{t.set(16777215)}wn.size<1e3&&wn.set(e,t)}return t}var En=/^\s*([+\-*])=\s*(-?\d*\.?\d+(?:e[+-]?\d+)?)\s*$/i;function Dn(e){return typeof e==`string`&&En.test(e)}function X(e,t){if(typeof e==`number`)return e;let n=typeof e==`string`?En.exec(e):null;if(!n)return t;let r=Number(n[2]);return n[1]===`+`?t+r:n[1]===`-`?t-r:t*r}function On(e,t){let n=Array.isArray(t)?t:typeof t==`number`?[t,t,t]:null,r=typeof t==`number`?t:Array.isArray(t)?t[0]:0;return e.map(e=>{let[i,a,o]=e,s;return s=Array.isArray(a)?[X(a[0],n?.[0]??0),X(a[1],n?.[1]??0),X(a[2],n?.[2]??0)]:Dn(a)?n&&Array.isArray(t)?[X(a,n[0]),X(a,n[1]),X(a,n[2])]:X(a,r):a,o===void 0?[i,s]:[i,s,o]})}function kn(e){return Array.isArray(e)?[Number(e[0])||0,Number(e[1])||0,Number(e[2])||0]:typeof e==`number`?[e,e,e]:null}function An(e){let t=Math.cbrt(.4122214708*e.r+.5363325363*e.g+.0514459929*e.b),n=Math.cbrt(.2119034982*e.r+.6806995451*e.g+.1073969566*e.b),r=Math.cbrt(.0883024619*e.r+.2817188376*e.g+.6299787005*e.b);return[.2104542553*t+.793617785*n-.0040720468*r,1.9779984951*t-2.428592205*n+.4505937099*r,.0259040371*t+.7827717662*n-.808675766*r]}function jn(e,t,n,r){let i=(e+.3963377774*t+.2158037573*n)**3,a=(e-.1055613458*t-.0638541728*n)**3,o=(e-.0894841775*t-1.291485548*n)**3;return r.setRGB(Math.max(0,4.0767416621*i-3.3077115913*a+.2309699292*o),Math.max(0,-1.2684380046*i+2.6097574011*a-.3413193965*o),Math.max(0,-.0041960863*i-.7034186147*a+1.707614701*o),Te)}function Mn(e,t,n,r=`oklch`,i=new F){if(r===`rgb`)return i.copy(e).lerp(t,n);if(r===`oklch`){let r=An(e),a=An(t),o=Math.hypot(r[1],r[2]),s=Math.hypot(a[1],a[2]),c=Math.atan2(r[2],r[1]),l=Math.atan2(a[2],a[1]);o<1e-4&&(c=l),s<1e-4&&(l=c);let u=l-c;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI);let d=r[0]+(a[0]-r[0])*n,f=Math.max(0,o+(s-o)*n),p=c+u*n;return jn(d,f*Math.cos(p),f*Math.sin(p),i)}if(r===`hsl`){let r={h:0,s:0,l:0},a={h:0,s:0,l:0};e.getHSL(r),t.getHSL(a),r.s<1e-4&&(r.h=a.h),a.s<1e-4&&(a.h=r.h);let o=a.h-r.h;return o>.5?--o:o<-.5&&(o+=1),i.setHSL(((r.h+o*n)%1+1)%1,r.s+(a.s-r.s)*n,r.l+(a.l-r.l)*n)}let a=An(e),o=An(t);return jn(a[0]+(o[0]-a[0])*n,a[1]+(o[1]-a[1])*n,a[2]+(o[2]-a[2])*n,i)}function Nn(e,t,n,r){if(typeof e==`boolean`||typeof t==`boolean`)return n>=1?t:e;if(typeof e==`number`&&typeof t==`number`)return e+(t-e)*n;if(typeof e==`string`||typeof t==`string`)return Mn(Tn(String(e)),Tn(String(t)),n,r);let i=kn(e),a=kn(t);return[i[0]+(a[0]-i[0])*n,i[1]+(a[1]-i[1])*n,i[2]+(a[2]-i[2])*n]}function Pn(e){return typeof e==`string`?Tn(e).clone():Array.isArray(e)?[e[0],e[1],e[2]]:e}function Fn(e,t,n,r){let i=e;if(!i.length)return;if(t<=i[0][0])return Pn(i[0][1]);let a=i[i.length-1];if(t>=a[0])return Pn(a[1]);for(let e=0;e<i.length-1;e++){let[a,o]=i[e],[s,l,u]=i[e+1];if(t>=a&&t<s)return typeof o==`boolean`||typeof l==`boolean`?o:Nn(o,l,s>a?c(u??n??`linear`,(t-a)/(s-a)):1,r)}return Pn(a[1])}function In(e){let t=e.indexOf(`.`);return t<0?{id:e,path:``}:{id:e.slice(0,t),path:e.slice(t+1)}}function Ln(e,t,n=1){let r=Array.from({length:e},(e,t)=>t);switch(t){case`end`:return r.map(t=>e-1-t);case`center`:{let t=(e-1)/2;return r.map(e=>Math.abs(e-t))}case`edges`:{let t=(e-1)/2;return r.map(e=>t-Math.abs(e-t))}case`random`:{let t=[...r],i=n*2654435761>>>0||1;for(let n=e-1;n>0;n--){i=i*1664525+1013904223>>>0;let e=i%(n+1);[t[n],t[e]]=[t[e],t[n]]}let a=Array(e);return t.forEach((e,t)=>a[e]=t),a}default:return r}}var Rn=(e,t)=>{let n=ct(e.colors,[`#ff006e`,`#8338ec`,`#3a86ff`]).map(e=>B(e)),r=V(e.speed,.5),i=z(e.emissive,!1),a=gn(t.object),o=new F;return{update(e){let s=(e*r%n.length+n.length)%n.length,c=Math.floor(s),l=s-c,u=l*l*(3-2*l);Mn(n[c],n[(c+1)%n.length],u,`oklch`,o);let d=t.object;d.isLight&&d.color.copy(o);for(let e of a){let t=e;t.color?.copy(o),i&&t.emissive&&t.emissive.copy(o)}}}},zn=(e,t)=>{let[n,r,i]=R(e.area,[1,1,1]),a=V(e.speed,.3),o=V(e.seed,1)+t.object.id*.137,s=Array.from({length:6},(e,t)=>rt(o*13.1+t)*Math.PI*2),c=Array.from({length:6},(e,t)=>.6+rt(o*7.7+t*3.3)*.8),l=(e,t)=>.65*Math.sin(t*c[e]+s[e])+.35*Math.sin(t*c[e+3]*2.3+s[e+3]);return{update(e){let o=e*a;t.object.position.x+=n/2*l(0,o),t.object.position.y+=r/2*l(1,o*.9),t.object.position.z+=i/2*l(2,o*1.1)}}};function Bn(e,t){let n=Math.floor(e),r=e-n,i=rt(n+t*31.7);return i+(rt(n+1+t*31.7)-i)*r*r*(3-2*r)}var Vn=(e,t)=>{let n=pt(V(e.amount,.3),0,1),r=V(e.speed,8),i=t.object.id,a=gn(t.object);for(let e of a)e.userData.baseEmissiveIntensity===void 0&&(e.userData.baseEmissiveIntensity=e.emissiveIntensity??1);return{update(e){let o=.6*Bn(e*r,i)+.4*Bn(e*r*2.7,i+3),s=1-n*o,c=t.object;c.isLight&&(c.intensity*=s);for(let e of a)e.emissiveIntensity!==void 0&&(e.emissiveIntensity=e.userData.baseEmissiveIntensity*s)}}},Hn=(e,t)=>{let n=V(e.amplitude,.15),r=V(e.speed,.5),i=V(e.phase,0);return{update:e=>void(t.object.position.y+=n*Math.sin(Y*(r*e+i)))}},Un=(e,t)=>{let n=V(e.strength,.5),r=V(e.smoothing,.9),i=dt(e.mode,`rotate`),a=0,o=0;return{update(e,s){let c=L(r,s);a+=(t.pointer.x-a)*c,o+=(t.pointer.y-o)*c,(i===`move`||i===`both`)&&(t.object.position.x+=a*n,t.object.position.y+=o*n),(i===`rotate`||i===`both`)&&(t.object.rotation.y+=a*n*.8,t.object.rotation.x+=-o*n*.8)}}},Wn=(e,t)=>{let n=V(e.height,.2),r=V(e.tilt,10)*H,i=0,a=0,o=0;return{update(e,s){let c=L(.82,s);i+=(+!!t.hovered()-i)*c,a+=(t.pointer.x-a)*c,o+=(t.pointer.y-o)*c,t.object.position.y+=n*i,t.object.rotation.x+=-o*r*i,t.object.rotation.y+=a*r*i}}},Gn=(e,t)=>{let n=V(e.scale,1.15),r=V(e.smoothing,.8),i=1;return{update(e,a){i+=((t.hovered()?n:1)-i)*L(r,a),t.object.scale.multiplyScalar(i)}}},Kn=(e,t)=>{let n=V(e.smoothing,.85),r=z(e.lockY,!1),i=Array.isArray(e.point)&&e.point.length===3?new E(...e.point):null,a=typeof e.target==`string`?e.target:`camera`,o=new T,s=new T,c=new E,l=new E,u=new k,d=new T,f=!0;return{update(e,p){let m=i??(a===`camera`?t.camera:t.find?.(a));m&&(m instanceof E?l.copy(m):m.getWorldPosition(l),t.object.getWorldPosition(c),r&&(l.y=c.y),l.distanceToSquared(c)<1e-10||(u.lookAt(l,c,le.DEFAULT_UP),o.setFromRotationMatrix(u),t.object.parent&&o.premultiply(t.object.parent.getWorldQuaternion(d).invert()),s.slerp(o,f?1:L(n,p)),f=!1,t.object.quaternion.copy(s)))}}},qn=(e,t)=>{let n=V(e.maxAngle,35)*H,r=V(e.smoothing,.85),i=0,a=0;return{update(e,o){let s=L(r,o);i+=(t.pointer.x*n-i)*s,a+=(-t.pointer.y*n-a)*s,t.object.rotation.y+=i,t.object.rotation.x+=a}}},Jn=(e,t)=>{let n=Math.max(V(e.radius,.25),.001),r=V(e.strength,.4),i=new E,a=new E,o=new E,s=new E,c=new E;return{update(e,l){if(a.set(0,0,0),t.pointer.inside){t.object.getWorldPosition(o),s.copy(o).project(t.camera);let e=(t.pointer.x-s.x)/2,i=(t.pointer.y-s.y)/2,l=Math.hypot(e,i);if(l<n){c.set(t.pointer.x,t.pointer.y,s.z).unproject(t.camera),a.copy(c).sub(o);let e=a.length();e>1e-6&&a.multiplyScalar(Math.min(e,r)*(1-l/n)/e)}}i.lerp(a,L(.85,l)),t.object.position.add(i)}}},Yn=(e,t)=>{let[n,r,i]=R(e.amplitude,[.1,.1,.05]),[a,o,s]=R(e.rotation,[3,3,2]),c=V(e.speed,.3),l=V(e.seed,1)*13.37+t.rng.next()*100,u=(e,t)=>at(e*c+l,t*5.17)*.8+at(e*c*2.3+l,t*5.17+2.9)*.2;return{update(e){t.object.position.x+=u(e,0)*n,t.object.position.y+=u(e,1)*r,t.object.position.z+=u(e,2)*i,t.object.rotation.x+=u(e,3)*a*H,t.object.rotation.y+=u(e,4)*o*H,t.object.rotation.z+=u(e,5)*s*H}}},Xn=(e,t)=>{let n=new E(...R(e.center,[0,0,0])),r=V(e.radius,2),i=V(e.speed,30)*H,a=V(e.phase,0)*H,o=hn(e.axis),s=z(e.faceDirection,!1),c=Math.abs(o.y)<.99?new E(0,1,0):new E(1,0,0),l=new E().crossVectors(c,o).normalize(),u=new E().crossVectors(o,l).normalize(),d=new E;return{update(e){let c=a+i*e,f=t.object.position.dot(o)-n.dot(o);if(d.copy(n).addScaledVector(l,Math.cos(c)*r).addScaledVector(u,Math.sin(c)*r).addScaledVector(o,f),t.object.position.copy(d),s){let e=l.clone().multiplyScalar(-Math.sin(c)).addScaledVector(u,Math.cos(c)).multiplyScalar(Math.sign(i)||1),n=new T().setFromUnitVectors(new E(0,0,1),e.normalize());t.object.quaternion.premultiply(n)}}}},Zn=(e,t)=>{let n=V(e.depth,.5),r=V(e.pointer,.3),i=V(e.scroll,0),a=V(e.smoothing,.9),o=0,s=0;return{update(e,c){let l=L(a,c),u=t.pointer.inside?t.pointer.x:0,d=t.pointer.inside?t.pointer.y:0;o+=(u-o)*l,s+=(d-s)*l,t.object.position.x+=o*r*n,t.object.position.y+=s*r*n*.6+(t.scroll()-.5)*i*n}}},Qn=(e,t)=>{let n=(Array.isArray(e.points)?e.points:[]).filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new E(e[0],e[1],e[2])),r=z(e.loop,!0),i=z(e.faceDirection,!0),a=Math.max(V(e.duration,5),.001);if(n.length<2)return{update(){}};let o=new We(n,r,`catmullrom`,.5),s=new E,c=new E(0,0,1);return{update(e){let n=r?e/a%1:Math.min(e/a,1);o.getPointAt(n,t.object.position),i&&(o.getTangentAt(Math.min(n,.9999),s).normalize(),t.object.quaternion.setFromUnitVectors(c,s))}}},$n=(e,t)=>{let n=V(e.amount,.08),r=V(e.speed,1);return{update:e=>void t.object.scale.multiplyScalar(1+n*Math.sin(Y*r*e))}},er=(e,t)=>{let n=hn(e.axis),r=V(e.speed,45)*H;return{update:e=>void t.object.rotateOnAxis(n,r*e)}},tr=(e,t)=>{let[n,r,i]=R(e.offset,[0,2,0]);return{update(){let e=t.scroll();t.object.position.x+=n*e,t.object.position.y+=r*e,t.object.position.z+=i*e}}},nr=(e,t)=>{let n=hn(e.axis),r=V(e.degrees,360)*H;return{update:()=>void t.object.rotateOnAxis(n,r*t.scroll())}},rr=(e,t)=>{let n=hn(e.axis),r=Math.max(V(e.duration,.8),.001),i=e.trigger===`hover`,a=-1,o=!1;return{update(e){let s=a>=0&&e-a<r;if(i){let n=t.hovered();n&&!o&&!s&&(a=e),o=n}else t.clicked()&&!s&&(a=e);if(a<0)return;let l=(e-a)/r;l>=1||t.object.rotateOnAxis(n,Y*c(`inOutCubic`,l))}}};function ir(e,t,n,r,i,a,o=1){let s=Math.min(Math.max(r,0),2);for(;s>1e-9;){let r=Math.min(.004166666666666667,s),c=(-i*(e-n)-a*t)/o;t+=c*r,e+=t*r,s-=r}return[e,t]}var ar={rotate:er,float:Hn,bob:xn,pulse:$n,wobble:(e,t)=>{let n=V(e.amount,.08),r=V(e.speed,2);return{update(e){let i=Math.sin(Y*r*e*.5),a=Math.sin(Y*r*e*.5+Math.PI/2);t.object.scale.x*=1+n*i,t.object.scale.y*=1-n*i,t.object.scale.z*=1+n*a*.5}}},sway:(e,t)=>{let n=hn(e.axis,[0,0,1]),r=V(e.angle,8)*H,i=V(e.speed,.5);return{update:e=>void t.object.rotateOnAxis(n,r*Math.sin(Y*i*e))}},orbit:Xn,path:Qn,followPointer:Un,lookAtPointer:qn,hoverScale:Gn,hoverLift:Wn,clickBounce:Sn,spinOnClick:rr,scrollRotate:nr,scrollMove:tr,drift:zn,blink:yn,colorCycle:Rn,flicker:Vn,billboard:vn,appear:_n,magnet:Jn,spring:(e,t)=>{let n=V(e.strength,.4),r=Math.max(V(e.stiffness,120),1),i=Math.max(V(e.damping,12),0),a=Math.max(V(e.mass,1),.01),o=dt(e.mode,`move`),s=V(e.angle,15)*H,c={x:0,vx:0,y:0,vy:0};return{update(e,l){let u=t.pointer.inside?t.pointer.x:0,d=t.pointer.inside?t.pointer.y:0;[c.x,c.vx]=ir(c.x,c.vx,u,l,r,i,a),[c.y,c.vy]=ir(c.y,c.vy,d,l,r,i,a),(o===`move`||o===`both`)&&(t.object.position.x+=c.x*n,t.object.position.y+=c.y*n),(o===`rotate`||o===`both`)&&(t.object.rotation.y+=c.x*s,t.object.rotation.x+=-c.y*s)}}},parallax:Zn,tilt:(e,t)=>{let n=V(e.maxAngle,12)*H,r=V(e.scale,1.04),i=V(e.lift,.1),a=V(e.smoothing,.86),o=z(e.hoverOnly,!0),s=z(e.reverse,!1)?-1:1,c=0,l=0,u=0;return{update(e,d){let f=o?t.hovered():t.pointer.inside,p=L(a,d);u+=(+!!f-u)*p,c+=((f?t.pointer.x:0)-c)*p,l+=((f?t.pointer.y:0)-l)*p,t.object.rotation.y+=c*n*s,t.object.rotation.x+=-l*n*s,t.object.position.z+=i*u,t.object.scale.multiplyScalar(1+(r-1)*u)}}},breathe:bn,noise:Yn,lookAt:Kn},or=new Set([`appear`]),sr=1e6,cr=new Set([`billboard`,`lookAt`]),lr=new Set([`lookAt`,`magnet`,`spring`]),ur=1/30;function dr(e,t,n=ur){let r=[];for(let i=Math.floor(e/n+1e-6)+1;i*n<t-1e-6;i++)r.push(i*n);return r}function fr(e,t,n,r={}){let i=t(e,n),a=e.when??`always`,o=V(e.delay,0),s=0,c=-1;return{def:e,late:cr.has(e.type),stateful:lr.has(e.type),step(t,l){if(r.settled?.()&&or.has(e.type)&&(a===`always`||a===`visible`)){i.update(sr,l);return}let u;switch(a){case`hover`:n.hovered()&&(s+=l),u=s-o;break;case`click`:if(c<0&&n.clicked()&&(c=t),c<0)return;u=t-c-o;break;case`scroll`:u=n.scroll()*10-o;break;default:u=t-o}i.update(Math.max(0,u),l)},dispose(){i.dispose?.()}}}var pr={count:300,area:[10,6,6],size:.08,colors:[`#ffffff`],speed:.3,direction:[0,1,0],spread:.3,lifetime:0,opacity:1,blending:`additive`,shape:`soft`,twinkle:0,wander:.2,spin:0,gravity:[0,0,0],endColor:null,endSize:1,stretch:1,swirl:0},mr={stars:{count:900,area:[40,20,20],size:.09,colors:[`#ffffff`,`#cfe2ff`,`#ffe8c2`],speed:0,wander:0,twinkle:.8,shape:`point`,blending:`additive`},snow:{count:1200,area:[20,12,10],size:.08,colors:[`#ffffff`,`#eef6ff`],speed:.6,direction:[0,-1,0],spread:.3,wander:.35,shape:`soft`,blending:`normal`,opacity:.95},rain:{count:2200,area:[20,12,10],size:.05,colors:[`#c9ddff`,`#a9c4f0`],speed:9,direction:[-.06,-1,0],spread:.04,wander:0,shape:`streak`,stretch:9,blending:`normal`,opacity:.5},fireflies:{count:90,area:[10,4,6],size:.16,colors:[`#fff3a0`,`#d4ff7a`,`#ffe066`],speed:.08,spread:1,wander:.7,twinkle:.9,shape:`point`,blending:`additive`},confetti:{count:320,area:[12,8,6],size:.16,colors:[`#ff006e`,`#ffbe0b`,`#3a86ff`,`#8338ec`,`#06d6a0`,`#fb5607`],speed:1.3,direction:[0,-1,0],spread:.5,wander:.45,spin:.8,shape:`square`,blending:`normal`},sparks:{count:320,area:[.6,.2,.6],size:.035,colors:[`#fff6d0`,`#ffd27a`,`#ff9a3d`],speed:5,direction:[0,1,0],spread:.45,lifetime:1.2,wander:0,gravity:[0,-6,0],endColor:`#ff4d00`,endSize:.5,shape:`streak`,stretch:4,blending:`additive`},dust:{count:450,area:[12,6,8],size:.035,colors:[`#ffffff`,`#fff4dc`],speed:.04,spread:1,wander:.45,twinkle:.35,opacity:.6,shape:`soft`,blending:`additive`},bubbles:{count:160,area:[8,6,4],size:.22,colors:[`#d6f3ff`,`#a9e4ff`],speed:.8,direction:[0,1,0],spread:.25,wander:.18,shape:`bubble`,blending:`normal`,opacity:.85},embers:{count:220,area:[6,.6,4],size:.07,colors:[`#ffb347`,`#ff7b00`,`#ffd27a`],speed:1,direction:[0,1,0],spread:.45,lifetime:3.2,wander:.45,twinkle:.4,endColor:`#c81d00`,endSize:.4,shape:`point`,blending:`additive`},hearts:{count:60,area:[8,4,4],size:.32,colors:[`#ff4d6d`,`#ff8fa3`,`#ff006e`],speed:.6,direction:[0,1,0],spread:.3,lifetime:5,wander:.3,endSize:1.3,shape:`heart`,blending:`normal`},magic:{count:260,area:[6,4,3],size:.13,colors:[`#fff3b0`,`#e9d5ff`,`#a5f3fc`,`#fbcfe8`],speed:.25,direction:[0,1,0],spread:1,lifetime:3.5,wander:.35,twinkle:.9,spin:.15,endSize:.2,shape:`star`,blending:`additive`},smoke:{count:90,area:[1.2,.3,1.2],size:1.1,colors:[`#d9dde3`,`#c3c8d0`,`#eef0f3`],speed:.7,direction:[.12,1,0],spread:.25,lifetime:6,wander:.35,spin:.05,endSize:3.2,endColor:`#f4f5f7`,shape:`smoke`,blending:`normal`,opacity:.4},fire:{count:150,area:[.6,.1,.6],size:.42,colors:[`#ffd27a`,`#ffb347`,`#ff9a3d`],speed:1.9,direction:[0,1,0],spread:.1,lifetime:1,wander:.1,gravity:[0,.6,0],endColor:`#c81d00`,endSize:.12,shape:`smoke`,spin:.2,blending:`additive`,opacity:.5},petals:{count:140,area:[14,8,6],size:.27,colors:[`#ffc2d4`,`#ffb3c6`,`#ffe5ec`,`#ff8fab`],speed:.55,direction:[.35,-1,.1],spread:.4,wander:.6,spin:.35,shape:`petal`,blending:`normal`},leaves:{count:110,area:[14,8,6],size:.26,colors:[`#e76f51`,`#f4a261`,`#e9c46a`,`#bc4b2a`,`#8a9a2b`],speed:.7,direction:[.45,-1,.1],spread:.45,wander:.7,spin:.3,shape:`leaf`,blending:`normal`},galaxyDust:{count:1800,area:[16,2,16],size:.05,colors:[`#a5b4fc`,`#f0abfc`,`#93c5fd`,`#ffffff`],speed:0,wander:.15,twinkle:.5,swirl:.12,opacity:.8,shape:`soft`,blending:`additive`},bokeh:{count:26,area:[16,9,6],size:1.1,colors:[`#ffd6a5`,`#fdffb6`,`#caffbf`,`#9bf6ff`,`#bdb2ff`,`#ffc6ff`],speed:.05,spread:1,wander:.5,twinkle:.3,opacity:.32,shape:`ring`,blending:`additive`}},hr={point:0,square:1,circle:2,star:3,spark:4,heart:5,bubble:6,soft:7,streak:8,smoke:9,petal:10,leaf:11,ring:12},gr=`
|
|
132
|
+
`,rn=null;function an(e){try{return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`}catch{return!1}}function on(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``);return!t||!(Number(t[1])>0)||!(Number(t[2])>0)?null:`${t[1]} / ${t[2]}`}function sn(){let e=typeof navigator<`u`?navigator:{};if(e.connection?.saveData)return`low`;let t=e.hardwareConcurrency??8,n=e.deviceMemory??8;return t<=2||n<=2?`low`:t<=4||n<=4?`medium`:`high`}function cn(e,t){let n=e;if(t.data&&Object.keys(t.data).length&&(n={...n,data:{...n.data??{},...t.data}}),t.loop!=null&&n.timeline){let e=t.loop.trim().toLowerCase(),r=e===`pingpong`?`pingpong`:e!==`false`&&e!==`0`&&e!==`no`;n={...n,timeline:{...n.timeline,loop:r}}}let r=t.quality?t.quality===`auto`?sn():t.quality:null;if((t.quality===`low`||t.quality===`medium`||t.quality===`high`||t.quality===`ultra`)&&(n={...n,target:{...n.target,quality:t.quality}}),r===`low`||r===`medium`||r===`high`){let e=r===`low`?1:r===`medium`?1.5:2,t={...n.target,maxDpr:Math.min(n.target?.maxDpr??2,e)};r===`low`&&Object.assign(t,{antialias:!1,shadows:!1}),n={...n,target:t,...r===`low`?{postfx:void 0}:{}}}return J(n)}var ln=class extends tn{static get observedAttributes(){return[`src`,`poster`,`aspect`,`alt`,`paused`,`loop`,`quality`,`library-base`]}player=null;ready;resolveReady;root=null;posterEl=null;posterBox=null;printEl=null;loadingEl=null;barEl=null;fallbackEl=null;sizeStyle=null;sizeSheet=null;sizeCssText=``;loadToken=0;connected=!1;source=null;dataOverrides={};dataObserver=null;interObs=null;inView=!0;lostTimer=null;wantPlay=null;autoAriaLabel=null;constructor(){super(),this.resetReady()}readySettled=!1;resetReady(){this.readySettled=!1,this.ready=new Promise(e=>this.resolveReady=e)}connectedCallback(){this.connected=!0,this.ensureShadow(),this.updatePoster(),this.applyAspect(null),this.ownerDocument.defaultView?.addEventListener(`beforeprint`,this.onBeforePrint),this.addEventListener(`webglcontextlost`,this.onContextLost,!0),this.addEventListener(`webglcontextrestored`,this.onContextRestored,!0),typeof MutationObserver<`u`&&(this.dataObserver=new MutationObserver(e=>{e.some(e=>e.attributeName?.startsWith(`data-`))&&this.refreshData()}),this.dataObserver.observe(this,{attributes:!0})),typeof IntersectionObserver<`u`&&(this.interObs=new IntersectionObserver(e=>this.inView=e.some(e=>e.isIntersecting)),this.interObs.observe(this)),this.load()}disconnectedCallback(){this.connected=!1,this.loadToken++,this.ownerDocument.defaultView?.removeEventListener(`beforeprint`,this.onBeforePrint),this.removeEventListener(`webglcontextlost`,this.onContextLost,!0),this.removeEventListener(`webglcontextrestored`,this.onContextRestored,!0),this.dataObserver?.disconnect(),this.dataObserver=null,this.interObs?.disconnect(),this.interObs=null,this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null,this.player?.dispose(),this.player=null,this.setStatus(`idle`)}attributeChangedCallback(e,t,n){this.connected&&t!==n&&(e===`poster`||e===`alt`?this.updatePoster():e===`aspect`?this.applyAspect(this.source):e===`paused`?n===null?this.getAttribute(`status`)===`ready`&&this.player?.play():this.player?.pause():e===`src`?(this.source=null,this.load()):this.rebuild())}play(){this.wantPlay=!0,this.hasAttribute(`paused`)&&this.removeAttribute(`paused`),this.player?.play()}pause(){this.wantPlay=!1,this.player?.pause()}async seek(e){await(this.player??await this.ready).seek(e)}get data(){return{...this.source?.data??{},...this.attrData(),...this.dataOverrides}}async setData(e,t={}){this.dataOverrides=t.replace?{...e}:{...this.dataOverrides,...e},await this.rebuild()}trigger(e,t){this.player?.emit?this.player.emit(e,t):this.ready.then(n=>n.emit?.(e,t))}reload(){return this.source=null,this.load()}ensureShadow(){if(this.root||typeof this.attachShadow!=`function`)return;let e=this.ownerDocument;this.root=this.shadowRoot??this.attachShadow({mode:`open`});let t=[];if(an(this.root))rn||(rn=new CSSStyleSheet,rn.replaceSync(nn)),this.sizeSheet=new CSSStyleSheet,this.root.adoptedStyleSheets=[rn,this.sizeSheet];else{let n=e.createElement(`style`);n.textContent=nn,this.sizeStyle=e.createElement(`style`),t=[n,this.sizeStyle]}let n=e.createElement(`slot`);this.posterBox=e.createElement(`div`),this.posterBox.className=`poster`,this.posterBox.setAttribute(`part`,`poster`);let r=e.createElement(`slot`);r.name=`poster`,this.posterEl=e.createElement(`img`),this.posterEl.setAttribute(`part`,`poster-image`),this.posterEl.decoding=`async`,r.appendChild(this.posterEl),this.posterBox.appendChild(r),this.printEl=e.createElement(`img`),this.printEl.className=`print`,this.printEl.alt=``,this.loadingEl=e.createElement(`div`),this.loadingEl.className=`loading indeterminate`,this.loadingEl.setAttribute(`part`,`loading`),this.loadingEl.setAttribute(`aria-hidden`,`true`),this.barEl=e.createElement(`div`),this.barEl.className=`bar`,this.barEl.setAttribute(`part`,`loading-bar`),this.loadingEl.appendChild(this.barEl),this.fallbackEl=e.createElement(`div`),this.fallbackEl.className=`fallback`,this.fallbackEl.setAttribute(`part`,`fallback`);let i=e.createElement(`slot`);i.name=`fallback`,this.fallbackEl.appendChild(i),this.root.append(...t,n,this.posterBox,this.printEl,this.loadingEl,this.fallbackEl)}updatePoster(){let e=this.posterEl;if(!e)return;let t=this.getAttribute(`poster`);e.alt=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``,t?e.getAttribute(`src`)!==t&&(e.src=t):e.removeAttribute(`src`),this.posterBox&&(this.posterBox.hidden=!this.posterSrc()),this.updateFallbackText()}posterSrc(){let e=this.querySelector(`[slot="poster"]`),t=e?.tagName===`IMG`?e:e?.querySelector(`img`);return t?.currentSrc||t?.getAttribute(`src`)||this.getAttribute(`poster`)}updateFallbackText(){let e=this.fallbackEl;if(!e)return;let t=e.querySelector(`slot`),n=!!this.querySelector(`[slot="fallback"]`),r=!!this.posterSrc();e.classList.toggle(`show`,n||!r),t&&!n&&(t.textContent=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``)}setStatus(e){e===`idle`?this.removeAttribute(`status`):this.setAttribute(`status`,e),(e===`unsupported`||e===`error`)&&this.updateFallbackText()}progress(e,t){this.loadingEl&&this.barEl&&t>0&&(this.loadingEl.classList.remove(`indeterminate`),this.barEl.style.width=`${Math.round(Math.min(e,t)/t*100)}%`),this.emit(`agent3d:progress`,{loaded:e,total:t})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}fail(e){this.emit(`agent3d:error`,e),this.emit(`agent3d-error`,e)}onBeforePrint=()=>{let e=this.printEl;if(!e)return;let t=``;try{this.player&&this.getAttribute(`status`)===`ready`&&(t=this.player.snapshot(`image/png`))}catch{}(!t||t.length<32)&&(t=this.posterSrc()??``),t?e.src=t:e.removeAttribute(`src`)};onContextLost=e=>{this.player&&this.inView&&this.getAttribute(`status`)===`ready`&&(e.preventDefault(),this.fail({code:`context-lost`,message:`The WebGL context was lost; restoring.`}),this.setStatus(`loading`),this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{this.lostTimer=null,this.rebuild(!0)},3e3))};onContextRestored=()=>{this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null;let e=this.player;e&&e.update(e.scene).then(()=>this.setStatus(`ready`),()=>void this.rebuild(!0))};childJson(e){let t=this.querySelector(e);if(t?.textContent)try{return JSON.parse(t.textContent)}catch(e){this.fail({code:`invalid-scene`,message:`Invalid inline JSON: ${e.message}`});return}}attrData(){return en(this.dataset??{})}refreshData(){this.source&&this.rebuild()}base(){let e=this.getAttribute(`src`);return e?new URL(`.`,new URL(e,this.ownerDocument.baseURI)).href:this.ownerDocument.baseURI}async fetchScene(){let e=this.childJson(`script[type="application/json"]:not([data-assets])`);if(e)return e;let t=this.getAttribute(`src`);if(!t)return;let n=new URL(t,this.ownerDocument.baseURI).href,r=await fetch(n);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()}async load(){let e=++this.loadToken;if(!this.source){this.setStatus(`loading`);let t;try{if(t=await this.fetchScene(),!t&&this.ownerDocument.readyState===`loading`){if(await new Promise(e=>this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})),e!==this.loadToken)return;t=await this.fetchScene()}}catch(t){if(e!==this.loadToken)return;this.setStatus(`error`),this.fail({code:`scene-load`,message:`Cannot load ${this.getAttribute(`src`)}: ${t.message}`,path:this.getAttribute(`src`)??void 0});return}if(e!==this.loadToken)return;if(!t){this.setStatus(`idle`);return}this.source=t}await this.mount(e)}async rebuild(e=!1){if(!this.connected||!this.source)return;let t=this.player;if(t&&!e&&this.getAttribute(`status`)===`ready`&&this.getAttribute(`library-base`)===this.mountedLibraryBase){let e=this.sceneForMount();this.applySizing(e),await t.update(e)}else await this.mount(++this.loadToken)}sceneForMount(){return cn(this.source,{data:{...this.attrData(),...this.dataOverrides},loop:this.getAttribute(`loop`),quality:this.getAttribute(`quality`)})}mountedLibraryBase=null;async mount(e){this.player?.dispose(),this.player=null,this.readySettled&&this.resetReady(),this.setStatus(`loading`);let t=this.sceneForMount();this.applySizing(t);let n=this.childJson(`script[data-assets]`),r={};this.querySelectorAll(`script[type="text/agent3d-script"][data-path]`).forEach(e=>{r[e.getAttribute(`data-path`)]=e.textContent??``});let i=this.getAttribute(`library-base`);this.mountedLibraryBase=i;let a=this.mountPlayer(this,t,{assetBase:this.base(),libraryBase:i?new URL(i,this.ownerDocument.baseURI).href:void 0,assetUrls:n,scriptSources:Object.keys(r).length?r:void 0,onError:t=>{e===this.loadToken&&(t.code===`webgl-unavailable`&&this.setStatus(`unsupported`),this.fail(t))},onEvent:(t,n)=>e===this.loadToken&&this.emit(`agent3d:event`,{name:t,payload:n}),onClick:(t,n)=>e===this.loadToken&&this.emit(`agent3d:click`,{id:t,x:n.x,y:n.y}),onProgress:(t,n)=>e===this.loadToken&&this.progress(t,n)});this.player=a;try{await a.ready}catch{e===this.loadToken&&this.getAttribute(`status`)!==`unsupported`&&this.setStatus(`error`);return}if(e!==this.loadToken)return;let o=(this.getAttribute(`autoplay`)??``).toLowerCase();(this.hasAttribute(`paused`)||this.wantPlay===!1||this.wantPlay!==!0&&(o===`false`||o===`0`||o===`no`))&&a.pause(),this.setStatus(`ready`),this.readySettled=!0,this.resolveReady(a),this.emit(`agent3d:ready`,{player:a}),this.emit(`agent3d-ready`,{player:a})}applyAspect(e){if(!this.sizeStyle&&!this.sizeSheet)return;let t=e?.target,n;n=t?.height?`:host{height:${t.height}}`:t?.kind===`fullscreen`?`:host{height:100vh;height:100dvh}`:`:host{aspect-ratio:${on(e?t?.aspect??this.getAttribute(`aspect`):this.getAttribute(`aspect`)??`16:9`)??`16 / 9`}}`,this.sizeCssText!==n&&(this.sizeCssText=n,this.sizeSheet?this.sizeSheet.replaceSync(n):this.sizeStyle&&(this.sizeStyle.textContent=n))}applySizing(e){if(this.sizeStyle||this.sizeSheet)this.applyAspect(e);else{this.style.display||(this.style.display=`block`),this.style.width||(this.style.width=`100%`),this.style.position||(this.style.position=`relative`);let t=on(e.target?.aspect)??`16 / 9`;e.target?.height?this.style.height=e.target.height:this.style.aspectRatio=t}let t=e.target?.kind===`game`;this.setAttribute(`role`,t?`application`:`img`);let n=this.getAttribute(`aria-label`);(n===null||n===this.autoAriaLabel)&&(this.autoAriaLabel=e.ariaLabel||e.title||`3D scene`,this.setAttribute(`aria-label`,this.autoAriaLabel)),t&&!this.hasAttribute(`tabindex`)&&(this.tabIndex=0),this.updatePoster()}};function un(e,t=`agent3d-scene`){typeof customElements<`u`&&(customElements.get(t)||customElements.define(t,e))}var dn=null,fn=null;function pn(){return dn??=i(()=>import(`./shaders-DoRMwJE_.js`).then(e=>e.SHADER_IMPLS),__vite__mapDeps([0,1,2,3,4]),import.meta.url),dn}function mn(){return fn??=i(()=>import(`./generators-C4n9MsXd.js`).then(e=>e.GENERATOR_IMPLS),__vite__mapDeps([5,3,4,1,2,6,7,8,9,10]),import.meta.url),fn}function hn(e,t=[0,1,0]){let n=new E(...R(e,t));return n.lengthSq()<1e-9&&n.set(0,1,0),n.normalize()}function gn(e){return nt(e)}var Y=Math.PI*2,_n=(e,t)=>{let n=dt(e.effect,`scale`),r=Math.max(V(e.duration,.8),.001),i=dt(e.ease,`outBack`),a=n===`fade`?gn(t.object):[];for(let e of a)e.userData.baseOpacity===void 0&&(e.userData.baseOpacity=e.opacity),e.transparent=!0;return{update(e){let o=Math.min(Math.max(e/r,0),1),s=c(i,o),l=t.object;switch(n){case`fade`:for(let e of a)e.opacity=e.userData.baseOpacity*c(`outCubic`,o);break;case`rise`:l.position.y-=(1-s)*1,l.scale.multiplyScalar(Math.max(1e-4,Math.min(1,o*3)));break;case`drop`:l.position.y+=(1-s)*3,o<=0&&(l.visible=!1);break;case`spin`:l.rotation.y+=(1-s)*Y,l.scale.multiplyScalar(Math.max(1e-4,s));break;default:l.scale.multiplyScalar(Math.max(1e-4,s))}}}},vn=(e,t)=>{let n=z(e.lockY,!0),r=new E,i=new E;return{update(){t.object.getWorldPosition(r),t.camera.getWorldPosition(i),n?t.object.rotation.set(0,Math.atan2(i.x-r.x,i.z-r.z),0):t.camera.getWorldQuaternion(t.object.quaternion)}}},yn=(e,t)=>{let n=Math.max(V(e.interval,3),.05),r=V(e.duration,.15),i=z(e.random,!0);return{update(e){let a=Math.floor(e/n),o=i?rt(a+t.object.id)*(n-r)*.8:n-r,s=e-a*n;s>=o&&s<o+r&&(t.object.visible=!1)}}},bn=(e,t)=>{let n=V(e.amount,.04),r=Math.max(V(e.period,4),.1),i=V(e.phase,0),a=V(e.rise,.02);return{update(e){let o=(e/r+i)%1,s=o<.6?.5-.5*Math.cos(o/.6*Math.PI):.5+.5*Math.cos((o-.6)/.4*Math.PI);t.object.scale.x*=1+n*.5*s,t.object.scale.z*=1+n*.5*s,t.object.scale.y*=1+n*s,t.object.position.y+=a*s}}},xn=(e,t)=>{let n=V(e.height,.3),r=V(e.speed,1.5);return{update(e){let i=Math.abs(Math.sin(Math.PI*r*e));t.object.position.y+=n*i;let a=(1-i)*(1-i)*.08;t.object.scale.y*=1-a,t.object.scale.x*=1+a*.5,t.object.scale.z*=1+a*.5}}},Sn=(e,t)=>{let n=V(e.amount,.25),r=-1;return{update(e){if(t.clicked()&&(r=e),r<0)return;let i=e-r;if(i>1.5)return;let a=n*Math.exp(-5*i)*Math.sin(i*22);t.object.scale.y*=1-a,t.object.scale.x*=1+a*.5,t.object.scale.z*=1+a*.5}}};function Cn(e,t,n){if(t<=0||e<=0)return 0;if(n===`pingpong`){let n=e%(2*t);return n<=t?n:2*t-n}return n?e%t:Math.min(e,t)}var wn=new Map;function Tn(e){let t=wn.get(e);if(!t){t=new F;try{t.setStyle(e)}catch{t.set(16777215)}wn.size<1e3&&wn.set(e,t)}return t}var En=/^\s*([+\-*])=\s*(-?\d*\.?\d+(?:e[+-]?\d+)?)\s*$/i;function Dn(e){return typeof e==`string`&&En.test(e)}function X(e,t){if(typeof e==`number`)return e;let n=typeof e==`string`?En.exec(e):null;if(!n)return t;let r=Number(n[2]);return n[1]===`+`?t+r:n[1]===`-`?t-r:t*r}function On(e,t){let n=Array.isArray(t)?t:typeof t==`number`?[t,t,t]:null,r=typeof t==`number`?t:Array.isArray(t)?t[0]:0;return e.map(e=>{let[i,a,o]=e,s;return s=Array.isArray(a)?[X(a[0],n?.[0]??0),X(a[1],n?.[1]??0),X(a[2],n?.[2]??0)]:Dn(a)?n&&Array.isArray(t)?[X(a,n[0]),X(a,n[1]),X(a,n[2])]:X(a,r):a,o===void 0?[i,s]:[i,s,o]})}function kn(e){return Array.isArray(e)?[Number(e[0])||0,Number(e[1])||0,Number(e[2])||0]:typeof e==`number`?[e,e,e]:null}function An(e){let t=Math.cbrt(.4122214708*e.r+.5363325363*e.g+.0514459929*e.b),n=Math.cbrt(.2119034982*e.r+.6806995451*e.g+.1073969566*e.b),r=Math.cbrt(.0883024619*e.r+.2817188376*e.g+.6299787005*e.b);return[.2104542553*t+.793617785*n-.0040720468*r,1.9779984951*t-2.428592205*n+.4505937099*r,.0259040371*t+.7827717662*n-.808675766*r]}function jn(e,t,n,r){let i=(e+.3963377774*t+.2158037573*n)**3,a=(e-.1055613458*t-.0638541728*n)**3,o=(e-.0894841775*t-1.291485548*n)**3;return r.setRGB(Math.max(0,4.0767416621*i-3.3077115913*a+.2309699292*o),Math.max(0,-1.2684380046*i+2.6097574011*a-.3413193965*o),Math.max(0,-.0041960863*i-.7034186147*a+1.707614701*o),Te)}function Mn(e,t,n,r=`oklch`,i=new F){if(r===`rgb`)return i.copy(e).lerp(t,n);if(r===`oklch`){let r=An(e),a=An(t),o=Math.hypot(r[1],r[2]),s=Math.hypot(a[1],a[2]),c=Math.atan2(r[2],r[1]),l=Math.atan2(a[2],a[1]);o<1e-4&&(c=l),s<1e-4&&(l=c);let u=l-c;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI);let d=r[0]+(a[0]-r[0])*n,f=Math.max(0,o+(s-o)*n),p=c+u*n;return jn(d,f*Math.cos(p),f*Math.sin(p),i)}if(r===`hsl`){let r={h:0,s:0,l:0},a={h:0,s:0,l:0};e.getHSL(r),t.getHSL(a),r.s<1e-4&&(r.h=a.h),a.s<1e-4&&(a.h=r.h);let o=a.h-r.h;return o>.5?--o:o<-.5&&(o+=1),i.setHSL(((r.h+o*n)%1+1)%1,r.s+(a.s-r.s)*n,r.l+(a.l-r.l)*n)}let a=An(e),o=An(t);return jn(a[0]+(o[0]-a[0])*n,a[1]+(o[1]-a[1])*n,a[2]+(o[2]-a[2])*n,i)}function Nn(e,t,n,r){if(typeof e==`boolean`||typeof t==`boolean`)return n>=1?t:e;if(typeof e==`number`&&typeof t==`number`)return e+(t-e)*n;if(typeof e==`string`||typeof t==`string`)return Mn(Tn(String(e)),Tn(String(t)),n,r);let i=kn(e),a=kn(t);return[i[0]+(a[0]-i[0])*n,i[1]+(a[1]-i[1])*n,i[2]+(a[2]-i[2])*n]}function Pn(e){return typeof e==`string`?Tn(e).clone():Array.isArray(e)?[e[0],e[1],e[2]]:e}function Fn(e,t,n,r){let i=e;if(!i.length)return;if(t<=i[0][0])return Pn(i[0][1]);let a=i[i.length-1];if(t>=a[0])return Pn(a[1]);for(let e=0;e<i.length-1;e++){let[a,o]=i[e],[s,l,u]=i[e+1];if(t>=a&&t<s)return typeof o==`boolean`||typeof l==`boolean`?o:Nn(o,l,s>a?c(u??n??`linear`,(t-a)/(s-a)):1,r)}return Pn(a[1])}function In(e){let t=e.indexOf(`.`);return t<0?{id:e,path:``}:{id:e.slice(0,t),path:e.slice(t+1)}}function Ln(e,t,n=1){let r=Array.from({length:e},(e,t)=>t);switch(t){case`end`:return r.map(t=>e-1-t);case`center`:{let t=(e-1)/2;return r.map(e=>Math.abs(e-t))}case`edges`:{let t=(e-1)/2;return r.map(e=>t-Math.abs(e-t))}case`random`:{let t=[...r],i=n*2654435761>>>0||1;for(let n=e-1;n>0;n--){i=i*1664525+1013904223>>>0;let e=i%(n+1);[t[n],t[e]]=[t[e],t[n]]}let a=Array(e);return t.forEach((e,t)=>a[e]=t),a}default:return r}}var Rn=(e,t)=>{let n=ct(e.colors,[`#ff006e`,`#8338ec`,`#3a86ff`]).map(e=>B(e)),r=V(e.speed,.5),i=z(e.emissive,!1),a=gn(t.object),o=new F;return{update(e){let s=(e*r%n.length+n.length)%n.length,c=Math.floor(s),l=s-c,u=l*l*(3-2*l);Mn(n[c],n[(c+1)%n.length],u,`oklch`,o);let d=t.object;d.isLight&&d.color.copy(o);for(let e of a){let t=e;t.color?.copy(o),i&&t.emissive&&t.emissive.copy(o)}}}},zn=(e,t)=>{let[n,r,i]=R(e.area,[1,1,1]),a=V(e.speed,.3),o=V(e.seed,1)+t.object.id*.137,s=Array.from({length:6},(e,t)=>rt(o*13.1+t)*Math.PI*2),c=Array.from({length:6},(e,t)=>.6+rt(o*7.7+t*3.3)*.8),l=(e,t)=>.65*Math.sin(t*c[e]+s[e])+.35*Math.sin(t*c[e+3]*2.3+s[e+3]);return{update(e){let o=e*a;t.object.position.x+=n/2*l(0,o),t.object.position.y+=r/2*l(1,o*.9),t.object.position.z+=i/2*l(2,o*1.1)}}};function Bn(e,t){let n=Math.floor(e),r=e-n,i=rt(n+t*31.7);return i+(rt(n+1+t*31.7)-i)*r*r*(3-2*r)}var Vn=(e,t)=>{let n=pt(V(e.amount,.3),0,1),r=V(e.speed,8),i=t.object.id,a=gn(t.object);for(let e of a)e.userData.baseEmissiveIntensity===void 0&&(e.userData.baseEmissiveIntensity=e.emissiveIntensity??1);return{update(e){let o=.6*Bn(e*r,i)+.4*Bn(e*r*2.7,i+3),s=1-n*o,c=t.object;c.isLight&&(c.intensity*=s);for(let e of a)e.emissiveIntensity!==void 0&&(e.emissiveIntensity=e.userData.baseEmissiveIntensity*s)}}},Hn=(e,t)=>{let n=V(e.amplitude,.15),r=V(e.speed,.5),i=V(e.phase,0);return{update:e=>void(t.object.position.y+=n*Math.sin(Y*(r*e+i)))}},Un=(e,t)=>{let n=V(e.strength,.5),r=V(e.smoothing,.9),i=dt(e.mode,`rotate`),a=0,o=0;return{update(e,s){let c=L(r,s);a+=(t.pointer.x-a)*c,o+=(t.pointer.y-o)*c,(i===`move`||i===`both`)&&(t.object.position.x+=a*n,t.object.position.y+=o*n),(i===`rotate`||i===`both`)&&(t.object.rotation.y+=a*n*.8,t.object.rotation.x+=-o*n*.8)}}},Wn=(e,t)=>{let n=V(e.height,.2),r=V(e.tilt,10)*H,i=0,a=0,o=0;return{update(e,s){let c=L(.82,s);i+=(+!!t.hovered()-i)*c,a+=(t.pointer.x-a)*c,o+=(t.pointer.y-o)*c,t.object.position.y+=n*i,t.object.rotation.x+=-o*r*i,t.object.rotation.y+=a*r*i}}},Gn=(e,t)=>{let n=V(e.scale,1.15),r=V(e.smoothing,.8),i=1;return{update(e,a){i+=((t.hovered()?n:1)-i)*L(r,a),t.object.scale.multiplyScalar(i)}}},Kn=(e,t)=>{let n=V(e.smoothing,.85),r=z(e.lockY,!1),i=Array.isArray(e.point)&&e.point.length===3?new E(...e.point):null,a=typeof e.target==`string`?e.target:`camera`,o=new T,s=new T,c=new E,l=new E,u=new k,d=new T,f=!0;return{update(e,p){let m=i??(a===`camera`?t.camera:t.find?.(a));m&&(m instanceof E?l.copy(m):m.getWorldPosition(l),t.object.getWorldPosition(c),r&&(l.y=c.y),l.distanceToSquared(c)<1e-10||(u.lookAt(l,c,le.DEFAULT_UP),o.setFromRotationMatrix(u),t.object.parent&&o.premultiply(t.object.parent.getWorldQuaternion(d).invert()),s.slerp(o,f?1:L(n,p)),f=!1,t.object.quaternion.copy(s)))}}},qn=(e,t)=>{let n=V(e.maxAngle,35)*H,r=V(e.smoothing,.85),i=0,a=0;return{update(e,o){let s=L(r,o);i+=(t.pointer.x*n-i)*s,a+=(-t.pointer.y*n-a)*s,t.object.rotation.y+=i,t.object.rotation.x+=a}}},Jn=(e,t)=>{let n=Math.max(V(e.radius,.25),.001),r=V(e.strength,.4),i=new E,a=new E,o=new E,s=new E,c=new E;return{update(e,l){if(a.set(0,0,0),t.pointer.inside){t.object.getWorldPosition(o),s.copy(o).project(t.camera);let e=(t.pointer.x-s.x)/2,i=(t.pointer.y-s.y)/2,l=Math.hypot(e,i);if(l<n){c.set(t.pointer.x,t.pointer.y,s.z).unproject(t.camera),a.copy(c).sub(o);let e=a.length();e>1e-6&&a.multiplyScalar(Math.min(e,r)*(1-l/n)/e)}}i.lerp(a,L(.85,l)),t.object.position.add(i)}}},Yn=(e,t)=>{let[n,r,i]=R(e.amplitude,[.1,.1,.05]),[a,o,s]=R(e.rotation,[3,3,2]),c=V(e.speed,.3),l=V(e.seed,1)*13.37+t.rng.next()*100,u=(e,t)=>at(e*c+l,t*5.17)*.8+at(e*c*2.3+l,t*5.17+2.9)*.2;return{update(e){t.object.position.x+=u(e,0)*n,t.object.position.y+=u(e,1)*r,t.object.position.z+=u(e,2)*i,t.object.rotation.x+=u(e,3)*a*H,t.object.rotation.y+=u(e,4)*o*H,t.object.rotation.z+=u(e,5)*s*H}}},Xn=(e,t)=>{let n=new E(...R(e.center,[0,0,0])),r=V(e.radius,2),i=V(e.speed,30)*H,a=V(e.phase,0)*H,o=hn(e.axis),s=z(e.faceDirection,!1),c=Math.abs(o.y)<.99?new E(0,1,0):new E(1,0,0),l=new E().crossVectors(c,o).normalize(),u=new E().crossVectors(o,l).normalize(),d=new E;return{update(e){let c=a+i*e,f=t.object.position.dot(o)-n.dot(o);if(d.copy(n).addScaledVector(l,Math.cos(c)*r).addScaledVector(u,Math.sin(c)*r).addScaledVector(o,f),t.object.position.copy(d),s){let e=l.clone().multiplyScalar(-Math.sin(c)).addScaledVector(u,Math.cos(c)).multiplyScalar(Math.sign(i)||1),n=new T().setFromUnitVectors(new E(0,0,1),e.normalize());t.object.quaternion.premultiply(n)}}}},Zn=(e,t)=>{let n=V(e.depth,.5),r=V(e.pointer,.3),i=V(e.scroll,0),a=V(e.smoothing,.9),o=0,s=0;return{update(e,c){let l=L(a,c),u=t.pointer.inside?t.pointer.x:0,d=t.pointer.inside?t.pointer.y:0;o+=(u-o)*l,s+=(d-s)*l,t.object.position.x+=o*r*n,t.object.position.y+=s*r*n*.6+(t.scroll()-.5)*i*n}}},Qn=(e,t)=>{let n=(Array.isArray(e.points)?e.points:[]).filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new E(e[0],e[1],e[2])),r=z(e.loop,!0),i=z(e.faceDirection,!0),a=Math.max(V(e.duration,5),.001);if(n.length<2)return{update(){}};let o=new We(n,r,`catmullrom`,.5),s=new E,c=new E(0,0,1);return{update(e){let n=r?e/a%1:Math.min(e/a,1);o.getPointAt(n,t.object.position),i&&(o.getTangentAt(Math.min(n,.9999),s).normalize(),t.object.quaternion.setFromUnitVectors(c,s))}}},$n=(e,t)=>{let n=V(e.amount,.08),r=V(e.speed,1);return{update:e=>void t.object.scale.multiplyScalar(1+n*Math.sin(Y*r*e))}},er=(e,t)=>{let n=hn(e.axis),r=V(e.speed,45)*H;return{update:e=>void t.object.rotateOnAxis(n,r*e)}},tr=(e,t)=>{let[n,r,i]=R(e.offset,[0,2,0]);return{update(){let e=t.scroll();t.object.position.x+=n*e,t.object.position.y+=r*e,t.object.position.z+=i*e}}},nr=(e,t)=>{let n=hn(e.axis),r=V(e.degrees,360)*H;return{update:()=>void t.object.rotateOnAxis(n,r*t.scroll())}},rr=(e,t)=>{let n=hn(e.axis),r=Math.max(V(e.duration,.8),.001),i=e.trigger===`hover`,a=-1,o=!1;return{update(e){let s=a>=0&&e-a<r;if(i){let n=t.hovered();n&&!o&&!s&&(a=e),o=n}else t.clicked()&&!s&&(a=e);if(a<0)return;let l=(e-a)/r;l>=1||t.object.rotateOnAxis(n,Y*c(`inOutCubic`,l))}}};function ir(e,t,n,r,i,a,o=1){let s=Math.min(Math.max(r,0),2);for(;s>1e-9;){let r=Math.min(.004166666666666667,s),c=(-i*(e-n)-a*t)/o;t+=c*r,e+=t*r,s-=r}return[e,t]}var ar={rotate:er,float:Hn,bob:xn,pulse:$n,wobble:(e,t)=>{let n=V(e.amount,.08),r=V(e.speed,2);return{update(e){let i=Math.sin(Y*r*e*.5),a=Math.sin(Y*r*e*.5+Math.PI/2);t.object.scale.x*=1+n*i,t.object.scale.y*=1-n*i,t.object.scale.z*=1+n*a*.5}}},sway:(e,t)=>{let n=hn(e.axis,[0,0,1]),r=V(e.angle,8)*H,i=V(e.speed,.5);return{update:e=>void t.object.rotateOnAxis(n,r*Math.sin(Y*i*e))}},orbit:Xn,path:Qn,followPointer:Un,lookAtPointer:qn,hoverScale:Gn,hoverLift:Wn,clickBounce:Sn,spinOnClick:rr,scrollRotate:nr,scrollMove:tr,drift:zn,blink:yn,colorCycle:Rn,flicker:Vn,billboard:vn,appear:_n,magnet:Jn,spring:(e,t)=>{let n=V(e.strength,.4),r=Math.max(V(e.stiffness,120),1),i=Math.max(V(e.damping,12),0),a=Math.max(V(e.mass,1),.01),o=dt(e.mode,`move`),s=V(e.angle,15)*H,c={x:0,vx:0,y:0,vy:0};return{update(e,l){let u=t.pointer.inside?t.pointer.x:0,d=t.pointer.inside?t.pointer.y:0;[c.x,c.vx]=ir(c.x,c.vx,u,l,r,i,a),[c.y,c.vy]=ir(c.y,c.vy,d,l,r,i,a),(o===`move`||o===`both`)&&(t.object.position.x+=c.x*n,t.object.position.y+=c.y*n),(o===`rotate`||o===`both`)&&(t.object.rotation.y+=c.x*s,t.object.rotation.x+=-c.y*s)}}},parallax:Zn,tilt:(e,t)=>{let n=V(e.maxAngle,12)*H,r=V(e.scale,1.04),i=V(e.lift,.1),a=V(e.smoothing,.86),o=z(e.hoverOnly,!0),s=z(e.reverse,!1)?-1:1,c=0,l=0,u=0;return{update(e,d){let f=o?t.hovered():t.pointer.inside,p=L(a,d);u+=(+!!f-u)*p,c+=((f?t.pointer.x:0)-c)*p,l+=((f?t.pointer.y:0)-l)*p,t.object.rotation.y+=c*n*s,t.object.rotation.x+=-l*n*s,t.object.position.z+=i*u,t.object.scale.multiplyScalar(1+(r-1)*u)}}},breathe:bn,noise:Yn,lookAt:Kn},or=new Set([`appear`]),sr=1e6,cr=new Set([`billboard`,`lookAt`]),lr=new Set([`lookAt`,`magnet`,`spring`]),ur=1/30;function dr(e,t,n=ur){let r=[];for(let i=Math.floor(e/n+1e-6)+1;i*n<t-1e-6;i++)r.push(i*n);return r}function fr(e,t,n,r={}){let i=t(e,n),a=e.when??`always`,o=V(e.delay,0),s=0,c=-1;return{def:e,late:cr.has(e.type),stateful:lr.has(e.type),step(t,l){if(r.settled?.()&&or.has(e.type)&&(a===`always`||a===`visible`)){i.update(sr,l);return}let u;switch(a){case`hover`:n.hovered()&&(s+=l),u=s-o;break;case`click`:if(c<0&&n.clicked()&&(c=t),c<0)return;u=t-c-o;break;case`scroll`:u=n.scroll()*10-o;break;default:u=t-o}i.update(Math.max(0,u),l)},dispose(){i.dispose?.()}}}var pr={count:300,area:[10,6,6],size:.08,colors:[`#ffffff`],speed:.3,direction:[0,1,0],spread:.3,lifetime:0,opacity:1,blending:`additive`,shape:`soft`,twinkle:0,wander:.2,spin:0,gravity:[0,0,0],endColor:null,endSize:1,stretch:1,swirl:0},mr={stars:{count:900,area:[40,20,20],size:.09,colors:[`#ffffff`,`#cfe2ff`,`#ffe8c2`],speed:0,wander:0,twinkle:.8,shape:`point`,blending:`additive`},snow:{count:1200,area:[20,12,10],size:.08,colors:[`#ffffff`,`#eef6ff`],speed:.6,direction:[0,-1,0],spread:.3,wander:.35,shape:`soft`,blending:`normal`,opacity:.95},rain:{count:2200,area:[20,12,10],size:.05,colors:[`#c9ddff`,`#a9c4f0`],speed:9,direction:[-.06,-1,0],spread:.04,wander:0,shape:`streak`,stretch:9,blending:`normal`,opacity:.5},fireflies:{count:90,area:[10,4,6],size:.16,colors:[`#fff3a0`,`#d4ff7a`,`#ffe066`],speed:.08,spread:1,wander:.7,twinkle:.9,shape:`point`,blending:`additive`},confetti:{count:320,area:[12,8,6],size:.16,colors:[`#ff006e`,`#ffbe0b`,`#3a86ff`,`#8338ec`,`#06d6a0`,`#fb5607`],speed:1.3,direction:[0,-1,0],spread:.5,wander:.45,spin:.8,shape:`square`,blending:`normal`},sparks:{count:320,area:[.6,.2,.6],size:.035,colors:[`#fff6d0`,`#ffd27a`,`#ff9a3d`],speed:5,direction:[0,1,0],spread:.45,lifetime:1.2,wander:0,gravity:[0,-6,0],endColor:`#ff4d00`,endSize:.5,shape:`streak`,stretch:4,blending:`additive`},dust:{count:450,area:[12,6,8],size:.035,colors:[`#ffffff`,`#fff4dc`],speed:.04,spread:1,wander:.45,twinkle:.35,opacity:.6,shape:`soft`,blending:`additive`},bubbles:{count:160,area:[8,6,4],size:.22,colors:[`#d6f3ff`,`#a9e4ff`],speed:.8,direction:[0,1,0],spread:.25,wander:.18,shape:`bubble`,blending:`normal`,opacity:.85},embers:{count:220,area:[6,.6,4],size:.07,colors:[`#ffb347`,`#ff7b00`,`#ffd27a`],speed:1,direction:[0,1,0],spread:.45,lifetime:3.2,wander:.45,twinkle:.4,endColor:`#c81d00`,endSize:.4,shape:`point`,blending:`additive`},hearts:{count:60,area:[8,4,4],size:.32,colors:[`#ff4d6d`,`#ff8fa3`,`#ff006e`],speed:.6,direction:[0,1,0],spread:.3,lifetime:5,wander:.3,endSize:1.3,shape:`heart`,blending:`normal`},magic:{count:260,area:[6,4,3],size:.13,colors:[`#fff3b0`,`#e9d5ff`,`#a5f3fc`,`#fbcfe8`],speed:.25,direction:[0,1,0],spread:1,lifetime:3.5,wander:.35,twinkle:.9,spin:.15,endSize:.2,shape:`star`,blending:`additive`},smoke:{count:90,area:[1.2,.3,1.2],size:1.1,colors:[`#d9dde3`,`#c3c8d0`,`#eef0f3`],speed:.7,direction:[.12,1,0],spread:.25,lifetime:6,wander:.35,spin:.05,endSize:3.2,endColor:`#f4f5f7`,shape:`smoke`,blending:`normal`,opacity:.4},fire:{count:150,area:[.6,.1,.6],size:.42,colors:[`#ffd27a`,`#ffb347`,`#ff9a3d`],speed:1.9,direction:[0,1,0],spread:.1,lifetime:1,wander:.1,gravity:[0,.6,0],endColor:`#c81d00`,endSize:.12,shape:`smoke`,spin:.2,blending:`additive`,opacity:.5},petals:{count:140,area:[14,8,6],size:.27,colors:[`#ffc2d4`,`#ffb3c6`,`#ffe5ec`,`#ff8fab`],speed:.55,direction:[.35,-1,.1],spread:.4,wander:.6,spin:.35,shape:`petal`,blending:`normal`},leaves:{count:110,area:[14,8,6],size:.26,colors:[`#e76f51`,`#f4a261`,`#e9c46a`,`#bc4b2a`,`#8a9a2b`],speed:.7,direction:[.45,-1,.1],spread:.45,wander:.7,spin:.3,shape:`leaf`,blending:`normal`},galaxyDust:{count:1800,area:[16,2,16],size:.05,colors:[`#a5b4fc`,`#f0abfc`,`#93c5fd`,`#ffffff`],speed:0,wander:.15,twinkle:.5,swirl:.12,opacity:.8,shape:`soft`,blending:`additive`},bokeh:{count:26,area:[16,9,6],size:1.1,colors:[`#ffd6a5`,`#fdffb6`,`#caffbf`,`#9bf6ff`,`#bdb2ff`,`#ffc6ff`],speed:.05,spread:1,wander:.5,twinkle:.3,opacity:.32,shape:`ring`,blending:`additive`}},hr={point:0,square:1,circle:2,star:3,spark:4,heart:5,bubble:6,soft:7,streak:8,smoke:9,petal:10,leaf:11,ring:12},gr=`
|
|
133
133
|
uniform float uTime; uniform vec3 uArea; uniform vec3 uVel; uniform float uSpread; uniform float uLife;
|
|
134
134
|
uniform float uWander; uniform float uSize; uniform float uViewport; uniform float uTwinkle; uniform float uSpin; uniform float uOpacity;
|
|
135
135
|
uniform vec3 uGravity; uniform vec3 uEndColor; uniform float uUseEnd; uniform float uEndSize; uniform float uStretch; uniform float uSwirl;
|
|
@@ -569,4 +569,4 @@ varying vec4 vShadowClip;
|
|
|
569
569
|
\t\tfloat edge = 1.0 - max(abs(ndc.x), abs(ndc.y));
|
|
570
570
|
\t\tgl_FragColor.a *= (1.0 - smoothstep(${zi.radial[0].toFixed(2)}, ${zi.radial[1].toFixed(2)}, length(vShadowUv - 0.5))) * smoothstep(0.0, ${zi.screenEdge.toFixed(2)}, edge);
|
|
571
571
|
\t}
|
|
572
|
-
\t#include <tonemapping_fragment>`)},n.customProgramCacheKey=()=>`agent3d-shadow-catcher`,n}var Vi=.45;function Hi(e,t){let n=e.background;return e.fog?.color?e.fog.color:t||(n&&typeof n==`object`&&`sky`in n&&n.sky?.horizon?n.sky.horizon:n&&typeof n==`object`&&`meshGradient`in n&&n.meshGradient[0]?n.meshGradient[0]:typeof n==`string`&&n!==`transparent`?n:`#ffffff`)}async function Ui(e,t,n,r,a){let o=[],s=[],c=a.renderer,l=e.background,u=!!n.isOrthographicCamera,d=null,f=0,p=null,h=null,g=null;t.background=null,t.backgroundIntensity=1,t.backgroundRotation.set(0,0,0),t.environmentRotation.set(0,0,0);let _=l&&typeof l==`object`?l:null,v=_&&`sky`in _?_.sky??{}:null;if(v&&xi(v))try{p=await ki(v)}catch(e){a.issue(`asset-load`,e.message,`environment.background.sky`)}if(!r&&l!==void 0&&l!==`transparent`){if(typeof l==`string`)t.background=B(l);else if(`gradient`in l)t.background=Ai(l.gradient,`linear`,V(l.angle,0),{grain:l.grain});else if(`radial`in l)t.background=Ai(l.radial,`radial`,0,{center:l.center,radius:l.radius,grain:l.grain});else if(`meshGradient`in l)g=l.meshGradient,o.push(ji(l.meshGradient,l,a));else if(`sky`in l){let e=l.sky??{};if(p){if(!u){o.push(p.mesh);let e=p;a.onUpdate(t=>e.setTime(t))}}else h=e,u?t.background=Ai([e.bottom??e.horizon??`#e8eef5`,e.horizon??`#cfe6ff`,e.top??`#2f6fd6`],`linear`,0):o.push(Pi(e,a))}else if(`hdri`in l)try{if(d=await Li(a.resolveAsset(l.hdri)),f=V(l.rotation,0)*H,t.backgroundRotation.set(0,f,0),t.backgroundIntensity=V(l.intensity,1),s.push(d),l.groundProjection&&!u){let n=typeof l.groundProjection==`object`?l.groundProjection:{},{GroundedSkybox:r}=await i(async()=>{let{GroundedSkybox:e}=await import(`./GroundedSkybox-cLn9JVlt.js`);return{GroundedSkybox:e}},__vite__mapDeps([15,1,2]),import.meta.url),a=V(n.height,2),s=V(n.radius,60),c=new r(d,a,s);c.position.y=a-.01+V(e.ground?.y,0),c.rotation.y=f,c.material.color.setScalar(t.backgroundIntensity),c.name=`__groundProjection`,c.userData.helper=!0,c.renderOrder=-999,o.push(c),t.background=B(`#000000`)}else t.background=d,t.backgroundBlurriness=V(l.blur,0)}catch(e){a.issue(`asset-load`,e.message,`environment.background.hdri`)}t.background instanceof Ge&&t.background!==d&&s.push(t.background)}t.fog=null,ri(t,null);let y=null;e.fog&&(y=B(Hi(e,p?.values.haze)),!e.fog.color&&p&&y.multiplyScalar(.82),`density`in e.fog?(t.fog=new Je(y,e.fog.density),e.fog.height!==void 0&&ri(t,{uA3dFogHeight:{value:e.fog.height},uA3dFogFalloff:{value:V(e.fog.falloff,.25)}})):t.fog=new de(y,V(e.fog.near,10),V(e.fog.far,60)),p?.setHaze(y,.85));let b=d?{hdri:``}:p?`sky`:`soft`,x=e.lighting??b;if(t.environment=null,t.environmentIntensity=V(e.lightingIntensity,1),c&&x!==`none`){let n=new Ve(c),o=null;try{if(typeof x==`object`){let e=x.hdri?await Li(a.resolveAsset(x.hdri)):d;e&&(o=n.fromEquirectangular(e)),x.intensity!==void 0&&(t.environmentIntensity=x.intensity),t.environmentRotation.set(0,x.hdri?V(x.rotation,0)*H:x.rotation===void 0?f:x.rotation*H,0),e&&e!==d&&e.dispose()}else if(x===`sky`){if(p){let e=p.envScene();o=n.fromScene(e,0,.1,100),Ii(e)}else if(h){let e=h,t=e.sun===!1?void 0:e.sun,r=Fi(e.top??`#2f6fd6`,e.horizon??`#cfe6ff`,e.bottom??e.horizon??`#e8eef5`,t?{dir:new E(...R(t.direction,[.4,.35,-1])),color:t.color??`#fff2d6`,power:4,size:.9}:void 0,!1);o=n.fromScene(r,.02),Ii(r)}else if(g){let e=g,t=Fi(e[1]??e[0],e[0],e[2]??e[0],void 0,!0);o=n.fromScene(t,.04),Ii(t)}else{let{RoomEnvironment:e}=await i(async()=>{let{RoomEnvironment:e}=await import(`./RoomEnvironment-v4QurKxu.js`);return{RoomEnvironment:e}},__vite__mapDeps([16,1,2]),import.meta.url),t=new e;o=n.fromScene(t,.06),t.dispose?.()}}else if(x===`studio`||x===`soft`){let{RoomEnvironment:r}=await i(async()=>{let{RoomEnvironment:e}=await import(`./RoomEnvironment-v4QurKxu.js`);return{RoomEnvironment:e}},__vite__mapDeps([16,1,2]),import.meta.url),a=new r;o=n.fromScene(a,x===`soft`?.06:.02),x===`soft`&&e.lightingIntensity===void 0&&(t.environmentIntensity=.8),a.dispose?.()}else{let e={neutral:[`#d8d8dc`,`#b9b9bd`,`#5a5a60`],sunset:[`#33306e`,`#ff9a5a`,`#3a2531`,{dir:new E(1,.15,-.6),color:`#ffb36b`,power:6,size:1.6}],night:[`#060a1a`,`#1d2a55`,`#05060c`,{dir:new E(-.5,.7,-.5),color:`#cfdcff`,power:3,size:.8}]},t=Fi(...e[x]??e.neutral);o=n.fromScene(t,.03),Ii(t)}}catch(e){a.issue(`asset-load`,e.message,`environment.lighting`)}o&&(t.environment=o.texture,s.push(o),u&&p&&!r&&(t.background=o.texture,t.backgroundBlurriness=0)),n.dispose();let l=e.lightingIntensity!==void 0||typeof x==`object`&&x.intensity!==void 0;e.rig&&!l&&(t.environmentIntensity*=Vi)}let S=[],C=v&&v.sun!==!1?v.sun??{}:null;if(p&&C&&C.light!==!1){let t=Ti(p.values.elevation),n=new j(C.color?B(C.color):t.color,V(C.intensity,t.intensity));n.position.copy(p.sunDir).multiplyScalar(30),n.name=`__sun`,n.userData.a3dId=`sun`,C.castShadow!==!1&&n.intensity>0&&li(n,{type:`directional`,shadow:{softness:3}},e.shadows),S.push(n)}for(let t of yi(e.rig)){let n=await mi(t,e.shadows);S.push(n)}for(let e of S)o.push(e),(e instanceof j||e instanceof P)&&o.push(e.target);let ee;if(e.ground){let t=e.ground,n=V(t.size,60),r=V(t.y,0),i=t.shadowOnly?Bi(B(t.color??`#000000`),V(t.opacity,.28)):Ri(B(t.color??`#d9d9d9`),V(t.roughness,.9));!t.shadowOnly&&t.opacity!==void 0&&(i.opacity=t.opacity);let a=new I(new m(n,n),i);if(a.rotation.x=-Math.PI/2,a.position.y=r,a.receiveShadow=!0,a.name=`__ground`,a.renderOrder=-20,a.userData.helper=!0,a.userData.ground=!0,o.push(a),ee=a,t.grid){let e=new te(n,Math.round(n),B(`#000000`),B(`#000000`)),t=e.material;t.transparent=!0,t.opacity=.12,t.depthWrite=!1,e.position.y=r+.002,e.userData.helper=!0,o.push(e)}}if(e.contactShadows){let n=qr(e.contactShadows,t,e.ground?V(e.ground.y,0):void 0,a);n&&(o.push(n.object),s.push(n))}return{objects:o,ground:ee,dispose(){for(let e of s)e.dispose();for(let e of o)e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose?.(),e.shadow?.dispose?.()})}}}function Wi(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>new w(Number(e[0]),Number(e[1]))):[]}function Gi(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new E(Number(e[0]),Number(e[1]),Number(e[2]))):[]}var Ki=(e,t=`segments`,n=32)=>Math.max(3,Math.round(V(e[t],n))),qi={box:e=>new Re(V(e.width,1),V(e.height,1),V(e.depth,1)),roundedBox:e=>{let t=V(e.width,1),n=V(e.height,1),r=V(e.depth,1),i=Math.min(V(e.radius,.1),Math.min(t,n,r)/2-1e-4);return new $t(t,n,r,Math.max(1,Math.round(V(e.segments,4))),Math.max(0,i))},sphere:e=>new ke(V(e.radius,.5),Ki(e),Math.max(2,Math.round(V(e.heightSegments,24)))),cylinder:e=>new pe(V(e.radiusTop,.5),V(e.radiusBottom,.5),V(e.height,1),Ki(e),1,z(e.openEnded,!1)),cone:e=>new h(V(e.radius,.5),V(e.height,1),Ki(e)),capsule:e=>{let t=Math.max(2,Math.round(V(e.segments,16)));return new be(V(e.radius,.3),V(e.length,.6),Math.max(2,Math.round(t/2)),t*2)},torus:e=>new x(V(e.radius,.5),V(e.tube,.15),Math.max(2,Math.round(V(e.radialSegments,24))),Math.max(3,Math.round(V(e.tubularSegments,64))),V(e.arc,360)*H),torusKnot:e=>new v(V(e.radius,.5),V(e.tube,.15),Math.round(V(e.tubularSegments,128)),Math.round(V(e.radialSegments,16)),Math.round(V(e.p,2)),Math.round(V(e.q,3))),plane:e=>new m(V(e.width,1),V(e.height,1),Math.max(1,Math.round(V(e.widthSegments,1))),Math.max(1,Math.round(V(e.heightSegments,1)))),circle:e=>new qe(V(e.radius,.5),Ki(e)),ring:e=>new Ie(V(e.innerRadius,.3),V(e.outerRadius,.5),Ki(e)),icosahedron:e=>new ie(V(e.radius,.5),Math.round(V(e.detail,0))),dodecahedron:e=>new ae(V(e.radius,.5),Math.round(V(e.detail,0))),octahedron:e=>new C(V(e.radius,.5),Math.round(V(e.detail,0))),tetrahedron:e=>new g(V(e.radius,.5),Math.round(V(e.detail,0))),lathe:e=>{let t=Wi(e.points);return t.length<2&&(t=[new w(.5,-.5),new w(.5,.5)]),new Ue(t,Ki(e))},extrude:e=>{let t=Wi(e.shape);t.length<3&&(t=[new w(-.5,-.5),new w(.5,-.5),new w(0,.5)]);let n=new Ce(t),r=V(e.depth,.2),i=V(e.bevel,.02),a=new ce(n,{depth:r,bevelEnabled:i>0,bevelSize:i,bevelThickness:i,bevelSegments:3,curveSegments:12});return a.translate(0,0,-r/2),a},tube:e=>{let t=Gi(e.points);t.length<2&&(t=[new E(-1,0,0),new E(1,0,0)]);let n=new We(t,z(e.closed,!1),`catmullrom`,.5);return new je(n,Math.max(2,Math.round(V(e.tubularSegments,64))),V(e.radius,.05),Math.max(3,Math.round(V(e.radialSegments,8))),z(e.closed,!1))}};function Ji(e){let t=qi[e.type]??qi.box,n=Xe.find(t=>t.id===e.type),r=t(ft(n,e));return r.computeBoundingBox(),r.computeBoundingSphere(),r}function Yi(e,t){let n=[],r=(e,t=new D,r=new E(1,1,1))=>n.push({position:e,rotation:t,scale:r});switch(e.type){case`grid`:{let[t,n,i]=e.count.map(e=>Math.max(1,Math.round(e))),[a,o,s]=e.spacing;for(let e=0;e<t;e++)for(let c=0;c<n;c++)for(let l=0;l<i;l++)r(new E((e-(t-1)/2)*a,(c-(n-1)/2)*o,(l-(i-1)/2)*s));break}case`scatter`:{let n=V(e.minScale,1),i=V(e.maxScale,1),[a,o,s]=e.area;for(let c=0;c<Math.max(0,Math.round(e.count));c++){let c=new E(t.range(-a/2,a/2),t.range(-o/2,o/2),t.range(-s/2,s/2)),l=e.randomRotation===!1?new D:new D(0,t.range(0,Math.PI*2),0),u=t.range(n,i);r(c,l,new E(u,u,u))}break}case`circle`:{let t=Math.max(1,Math.round(e.count));for(let n=0;n<t;n++){let i=n/t*Math.PI*2;r(new E(Math.cos(i)*e.radius,0,Math.sin(i)*e.radius),new D(0,-i,0))}break}case`list`:for(let t of e.items){let e=t.position??[0,0,0],n=t.rotation??[0,0,0],i=t.scale??1;r(new E(...e),new D(n[0]*H,n[1]*H,n[2]*H),typeof i==`number`?new E(i,i,i):new E(...i))}}return n}function Xi(e,t,n,r,i){let a=Yi(e.layout,r),o=new ye(t,n,Math.max(1,a.length));o.count=a.length;let s=new k,c=new T;if(a.forEach((e,t)=>{s.compose(e.position,c.setFromEuler(e.rotation),e.scale),o.setMatrixAt(t,s)}),e.colors?.length){let t=e.layout.type===`scatter`;a.forEach((n,a)=>o.setColorAt(a,i(t?r.pick(e.colors):e.colors[a%e.colors.length]))),o.instanceColor&&(o.instanceColor.needsUpdate=!0)}return o.instanceMatrix.needsUpdate=!0,o.computeBoundingBox(),o.computeBoundingSphere(),o}function Zi(e){let t={position:e.position.clone(),quaternion:e.quaternion.clone(),scale:e.scale.clone(),visible:e.visible},n=e;return n.isLight&&(t.intensity=n.intensity,t.color=n.color.clone()),t}function Qi(e,t){t.position&&e.position.set(t.position[0]??0,t.position[1]??0,t.position[2]??0),t.rotation&&e.rotation.set((t.rotation[0]??0)*H,(t.rotation[1]??0)*H,(t.rotation[2]??0)*H),t.scale!==void 0&&(typeof t.scale==`number`?e.scale.setScalar(t.scale):e.scale.set(t.scale[0]??1,t.scale[1]??1,t.scale[2]??1))}var $i=new Set([`hoverScale`,`hoverLift`,`clickBounce`,`spinOnClick`]),ea=class e{def;ctx;scene=new Se;camera;rig;env=null;entries=new Map;timeline=null;settleEntrances=!1;updaters=[];photoCameras=[];cameraRest0={position:new E,target:new E,fov:45,zoom:10,focus:void 0};motionHost;overrides;shots=[];focusWritten=!1;postfxParam=null;viewportH=600;input={pointer:{x:0,y:0,inside:!1},scroll:0,hovered:new Set,clicked:new Set,timelineT:null};disposed=!1;constructor(e,t){this.def=e,this.ctx=t,t.onUpdate=e=>this.updaters.push(e)}static async create(t,n,r,i,a=!1){let o=new e(t,n);return await o.build(r,i,a),o}async build(e,t,n){let{def:r,ctx:i}=this;{this.camera=ut(r.camera,e),this.rig=await st(r.camera,this.camera,t,i.deterministic),this.cameraRest0.position.copy(this.rig.rest.position),this.cameraRest0.target.copy(this.rig.rest.target),this.cameraRest0.fov=this.rig.rest.fov,this.cameraRest0.zoom=this.rig.rest.zoom;let n=r.postfx?.find(e=>e.type===`dof`);this.cameraRest0.focus=n&&typeof n.focus==`number`?n.focus:n?8:void 0,this.rig.rest.focus=this.cameraRest0.focus;let a=Ui(r.environment??{background:`#ffffff`},this.scene,this.camera,!!r.target?.transparent,i),o=Promise.all((r.lights??[]).map((e,t)=>this.addLight(e,t))),s=new Map,c=r.objects??[],u=e=>e.attach===`camera`?this.camera:this.scene;c.some(e=>e.attach===`camera`)&&this.scene.add(this.camera),await Promise.all(c.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(e=>this.addObject(e,u(e),void 0,s))),ta(s,c),await Promise.all(c.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(e=>this.addObject(e,u(e),void 0,s)));let d=new Map(c.map((e,t)=>[e.id,t]));this.scene.children.sort((e,t)=>(d.get(e.userData.a3dId)??-1)-(d.get(t.userData.a3dId)??-1)),this.env=await a;for(let e of this.env.objects)this.scene.add(e);if(await o,this.canonicalOrder(r),this.motionHost={object:e=>this.entries.get(e)?.object??null,select:e=>this.select(e),camera:this.rig.rest,scene:this.scene,renderer:i.renderer,postfx:{set:(e,t,n)=>this.postfxParam?.(e,t,n),base:(e,t)=>{let n=l(r.postfx).find(t=>t.type===e)?.[t];return typeof n==`number`||typeof n==`string`?n:void 0}},clips:e=>this.entries.get(e)?.animator?.control,photoEffects:e=>this.entries.get(e)?.photoFx,issue:i.issue,seed:r.seed??1},this.overrides=new Nr(this.motionHost),this.shots=zr(r.camera?.shots),r.timeline){this.timeline=jr(r.timeline,this.motionHost);for(let e of this.timeline.targets){let t=this.entries.get(e);t&&(t.animated=!0)}}for(let e of r.interactions??[]){if(e.target&&(e.on===`click`||e.on===`hover`||e.on===`hoverEnd`)){let t=this.entries.get(e.target);t&&(t.interactive=!0)}for(let t of e.do??[]){let e=t.set?.path;if(typeof e==`string`)for(let t of this.overrides.idsOf(e)){let e=this.entries.get(t);e&&(e.animated=!0)}}}this.fitShadows()}}canonicalOrder(e){let t=this.entries,n=new Map,r=e=>{let r=t.get(e);r&&!n.has(e)&&n.set(e,r)};(e.lights??[]).forEach((e,t)=>r(e.id??`light${t}`));let i=e=>{for(let n of e){r(n.id);let e=`${n.id}/`;for(let i of t.keys())i.startsWith(e)&&t.get(i).parentId===n.id&&r(i);if(!n.children?.length)continue;let a=t.get(n.id)?.object;if(a){let e=new Map(n.children.map((e,t)=>[e.id,t]));a.children.sort((t,n)=>(e.get(t.userData.a3dId)??-1)-(e.get(n.userData.a3dId)??-1))}i(n.children)}};i(e.objects??[]);for(let[e,r]of t)n.has(e)||n.set(e,r);this.entries=n}async overrideGeneratorMaterial(e,t,n){let r=jt(t),i=await Gt(t,n,{vertexColors:r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map}),a=[];e.traverse(e=>{e.isMesh&&e.userData.materialTarget&&a.push(e)});for(let e of a)e.material.dispose(),e.material=i,Lt(i,e.geometry)}rngFor(e,t){return et(t??tt(this.def.seed??1,e))}behaviourContext(e){let t=this;return{object:e.object,base:{position:e.rest.position,rotation:new D().setFromQuaternion(e.rest.quaternion),scale:e.rest.scale},get pointer(){return t.input.pointer},hovered:()=>t.input.hovered.has(e.id),clicked:()=>t.input.clicked.has(e.id),scroll:()=>t.input.scroll,get camera(){return t.camera},rng:this.rngFor(e.id+`:behaviours`),find:e=>e===`camera`?t.camera:t.entries.get(e)?.object??null}}attachBehaviours(e){let t=e.def.behaviours??[];e.runners=[];for(let n of t){let t=ar[n.type];t?(e.runners.push(fr(n,t,this.behaviourContext(e),{settled:()=>this.settleEntrances})),($i.has(n.type)||n.when===`hover`||n.when===`click`)&&(e.interactive=!0)):this.ctx.issue(`unknown-catalog-id`,`Unknown behaviour "${n.type}"`,`objects#${e.id}.behaviours`)}e.runners.length&&(e.animated=!0)}resetBehaviours(){for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.def.behaviours?.length&&this.attachBehaviours(e),e.animator?.reset?e.animator.reset():e.animator?.mixer.setTime(0)}this.overrides?.reset()}async addLight(e,t){let n=await mi(e,this.def.environment?.shadows),r=e.id??`light${t}`;this.scene.add(n),(n instanceof j||n instanceof P)&&this.scene.add(n.target),n.userData.a3dId=r;let i={id:r,kind:`light`,def:e,object:n,rest:Zi(n),runners:[],animated:!1,topLevel:!1,interactive:!1};this.entries.set(r,i),this.attachBehaviours(i)}async addObject(e,t,n,r){let a=this.ctx,o,s,c,l,u,d=[],f=e.kind!==`particles`&&e.kind!==`generator`&&e.kind!==`photo`;try{switch(e.kind){case`mesh`:{let t=Ji(e.geometry),n=await Gt(e.material,a,{defaultColor:`#dddddd`});Lt(n,t),o=new I(t,n);break}case`text`:{let{buildText:t}=await i(async()=>{let{buildText:e}=await import(`./text-NO7lyCoH.js`);return{buildText:e}},__vite__mapDeps([17,18,8,2,4,1,9,7,19]),import.meta.url),n=await a.track(t(e,a));o=n.object,d=n.letters;break}case`svg`:{let{buildSvg:t}=await i(async()=>{let{buildSvg:e}=await import(`./svg-CJ_RtiER.js`);return{buildSvg:e}},__vite__mapDeps([20,18,8,2,4,1,9,7,19]),import.meta.url);o=await a.track(t(e,a));break}case`photo`:{let{buildPhoto:t}=await i(async()=>{let{buildPhoto:e}=await import(`./photo-BuVK-UvQ.js`);return{buildPhoto:e}},__vite__mapDeps([21,18,8,2,4,1,9,7]),import.meta.url),n=await a.track(t(e,a));o=n.object,s={object:n.object,dispose:()=>n.dispose()},u=n.effects,this.updaters.push((e,t)=>n.update(e,t,{pointer:this.input.pointer,scroll:this.input.scroll,camera:this.camera??null,reduced:this.settleEntrances})),n.applyCamera&&this.photoCameras.push(n.applyCamera);break}case`model`:{let{buildModel:t}=await i(async()=>{let{buildModel:e}=await import(`./model-D8-inS_D.js`);return{buildModel:e}},__vite__mapDeps([22,7,1,2,8,4,9]),import.meta.url),n=await a.track(t(e,a));o=n.object,c=n.animator;break}case`instances`:{let t=Ji(e.geometry),n=await Gt(e.material,a,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});Lt(n,t),o=Xi(e,t,n,this.rngFor(e.id,e.layout.seed),e=>B(e));break}case`particles`:{l=yr(e,this.rngFor(e.id,e.seed)),l.setViewport(this.viewportH),o=l.points;let t=l;this.updaters.push(e=>t.update(e));break}case`generator`:{let t=(await a.generators())[e.generator];if(!t){a.issue(`unknown-catalog-id`,`Unknown generator "${e.generator}"`,`objects#${e.id}.generator`),o=new he;break}let n=Qe.find(t=>t.id===e.generator),i=ft(n,e.params??{}),c=e.scale,l={position:[...e.position??[0,0,0]],scale:typeof c==`number`?[c,c,c]:c?[...c]:[1,1,1]},u={...a,siblings:r,rng:this.rngFor(e.id,e.seed),placement:l};if(s=await a.track(Promise.resolve(t(i,u))),o=s.object,s.update){let e=s.update.bind(s);this.updaters.push((t,n)=>e(t,n))}r.set(e.id,s),e.material&&n?.material&&await this.overrideGeneratorMaterial(o,e.material,a);break}default:o=new he}}catch(t){a.issue(e.kind===`model`||e.kind===`text`||e.kind===`svg`||e.kind===`photo`?`asset-load`:`build-error`,`${e.id}: ${t.message}`,`objects#${e.id}`),o=new he}if(this.disposed)return null;o.name=e.name??e.id,o.userData={...e.userData??{},...o.userData,a3dId:e.id,tags:e.tags??[]},Qi(o,e),e.visible===!1&&(o.visible=!1);let p=e.castShadow??(f?!0:void 0),m=e.receiveShadow??(f?!0:void 0);(p!==void 0||m!==void 0)&&o.traverse(e=>{e.isMesh&&(p!==void 0&&(e.castShadow=p),m!==void 0&&(e.receiveShadow=m))}),t.add(o);let h={id:e.id,kind:e.kind,def:e,object:o,rest:Zi(o),runners:[],animated:!1,topLevel:t===this.scene||t===this.camera&&!n,parentId:n,built:s,animator:c,particles:l,photoFx:u,interactive:!!e.href};this.entries.set(e.id,h),this.attachBehaviours(h);for(let t of d){let n={id:t.id,kind:`text`,def:t.def,object:t.object,rest:Zi(t.object),runners:[],animated:!0,topLevel:!1,parentId:e.id,interactive:!1};t.reveal&&n.runners.push(fr(t.reveal.def,t.reveal.impl,this.behaviourContext(n),{settled:()=>this.settleEntrances})),this.entries.set(t.id,n)}if(e.children?.length){let t=new Map,n=e.children;await Promise.all(n.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(n=>this.addObject(n,o,e.id,t))),ta(t,n),await Promise.all(n.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(n=>this.addObject(n,o,e.id,t)))}return h}removeEntry(e){let t=this.entries.get(e);if(t){t.object.traverse(t=>{let n=t.userData.a3dId;n&&n!==e&&this.entries.delete(n)}),t.object.removeFromParent();for(let e of t.runners)e.dispose();this.entries.delete(e)}}idsFor(e){let t=[];for(let n=e;n;n=n.parent){let e=n.userData?.a3dId;e&&this.entries.has(e)&&t.push(e)}return t}select(e){if(e.startsWith(`tag:`)){let t=e.slice(4),n=[],r=e=>{for(let i of e??[])i.tags?.includes(t)&&this.entries.has(i.id)&&n.push(i.id),r(i.children)};return r(this.def.objects),n}if(e.startsWith(`children:`)){let t=e.slice(9);return[...this.entries.values()].filter(e=>e.parentId===t).map(e=>e.id)}return kr(e,{object:()=>null,camera:null,issue:()=>void 0}).filter(e=>e!==``)}objectPosition(e){let t=this.entries.get(e);return t?t.object.getWorldPosition(new E):null}interactiveRoots(){let e=[];for(let t of this.entries.values())t.interactive&&t.kind!==`light`&&e.push(t.object);return e}fitShadows(){let e=[];if(this.scene.traverse(t=>{t instanceof j&&t.castShadow&&e.push(t)}),!e.length)return;let t=new A,n=new A;this.scene.updateMatrixWorld(!0);for(let e of this.entries.values())e.topLevel&&e.kind!==`particles`&&e.def.attach!==`camera`&&(n.setFromObject(e.object),n.isEmpty()||n.getSize(new E).length()>200||t.union(n));t.isEmpty()&&t.set(new E(-5,-1,-5),new E(5,5,5));let r=this.env?.ground?this.env.ground.position.y:t.min.y;t.expandByPoint(new E(t.min.x,r,t.min.z)),t.expandByPoint(new E(t.max.x,r,t.max.z)),t.expandByScalar(.3);for(let n of e)hi(n,t)}setViewport(e,t,n){this.viewportH=t*n,lt(this.camera,this.def.camera,e/Math.max(t,1),it(this.def.target?.aspect));for(let e of this.entries.values())e.particles?.setViewport(this.viewportH)}frame(e,t,n,r){this.input=n;for(let e of this.entries.values()){if(!e.animated)continue;let t=e.object;t.position.copy(e.rest.position),t.quaternion.copy(e.rest.quaternion),t.scale.copy(e.rest.scale),t.visible=e.rest.visible;let n=t;n.isLight&&e.rest.intensity!==void 0&&(n.intensity=e.rest.intensity,e.rest.color&&!this.timeline?.targets.has(e.id)&&n.color.copy(e.rest.color))}let i=this.def.timeline?n.timelineT??0:e;if(this.shots.length||this.timeline?.animatesCamera){let e=this.rig.rest;if(e.position.copy(this.cameraRest0.position),e.target.copy(this.cameraRest0.target),e.fov=this.cameraRest0.fov,e.zoom=this.cameraRest0.zoom,e.focus=this.cameraRest0.focus,this.shots.length){let t=Br(this.shots,i,e,{objectPosition:e=>this.objectPosition(e)});e.position.copy(t.position),e.target.copy(t.target),e.fov=t.fov,e.focus=t.focus}}this.timeline&&n.timelineT!==null&&this.timeline.apply(n.timelineT),this.overrides?.apply(e),this.rig.rest.focus!==void 0&&(this.focusWritten||this.rig.rest.focus!==this.cameraRest0.focus)&&(this.postfxParam?.(`dof`,`focus`,this.rig.rest.focus),this.focusWritten=!0);for(let n of this.entries.values())for(let r of n.runners)r.late||r.step(e,t);for(let e of this.entries.values()){let t=e.object.userData.setPointer?e.object:e.object.children[0],r=t?.userData.setPointer;if(!r)continue;r(n.pointer.x,n.pointer.y);let i=t.userData.setPointerLocal;if(i&&this.camera){let e=this.pointerOnPlane(t,n.pointer.x,n.pointer.y);e&&i(e.x,e.z)}}for(let n of this.updaters)n(e,t);for(let e of this.entries.values())e.animator?.mixer.update(t);let a=this.def.camera?.lookAt;this.rig.update(e,t,{pointer:n.pointer,scroll:n.scroll,followTarget:r,lookAt:a?this.objectPosition(a):null}),this.photoCameras.forEach((e,t)=>e(this.camera,t===0&&!this.rig.orbit)),this.camera.updateMatrixWorld();for(let n of this.entries.values())for(let r of n.runners)r.late&&r.step(e,t)}hasStatefulMotion(){if(this.def.camera?.controls===`follow`&&this.def.camera.follow)return!0;for(let e of this.entries.values())for(let t of e.runners)if(t.stateful)return!0;return!1}pointerRay=new ue;pointerOnPlane(e,t,n){e.updateWorldMatrix(!0,!1),this.camera.updateMatrixWorld(),this.pointerRay.setFromCamera(new w(t,n),this.camera);let r=e.matrixWorld.clone().invert(),i=this.pointerRay.ray.clone().applyMatrix4(r);if(Math.abs(i.direction.y)<1e-6)return null;let a=-i.origin.y/i.direction.y;return a<0?null:i.origin.addScaledVector(i.direction,a)}dispose(){this.disposed=!0;for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.built?.dispose?.()}this.rig?.dispose(),this.env?.dispose(),ot(this.scene);let e=this.scene.environment;e&&e.dispose();let t=this.scene.background;t&&t.isTexture&&t.dispose(),this.scene.traverse(e=>e.shadow?.dispose?.()),this.entries.clear()}};function ta(e,t){let n=[...e.entries()],r=new Map(t.map((e,t)=>[e.id,t]));n.sort((e,t)=>(r.get(e[0])??1/0)-(r.get(t[0])??1/0)),e.clear();for(let[t,r]of n)e.set(t,r)}var na=new WeakMap;function ra(e){let t=na.get(e);if(t===void 0){t=null;let n=e.ownerDocument.defaultView;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement)if(r.parentElement&&n?.getComputedStyle(r).position===`sticky`){t=r;break}e.isConnected&&na.set(e,t)}if(!t){let t=e.getBoundingClientRect();return{top:t.top,height:t.height}}let n=t.parentElement.getBoundingClientRect();return{top:n.top,height:Math.max(1,n.height-t.getBoundingClientRect().height)}}var ia=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`,`PageUp`,`PageDown`,`Home`,`End`]);function aa(){return{pointer:{x:0,y:0,inside:!1,down:!1,justPressed:!1},keys:new Set,pressed:new Set,swipe:null,clicks:[],scroll:0}}function oa(e){e.pressed.clear(),e.pointer.justPressed=!1,e.swipe=null,e.clicks.length=0}function sa(e,t,n){n?(e.keys.has(t)||e.pressed.add(t),e.keys.add(t)):e.keys.delete(t)}function ca(e,t,n){let r=e.ownerDocument.defaultView??window,i=!1,a=!1,o=null,s=t=>{let n=e.getBoundingClientRect();return{x:(t.clientX-n.left)/Math.max(n.width,1)*2-1,y:-((t.clientY-n.top)/Math.max(n.height,1)*2-1)}},c=e=>{let r=s(e);t.pointer.x=r.x,t.pointer.y=r.y,t.pointer.inside=!0,n.onPointerMove?.()},l=()=>{a=!0,t.pointer.inside=!0},u=()=>{a=!1,t.pointer.inside=!1,t.pointer.down=!1},d=e=>{i=!0;let n=s(e);t.pointer.x=n.x,t.pointer.y=n.y,t.pointer.down=!0,t.pointer.justPressed=!0,o={x:n.x,y:n.y,t:performance.now(),px:e.clientX,py:e.clientY}},f=e=>{if(t.pointer.down=!1,!o)return;let n=e.clientX-o.px,r=e.clientY-o.py,i=Math.hypot(n,r);i<8?t.clicks.push(s(e)):i>30&&performance.now()-o.t<600&&(t.swipe=Math.abs(n)>Math.abs(r)?n>0?`right`:`left`:r>0?`down`:`up`),o=null},p=()=>i||a||e.contains(e.ownerDocument.activeElement),m=e=>{if(!p())return;let r=e.target;(!r||r.tagName!==`INPUT`&&r.tagName!==`TEXTAREA`&&!r.isContentEditable)&&(sa(t,e.code,e.type===`keydown`),n.game&&ia.has(e.code)&&e.preventDefault())},h=()=>t.keys.clear(),g=t=>{e.contains(t.target)||(i=!1)};return e.addEventListener(`pointermove`,c),e.addEventListener(`pointerenter`,l),e.addEventListener(`pointerleave`,u),e.addEventListener(`pointerdown`,d),r.addEventListener(`pointerup`,f),r.addEventListener(`keydown`,m,{passive:!1}),r.addEventListener(`keyup`,m),r.addEventListener(`blur`,h),r.document.addEventListener(`pointerdown`,g,!0),n.game&&(e.style.touchAction=`none`,e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`)),{dispose(){e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerenter`,l),e.removeEventListener(`pointerleave`,u),e.removeEventListener(`pointerdown`,d),r.removeEventListener(`pointerup`,f),r.removeEventListener(`keydown`,m),r.removeEventListener(`keyup`,m),r.removeEventListener(`blur`,h),r.document.removeEventListener(`pointerdown`,g,!0)}}}function la(e){let t=e.ownerDocument.defaultView;if(!t)return 0;let n=ra(e),r=t.innerHeight||1,i=(r-n.top)/(r+n.height);return i<0?0:i>1?1:i}var Q=(e,t,n)=>e<t?t:e>n?n:e;function ua(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`&&t&&typeof t[e]==`number`?t[e]:n}function da(e,t){let n=Math.max(e.duration||0,.001);if(t===`timeline`)return{from:0,to:n,loop:e.loop,speed:1};let r=e.segments?.[t];if(!r)return null;let i=Array.isArray(r)?{from:r[0],to:r[1]}:r;return{from:Q(ua(i.from,e.markers,0),0,n),to:Q(ua(i.to,e.markers,n),0,n),loop:i.loop??!1,speed:typeof i.speed==`number`&&i.speed>0?i.speed:1}}function fa(e,t,n){let r=Math.abs(e.to-e.from),i=e.to>=e.from?1:-1,a=n===void 0?0:Math.abs(n-e.from),o=r<=0?0:Cn(Math.max(0,t*e.speed+a),r,e.loop);return e.from+i*o}function pa(e,t,n){let r=Math.max(e.duration||0,.001),i=n&&n!==`seek`&&n!==`timeline`&&e.segments?.[n]?n:``;if(!i)for(let n of Object.keys(e.segments??{})){let a=da(e,n);if(!a)continue;let o=Math.min(a.from,a.to),s=Math.max(a.from,a.to);if(t>=o&&(t<s||s>=r-1e-6&&t<=s)){i=n;break}}let a=``,o=-1/0;for(let[n,r]of Object.entries(e.markers??{}))typeof r==`number`&&r<=t+1e-6&&r>=o&&(o=r,a=n);return{time:t,duration:r,progress:Q(t/r,0,1),segment:i,marker:a}}var ma=class{def;hoverClock=0;clickAt=-1;active=null;toggled=new Map;prevLocal=null;lastLocal=0;lastT=0;pending=[];constructor(e){this.def=e}get duration(){return Math.max(this.def.duration||0,.001)}reset(){this.hoverClock=0,this.clickAt=-1,this.active=null,this.toggled.clear(),this.prevLocal=null,this.lastLocal=0,this.lastT=0,this.pending=[]}get local(){return this.lastLocal}play(e,t,n={}){let r=da(this.def,e);if(!r)return!1;let i=n.reverse?{...r,from:r.to,to:r.from}:r;return this.active={...i,name:e,start:t},this.toggled.set(e,!n.reverse),!0}toggle(e,t){let n=da(this.def,e);if(!n)return!1;let r=!this.toggled.get(e),i=r?n:{...n,from:n.to,to:n.from},a=this.active?.name===e?this.lastLocal:void 0,o=a!==void 0&&a>=Math.min(n.from,n.to)&&a<=Math.max(n.from,n.to);return this.active={...i,loop:!1,name:e,start:t,startLocal:o?a:void 0},this.toggled.set(e,r),!0}seek(e,t){let n=Q(ua(e,this.def.markers,0),0,this.duration);this.active={name:`seek`,from:n,to:n,loop:!1,speed:1,start:t}}autoRange(){let e=typeof this.def.autoplay==`string`?this.def.autoplay:null,t=e?da(this.def,e):null,n=typeof this.def.speed==`number`&&this.def.speed>0?this.def.speed:1;return t?{...t,speed:t.speed*n}:{from:0,to:this.duration,loop:this.def.loop,speed:n}}autoLocal(e){let t=this.autoRange(),n=this.def.trigger??`visible`;if(e.staticMotion)return typeof this.def.autoplay==`string`?t.to:fa({...t,speed:1},e.posterTime??0);if(n===`manual`||this.def.autoplay===!1)return t.from;if(n===`scroll`)return t.from+(t.to-t.from)*Q(e.scroll,0,1);if(e.deterministic)return fa(t,e.t);switch(n){case`hover`:{this.hoverClock+=e.hovered?e.dt:t.loop?0:-e.dt;let n=Math.abs(t.to-t.from)/t.speed;return t.loop||(this.hoverClock=Q(this.hoverClock,0,n)),fa(t,this.hoverClock)}case`click`:return e.clicked&&(this.clickAt=e.t),this.clickAt<0?t.from:fa(t,e.t-this.clickAt);default:return fa(t,e.t)}}update(e){let t;return t=this.active&&!e.staticMotion?fa(this.active,Math.max(0,e.t-this.active.start),this.active.startLocal):this.autoLocal(e),t=Q(t,0,this.duration),this.collectMarkers(this.prevLocal,t,e.t<this.lastT),this.prevLocal=t,this.lastLocal=t,this.lastT=e.t,t}collectMarkers(e,t,n){let r=this.def.markers;if(r&&!n)for(let[n,i]of Object.entries(r)){if(typeof i!=`number`)continue;let r;r=e===null?i<=t:t>e?i>e&&i<=t:t<e?this.isLoopingForward()?i>e||i<=t:i<e&&i>=t:!1,r&&this.pending.push({name:n,time:i})}}isLoopingForward(){let e=this.active??this.autoRange();return!!e.loop&&e.loop!==`pingpong`&&e.to>=e.from}info(){return pa(this.def,this.lastLocal,this.active?.name)}drainMarkers(){let e=this.pending;return this.pending=[],e}};function ha(e,t){if(typeof e!=`string`||!e.trim())return null;try{let n=new URL(e.trim(),t);return n.protocol===`http:`||n.protocol===`https:`?n.href:null}catch{return null}}var ga=new Set([`click`,`key`]),_a=class{defs;host;hoverPrev=new Set;insidePrev=!1;scrollPrev=null;visibleFired=!1;fired=new Set;queue=[];constructor(e,t){this.defs=e,this.host=t}targets(){let e=new Set;for(let t of this.defs)t.target&&(t.on===`click`||t.on===`hover`||t.on===`hoverEnd`)&&e.add(t.target);return e}reset(){this.hoverPrev.clear(),this.insidePrev=!1,this.scrollPrev=null,this.visibleFired=!1,this.fired.clear(),this.queue=[]}event(e,t){this.queue.length<64&&this.queue.push({name:e,payload:t})}fire(e,t,n){let r=0;return this.defs.forEach((i,a)=>{if(i.on===e&&!(e===`key`?i.key!==t:e===`event`?i.event!==t:(i.target??void 0)!==t)&&!(i.once&&this.fired.has(a))){this.fired.add(a),r++;for(let t of i.do??[])this.run(t,n&&ga.has(e))}}),r}step(e){for(let t of this.targets()){let n=e.hovered.has(t),r=this.hoverPrev.has(t);n&&!r&&this.fire(`hover`,t,!1),!n&&r&&this.fire(`hoverEnd`,t,!1)}this.hoverPrev=new Set([...e.hovered].filter(e=>this.isTarget(e))),e.pointerInside!==this.insidePrev&&this.fire(e.pointerInside?`hover`:`hoverEnd`,void 0,!1),this.insidePrev=e.pointerInside;for(let t of e.clicked)this.fire(`click`,t,e.userGesture);e.canvasClicked&&this.fire(`click`,void 0,e.userGesture);for(let t of e.pressed)this.fire(`key`,t,e.userGesture);e.visible&&!this.visibleFired&&(this.visibleFired=!0,this.fire(`visible`,void 0,!1)),this.scrollPrev!==null&&e.scroll!==this.scrollPrev&&this.defs.forEach((t,n)=>{if(t.on===`scroll`&&typeof t.at==`number`&&!(!(this.scrollPrev<t.at&&e.scroll>=t.at)||t.once&&this.fired.has(n))){this.fired.add(n);for(let e of t.do??[])this.run(e,!1)}}),this.scrollPrev=e.scroll,this.flush()}flush(){for(let e=0;this.queue.length&&e<16;e++){let e=this.queue;this.queue=[];for(let t of e)this.fire(`event`,t.name,!1)}this.queue=[]}isTarget(e){return this.defs.some(t=>t.target===e)}run(e,t){let n=e;if(typeof n.play==`string`)this.host.play(n.play,n.reverse===!0);else if(typeof n.toggle==`string`)this.host.toggle(n.toggle);else if(typeof n.seek==`number`||typeof n.seek==`string`)this.host.seek(n.seek);else if(n.set&&typeof n.set==`object`){let e=n.set;typeof e.path==`string`&&e.value!==void 0&&this.host.set(e.path,e.value,typeof n.duration==`number`?n.duration:0,typeof n.ease==`string`?n.ease:void 0)}else typeof n.emit==`string`?this.host.emit(n.emit,n.payload):typeof n.openUrl==`string`?t?this.host.openUrl(n.openUrl,typeof n.newTab==`boolean`?n.newTab:void 0):this.host.emit(`openUrl`,{url:n.openUrl,blocked:!0}):n.playClip!==void 0&&typeof n.target==`string`&&this.host.playClip(n.target,n.playClip,{loop:n.loop,speed:n.speed,crossfade:n.crossfade})}},va=`top bottom`,ya=`bottom top`;function ba(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:e.endsWith(`%`)?Number(e.slice(0,-1))/100*t:e.endsWith(`px`)?Number(e.slice(0,-2)):null}function xa(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==2)return null;let i=ba(r[0],t),a=ba(r[1],n);return i===null||a===null?null:i-a}function Sa(e,t,n,r=va,i=ya){let a=xa(r,t,n)??-n,o=xa(i,t,n)??t,s=0-e;if(Math.abs(o-a)<1e-6)return+(s>=o);let c=(s-a)/(o-a);return c<0?0:c>1?1:c}var Ca=8e3;function wa(e,t,n=Ca){let r=[],i=0;if(e.traverseVisible(e=>{let t=e;if(!(t.isMesh||e.isLine)||e.isPoints)return;let n=t.geometry?.getAttribute(`position`);if(!n)return;let a=t.isInstancedMesh?t.count:1;a&&(r.push(t),i+=n.count*a)}),!r.length||!i)return null;let a=Math.max(1,Math.ceil(i/n)),o=new E,s=new k,c=new k,l=0,u=0;for(let e of r){let n=e.geometry.getAttribute(`position`),r=e,i=e.isSkinnedMesh?e:null,d=r.isInstancedMesh?r.count:1;for(let f=0;f<d;f++){r.isInstancedMesh?c.multiplyMatrices(e.matrixWorld,(r.getMatrixAt(f,s),s)):c.copy(e.matrixWorld);for(let e=f%a;e<n.count;e+=a)if(o.fromBufferAttribute(n,e),i&&i.applyBoneTransform(e,o),o.applyMatrix4(c),t.containsPoint(o)?l++:u++,l&&u)return`partial`}}return!l&&!u?null:u?`partial`:`full`}function Ta(e,t,n){if(n!==`parts`){let r=e.worldToLocal(t.clone()),i=n.heightAt(r.x,r.z);return Number.isFinite(i)&&r.y<i}let r=new A,i=new k,a=!1;return e.traverseVisible(e=>{let n=e;if(a||!n.isMesh||!n.geometry)return;n.geometry.boundingBox||n.geometry.computeBoundingBox();let o=n.geometry.boundingBox,s=e;if(s.isInstancedMesh)for(let e=0;e<s.count&&!a;e++)s.getMatrixAt(e,i),r.copy(o).applyMatrix4(i.premultiply(s.matrixWorld)).containsPoint(t)&&(a=Da(n,t,r,e));else r.copy(o).applyMatrix4(n.matrixWorld).containsPoint(t)&&(a=Da(n,t,r))}),a}var Ea=[new E(1,0,0),new E(-1,0,0),new E(0,1,0),new E(0,-1,0),new E(0,0,1),new E(0,0,-1)];function Da(e,t,n,r){let i=(Array.isArray(e.material)?e.material:[e.material]).filter(Boolean),a=i.map(e=>e.side);for(let e of i)e.side=2;try{let i=new ue;return i.far=n.getSize(new E).length()+.001,Ea.every(n=>(i.set(t,n),i.intersectObject(e,!1).some(e=>r===void 0||e.instanceId===r)))}finally{i.forEach((e,t)=>e.side=a[t])}}var Oa={none:0,aces:4,agx:6,neutral:7,reinhard:2};function ka(e){if(e.scripts?.length||e.ui?.elements?.length||e.physics||e.audio)return!0;let t=e=>!!e?.some(e=>!!e.body||t(e.children));return t(e.objects)}function Aa(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e.target?.aspect??``);return t&&Number(t[1])>0&&Number(t[2])>0?Number(t[1])/Number(t[2]):16/9}var ja=8,Ma=2e4,$=new Set;function Na(e){for(;$.size>=ja;){let t=null;for(let n of $)n!==e&&n.releasable()&&(!t||n.lastSeen<t.lastSeen)&&(t=n);if(!t)return;t.release()}}function Pa(){return $.size}var Fa=class{container;options;scene;canvas;lastSeen=0;released=!1;releaseTimer=null;placeholder=null;readyCalled=!1;ready;issues=[];input;renderer=null;world=null;game=null;postfx=null;quality=r(`high`);qualityAuto=!1;perfClock=0;slowFor=0;renderSamples=1;inputState=aa();inputBinding=null;resolveAsset;deterministic;t=0;tl=null;interactions=null;eventListeners=new Map;scrollOverride=null;tlScroll=null;raf=0;playing=!1;visible=!0;started=!1;timeScale=1;staticMotion=!1;lastNow=0;fps=0;building=null;rebuilding=!1;disposed=!1;hovered=new Set;resizeObs=null;interObs=null;readyResolve;readyReject;raycaster=new ue;width=1;height=1;lastStats={triangles:0,drawCalls:0,geometries:0,textures:0};onVisibility=()=>this.updateRunning();editor;overlay=null;worldListeners=new Set;constructor(e,t,n){this.container=e,this.options=n,this.scene=t,this.deterministic=!!n.deterministic,this.resolveAsset=_t(n),this.ready=new Promise((e,t)=>{this.readyResolve=e,this.readyReject=t}),this.ready.catch(()=>void 0);let r=e.ownerDocument;this.canvas=r.createElement(`canvas`),this.canvas.style.cssText=`display:block;width:100%;height:100%;outline:none;touch-action:manipulation;`;let i=r.defaultView?.getComputedStyle(e).position;i&&i!==`static`||(e.style.position=`relative`);let a=this;n.editor&&(this.editor={world:()=>a.world,renderer:()=>a.renderer,setOverlay:e=>{a.overlay=e},render:()=>a.render(),onWorld:e=>(a.worldListeners.add(e),()=>a.worldListeners.delete(e)),running:()=>!!a.raf}),this.input={pointer(e,t){a.inputState.pointer.x=e,a.inputState.pointer.y=t,a.inputState.pointer.inside=!0,a.inputInteractions()},key(e,t){sa(a.inputState,e,t),a.inputInteractions()},click(e,t){let n=e??a.inputState.pointer.x,r=t??a.inputState.pointer.y;a.inputState.pointer.x=n,a.inputState.pointer.y=r,a.inputState.pointer.inside=!0,a.inputState.pointer.justPressed=!0,a.inputState.clicks.push({x:n,y:r}),a.inputInteractions()},down(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.inside=!0,n.justPressed=!n.down,n.down=!0},up(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.down=!1},swipe(e){a.inputState.swipe=e},scroll(e){a.setScrollProgress(e),a.inputInteractions()}},e.appendChild(this.canvas),this.inputBinding=ca(e,this.inputState,{game:t.target?.kind===`game`}),this.measure(),typeof ResizeObserver<`u`&&(this.resizeObs=new ResizeObserver(()=>this.resize()),this.resizeObs.observe(e));let o=t.target??{},s=n.reducedMotion??(typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),c=o.reducedMotion??(o.kind===`game`?`ignore`:`static`);s&&!this.deterministic&&(c===`static`?this.staticMotion=!0:c===`slow`&&(this.timeScale=.5)),this.deterministic||o.lazy===!1||typeof IntersectionObserver>`u`?this.start():(this.visible=!1,this.interObs=new IntersectionObserver(e=>{let t=e.some(e=>e.isIntersecting);this.visible=t,this.lastSeen=performance.now(),this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null,t?this.start():this.releasable()&&(this.releaseTimer=setTimeout(()=>this.release(),Ma)),this.updateRunning()},{rootMargin:`200px 0px`}),this.interObs.observe(e),this.armStartFallback()),r.addEventListener(`visibilitychange`,this.onVisibility)}fallbackCleanup=null;armStartFallback(){let e=this.container.ownerDocument,t=e.defaultView;if(!t)return;let n=()=>{if(this.started||this.disposed)return a();if(e.visibilityState===`hidden`||!this.container.isConnected)return;let n=this.container.getBoundingClientRect(),r=t.innerHeight||e.documentElement.clientHeight,i=t.innerWidth||e.documentElement.clientWidth;n.bottom>=-200&&n.top<=r+200&&n.right>=0&&n.left<=i&&(n.width>0||n.height>0)&&(this.visible=!0,this.lastSeen=performance.now(),this.start(),this.updateRunning(),a())},r=[setTimeout(n,500),setTimeout(n,2e3)],i=t.requestAnimationFrame(()=>i=t.requestAnimationFrame(n)),a=()=>{for(let e of r)clearTimeout(e);t.cancelAnimationFrame(i),t.removeEventListener(`load`,n),t.removeEventListener(`scroll`,n),e.removeEventListener(`visibilitychange`,n),this.fallbackCleanup=null};t.addEventListener(`load`,n),t.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`visibilitychange`,n),this.fallbackCleanup=a}createRenderer(){let e=this.scene.target??{},t=new Ae({canvas:this.canvas,antialias:e.antialias!==!1,alpha:!!e.transparent,premultipliedAlpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:this.deterministic});if(!t.getContext())throw Error(`no context`);return this.configureRenderer(t),t.info.autoReset=!1,t}configureRenderer(e){let t=this.scene.target??{};e.outputColorSpace=N,e.toneMapping=Oa[t.toneMapping??`aces`]??4,e.toneMappingExposure=t.exposure??1,this.quality=r(n(t.quality,this.deviceHints(e))),this.qualityAuto=(t.quality??`auto`)===`auto`&&!this.deterministic&&!this.options.editor,this.perfClock=this.slowFor=0;let i=this.options.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,this.quality.dprCap);e.setPixelRatio(i);let a=ci(this.scene);if(e.shadowMap.enabled=a.enabled,e.shadowMap.type=a.type,t.transparent)e.setClearColor(0,0);else{let t=this.scene.environment?.background;e.setClearColor(typeof t==`string`&&t!==`transparent`?B(t):new F(0),1)}}start(){if(!(this.started||this.disposed)){if(this.started=!0,Na(this),this.released){let e=this.container.ownerDocument.createElement(`canvas`);e.style.cssText=this.canvas.style.cssText,this.canvas.replaceWith(e),this.canvas=e,this.released=!1}try{this.renderer=this.createRenderer(),$.add(this)}catch(e){this.report({code:`webgl-unavailable`,message:`WebGL is not available: ${e.message}`}),this.readyReject(Error(`webgl-unavailable`));return}this.measure(),this.renderer.setSize(this.width,this.height,!1),this.building=this.buildAll().then(()=>{this.disposed||(this.deterministic?(this.t=0,this.frame(0)):this.staticMotion?(this.t=this.scene.target?.posterTime??0,this.game?.advanceTo(this.t),this.frame(0),this.renderStill()):(this.frame(0),this.playing=!0,this.updateRunning()),this.placeholder?.remove(),this.placeholder=null,this.readyResolve(),this.readyCalled||this.options.onReady?.(this),this.readyCalled=!0)}).catch(e=>{this.report({code:`build-error`,message:e.message}),this.readyReject(e)})}}makeContext(e){return{scene:this.scene,rng:et(this.scene.seed??1),siblings:new Map,color:e=>B(e),resolveAsset:this.resolveAsset,renderer:this.renderer,deterministic:this.deterministic,quality:this.quality.tier,track:t=>(e.push(t.catch(()=>void 0)),this.trackProgress(t),t),onUpdate:()=>void 0,issue:(e,t,n)=>this.report({code:e,message:t,path:n}),shaders:pn,generators:mn}}async buildWorld(){let e=[],t=this.makeContext(e),n=await ea.create(J(this.scene),t,this.width/Math.max(this.height,1),this.canvas,!!this.options.editor);return await Promise.all(e),await Promise.all(e),n.setViewport(this.width,this.height,this.renderer.getPixelRatio()),n}async attachWorld(e){this.world=e,this.attachMotion(e),e.settleEntrances=this.staticMotion,await this.buildPostFx(e),this.renderer?.shadowMap&&(this.renderer.shadowMap.needsUpdate=!0);for(let e of this.worldListeners)try{e()}catch{}}async buildAll(){let e=await this.buildWorld();if(this.disposed)e.dispose();else{if(await this.attachWorld(e),ka(this.scene)){let{GameHost:t}=await i(async()=>{let{GameHost:e}=await import(`./game-43BhY_EE.js`);return{GameHost:e}},__vite__mapDeps([23,7,1,2,6,8,4,9]),import.meta.url);this.game=await t.create({scene:J(this.scene),container:this.container,input:this.inputState,resolveAsset:this.resolveAsset,scriptSources:this.options.scriptSources,deterministic:this.deterministic,issue:e=>this.report(e),rebuild:async()=>{let e=this.world,t=await this.buildWorld();return e?.dispose(),await this.attachWorld(t),t}},e);let n=this.game,r=n.emit.bind(n);n.emit=(e,t)=>{r(e,t),this.notify(e,t),this.dispatchMotionEvent(e,t)}}try{this.renderer?.compile(e.scene,e.camera)}catch{}}}loadTotal=0;loadDone=0;trackProgress(e){if(!this.options.onProgress)return;this.loadTotal++;let t=()=>{this.loadDone++;try{this.options.onProgress?.(this.loadDone,this.loadTotal)}catch{}};e.then(t,t)}notify(e,t){try{this.options.onEvent?.(e,t)}catch{}}emit(e,t){if(this.game)return this.game.emit(e,t);this.notify(e,t),this.dispatchMotionEvent(e,t)}dispatchMotionEvent(e,t){for(let n of this.eventListeners.get(e)??[])try{n(t)}catch{}this.interactions?.event(e,t)}report(e){this.issues.push(e);try{this.options.onError?.(e)}catch{}this.options.onError||console.warn(`[agent3d] ${e.code}: ${e.message}`)}updateRunning(){let e=this.container.ownerDocument.visibilityState===`hidden`,t=this.scene.target?.pauseOffscreen!==!1,n=this.playing&&!this.disposed&&!e&&(this.visible||!t)&&!!this.world;if(n&&!this.raf){this.lastNow=performance.now();let e=t=>{this.raf=requestAnimationFrame(e);let n=Math.min(Math.max((t-this.lastNow)/1e3,0),.1);this.lastNow=t,n>.002&&(this.fps=this.fps?this.fps*.9+1/n*.1:1/n),this.qualityAuto&&this.adaptQuality(n),this.tick(n*this.timeScale)};this.raf=requestAnimationFrame(e)}else!n&&this.raf&&(cancelAnimationFrame(this.raf),this.raf=0)}tick(e){this.world&&!this.rebuilding&&(this.game?.pendingRestart?(this.rebuilding=!0,this.game.restart().then(()=>{this.rebuilding=!1,this.t=0,this.resetMotion()})):(e=Math.max(e,0),this.t=Math.max(this.t+e,0),this.game?.advance(e),this.frame(e)))}attachMotion(e){this.tl=this.scene.timeline?new ma(this.scene.timeline):null,this.tlScroll=null,e.postfxParam=(e,t,n)=>this.postfx?.setParam?.(e,t,n);let t=this.scene.interactions??[];this.interactions=t.length?new _a(t,{play:(e,t)=>this.playSegment(e,{reverse:t}),toggle:e=>{this.tl?.toggle(e,this.t)||this.unknownSegment(e)},seek:e=>this.tl?.seek(e,this.t),set:(t,n,r,i)=>e.overrides.set(t,n,this.t,r,i),emit:(e,t)=>this.emit(e,t),openUrl:(e,t)=>this.openUrl(e,t),playClip:(t,n,r)=>{let i=e.entries.get(t)?.animator;i?i.play(n,r):this.report({code:`interaction`,message:`playClip: "${t}" is not a model with animation clips`,path:`interactions`})}}):null}handledClicks=0;handledKeys=new Set;inputInteractions(){let e=this.world;if(!this.deterministic||!this.interactions||!e)return;let t=this.inputState,n=e.interactiveRoots(),r=new Set(t.pointer.inside?this.pickIds(t.pointer.x,t.pointer.y,n):[]),i=new Set;for(let e of t.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,n))i.add(t);let a=new Set([...t.pressed].filter(e=>!this.handledKeys.has(e)));this.interactions.step({hovered:r,pointerInside:t.pointer.inside,clicked:i,canvasClicked:t.clicks.length>this.handledClicks,pressed:a,scroll:this.scrollValue(),visible:!0,userGesture:!1}),this.handledClicks=t.clicks.length;for(let e of a)this.handledKeys.add(e)}resetMotion(){this.tl?.reset(),this.interactions?.reset(),this.tlScroll=null}unknownSegment(e){this.report({code:`interaction`,message:`Unknown timeline segment "${e}"`,path:`timeline.segments`})}timelineLocal(e,t,n){let r=this.scene.timeline;return!r||!this.world?.timeline||!this.tl?null:this.tl.update({t:this.t,dt:e,deterministic:this.deterministic,staticMotion:this.staticMotion,posterTime:this.scene.target?.posterTime,hovered:t,clicked:n,scroll:r.trigger===`scroll`?this.timelineScroll(e):0})}timelineScroll(e){let t=this.scene.timeline;if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion)return this.scrollValue();let n=this.container.ownerDocument.defaultView,r=ra(this.container),i=Sa(r.top,r.height,n?.innerHeight||1,t.scroll?.start,t.scroll?.end),a=Math.min(Math.max(t.scroll?.smoothing??.8,0),.99);return this.tlScroll===null||a<=0?this.tlScroll=i:this.tlScroll+=(i-this.tlScroll)*(1-a**(Math.max(e,0)*60)),Math.abs(i-this.tlScroll)<1e-4&&(this.tlScroll=i),this.tlScroll}scrollValue(){if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion){let e=this.scene.timeline,t=e?.trigger===`scroll`&&e.duration>0?e.duration:4;return Math.min(Math.max(this.t/t,0),1)}return la(this.container)}openUrl(e,t){let n=this.container.ownerDocument.defaultView,r=n?ha(e,n.location.href):null;if(this.emit(`openUrl`,{url:r??e,blocked:!r||this.deterministic}),!r||!n||this.deterministic)return;let i=new URL(r).origin!==n.location.origin;t??i?n.open(r,`_blank`,`noopener,noreferrer`):n.location.assign(r)}playSegment(e,t={}){this.tl?.play(e,this.t,t)||this.unknownSegment(e)}trigger(e,t){this.interactions?.fire(e,t,!this.deterministic),this.interactions?.flush()}on(e,t){let n=this.eventListeners.get(e);return n||this.eventListeners.set(e,n=new Set),n.add(t),()=>n.delete(t)}setScrollProgress(e){this.scrollOverride=e===null||!Number.isFinite(e)?null:Math.min(Math.max(e,0),1)}pickIds(e,t,n){if(!this.world||!n.length)return[];this.raycaster.setFromCamera(new w(e,t),this.world.camera);let r=this.raycaster.intersectObjects(n,!0).find(e=>e.object.visible&&!e.object.isPoints);return r?this.world.idsFor(r.object):[]}frame(e){let t=this.world;if(!t)return;let n=this.inputState,r=t.interactiveRoots();this.hovered=new Set(n.pointer.inside?this.pickIds(n.pointer.x,n.pointer.y,r):[]);let i=new Set;for(let e of n.clicks){let n=this.pickIds(e.x,e.y,r);for(let e of n)i.add(e);if(this.options.onClick){let r=[...t.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object),i=n[0]??this.pickIds(e.x,e.y,r)[0]??null;try{this.options.onClick(i,{x:e.x,y:e.y})}catch{}}let a=n.map(e=>t.entries.get(e)?.def).find(e=>e&&`href`in e&&e.href);a?.href&&!this.deterministic&&this.navigate(a.href)}let a=[...this.hovered].some(e=>!!t.entries.get(e)?.def?.href)||[...this.hovered].some(e=>t.entries.get(e)?.interactive)?`pointer`:``;this.canvas.style.cursor!==a&&(this.canvas.style.cursor=a);let o=this.scrollValue(),s=i;if(this.handledClicks){s=new Set;for(let e of n.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,r))s.add(t)}this.interactions?.step({hovered:this.hovered,pointerInside:n.pointer.inside,clicked:s,canvasClicked:n.clicks.length>this.handledClicks,pressed:this.handledKeys.size?new Set([...n.pressed].filter(e=>!this.handledKeys.has(e))):n.pressed,scroll:o,visible:!0,userGesture:!this.deterministic});let c={pointer:n.pointer,scroll:o,hovered:this.hovered,clicked:i,timelineT:this.timelineLocal(e,n.pointer.inside,n.clicks.length>0)};for(let e of this.tl?.drainMarkers()??[])this.emit(e.name,{marker:e.name,time:e.time});this.interactions?.flush();let l=this.scene.camera?.follow?.target;t.frame(this.t,e,c,l?t.entries.get(l)?.object:null),this.game?.hud?.setTimeline(this.tl&&c.timelineT!==null?this.tl.info():null),this.game?.afterFrame(),this.render(),oa(n),this.handledClicks=0,this.handledKeys.clear()}navigate(e){let t=this.container.ownerDocument.defaultView;if(!t)return;let n=ha(e,t.location.href);if(!n)return;let r=new URL(n);r.origin===t.location.origin?t.location.assign(r.href):t.open(r.href,`_blank`,`noopener,noreferrer`)}render(e=!0){let t=this.renderer,n=this.world;if(!t||!n)return;let r=e?this.overlay:null,i=r?.viewCamera?.()??null,a=n.camera,o=i&&i!==a?{p:a.position.clone(),q:a.quaternion.clone(),proj:a.projectionMatrix.clone(),inv:a.projectionMatrixInverse.clone(),near:a.near,far:a.far}:null;if(i&&o){i.updateMatrixWorld(),i.matrixWorld.decompose(a.position,a.quaternion,new E),a.projectionMatrix.copy(i.projectionMatrix),a.projectionMatrixInverse.copy(i.projectionMatrixInverse);let e=i;typeof e.near==`number`&&(a.near=e.near,a.far=e.far),a.updateMatrixWorld(!0)}if(t.info.reset(),this.postfx?this.postfx.render(this.t,{samples:this.renderSamples}):t.render(n.scene,n.camera),this.renderSamples===1&&(this.lastStats={triangles:t.info.render.triangles,drawCalls:t.info.render.calls,geometries:t.info.memory.geometries,textures:t.info.memory.textures}),r)try{r.draw(t,a)}catch(e){this.report({code:`editor-overlay`,message:e.message}),this.overlay=null}o&&(a.position.copy(o.p),a.quaternion.copy(o.q),a.projectionMatrix.copy(o.proj),a.projectionMatrixInverse.copy(o.inv),a.near=o.near,a.far=o.far,a.updateMatrixWorld(!0))}releasable(){return!!this.renderer&&!!this.world&&!this.game&&!this.deterministic&&!this.options.editor&&!this.visible&&!this.disposed&&!this.released&&!ka(this.scene)}release(){if(!this.releasable())return;this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null;let e=``;try{this.render(),e=this.canvas.toDataURL(`image/webp`,.85)}catch{}if(e&&e.length>32){let t=this.container.ownerDocument.createElement(`img`);t.alt=``,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;`,t.src=e,this.placeholder?.remove(),this.placeholder=t,this.canvas.after(t)}this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.postfx?.dispose(),this.postfx=null,this.world?.dispose(),this.world=null,this.renderer?.dispose(),this.renderer?.forceContextLoss(),this.renderer=null,$.delete(this),this.released=!0,this.started=!1,this.building=null}play(){this.playing=!0,this.start(),this.updateRunning()}pause(){this.playing=!1,this.updateRunning(),this.deterministic||this.renderStill()}async seek(e){if(this.started||this.start(),await this.building,!this.world)return;let t=Math.max(0,e);t<this.t-1e-9&&(this.game?await this.game.restart():this.world.resetBehaviours(),this.t=0,this.resetMotion(),this.world.frame(0,0,{pointer:this.inputState.pointer,scroll:0,hovered:new Set,clicked:new Set,timelineT:this.world.timeline?0:null})),this.advanceMotionGrid(t);let n=t-this.t;this.t=t,this.game?.advanceTo(t),this.frame(n)}advanceMotionGrid(e){let t=this.world;if(!t||!this.deterministic||this.game||!t.hasStatefulMotion())return;let n=this.scene.camera?.follow?.target,r=n?t.entries.get(n)?.object:null;for(let n of dr(this.t,e)){let e=n-this.t;this.t=n;let i=this.inputState,a=t.interactiveRoots(),o=new Set(i.pointer.inside?this.pickIds(i.pointer.x,i.pointer.y,a):[]);t.frame(this.t,e,{pointer:i.pointer,scroll:this.scrollValue(),hovered:o,clicked:new Set,timelineT:this.timelineLocal(e,i.pointer.inside,!1)},r)}}time(){return this.t}async update(e){if(await this.building,this.scene=e,!this.renderer)return;this.renderer&&this.configureRenderer(this.renderer),this.game?.dispose(),this.game=null;let t=this.world;this.world=null,t?.dispose(),this.postfx?.dispose(),this.postfx=null,this.building=this.buildAll(),await this.building,this.frame(0)}measure(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||300),t=this.container.clientHeight;t||=Math.round(e/Aa(this.scene)),this.width=e,this.height=Math.max(1,t)}resize(){this.renderer&&(this.measure(),this.renderer.setSize(this.width,this.height,!1),this.world?.setViewport(this.width,this.height,this.renderer.getPixelRatio()),this.postfx?.setSize(this.width,this.height),this.world&&(!this.raf||this.deterministic)&&this.render())}stats(){return{...this.lastStats,fps:this.deterministic?void 0:Math.round(this.fps)||void 0}}inspect(){let e=this.world,t=e?.camera,n={objects:[],camera:{position:[0,0,0],target:[0,0,0]}};if(!e||!t)return n;e.scene.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let r=new f().setFromProjectionMatrix(new k().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),i=t.getWorldPosition(new E),a=new A,o=new E,s;for(let c of e.entries.values()){if(!c.topLevel)continue;if(a.setFromObject(c.object),c.particles){let e=c.object.geometry;e.boundingBox&&a.copy(e.boundingBox).applyMatrix4(c.object.matrixWorld)}if(a.isEmpty())continue;let e=0,l=1/0,u=1/0,d=-1/0,f=-1/0;for(let n=0;n<8;n++)o.set(n&1?a.max.x:a.min.x,n&2?a.max.y:a.min.y,n&4?a.max.z:a.min.z),r.containsPoint(o)&&e++,o.project(t),l=Math.min(l,o.x),d=Math.max(d,o.x),u=Math.min(u,o.y),f=Math.max(f,o.y);let p=e===8?`full`:r.intersectsBox(a)?`partial`:`none`;p===`partial`&&!c.particles&&(p=wa(c.object,r)??p);let m=Math.max(-1,l),h=Math.min(1,d),g=Math.max(-1,u),_=Math.min(1,f),v=p===`none`||a.containsPoint(i)?+!!a.containsPoint(i):Math.max(0,h-m)*Math.max(0,_-g)/4;!s&&c.kind!==`particles`&&a.containsPoint(i)&&(c.kind!==`generator`||Ta(c.object,i,c.def.generator===`terrain`&&c.built?.heightAt?{heightAt:c.built.heightAt}:`parts`))&&(s=c.id),n.objects.push({id:c.id,min:[a.min.x,a.min.y,a.min.z],max:[a.max.x,a.max.y,a.max.z],inView:p,screenCoverage:Math.round(Math.min(1,v)*1e3)/1e3})}let c=e.rig.orbit?e.rig.orbit.target:e.rig.rest.target;return n.camera={position:[i.x,i.y,i.z],target:[c.x,c.y,c.z]},s&&(n.camera.insideObject=s),n}snapshot(e=`image/png`,t){this.renderSamples=this.deterministic&&this.postfx?.stillSamples||1;try{this.render(!1)}finally{this.renderSamples=1}return this.canvas.toDataURL(e,t)}async snapshotHighQuality(e=16,t=`image/png`,n){this.started||this.start(),await this.building;let a=this.renderer,o=this.world;if(!a||!o)return this.canvas.toDataURL(t,n);let s=Math.max(1,Math.min(64,Math.round(e))),c=null;if(!this.postfx){let{createPostFx:e}=await i(async()=>{let{createPostFx:e}=await import(`./postfx-Bcnem9ci.js`);return{createPostFx:e}},__vite__mapDeps([24,1,2,8,4,9,7,6]),import.meta.url);c=e([],{renderer:a,scene:o.scene,camera:o.camera,width:this.width,height:this.height,quality:r(`ultra`),antialias:this.scene.target?.antialias!==!1},()=>void 0)}let l=this.postfx??c;try{return l.render(this.t,{samples:s}),this.canvas.toDataURL(t,n)}finally{c?.dispose()}}deviceHints(e){let t=globalThis.navigator??{},n;try{let t=e.getContext(),r=t.getExtension(`WEBGL_debug_renderer_info`);n=String(t.getParameter(r?r.UNMASKED_RENDERER_WEBGL:t.RENDERER)??``)}catch{}let r=t.userAgent??``;return{deterministic:this.deterministic,mobile:t.userAgentData?.mobile??/Mobi|Android|iPhone|iPad|iPod/i.test(r),cores:t.hardwareConcurrency,memoryGb:t.deviceMemory,gpu:n}}async buildPostFx(e,t=!1){if(t||(this.postfx?.dispose(),this.postfx=null),!this.scene.postfx?.length||!this.renderer)return;let{createPostFx:n}=await i(async()=>{let{createPostFx:e}=await import(`./postfx-Bcnem9ci.js`);return{createPostFx:e}},__vite__mapDeps([24,1,2,8,4,9,7,6]),import.meta.url);if(this.world!==e||!this.renderer)return;let r=n(this.scene.postfx,{renderer:this.renderer,scene:e.scene,camera:e.camera,width:this.width,height:this.height,quality:this.quality,antialias:this.scene.target?.antialias!==!1},e=>this.report({code:`unknown-catalog-id`,message:`Unknown post effect "${e}"`,path:`postfx`}));if(await r.ready,this.world!==e)return r.dispose();this.postfx?.dispose(),this.postfx=r}renderStill(){let e=this.postfx?.stillSamples??0;if(!(e<2||!this.world)){this.renderSamples=e;try{this.render()}finally{this.renderSamples=1}}}adaptQuality(e){let t=this.renderer;if(!t||!this.world||this.rebuilding||(this.perfClock+=e,this.perfClock<2)||(this.fps<40?this.slowFor+=e:this.slowFor=Math.max(0,this.slowFor-e),this.slowFor<3))return;if(this.slowFor=0,this.perfClock=0,this.options.pixelRatio===void 0&&t.getPixelRatio()>1.01){t.setPixelRatio(Math.max(1,t.getPixelRatio()*.75)),this.resize();return}let n=u(this.quality.tier);n?(this.quality=r(n),this.scene.postfx?.length&&this.buildPostFx(this.world,!0)):this.qualityAuto=!1}pick(e,t){let n=this.world;if(!n)return null;let r=[...n.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object);return this.pickIds(e,t,r)[0]??null}state(){return this.game?.state??{}}dispose(){this.disposed||(this.disposed=!0,this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.resizeObs?.disconnect(),this.interObs?.disconnect(),this.fallbackCleanup?.(),this.container.ownerDocument.removeEventListener(`visibilitychange`,this.onVisibility),this.inputBinding?.dispose(),this.overlay=null,this.worldListeners.clear(),this.game?.dispose(),this.postfx?.dispose(),this.world?.dispose(),this.renderer?.dispose(),this.renderer?.forceContextLoss(),$.delete(this),this.releaseTimer&&clearTimeout(this.releaseTimer),this.placeholder?.remove(),this.canvas.remove())}};function Ia(e,t,n={}){let r=new Fa(e,t,n);return r.canvas.isConnected&&r.resize(),r}var La=class extends ln{mountPlayer(e,t,n){return Ia(e,t,n)}};function Ra(e=`agent3d-scene`){un(La,e)}var za=e({Agent3DSceneElement:()=>La,bindSceneData:()=>J,liveContextCount:()=>Pa,mountScene:()=>Ia,version:()=>t});Ra();var Ba=globalThis;Ba.Agent3D||={mountScene:Ia,version:t,bindSceneData:J,liveContexts:Pa};export{La as Agent3DSceneElement,Gt as a,J as bindSceneData,At as c,$t as i,Pa as liveContextCount,Ia as mountScene,Hr as n,Kt as o,Vr as r,jt as s,za as t,t as version};
|
|
572
|
+
\t#include <tonemapping_fragment>`)},n.customProgramCacheKey=()=>`agent3d-shadow-catcher`,n}var Vi=.45;function Hi(e,t){let n=e.background;return e.fog?.color?e.fog.color:t||(n&&typeof n==`object`&&`sky`in n&&n.sky?.horizon?n.sky.horizon:n&&typeof n==`object`&&`meshGradient`in n&&n.meshGradient[0]?n.meshGradient[0]:typeof n==`string`&&n!==`transparent`?n:`#ffffff`)}async function Ui(e,t,n,r,a){let o=[],s=[],c=a.renderer,l=e.background,u=!!n.isOrthographicCamera,d=null,f=0,p=null,h=null,g=null;t.background=null,t.backgroundIntensity=1,t.backgroundRotation.set(0,0,0),t.environmentRotation.set(0,0,0);let _=l&&typeof l==`object`?l:null,v=_&&`sky`in _?_.sky??{}:null;if(v&&xi(v))try{p=await ki(v)}catch(e){a.issue(`asset-load`,e.message,`environment.background.sky`)}if(!r&&l!==void 0&&l!==`transparent`){if(typeof l==`string`)t.background=B(l);else if(`gradient`in l)t.background=Ai(l.gradient,`linear`,V(l.angle,0),{grain:l.grain});else if(`radial`in l)t.background=Ai(l.radial,`radial`,0,{center:l.center,radius:l.radius,grain:l.grain});else if(`meshGradient`in l)g=l.meshGradient,o.push(ji(l.meshGradient,l,a));else if(`sky`in l){let e=l.sky??{};if(p){if(!u){o.push(p.mesh);let e=p;a.onUpdate(t=>e.setTime(t))}}else h=e,u?t.background=Ai([e.bottom??e.horizon??`#e8eef5`,e.horizon??`#cfe6ff`,e.top??`#2f6fd6`],`linear`,0):o.push(Pi(e,a))}else if(`hdri`in l)try{if(d=await Li(a.resolveAsset(l.hdri)),f=V(l.rotation,0)*H,t.backgroundRotation.set(0,f,0),t.backgroundIntensity=V(l.intensity,1),s.push(d),l.groundProjection&&!u){let n=typeof l.groundProjection==`object`?l.groundProjection:{},{GroundedSkybox:r}=await i(async()=>{let{GroundedSkybox:e}=await import(`./GroundedSkybox-cLn9JVlt.js`);return{GroundedSkybox:e}},__vite__mapDeps([15,1,2]),import.meta.url),a=V(n.height,2),s=V(n.radius,60),c=new r(d,a,s);c.position.y=a-.01+V(e.ground?.y,0),c.rotation.y=f,c.material.color.setScalar(t.backgroundIntensity),c.name=`__groundProjection`,c.userData.helper=!0,c.renderOrder=-999,o.push(c),t.background=B(`#000000`)}else t.background=d,t.backgroundBlurriness=V(l.blur,0)}catch(e){a.issue(`asset-load`,e.message,`environment.background.hdri`)}t.background instanceof Ge&&t.background!==d&&s.push(t.background)}t.fog=null,ri(t,null);let y=null;e.fog&&(y=B(Hi(e,p?.values.haze)),!e.fog.color&&p&&y.multiplyScalar(.82),`density`in e.fog?(t.fog=new Je(y,e.fog.density),e.fog.height!==void 0&&ri(t,{uA3dFogHeight:{value:e.fog.height},uA3dFogFalloff:{value:V(e.fog.falloff,.25)}})):t.fog=new de(y,V(e.fog.near,10),V(e.fog.far,60)),p?.setHaze(y,.85));let b=d?{hdri:``}:p?`sky`:`soft`,x=e.lighting??b;if(t.environment=null,t.environmentIntensity=V(e.lightingIntensity,1),c&&x!==`none`){let n=new Ve(c),o=null;try{if(typeof x==`object`){let e=x.hdri?await Li(a.resolveAsset(x.hdri)):d;e&&(o=n.fromEquirectangular(e)),x.intensity!==void 0&&(t.environmentIntensity=x.intensity),t.environmentRotation.set(0,x.hdri?V(x.rotation,0)*H:x.rotation===void 0?f:x.rotation*H,0),e&&e!==d&&e.dispose()}else if(x===`sky`){if(p){let e=p.envScene();o=n.fromScene(e,0,.1,100),Ii(e)}else if(h){let e=h,t=e.sun===!1?void 0:e.sun,r=Fi(e.top??`#2f6fd6`,e.horizon??`#cfe6ff`,e.bottom??e.horizon??`#e8eef5`,t?{dir:new E(...R(t.direction,[.4,.35,-1])),color:t.color??`#fff2d6`,power:4,size:.9}:void 0,!1);o=n.fromScene(r,.02),Ii(r)}else if(g){let e=g,t=Fi(e[1]??e[0],e[0],e[2]??e[0],void 0,!0);o=n.fromScene(t,.04),Ii(t)}else{let{RoomEnvironment:e}=await i(async()=>{let{RoomEnvironment:e}=await import(`./RoomEnvironment-v4QurKxu.js`);return{RoomEnvironment:e}},__vite__mapDeps([16,1,2]),import.meta.url),t=new e;o=n.fromScene(t,.06),t.dispose?.()}}else if(x===`studio`||x===`soft`){let{RoomEnvironment:r}=await i(async()=>{let{RoomEnvironment:e}=await import(`./RoomEnvironment-v4QurKxu.js`);return{RoomEnvironment:e}},__vite__mapDeps([16,1,2]),import.meta.url),a=new r;o=n.fromScene(a,x===`soft`?.06:.02),x===`soft`&&e.lightingIntensity===void 0&&(t.environmentIntensity=.8),a.dispose?.()}else{let e={neutral:[`#d8d8dc`,`#b9b9bd`,`#5a5a60`],sunset:[`#33306e`,`#ff9a5a`,`#3a2531`,{dir:new E(1,.15,-.6),color:`#ffb36b`,power:6,size:1.6}],night:[`#060a1a`,`#1d2a55`,`#05060c`,{dir:new E(-.5,.7,-.5),color:`#cfdcff`,power:3,size:.8}]},t=Fi(...e[x]??e.neutral);o=n.fromScene(t,.03),Ii(t)}}catch(e){a.issue(`asset-load`,e.message,`environment.lighting`)}o&&(t.environment=o.texture,s.push(o),u&&p&&!r&&(t.background=o.texture,t.backgroundBlurriness=0)),n.dispose();let l=e.lightingIntensity!==void 0||typeof x==`object`&&x.intensity!==void 0;e.rig&&!l&&(t.environmentIntensity*=Vi)}let S=[],C=v&&v.sun!==!1?v.sun??{}:null;if(p&&C&&C.light!==!1){let t=Ti(p.values.elevation),n=new j(C.color?B(C.color):t.color,V(C.intensity,t.intensity));n.position.copy(p.sunDir).multiplyScalar(30),n.name=`__sun`,n.userData.a3dId=`sun`,C.castShadow!==!1&&n.intensity>0&&li(n,{type:`directional`,shadow:{softness:3}},e.shadows),S.push(n)}for(let t of yi(e.rig)){let n=await mi(t,e.shadows);S.push(n)}for(let e of S)o.push(e),(e instanceof j||e instanceof P)&&o.push(e.target);let ee;if(e.ground){let t=e.ground,n=V(t.size,60),r=V(t.y,0),i=t.shadowOnly?Bi(B(t.color??`#000000`),V(t.opacity,.28)):Ri(B(t.color??`#d9d9d9`),V(t.roughness,.9));!t.shadowOnly&&t.opacity!==void 0&&(i.opacity=t.opacity);let a=new I(new m(n,n),i);if(a.rotation.x=-Math.PI/2,a.position.y=r,a.receiveShadow=!0,a.name=`__ground`,a.renderOrder=-20,a.userData.helper=!0,a.userData.ground=!0,o.push(a),ee=a,t.grid){let e=new te(n,Math.round(n),B(`#000000`),B(`#000000`)),t=e.material;t.transparent=!0,t.opacity=.12,t.depthWrite=!1,e.position.y=r+.002,e.userData.helper=!0,o.push(e)}}if(e.contactShadows){let n=qr(e.contactShadows,t,e.ground?V(e.ground.y,0):void 0,a);n&&(o.push(n.object),s.push(n))}return{objects:o,ground:ee,dispose(){for(let e of s)e.dispose();for(let e of o)e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose?.(),e.shadow?.dispose?.()})}}}function Wi(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>new w(Number(e[0]),Number(e[1]))):[]}function Gi(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new E(Number(e[0]),Number(e[1]),Number(e[2]))):[]}var Ki=(e,t=`segments`,n=32)=>Math.max(3,Math.round(V(e[t],n))),qi={box:e=>new Re(V(e.width,1),V(e.height,1),V(e.depth,1)),roundedBox:e=>{let t=V(e.width,1),n=V(e.height,1),r=V(e.depth,1),i=Math.min(V(e.radius,.1),Math.min(t,n,r)/2-1e-4);return new $t(t,n,r,Math.max(1,Math.round(V(e.segments,4))),Math.max(0,i))},sphere:e=>new ke(V(e.radius,.5),Ki(e),Math.max(2,Math.round(V(e.heightSegments,24)))),cylinder:e=>new pe(V(e.radiusTop,.5),V(e.radiusBottom,.5),V(e.height,1),Ki(e),1,z(e.openEnded,!1)),cone:e=>new h(V(e.radius,.5),V(e.height,1),Ki(e)),capsule:e=>{let t=Math.max(2,Math.round(V(e.segments,16)));return new be(V(e.radius,.3),V(e.length,.6),Math.max(2,Math.round(t/2)),t*2)},torus:e=>new x(V(e.radius,.5),V(e.tube,.15),Math.max(2,Math.round(V(e.radialSegments,24))),Math.max(3,Math.round(V(e.tubularSegments,64))),V(e.arc,360)*H),torusKnot:e=>new v(V(e.radius,.5),V(e.tube,.15),Math.round(V(e.tubularSegments,128)),Math.round(V(e.radialSegments,16)),Math.round(V(e.p,2)),Math.round(V(e.q,3))),plane:e=>new m(V(e.width,1),V(e.height,1),Math.max(1,Math.round(V(e.widthSegments,1))),Math.max(1,Math.round(V(e.heightSegments,1)))),circle:e=>new qe(V(e.radius,.5),Ki(e)),ring:e=>new Ie(V(e.innerRadius,.3),V(e.outerRadius,.5),Ki(e)),icosahedron:e=>new ie(V(e.radius,.5),Math.round(V(e.detail,0))),dodecahedron:e=>new ae(V(e.radius,.5),Math.round(V(e.detail,0))),octahedron:e=>new C(V(e.radius,.5),Math.round(V(e.detail,0))),tetrahedron:e=>new g(V(e.radius,.5),Math.round(V(e.detail,0))),lathe:e=>{let t=Wi(e.points);return t.length<2&&(t=[new w(.5,-.5),new w(.5,.5)]),new Ue(t,Ki(e))},extrude:e=>{let t=Wi(e.shape);t.length<3&&(t=[new w(-.5,-.5),new w(.5,-.5),new w(0,.5)]);let n=new Ce(t),r=V(e.depth,.2),i=V(e.bevel,.02),a=new ce(n,{depth:r,bevelEnabled:i>0,bevelSize:i,bevelThickness:i,bevelSegments:3,curveSegments:12});return a.translate(0,0,-r/2),a},tube:e=>{let t=Gi(e.points);t.length<2&&(t=[new E(-1,0,0),new E(1,0,0)]);let n=new We(t,z(e.closed,!1),`catmullrom`,.5);return new je(n,Math.max(2,Math.round(V(e.tubularSegments,64))),V(e.radius,.05),Math.max(3,Math.round(V(e.radialSegments,8))),z(e.closed,!1))}};function Ji(e){let t=qi[e.type]??qi.box,n=Xe.find(t=>t.id===e.type),r=t(ft(n,e));return r.computeBoundingBox(),r.computeBoundingSphere(),r}function Yi(e,t){let n=[],r=(e,t=new D,r=new E(1,1,1))=>n.push({position:e,rotation:t,scale:r});switch(e.type){case`grid`:{let[t,n,i]=e.count.map(e=>Math.max(1,Math.round(e))),[a,o,s]=e.spacing;for(let e=0;e<t;e++)for(let c=0;c<n;c++)for(let l=0;l<i;l++)r(new E((e-(t-1)/2)*a,(c-(n-1)/2)*o,(l-(i-1)/2)*s));break}case`scatter`:{let n=V(e.minScale,1),i=V(e.maxScale,1),[a,o,s]=e.area;for(let c=0;c<Math.max(0,Math.round(e.count));c++){let c=new E(t.range(-a/2,a/2),t.range(-o/2,o/2),t.range(-s/2,s/2)),l=e.randomRotation===!1?new D:new D(0,t.range(0,Math.PI*2),0),u=t.range(n,i);r(c,l,new E(u,u,u))}break}case`circle`:{let t=Math.max(1,Math.round(e.count));for(let n=0;n<t;n++){let i=n/t*Math.PI*2;r(new E(Math.cos(i)*e.radius,0,Math.sin(i)*e.radius),new D(0,-i,0))}break}case`list`:for(let t of e.items){let e=t.position??[0,0,0],n=t.rotation??[0,0,0],i=t.scale??1;r(new E(...e),new D(n[0]*H,n[1]*H,n[2]*H),typeof i==`number`?new E(i,i,i):new E(...i))}}return n}function Xi(e,t,n,r,i){let a=Yi(e.layout,r),o=new ye(t,n,Math.max(1,a.length));o.count=a.length;let s=new k,c=new T;if(a.forEach((e,t)=>{s.compose(e.position,c.setFromEuler(e.rotation),e.scale),o.setMatrixAt(t,s)}),e.colors?.length){let t=e.layout.type===`scatter`;a.forEach((n,a)=>o.setColorAt(a,i(t?r.pick(e.colors):e.colors[a%e.colors.length]))),o.instanceColor&&(o.instanceColor.needsUpdate=!0)}return o.instanceMatrix.needsUpdate=!0,o.computeBoundingBox(),o.computeBoundingSphere(),o}function Zi(e){let t={position:e.position.clone(),quaternion:e.quaternion.clone(),scale:e.scale.clone(),visible:e.visible},n=e;return n.isLight&&(t.intensity=n.intensity,t.color=n.color.clone()),t}function Qi(e,t){t.position&&e.position.set(t.position[0]??0,t.position[1]??0,t.position[2]??0),t.rotation&&e.rotation.set((t.rotation[0]??0)*H,(t.rotation[1]??0)*H,(t.rotation[2]??0)*H),t.scale!==void 0&&(typeof t.scale==`number`?e.scale.setScalar(t.scale):e.scale.set(t.scale[0]??1,t.scale[1]??1,t.scale[2]??1))}var $i=new Set([`hoverScale`,`hoverLift`,`clickBounce`,`spinOnClick`]),ea=class e{def;ctx;scene=new Se;camera;rig;env=null;entries=new Map;timeline=null;settleEntrances=!1;updaters=[];photoCameras=[];cameraRest0={position:new E,target:new E,fov:45,zoom:10,focus:void 0};motionHost;overrides;shots=[];focusWritten=!1;postfxParam=null;viewportH=600;input={pointer:{x:0,y:0,inside:!1},scroll:0,hovered:new Set,clicked:new Set,timelineT:null};disposed=!1;constructor(e,t){this.def=e,this.ctx=t,t.onUpdate=e=>this.updaters.push(e)}static async create(t,n,r,i,a=!1){let o=new e(t,n);return await o.build(r,i,a),o}async build(e,t,n){let{def:r,ctx:i}=this;{this.camera=ut(r.camera,e),this.rig=await st(r.camera,this.camera,t,i.deterministic),this.cameraRest0.position.copy(this.rig.rest.position),this.cameraRest0.target.copy(this.rig.rest.target),this.cameraRest0.fov=this.rig.rest.fov,this.cameraRest0.zoom=this.rig.rest.zoom;let n=r.postfx?.find(e=>e.type===`dof`);this.cameraRest0.focus=n&&typeof n.focus==`number`?n.focus:n?8:void 0,this.rig.rest.focus=this.cameraRest0.focus;let a=Ui(r.environment??{background:`#ffffff`},this.scene,this.camera,!!r.target?.transparent,i),o=Promise.all((r.lights??[]).map((e,t)=>this.addLight(e,t))),s=new Map,c=r.objects??[],u=e=>e.attach===`camera`?this.camera:this.scene;c.some(e=>e.attach===`camera`)&&this.scene.add(this.camera),await Promise.all(c.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(e=>this.addObject(e,u(e),void 0,s))),ta(s,c),await Promise.all(c.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(e=>this.addObject(e,u(e),void 0,s)));let d=new Map(c.map((e,t)=>[e.id,t]));this.scene.children.sort((e,t)=>(d.get(e.userData.a3dId)??-1)-(d.get(t.userData.a3dId)??-1)),this.env=await a;for(let e of this.env.objects)this.scene.add(e);if(await o,this.canonicalOrder(r),this.motionHost={object:e=>this.entries.get(e)?.object??null,select:e=>this.select(e),camera:this.rig.rest,scene:this.scene,renderer:i.renderer,postfx:{set:(e,t,n)=>this.postfxParam?.(e,t,n),base:(e,t)=>{let n=l(r.postfx).find(t=>t.type===e)?.[t];return typeof n==`number`||typeof n==`string`?n:void 0}},clips:e=>this.entries.get(e)?.animator?.control,photoEffects:e=>this.entries.get(e)?.photoFx,issue:i.issue,seed:r.seed??1},this.overrides=new Nr(this.motionHost),this.shots=zr(r.camera?.shots),r.timeline){this.timeline=jr(r.timeline,this.motionHost);for(let e of this.timeline.targets){let t=this.entries.get(e);t&&(t.animated=!0)}}for(let e of r.interactions??[]){if(e.target&&(e.on===`click`||e.on===`hover`||e.on===`hoverEnd`)){let t=this.entries.get(e.target);t&&(t.interactive=!0)}for(let t of e.do??[]){let e=t.set?.path;if(typeof e==`string`)for(let t of this.overrides.idsOf(e)){let e=this.entries.get(t);e&&(e.animated=!0)}}}this.fitShadows()}}canonicalOrder(e){let t=this.entries,n=new Map,r=e=>{let r=t.get(e);r&&!n.has(e)&&n.set(e,r)};(e.lights??[]).forEach((e,t)=>r(e.id??`light${t}`));let i=e=>{for(let n of e){r(n.id);let e=`${n.id}/`;for(let i of t.keys())i.startsWith(e)&&t.get(i).parentId===n.id&&r(i);if(!n.children?.length)continue;let a=t.get(n.id)?.object;if(a){let e=new Map(n.children.map((e,t)=>[e.id,t]));a.children.sort((t,n)=>(e.get(t.userData.a3dId)??-1)-(e.get(n.userData.a3dId)??-1))}i(n.children)}};i(e.objects??[]);for(let[e,r]of t)n.has(e)||n.set(e,r);this.entries=n}async overrideGeneratorMaterial(e,t,n){let r=jt(t),i=await Gt(t,n,{vertexColors:r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map}),a=[];e.traverse(e=>{e.isMesh&&e.userData.materialTarget&&a.push(e)});for(let e of a)e.material.dispose(),e.material=i,Lt(i,e.geometry)}rngFor(e,t){return et(t??tt(this.def.seed??1,e))}behaviourContext(e){let t=this;return{object:e.object,base:{position:e.rest.position,rotation:new D().setFromQuaternion(e.rest.quaternion),scale:e.rest.scale},get pointer(){return t.input.pointer},hovered:()=>t.input.hovered.has(e.id),clicked:()=>t.input.clicked.has(e.id),scroll:()=>t.input.scroll,get camera(){return t.camera},rng:this.rngFor(e.id+`:behaviours`),find:e=>e===`camera`?t.camera:t.entries.get(e)?.object??null}}attachBehaviours(e){let t=e.def.behaviours??[];e.runners=[];for(let n of t){let t=ar[n.type];t?(e.runners.push(fr(n,t,this.behaviourContext(e),{settled:()=>this.settleEntrances})),($i.has(n.type)||n.when===`hover`||n.when===`click`)&&(e.interactive=!0)):this.ctx.issue(`unknown-catalog-id`,`Unknown behaviour "${n.type}"`,`objects#${e.id}.behaviours`)}e.runners.length&&(e.animated=!0)}resetBehaviours(){for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.def.behaviours?.length&&this.attachBehaviours(e),e.animator?.reset?e.animator.reset():e.animator?.mixer.setTime(0)}this.overrides?.reset()}async addLight(e,t){let n=await mi(e,this.def.environment?.shadows),r=e.id??`light${t}`;this.scene.add(n),(n instanceof j||n instanceof P)&&this.scene.add(n.target),n.userData.a3dId=r;let i={id:r,kind:`light`,def:e,object:n,rest:Zi(n),runners:[],animated:!1,topLevel:!1,interactive:!1};this.entries.set(r,i),this.attachBehaviours(i)}async addObject(e,t,n,r){let a=this.ctx,o,s,c,l,u,d=[],f=e.kind!==`particles`&&e.kind!==`generator`&&e.kind!==`photo`;try{switch(e.kind){case`mesh`:{let t=Ji(e.geometry),n=await Gt(e.material,a,{defaultColor:`#dddddd`});Lt(n,t),o=new I(t,n);break}case`text`:{let{buildText:t}=await i(async()=>{let{buildText:e}=await import(`./text-BkPPDghK.js`);return{buildText:e}},__vite__mapDeps([17,18,8,2,4,1,9,7,19]),import.meta.url),n=await a.track(t(e,a));o=n.object,d=n.letters;break}case`svg`:{let{buildSvg:t}=await i(async()=>{let{buildSvg:e}=await import(`./svg-n3rkKAm5.js`);return{buildSvg:e}},__vite__mapDeps([20,18,8,2,4,1,9,7,19]),import.meta.url);o=await a.track(t(e,a));break}case`photo`:{let{buildPhoto:t}=await i(async()=>{let{buildPhoto:e}=await import(`./photo-CPGGCRa-.js`);return{buildPhoto:e}},__vite__mapDeps([21,18,8,2,4,1,9,7]),import.meta.url),n=await a.track(t(e,a));o=n.object,s={object:n.object,dispose:()=>n.dispose()},u=n.effects,this.updaters.push((e,t)=>n.update(e,t,{pointer:this.input.pointer,scroll:this.input.scroll,camera:this.camera??null,reduced:this.settleEntrances})),n.applyCamera&&this.photoCameras.push(n.applyCamera);break}case`model`:{let{buildModel:t}=await i(async()=>{let{buildModel:e}=await import(`./model-CkPfLOl0.js`);return{buildModel:e}},__vite__mapDeps([22,7,1,2,8,4,9]),import.meta.url),n=await a.track(t(e,a));o=n.object,c=n.animator;break}case`instances`:{let t=Ji(e.geometry),n=await Gt(e.material,a,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});Lt(n,t),o=Xi(e,t,n,this.rngFor(e.id,e.layout.seed),e=>B(e));break}case`particles`:{l=yr(e,this.rngFor(e.id,e.seed)),l.setViewport(this.viewportH),o=l.points;let t=l;this.updaters.push(e=>t.update(e));break}case`generator`:{let t=(await a.generators())[e.generator];if(!t){a.issue(`unknown-catalog-id`,`Unknown generator "${e.generator}"`,`objects#${e.id}.generator`),o=new he;break}let n=Qe.find(t=>t.id===e.generator),i=ft(n,e.params??{}),c=e.scale,l={position:[...e.position??[0,0,0]],scale:typeof c==`number`?[c,c,c]:c?[...c]:[1,1,1]},u={...a,siblings:r,rng:this.rngFor(e.id,e.seed),placement:l};if(s=await a.track(Promise.resolve(t(i,u))),o=s.object,s.update){let e=s.update.bind(s);this.updaters.push((t,n)=>e(t,n))}r.set(e.id,s),e.material&&n?.material&&await this.overrideGeneratorMaterial(o,e.material,a);break}default:o=new he}}catch(t){a.issue(e.kind===`model`||e.kind===`text`||e.kind===`svg`||e.kind===`photo`?`asset-load`:`build-error`,`${e.id}: ${t.message}`,`objects#${e.id}`),o=new he}if(this.disposed)return null;o.name=e.name??e.id,o.userData={...e.userData??{},...o.userData,a3dId:e.id,tags:e.tags??[]},Qi(o,e),e.visible===!1&&(o.visible=!1);let p=e.castShadow??(f?!0:void 0),m=e.receiveShadow??(f?!0:void 0);(p!==void 0||m!==void 0)&&o.traverse(e=>{e.isMesh&&(p!==void 0&&(e.castShadow=p),m!==void 0&&(e.receiveShadow=m))}),t.add(o);let h={id:e.id,kind:e.kind,def:e,object:o,rest:Zi(o),runners:[],animated:!1,topLevel:t===this.scene||t===this.camera&&!n,parentId:n,built:s,animator:c,particles:l,photoFx:u,interactive:!!e.href};this.entries.set(e.id,h),this.attachBehaviours(h);for(let t of d){let n={id:t.id,kind:`text`,def:t.def,object:t.object,rest:Zi(t.object),runners:[],animated:!0,topLevel:!1,parentId:e.id,interactive:!1};t.reveal&&n.runners.push(fr(t.reveal.def,t.reveal.impl,this.behaviourContext(n),{settled:()=>this.settleEntrances})),this.entries.set(t.id,n)}if(e.children?.length){let t=new Map,n=e.children;await Promise.all(n.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(n=>this.addObject(n,o,e.id,t))),ta(t,n),await Promise.all(n.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(n=>this.addObject(n,o,e.id,t)))}return h}removeEntry(e){let t=this.entries.get(e);if(t){t.object.traverse(t=>{let n=t.userData.a3dId;n&&n!==e&&this.entries.delete(n)}),t.object.removeFromParent();for(let e of t.runners)e.dispose();this.entries.delete(e)}}idsFor(e){let t=[];for(let n=e;n;n=n.parent){let e=n.userData?.a3dId;e&&this.entries.has(e)&&t.push(e)}return t}select(e){if(e.startsWith(`tag:`)){let t=e.slice(4),n=[],r=e=>{for(let i of e??[])i.tags?.includes(t)&&this.entries.has(i.id)&&n.push(i.id),r(i.children)};return r(this.def.objects),n}if(e.startsWith(`children:`)){let t=e.slice(9);return[...this.entries.values()].filter(e=>e.parentId===t).map(e=>e.id)}return kr(e,{object:()=>null,camera:null,issue:()=>void 0}).filter(e=>e!==``)}objectPosition(e){let t=this.entries.get(e);return t?t.object.getWorldPosition(new E):null}interactiveRoots(){let e=[];for(let t of this.entries.values())t.interactive&&t.kind!==`light`&&e.push(t.object);return e}fitShadows(){let e=[];if(this.scene.traverse(t=>{t instanceof j&&t.castShadow&&e.push(t)}),!e.length)return;let t=new A,n=new A;this.scene.updateMatrixWorld(!0);for(let e of this.entries.values())e.topLevel&&e.kind!==`particles`&&e.def.attach!==`camera`&&(n.setFromObject(e.object),n.isEmpty()||n.getSize(new E).length()>200||t.union(n));t.isEmpty()&&t.set(new E(-5,-1,-5),new E(5,5,5));let r=this.env?.ground?this.env.ground.position.y:t.min.y;t.expandByPoint(new E(t.min.x,r,t.min.z)),t.expandByPoint(new E(t.max.x,r,t.max.z)),t.expandByScalar(.3);for(let n of e)hi(n,t)}setViewport(e,t,n){this.viewportH=t*n,lt(this.camera,this.def.camera,e/Math.max(t,1),it(this.def.target?.aspect));for(let e of this.entries.values())e.particles?.setViewport(this.viewportH)}frame(e,t,n,r){this.input=n;for(let e of this.entries.values()){if(!e.animated)continue;let t=e.object;t.position.copy(e.rest.position),t.quaternion.copy(e.rest.quaternion),t.scale.copy(e.rest.scale),t.visible=e.rest.visible;let n=t;n.isLight&&e.rest.intensity!==void 0&&(n.intensity=e.rest.intensity,e.rest.color&&!this.timeline?.targets.has(e.id)&&n.color.copy(e.rest.color))}let i=this.def.timeline?n.timelineT??0:e;if(this.shots.length||this.timeline?.animatesCamera){let e=this.rig.rest;if(e.position.copy(this.cameraRest0.position),e.target.copy(this.cameraRest0.target),e.fov=this.cameraRest0.fov,e.zoom=this.cameraRest0.zoom,e.focus=this.cameraRest0.focus,this.shots.length){let t=Br(this.shots,i,e,{objectPosition:e=>this.objectPosition(e)});e.position.copy(t.position),e.target.copy(t.target),e.fov=t.fov,e.focus=t.focus}}this.timeline&&n.timelineT!==null&&this.timeline.apply(n.timelineT),this.overrides?.apply(e),this.rig.rest.focus!==void 0&&(this.focusWritten||this.rig.rest.focus!==this.cameraRest0.focus)&&(this.postfxParam?.(`dof`,`focus`,this.rig.rest.focus),this.focusWritten=!0);for(let n of this.entries.values())for(let r of n.runners)r.late||r.step(e,t);for(let e of this.entries.values()){let t=e.object.userData.setPointer?e.object:e.object.children[0],r=t?.userData.setPointer;if(!r)continue;r(n.pointer.x,n.pointer.y);let i=t.userData.setPointerLocal;if(i&&this.camera){let e=this.pointerOnPlane(t,n.pointer.x,n.pointer.y);e&&i(e.x,e.z)}}for(let n of this.updaters)n(e,t);for(let e of this.entries.values())e.animator?.mixer.update(t);let a=this.def.camera?.lookAt;this.rig.update(e,t,{pointer:n.pointer,scroll:n.scroll,followTarget:r,lookAt:a?this.objectPosition(a):null}),this.photoCameras.forEach((e,t)=>e(this.camera,t===0&&!this.rig.orbit)),this.camera.updateMatrixWorld();for(let n of this.entries.values())for(let r of n.runners)r.late&&r.step(e,t)}hasStatefulMotion(){if(this.def.camera?.controls===`follow`&&this.def.camera.follow)return!0;for(let e of this.entries.values())for(let t of e.runners)if(t.stateful)return!0;return!1}pointerRay=new ue;pointerOnPlane(e,t,n){e.updateWorldMatrix(!0,!1),this.camera.updateMatrixWorld(),this.pointerRay.setFromCamera(new w(t,n),this.camera);let r=e.matrixWorld.clone().invert(),i=this.pointerRay.ray.clone().applyMatrix4(r);if(Math.abs(i.direction.y)<1e-6)return null;let a=-i.origin.y/i.direction.y;return a<0?null:i.origin.addScaledVector(i.direction,a)}dispose(){this.disposed=!0;for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.built?.dispose?.()}this.rig?.dispose(),this.env?.dispose(),ot(this.scene);let e=this.scene.environment;e&&e.dispose();let t=this.scene.background;t&&t.isTexture&&t.dispose(),this.scene.traverse(e=>e.shadow?.dispose?.()),this.entries.clear()}};function ta(e,t){let n=[...e.entries()],r=new Map(t.map((e,t)=>[e.id,t]));n.sort((e,t)=>(r.get(e[0])??1/0)-(r.get(t[0])??1/0)),e.clear();for(let[t,r]of n)e.set(t,r)}var na=new WeakMap;function ra(e){let t=na.get(e);if(t===void 0){t=null;let n=e.ownerDocument.defaultView;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement)if(r.parentElement&&n?.getComputedStyle(r).position===`sticky`){t=r;break}e.isConnected&&na.set(e,t)}if(!t){let t=e.getBoundingClientRect();return{top:t.top,height:t.height}}let n=t.parentElement.getBoundingClientRect();return{top:n.top,height:Math.max(1,n.height-t.getBoundingClientRect().height)}}var ia=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`,`PageUp`,`PageDown`,`Home`,`End`]);function aa(){return{pointer:{x:0,y:0,inside:!1,down:!1,justPressed:!1},keys:new Set,pressed:new Set,swipe:null,clicks:[],scroll:0}}function oa(e){e.pressed.clear(),e.pointer.justPressed=!1,e.swipe=null,e.clicks.length=0}function sa(e,t,n){n?(e.keys.has(t)||e.pressed.add(t),e.keys.add(t)):e.keys.delete(t)}function ca(e,t,n){let r=e.ownerDocument.defaultView??window,i=!1,a=!1,o=null,s=t=>{let n=e.getBoundingClientRect();return{x:(t.clientX-n.left)/Math.max(n.width,1)*2-1,y:-((t.clientY-n.top)/Math.max(n.height,1)*2-1)}},c=e=>{let r=s(e);t.pointer.x=r.x,t.pointer.y=r.y,t.pointer.inside=!0,n.onPointerMove?.()},l=()=>{a=!0,t.pointer.inside=!0},u=()=>{a=!1,t.pointer.inside=!1,t.pointer.down=!1},d=e=>{i=!0;let n=s(e);t.pointer.x=n.x,t.pointer.y=n.y,t.pointer.down=!0,t.pointer.justPressed=!0,o={x:n.x,y:n.y,t:performance.now(),px:e.clientX,py:e.clientY}},f=e=>{if(t.pointer.down=!1,!o)return;let n=e.clientX-o.px,r=e.clientY-o.py,i=Math.hypot(n,r);i<8?t.clicks.push(s(e)):i>30&&performance.now()-o.t<600&&(t.swipe=Math.abs(n)>Math.abs(r)?n>0?`right`:`left`:r>0?`down`:`up`),o=null},p=()=>i||a||e.contains(e.ownerDocument.activeElement),m=e=>{if(!p())return;let r=e.target;(!r||r.tagName!==`INPUT`&&r.tagName!==`TEXTAREA`&&!r.isContentEditable)&&(sa(t,e.code,e.type===`keydown`),n.game&&ia.has(e.code)&&e.preventDefault())},h=()=>t.keys.clear(),g=t=>{e.contains(t.target)||(i=!1)};return e.addEventListener(`pointermove`,c),e.addEventListener(`pointerenter`,l),e.addEventListener(`pointerleave`,u),e.addEventListener(`pointerdown`,d),r.addEventListener(`pointerup`,f),r.addEventListener(`keydown`,m,{passive:!1}),r.addEventListener(`keyup`,m),r.addEventListener(`blur`,h),r.document.addEventListener(`pointerdown`,g,!0),n.game&&(e.style.touchAction=`none`,e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`)),{dispose(){e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerenter`,l),e.removeEventListener(`pointerleave`,u),e.removeEventListener(`pointerdown`,d),r.removeEventListener(`pointerup`,f),r.removeEventListener(`keydown`,m),r.removeEventListener(`keyup`,m),r.removeEventListener(`blur`,h),r.document.removeEventListener(`pointerdown`,g,!0)}}}function la(e){let t=e.ownerDocument.defaultView;if(!t)return 0;let n=ra(e),r=t.innerHeight||1,i=(r-n.top)/(r+n.height);return i<0?0:i>1?1:i}var Q=(e,t,n)=>e<t?t:e>n?n:e;function ua(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`&&t&&typeof t[e]==`number`?t[e]:n}function da(e,t){let n=Math.max(e.duration||0,.001);if(t===`timeline`)return{from:0,to:n,loop:e.loop,speed:1};let r=e.segments?.[t];if(!r)return null;let i=Array.isArray(r)?{from:r[0],to:r[1]}:r;return{from:Q(ua(i.from,e.markers,0),0,n),to:Q(ua(i.to,e.markers,n),0,n),loop:i.loop??!1,speed:typeof i.speed==`number`&&i.speed>0?i.speed:1}}function fa(e,t,n){let r=Math.abs(e.to-e.from),i=e.to>=e.from?1:-1,a=n===void 0?0:Math.abs(n-e.from),o=r<=0?0:Cn(Math.max(0,t*e.speed+a),r,e.loop);return e.from+i*o}function pa(e,t,n){let r=Math.max(e.duration||0,.001),i=n&&n!==`seek`&&n!==`timeline`&&e.segments?.[n]?n:``;if(!i)for(let n of Object.keys(e.segments??{})){let a=da(e,n);if(!a)continue;let o=Math.min(a.from,a.to),s=Math.max(a.from,a.to);if(t>=o&&(t<s||s>=r-1e-6&&t<=s)){i=n;break}}let a=``,o=-1/0;for(let[n,r]of Object.entries(e.markers??{}))typeof r==`number`&&r<=t+1e-6&&r>=o&&(o=r,a=n);return{time:t,duration:r,progress:Q(t/r,0,1),segment:i,marker:a}}var ma=class{def;hoverClock=0;clickAt=-1;active=null;toggled=new Map;prevLocal=null;lastLocal=0;lastT=0;pending=[];constructor(e){this.def=e}get duration(){return Math.max(this.def.duration||0,.001)}reset(){this.hoverClock=0,this.clickAt=-1,this.active=null,this.toggled.clear(),this.prevLocal=null,this.lastLocal=0,this.lastT=0,this.pending=[]}get local(){return this.lastLocal}play(e,t,n={}){let r=da(this.def,e);if(!r)return!1;let i=n.reverse?{...r,from:r.to,to:r.from}:r;return this.active={...i,name:e,start:t},this.toggled.set(e,!n.reverse),!0}toggle(e,t){let n=da(this.def,e);if(!n)return!1;let r=!this.toggled.get(e),i=r?n:{...n,from:n.to,to:n.from},a=this.active?.name===e?this.lastLocal:void 0,o=a!==void 0&&a>=Math.min(n.from,n.to)&&a<=Math.max(n.from,n.to);return this.active={...i,loop:!1,name:e,start:t,startLocal:o?a:void 0},this.toggled.set(e,r),!0}seek(e,t){let n=Q(ua(e,this.def.markers,0),0,this.duration);this.active={name:`seek`,from:n,to:n,loop:!1,speed:1,start:t}}autoRange(){let e=typeof this.def.autoplay==`string`?this.def.autoplay:null,t=e?da(this.def,e):null,n=typeof this.def.speed==`number`&&this.def.speed>0?this.def.speed:1;return t?{...t,speed:t.speed*n}:{from:0,to:this.duration,loop:this.def.loop,speed:n}}autoLocal(e){let t=this.autoRange(),n=this.def.trigger??`visible`;if(e.staticMotion)return typeof this.def.autoplay==`string`?t.to:fa({...t,speed:1},e.posterTime??0);if(n===`manual`||this.def.autoplay===!1)return t.from;if(n===`scroll`)return t.from+(t.to-t.from)*Q(e.scroll,0,1);if(e.deterministic)return fa(t,e.t);switch(n){case`hover`:{this.hoverClock+=e.hovered?e.dt:t.loop?0:-e.dt;let n=Math.abs(t.to-t.from)/t.speed;return t.loop||(this.hoverClock=Q(this.hoverClock,0,n)),fa(t,this.hoverClock)}case`click`:return e.clicked&&(this.clickAt=e.t),this.clickAt<0?t.from:fa(t,e.t-this.clickAt);default:return fa(t,e.t)}}update(e){let t;return t=this.active&&!e.staticMotion?fa(this.active,Math.max(0,e.t-this.active.start),this.active.startLocal):this.autoLocal(e),t=Q(t,0,this.duration),this.collectMarkers(this.prevLocal,t,e.t<this.lastT),this.prevLocal=t,this.lastLocal=t,this.lastT=e.t,t}collectMarkers(e,t,n){let r=this.def.markers;if(r&&!n)for(let[n,i]of Object.entries(r)){if(typeof i!=`number`)continue;let r;r=e===null?i<=t:t>e?i>e&&i<=t:t<e?this.isLoopingForward()?i>e||i<=t:i<e&&i>=t:!1,r&&this.pending.push({name:n,time:i})}}isLoopingForward(){let e=this.active??this.autoRange();return!!e.loop&&e.loop!==`pingpong`&&e.to>=e.from}info(){return pa(this.def,this.lastLocal,this.active?.name)}drainMarkers(){let e=this.pending;return this.pending=[],e}};function ha(e,t){if(typeof e!=`string`||!e.trim())return null;try{let n=new URL(e.trim(),t);return n.protocol===`http:`||n.protocol===`https:`?n.href:null}catch{return null}}var ga=new Set([`click`,`key`]),_a=class{defs;host;hoverPrev=new Set;insidePrev=!1;scrollPrev=null;visibleFired=!1;fired=new Set;queue=[];constructor(e,t){this.defs=e,this.host=t}targets(){let e=new Set;for(let t of this.defs)t.target&&(t.on===`click`||t.on===`hover`||t.on===`hoverEnd`)&&e.add(t.target);return e}reset(){this.hoverPrev.clear(),this.insidePrev=!1,this.scrollPrev=null,this.visibleFired=!1,this.fired.clear(),this.queue=[]}event(e,t){this.queue.length<64&&this.queue.push({name:e,payload:t})}fire(e,t,n){let r=0;return this.defs.forEach((i,a)=>{if(i.on===e&&!(e===`key`?i.key!==t:e===`event`?i.event!==t:(i.target??void 0)!==t)&&!(i.once&&this.fired.has(a))){this.fired.add(a),r++;for(let t of i.do??[])this.run(t,n&&ga.has(e))}}),r}step(e){for(let t of this.targets()){let n=e.hovered.has(t),r=this.hoverPrev.has(t);n&&!r&&this.fire(`hover`,t,!1),!n&&r&&this.fire(`hoverEnd`,t,!1)}this.hoverPrev=new Set([...e.hovered].filter(e=>this.isTarget(e))),e.pointerInside!==this.insidePrev&&this.fire(e.pointerInside?`hover`:`hoverEnd`,void 0,!1),this.insidePrev=e.pointerInside;for(let t of e.clicked)this.fire(`click`,t,e.userGesture);e.canvasClicked&&this.fire(`click`,void 0,e.userGesture);for(let t of e.pressed)this.fire(`key`,t,e.userGesture);e.visible&&!this.visibleFired&&(this.visibleFired=!0,this.fire(`visible`,void 0,!1)),this.scrollPrev!==null&&e.scroll!==this.scrollPrev&&this.defs.forEach((t,n)=>{if(t.on===`scroll`&&typeof t.at==`number`&&!(!(this.scrollPrev<t.at&&e.scroll>=t.at)||t.once&&this.fired.has(n))){this.fired.add(n);for(let e of t.do??[])this.run(e,!1)}}),this.scrollPrev=e.scroll,this.flush()}flush(){for(let e=0;this.queue.length&&e<16;e++){let e=this.queue;this.queue=[];for(let t of e)this.fire(`event`,t.name,!1)}this.queue=[]}isTarget(e){return this.defs.some(t=>t.target===e)}run(e,t){let n=e;if(typeof n.play==`string`)this.host.play(n.play,n.reverse===!0);else if(typeof n.toggle==`string`)this.host.toggle(n.toggle);else if(typeof n.seek==`number`||typeof n.seek==`string`)this.host.seek(n.seek);else if(n.set&&typeof n.set==`object`){let e=n.set;typeof e.path==`string`&&e.value!==void 0&&this.host.set(e.path,e.value,typeof n.duration==`number`?n.duration:0,typeof n.ease==`string`?n.ease:void 0)}else typeof n.emit==`string`?this.host.emit(n.emit,n.payload):typeof n.openUrl==`string`?t?this.host.openUrl(n.openUrl,typeof n.newTab==`boolean`?n.newTab:void 0):this.host.emit(`openUrl`,{url:n.openUrl,blocked:!0}):n.playClip!==void 0&&typeof n.target==`string`&&this.host.playClip(n.target,n.playClip,{loop:n.loop,speed:n.speed,crossfade:n.crossfade})}},va=`top bottom`,ya=`bottom top`;function ba(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:e.endsWith(`%`)?Number(e.slice(0,-1))/100*t:e.endsWith(`px`)?Number(e.slice(0,-2)):null}function xa(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==2)return null;let i=ba(r[0],t),a=ba(r[1],n);return i===null||a===null?null:i-a}function Sa(e,t,n,r=va,i=ya){let a=xa(r,t,n)??-n,o=xa(i,t,n)??t,s=0-e;if(Math.abs(o-a)<1e-6)return+(s>=o);let c=(s-a)/(o-a);return c<0?0:c>1?1:c}var Ca=8e3;function wa(e,t,n=Ca){let r=[],i=0;if(e.traverseVisible(e=>{let t=e;if(!(t.isMesh||e.isLine)||e.isPoints)return;let n=t.geometry?.getAttribute(`position`);if(!n)return;let a=t.isInstancedMesh?t.count:1;a&&(r.push(t),i+=n.count*a)}),!r.length||!i)return null;let a=Math.max(1,Math.ceil(i/n)),o=new E,s=new k,c=new k,l=0,u=0;for(let e of r){let n=e.geometry.getAttribute(`position`),r=e,i=e.isSkinnedMesh?e:null,d=r.isInstancedMesh?r.count:1;for(let f=0;f<d;f++){r.isInstancedMesh?c.multiplyMatrices(e.matrixWorld,(r.getMatrixAt(f,s),s)):c.copy(e.matrixWorld);for(let e=f%a;e<n.count;e+=a)if(o.fromBufferAttribute(n,e),i&&i.applyBoneTransform(e,o),o.applyMatrix4(c),t.containsPoint(o)?l++:u++,l&&u)return`partial`}}return!l&&!u?null:u?`partial`:`full`}function Ta(e,t,n){if(n!==`parts`){let r=e.worldToLocal(t.clone()),i=n.heightAt(r.x,r.z);return Number.isFinite(i)&&r.y<i}let r=new A,i=new k,a=!1;return e.traverseVisible(e=>{let n=e;if(a||!n.isMesh||!n.geometry)return;n.geometry.boundingBox||n.geometry.computeBoundingBox();let o=n.geometry.boundingBox,s=e;if(s.isInstancedMesh)for(let e=0;e<s.count&&!a;e++)s.getMatrixAt(e,i),r.copy(o).applyMatrix4(i.premultiply(s.matrixWorld)).containsPoint(t)&&(a=Da(n,t,r,e));else r.copy(o).applyMatrix4(n.matrixWorld).containsPoint(t)&&(a=Da(n,t,r))}),a}var Ea=[new E(1,0,0),new E(-1,0,0),new E(0,1,0),new E(0,-1,0),new E(0,0,1),new E(0,0,-1)];function Da(e,t,n,r){let i=(Array.isArray(e.material)?e.material:[e.material]).filter(Boolean),a=i.map(e=>e.side);for(let e of i)e.side=2;try{let i=new ue;return i.far=n.getSize(new E).length()+.001,Ea.every(n=>(i.set(t,n),i.intersectObject(e,!1).some(e=>r===void 0||e.instanceId===r)))}finally{i.forEach((e,t)=>e.side=a[t])}}var Oa={none:0,aces:4,agx:6,neutral:7,reinhard:2};function ka(e){if(e.scripts?.length||e.ui?.elements?.length||e.physics||e.audio)return!0;let t=e=>!!e?.some(e=>!!e.body||t(e.children));return t(e.objects)}function Aa(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e.target?.aspect??``);return t&&Number(t[1])>0&&Number(t[2])>0?Number(t[1])/Number(t[2]):16/9}var ja=8,Ma=2e4,$=new Set;function Na(e){for(;$.size>=ja;){let t=null;for(let n of $)n!==e&&n.releasable()&&(!t||n.lastSeen<t.lastSeen)&&(t=n);if(!t)return;t.release()}}function Pa(){return $.size}var Fa=class{container;options;scene;canvas;lastSeen=0;released=!1;releaseTimer=null;placeholder=null;readyCalled=!1;ready;issues=[];input;renderer=null;world=null;game=null;postfx=null;quality=r(`high`);qualityAuto=!1;perfClock=0;slowFor=0;renderSamples=1;inputState=aa();inputBinding=null;resolveAsset;deterministic;t=0;tl=null;interactions=null;eventListeners=new Map;scrollOverride=null;tlScroll=null;raf=0;playing=!1;visible=!0;started=!1;timeScale=1;staticMotion=!1;lastNow=0;fps=0;building=null;rebuilding=!1;disposed=!1;hovered=new Set;resizeObs=null;interObs=null;readyResolve;readyReject;raycaster=new ue;width=1;height=1;lastStats={triangles:0,drawCalls:0,geometries:0,textures:0};onVisibility=()=>this.updateRunning();editor;overlay=null;worldListeners=new Set;constructor(e,t,n){this.container=e,this.options=n,this.scene=t,this.deterministic=!!n.deterministic,this.resolveAsset=_t(n),this.ready=new Promise((e,t)=>{this.readyResolve=e,this.readyReject=t}),this.ready.catch(()=>void 0);let r=e.ownerDocument;this.canvas=r.createElement(`canvas`),this.canvas.style.cssText=`display:block;width:100%;height:100%;outline:none;touch-action:manipulation;`;let i=r.defaultView?.getComputedStyle(e).position;i&&i!==`static`||(e.style.position=`relative`);let a=this;n.editor&&(this.editor={world:()=>a.world,renderer:()=>a.renderer,setOverlay:e=>{a.overlay=e},render:()=>a.render(),onWorld:e=>(a.worldListeners.add(e),()=>a.worldListeners.delete(e)),running:()=>!!a.raf}),this.input={pointer(e,t){a.inputState.pointer.x=e,a.inputState.pointer.y=t,a.inputState.pointer.inside=!0,a.inputInteractions()},key(e,t){sa(a.inputState,e,t),a.inputInteractions()},click(e,t){let n=e??a.inputState.pointer.x,r=t??a.inputState.pointer.y;a.inputState.pointer.x=n,a.inputState.pointer.y=r,a.inputState.pointer.inside=!0,a.inputState.pointer.justPressed=!0,a.inputState.clicks.push({x:n,y:r}),a.inputInteractions()},down(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.inside=!0,n.justPressed=!n.down,n.down=!0},up(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.down=!1},swipe(e){a.inputState.swipe=e},scroll(e){a.setScrollProgress(e),a.inputInteractions()}},e.appendChild(this.canvas),this.inputBinding=ca(e,this.inputState,{game:t.target?.kind===`game`}),this.measure(),typeof ResizeObserver<`u`&&(this.resizeObs=new ResizeObserver(()=>this.resize()),this.resizeObs.observe(e));let o=t.target??{},s=n.reducedMotion??(typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),c=o.reducedMotion??(o.kind===`game`?`ignore`:`static`);s&&!this.deterministic&&(c===`static`?this.staticMotion=!0:c===`slow`&&(this.timeScale=.5)),this.deterministic||o.lazy===!1||typeof IntersectionObserver>`u`?this.start():(this.visible=!1,this.interObs=new IntersectionObserver(e=>{let t=e.some(e=>e.isIntersecting);this.visible=t,this.lastSeen=performance.now(),this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null,t?this.start():this.releasable()&&(this.releaseTimer=setTimeout(()=>this.release(),Ma)),this.updateRunning()},{rootMargin:`200px 0px`}),this.interObs.observe(e),this.armStartFallback()),r.addEventListener(`visibilitychange`,this.onVisibility)}fallbackCleanup=null;armStartFallback(){let e=this.container.ownerDocument,t=e.defaultView;if(!t)return;let n=()=>{if(this.started||this.disposed)return a();if(e.visibilityState===`hidden`||!this.container.isConnected)return;let n=this.container.getBoundingClientRect(),r=t.innerHeight||e.documentElement.clientHeight,i=t.innerWidth||e.documentElement.clientWidth;n.bottom>=-200&&n.top<=r+200&&n.right>=0&&n.left<=i&&(n.width>0||n.height>0)&&(this.visible=!0,this.lastSeen=performance.now(),this.start(),this.updateRunning(),a())},r=[setTimeout(n,500),setTimeout(n,2e3)],i=t.requestAnimationFrame(()=>i=t.requestAnimationFrame(n)),a=()=>{for(let e of r)clearTimeout(e);t.cancelAnimationFrame(i),t.removeEventListener(`load`,n),t.removeEventListener(`scroll`,n),e.removeEventListener(`visibilitychange`,n),this.fallbackCleanup=null};t.addEventListener(`load`,n),t.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`visibilitychange`,n),this.fallbackCleanup=a}createRenderer(){let e=this.scene.target??{},t=new Ae({canvas:this.canvas,antialias:e.antialias!==!1,alpha:!!e.transparent,premultipliedAlpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:this.deterministic});if(!t.getContext())throw Error(`no context`);return this.configureRenderer(t),t.info.autoReset=!1,t}configureRenderer(e){let t=this.scene.target??{};e.outputColorSpace=N,e.toneMapping=Oa[t.toneMapping??`aces`]??4,e.toneMappingExposure=t.exposure??1,this.quality=r(n(t.quality,this.deviceHints(e))),this.qualityAuto=(t.quality??`auto`)===`auto`&&!this.deterministic&&!this.options.editor,this.perfClock=this.slowFor=0;let i=this.options.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,this.quality.dprCap);e.setPixelRatio(i);let a=ci(this.scene);if(e.shadowMap.enabled=a.enabled,e.shadowMap.type=a.type,t.transparent)e.setClearColor(0,0);else{let t=this.scene.environment?.background;e.setClearColor(typeof t==`string`&&t!==`transparent`?B(t):new F(0),1)}}start(){if(!(this.started||this.disposed)){if(this.started=!0,Na(this),this.released){let e=this.container.ownerDocument.createElement(`canvas`);e.style.cssText=this.canvas.style.cssText,this.canvas.replaceWith(e),this.canvas=e,this.released=!1}try{this.renderer=this.createRenderer(),$.add(this)}catch(e){this.report({code:`webgl-unavailable`,message:`WebGL is not available: ${e.message}`}),this.readyReject(Error(`webgl-unavailable`));return}this.measure(),this.renderer.setSize(this.width,this.height,!1),this.building=this.buildAll().then(()=>{this.disposed||(this.deterministic?(this.t=0,this.frame(0)):this.staticMotion?(this.t=this.scene.target?.posterTime??0,this.game?.advanceTo(this.t),this.frame(0),this.renderStill()):(this.frame(0),this.playing=!0,this.updateRunning()),this.placeholder?.remove(),this.placeholder=null,this.readyResolve(),this.readyCalled||this.options.onReady?.(this),this.readyCalled=!0)}).catch(e=>{this.report({code:`build-error`,message:e.message}),this.readyReject(e)})}}makeContext(e){return{scene:this.scene,rng:et(this.scene.seed??1),siblings:new Map,color:e=>B(e),resolveAsset:this.resolveAsset,renderer:this.renderer,deterministic:this.deterministic,quality:this.quality.tier,track:t=>(e.push(t.catch(()=>void 0)),this.trackProgress(t),t),onUpdate:()=>void 0,issue:(e,t,n)=>this.report({code:e,message:t,path:n}),shaders:pn,generators:mn}}async buildWorld(){let e=[],t=this.makeContext(e),n=await ea.create(J(this.scene),t,this.width/Math.max(this.height,1),this.canvas,!!this.options.editor);return await Promise.all(e),await Promise.all(e),n.setViewport(this.width,this.height,this.renderer.getPixelRatio()),n}async attachWorld(e){this.world=e,this.attachMotion(e),e.settleEntrances=this.staticMotion,await this.buildPostFx(e),this.renderer?.shadowMap&&(this.renderer.shadowMap.needsUpdate=!0);for(let e of this.worldListeners)try{e()}catch{}}async buildAll(){let e=await this.buildWorld();if(this.disposed)e.dispose();else{if(await this.attachWorld(e),ka(this.scene)){let{GameHost:t}=await i(async()=>{let{GameHost:e}=await import(`./game-DnnuBk26.js`);return{GameHost:e}},__vite__mapDeps([23,7,1,2,6,8,4,9]),import.meta.url);this.game=await t.create({scene:J(this.scene),container:this.container,input:this.inputState,resolveAsset:this.resolveAsset,scriptSources:this.options.scriptSources,deterministic:this.deterministic,issue:e=>this.report(e),rebuild:async()=>{let e=this.world,t=await this.buildWorld();return e?.dispose(),await this.attachWorld(t),t}},e);let n=this.game,r=n.emit.bind(n);n.emit=(e,t)=>{r(e,t),this.notify(e,t),this.dispatchMotionEvent(e,t)}}try{this.renderer?.compile(e.scene,e.camera)}catch{}}}loadTotal=0;loadDone=0;trackProgress(e){if(!this.options.onProgress)return;this.loadTotal++;let t=()=>{this.loadDone++;try{this.options.onProgress?.(this.loadDone,this.loadTotal)}catch{}};e.then(t,t)}notify(e,t){try{this.options.onEvent?.(e,t)}catch{}}emit(e,t){if(this.game)return this.game.emit(e,t);this.notify(e,t),this.dispatchMotionEvent(e,t)}dispatchMotionEvent(e,t){for(let n of this.eventListeners.get(e)??[])try{n(t)}catch{}this.interactions?.event(e,t)}report(e){this.issues.push(e);try{this.options.onError?.(e)}catch{}this.options.onError||console.warn(`[agent3d] ${e.code}: ${e.message}`)}updateRunning(){let e=this.container.ownerDocument.visibilityState===`hidden`,t=this.scene.target?.pauseOffscreen!==!1,n=this.playing&&!this.disposed&&!e&&(this.visible||!t)&&!!this.world;if(n&&!this.raf){this.lastNow=performance.now();let e=t=>{this.raf=requestAnimationFrame(e);let n=Math.min(Math.max((t-this.lastNow)/1e3,0),.1);this.lastNow=t,n>.002&&(this.fps=this.fps?this.fps*.9+1/n*.1:1/n),this.qualityAuto&&this.adaptQuality(n),this.tick(n*this.timeScale)};this.raf=requestAnimationFrame(e)}else!n&&this.raf&&(cancelAnimationFrame(this.raf),this.raf=0)}tick(e){this.world&&!this.rebuilding&&(this.game?.pendingRestart?(this.rebuilding=!0,this.game.restart().then(()=>{this.rebuilding=!1,this.t=0,this.resetMotion()})):(e=Math.max(e,0),this.t=Math.max(this.t+e,0),this.game?.advance(e),this.frame(e)))}attachMotion(e){this.tl=this.scene.timeline?new ma(this.scene.timeline):null,this.tlScroll=null,e.postfxParam=(e,t,n)=>this.postfx?.setParam?.(e,t,n);let t=this.scene.interactions??[];this.interactions=t.length?new _a(t,{play:(e,t)=>this.playSegment(e,{reverse:t}),toggle:e=>{this.tl?.toggle(e,this.t)||this.unknownSegment(e)},seek:e=>this.tl?.seek(e,this.t),set:(t,n,r,i)=>e.overrides.set(t,n,this.t,r,i),emit:(e,t)=>this.emit(e,t),openUrl:(e,t)=>this.openUrl(e,t),playClip:(t,n,r)=>{let i=e.entries.get(t)?.animator;i?i.play(n,r):this.report({code:`interaction`,message:`playClip: "${t}" is not a model with animation clips`,path:`interactions`})}}):null}handledClicks=0;handledKeys=new Set;inputInteractions(){let e=this.world;if(!this.deterministic||!this.interactions||!e)return;let t=this.inputState,n=e.interactiveRoots(),r=new Set(t.pointer.inside?this.pickIds(t.pointer.x,t.pointer.y,n):[]),i=new Set;for(let e of t.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,n))i.add(t);let a=new Set([...t.pressed].filter(e=>!this.handledKeys.has(e)));this.interactions.step({hovered:r,pointerInside:t.pointer.inside,clicked:i,canvasClicked:t.clicks.length>this.handledClicks,pressed:a,scroll:this.scrollValue(),visible:!0,userGesture:!1}),this.handledClicks=t.clicks.length;for(let e of a)this.handledKeys.add(e)}resetMotion(){this.tl?.reset(),this.interactions?.reset(),this.tlScroll=null}unknownSegment(e){this.report({code:`interaction`,message:`Unknown timeline segment "${e}"`,path:`timeline.segments`})}timelineLocal(e,t,n){let r=this.scene.timeline;return!r||!this.world?.timeline||!this.tl?null:this.tl.update({t:this.t,dt:e,deterministic:this.deterministic,staticMotion:this.staticMotion,posterTime:this.scene.target?.posterTime,hovered:t,clicked:n,scroll:r.trigger===`scroll`?this.timelineScroll(e):0})}timelineScroll(e){let t=this.scene.timeline;if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion)return this.scrollValue();let n=this.container.ownerDocument.defaultView,r=ra(this.container),i=Sa(r.top,r.height,n?.innerHeight||1,t.scroll?.start,t.scroll?.end),a=Math.min(Math.max(t.scroll?.smoothing??.8,0),.99);return this.tlScroll===null||a<=0?this.tlScroll=i:this.tlScroll+=(i-this.tlScroll)*(1-a**(Math.max(e,0)*60)),Math.abs(i-this.tlScroll)<1e-4&&(this.tlScroll=i),this.tlScroll}scrollValue(){if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion){let e=this.scene.timeline,t=e?.trigger===`scroll`&&e.duration>0?e.duration:4;return Math.min(Math.max(this.t/t,0),1)}return la(this.container)}openUrl(e,t){let n=this.container.ownerDocument.defaultView,r=n?ha(e,n.location.href):null;if(this.emit(`openUrl`,{url:r??e,blocked:!r||this.deterministic}),!r||!n||this.deterministic)return;let i=new URL(r).origin!==n.location.origin;t??i?n.open(r,`_blank`,`noopener,noreferrer`):n.location.assign(r)}playSegment(e,t={}){this.tl?.play(e,this.t,t)||this.unknownSegment(e)}trigger(e,t){this.interactions?.fire(e,t,!this.deterministic),this.interactions?.flush()}on(e,t){let n=this.eventListeners.get(e);return n||this.eventListeners.set(e,n=new Set),n.add(t),()=>n.delete(t)}setScrollProgress(e){this.scrollOverride=e===null||!Number.isFinite(e)?null:Math.min(Math.max(e,0),1)}pickIds(e,t,n){if(!this.world||!n.length)return[];this.raycaster.setFromCamera(new w(e,t),this.world.camera);let r=this.raycaster.intersectObjects(n,!0).find(e=>e.object.visible&&!e.object.isPoints);return r?this.world.idsFor(r.object):[]}frame(e){let t=this.world;if(!t)return;let n=this.inputState,r=t.interactiveRoots();this.hovered=new Set(n.pointer.inside?this.pickIds(n.pointer.x,n.pointer.y,r):[]);let i=new Set;for(let e of n.clicks){let n=this.pickIds(e.x,e.y,r);for(let e of n)i.add(e);if(this.options.onClick){let r=[...t.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object),i=n[0]??this.pickIds(e.x,e.y,r)[0]??null;try{this.options.onClick(i,{x:e.x,y:e.y})}catch{}}let a=n.map(e=>t.entries.get(e)?.def).find(e=>e&&`href`in e&&e.href);a?.href&&!this.deterministic&&this.navigate(a.href)}let a=[...this.hovered].some(e=>!!t.entries.get(e)?.def?.href)||[...this.hovered].some(e=>t.entries.get(e)?.interactive)?`pointer`:``;this.canvas.style.cursor!==a&&(this.canvas.style.cursor=a);let o=this.scrollValue(),s=i;if(this.handledClicks){s=new Set;for(let e of n.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,r))s.add(t)}this.interactions?.step({hovered:this.hovered,pointerInside:n.pointer.inside,clicked:s,canvasClicked:n.clicks.length>this.handledClicks,pressed:this.handledKeys.size?new Set([...n.pressed].filter(e=>!this.handledKeys.has(e))):n.pressed,scroll:o,visible:!0,userGesture:!this.deterministic});let c={pointer:n.pointer,scroll:o,hovered:this.hovered,clicked:i,timelineT:this.timelineLocal(e,n.pointer.inside,n.clicks.length>0)};for(let e of this.tl?.drainMarkers()??[])this.emit(e.name,{marker:e.name,time:e.time});this.interactions?.flush();let l=this.scene.camera?.follow?.target;t.frame(this.t,e,c,l?t.entries.get(l)?.object:null),this.game?.hud?.setTimeline(this.tl&&c.timelineT!==null?this.tl.info():null),this.game?.afterFrame(),this.render(),oa(n),this.handledClicks=0,this.handledKeys.clear()}navigate(e){let t=this.container.ownerDocument.defaultView;if(!t)return;let n=ha(e,t.location.href);if(!n)return;let r=new URL(n);r.origin===t.location.origin?t.location.assign(r.href):t.open(r.href,`_blank`,`noopener,noreferrer`)}render(e=!0){let t=this.renderer,n=this.world;if(!t||!n)return;let r=e?this.overlay:null,i=r?.viewCamera?.()??null,a=n.camera,o=i&&i!==a?{p:a.position.clone(),q:a.quaternion.clone(),proj:a.projectionMatrix.clone(),inv:a.projectionMatrixInverse.clone(),near:a.near,far:a.far}:null;if(i&&o){i.updateMatrixWorld(),i.matrixWorld.decompose(a.position,a.quaternion,new E),a.projectionMatrix.copy(i.projectionMatrix),a.projectionMatrixInverse.copy(i.projectionMatrixInverse);let e=i;typeof e.near==`number`&&(a.near=e.near,a.far=e.far),a.updateMatrixWorld(!0)}if(t.info.reset(),this.postfx?this.postfx.render(this.t,{samples:this.renderSamples}):t.render(n.scene,n.camera),this.renderSamples===1&&(this.lastStats={triangles:t.info.render.triangles,drawCalls:t.info.render.calls,geometries:t.info.memory.geometries,textures:t.info.memory.textures}),r)try{r.draw(t,a)}catch(e){this.report({code:`editor-overlay`,message:e.message}),this.overlay=null}o&&(a.position.copy(o.p),a.quaternion.copy(o.q),a.projectionMatrix.copy(o.proj),a.projectionMatrixInverse.copy(o.inv),a.near=o.near,a.far=o.far,a.updateMatrixWorld(!0))}releasable(){return!!this.renderer&&!!this.world&&!this.game&&!this.deterministic&&!this.options.editor&&!this.visible&&!this.disposed&&!this.released&&!ka(this.scene)}release(){if(!this.releasable())return;this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null;let e=``;try{this.render(),e=this.canvas.toDataURL(`image/webp`,.85)}catch{}if(e&&e.length>32){let t=this.container.ownerDocument.createElement(`img`);t.alt=``,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;`,t.src=e,this.placeholder?.remove(),this.placeholder=t,this.canvas.after(t)}this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.postfx?.dispose(),this.postfx=null,this.world?.dispose(),this.world=null,this.renderer?.dispose(),this.renderer?.forceContextLoss(),this.renderer=null,$.delete(this),this.released=!0,this.started=!1,this.building=null}play(){this.playing=!0,this.start(),this.updateRunning()}pause(){this.playing=!1,this.updateRunning(),this.deterministic||this.renderStill()}async seek(e){if(this.started||this.start(),await this.building,!this.world)return;let t=Math.max(0,e);t<this.t-1e-9&&(this.game?await this.game.restart():this.world.resetBehaviours(),this.t=0,this.resetMotion(),this.world.frame(0,0,{pointer:this.inputState.pointer,scroll:0,hovered:new Set,clicked:new Set,timelineT:this.world.timeline?0:null})),this.advanceMotionGrid(t);let n=t-this.t;this.t=t,this.game?.advanceTo(t),this.frame(n)}advanceMotionGrid(e){let t=this.world;if(!t||!this.deterministic||this.game||!t.hasStatefulMotion())return;let n=this.scene.camera?.follow?.target,r=n?t.entries.get(n)?.object:null;for(let n of dr(this.t,e)){let e=n-this.t;this.t=n;let i=this.inputState,a=t.interactiveRoots(),o=new Set(i.pointer.inside?this.pickIds(i.pointer.x,i.pointer.y,a):[]);t.frame(this.t,e,{pointer:i.pointer,scroll:this.scrollValue(),hovered:o,clicked:new Set,timelineT:this.timelineLocal(e,i.pointer.inside,!1)},r)}}time(){return this.t}async update(e){if(await this.building,this.scene=e,!this.renderer)return;this.renderer&&this.configureRenderer(this.renderer),this.game?.dispose(),this.game=null;let t=this.world;this.world=null,t?.dispose(),this.postfx?.dispose(),this.postfx=null,this.building=this.buildAll(),await this.building,this.frame(0)}measure(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||300),t=this.container.clientHeight;t||=Math.round(e/Aa(this.scene)),this.width=e,this.height=Math.max(1,t)}resize(){this.renderer&&(this.measure(),this.renderer.setSize(this.width,this.height,!1),this.world?.setViewport(this.width,this.height,this.renderer.getPixelRatio()),this.postfx?.setSize(this.width,this.height),this.world&&(!this.raf||this.deterministic)&&this.render())}stats(){return{...this.lastStats,fps:this.deterministic?void 0:Math.round(this.fps)||void 0}}inspect(){let e=this.world,t=e?.camera,n={objects:[],camera:{position:[0,0,0],target:[0,0,0]}};if(!e||!t)return n;e.scene.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let r=new f().setFromProjectionMatrix(new k().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),i=t.getWorldPosition(new E),a=new A,o=new E,s;for(let c of e.entries.values()){if(!c.topLevel)continue;if(a.setFromObject(c.object),c.particles){let e=c.object.geometry;e.boundingBox&&a.copy(e.boundingBox).applyMatrix4(c.object.matrixWorld)}if(a.isEmpty())continue;let e=0,l=1/0,u=1/0,d=-1/0,f=-1/0;for(let n=0;n<8;n++)o.set(n&1?a.max.x:a.min.x,n&2?a.max.y:a.min.y,n&4?a.max.z:a.min.z),r.containsPoint(o)&&e++,o.project(t),l=Math.min(l,o.x),d=Math.max(d,o.x),u=Math.min(u,o.y),f=Math.max(f,o.y);let p=e===8?`full`:r.intersectsBox(a)?`partial`:`none`;p===`partial`&&!c.particles&&(p=wa(c.object,r)??p);let m=Math.max(-1,l),h=Math.min(1,d),g=Math.max(-1,u),_=Math.min(1,f),v=p===`none`||a.containsPoint(i)?+!!a.containsPoint(i):Math.max(0,h-m)*Math.max(0,_-g)/4;!s&&c.kind!==`particles`&&a.containsPoint(i)&&(c.kind!==`generator`||Ta(c.object,i,c.def.generator===`terrain`&&c.built?.heightAt?{heightAt:c.built.heightAt}:`parts`))&&(s=c.id),n.objects.push({id:c.id,min:[a.min.x,a.min.y,a.min.z],max:[a.max.x,a.max.y,a.max.z],inView:p,screenCoverage:Math.round(Math.min(1,v)*1e3)/1e3})}let c=e.rig.orbit?e.rig.orbit.target:e.rig.rest.target;return n.camera={position:[i.x,i.y,i.z],target:[c.x,c.y,c.z]},s&&(n.camera.insideObject=s),n}snapshot(e=`image/png`,t){this.renderSamples=this.deterministic&&this.postfx?.stillSamples||1;try{this.render(!1)}finally{this.renderSamples=1}return this.canvas.toDataURL(e,t)}async snapshotHighQuality(e=16,t=`image/png`,n){this.started||this.start(),await this.building;let a=this.renderer,o=this.world;if(!a||!o)return this.canvas.toDataURL(t,n);let s=Math.max(1,Math.min(64,Math.round(e))),c=null;if(!this.postfx){let{createPostFx:e}=await i(async()=>{let{createPostFx:e}=await import(`./postfx-Dp7mgfGJ.js`);return{createPostFx:e}},__vite__mapDeps([24,1,2,8,4,9,7,6]),import.meta.url);c=e([],{renderer:a,scene:o.scene,camera:o.camera,width:this.width,height:this.height,quality:r(`ultra`),antialias:this.scene.target?.antialias!==!1},()=>void 0)}let l=this.postfx??c;try{return l.render(this.t,{samples:s}),this.canvas.toDataURL(t,n)}finally{c?.dispose()}}deviceHints(e){let t=globalThis.navigator??{},n;try{let t=e.getContext(),r=t.getExtension(`WEBGL_debug_renderer_info`);n=String(t.getParameter(r?r.UNMASKED_RENDERER_WEBGL:t.RENDERER)??``)}catch{}let r=t.userAgent??``;return{deterministic:this.deterministic,mobile:t.userAgentData?.mobile??/Mobi|Android|iPhone|iPad|iPod/i.test(r),cores:t.hardwareConcurrency,memoryGb:t.deviceMemory,gpu:n}}async buildPostFx(e,t=!1){if(t||(this.postfx?.dispose(),this.postfx=null),!this.scene.postfx?.length||!this.renderer)return;let{createPostFx:n}=await i(async()=>{let{createPostFx:e}=await import(`./postfx-Dp7mgfGJ.js`);return{createPostFx:e}},__vite__mapDeps([24,1,2,8,4,9,7,6]),import.meta.url);if(this.world!==e||!this.renderer)return;let r=n(this.scene.postfx,{renderer:this.renderer,scene:e.scene,camera:e.camera,width:this.width,height:this.height,quality:this.quality,antialias:this.scene.target?.antialias!==!1},e=>this.report({code:`unknown-catalog-id`,message:`Unknown post effect "${e}"`,path:`postfx`}));if(await r.ready,this.world!==e)return r.dispose();this.postfx?.dispose(),this.postfx=r}renderStill(){let e=this.postfx?.stillSamples??0;if(!(e<2||!this.world)){this.renderSamples=e;try{this.render()}finally{this.renderSamples=1}}}adaptQuality(e){let t=this.renderer;if(!t||!this.world||this.rebuilding||(this.perfClock+=e,this.perfClock<2)||(this.fps<40?this.slowFor+=e:this.slowFor=Math.max(0,this.slowFor-e),this.slowFor<3))return;if(this.slowFor=0,this.perfClock=0,this.options.pixelRatio===void 0&&t.getPixelRatio()>1.01){t.setPixelRatio(Math.max(1,t.getPixelRatio()*.75)),this.resize();return}let n=u(this.quality.tier);n?(this.quality=r(n),this.scene.postfx?.length&&this.buildPostFx(this.world,!0)):this.qualityAuto=!1}pick(e,t){let n=this.world;if(!n)return null;let r=[...n.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object);return this.pickIds(e,t,r)[0]??null}state(){return this.game?.state??{}}dispose(){this.disposed||(this.disposed=!0,this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.resizeObs?.disconnect(),this.interObs?.disconnect(),this.fallbackCleanup?.(),this.container.ownerDocument.removeEventListener(`visibilitychange`,this.onVisibility),this.inputBinding?.dispose(),this.overlay=null,this.worldListeners.clear(),this.game?.dispose(),this.postfx?.dispose(),this.world?.dispose(),this.renderer?.dispose(),this.renderer?.forceContextLoss(),$.delete(this),this.releaseTimer&&clearTimeout(this.releaseTimer),this.placeholder?.remove(),this.canvas.remove())}};function Ia(e,t,n={}){let r=new Fa(e,t,n);return r.canvas.isConnected&&r.resize(),r}var La=class extends ln{mountPlayer(e,t,n){return Ia(e,t,n)}};function Ra(e=`agent3d-scene`){un(La,e)}var za=e({Agent3DSceneElement:()=>La,bindSceneData:()=>J,liveContextCount:()=>Pa,mountScene:()=>Ia,version:()=>t});Ra();var Ba=globalThis;Ba.Agent3D||={mountScene:Ia,version:t,bindSceneData:J,liveContexts:Pa};export{La as Agent3DSceneElement,Gt as a,J as bindSceneData,At as c,$t as i,Pa as liveContextCount,Ia as mountScene,Hr as n,Kt as o,Vr as r,jt as s,za as t,t as version};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{In as e,Ln as t,on as n,x as r}from"./three.module-B9FlcKtd.js";import{r as i}from"./params-BZqUA__U.js";import{n as a,r as o}from"./runtime-
|
|
1
|
+
import{In as e,Ln as t,on as n,x as r}from"./three.module-B9FlcKtd.js";import{r as i}from"./params-BZqUA__U.js";import{n as a,r as o}from"./runtime-ByR4qfyV.js";var s=`
|
|
2
2
|
varying vec2 vUv;
|
|
3
3
|
varying vec3 vPos;
|
|
4
4
|
varying vec3 vNormalV;
|