@fleox/agent3d 0.2.1 → 0.2.3
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 +11 -10
- package/changelog.json +22 -0
- package/dist/agent/agent3d.mjs +58 -47
- package/dist/agent/chunks/{browser-t_JL_B82.mjs → browser-Br1tURgt.mjs} +21 -2
- package/dist/agent/chunks/{check-CBO3Ekx1.mjs → check-CfZcfaPs.mjs} +12 -0
- package/dist/agent/chunks/{export-BCI8vKw8.mjs → export-BHugc2H7.mjs} +1 -1
- package/dist/agent/chunks/{imageCodec-Dz9PFxi9.mjs → imageCodec-QM0EXQDJ.mjs} +1 -1
- package/dist/agent/chunks/{package-BOIyp_2B.mjs → package-fw4h5vsh.mjs} +2 -2
- package/dist/agent/chunks/{render-CN4mgGLQ.mjs → render-EHb40avl.mjs} +1 -1
- package/dist/agent/chunks/{tools-DT2tetIK.mjs → tools-DKxgjQSJ.mjs} +2 -2
- package/dist/runtime/agent3d-runtime.js +2 -2
- package/dist/runtime/agent3d-runtime.single.js +2 -2
- package/dist/runtime/chunks/catalog--OTp4gjy.js +1 -0
- package/dist/runtime/chunks/{generators-D5JUo0jp.js → generators--kOFg1G_.js} +1 -1
- package/dist/runtime/chunks/{materials-Dn-bYrZd.js → materials-w3EW0g-7.js} +1 -1
- package/dist/runtime/chunks/{model-BCVF3QzB.js → model-DbfZaLni.js} +1 -1
- package/dist/runtime/chunks/{params-C2uoUDJ0.js → params-BCNrVCYZ.js} +1 -1
- package/dist/runtime/chunks/{postfx-i_J5Vf-l.js → postfx-CFucYRev.js} +1 -1
- package/dist/runtime/chunks/{postfx-UgKCbmZs.js → postfx-Cbf_vvOr.js} +1 -1
- package/dist/runtime/chunks/{shaders-Dw6zHdu_.js → shaders-Ba3v6Xnj.js} +1 -1
- package/dist/runtime/chunks/{svg-CmlFY_8O.js → svg-CfPIQnDG.js} +1 -1
- package/dist/runtime/chunks/{text-D1EQpdSU.js → text-BaON-ISS.js} +1 -1
- package/dist/studio/assets/{camera-7sEn13L-.js → camera-Be6lnp3k.js} +1 -1
- package/dist/studio/assets/{editor-CnbvVkhU.js → editor-Mpnz-b2E.js} +1 -1
- package/dist/studio/assets/{game-B04KGAK0.js → game-WMgRSJUD.js} +3 -3
- package/dist/studio/assets/{generators-LSni1Yfc.js → generators-DozXE7ta.js} +1 -1
- package/dist/studio/assets/{index-3LL5NEIH.js → index-tSGZFEt5.js} +5 -5
- package/dist/studio/assets/{model-CNddhwmA.js → model-C2bZTK7-.js} +1 -1
- package/dist/studio/assets/{physicsHost-hMU_SDiX.js → physicsHost-CTRsIvfu.js} +1 -1
- package/dist/studio/assets/{postfx-BcCZS0Bq.js → postfx-DQtp0JIy.js} +1 -1
- package/dist/studio/assets/{runtime-DY_KqD1x.js → runtime-NGp1VdnH.js} +4 -4
- package/dist/studio/assets/{shaders-BhMCstyv.js → shaders-BOb6Uter.js} +1 -1
- package/dist/studio/assets/{svg-CNKK-h7H.js → svg-CnUMpv_N.js} +1 -1
- package/dist/studio/assets/{text-BSPI7dk1.js → text-CGIZs8HE.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/agent3d-assets/SKILL.md +24 -24
- package/plugin/skills/agent3d-create/SKILL.md +20 -20
- 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 +21 -21
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
- package/dist/runtime/chunks/catalog-DL6sgPay.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$t as e,A as t,Bt as n,Cn as r,Et as i,G as a,H as o,In as s,It as c,J as l,L as u,M as d,Mn as f,Mt as p,N as m,Nn as h,Nt as g,On as _,Pt as v,R as y,Rt as b,S as x,Sn as S,Tn as C,U as w,Ut as T,V as ee,W as E,Xt as D,Yt as O,_ as te,an as ne,b as k,bn as re,bt as A,d as j,dn as ie,en as ae,et as oe,f as se,fn as ce,g as le,h as ue,hn as M,i as de,in as fe,j as pe,lt as me,m as he,nn as ge,o as _e,p as ve,pn as ye,r as be,rn as N,t as xe,v as Se,vt as P,w as Ce,xt as we,yn as Te,yt as F,z as Ee,zt as De}from"./chunks/three.module-DnaBiDAJ.js";import{i as Oe,n as ke,o as Ae,r as je,s as Me,t as Ne,u as Pe}from"./chunks/materials-Dn-bYrZd.js";import{i as Fe,n as Ie,o as Le,r as Re}from"./chunks/postfx-i_J5Vf-l.js";import{i as ze,n as Be,t as Ve}from"./chunks/catalog-DL6sgPay.js";import{t as I}from"./chunks/easing-CXSz2e6P.js";import{a as He,c as L,d as R,f as z,i as Ue,l as B,n as V,o as H,p as We,r as Ge,s as Ke,t as U,u as qe}from"./chunks/util-CyaW1fcW.js";import{a as Je,i as Ye,t as Xe}from"./chunks/random-eeej60NW.js";import{n as Ze,t as Qe}from"./chunks/meshGradient.glsl-BMatplLA.js";import{n as $e}from"./chunks/params-C2uoUDJ0.js";import{t as et}from"./chunks/RoundedBoxGeometry-BViRogcJ.js";var tt=`0.2.1`,nt=/\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;function rt(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function it(e){return typeof e!=`string`||!e.includes(`{data.`)?!1:(nt.lastIndex=0,nt.test(e))}function at(e,t){return e.includes(`{data.`)?e.replace(nt,(e,n,r)=>{let i=rt(t,n);return i==null||i===``?r??``:typeof i==`object`?JSON.stringify(i):String(i)}):e}var ot=/^\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}$/;function st(e,t){if(typeof e!=`string`||!e.includes(`{data.`))return e;let n=ot.exec(e.trim());if(!n)return at(e,t);let r=rt(t,n[1]);if(r!=null&&r!==``)return r;if(n[2]!==void 0)try{return JSON.parse(n[2])}catch{return n[2]}}function W(e,t=e.data){let n=!1,r=e=>it(e)?(n=!0,at(e,t)):e,i=e=>{if(typeof e==`string`)return it(e)?(n=!0,st(e,t)):e;if(Array.isArray(e)){let t=e.map(i);return t.every((t,n)=>t===e[n])?e:t}if(e&&typeof e==`object`){let t=!1,n={};for(let[r,a]of Object.entries(e)){let e=i(a);e!==a&&(t=!0),e!==void 0&&(n[r]=e)}return t?n:e}return e},a=e=>{let t=e,n=t.kind===`text`?r(t.text):t.text,o=r(t.href),s=t.kind===`generator`&&t.params?i(t.params):t.params,c=e.children?.map(a);return n===t.text&&o===t.href&&s===t.params&&(!c||c.every((t,n)=>t===e.children[n]))?e:{...e,...t.kind===`text`?{text:n}:{},...t.href===void 0?{}:{href:o},...s===t.params?{}:{params:s},...c?{children:c}:{}}},o=e.interactions?.map(e=>{let t=e.do;if(!Array.isArray(t))return e;let n=t.map(e=>{let t=e;return!t||typeof t!=`object`||!it(t.openUrl)?e:{...t,openUrl:r(t.openUrl)}});return n.every((e,n)=>e===t[n])?e:{...e,do:n}}),s=(e.objects??[]).map(a),c=r(e.title),l=r(e.ariaLabel),u=e.ui?.elements?.map(e=>{let t=e,n=r(t.text);return n===t.text?e:{...e,text:n}});return n?{...e,title:c,...e.ariaLabel===void 0?{}:{ariaLabel:l},objects:s,...e.ui&&u?{ui:{...e.ui,elements:u}}:{},...o?{interactions:o}:{}}:e}function ct(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(n===`json`)try{let e=JSON.parse(r);e&&typeof e==`object`&&!Array.isArray(e)&&Object.assign(t,e)}catch{}else t[n]=r}return t}var lt=null,ut=null;function dt(){return lt??=import(`./chunks/shaders-Dw6zHdu_.js`).then(e=>e.SHADER_IMPLS),lt}function ft(){return ut??=import(`./chunks/generators-D5JUo0jp.js`).then(e=>e.GENERATOR_IMPLS),ut}function G(e,t=[0,1,0]){let n=new h(...z(e,t));return n.lengthSq()<1e-9&&n.set(0,1,0),n.normalize()}function pt(e){return Ke(e)}var K=Math.PI*2,mt=(e,t)=>{let n=qe(e.effect,`scale`),r=Math.max(L(e.duration,.8),.001),i=qe(e.ease,`outBack`),a=n===`fade`?pt(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=I(i,o),c=t.object;switch(n){case`fade`:for(let e of a)e.opacity=e.userData.baseOpacity*I(`outCubic`,o);break;case`rise`:c.position.y-=(1-s)*1,c.scale.multiplyScalar(Math.max(1e-4,Math.min(1,o*3)));break;case`drop`:c.position.y+=(1-s)*3,o<=0&&(c.visible=!1);break;case`spin`:c.rotation.y+=(1-s)*K,c.scale.multiplyScalar(Math.max(1e-4,s));break;default:c.scale.multiplyScalar(Math.max(1e-4,s))}}}},ht=(e,t)=>{let n=V(e.lockY,!0),r=new h,i=new h;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)}}},gt=(e,t)=>{let n=Math.max(L(e.interval,3),.05),r=L(e.duration,.15),i=V(e.random,!0);return{update(e){let a=Math.floor(e/n),o=i?H(a+t.object.id)*(n-r)*.8:n-r,s=e-a*n;s>=o&&s<o+r&&(t.object.visible=!1)}}},_t=(e,t)=>{let n=L(e.amount,.04),r=Math.max(L(e.period,4),.1),i=L(e.phase,0),a=L(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}}},vt=(e,t)=>{let n=L(e.height,.3),r=L(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}}},yt=(e,t)=>{let n=L(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 bt(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 xt=/* @__PURE__ */ new Map;function St(e){let t=xt.get(e);if(!t){t=new k;try{t.setStyle(e)}catch{t.set(16777215)}xt.size<1e3&&xt.set(e,t)}return t}var Ct=/^\s*([+\-*])=\s*(-?\d*\.?\d+(?:e[+-]?\d+)?)\s*$/i;function wt(e){return typeof e==`string`&&Ct.test(e)}function q(e,t){if(typeof e==`number`)return e;let n=typeof e==`string`?Ct.exec(e):null;if(!n)return t;let r=Number(n[2]);return n[1]===`+`?t+r:n[1]===`-`?t-r:t*r}function Tt(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)?[q(a[0],n?.[0]??0),q(a[1],n?.[1]??0),q(a[2],n?.[2]??0)]:wt(a)?n&&Array.isArray(t)?[q(a,n[0]),q(a,n[1]),q(a,n[2])]:q(a,r):a,o===void 0?[i,s]:[i,s,o]})}function Et(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 Dt(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 Ot(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),me)}function kt(e,t,n,r=`oklch`,i=new k){if(r===`rgb`)return i.copy(e).lerp(t,n);if(r===`oklch`){let r=Dt(e),a=Dt(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 Ot(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=Dt(e),o=Dt(t);return Ot(a[0]+(o[0]-a[0])*n,a[1]+(o[1]-a[1])*n,a[2]+(o[2]-a[2])*n,i)}function At(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 kt(St(String(e)),St(String(t)),n,r);let i=Et(e),a=Et(t);return[i[0]+(a[0]-i[0])*n,i[1]+(a[1]-i[1])*n,i[2]+(a[2]-i[2])*n]}function jt(e){return typeof e==`string`?St(e).clone():Array.isArray(e)?[e[0],e[1],e[2]]:e}function Mt(e,t,n,r){let i=e;if(!i.length)return;if(t<=i[0][0])return jt(i[0][1]);let a=i[i.length-1];if(t>=a[0])return jt(a[1]);for(let e=0;e<i.length-1;e++){let[a,o]=i[e],[s,c,l]=i[e+1];if(t>=a&&t<s)return typeof o==`boolean`||typeof c==`boolean`?o:At(o,c,s>a?I(l??n??`linear`,(t-a)/(s-a)):1,r)}return jt(a[1])}function Nt(e){let t=e.indexOf(`.`);return t<0?{id:e,path:``}:{id:e.slice(0,t),path:e.slice(t+1)}}function Pt(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 Ft=(e,t)=>{let n=Ue(e.colors,[`#ff006e`,`#8338ec`,`#3a86ff`]).map(e=>R(e)),r=L(e.speed,.5),i=V(e.emissive,!1),a=pt(t.object),o=new k;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);kt(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)}}}},It=(e,t)=>{let[n,r,i]=z(e.area,[1,1,1]),a=L(e.speed,.3),o=L(e.seed,1)+t.object.id*.137,s=Array.from({length:6},(e,t)=>H(o*13.1+t)*Math.PI*2),c=Array.from({length:6},(e,t)=>.6+H(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 Lt(e,t){let n=Math.floor(e),r=e-n,i=H(n+t*31.7);return i+(H(n+1+t*31.7)-i)*r*r*(3-2*r)}var Rt=(e,t)=>{let n=Ge(L(e.amount,.3),0,1),r=L(e.speed,8),i=t.object.id,a=pt(t.object);for(let e of a)e.userData.baseEmissiveIntensity===void 0&&(e.userData.baseEmissiveIntensity=e.emissiveIntensity??1);return{update(e){let o=.6*Lt(e*r,i)+.4*Lt(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)}}},zt=(e,t)=>{let n=L(e.amplitude,.15),r=L(e.speed,.5),i=L(e.phase,0);return{update:e=>void(t.object.position.y+=n*Math.sin(K*(r*e+i)))}},Bt=(e,t)=>{let n=L(e.strength,.5),r=L(e.smoothing,.9),i=qe(e.mode,`rotate`),a=0,o=0;return{update(e,s){let c=B(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)}}},Vt=(e,t)=>{let n=L(e.height,.2),r=L(e.tilt,10)*U,i=0,a=0,o=0;return{update(e,s){let c=B(.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}}},Ht=(e,t)=>{let n=L(e.scale,1.15),r=L(e.smoothing,.8),i=1;return{update(e,a){i+=((t.hovered()?n:1)-i)*B(r,a),t.object.scale.multiplyScalar(i)}}},Ut=(e,t)=>{let n=L(e.smoothing,.85),r=V(e.lockY,!1),i=Array.isArray(e.point)&&e.point.length===3?new h(...e.point):null,a=typeof e.target==`string`?e.target:`camera`,o=new T,s=new T,c=new h,l=new h,u=new P,d=new T,f=!0;return{update(e,m){let g=i??(a===`camera`?t.camera:t.find?.(a));g&&(g instanceof h?l.copy(g):g.getWorldPosition(l),t.object.getWorldPosition(c),r&&(l.y=c.y),l.distanceToSquared(c)<1e-10||(u.lookAt(l,c,p.DEFAULT_UP),o.setFromRotationMatrix(u),t.object.parent&&o.premultiply(t.object.parent.getWorldQuaternion(d).invert()),s.slerp(o,f?1:B(n,m)),f=!1,t.object.quaternion.copy(s)))}}},Wt=(e,t)=>{let n=L(e.maxAngle,35)*U,r=L(e.smoothing,.85),i=0,a=0;return{update(e,o){let s=B(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}}},Gt=(e,t)=>{let n=Math.max(L(e.radius,.25),.001),r=L(e.strength,.4),i=new h,a=new h,o=new h,s=new h,c=new h;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,B(.85,l)),t.object.position.add(i)}}},Kt=(e,t)=>{let[n,r,i]=z(e.amplitude,[.1,.1,.05]),[a,o,s]=z(e.rotation,[3,3,2]),c=L(e.speed,.3),l=L(e.seed,1)*13.37+t.rng.next()*100,u=(e,t)=>Je(e*c+l,t*5.17)*.8+Je(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*U,t.object.rotation.y+=u(e,4)*o*U,t.object.rotation.z+=u(e,5)*s*U}}},qt=(e,t)=>{let n=new h(...z(e.center,[0,0,0])),r=L(e.radius,2),i=L(e.speed,30)*U,a=L(e.phase,0)*U,o=G(e.axis),s=V(e.faceDirection,!1),c=Math.abs(o.y)<.99?new h(0,1,0):new h(1,0,0),l=new h().crossVectors(c,o).normalize(),u=new h().crossVectors(o,l).normalize(),d=new h;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 h(0,0,1),e.normalize());t.object.quaternion.premultiply(n)}}}},Jt=(e,t)=>{let n=L(e.depth,.5),r=L(e.pointer,.3),i=L(e.scroll,0),a=L(e.smoothing,.9),o=0,s=0;return{update(e,c){let l=B(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}}},Yt=(e,t)=>{let n=(Array.isArray(e.points)?e.points:[]).filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new h(e[0],e[1],e[2])),r=V(e.loop,!0),i=V(e.faceDirection,!0),a=Math.max(L(e.duration,5),.001);if(n.length<2)return{update(){}};let o=new te(n,r,`catmullrom`,.5),s=new h,c=new h(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))}}},Xt=(e,t)=>{let n=L(e.amount,.08),r=L(e.speed,1);return{update:e=>void t.object.scale.multiplyScalar(1+n*Math.sin(K*r*e))}},Zt=(e,t)=>{let n=G(e.axis),r=L(e.speed,45)*U;return{update:e=>void t.object.rotateOnAxis(n,r*e)}},Qt=(e,t)=>{let[n,r,i]=z(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}}},$t=(e,t)=>{let n=G(e.axis),r=L(e.degrees,360)*U;return{update:()=>void t.object.rotateOnAxis(n,r*t.scroll())}},en=(e,t)=>{let n=G(e.axis),r=Math.max(L(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 c=(e-a)/r;c>=1||t.object.rotateOnAxis(n,K*I(`inOutCubic`,c))}}};function tn(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 nn={rotate:Zt,float:zt,bob:vt,pulse:Xt,wobble:(e,t)=>{let n=L(e.amount,.08),r=L(e.speed,2);return{update(e){let i=Math.sin(K*r*e*.5),a=Math.sin(K*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=G(e.axis,[0,0,1]),r=L(e.angle,8)*U,i=L(e.speed,.5);return{update:e=>void t.object.rotateOnAxis(n,r*Math.sin(K*i*e))}},orbit:qt,path:Yt,followPointer:Bt,lookAtPointer:Wt,hoverScale:Ht,hoverLift:Vt,clickBounce:yt,spinOnClick:en,scrollRotate:$t,scrollMove:Qt,drift:It,blink:gt,colorCycle:Ft,flicker:Rt,billboard:ht,appear:mt,magnet:Gt,spring:(e,t)=>{let n=L(e.strength,.4),r=Math.max(L(e.stiffness,120),1),i=Math.max(L(e.damping,12),0),a=Math.max(L(e.mass,1),.01),o=qe(e.mode,`move`),s=L(e.angle,15)*U,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]=tn(c.x,c.vx,u,l,r,i,a),[c.y,c.vy]=tn(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:Jt,tilt:(e,t)=>{let n=L(e.maxAngle,12)*U,r=L(e.scale,1.04),i=L(e.lift,.1),a=L(e.smoothing,.86),o=V(e.hoverOnly,!0),s=V(e.reverse,!1)?-1:1,c=0,l=0,u=0;return{update(e,d){let f=o?t.hovered():t.pointer.inside,p=B(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:_t,noise:Kt,lookAt:Ut},rn=/* @__PURE__ */ new Set([`appear`]),an=1e6,on=/* @__PURE__ */ new Set([`billboard`,`lookAt`]),sn=/* @__PURE__ */ new Set([`lookAt`,`magnet`,`spring`]),cn=1/30;function ln(e,t,n=cn){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 un(e,t,n,r={}){let i=t(e,n),a=e.when??`always`,o=L(e.delay,0),s=0,c=-1;return{def:e,late:on.has(e.type),stateful:sn.has(e.type),step(t,l){if(r.settled?.()&&rn.has(e.type)&&(a===`always`||a===`visible`)){i.update(an,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 dn={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},fn={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`}},pn={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},mn=`
|
|
1
|
+
import{$t as e,A as t,Bt as n,Cn as r,Et as i,G as a,H as o,In as s,It as c,J as l,L as u,M as d,Mn as f,Mt as p,N as m,Nn as h,Nt as g,On as _,Pt as v,R as y,Rt as b,S as x,Sn as S,Tn as C,U as w,Ut as T,V as ee,W as E,Xt as D,Yt as O,_ as te,an as ne,b as k,bn as re,bt as A,d as j,dn as ie,en as ae,et as oe,f as se,fn as ce,g as le,h as ue,hn as M,i as de,in as fe,j as pe,lt as me,m as he,nn as ge,o as _e,p as ve,pn as ye,r as be,rn as N,t as xe,v as Se,vt as P,w as Ce,xt as we,yn as Te,yt as F,z as Ee,zt as De}from"./chunks/three.module-DnaBiDAJ.js";import{i as Oe,n as ke,o as Ae,r as je,s as Me,t as Ne,u as Pe}from"./chunks/materials-w3EW0g-7.js";import{i as Fe,n as Ie,o as Le,r as Re}from"./chunks/postfx-CFucYRev.js";import{i as ze,n as Be,t as Ve}from"./chunks/catalog--OTp4gjy.js";import{t as I}from"./chunks/easing-CXSz2e6P.js";import{a as He,c as L,d as R,f as z,i as Ue,l as B,n as V,o as H,p as We,r as Ge,s as Ke,t as U,u as qe}from"./chunks/util-CyaW1fcW.js";import{a as Je,i as Ye,t as Xe}from"./chunks/random-eeej60NW.js";import{n as Ze,t as Qe}from"./chunks/meshGradient.glsl-BMatplLA.js";import{n as $e}from"./chunks/params-BCNrVCYZ.js";import{t as et}from"./chunks/RoundedBoxGeometry-BViRogcJ.js";var tt=`0.2.3`,nt=/\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;function rt(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function it(e){return typeof e!=`string`||!e.includes(`{data.`)?!1:(nt.lastIndex=0,nt.test(e))}function at(e,t){return e.includes(`{data.`)?e.replace(nt,(e,n,r)=>{let i=rt(t,n);return i==null||i===``?r??``:typeof i==`object`?JSON.stringify(i):String(i)}):e}var ot=/^\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}$/;function st(e,t){if(typeof e!=`string`||!e.includes(`{data.`))return e;let n=ot.exec(e.trim());if(!n)return at(e,t);let r=rt(t,n[1]);if(r!=null&&r!==``)return r;if(n[2]!==void 0)try{return JSON.parse(n[2])}catch{return n[2]}}function W(e,t=e.data){let n=!1,r=e=>it(e)?(n=!0,at(e,t)):e,i=e=>{if(typeof e==`string`)return it(e)?(n=!0,st(e,t)):e;if(Array.isArray(e)){let t=e.map(i);return t.every((t,n)=>t===e[n])?e:t}if(e&&typeof e==`object`){let t=!1,n={};for(let[r,a]of Object.entries(e)){let e=i(a);e!==a&&(t=!0),e!==void 0&&(n[r]=e)}return t?n:e}return e},a=e=>{let t=e,n=t.kind===`text`?r(t.text):t.text,o=r(t.href),s=t.kind===`generator`&&t.params?i(t.params):t.params,c=e.children?.map(a);return n===t.text&&o===t.href&&s===t.params&&(!c||c.every((t,n)=>t===e.children[n]))?e:{...e,...t.kind===`text`?{text:n}:{},...t.href===void 0?{}:{href:o},...s===t.params?{}:{params:s},...c?{children:c}:{}}},o=e.interactions?.map(e=>{let t=e.do;if(!Array.isArray(t))return e;let n=t.map(e=>{let t=e;return!t||typeof t!=`object`||!it(t.openUrl)?e:{...t,openUrl:r(t.openUrl)}});return n.every((e,n)=>e===t[n])?e:{...e,do:n}}),s=(e.objects??[]).map(a),c=r(e.title),l=r(e.ariaLabel),u=e.ui?.elements?.map(e=>{let t=e,n=r(t.text);return n===t.text?e:{...e,text:n}});return n?{...e,title:c,...e.ariaLabel===void 0?{}:{ariaLabel:l},objects:s,...e.ui&&u?{ui:{...e.ui,elements:u}}:{},...o?{interactions:o}:{}}:e}function ct(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(n===`json`)try{let e=JSON.parse(r);e&&typeof e==`object`&&!Array.isArray(e)&&Object.assign(t,e)}catch{}else t[n]=r}return t}var lt=null,ut=null;function dt(){return lt??=import(`./chunks/shaders-Ba3v6Xnj.js`).then(e=>e.SHADER_IMPLS),lt}function ft(){return ut??=import(`./chunks/generators--kOFg1G_.js`).then(e=>e.GENERATOR_IMPLS),ut}function G(e,t=[0,1,0]){let n=new h(...z(e,t));return n.lengthSq()<1e-9&&n.set(0,1,0),n.normalize()}function pt(e){return Ke(e)}var K=Math.PI*2,mt=(e,t)=>{let n=qe(e.effect,`scale`),r=Math.max(L(e.duration,.8),.001),i=qe(e.ease,`outBack`),a=n===`fade`?pt(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=I(i,o),c=t.object;switch(n){case`fade`:for(let e of a)e.opacity=e.userData.baseOpacity*I(`outCubic`,o);break;case`rise`:c.position.y-=(1-s)*1,c.scale.multiplyScalar(Math.max(1e-4,Math.min(1,o*3)));break;case`drop`:c.position.y+=(1-s)*3,o<=0&&(c.visible=!1);break;case`spin`:c.rotation.y+=(1-s)*K,c.scale.multiplyScalar(Math.max(1e-4,s));break;default:c.scale.multiplyScalar(Math.max(1e-4,s))}}}},ht=(e,t)=>{let n=V(e.lockY,!0),r=new h,i=new h;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)}}},gt=(e,t)=>{let n=Math.max(L(e.interval,3),.05),r=L(e.duration,.15),i=V(e.random,!0);return{update(e){let a=Math.floor(e/n),o=i?H(a+t.object.id)*(n-r)*.8:n-r,s=e-a*n;s>=o&&s<o+r&&(t.object.visible=!1)}}},_t=(e,t)=>{let n=L(e.amount,.04),r=Math.max(L(e.period,4),.1),i=L(e.phase,0),a=L(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}}},vt=(e,t)=>{let n=L(e.height,.3),r=L(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}}},yt=(e,t)=>{let n=L(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 bt(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 xt=/* @__PURE__ */ new Map;function St(e){let t=xt.get(e);if(!t){t=new k;try{t.setStyle(e)}catch{t.set(16777215)}xt.size<1e3&&xt.set(e,t)}return t}var Ct=/^\s*([+\-*])=\s*(-?\d*\.?\d+(?:e[+-]?\d+)?)\s*$/i;function wt(e){return typeof e==`string`&&Ct.test(e)}function q(e,t){if(typeof e==`number`)return e;let n=typeof e==`string`?Ct.exec(e):null;if(!n)return t;let r=Number(n[2]);return n[1]===`+`?t+r:n[1]===`-`?t-r:t*r}function Tt(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)?[q(a[0],n?.[0]??0),q(a[1],n?.[1]??0),q(a[2],n?.[2]??0)]:wt(a)?n&&Array.isArray(t)?[q(a,n[0]),q(a,n[1]),q(a,n[2])]:q(a,r):a,o===void 0?[i,s]:[i,s,o]})}function Et(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 Dt(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 Ot(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),me)}function kt(e,t,n,r=`oklch`,i=new k){if(r===`rgb`)return i.copy(e).lerp(t,n);if(r===`oklch`){let r=Dt(e),a=Dt(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 Ot(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=Dt(e),o=Dt(t);return Ot(a[0]+(o[0]-a[0])*n,a[1]+(o[1]-a[1])*n,a[2]+(o[2]-a[2])*n,i)}function At(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 kt(St(String(e)),St(String(t)),n,r);let i=Et(e),a=Et(t);return[i[0]+(a[0]-i[0])*n,i[1]+(a[1]-i[1])*n,i[2]+(a[2]-i[2])*n]}function jt(e){return typeof e==`string`?St(e).clone():Array.isArray(e)?[e[0],e[1],e[2]]:e}function Mt(e,t,n,r){let i=e;if(!i.length)return;if(t<=i[0][0])return jt(i[0][1]);let a=i[i.length-1];if(t>=a[0])return jt(a[1]);for(let e=0;e<i.length-1;e++){let[a,o]=i[e],[s,c,l]=i[e+1];if(t>=a&&t<s)return typeof o==`boolean`||typeof c==`boolean`?o:At(o,c,s>a?I(l??n??`linear`,(t-a)/(s-a)):1,r)}return jt(a[1])}function Nt(e){let t=e.indexOf(`.`);return t<0?{id:e,path:``}:{id:e.slice(0,t),path:e.slice(t+1)}}function Pt(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 Ft=(e,t)=>{let n=Ue(e.colors,[`#ff006e`,`#8338ec`,`#3a86ff`]).map(e=>R(e)),r=L(e.speed,.5),i=V(e.emissive,!1),a=pt(t.object),o=new k;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);kt(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)}}}},It=(e,t)=>{let[n,r,i]=z(e.area,[1,1,1]),a=L(e.speed,.3),o=L(e.seed,1)+t.object.id*.137,s=Array.from({length:6},(e,t)=>H(o*13.1+t)*Math.PI*2),c=Array.from({length:6},(e,t)=>.6+H(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 Lt(e,t){let n=Math.floor(e),r=e-n,i=H(n+t*31.7);return i+(H(n+1+t*31.7)-i)*r*r*(3-2*r)}var Rt=(e,t)=>{let n=Ge(L(e.amount,.3),0,1),r=L(e.speed,8),i=t.object.id,a=pt(t.object);for(let e of a)e.userData.baseEmissiveIntensity===void 0&&(e.userData.baseEmissiveIntensity=e.emissiveIntensity??1);return{update(e){let o=.6*Lt(e*r,i)+.4*Lt(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)}}},zt=(e,t)=>{let n=L(e.amplitude,.15),r=L(e.speed,.5),i=L(e.phase,0);return{update:e=>void(t.object.position.y+=n*Math.sin(K*(r*e+i)))}},Bt=(e,t)=>{let n=L(e.strength,.5),r=L(e.smoothing,.9),i=qe(e.mode,`rotate`),a=0,o=0;return{update(e,s){let c=B(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)}}},Vt=(e,t)=>{let n=L(e.height,.2),r=L(e.tilt,10)*U,i=0,a=0,o=0;return{update(e,s){let c=B(.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}}},Ht=(e,t)=>{let n=L(e.scale,1.15),r=L(e.smoothing,.8),i=1;return{update(e,a){i+=((t.hovered()?n:1)-i)*B(r,a),t.object.scale.multiplyScalar(i)}}},Ut=(e,t)=>{let n=L(e.smoothing,.85),r=V(e.lockY,!1),i=Array.isArray(e.point)&&e.point.length===3?new h(...e.point):null,a=typeof e.target==`string`?e.target:`camera`,o=new T,s=new T,c=new h,l=new h,u=new P,d=new T,f=!0;return{update(e,m){let g=i??(a===`camera`?t.camera:t.find?.(a));g&&(g instanceof h?l.copy(g):g.getWorldPosition(l),t.object.getWorldPosition(c),r&&(l.y=c.y),l.distanceToSquared(c)<1e-10||(u.lookAt(l,c,p.DEFAULT_UP),o.setFromRotationMatrix(u),t.object.parent&&o.premultiply(t.object.parent.getWorldQuaternion(d).invert()),s.slerp(o,f?1:B(n,m)),f=!1,t.object.quaternion.copy(s)))}}},Wt=(e,t)=>{let n=L(e.maxAngle,35)*U,r=L(e.smoothing,.85),i=0,a=0;return{update(e,o){let s=B(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}}},Gt=(e,t)=>{let n=Math.max(L(e.radius,.25),.001),r=L(e.strength,.4),i=new h,a=new h,o=new h,s=new h,c=new h;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,B(.85,l)),t.object.position.add(i)}}},Kt=(e,t)=>{let[n,r,i]=z(e.amplitude,[.1,.1,.05]),[a,o,s]=z(e.rotation,[3,3,2]),c=L(e.speed,.3),l=L(e.seed,1)*13.37+t.rng.next()*100,u=(e,t)=>Je(e*c+l,t*5.17)*.8+Je(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*U,t.object.rotation.y+=u(e,4)*o*U,t.object.rotation.z+=u(e,5)*s*U}}},qt=(e,t)=>{let n=new h(...z(e.center,[0,0,0])),r=L(e.radius,2),i=L(e.speed,30)*U,a=L(e.phase,0)*U,o=G(e.axis),s=V(e.faceDirection,!1),c=Math.abs(o.y)<.99?new h(0,1,0):new h(1,0,0),l=new h().crossVectors(c,o).normalize(),u=new h().crossVectors(o,l).normalize(),d=new h;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 h(0,0,1),e.normalize());t.object.quaternion.premultiply(n)}}}},Jt=(e,t)=>{let n=L(e.depth,.5),r=L(e.pointer,.3),i=L(e.scroll,0),a=L(e.smoothing,.9),o=0,s=0;return{update(e,c){let l=B(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}}},Yt=(e,t)=>{let n=(Array.isArray(e.points)?e.points:[]).filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new h(e[0],e[1],e[2])),r=V(e.loop,!0),i=V(e.faceDirection,!0),a=Math.max(L(e.duration,5),.001);if(n.length<2)return{update(){}};let o=new te(n,r,`catmullrom`,.5),s=new h,c=new h(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))}}},Xt=(e,t)=>{let n=L(e.amount,.08),r=L(e.speed,1);return{update:e=>void t.object.scale.multiplyScalar(1+n*Math.sin(K*r*e))}},Zt=(e,t)=>{let n=G(e.axis),r=L(e.speed,45)*U;return{update:e=>void t.object.rotateOnAxis(n,r*e)}},Qt=(e,t)=>{let[n,r,i]=z(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}}},$t=(e,t)=>{let n=G(e.axis),r=L(e.degrees,360)*U;return{update:()=>void t.object.rotateOnAxis(n,r*t.scroll())}},en=(e,t)=>{let n=G(e.axis),r=Math.max(L(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 c=(e-a)/r;c>=1||t.object.rotateOnAxis(n,K*I(`inOutCubic`,c))}}};function tn(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 nn={rotate:Zt,float:zt,bob:vt,pulse:Xt,wobble:(e,t)=>{let n=L(e.amount,.08),r=L(e.speed,2);return{update(e){let i=Math.sin(K*r*e*.5),a=Math.sin(K*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=G(e.axis,[0,0,1]),r=L(e.angle,8)*U,i=L(e.speed,.5);return{update:e=>void t.object.rotateOnAxis(n,r*Math.sin(K*i*e))}},orbit:qt,path:Yt,followPointer:Bt,lookAtPointer:Wt,hoverScale:Ht,hoverLift:Vt,clickBounce:yt,spinOnClick:en,scrollRotate:$t,scrollMove:Qt,drift:It,blink:gt,colorCycle:Ft,flicker:Rt,billboard:ht,appear:mt,magnet:Gt,spring:(e,t)=>{let n=L(e.strength,.4),r=Math.max(L(e.stiffness,120),1),i=Math.max(L(e.damping,12),0),a=Math.max(L(e.mass,1),.01),o=qe(e.mode,`move`),s=L(e.angle,15)*U,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]=tn(c.x,c.vx,u,l,r,i,a),[c.y,c.vy]=tn(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:Jt,tilt:(e,t)=>{let n=L(e.maxAngle,12)*U,r=L(e.scale,1.04),i=L(e.lift,.1),a=L(e.smoothing,.86),o=V(e.hoverOnly,!0),s=V(e.reverse,!1)?-1:1,c=0,l=0,u=0;return{update(e,d){let f=o?t.hovered():t.pointer.inside,p=B(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:_t,noise:Kt,lookAt:Ut},rn=/* @__PURE__ */ new Set([`appear`]),an=1e6,on=/* @__PURE__ */ new Set([`billboard`,`lookAt`]),sn=/* @__PURE__ */ new Set([`lookAt`,`magnet`,`spring`]),cn=1/30;function ln(e,t,n=cn){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 un(e,t,n,r={}){let i=t(e,n),a=e.when??`always`,o=L(e.delay,0),s=0,c=-1;return{def:e,late:on.has(e.type),stateful:sn.has(e.type),step(t,l){if(r.settled?.()&&rn.has(e.type)&&(a===`always`||a===`visible`)){i.update(an,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 dn={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},fn={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`}},pn={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},mn=`
|
|
2
2
|
uniform float uTime; uniform vec3 uArea; uniform vec3 uVel; uniform float uSpread; uniform float uLife;
|
|
3
3
|
uniform float uWander; uniform float uSize; uniform float uViewport; uniform float uTwinkle; uniform float uSpin; uniform float uOpacity;
|
|
4
4
|
uniform vec3 uGravity; uniform vec3 uEndColor; uniform float uUseEnd; uniform float uEndSize; uniform float uStretch; uniform float uSwirl;
|
|
@@ -351,7 +351,7 @@ varying vec4 vShadowClip;
|
|
|
351
351
|
\t\tfloat edge = 1.0 - max(abs(ndc.x), abs(ndc.y));
|
|
352
352
|
\t\tgl_FragColor.a *= (1.0 - smoothstep(${zr.radial[0].toFixed(2)}, ${zr.radial[1].toFixed(2)}, length(vShadowUv - 0.5))) * smoothstep(0.0, ${zr.screenEdge.toFixed(2)}, edge);
|
|
353
353
|
\t}
|
|
354
|
-
\t#include <tonemapping_fragment>`)},n.customProgramCacheKey=()=>`agent3d-shadow-catcher`,n}var Vr=.45;function Hr(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 Ur(e,n,r,i,a){let o=[],s=[],c=a.renderer,l=e.background,d=!!r.isOrthographicCamera,f=null,p=0,m=null,g=null,_=null;n.background=null,n.backgroundIntensity=1,n.backgroundRotation.set(0,0,0),n.environmentRotation.set(0,0,0);let v=l&&typeof l==`object`?l:null,x=v&&`sky`in v?v.sky??{}:null;if(x&&xr(x))try{m=await kr(x)}catch(e){a.issue(`asset-load`,e.message,`environment.background.sky`)}if(!i&&l!==void 0&&l!==`transparent`){if(typeof l==`string`)n.background=R(l);else if(`gradient`in l)n.background=Ar(l.gradient,`linear`,L(l.angle,0),{grain:l.grain});else if(`radial`in l)n.background=Ar(l.radial,`radial`,0,{center:l.center,radius:l.radius,grain:l.grain});else if(`meshGradient`in l)_=l.meshGradient,o.push(jr(l.meshGradient,l,a));else if(`sky`in l){let e=l.sky??{};if(m){if(!d){o.push(m.mesh);let e=m;a.onUpdate(t=>e.setTime(t))}}else g=e,d?n.background=Ar([e.bottom??e.horizon??`#e8eef5`,e.horizon??`#cfe6ff`,e.top??`#2f6fd6`],`linear`,0):o.push(Pr(e,a))}else if(`hdri`in l)try{if(f=await Lr(a.resolveAsset(l.hdri)),p=L(l.rotation,0)*U,n.backgroundRotation.set(0,p,0),n.backgroundIntensity=L(l.intensity,1),s.push(f),l.groundProjection&&!d){let t=typeof l.groundProjection==`object`?l.groundProjection:{},{GroundedSkybox:r}=await import(`./chunks/GroundedSkybox-g1ASZWNu.js`),i=L(t.height,2),a=L(t.radius,60),s=new r(f,i,a);s.position.y=i-.01+L(e.ground?.y,0),s.rotation.y=p,s.material.color.setScalar(n.backgroundIntensity),s.name=`__groundProjection`,s.userData.helper=!0,s.renderOrder=-999,o.push(s),n.background=R(`#000000`)}else n.background=f,n.backgroundBlurriness=L(l.blur,0)}catch(e){a.issue(`asset-load`,e.message,`environment.background.hdri`)}n.background instanceof re&&n.background!==f&&s.push(n.background)}n.fog=null,rr(n,null);let S=null;e.fog&&(S=R(Hr(e,m?.values.haze)),!e.fog.color&&m&&S.multiplyScalar(.82),`density`in e.fog?(n.fog=new y(S,e.fog.density),e.fog.height!==void 0&&rr(n,{uA3dFogHeight:{value:e.fog.height},uA3dFogFalloff:{value:L(e.fog.falloff,.25)}})):n.fog=new u(S,L(e.fog.near,10),L(e.fog.far,60)),m?.setHaze(S,.85));let C=f?{hdri:``}:m?`sky`:`soft`,w=e.lighting??C;if(n.environment=null,n.environmentIntensity=L(e.lightingIntensity,1),c&&w!==`none`){let t=new xe(c),r=null;try{if(typeof w==`object`){let e=w.hdri?await Lr(a.resolveAsset(w.hdri)):f;e&&(r=t.fromEquirectangular(e)),w.intensity!==void 0&&(n.environmentIntensity=w.intensity),n.environmentRotation.set(0,w.hdri?L(w.rotation,0)*U:w.rotation===void 0?p:w.rotation*U,0),e&&e!==f&&e.dispose()}else if(w===`sky`){if(m){let e=m.envScene();r=t.fromScene(e,0,.1,100),Ir(e)}else if(g){let e=g,n=e.sun===!1?void 0:e.sun,i=Fr(e.top??`#2f6fd6`,e.horizon??`#cfe6ff`,e.bottom??e.horizon??`#e8eef5`,n?{dir:new h(...z(n.direction,[.4,.35,-1])),color:n.color??`#fff2d6`,power:4,size:.9}:void 0,!1);r=t.fromScene(i,.02),Ir(i)}else if(_){let e=_,n=Fr(e[1]??e[0],e[0],e[2]??e[0],void 0,!0);r=t.fromScene(n,.04),Ir(n)}else{let{RoomEnvironment:e}=await import(`./chunks/RoomEnvironment-CXgfLJdO.js`),n=new e;r=t.fromScene(n,.06),n.dispose?.()}}else if(w===`studio`||w===`soft`){let{RoomEnvironment:i}=await import(`./chunks/RoomEnvironment-CXgfLJdO.js`),a=new i;r=t.fromScene(a,w===`soft`?.06:.02),w===`soft`&&e.lightingIntensity===void 0&&(n.environmentIntensity=.8),a.dispose?.()}else{let e={neutral:[`#d8d8dc`,`#b9b9bd`,`#5a5a60`],sunset:[`#33306e`,`#ff9a5a`,`#3a2531`,{dir:new h(1,.15,-.6),color:`#ffb36b`,power:6,size:1.6}],night:[`#060a1a`,`#1d2a55`,`#05060c`,{dir:new h(-.5,.7,-.5),color:`#cfdcff`,power:3,size:.8}]},n=Fr(...e[w]??e.neutral);r=t.fromScene(n,.03),Ir(n)}}catch(e){a.issue(`asset-load`,e.message,`environment.lighting`)}r&&(n.environment=r.texture,s.push(r),d&&m&&!i&&(n.background=r.texture,n.backgroundBlurriness=0)),t.dispose();let o=e.lightingIntensity!==void 0||typeof w==`object`&&w.intensity!==void 0;e.rig&&!o&&(n.environmentIntensity*=Vr)}let T=[],E=x&&x.sun!==!1?x.sun??{}:null;if(m&&E&&E.light!==!1){let n=Tr(m.values.elevation),r=new t(E.color?R(E.color):n.color,L(E.intensity,n.intensity));r.position.copy(m.sunDir).multiplyScalar(30),r.name=`__sun`,r.userData.a3dId=`sun`,E.castShadow!==!1&&r.intensity>0&&lr(r,{type:`directional`,shadow:{softness:3}},e.shadows),T.push(r)}for(let t of yr(e.rig)){let n=await mr(t,e.shadows);T.push(n)}for(let e of T)o.push(e),(e instanceof t||e instanceof M)&&o.push(e.target);let D;if(e.ground){let t=e.ground,n=L(t.size,60),r=L(t.y,0),i=t.shadowOnly?Br(R(t.color??`#000000`),L(t.opacity,.28)):Rr(R(t.color??`#d9d9d9`),L(t.roughness,.9));!t.shadowOnly&&t.opacity!==void 0&&(i.opacity=t.opacity);let a=new F(new b(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),D=a,t.grid){let e=new ee(n,Math.round(n),R(`#000000`),R(`#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 t=qn(e.contactShadows,n,e.ground?L(e.ground.y,0):void 0,a);t&&(o.push(t.object),s.push(t))}return{objects:o,ground:D,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 Wr(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>new f(Number(e[0]),Number(e[1]))):[]}function Gr(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new h(Number(e[0]),Number(e[1]),Number(e[2]))):[]}var X=(e,t=`segments`,n=32)=>Math.max(3,Math.round(L(e[t],n))),Kr={box:e=>new se(L(e.width,1),L(e.height,1),L(e.depth,1)),roundedBox:e=>{let t=L(e.width,1),n=L(e.height,1),r=L(e.depth,1),i=Math.min(L(e.radius,.1),Math.min(t,n,r)/2-1e-4);return new et(t,n,r,Math.max(1,Math.round(L(e.segments,4))),Math.max(0,i))},sphere:e=>new ce(L(e.radius,.5),X(e),Math.max(2,Math.round(L(e.heightSegments,24)))),cylinder:e=>new Ce(L(e.radiusTop,.5),L(e.radiusBottom,.5),L(e.height,1),X(e),1,V(e.openEnded,!1)),cone:e=>new x(L(e.radius,.5),L(e.height,1),X(e)),capsule:e=>{let t=Math.max(2,Math.round(L(e.segments,16)));return new le(L(e.radius,.3),L(e.length,.6),Math.max(2,Math.round(t/2)),t*2)},torus:e=>new S(L(e.radius,.5),L(e.tube,.15),Math.max(2,Math.round(L(e.radialSegments,24))),Math.max(3,Math.round(L(e.tubularSegments,64))),L(e.arc,360)*U),torusKnot:e=>new r(L(e.radius,.5),L(e.tube,.15),Math.round(L(e.tubularSegments,128)),Math.round(L(e.radialSegments,16)),Math.round(L(e.p,2)),Math.round(L(e.q,3))),plane:e=>new b(L(e.width,1),L(e.height,1),Math.max(1,Math.round(L(e.widthSegments,1))),Math.max(1,Math.round(L(e.heightSegments,1)))),circle:e=>new Se(L(e.radius,.5),X(e)),ring:t=>new e(L(t.innerRadius,.3),L(t.outerRadius,.5),X(t)),icosahedron:e=>new a(L(e.radius,.5),Math.round(L(e.detail,0))),dodecahedron:e=>new pe(L(e.radius,.5),Math.round(L(e.detail,0))),octahedron:e=>new g(L(e.radius,.5),Math.round(L(e.detail,0))),tetrahedron:e=>new Te(L(e.radius,.5),Math.round(L(e.detail,0))),lathe:e=>{let t=Wr(e.points);return t.length<2&&(t=[new f(.5,-.5),new f(.5,.5)]),new oe(t,X(e))},extrude:e=>{let t=Wr(e.shape);t.length<3&&(t=[new f(-.5,-.5),new f(.5,-.5),new f(0,.5)]);let n=new ne(t),r=L(e.depth,.2),i=L(e.bevel,.02),a=new m(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=Gr(e.points);t.length<2&&(t=[new h(-1,0,0),new h(1,0,0)]);let n=new te(t,V(e.closed,!1),`catmullrom`,.5);return new C(n,Math.max(2,Math.round(L(e.tubularSegments,64))),L(e.radius,.05),Math.max(3,Math.round(L(e.radialSegments,8))),V(e.closed,!1))}};function qr(e){let t=Kr[e.type]??Kr.box,n=Be.find(t=>t.id===e.type),r=t(We(n,e));return r.computeBoundingBox(),r.computeBoundingSphere(),r}function Jr(e,t){let n=[],r=(e,t=new d,r=new h(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 h((e-(t-1)/2)*a,(c-(n-1)/2)*o,(l-(i-1)/2)*s));break}case`scatter`:{let n=L(e.minScale,1),i=L(e.maxScale,1),[a,o,s]=e.area;for(let c=0;c<Math.max(0,Math.round(e.count));c++){let c=new h(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 h(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 h(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 h(...e),new d(n[0]*U,n[1]*U,n[2]*U),typeof i==`number`?new h(i,i,i):new h(...i))}}return n}function Yr(e,t,n,r,i){let a=Jr(e.layout,r),o=new l(t,n,Math.max(1,a.length));o.count=a.length;let s=new P,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 Xr(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 Zr(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)*U,(t.rotation[1]??0)*U,(t.rotation[2]??0)*U),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 Qr=/* @__PURE__ */ new Set([`hoverScale`,`hoverLift`,`clickBounce`,`spinOnClick`]),$r=class e{def;ctx;scene=new ge;camera;rig;env=null;entries=/* @__PURE__ */ new Map;timeline=null;settleEntrances=!1;updaters=[];cameraRest0={position:new h,target:new h,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:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ 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=Ln(r.camera,e),this.rig=await Hn(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=Ur(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=/* @__PURE__ */ new Map,c=r.objects??[],l=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,l(e),void 0,s))),ei(s,c),await Promise.all(c.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(e=>this.addObject(e,l(e),void 0,s)));let u=new Map(c.map((e,t)=>[e.id,t]));this.scene.children.sort((e,t)=>(u.get(e.userData.a3dId)??-1)-(u.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=Ie(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,issue:i.issue,seed:r.seed??1},this.overrides=new An(this.motionHost),this.shots=Fn(r.camera?.shots),r.timeline){this.timeline=On(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=/* @__PURE__ */ 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=Ae(t),i=r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map,a=await ke(t,n,{vertexColors:i}),o=[];e.traverse(e=>{e.isMesh&&e.userData.materialTarget&&o.push(e)});for(let e of o)e.material.dispose(),e.material=a,Oe(a,e.geometry)}rngFor(e,t){return Xe(t??Ye(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=nn[n.type];t?(e.runners.push(un(n,t,this.behaviourContext(e),{settled:()=>this.settleEntrances})),(Qr.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,n){let r=await mr(e,this.def.environment?.shadows),i=e.id??`light${n}`;this.scene.add(r),(r instanceof t||r instanceof M)&&this.scene.add(r.target),r.userData.a3dId=i;let a={id:i,kind:`light`,def:e,object:r,rest:Xr(r),runners:[],animated:!1,topLevel:!1,interactive:!1};this.entries.set(i,a),this.attachBehaviours(a)}async addObject(e,t,n,r){let i=this.ctx,a,s,c,l,u=[],d=e.kind!==`particles`&&e.kind!==`generator`;try{switch(e.kind){case`mesh`:{let t=qr(e.geometry),n=await ke(e.material,i,{defaultColor:`#dddddd`});Oe(n,t),a=new F(t,n);break}case`text`:{let{buildText:t}=await import(`./chunks/text-D1EQpdSU.js`),n=await i.track(t(e,i));a=n.object,u=n.letters;break}case`svg`:{let{buildSvg:t}=await import(`./chunks/svg-CmlFY_8O.js`);a=await i.track(t(e,i));break}case`model`:{let{buildModel:t}=await import(`./chunks/model-BCVF3QzB.js`),n=await i.track(t(e,i));a=n.object,c=n.animator;break}case`instances`:{let t=qr(e.geometry),n=await ke(e.material,i,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});Oe(n,t),a=Yr(e,t,n,this.rngFor(e.id,e.layout.seed),e=>R(e));break}case`particles`:{l=_n(e,this.rngFor(e.id,e.seed)),l.setViewport(this.viewportH),a=l.points;let t=l;this.updaters.push(e=>t.update(e));break}case`generator`:{let t=(await i.generators())[e.generator];if(!t){i.issue(`unknown-catalog-id`,`Unknown generator "${e.generator}"`,`objects#${e.id}.generator`),a=new o;break}let n=Ve.find(t=>t.id===e.generator),c=We(n,e.params??{}),l=e.scale,u={position:[...e.position??[0,0,0]],scale:typeof l==`number`?[l,l,l]:l?[...l]:[1,1,1]},d={...i,siblings:r,rng:this.rngFor(e.id,e.seed),placement:u};if(s=await i.track(Promise.resolve(t(c,d))),a=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(a,e.material,i);break}default:a=new o}}catch(t){i.issue(e.kind===`model`||e.kind===`text`||e.kind===`svg`?`asset-load`:`build-error`,`${e.id}: ${t.message}`,`objects#${e.id}`),a=new o}if(this.disposed)return null;a.name=e.name??e.id,a.userData={...e.userData??{},...a.userData,a3dId:e.id,tags:e.tags??[]},Zr(a,e),e.visible===!1&&(a.visible=!1);let f=e.castShadow??(d?!0:void 0),p=e.receiveShadow??(d?!0:void 0);(f!==void 0||p!==void 0)&&a.traverse(e=>{e.isMesh&&(f!==void 0&&(e.castShadow=f),p!==void 0&&(e.receiveShadow=p))}),t.add(a);let m={id:e.id,kind:e.kind,def:e,object:a,rest:Xr(a),runners:[],animated:!1,topLevel:t===this.scene||t===this.camera&&!n,parentId:n,built:s,animator:c,particles:l,interactive:!!e.href};this.entries.set(e.id,m),this.attachBehaviours(m);for(let t of u){let n={id:t.id,kind:`text`,def:t.def,object:t.object,rest:Xr(t.object),runners:[],animated:!0,topLevel:!1,parentId:e.id,interactive:!1};t.reveal&&n.runners.push(un(t.reveal.def,t.reveal.impl,this.behaviourContext(n),{settled:()=>this.settleEntrances})),this.entries.set(t.id,n)}if(e.children?.length){let t=/* @__PURE__ */ new Map,n=e.children;await Promise.all(n.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(n=>this.addObject(n,a,e.id,t))),ei(t,n),await Promise.all(n.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(n=>this.addObject(n,a,e.id,t)))}return m}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 En(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 h):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(n=>{n instanceof t&&n.castShadow&&e.push(n)}),!e.length)return;let n=new j,r=new j;this.scene.updateMatrixWorld(!0);for(let e of this.entries.values())e.topLevel&&e.kind!==`particles`&&e.def.attach!==`camera`&&(r.setFromObject(e.object),r.isEmpty()||r.getSize(new h).length()>200||n.union(r));n.isEmpty()&&n.set(new h(-5,-1,-5),new h(5,5,5));let i=this.env?.ground?this.env.ground.position.y:n.min.y;n.expandByPoint(new h(n.min.x,i,n.min.z)),n.expandByPoint(new h(n.max.x,i,n.max.z)),n.expandByScalar(.3);for(let t of e)hr(t,n)}setViewport(e,t,n){this.viewportH=t*n;let r=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(this.def.target?.aspect??``),i=r?Number(r[1])/Number(r[2]):void 0;Bn(this.camera,this.def.camera,e/Math.max(t,1),i&&Number.isFinite(i)&&i>0?i:void 0);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=In(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.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 O;pointerOnPlane(e,t,n){e.updateWorldMatrix(!0,!1),this.camera.updateMatrixWorld(),this.pointerRay.setFromCamera(new f(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(),He(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 ei(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 ti=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`,`PageUp`,`PageDown`,`Home`,`End`]);function ni(){return{pointer:{x:0,y:0,inside:!1,down:!1,justPressed:!1},keys:/* @__PURE__ */ new Set,pressed:/* @__PURE__ */ new Set,swipe:null,clicks:[],scroll:0}}function ri(e){e.pressed.clear(),e.pointer.justPressed=!1,e.swipe=null,e.clicks.length=0}function ii(e,t,n){n?(e.keys.has(t)||e.pressed.add(t),e.keys.add(t)):e.keys.delete(t)}function ai(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)&&(ii(t,e.code,e.type===`keydown`),n.game&&ti.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 oi(e){let t=e.ownerDocument.defaultView;if(!t)return 0;let n=e.getBoundingClientRect(),r=t.innerHeight||1,i=(r-n.top)/(r+n.height);return i<0?0:i>1?1:i}var Z=(e,t,n)=>e<t?t:e>n?n:e;function si(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`&&t&&typeof t[e]==`number`?t[e]:n}function ci(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:Z(si(i.from,e.markers,0),0,n),to:Z(si(i.to,e.markers,n),0,n),loop:i.loop??!1,speed:typeof i.speed==`number`&&i.speed>0?i.speed:1}}function Q(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:bt(Math.max(0,t*e.speed+a),r,e.loop);return e.from+i*o}function li(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=ci(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:Z(t/r,0,1),segment:i,marker:a}}var ui=class{def;hoverClock=0;clickAt=-1;active=null;toggled=/* @__PURE__ */ 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=ci(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=ci(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=Z(si(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?ci(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:Q({...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)*Z(e.scroll,0,1);if(e.deterministic)return Q(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=Z(this.hoverClock,0,n)),Q(t,this.hoverClock)}case`click`:return e.clicked&&(this.clickAt=e.t),this.clickAt<0?t.from:Q(t,e.t-this.clickAt);default:return Q(t,e.t)}}update(e){let t;return t=this.active&&!e.staticMotion?Q(this.active,Math.max(0,e.t-this.active.start),this.active.startLocal):this.autoLocal(e),t=Z(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 li(this.def,this.lastLocal,this.active?.name)}drainMarkers(){let e=this.pending;return this.pending=[],e}};function di(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 fi=/* @__PURE__ */ new Set([`click`,`key`]),pi=class{defs;host;hoverPrev=/* @__PURE__ */ new Set;insidePrev=!1;scrollPrev=null;visibleFired=!1;fired=/* @__PURE__ */ new Set;queue=[];constructor(e,t){this.defs=e,this.host=t}targets(){let e=/* @__PURE__ */ 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&&fi.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})}},mi=`top bottom`,hi=`bottom top`;function gi(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 _i(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==2)return null;let i=gi(r[0],t),a=gi(r[1],n);return i===null||a===null?null:i-a}function vi(e,t,n,r=mi,i=hi){let a=_i(r,t,n)??-n,o=_i(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 yi=8e3;function bi(e,t,n=yi){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 h,s=new P,c=new P,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 xi(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 j,i=new P,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=Ci(n,t,r,e));else r.copy(o).applyMatrix4(n.matrixWorld).containsPoint(t)&&(a=Ci(n,t,r))}),a}var Si=[new h(1,0,0),new h(-1,0,0),new h(0,1,0),new h(0,-1,0),new h(0,0,1),new h(0,0,-1)];function Ci(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 O;return i.far=n.getSize(new h).length()+.001,Si.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 wi={none:0,aces:4,agx:6,neutral:7,reinhard:2};function Ti(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 Ei(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 Di=8,Oi=2e4,$=/* @__PURE__ */ new Set;function ki(e){for(;$.size>=Di;){let t=null;for(let n of $)n!==e&&n.releasable()&&(!t||n.lastSeen<t.lastSeen)&&(t=n);if(!t)return;t.release()}}function Ai(){return $.size}var ji=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=Fe(`high`);qualityAuto=!1;perfClock=0;slowFor=0;renderSamples=1;inputState=ni();inputBinding=null;resolveAsset;deterministic;t=0;tl=null;interactions=null;eventListeners=/* @__PURE__ */ 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=/* @__PURE__ */ new Set;resizeObs=null;interObs=null;readyResolve;readyReject;raycaster=new O;width=1;height=1;lastStats={triangles:0,drawCalls:0,geometries:0,textures:0};onVisibility=()=>this.updateRunning();editor;overlay=null;worldListeners=/* @__PURE__ */ new Set;constructor(e,t,n){this.container=e,this.options=n,this.scene=t,this.deterministic=!!n.deterministic,this.resolveAsset=Me(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){ii(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=ai(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(),Oi)),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 de({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=ae,e.toneMapping=wi[t.toneMapping??`aces`]??4,e.toneMappingExposure=t.exposure??1,this.quality=Fe(Le(t.quality,this.deviceHints(e))),this.qualityAuto=(t.quality??`auto`)===`auto`&&!this.deterministic&&!this.options.editor,this.perfClock=this.slowFor=0;let n=this.options.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,this.quality.dprCap);e.setPixelRatio(n);let r=cr(this.scene);if(e.shadowMap.enabled=r.enabled,e.shadowMap.type=r.type,t.transparent)e.setClearColor(0,0);else{let t=this.scene.environment?.background;e.setClearColor(typeof t==`string`&&t!==`transparent`?R(t):new k(0),1)}}start(){if(!(this.started||this.disposed)){if(this.started=!0,ki(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(/* @__PURE__ */ 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:Xe(this.scene.seed??1),siblings:/* @__PURE__ */ new Map,color:e=>R(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:dt,generators:ft}}async buildWorld(){let e=[],t=this.makeContext(e),n=await $r.create(W(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),Ti(this.scene)){let{GameHost:t}=await import(`./chunks/game-BoEiyZrL.js`);this.game=await t.create({scene:W(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 ui(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 pi(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=/* @__PURE__ */ 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=/* @__PURE__ */ 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=this.container.getBoundingClientRect(),i=vi(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 oi(this.container)}openUrl(e,t){let n=this.container.ownerDocument.defaultView,r=n?di(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=/* @__PURE__ */ 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 f(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=/* @__PURE__ */ 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=/* @__PURE__ */ 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(),ri(n),this.handledClicks=0,this.handledKeys.clear()}navigate(e){let t=this.container.ownerDocument.defaultView;if(!t)return;let n=di(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 h),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&&!Ti(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:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ 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 ln(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:/* @__PURE__ */ 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/Ei(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 Ee().setFromProjectionMatrix(new P().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),i=t.getWorldPosition(new h),a=new j,o=new h,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=bi(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`||xi(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 r=this.renderer,i=this.world;if(!r||!i)return this.canvas.toDataURL(t,n);let a=Math.max(1,Math.min(64,Math.round(e))),o=null;if(!this.postfx){let{createPostFx:e}=await import(`./chunks/postfx-UgKCbmZs.js`);o=e([],{renderer:r,scene:i.scene,camera:i.camera,width:this.width,height:this.height,quality:Fe(`ultra`),antialias:this.scene.target?.antialias!==!1},()=>void 0)}let s=this.postfx??o;try{return s.render(this.t,{samples:a}),this.canvas.toDataURL(t,n)}finally{o?.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 import(`./chunks/postfx-UgKCbmZs.js`);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=Re(this.quality.tier);n?(this.quality=Fe(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 Mi(e,t,n={}){let r=new ji(e,t,n);return r.canvas.isConnected&&r.resize(),r}var Ni=typeof HTMLElement<`u`?HTMLElement:class{},Pi=`
|
|
354
|
+
\t#include <tonemapping_fragment>`)},n.customProgramCacheKey=()=>`agent3d-shadow-catcher`,n}var Vr=.45;function Hr(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 Ur(e,n,r,i,a){let o=[],s=[],c=a.renderer,l=e.background,d=!!r.isOrthographicCamera,f=null,p=0,m=null,g=null,_=null;n.background=null,n.backgroundIntensity=1,n.backgroundRotation.set(0,0,0),n.environmentRotation.set(0,0,0);let v=l&&typeof l==`object`?l:null,x=v&&`sky`in v?v.sky??{}:null;if(x&&xr(x))try{m=await kr(x)}catch(e){a.issue(`asset-load`,e.message,`environment.background.sky`)}if(!i&&l!==void 0&&l!==`transparent`){if(typeof l==`string`)n.background=R(l);else if(`gradient`in l)n.background=Ar(l.gradient,`linear`,L(l.angle,0),{grain:l.grain});else if(`radial`in l)n.background=Ar(l.radial,`radial`,0,{center:l.center,radius:l.radius,grain:l.grain});else if(`meshGradient`in l)_=l.meshGradient,o.push(jr(l.meshGradient,l,a));else if(`sky`in l){let e=l.sky??{};if(m){if(!d){o.push(m.mesh);let e=m;a.onUpdate(t=>e.setTime(t))}}else g=e,d?n.background=Ar([e.bottom??e.horizon??`#e8eef5`,e.horizon??`#cfe6ff`,e.top??`#2f6fd6`],`linear`,0):o.push(Pr(e,a))}else if(`hdri`in l)try{if(f=await Lr(a.resolveAsset(l.hdri)),p=L(l.rotation,0)*U,n.backgroundRotation.set(0,p,0),n.backgroundIntensity=L(l.intensity,1),s.push(f),l.groundProjection&&!d){let t=typeof l.groundProjection==`object`?l.groundProjection:{},{GroundedSkybox:r}=await import(`./chunks/GroundedSkybox-g1ASZWNu.js`),i=L(t.height,2),a=L(t.radius,60),s=new r(f,i,a);s.position.y=i-.01+L(e.ground?.y,0),s.rotation.y=p,s.material.color.setScalar(n.backgroundIntensity),s.name=`__groundProjection`,s.userData.helper=!0,s.renderOrder=-999,o.push(s),n.background=R(`#000000`)}else n.background=f,n.backgroundBlurriness=L(l.blur,0)}catch(e){a.issue(`asset-load`,e.message,`environment.background.hdri`)}n.background instanceof re&&n.background!==f&&s.push(n.background)}n.fog=null,rr(n,null);let S=null;e.fog&&(S=R(Hr(e,m?.values.haze)),!e.fog.color&&m&&S.multiplyScalar(.82),`density`in e.fog?(n.fog=new y(S,e.fog.density),e.fog.height!==void 0&&rr(n,{uA3dFogHeight:{value:e.fog.height},uA3dFogFalloff:{value:L(e.fog.falloff,.25)}})):n.fog=new u(S,L(e.fog.near,10),L(e.fog.far,60)),m?.setHaze(S,.85));let C=f?{hdri:``}:m?`sky`:`soft`,w=e.lighting??C;if(n.environment=null,n.environmentIntensity=L(e.lightingIntensity,1),c&&w!==`none`){let t=new xe(c),r=null;try{if(typeof w==`object`){let e=w.hdri?await Lr(a.resolveAsset(w.hdri)):f;e&&(r=t.fromEquirectangular(e)),w.intensity!==void 0&&(n.environmentIntensity=w.intensity),n.environmentRotation.set(0,w.hdri?L(w.rotation,0)*U:w.rotation===void 0?p:w.rotation*U,0),e&&e!==f&&e.dispose()}else if(w===`sky`){if(m){let e=m.envScene();r=t.fromScene(e,0,.1,100),Ir(e)}else if(g){let e=g,n=e.sun===!1?void 0:e.sun,i=Fr(e.top??`#2f6fd6`,e.horizon??`#cfe6ff`,e.bottom??e.horizon??`#e8eef5`,n?{dir:new h(...z(n.direction,[.4,.35,-1])),color:n.color??`#fff2d6`,power:4,size:.9}:void 0,!1);r=t.fromScene(i,.02),Ir(i)}else if(_){let e=_,n=Fr(e[1]??e[0],e[0],e[2]??e[0],void 0,!0);r=t.fromScene(n,.04),Ir(n)}else{let{RoomEnvironment:e}=await import(`./chunks/RoomEnvironment-CXgfLJdO.js`),n=new e;r=t.fromScene(n,.06),n.dispose?.()}}else if(w===`studio`||w===`soft`){let{RoomEnvironment:i}=await import(`./chunks/RoomEnvironment-CXgfLJdO.js`),a=new i;r=t.fromScene(a,w===`soft`?.06:.02),w===`soft`&&e.lightingIntensity===void 0&&(n.environmentIntensity=.8),a.dispose?.()}else{let e={neutral:[`#d8d8dc`,`#b9b9bd`,`#5a5a60`],sunset:[`#33306e`,`#ff9a5a`,`#3a2531`,{dir:new h(1,.15,-.6),color:`#ffb36b`,power:6,size:1.6}],night:[`#060a1a`,`#1d2a55`,`#05060c`,{dir:new h(-.5,.7,-.5),color:`#cfdcff`,power:3,size:.8}]},n=Fr(...e[w]??e.neutral);r=t.fromScene(n,.03),Ir(n)}}catch(e){a.issue(`asset-load`,e.message,`environment.lighting`)}r&&(n.environment=r.texture,s.push(r),d&&m&&!i&&(n.background=r.texture,n.backgroundBlurriness=0)),t.dispose();let o=e.lightingIntensity!==void 0||typeof w==`object`&&w.intensity!==void 0;e.rig&&!o&&(n.environmentIntensity*=Vr)}let T=[],E=x&&x.sun!==!1?x.sun??{}:null;if(m&&E&&E.light!==!1){let n=Tr(m.values.elevation),r=new t(E.color?R(E.color):n.color,L(E.intensity,n.intensity));r.position.copy(m.sunDir).multiplyScalar(30),r.name=`__sun`,r.userData.a3dId=`sun`,E.castShadow!==!1&&r.intensity>0&&lr(r,{type:`directional`,shadow:{softness:3}},e.shadows),T.push(r)}for(let t of yr(e.rig)){let n=await mr(t,e.shadows);T.push(n)}for(let e of T)o.push(e),(e instanceof t||e instanceof M)&&o.push(e.target);let D;if(e.ground){let t=e.ground,n=L(t.size,60),r=L(t.y,0),i=t.shadowOnly?Br(R(t.color??`#000000`),L(t.opacity,.28)):Rr(R(t.color??`#d9d9d9`),L(t.roughness,.9));!t.shadowOnly&&t.opacity!==void 0&&(i.opacity=t.opacity);let a=new F(new b(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),D=a,t.grid){let e=new ee(n,Math.round(n),R(`#000000`),R(`#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 t=qn(e.contactShadows,n,e.ground?L(e.ground.y,0):void 0,a);t&&(o.push(t.object),s.push(t))}return{objects:o,ground:D,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 Wr(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>new f(Number(e[0]),Number(e[1]))):[]}function Gr(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new h(Number(e[0]),Number(e[1]),Number(e[2]))):[]}var X=(e,t=`segments`,n=32)=>Math.max(3,Math.round(L(e[t],n))),Kr={box:e=>new se(L(e.width,1),L(e.height,1),L(e.depth,1)),roundedBox:e=>{let t=L(e.width,1),n=L(e.height,1),r=L(e.depth,1),i=Math.min(L(e.radius,.1),Math.min(t,n,r)/2-1e-4);return new et(t,n,r,Math.max(1,Math.round(L(e.segments,4))),Math.max(0,i))},sphere:e=>new ce(L(e.radius,.5),X(e),Math.max(2,Math.round(L(e.heightSegments,24)))),cylinder:e=>new Ce(L(e.radiusTop,.5),L(e.radiusBottom,.5),L(e.height,1),X(e),1,V(e.openEnded,!1)),cone:e=>new x(L(e.radius,.5),L(e.height,1),X(e)),capsule:e=>{let t=Math.max(2,Math.round(L(e.segments,16)));return new le(L(e.radius,.3),L(e.length,.6),Math.max(2,Math.round(t/2)),t*2)},torus:e=>new S(L(e.radius,.5),L(e.tube,.15),Math.max(2,Math.round(L(e.radialSegments,24))),Math.max(3,Math.round(L(e.tubularSegments,64))),L(e.arc,360)*U),torusKnot:e=>new r(L(e.radius,.5),L(e.tube,.15),Math.round(L(e.tubularSegments,128)),Math.round(L(e.radialSegments,16)),Math.round(L(e.p,2)),Math.round(L(e.q,3))),plane:e=>new b(L(e.width,1),L(e.height,1),Math.max(1,Math.round(L(e.widthSegments,1))),Math.max(1,Math.round(L(e.heightSegments,1)))),circle:e=>new Se(L(e.radius,.5),X(e)),ring:t=>new e(L(t.innerRadius,.3),L(t.outerRadius,.5),X(t)),icosahedron:e=>new a(L(e.radius,.5),Math.round(L(e.detail,0))),dodecahedron:e=>new pe(L(e.radius,.5),Math.round(L(e.detail,0))),octahedron:e=>new g(L(e.radius,.5),Math.round(L(e.detail,0))),tetrahedron:e=>new Te(L(e.radius,.5),Math.round(L(e.detail,0))),lathe:e=>{let t=Wr(e.points);return t.length<2&&(t=[new f(.5,-.5),new f(.5,.5)]),new oe(t,X(e))},extrude:e=>{let t=Wr(e.shape);t.length<3&&(t=[new f(-.5,-.5),new f(.5,-.5),new f(0,.5)]);let n=new ne(t),r=L(e.depth,.2),i=L(e.bevel,.02),a=new m(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=Gr(e.points);t.length<2&&(t=[new h(-1,0,0),new h(1,0,0)]);let n=new te(t,V(e.closed,!1),`catmullrom`,.5);return new C(n,Math.max(2,Math.round(L(e.tubularSegments,64))),L(e.radius,.05),Math.max(3,Math.round(L(e.radialSegments,8))),V(e.closed,!1))}};function qr(e){let t=Kr[e.type]??Kr.box,n=Be.find(t=>t.id===e.type),r=t(We(n,e));return r.computeBoundingBox(),r.computeBoundingSphere(),r}function Jr(e,t){let n=[],r=(e,t=new d,r=new h(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 h((e-(t-1)/2)*a,(c-(n-1)/2)*o,(l-(i-1)/2)*s));break}case`scatter`:{let n=L(e.minScale,1),i=L(e.maxScale,1),[a,o,s]=e.area;for(let c=0;c<Math.max(0,Math.round(e.count));c++){let c=new h(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 h(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 h(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 h(...e),new d(n[0]*U,n[1]*U,n[2]*U),typeof i==`number`?new h(i,i,i):new h(...i))}}return n}function Yr(e,t,n,r,i){let a=Jr(e.layout,r),o=new l(t,n,Math.max(1,a.length));o.count=a.length;let s=new P,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 Xr(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 Zr(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)*U,(t.rotation[1]??0)*U,(t.rotation[2]??0)*U),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 Qr=/* @__PURE__ */ new Set([`hoverScale`,`hoverLift`,`clickBounce`,`spinOnClick`]),$r=class e{def;ctx;scene=new ge;camera;rig;env=null;entries=/* @__PURE__ */ new Map;timeline=null;settleEntrances=!1;updaters=[];cameraRest0={position:new h,target:new h,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:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ 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=Ln(r.camera,e),this.rig=await Hn(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=Ur(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=/* @__PURE__ */ new Map,c=r.objects??[],l=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,l(e),void 0,s))),ei(s,c),await Promise.all(c.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(e=>this.addObject(e,l(e),void 0,s)));let u=new Map(c.map((e,t)=>[e.id,t]));this.scene.children.sort((e,t)=>(u.get(e.userData.a3dId)??-1)-(u.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=Ie(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,issue:i.issue,seed:r.seed??1},this.overrides=new An(this.motionHost),this.shots=Fn(r.camera?.shots),r.timeline){this.timeline=On(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=/* @__PURE__ */ 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=Ae(t),i=r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map,a=await ke(t,n,{vertexColors:i}),o=[];e.traverse(e=>{e.isMesh&&e.userData.materialTarget&&o.push(e)});for(let e of o)e.material.dispose(),e.material=a,Oe(a,e.geometry)}rngFor(e,t){return Xe(t??Ye(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=nn[n.type];t?(e.runners.push(un(n,t,this.behaviourContext(e),{settled:()=>this.settleEntrances})),(Qr.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,n){let r=await mr(e,this.def.environment?.shadows),i=e.id??`light${n}`;this.scene.add(r),(r instanceof t||r instanceof M)&&this.scene.add(r.target),r.userData.a3dId=i;let a={id:i,kind:`light`,def:e,object:r,rest:Xr(r),runners:[],animated:!1,topLevel:!1,interactive:!1};this.entries.set(i,a),this.attachBehaviours(a)}async addObject(e,t,n,r){let i=this.ctx,a,s,c,l,u=[],d=e.kind!==`particles`&&e.kind!==`generator`;try{switch(e.kind){case`mesh`:{let t=qr(e.geometry),n=await ke(e.material,i,{defaultColor:`#dddddd`});Oe(n,t),a=new F(t,n);break}case`text`:{let{buildText:t}=await import(`./chunks/text-BaON-ISS.js`),n=await i.track(t(e,i));a=n.object,u=n.letters;break}case`svg`:{let{buildSvg:t}=await import(`./chunks/svg-CfPIQnDG.js`);a=await i.track(t(e,i));break}case`model`:{let{buildModel:t}=await import(`./chunks/model-DbfZaLni.js`),n=await i.track(t(e,i));a=n.object,c=n.animator;break}case`instances`:{let t=qr(e.geometry),n=await ke(e.material,i,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});Oe(n,t),a=Yr(e,t,n,this.rngFor(e.id,e.layout.seed),e=>R(e));break}case`particles`:{l=_n(e,this.rngFor(e.id,e.seed)),l.setViewport(this.viewportH),a=l.points;let t=l;this.updaters.push(e=>t.update(e));break}case`generator`:{let t=(await i.generators())[e.generator];if(!t){i.issue(`unknown-catalog-id`,`Unknown generator "${e.generator}"`,`objects#${e.id}.generator`),a=new o;break}let n=Ve.find(t=>t.id===e.generator),c=We(n,e.params??{}),l=e.scale,u={position:[...e.position??[0,0,0]],scale:typeof l==`number`?[l,l,l]:l?[...l]:[1,1,1]},d={...i,siblings:r,rng:this.rngFor(e.id,e.seed),placement:u};if(s=await i.track(Promise.resolve(t(c,d))),a=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(a,e.material,i);break}default:a=new o}}catch(t){i.issue(e.kind===`model`||e.kind===`text`||e.kind===`svg`?`asset-load`:`build-error`,`${e.id}: ${t.message}`,`objects#${e.id}`),a=new o}if(this.disposed)return null;a.name=e.name??e.id,a.userData={...e.userData??{},...a.userData,a3dId:e.id,tags:e.tags??[]},Zr(a,e),e.visible===!1&&(a.visible=!1);let f=e.castShadow??(d?!0:void 0),p=e.receiveShadow??(d?!0:void 0);(f!==void 0||p!==void 0)&&a.traverse(e=>{e.isMesh&&(f!==void 0&&(e.castShadow=f),p!==void 0&&(e.receiveShadow=p))}),t.add(a);let m={id:e.id,kind:e.kind,def:e,object:a,rest:Xr(a),runners:[],animated:!1,topLevel:t===this.scene||t===this.camera&&!n,parentId:n,built:s,animator:c,particles:l,interactive:!!e.href};this.entries.set(e.id,m),this.attachBehaviours(m);for(let t of u){let n={id:t.id,kind:`text`,def:t.def,object:t.object,rest:Xr(t.object),runners:[],animated:!0,topLevel:!1,parentId:e.id,interactive:!1};t.reveal&&n.runners.push(un(t.reveal.def,t.reveal.impl,this.behaviourContext(n),{settled:()=>this.settleEntrances})),this.entries.set(t.id,n)}if(e.children?.length){let t=/* @__PURE__ */ new Map,n=e.children;await Promise.all(n.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(n=>this.addObject(n,a,e.id,t))),ei(t,n),await Promise.all(n.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(n=>this.addObject(n,a,e.id,t)))}return m}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 En(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 h):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(n=>{n instanceof t&&n.castShadow&&e.push(n)}),!e.length)return;let n=new j,r=new j;this.scene.updateMatrixWorld(!0);for(let e of this.entries.values())e.topLevel&&e.kind!==`particles`&&e.def.attach!==`camera`&&(r.setFromObject(e.object),r.isEmpty()||r.getSize(new h).length()>200||n.union(r));n.isEmpty()&&n.set(new h(-5,-1,-5),new h(5,5,5));let i=this.env?.ground?this.env.ground.position.y:n.min.y;n.expandByPoint(new h(n.min.x,i,n.min.z)),n.expandByPoint(new h(n.max.x,i,n.max.z)),n.expandByScalar(.3);for(let t of e)hr(t,n)}setViewport(e,t,n){this.viewportH=t*n;let r=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(this.def.target?.aspect??``),i=r?Number(r[1])/Number(r[2]):void 0;Bn(this.camera,this.def.camera,e/Math.max(t,1),i&&Number.isFinite(i)&&i>0?i:void 0);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=In(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.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 O;pointerOnPlane(e,t,n){e.updateWorldMatrix(!0,!1),this.camera.updateMatrixWorld(),this.pointerRay.setFromCamera(new f(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(),He(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 ei(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 ti=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`,`PageUp`,`PageDown`,`Home`,`End`]);function ni(){return{pointer:{x:0,y:0,inside:!1,down:!1,justPressed:!1},keys:/* @__PURE__ */ new Set,pressed:/* @__PURE__ */ new Set,swipe:null,clicks:[],scroll:0}}function ri(e){e.pressed.clear(),e.pointer.justPressed=!1,e.swipe=null,e.clicks.length=0}function ii(e,t,n){n?(e.keys.has(t)||e.pressed.add(t),e.keys.add(t)):e.keys.delete(t)}function ai(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)&&(ii(t,e.code,e.type===`keydown`),n.game&&ti.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 oi(e){let t=e.ownerDocument.defaultView;if(!t)return 0;let n=e.getBoundingClientRect(),r=t.innerHeight||1,i=(r-n.top)/(r+n.height);return i<0?0:i>1?1:i}var Z=(e,t,n)=>e<t?t:e>n?n:e;function si(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`&&t&&typeof t[e]==`number`?t[e]:n}function ci(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:Z(si(i.from,e.markers,0),0,n),to:Z(si(i.to,e.markers,n),0,n),loop:i.loop??!1,speed:typeof i.speed==`number`&&i.speed>0?i.speed:1}}function Q(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:bt(Math.max(0,t*e.speed+a),r,e.loop);return e.from+i*o}function li(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=ci(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:Z(t/r,0,1),segment:i,marker:a}}var ui=class{def;hoverClock=0;clickAt=-1;active=null;toggled=/* @__PURE__ */ 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=ci(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=ci(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=Z(si(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?ci(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:Q({...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)*Z(e.scroll,0,1);if(e.deterministic)return Q(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=Z(this.hoverClock,0,n)),Q(t,this.hoverClock)}case`click`:return e.clicked&&(this.clickAt=e.t),this.clickAt<0?t.from:Q(t,e.t-this.clickAt);default:return Q(t,e.t)}}update(e){let t;return t=this.active&&!e.staticMotion?Q(this.active,Math.max(0,e.t-this.active.start),this.active.startLocal):this.autoLocal(e),t=Z(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 li(this.def,this.lastLocal,this.active?.name)}drainMarkers(){let e=this.pending;return this.pending=[],e}};function di(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 fi=/* @__PURE__ */ new Set([`click`,`key`]),pi=class{defs;host;hoverPrev=/* @__PURE__ */ new Set;insidePrev=!1;scrollPrev=null;visibleFired=!1;fired=/* @__PURE__ */ new Set;queue=[];constructor(e,t){this.defs=e,this.host=t}targets(){let e=/* @__PURE__ */ 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&&fi.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})}},mi=`top bottom`,hi=`bottom top`;function gi(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 _i(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==2)return null;let i=gi(r[0],t),a=gi(r[1],n);return i===null||a===null?null:i-a}function vi(e,t,n,r=mi,i=hi){let a=_i(r,t,n)??-n,o=_i(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 yi=8e3;function bi(e,t,n=yi){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 h,s=new P,c=new P,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 xi(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 j,i=new P,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=Ci(n,t,r,e));else r.copy(o).applyMatrix4(n.matrixWorld).containsPoint(t)&&(a=Ci(n,t,r))}),a}var Si=[new h(1,0,0),new h(-1,0,0),new h(0,1,0),new h(0,-1,0),new h(0,0,1),new h(0,0,-1)];function Ci(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 O;return i.far=n.getSize(new h).length()+.001,Si.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 wi={none:0,aces:4,agx:6,neutral:7,reinhard:2};function Ti(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 Ei(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 Di=8,Oi=2e4,$=/* @__PURE__ */ new Set;function ki(e){for(;$.size>=Di;){let t=null;for(let n of $)n!==e&&n.releasable()&&(!t||n.lastSeen<t.lastSeen)&&(t=n);if(!t)return;t.release()}}function Ai(){return $.size}var ji=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=Fe(`high`);qualityAuto=!1;perfClock=0;slowFor=0;renderSamples=1;inputState=ni();inputBinding=null;resolveAsset;deterministic;t=0;tl=null;interactions=null;eventListeners=/* @__PURE__ */ 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=/* @__PURE__ */ new Set;resizeObs=null;interObs=null;readyResolve;readyReject;raycaster=new O;width=1;height=1;lastStats={triangles:0,drawCalls:0,geometries:0,textures:0};onVisibility=()=>this.updateRunning();editor;overlay=null;worldListeners=/* @__PURE__ */ new Set;constructor(e,t,n){this.container=e,this.options=n,this.scene=t,this.deterministic=!!n.deterministic,this.resolveAsset=Me(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){ii(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=ai(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(),Oi)),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 de({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=ae,e.toneMapping=wi[t.toneMapping??`aces`]??4,e.toneMappingExposure=t.exposure??1,this.quality=Fe(Le(t.quality,this.deviceHints(e))),this.qualityAuto=(t.quality??`auto`)===`auto`&&!this.deterministic&&!this.options.editor,this.perfClock=this.slowFor=0;let n=this.options.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,this.quality.dprCap);e.setPixelRatio(n);let r=cr(this.scene);if(e.shadowMap.enabled=r.enabled,e.shadowMap.type=r.type,t.transparent)e.setClearColor(0,0);else{let t=this.scene.environment?.background;e.setClearColor(typeof t==`string`&&t!==`transparent`?R(t):new k(0),1)}}start(){if(!(this.started||this.disposed)){if(this.started=!0,ki(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(/* @__PURE__ */ 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:Xe(this.scene.seed??1),siblings:/* @__PURE__ */ new Map,color:e=>R(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:dt,generators:ft}}async buildWorld(){let e=[],t=this.makeContext(e),n=await $r.create(W(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),Ti(this.scene)){let{GameHost:t}=await import(`./chunks/game-BoEiyZrL.js`);this.game=await t.create({scene:W(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 ui(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 pi(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=/* @__PURE__ */ 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=/* @__PURE__ */ 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=this.container.getBoundingClientRect(),i=vi(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 oi(this.container)}openUrl(e,t){let n=this.container.ownerDocument.defaultView,r=n?di(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=/* @__PURE__ */ 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 f(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=/* @__PURE__ */ 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=/* @__PURE__ */ 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(),ri(n),this.handledClicks=0,this.handledKeys.clear()}navigate(e){let t=this.container.ownerDocument.defaultView;if(!t)return;let n=di(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 h),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&&!Ti(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:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ 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 ln(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:/* @__PURE__ */ 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/Ei(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 Ee().setFromProjectionMatrix(new P().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),i=t.getWorldPosition(new h),a=new j,o=new h,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=bi(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`||xi(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 r=this.renderer,i=this.world;if(!r||!i)return this.canvas.toDataURL(t,n);let a=Math.max(1,Math.min(64,Math.round(e))),o=null;if(!this.postfx){let{createPostFx:e}=await import(`./chunks/postfx-Cbf_vvOr.js`);o=e([],{renderer:r,scene:i.scene,camera:i.camera,width:this.width,height:this.height,quality:Fe(`ultra`),antialias:this.scene.target?.antialias!==!1},()=>void 0)}let s=this.postfx??o;try{return s.render(this.t,{samples:a}),this.canvas.toDataURL(t,n)}finally{o?.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 import(`./chunks/postfx-Cbf_vvOr.js`);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=Re(this.quality.tier);n?(this.quality=Fe(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 Mi(e,t,n={}){let r=new ji(e,t,n);return r.canvas.isConnected&&r.resize(),r}var Ni=typeof HTMLElement<`u`?HTMLElement:class{},Pi=`
|
|
355
355
|
:host{display:block;position:relative;width:100%;overflow:hidden;background:var(--agent3d-background,transparent);contain:layout paint;-webkit-tap-highlight-color:transparent}
|
|
356
356
|
:host([hidden]){display:none}
|
|
357
357
|
:host([interactive="false"]) ::slotted(*){pointer-events:none}
|