@fleox/agent3d 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -13
- package/changelog.json +26 -0
- package/dist/agent/agent3d.mjs +228 -53
- package/dist/agent/chunks/{assets-BUUM9TUB.mjs → assets-YBkgdfgy.mjs} +27 -8
- package/dist/agent/chunks/{browser-Br1tURgt.mjs → browser-Dil7VM5m.mjs} +1 -1
- package/dist/agent/chunks/{cdp-Bdtm4fBN.mjs → cdp-DLEis_Z3.mjs} +1 -1
- package/dist/agent/chunks/{check-CfZcfaPs.mjs → check-DP9fRYbK.mjs} +64 -4
- package/dist/agent/chunks/depth-BZT4gseQ.mjs +483 -0
- package/dist/agent/chunks/depth-CD_ql3QJ.mjs +190 -0
- package/dist/agent/chunks/{export-BHugc2H7.mjs → export-bJwh2SqG.mjs} +12 -6
- package/dist/agent/chunks/{imageCodec-QM0EXQDJ.mjs → imageCodec-DeGfmBp3.mjs} +3 -3
- package/dist/agent/chunks/{objects-DBAws7uf.mjs → objects-DuytRxiC.mjs} +3 -3
- package/dist/agent/chunks/{optimizeSizing-CkZ3fZRp.mjs → optimizeSizing-B-BBiUkD.mjs} +51 -3
- package/dist/agent/chunks/{package-fw4h5vsh.mjs → package-fMbw9UGh.mjs} +2 -1
- package/dist/agent/chunks/{render-EHb40avl.mjs → render-B05DU4Q5.mjs} +4 -4
- package/dist/agent/chunks/{scene-BgajNvBf.mjs → scene-DWgXH6As.mjs} +2 -2
- package/dist/agent/chunks/{server-CACCerkZ.mjs → server-Dt_YFvN7.mjs} +6 -2
- package/dist/agent/chunks/{tools-DKxgjQSJ.mjs → tools-Cm4BqDkO.mjs} +60 -6
- package/dist/agent/chunks/{tree-BrNYGui2.mjs → tree-CqSj-o8T.mjs} +1 -0
- package/dist/agent/ort/LICENSE.txt +9 -0
- package/dist/agent/ort/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/agent/ort/ort.wasm.bundle.min.mjs +9 -0
- package/dist/runtime/agent3d-runtime.js +6 -6
- package/dist/runtime/agent3d-runtime.single.js +311 -62
- package/dist/runtime/chunks/assets-qnxDnVkj.js +1 -0
- package/dist/runtime/chunks/materials-dC4vDNHh.js +107 -0
- package/dist/runtime/chunks/{model-DbfZaLni.js → model-BCAl_NRl.js} +1 -1
- package/dist/runtime/chunks/photo-DNf14X7B.js +250 -0
- package/dist/runtime/chunks/svg-CLUxY6Zy.js +1 -0
- package/dist/runtime/chunks/{text-BaON-ISS.js → text-rSo_2Luk.js} +2 -2
- package/dist/studio/assets/assets-BW5lQkYR.js +1 -0
- package/dist/studio/assets/{camera-Be6lnp3k.js → camera-BgzPVnn-.js} +1 -1
- package/dist/studio/assets/{editor-Mpnz-b2E.js → editor-NkBUKsDB.js} +1 -1
- package/dist/studio/assets/{game-WMgRSJUD.js → game-DARpu0ah.js} +3 -3
- package/dist/studio/assets/{generators-DozXE7ta.js → generators-BjIs-kHx.js} +1 -1
- package/dist/studio/assets/index-L-N-e2KM.js +479 -0
- package/dist/studio/assets/{model-C2bZTK7-.js → model-CqI8j03Z.js} +1 -1
- package/dist/studio/assets/params-DhsDKSDs.js +1 -0
- package/dist/studio/assets/photo-DAHd1yNF.js +250 -0
- package/dist/studio/assets/{physicsHost-CTRsIvfu.js → physicsHost-tEUto2-_.js} +1 -1
- package/dist/studio/assets/{postfx-DQtp0JIy.js → postfx-BGu30OJK.js} +1 -1
- package/dist/studio/assets/runtime-C_qkIpAK.js +572 -0
- package/dist/studio/assets/{shaders-BOb6Uter.js → shaders-Dt6FGXH_.js} +12 -12
- package/dist/studio/assets/svg-ZZt5MdNf.js +2 -0
- package/dist/studio/assets/{text-CGIZs8HE.js → text-B-HM422i.js} +2 -2
- package/dist/studio/index.html +1 -1
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/agent3d-assets/SKILL.md +40 -25
- package/plugin/skills/agent3d-create/SKILL.md +57 -21
- package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
- package/plugin/skills/agent3d-create/references/recipes.md +71 -6
- package/plugin/skills/agent3d-edit/SKILL.md +22 -22
- package/plugin/skills/agent3d-edit/references/patch-ops.md +11 -3
- package/plugin/skills/agent3d-game/SKILL.md +7 -7
- package/plugin/skills/agent3d-publish/SKILL.md +23 -21
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
- package/templates/hero-photo-3d/README.md +28 -0
- package/templates/hero-photo-3d/agent3d.json +8 -0
- package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
- package/templates/hero-photo-3d/assets/manifest.json +25 -0
- package/templates/hero-photo-3d/assets/textures/street.webp +0 -0
- package/templates/hero-photo-3d/preview.png +0 -0
- package/templates/hero-photo-3d/scene.json +120 -0
- package/templates/hero-photo-3d/template.json +8 -0
- package/dist/runtime/chunks/materials-w3EW0g-7.js +0 -107
- package/dist/runtime/chunks/svg-CfPIQnDG.js +0 -1
- package/dist/studio/assets/index-tSGZFEt5.js +0 -479
- package/dist/studio/assets/runtime-NGp1VdnH.js +0 -572
- package/dist/studio/assets/svg-CnUMpv_N.js +0 -2
|
@@ -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-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=`
|
|
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,t as ke}from"./chunks/assets-qnxDnVkj.js";import{i as Ae,n as je,o as Me,r as Ne}from"./chunks/postfx-CFucYRev.js";import{i as Pe,n as Fe,t as Ie}from"./chunks/catalog--OTp4gjy.js";import{t as I}from"./chunks/easing-CXSz2e6P.js";import{a as Le,c as L,d as R,f as z,i as Re,l as B,n as V,o as H,p as ze,r as Be,s as Ve,t as U,u as He}from"./chunks/util-CyaW1fcW.js";import{a as Ue,i as We,t as Ge}from"./chunks/random-eeej60NW.js";import{i as Ke,n as qe,o as Je,r as Ye,t as Xe}from"./chunks/materials-dC4vDNHh.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.3.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-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 Ve(e)}var K=Math.PI*2,mt=(e,t)=>{let n=He(e.effect,`scale`),r=Math.max(L(e.duration,.8),.001),i=He(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=Re(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=Be(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=He(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)=>Ue(e*c+l,t*5.17)*.8+Ue(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=He(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;
|
|
@@ -145,7 +145,7 @@ void main() {
|
|
|
145
145
|
if (a < 0.003) discard;
|
|
146
146
|
gl_FragColor = vec4(col, a);
|
|
147
147
|
#include <colorspace_fragment>
|
|
148
|
-
}`;function gn(e){let t=fn[e.preset??``]??{},n={...dn,...t};return e.count!==void 0&&(n.count=Math.max(1,Math.round(e.count))),e.area&&(n.area=z(e.area,n.area)),e.size!==void 0&&(n.size=e.size),e.color!==void 0&&(n.colors=Ue(e.color,n.colors)),e.speed!==void 0&&(n.speed=e.speed),e.direction&&(n.direction=z(e.direction,n.direction)),e.spread!==void 0&&(n.spread=e.spread),e.lifetime!==void 0&&(n.lifetime=e.lifetime),e.opacity!==void 0&&(n.opacity=e.opacity),e.blending&&(n.blending=e.blending),e.shape&&(n.shape=e.shape),n}function _n(e,t){let r=gn(e),i=r.count,a=new Float32Array(i*3),o=new Float32Array(i*4),s=new Float32Array(i*3),c=r.colors.map(e=>R(e));for(let e=0;e<i;e++){a[e*3]=t.next()-.5,a[e*3+1]=t.next()-.5,a[e*3+2]=t.next()-.5;for(let n=0;n<4;n++)o[e*4+n]=t.next();let n=c[Math.floor(t.next()*c.length)%c.length];s[e*3]=n.r,s[e*3+1]=n.g,s[e*3+2]=n.b}let l=new he;l.setAttribute(`position`,new ve(a,3)),l.setAttribute(`aRand`,new ve(o,4)),l.setAttribute(`color`,new ve(s,3));let u=new h(...r.direction);u.lengthSq()<1e-9&&u.set(0,1,0),u.normalize().multiplyScalar(r.speed);let d=new h(...r.area).multiplyScalar(.5);l.boundingBox=new j(d.clone().negate(),d.clone()),l.boundingSphere=new ie(new h,d.length());let f=new N({uniforms:{uTime:{value:0},uArea:{value:new h(...r.area)},uVel:{value:u},uSpread:{value:r.spread},uLife:{value:Math.max(0,r.lifetime)},uWander:{value:r.wander},uSize:{value:r.size},uViewport:{value:600},uTwinkle:{value:r.twinkle},uSpin:{value:r.spin},uOpacity:{value:L(r.opacity,1)},uShape:{value:pn[r.shape]??7},uGravity:{value:new h(...r.gravity)},uEndColor:{value:r.endColor?R(r.endColor).clone():new k(1,1,1)},uUseEnd:{value:+!!r.endColor},uEndSize:{value:r.endSize},uStretch:{value:r.stretch},uSwirl:{value:r.swirl}},vertexShader:mn,fragmentShader:hn,transparent:!0,depthWrite:!1,blending:r.blending===`additive`?2:1});f.toneMapped=!1;let p=new n(l,f);return p.frustumCulled=!1,p.renderOrder=10,{points:p,update(e){f.uniforms.uTime.value=e},setViewport(e){f.uniforms.uViewport.value=e}}}function vn(e){return Array.isArray(e)?e:typeof e==`number`?[e,e,e]:null}function J(e,t,n=1){let r=e;return t?t!==`x`&&t!==`y`&&t!==`z`?{get:()=>void 0,set:()=>void 0}:{get:()=>r[t]/n,set:e=>{typeof e==`number`&&(r[t]=e*n)}}:{get:()=>[r.x/n,r.y/n,r.z/n],set:t=>{let r=vn(t);r&&e.set(r[0]*n,r[1]*n,r[2]*n)}}}function yn(e){return{get:()=>e()?.clone(),set:t=>{let n=e();n&&t instanceof k&&n.copy(t)}}}function bn(e,t,n=1){return{get:()=>typeof e[t]==`number`?e[t]/n:void 0,set:r=>{typeof r==`number`?e[t]=r*n:typeof r==`boolean`&&typeof e[t]==`boolean`&&(e[t]=r)}}}function xn(e,t){let n=null,r=()=>n??=Ke(e);if(t.startsWith(`uniforms.`)){let e=t.slice(9);return{get(){let t=r()[0]?.uniforms?.[e];if(t)return t.value instanceof k?t.value.clone():t.value instanceof h?[t.value.x,t.value.y,t.value.z]:typeof t.value==`number`?t.value:void 0},set(t){for(let n of r()){let r=n.uniforms?.[e];r&&(t instanceof k?r.value instanceof k&&r.value.copy(t):Array.isArray(t)&&r.value?.set?r.value.set(...t):r.value=t)}}}}if(t===`envMapIntensity`){let e=()=>r().filter(e=>e.isMeshStandardMaterial);return{get:()=>{let t=e()[0];return t?je(t).value:void 0},set:t=>{if(typeof t==`number`)for(let n of e())je(n).value=t}}}if(t===`anisotropyRotation`||t===`iridescenceIOR`){let e=t===`anisotropyRotation`?U:1;return{get(){let n=r()[0]?.[t];return typeof n==`number`?n/e:void 0},set(n){if(typeof n==`number`)for(let i of r())t in i&&(i[t]=n*e)}}}return{get(){let e=r()[0]?.[t];return e instanceof k?e.clone():typeof e==`number`||typeof e==`boolean`?e:void 0},set(e){for(let n of r()){let r=n,i=r[t];i instanceof k?e instanceof k&&i.copy(e):(typeof e==`number`||typeof e==`boolean`)&&t in r&&(r[t]=e,t===`opacity`&&typeof e==`number`&&e<1&&!n.transparent&&(n.transparent=!0,n.needsUpdate=!0))}}}}function Sn(e,t){let n=null,r=()=>(n||(n=[],e.traverse(e=>{let r=e,i=r.morphTargetDictionary?.[t];r.isMesh&&i!==void 0&&r.morphTargetInfluences&&n.push({m:r,i})})),n);return{get:()=>{let e=r()[0];return e?e.m.morphTargetInfluences[e.i]:void 0},set:e=>{if(typeof e==`number`)for(let t of r())t.m.morphTargetInfluences[t.i]=e}}}var Cn={get:()=>void 0,set:()=>void 0};function wn(e,t,n,r=t){let i=e=>(n.issue(`timeline-target`,e,r),null);if(e===`camera`){let e=n.camera;return e?t.startsWith(`position`)?J(e.position,t.slice(9)):t.startsWith(`target`)?J(e.target,t.slice(7)):t===`fov`||t===`zoom`||t===`focus`?bn(e,t):i(`Camera property "${t}" is not animatable`):null}if(e===`environment`){let e=n.scene;if(!e)return null;switch(t){case`fog.color`:return yn(()=>e.fog?.color);case`fog.near`:case`fog.far`:case`fog.density`:return{get:()=>e.fog?.[t.slice(4)],set:n=>e.fog&&typeof n==`number`&&(e.fog[t.slice(4)]=n)};case`lightingIntensity`:return bn(e,`environmentIntensity`);case`background`:return yn(()=>e.background instanceof k?e.background:null);case`exposure`:return n.renderer?bn(n.renderer,`toneMappingExposure`):Cn}return i(`Environment property "${t}" is not animatable`)}if(e===`postfx`){let[e,r]=t.split(`.`),a=n.postfx;if(!e||!r)return i(`Post effect track "${t}" must be "postfx.<type>.<param>"`);let o;return{get:()=>{if(o!==void 0)return o;let t=a?.base(e,r);return typeof t==`number`?t:void 0},set:t=>{o=t,a?.set(e,r,t instanceof k?`#${t.getHexString()}`:t)}}}let a=n.object(e);if(!a)return i(`Timeline track targets unknown object "${e}"`);let[o,...s]=t.split(`.`),c=s.join(`.`);switch(o){case`position`:return J(a.position,c);case`rotation`:return J(a.rotation,c,U);case`scale`:return J(a.scale,c);case`visible`:return{get:()=>a.visible,set:e=>a.visible=typeof e==`boolean`?e:typeof e==`number`?e>.5:a.visible};case`material`:return xn(a,c);case`morph`:return Sn(a,c);case`animation`:{let r=n.clips?.(e),a=s[s.length-1],o=s.slice(0,-1).join(`.`);return r?!o||![`weight`,`speed`,`time`].includes(a)?i(`Animation track "${t}" must be "animation.<clip>.weight|speed|time"`):{get:()=>a===`weight`?0:+(a===`speed`),set:e=>typeof e==`number`&&r[a](o,e)}:i(`"${e}" has no animation clips (animation tracks need a model with clips)`)}case`target`:{let e=a.target;if(e)return J(e.position,c);break}case`angle`:if(a.isSpotLight)return bn(a,`angle`,U)}let l=a;return o in l?{get(){let e=l[o];return e instanceof k?e.clone():e instanceof h?J(e,c).get():typeof e==`number`||typeof e==`boolean`?e:void 0},set(e){let t=l[o];t instanceof k&&e instanceof k?t.copy(e):t instanceof h?J(t,c).set(e):(typeof t==`number`&&typeof e==`number`||typeof t==`boolean`&&typeof e==`boolean`)&&(l[o]=e)}}:i(`Unknown property "${t}" on "${e}"`)}var Tn=/* @__PURE__ */ new Set([`camera`,`environment`,`postfx`]);function En(e,t){return Tn.has(e)?[e]:e.includes(`,`)||e.startsWith(`tag:`)||e.startsWith(`children:`)?t.select?t.select(e):e.split(`,`).map(e=>e.trim()).filter(Boolean):[e]}function Dn(e,t){let{id:n,path:r}=Nt(e.target),i=En(n,t);if(!i.length)return t.issue(`timeline-target`,`Track selector "${n}" matches no object`,`timeline.tracks[${e.target}]`),[];let a=Pt(i.length,e.staggerFrom,t.seed??1),o=typeof e.stagger==`number`?e.stagger:0,s=[];return i.forEach((n,i)=>{let c=wn(n,r,t,`timeline.tracks[${e.target}]`);if(!c)return;let l=Tt(e.keys,c.get()),u=o*a[i];u&&(l=l.map(e=>[e[0]+u,e[1],e[2]])),s.push({id:n,keys:l,ease:e.ease,colorSpace:e.colorSpace,set:c.set})}),s}function On(e,t){let n=(e.tracks??[]).flatMap(e=>Dn(e,t));return{def:e,targets:new Set(n.map(e=>e.id).filter(e=>!Tn.has(e))),animatesCamera:n.some(e=>e.id===`camera`),apply(e){for(let t of n){let n=Mt(t.keys,e,t.ease,t.colorSpace);n!==void 0&&t.set(n)}}}}function kn(e){if(e!==void 0)return typeof e==`object`&&!Array.isArray(e)?`#${e.getHexString()}`:e}var An=class{host;list=/* @__PURE__ */ new Map;constructor(e){this.host=e}get size(){return this.list.size}idsOf(e){return En(Nt(e).id,this.host)}set(e,t,n,r=0,i){let{id:a,path:o}=Nt(e);for(let s of En(a,this.host)){let a=`${s}.${o}`,c=this.list.get(a),l=c?.acc??wn(s,o,this.host,`interactions:${e}`);if(!l)continue;let u=c?.last??l.get(),[[,d]]=Tt([[0,t]],u),f=kn(u)??d;this.list.set(a,{acc:l,from:f,to:d,start:n,duration:Math.max(0,r),ease:i,orig:c?c.orig:l.get(),last:u})}}apply(e){for(let t of this.list.values()){let n=t.duration>0?I(t.ease??`outCubic`,(e-t.start)/t.duration):1,r=typeof t.to==`boolean`||typeof t.from==`boolean`?n>=1?t.to:t.from:At(t.from,t.to,e<t.start?0:n),i=typeof r==`string`?At(r,r,1):r;t.acc.set(i),t.last=i}}reset(){for(let e of this.list.values())e.orig!==void 0&&e.acc.set(e.orig);this.list.clear()}},jn=new h(0,1,0);function Y(e){return Array.isArray(e)&&e.length===3&&e.every(e=>typeof e==`number`)?new h(e[0],e[1],e[2]):null}var Mn=/* @__PURE__ */ new WeakMap;function Nn(e,t){let n=(e.points??[]).map(Y).filter(e=>!!e);if(!n.length)return null;let r=`${t.x},${t.y},${t.z}`,i=Mn.get(e);if(i&&i.key===r)return i.curve;let a=new te([t.clone(),...n],!1,`centripetal`);return Mn.set(e,{key:r,curve:a}),a}function Pn(e,t,n,r){let i=n.position,a=n.target,o=a.clone().sub(i),s=o.length()||1,c=o.clone().divideScalar(s),l=new h().crossVectors(c,jn);l.lengthSq()<1e-8&&l.set(1,0,0),l.normalize();let u=typeof e.fov==`number`?e.fov:null;switch(e.type){case`dolly`:case`pushIn`:case`pullOut`:{let n=typeof e.distance==`number`?e.distance:e.type===`pullOut`?s*.33:s*.25;e.type===`pullOut`&&(n=-Math.abs(n)),n=Math.min(n,s-.05),i.addScaledVector(c,n*t);break}case`truck`:{let n=(e.distance??1)*t;i.addScaledVector(l,n),a.addScaledVector(l,n);break}case`pedestal`:{let n=(e.distance??1)*t;i.y+=n,a.y+=n;break}case`crane`:if(i.y+=(e.height??2)*t,typeof e.distance==`number`){let n=new h(c.x,0,c.z);n.lengthSq()>1e-8&&i.addScaledVector(n.normalize(),e.distance*t)}break;case`orbit`:{let n=i.clone().sub(a);if(n.applyAxisAngle(jn,(e.angle??90)*U*t),e.elevation){let r=new ye().setFromVector3(n);r.phi=Math.min(Math.max(r.phi-e.elevation*U*t,.01),Math.PI-.01),n.setFromSpherical(r)}typeof e.distance==`number`&&n.setLength(Math.max(.05,n.length()+e.distance*t)),i.copy(a).add(n);break}case`move`:{let n=Y(e.position),r=Y(e.target);n&&i.lerp(n,t),r&&a.lerp(r,t);break}case`path`:{let n=Nn(e,i);if(!n)break;let o=n.getPointAt(Math.min(Math.max(t,0),1)),s=typeof e.lookAt==`string`?r.objectPosition(e.lookAt):Y(e.lookAt);if(s)a.lerp(s,Math.min(1,t*4));else{let r=Math.min(Math.max(e.lookAhead??.05,.001),.5),i=Math.min(t+r,1),o=n.getPointAt(i);i>=1&&o.add(n.getTangentAt(1).multiplyScalar(r*n.getLength())),a.lerp(o,Math.min(1,t*6))}i.copy(o);break}case`lookAt`:{let n=e.object?r.objectPosition(e.object):Y(e.target);n&&a.lerp(n,t);break}case`focus`:{let a=typeof e.focus==`number`?e.focus:null;if(e.object){let t=r.objectPosition(e.object);t&&(a=t.distanceTo(i))}a!==null&&(n.focus=(n.focus??a)+(a-(n.focus??a))*t);break}}u!==null&&(n.fov+=(u-n.fov)*t)}function Fn(e){return[...e??[]].filter(e=>e&&typeof e.at==`number`&&typeof e.duration==`number`).sort((e,t)=>e.at-t.at)}function In(e,t,n,r){let i={position:n.position.clone(),target:n.target.clone(),fov:n.fov,focus:n.focus};for(let n of e){if(t<n.at)break;let e=n.duration>0?(t-n.at)/n.duration:1;Pn(n,I(n.ease??`inOutCubic`,e),i,r)}return i}function Ln(e,t){let n=L(e.near,.1),r=L(e.far,1e3),i;if(e.type===`orthographic`){let a=L(e.zoom,10)/2;i=new v(-a*t,a*t,a,-a,n,r)}else i=new c(L(e.fov,45),t,n,r);i.position.set(...e.position);let a=e.target??[0,0,0];return Vn(i.position,new h(a[0],a[1],a[2])),i.lookAt(a[0],a[1],a[2]),i}function Rn(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function zn(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*U/2)*t)/U)}function Bn(e,t,n,r){let i=Rn(n,r);if(e.userData.fitScale=i,e instanceof c)e.aspect=n,e.fov=zn(L(e.userData.restFov,L(t.fov,45)),i),e.updateProjectionMatrix();else if(e instanceof v){let r=(e.userData.zoomHeight??L(t.zoom,10))/2*i;e.left=-r*n,e.right=r*n,e.top=r,e.bottom=-r,e.updateProjectionMatrix()}}function Vn(e,t){let n=t.x-e.x,r=t.y-e.y,i=t.z-e.z,a=Math.hypot(n,r,i);if(a<1e-9)return;let o=-1e-4/a;e.set(e.x+n*o,e.y+r*o,e.z+i*o)}async function Hn(e,t,n,r){let i=new h(...e.target??[0,0,0]),a={position:new h(...e.position),target:i.clone(),fov:L(e.fov,45),zoom:L(e.zoom,10)},o=e.controls??`none`,s=a.position.clone(),l=a.target.clone(),u=new f,d=new h,p=!0,m=null;if(o===`orbit`&&n&&!r){let{OrbitControls:r}=await import(`./chunks/OrbitControls-BIpWXK4x.js`),i=new r(t,n);i.target.copy(a.target),i.enableDamping=!0,i.dampingFactor=.08,i.enableZoom=e.orbitZoom!==!1,i.enablePan=!1;let o=e.orbitLimits??{};o.minDistance!==void 0&&(i.minDistance=o.minDistance),o.maxDistance!==void 0&&(i.maxDistance=o.maxDistance),o.minPolar!==void 0&&(i.minPolarAngle=o.minPolar*U),o.maxPolar!==void 0&&(i.maxPolarAngle=o.maxPolar*U),o.minAzimuth!==void 0&&(i.minAzimuthAngle=o.minAzimuth*U),o.maxAzimuth!==void 0&&(i.maxAzimuthAngle=o.maxAzimuth*U),e.autoRotate&&(i.autoRotate=!0,i.autoRotateSpeed=e.autoRotate/360*60),m=i}let g=new h,_=new h;return{rest:a,shake:d,orbit:m,update(n,r,i){if(t instanceof c){t.userData.restFov=a.fov;let e=zn(a.fov,L(t.userData.fitScale,1));t.fov!==e&&(t.fov=e,t.updateProjectionMatrix())}else if(t instanceof v&&L(t.userData.zoomHeight,L(e.zoom,10))!==a.zoom){t.userData.zoomHeight=a.zoom;let e=(t.right-t.left)/Math.max(t.top-t.bottom,1e-6),n=a.zoom/2*L(t.userData.fitScale,1);t.left=-n*e,t.right=n*e,t.top=n,t.bottom=-n,t.updateProjectionMatrix()}if(m){m.update(),t.position.add(d);return}let f=g.copy(a.position),y=l;if(o===`scroll`&&e.scrollPath?.length){let t=e.scrollPath,n=Ge(i.scroll,0,1)*(t.length-1),r=Math.min(Math.floor(n),t.length-2),a=t.length===1?0:n-Math.max(r,0),o=a*a*(3-2*a),s=t[Math.max(r,0)],c=t[Math.min(Math.max(r,0)+1,t.length-1)];f.set(...s.position).lerp(new h(...c.position),o);let l=new h(...s.target??e.target??[0,0,0]),u=new h(...c.target??e.target??[0,0,0]);y.copy(l.lerp(u,o))}else if(o===`follow`&&i.followTarget){let t=e.follow??{target:``},n=i.followTarget.getWorldPosition(new h),a=new h(...t.offset??[0,4,8]),o=n.clone().add(a),c=n.clone().add(new h(0,0,-L(t.lookAhead,0))),l=p?1:B(L(t.smoothing,.85),r);s.lerp(o,l),y.lerp(c,l),f=g.copy(s)}else y.copy(a.target);if(i.lookAt&&y.copy(i.lookAt),e.autoRotate&&o!==`follow`){let t=e.autoRotate*U*n,r=f.clone().sub(y);r.applyAxisAngle(new h(0,1,0),t),f.copy(y).add(r)}if(o===`parallax`){let n=e.parallax??{},a=L(n.strength,.5),o=B(L(n.smoothing,.92),r);u.x+=(i.pointer.x*a-u.x)*o,u.y+=(i.pointer.y*a*.6-u.y)*o;let s=y.clone().sub(f).normalize(),c=new h().crossVectors(s,t.up).normalize(),l=new h().crossVectors(c,s).normalize();f.addScaledVector(c,u.x).addScaledVector(l,u.y)}if(e.shake){let r=e.shake,i=L(r.speed,.5),a=L(r.amount,.03),o=L(r.rotation,.4)*U,s=L(r.seed,1)*17.31,c=e=>Je(n*i+s,e*7.13)*.75+Je(n*i*2.7+s,e*7.13+3.1)*.25,l=y.clone().sub(f),u=l.length()||1;l.divideScalar(u);let d=new h().crossVectors(l,t.up).normalize(),p=new h().crossVectors(d,l).normalize();f.addScaledVector(d,c(0)*a).addScaledVector(p,c(1)*a),_.copy(y).addScaledVector(d,Math.tan(c(2)*o)*u).addScaledVector(p,Math.tan(c(3)*o)*u)}else _.copy(y);t.position.copy(f).add(d),Vn(t.position,_),t.lookAt(_),p=!1},dispose(){m?.dispose()}}}var Un=`
|
|
148
|
+
}`;function gn(e){let t=fn[e.preset??``]??{},n={...dn,...t};return e.count!==void 0&&(n.count=Math.max(1,Math.round(e.count))),e.area&&(n.area=z(e.area,n.area)),e.size!==void 0&&(n.size=e.size),e.color!==void 0&&(n.colors=Re(e.color,n.colors)),e.speed!==void 0&&(n.speed=e.speed),e.direction&&(n.direction=z(e.direction,n.direction)),e.spread!==void 0&&(n.spread=e.spread),e.lifetime!==void 0&&(n.lifetime=e.lifetime),e.opacity!==void 0&&(n.opacity=e.opacity),e.blending&&(n.blending=e.blending),e.shape&&(n.shape=e.shape),n}function _n(e,t){let r=gn(e),i=r.count,a=new Float32Array(i*3),o=new Float32Array(i*4),s=new Float32Array(i*3),c=r.colors.map(e=>R(e));for(let e=0;e<i;e++){a[e*3]=t.next()-.5,a[e*3+1]=t.next()-.5,a[e*3+2]=t.next()-.5;for(let n=0;n<4;n++)o[e*4+n]=t.next();let n=c[Math.floor(t.next()*c.length)%c.length];s[e*3]=n.r,s[e*3+1]=n.g,s[e*3+2]=n.b}let l=new he;l.setAttribute(`position`,new ve(a,3)),l.setAttribute(`aRand`,new ve(o,4)),l.setAttribute(`color`,new ve(s,3));let u=new h(...r.direction);u.lengthSq()<1e-9&&u.set(0,1,0),u.normalize().multiplyScalar(r.speed);let d=new h(...r.area).multiplyScalar(.5);l.boundingBox=new j(d.clone().negate(),d.clone()),l.boundingSphere=new ie(new h,d.length());let f=new N({uniforms:{uTime:{value:0},uArea:{value:new h(...r.area)},uVel:{value:u},uSpread:{value:r.spread},uLife:{value:Math.max(0,r.lifetime)},uWander:{value:r.wander},uSize:{value:r.size},uViewport:{value:600},uTwinkle:{value:r.twinkle},uSpin:{value:r.spin},uOpacity:{value:L(r.opacity,1)},uShape:{value:pn[r.shape]??7},uGravity:{value:new h(...r.gravity)},uEndColor:{value:r.endColor?R(r.endColor).clone():new k(1,1,1)},uUseEnd:{value:+!!r.endColor},uEndSize:{value:r.endSize},uStretch:{value:r.stretch},uSwirl:{value:r.swirl}},vertexShader:mn,fragmentShader:hn,transparent:!0,depthWrite:!1,blending:r.blending===`additive`?2:1});f.toneMapped=!1;let p=new n(l,f);return p.frustumCulled=!1,p.renderOrder=10,{points:p,update(e){f.uniforms.uTime.value=e},setViewport(e){f.uniforms.uViewport.value=e}}}function vn(e){return Array.isArray(e)?e:typeof e==`number`?[e,e,e]:null}function J(e,t,n=1){let r=e;return t?t!==`x`&&t!==`y`&&t!==`z`?{get:()=>void 0,set:()=>void 0}:{get:()=>r[t]/n,set:e=>{typeof e==`number`&&(r[t]=e*n)}}:{get:()=>[r.x/n,r.y/n,r.z/n],set:t=>{let r=vn(t);r&&e.set(r[0]*n,r[1]*n,r[2]*n)}}}function yn(e){return{get:()=>e()?.clone(),set:t=>{let n=e();n&&t instanceof k&&n.copy(t)}}}function bn(e,t,n=1){return{get:()=>typeof e[t]==`number`?e[t]/n:void 0,set:r=>{typeof r==`number`?e[t]=r*n:typeof r==`boolean`&&typeof e[t]==`boolean`&&(e[t]=r)}}}function xn(e,t){let n=null,r=()=>n??=Ve(e);if(t.startsWith(`uniforms.`)){let e=t.slice(9);return{get(){let t=r()[0]?.uniforms?.[e];if(t)return t.value instanceof k?t.value.clone():t.value instanceof h?[t.value.x,t.value.y,t.value.z]:typeof t.value==`number`?t.value:void 0},set(t){for(let n of r()){let r=n.uniforms?.[e];r&&(t instanceof k?r.value instanceof k&&r.value.copy(t):Array.isArray(t)&&r.value?.set?r.value.set(...t):r.value=t)}}}}if(t===`envMapIntensity`){let e=()=>r().filter(e=>e.isMeshStandardMaterial);return{get:()=>{let t=e()[0];return t?Ye(t).value:void 0},set:t=>{if(typeof t==`number`)for(let n of e())Ye(n).value=t}}}if(t===`anisotropyRotation`||t===`iridescenceIOR`){let e=t===`anisotropyRotation`?U:1;return{get(){let n=r()[0]?.[t];return typeof n==`number`?n/e:void 0},set(n){if(typeof n==`number`)for(let i of r())t in i&&(i[t]=n*e)}}}return{get(){let e=r()[0]?.[t];return e instanceof k?e.clone():typeof e==`number`||typeof e==`boolean`?e:void 0},set(e){for(let n of r()){let r=n,i=r[t];i instanceof k?e instanceof k&&i.copy(e):(typeof e==`number`||typeof e==`boolean`)&&t in r&&(r[t]=e,t===`opacity`&&typeof e==`number`&&e<1&&!n.transparent&&(n.transparent=!0,n.needsUpdate=!0))}}}}function Sn(e,t){let n=null,r=()=>(n||(n=[],e.traverse(e=>{let r=e,i=r.morphTargetDictionary?.[t];r.isMesh&&i!==void 0&&r.morphTargetInfluences&&n.push({m:r,i})})),n);return{get:()=>{let e=r()[0];return e?e.m.morphTargetInfluences[e.i]:void 0},set:e=>{if(typeof e==`number`)for(let t of r())t.m.morphTargetInfluences[t.i]=e}}}var Cn={get:()=>void 0,set:()=>void 0};function wn(e,t,n,r=t){let i=e=>(n.issue(`timeline-target`,e,r),null);if(e===`camera`){let e=n.camera;return e?t.startsWith(`position`)?J(e.position,t.slice(9)):t.startsWith(`target`)?J(e.target,t.slice(7)):t===`fov`||t===`zoom`||t===`focus`?bn(e,t):i(`Camera property "${t}" is not animatable`):null}if(e===`environment`){let e=n.scene;if(!e)return null;switch(t){case`fog.color`:return yn(()=>e.fog?.color);case`fog.near`:case`fog.far`:case`fog.density`:return{get:()=>e.fog?.[t.slice(4)],set:n=>e.fog&&typeof n==`number`&&(e.fog[t.slice(4)]=n)};case`lightingIntensity`:return bn(e,`environmentIntensity`);case`background`:return yn(()=>e.background instanceof k?e.background:null);case`exposure`:return n.renderer?bn(n.renderer,`toneMappingExposure`):Cn}return i(`Environment property "${t}" is not animatable`)}if(e===`postfx`){let[e,r]=t.split(`.`),a=n.postfx;if(!e||!r)return i(`Post effect track "${t}" must be "postfx.<type>.<param>"`);let o;return{get:()=>{if(o!==void 0)return o;let t=a?.base(e,r);return typeof t==`number`?t:void 0},set:t=>{o=t,a?.set(e,r,t instanceof k?`#${t.getHexString()}`:t)}}}let a=n.object(e);if(!a)return i(`Timeline track targets unknown object "${e}"`);let[o,...s]=t.split(`.`),c=s.join(`.`);switch(o){case`position`:return J(a.position,c);case`rotation`:return J(a.rotation,c,U);case`scale`:return J(a.scale,c);case`visible`:return{get:()=>a.visible,set:e=>a.visible=typeof e==`boolean`?e:typeof e==`number`?e>.5:a.visible};case`material`:return xn(a,c);case`morph`:return Sn(a,c);case`animation`:{let r=n.clips?.(e),a=s[s.length-1],o=s.slice(0,-1).join(`.`);return r?!o||![`weight`,`speed`,`time`].includes(a)?i(`Animation track "${t}" must be "animation.<clip>.weight|speed|time"`):{get:()=>a===`weight`?0:+(a===`speed`),set:e=>typeof e==`number`&&r[a](o,e)}:i(`"${e}" has no animation clips (animation tracks need a model with clips)`)}case`target`:{let e=a.target;if(e)return J(e.position,c);break}case`angle`:if(a.isSpotLight)return bn(a,`angle`,U)}let l=a;return o in l?{get(){let e=l[o];return e instanceof k?e.clone():e instanceof h?J(e,c).get():typeof e==`number`||typeof e==`boolean`?e:void 0},set(e){let t=l[o];t instanceof k&&e instanceof k?t.copy(e):t instanceof h?J(t,c).set(e):(typeof t==`number`&&typeof e==`number`||typeof t==`boolean`&&typeof e==`boolean`)&&(l[o]=e)}}:i(`Unknown property "${t}" on "${e}"`)}var Tn=/* @__PURE__ */ new Set([`camera`,`environment`,`postfx`]);function En(e,t){return Tn.has(e)?[e]:e.includes(`,`)||e.startsWith(`tag:`)||e.startsWith(`children:`)?t.select?t.select(e):e.split(`,`).map(e=>e.trim()).filter(Boolean):[e]}function Dn(e,t){let{id:n,path:r}=Nt(e.target),i=En(n,t);if(!i.length)return t.issue(`timeline-target`,`Track selector "${n}" matches no object`,`timeline.tracks[${e.target}]`),[];let a=Pt(i.length,e.staggerFrom,t.seed??1),o=typeof e.stagger==`number`?e.stagger:0,s=[];return i.forEach((n,i)=>{let c=wn(n,r,t,`timeline.tracks[${e.target}]`);if(!c)return;let l=Tt(e.keys,c.get()),u=o*a[i];u&&(l=l.map(e=>[e[0]+u,e[1],e[2]])),s.push({id:n,keys:l,ease:e.ease,colorSpace:e.colorSpace,set:c.set})}),s}function On(e,t){let n=(e.tracks??[]).flatMap(e=>Dn(e,t));return{def:e,targets:new Set(n.map(e=>e.id).filter(e=>!Tn.has(e))),animatesCamera:n.some(e=>e.id===`camera`),apply(e){for(let t of n){let n=Mt(t.keys,e,t.ease,t.colorSpace);n!==void 0&&t.set(n)}}}}function kn(e){if(e!==void 0)return typeof e==`object`&&!Array.isArray(e)?`#${e.getHexString()}`:e}var An=class{host;list=/* @__PURE__ */ new Map;constructor(e){this.host=e}get size(){return this.list.size}idsOf(e){return En(Nt(e).id,this.host)}set(e,t,n,r=0,i){let{id:a,path:o}=Nt(e);for(let s of En(a,this.host)){let a=`${s}.${o}`,c=this.list.get(a),l=c?.acc??wn(s,o,this.host,`interactions:${e}`);if(!l)continue;let u=c?.last??l.get(),[[,d]]=Tt([[0,t]],u),f=kn(u)??d;this.list.set(a,{acc:l,from:f,to:d,start:n,duration:Math.max(0,r),ease:i,orig:c?c.orig:l.get(),last:u})}}apply(e){for(let t of this.list.values()){let n=t.duration>0?I(t.ease??`outCubic`,(e-t.start)/t.duration):1,r=typeof t.to==`boolean`||typeof t.from==`boolean`?n>=1?t.to:t.from:At(t.from,t.to,e<t.start?0:n),i=typeof r==`string`?At(r,r,1):r;t.acc.set(i),t.last=i}}reset(){for(let e of this.list.values())e.orig!==void 0&&e.acc.set(e.orig);this.list.clear()}},jn=new h(0,1,0);function Y(e){return Array.isArray(e)&&e.length===3&&e.every(e=>typeof e==`number`)?new h(e[0],e[1],e[2]):null}var Mn=/* @__PURE__ */ new WeakMap;function Nn(e,t){let n=(e.points??[]).map(Y).filter(e=>!!e);if(!n.length)return null;let r=`${t.x},${t.y},${t.z}`,i=Mn.get(e);if(i&&i.key===r)return i.curve;let a=new te([t.clone(),...n],!1,`centripetal`);return Mn.set(e,{key:r,curve:a}),a}function Pn(e,t,n,r){let i=n.position,a=n.target,o=a.clone().sub(i),s=o.length()||1,c=o.clone().divideScalar(s),l=new h().crossVectors(c,jn);l.lengthSq()<1e-8&&l.set(1,0,0),l.normalize();let u=typeof e.fov==`number`?e.fov:null;switch(e.type){case`dolly`:case`pushIn`:case`pullOut`:{let n=typeof e.distance==`number`?e.distance:e.type===`pullOut`?s*.33:s*.25;e.type===`pullOut`&&(n=-Math.abs(n)),n=Math.min(n,s-.05),i.addScaledVector(c,n*t);break}case`truck`:{let n=(e.distance??1)*t;i.addScaledVector(l,n),a.addScaledVector(l,n);break}case`pedestal`:{let n=(e.distance??1)*t;i.y+=n,a.y+=n;break}case`crane`:if(i.y+=(e.height??2)*t,typeof e.distance==`number`){let n=new h(c.x,0,c.z);n.lengthSq()>1e-8&&i.addScaledVector(n.normalize(),e.distance*t)}break;case`orbit`:{let n=i.clone().sub(a);if(n.applyAxisAngle(jn,(e.angle??90)*U*t),e.elevation){let r=new ye().setFromVector3(n);r.phi=Math.min(Math.max(r.phi-e.elevation*U*t,.01),Math.PI-.01),n.setFromSpherical(r)}typeof e.distance==`number`&&n.setLength(Math.max(.05,n.length()+e.distance*t)),i.copy(a).add(n);break}case`move`:{let n=Y(e.position),r=Y(e.target);n&&i.lerp(n,t),r&&a.lerp(r,t);break}case`path`:{let n=Nn(e,i);if(!n)break;let o=n.getPointAt(Math.min(Math.max(t,0),1)),s=typeof e.lookAt==`string`?r.objectPosition(e.lookAt):Y(e.lookAt);if(s)a.lerp(s,Math.min(1,t*4));else{let r=Math.min(Math.max(e.lookAhead??.05,.001),.5),i=Math.min(t+r,1),o=n.getPointAt(i);i>=1&&o.add(n.getTangentAt(1).multiplyScalar(r*n.getLength())),a.lerp(o,Math.min(1,t*6))}i.copy(o);break}case`lookAt`:{let n=e.object?r.objectPosition(e.object):Y(e.target);n&&a.lerp(n,t);break}case`focus`:{let a=typeof e.focus==`number`?e.focus:null;if(e.object){let t=r.objectPosition(e.object);t&&(a=t.distanceTo(i))}a!==null&&(n.focus=(n.focus??a)+(a-(n.focus??a))*t);break}}u!==null&&(n.fov+=(u-n.fov)*t)}function Fn(e){return[...e??[]].filter(e=>e&&typeof e.at==`number`&&typeof e.duration==`number`).sort((e,t)=>e.at-t.at)}function In(e,t,n,r){let i={position:n.position.clone(),target:n.target.clone(),fov:n.fov,focus:n.focus};for(let n of e){if(t<n.at)break;let e=n.duration>0?(t-n.at)/n.duration:1;Pn(n,I(n.ease??`inOutCubic`,e),i,r)}return i}function Ln(e,t){let n=L(e.near,.1),r=L(e.far,1e3),i;if(e.type===`orthographic`){let a=L(e.zoom,10)/2;i=new v(-a*t,a*t,a,-a,n,r)}else i=new c(L(e.fov,45),t,n,r);i.position.set(...e.position);let a=e.target??[0,0,0];return Vn(i.position,new h(a[0],a[1],a[2])),i.lookAt(a[0],a[1],a[2]),i}function Rn(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function zn(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*U/2)*t)/U)}function Bn(e,t,n,r){let i=Rn(n,r);if(e.userData.fitScale=i,e instanceof c)e.aspect=n,e.fov=zn(L(e.userData.restFov,L(t.fov,45)),i),e.updateProjectionMatrix();else if(e instanceof v){let r=(e.userData.zoomHeight??L(t.zoom,10))/2*i;e.left=-r*n,e.right=r*n,e.top=r,e.bottom=-r,e.updateProjectionMatrix()}}function Vn(e,t){let n=t.x-e.x,r=t.y-e.y,i=t.z-e.z,a=Math.hypot(n,r,i);if(a<1e-9)return;let o=-1e-4/a;e.set(e.x+n*o,e.y+r*o,e.z+i*o)}async function Hn(e,t,n,r){let i=new h(...e.target??[0,0,0]),a={position:new h(...e.position),target:i.clone(),fov:L(e.fov,45),zoom:L(e.zoom,10)},o=e.controls??`none`,s=a.position.clone(),l=a.target.clone(),u=new f,d=new h,p=!0,m=null;if(o===`orbit`&&n&&!r){let{OrbitControls:r}=await import(`./chunks/OrbitControls-BIpWXK4x.js`),i=new r(t,n);i.target.copy(a.target),i.enableDamping=!0,i.dampingFactor=.08,i.enableZoom=e.orbitZoom!==!1,i.enablePan=!1;let o=e.orbitLimits??{};o.minDistance!==void 0&&(i.minDistance=o.minDistance),o.maxDistance!==void 0&&(i.maxDistance=o.maxDistance),o.minPolar!==void 0&&(i.minPolarAngle=o.minPolar*U),o.maxPolar!==void 0&&(i.maxPolarAngle=o.maxPolar*U),o.minAzimuth!==void 0&&(i.minAzimuthAngle=o.minAzimuth*U),o.maxAzimuth!==void 0&&(i.maxAzimuthAngle=o.maxAzimuth*U),e.autoRotate&&(i.autoRotate=!0,i.autoRotateSpeed=e.autoRotate/360*60),m=i}let g=new h,_=new h;return{rest:a,shake:d,orbit:m,update(n,r,i){if(t instanceof c){t.userData.restFov=a.fov;let e=zn(a.fov,L(t.userData.fitScale,1));t.fov!==e&&(t.fov=e,t.updateProjectionMatrix())}else if(t instanceof v&&L(t.userData.zoomHeight,L(e.zoom,10))!==a.zoom){t.userData.zoomHeight=a.zoom;let e=(t.right-t.left)/Math.max(t.top-t.bottom,1e-6),n=a.zoom/2*L(t.userData.fitScale,1);t.left=-n*e,t.right=n*e,t.top=n,t.bottom=-n,t.updateProjectionMatrix()}if(m){m.update(),t.position.add(d);return}let f=g.copy(a.position),y=l;if(o===`scroll`&&e.scrollPath?.length){let t=e.scrollPath,n=Be(i.scroll,0,1)*(t.length-1),r=Math.min(Math.floor(n),t.length-2),a=t.length===1?0:n-Math.max(r,0),o=a*a*(3-2*a),s=t[Math.max(r,0)],c=t[Math.min(Math.max(r,0)+1,t.length-1)];f.set(...s.position).lerp(new h(...c.position),o);let l=new h(...s.target??e.target??[0,0,0]),u=new h(...c.target??e.target??[0,0,0]);y.copy(l.lerp(u,o))}else if(o===`follow`&&i.followTarget){let t=e.follow??{target:``},n=i.followTarget.getWorldPosition(new h),a=new h(...t.offset??[0,4,8]),o=n.clone().add(a),c=n.clone().add(new h(0,0,-L(t.lookAhead,0))),l=p?1:B(L(t.smoothing,.85),r);s.lerp(o,l),y.lerp(c,l),f=g.copy(s)}else y.copy(a.target);if(i.lookAt&&y.copy(i.lookAt),e.autoRotate&&o!==`follow`){let t=e.autoRotate*U*n,r=f.clone().sub(y);r.applyAxisAngle(new h(0,1,0),t),f.copy(y).add(r)}if(o===`parallax`){let n=e.parallax??{},a=L(n.strength,.5),o=B(L(n.smoothing,.92),r);u.x+=(i.pointer.x*a-u.x)*o,u.y+=(i.pointer.y*a*.6-u.y)*o;let s=y.clone().sub(f).normalize(),c=new h().crossVectors(s,t.up).normalize(),l=new h().crossVectors(c,s).normalize();f.addScaledVector(c,u.x).addScaledVector(l,u.y)}if(e.shake){let r=e.shake,i=L(r.speed,.5),a=L(r.amount,.03),o=L(r.rotation,.4)*U,s=L(r.seed,1)*17.31,c=e=>Ue(n*i+s,e*7.13)*.75+Ue(n*i*2.7+s,e*7.13+3.1)*.25,l=y.clone().sub(f),u=l.length()||1;l.divideScalar(u);let d=new h().crossVectors(l,t.up).normalize(),p=new h().crossVectors(d,l).normalize();f.addScaledVector(d,c(0)*a).addScaledVector(p,c(1)*a),_.copy(y).addScaledVector(d,Math.tan(c(2)*o)*u).addScaledVector(p,Math.tan(c(3)*o)*u)}else _.copy(y);t.position.copy(f).add(d),Vn(t.position,_),t.lookAt(_),p=!1},dispose(){m?.dispose()}}}var Un=`
|
|
149
149
|
varying vec2 vUv;
|
|
150
150
|
void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }`,Wn=`
|
|
151
151
|
uniform sampler2D tDiffuse;
|
|
@@ -187,7 +187,7 @@ float a3dHeightFog(float density) {
|
|
|
187
187
|
else amount = (density / b) * exp(-h * b) * (1.0 - exp(-dist * rd.y * b)) / rd.y;
|
|
188
188
|
return 1.0 - exp(-max(amount, 0.0));
|
|
189
189
|
}
|
|
190
|
-
`;function tr(e,t){e.fog&&!e.isShaderMaterial&&
|
|
190
|
+
`;function tr(e,t){e.fog&&!e.isShaderMaterial&&Xe(e,`height-fog`,e=>{Object.assign(e.uniforms,t),e.vertexShader.includes(`#include <fog_vertex>`)&&(e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
|
|
191
191
|
varying vec3 vA3dFogWorld;`).replace(`#include <fog_vertex>`,`#include <fog_vertex>
|
|
192
192
|
{
|
|
193
193
|
vec4 a3dW = vec4( transformed, 1.0 );
|
|
@@ -263,7 +263,7 @@ void main() {
|
|
|
263
263
|
float fogF = smoothstep( fogNear, fogFar, vFogDepth );
|
|
264
264
|
gl_FragColor.rgb *= 1.0 - fogF;
|
|
265
265
|
#endif
|
|
266
|
-
}`;function pr(e,t){let n=typeof t.volumetric==`object`?t.volumetric:{},r=new Ce(1,0,1,48,24,!0);r.translate(0,.5,0),r.rotateX(Math.PI/2);let i=new N({uniforms:{..._.clone(be.fog),uColor:{value:R(n.color??t.color??`#ffffff`)},uIntensity:{value:L(n.intensity,1)},uDepth:{value:null},uUseDepth:{value:0},uViewport:{value:new f(1,1)},uNear:{value:.1},uFar:{value:1e3},uOrtho:{value:0},uGroundY:{value:0},uUseGround:{value:0},uSoft:{value:.5}},vertexShader:dr,fragmentShader:fr,transparent:!0,depthWrite:!1,blending:2,premultipliedAlpha:!0,side:2,fog:!1}),a=new F(r,i);a.name=`__volumetric`,a.userData.helper=!0,a.castShadow=!1,a.receiveShadow=!1,a.frustumCulled=!1;let o=typeof t.volumetric==`object`?t.volumetric.length:void 0,s=new h,c=new h,l=L(n.intensity,1),u=Math.max(e.intensity,.001),d,p=new h;return a.onBeforeRender=(t,r,f)=>{e.getWorldPosition(s),e.target.getWorldPosition(c);let m=o??Math.max(.5,s.distanceTo(c)*1.25),g=i.uniforms;g.uSoft.value=Math.max(.05,m*.12);let _=r.userData.a3dDepth,v=f;_&&t.getRenderTarget()?(g.uDepth.value=_.texture,g.uUseDepth.value=1,g.uViewport.value.set(_.width,_.height),g.uNear.value=v.near,g.uFar.value=v.far,g.uOrtho.value=+!!v.isOrthographicCamera):(g.uDepth.value=null,g.uUseDepth.value=0),(d===void 0||d&&!d.parent)&&(d=null,r.traverse(e=>{!d&&e.userData.ground&&(d=e)})),d&&d.visible?(d.getWorldPosition(p),g.uGroundY.value=p.y,g.uUseGround.value=1):(g.uGroundY.value=c.y,g.uUseGround.value=+(!o&&c.y<s.y-.1));let y=Math.tan(Math.min(e.angle,1.5))*m,b=new T().setFromUnitVectors(new h(0,0,1),c.clone().sub(s).normalize()),x=e.getWorldQuaternion(new T).invert();a.quaternion.copy(x.multiply(b)),a.scale.set(y,y,m),a.position.set(0,0,0),a.updateMatrixWorld(!0),i.uniforms.uColor.value.copy(n.color?R(n.color):e.color),i.uniforms.uIntensity.value=l*Math.min(3,e.intensity/u)},a}async function mr(e,n){let r=R(e.color??`#ffffff`),i=L(e.intensity,or[e.type]??1),a;switch(e.type){case`ambient`:a=new _e(r,i);break;case`hemisphere`:a=new E(R(e.skyColor??e.color??`#ffffff`),R(e.groundColor??`#444444`),i),a.position.set(0,10,0);break;case`point`:a=new De(r,i,L(e.distance,0),L(e.decay,2));break;case`spot`:a=new M(r,i,L(e.distance,0),L(e.angle,30)*U,L(e.penumbra,.3),L(e.decay,2));break;case`rect`:await ar(),a=new D(r,i,L(e.width,2),L(e.height,2));break;default:a=new t(r,i)}let o=e.position??(e.type===`directional`?[5,10,7]:e.type===`spot`?[3,6,4]:[0,3,3]);e.type!==`ambient`&&e.type!==`hemisphere`&&a.position.set(o[0],o[1],o[2]);let s=e.target??[0,0,0];return a instanceof t||a instanceof M?a.target.position.set(s[0],s[1],s[2]):a instanceof D&&(a.lookAt(s[0],s[1],s[2]),e.panel&&a.add(ur(a))),e.castShadow&&(a instanceof t||a instanceof M||a instanceof De)&&lr(a,e,n),e.volumetric&&a instanceof M&&a.add(pr(a,e)),a.name=e.id??e.type,a.userData.baseIntensity=i,a.userData.baseColor=r.clone(),a}function hr(e,t){if(t.isEmpty())return;let n=e.shadow.camera;e.updateMatrixWorld(),e.target.updateMatrixWorld();let r=new h().setFromMatrixPosition(e.matrixWorld),i=new h().setFromMatrixPosition(e.target.matrixWorld),a=new P().lookAt(r,i,new h(0,1,0));a.setPosition(r);let o=a.clone().invert(),s=new j,c=new h;for(let e=0;e<8;e++)c.set(e&1?t.max.x:t.min.x,e&2?t.max.y:t.min.y,e&4?t.max.z:t.min.z).applyMatrix4(o),s.expandByPoint(c);let l=.5;n.left=s.min.x-l,n.right=s.max.x+l,n.bottom=s.min.y-l,n.top=s.max.y+l,n.near=Math.max(.01,-s.max.z-l),n.far=-s.min.z+l,n.updateProjectionMatrix();let u=Math.max(n.right-n.left,n.top-n.bottom)/e.shadow.mapSize.x;e.userData.fixedNormalBias||(e.shadow.normalBias=Math.max(.01,u*1.5))}var gr={"studio-3point":[{id:`key`,type:`directional`,position:[4,6,5],color:`#fff1e0`,intensity:2.6,castShadow:!0,shadow:{softness:6}},{id:`fill`,type:`directional`,position:[-5,2.5,3],color:`#dbe6ff`,intensity:.8},{id:`rim`,type:`directional`,position:[-1.5,4,-6],color:`#ffffff`,intensity:2.2},{id:`sky`,type:`hemisphere`,skyColor:`#ffffff`,groundColor:`#3a3f4a`,intensity:.35}],softbox:[{id:`top`,type:`rect`,position:[0,5,1.5],width:5,height:5,color:`#ffffff`,intensity:2.1},{id:`left`,type:`rect`,position:[-4.5,2,2.5],width:2,height:4.5,color:`#fff6ee`,intensity:2.6},{id:`right`,type:`rect`,position:[4.5,2,2.5],width:2,height:4.5,color:`#eef4ff`,intensity:1.7},{id:`shadow`,type:`directional`,position:[1,8,2.5],color:`#ffffff`,intensity:.7,castShadow:!0,shadow:{softness:10,intensity:.75}},{id:`sky`,type:`hemisphere`,skyColor:`#ffffff`,groundColor:`#50555f`,intensity:.3}],"product-top":[{id:`top`,type:`rect`,position:[0,4.5,.5],width:3,height:3,color:`#ffffff`,intensity:6},{id:`stripL`,type:`rect`,position:[-3.2,1.6,1.2],width:.6,height:4.5,color:`#ffffff`,intensity:10},{id:`stripR`,type:`rect`,position:[3.2,1.6,1.2],width:.6,height:4.5,color:`#ffffff`,intensity:10},{id:`shadow`,type:`directional`,position:[.5,8,1.5],color:`#ffffff`,intensity:.9,castShadow:!0,shadow:{softness:8,intensity:.8}},{id:`sky`,type:`hemisphere`,skyColor:`#ffffff`,groundColor:`#30333a`,intensity:.15}],rim:[{id:`rimCool`,type:`directional`,position:[-5,3,-5],color:`#9fc4ff`,intensity:3.2,castShadow:!0,shadow:{softness:5}},{id:`rimWarm`,type:`directional`,position:[5,3,-5],color:`#ffb27a`,intensity:3},{id:`front`,type:`directional`,position:[0,2,6],color:`#ffffff`,intensity:.35},{id:`ambient`,type:`ambient`,color:`#ffffff`,intensity:.1}],dramatic:[{id:`key`,type:`spot`,position:[5,5,3],color:`#ffe2c0`,intensity:90,angle:26,penumbra:.45,castShadow:!0,shadow:{softness:3}},{id:`rim`,type:`directional`,position:[-3,4,-5],color:`#a9c2ff`,intensity:1.3},{id:`sky`,type:`hemisphere`,skyColor:`#8090b0`,groundColor:`#101012`,intensity:.08}],"golden-hour":[{id:`sun`,type:`directional`,position:[6.5,2,3],color:`#ffb46b`,intensity:3.2,castShadow:!0,shadow:{softness:5}},{id:`sky`,type:`hemisphere`,skyColor:`#8fb4ff`,groundColor:`#4a3020`,intensity:.65},{id:`bounce`,type:`directional`,position:[-4,3,4],color:`#ffd9b0`,intensity:.3}],noon:[{id:`sun`,type:`directional`,position:[2,10,3],color:`#fffaf0`,intensity:3.2,castShadow:!0,shadow:{softness:3}},{id:`sky`,type:`hemisphere`,skyColor:`#bcd8ff`,groundColor:`#6b5a45`,intensity:.75}],overcast:[{id:`sky`,type:`hemisphere`,skyColor:`#e8eef5`,groundColor:`#6f6a60`,intensity:1.4},{id:`top`,type:`directional`,position:[1,8,2],color:`#f2f5ff`,intensity:.6,castShadow:!0,shadow:{softness:14,intensity:.6}}],neon:[{id:`magenta`,type:`rect`,position:[-3.5,1.5,1.5],width:1,height:4,color:`#ff2bd6`,intensity:12},{id:`cyan`,type:`rect`,position:[3.5,1.5,1.5],width:1,height:4,color:`#22e4ff`,intensity:12},{id:`back`,type:`point`,position:[0,3,-3],color:`#7a5cff`,intensity:20},{id:`shadow`,type:`directional`,position:[0,6,3],color:`#b9a6ff`,intensity:.35,castShadow:!0,shadow:{softness:6}},{id:`ambient`,type:`ambient`,color:`#1a1030`,intensity:.25}],moonlight:[{id:`moon`,type:`directional`,position:[-4,7,-3],color:`#9db8ff`,intensity:1.6,castShadow:!0,shadow:{softness:6}},{id:`sky`,type:`hemisphere`,skyColor:`#2a3b66`,groundColor:`#0a0c14`,intensity:.5}]};Object.keys(gr);function _r(e,t,n){let r=e=>{let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t.slice(0,6);return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))};if(!/^#?[0-9a-f]{3,8}$/i.test(e)||!/^#?[0-9a-f]{3,8}$/i.test(t))return e;let i=r(e),a=r(t);return`#`+i.map((e,t)=>Math.round(e+(a[t]-e)*n).toString(16).padStart(2,`0`)).join(``)}function vr(e,t,n){let r=t*Math.PI/180,i=Math.cos(r),a=Math.sin(r);return[(e[0]*i+e[2]*a)*n,e[1]*n,(-e[0]*a+e[2]*i)*n]}function yr(e){if(!e)return[];let t=typeof e==`string`?{preset:e}:e,n=gr[t.preset],r=ze.find(e=>e.id===t.preset);if(!n||!r)return[];let i=$e(r,t),a=i.num(`intensity`),o=i.num(`rotation`),s=i.num(`scale`),c=i.bool(`castShadow`),l=typeof t.color==`string`?t.color:void 0;return n.map(e=>{let t={...e,id:`rig:${e.id}`};return e.position&&(t.position=vr(e.position,o,s)),e.target&&(t.target=vr(e.target,o,s)),e.width&&(t.width=e.width*s),e.height&&(t.height=e.height*s),e.intensity!==void 0&&(t.intensity=e.intensity*a*(e.type===`point`||e.type===`spot`?s*s:1)),l&&(t.color&&=_r(t.color,l,.45),t.skyColor&&=_r(t.skyColor,l,.45)),c||delete t.castShadow,t})}var br={sunrise:{elevation:2.5,azimuth:70,turbidity:5,rayleigh:2.4,mieCoefficient:.004,mieDirectionalG:.9,exposure:.7,haze:`#f1c1a0`},morning:{elevation:18,azimuth:110,turbidity:2.6,rayleigh:2.4,mieCoefficient:.003,mieDirectionalG:.8,exposure:.2,haze:`#b9cde4`},noon:{elevation:62,azimuth:150,turbidity:2,rayleigh:2.6,mieCoefficient:.003,mieDirectionalG:.8,exposure:.11,haze:`#a9c3e3`},afternoon:{elevation:32,azimuth:220,turbidity:2.4,rayleigh:2.6,mieCoefficient:.003,mieDirectionalG:.8,exposure:.15,haze:`#b4c8de`},"golden-hour":{elevation:6,azimuth:235,turbidity:5,rayleigh:3.6,mieCoefficient:.004,mieDirectionalG:.8,exposure:.36,haze:`#f4c08c`},sunset:{elevation:1.5,azimuth:250,turbidity:8,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.94,exposure:.8,haze:`#e9a07e`},dusk:{elevation:-3,azimuth:255,turbidity:6,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.85,exposure:6,haze:`#5a5f86`}};function xr(e){return!!e&&(e.physical===!0||e.preset!==void 0||e.turbidity!==void 0||e.rayleigh!==void 0)}function Sr(e){let t=br[e.preset??`afternoon`]??br.afternoon,n=e.sun===!1?void 0:e.sun,r=L(n?.elevation,t.elevation),i=L(n?.azimuth,t.azimuth);if(n?.direction&&n.elevation===void 0&&n.azimuth===void 0){let[e,t,a]=n.direction;r=Math.asin(t/(Math.hypot(e,t,a)||1))*180/Math.PI,i=Math.atan2(e,a)*180/Math.PI}return{elevation:r,azimuth:i,turbidity:L(e.turbidity,t.turbidity),rayleigh:L(e.rayleigh,t.rayleigh),mieCoefficient:L(e.mieCoefficient,t.mieCoefficient),mieDirectionalG:L(e.mieDirectionalG,t.mieDirectionalG),exposure:L(e.exposure,1)*t.exposure,haze:t.haze}}function Cr(e,t){let n=e*Math.PI/180,r=t*Math.PI/180;return[Math.cos(n)*Math.sin(r),Math.sin(n),Math.cos(n)*Math.cos(r)]}var wr=[[-4,`#ff6a3a`,0],[0,`#ff8a4c`,.6],[3,`#ff9a52`,1.5],[8,`#ffb46a`,2.4],[16,`#ffdcb4`,2.8],[30,`#fff0dc`,3.1],[60,`#fff8ee`,3.3]];function Tr(e){let t=wr;if(e<=t[0][0])return{color:R(t[0][1]),intensity:0};for(let n=1;n<t.length;n++){let[r,i,a]=t[n],[o,s,c]=t[n-1];if(e<=r){let t=(e-o)/(r-o);return{color:R(s).lerp(R(i),t),intensity:c+(a-c)*t}}}let n=t[t.length-1];return{color:R(n[1]),intensity:n[2]}}var Er=null;function Dr(){return Er??=import(`./chunks/Sky-DGJXlPb_.js`).then(e=>e.Sky.SkyShader),Er}var Or=`
|
|
266
|
+
}`;function pr(e,t){let n=typeof t.volumetric==`object`?t.volumetric:{},r=new Ce(1,0,1,48,24,!0);r.translate(0,.5,0),r.rotateX(Math.PI/2);let i=new N({uniforms:{..._.clone(be.fog),uColor:{value:R(n.color??t.color??`#ffffff`)},uIntensity:{value:L(n.intensity,1)},uDepth:{value:null},uUseDepth:{value:0},uViewport:{value:new f(1,1)},uNear:{value:.1},uFar:{value:1e3},uOrtho:{value:0},uGroundY:{value:0},uUseGround:{value:0},uSoft:{value:.5}},vertexShader:dr,fragmentShader:fr,transparent:!0,depthWrite:!1,blending:2,premultipliedAlpha:!0,side:2,fog:!1}),a=new F(r,i);a.name=`__volumetric`,a.userData.helper=!0,a.castShadow=!1,a.receiveShadow=!1,a.frustumCulled=!1;let o=typeof t.volumetric==`object`?t.volumetric.length:void 0,s=new h,c=new h,l=L(n.intensity,1),u=Math.max(e.intensity,.001),d,p=new h;return a.onBeforeRender=(t,r,f)=>{e.getWorldPosition(s),e.target.getWorldPosition(c);let m=o??Math.max(.5,s.distanceTo(c)*1.25),g=i.uniforms;g.uSoft.value=Math.max(.05,m*.12);let _=r.userData.a3dDepth,v=f;_&&t.getRenderTarget()?(g.uDepth.value=_.texture,g.uUseDepth.value=1,g.uViewport.value.set(_.width,_.height),g.uNear.value=v.near,g.uFar.value=v.far,g.uOrtho.value=+!!v.isOrthographicCamera):(g.uDepth.value=null,g.uUseDepth.value=0),(d===void 0||d&&!d.parent)&&(d=null,r.traverse(e=>{!d&&e.userData.ground&&(d=e)})),d&&d.visible?(d.getWorldPosition(p),g.uGroundY.value=p.y,g.uUseGround.value=1):(g.uGroundY.value=c.y,g.uUseGround.value=+(!o&&c.y<s.y-.1));let y=Math.tan(Math.min(e.angle,1.5))*m,b=new T().setFromUnitVectors(new h(0,0,1),c.clone().sub(s).normalize()),x=e.getWorldQuaternion(new T).invert();a.quaternion.copy(x.multiply(b)),a.scale.set(y,y,m),a.position.set(0,0,0),a.updateMatrixWorld(!0),i.uniforms.uColor.value.copy(n.color?R(n.color):e.color),i.uniforms.uIntensity.value=l*Math.min(3,e.intensity/u)},a}async function mr(e,n){let r=R(e.color??`#ffffff`),i=L(e.intensity,or[e.type]??1),a;switch(e.type){case`ambient`:a=new _e(r,i);break;case`hemisphere`:a=new E(R(e.skyColor??e.color??`#ffffff`),R(e.groundColor??`#444444`),i),a.position.set(0,10,0);break;case`point`:a=new De(r,i,L(e.distance,0),L(e.decay,2));break;case`spot`:a=new M(r,i,L(e.distance,0),L(e.angle,30)*U,L(e.penumbra,.3),L(e.decay,2));break;case`rect`:await ar(),a=new D(r,i,L(e.width,2),L(e.height,2));break;default:a=new t(r,i)}let o=e.position??(e.type===`directional`?[5,10,7]:e.type===`spot`?[3,6,4]:[0,3,3]);e.type!==`ambient`&&e.type!==`hemisphere`&&a.position.set(o[0],o[1],o[2]);let s=e.target??[0,0,0];return a instanceof t||a instanceof M?a.target.position.set(s[0],s[1],s[2]):a instanceof D&&(a.lookAt(s[0],s[1],s[2]),e.panel&&a.add(ur(a))),e.castShadow&&(a instanceof t||a instanceof M||a instanceof De)&&lr(a,e,n),e.volumetric&&a instanceof M&&a.add(pr(a,e)),a.name=e.id??e.type,a.userData.baseIntensity=i,a.userData.baseColor=r.clone(),a}function hr(e,t){if(t.isEmpty())return;let n=e.shadow.camera;e.updateMatrixWorld(),e.target.updateMatrixWorld();let r=new h().setFromMatrixPosition(e.matrixWorld),i=new h().setFromMatrixPosition(e.target.matrixWorld),a=new P().lookAt(r,i,new h(0,1,0));a.setPosition(r);let o=a.clone().invert(),s=new j,c=new h;for(let e=0;e<8;e++)c.set(e&1?t.max.x:t.min.x,e&2?t.max.y:t.min.y,e&4?t.max.z:t.min.z).applyMatrix4(o),s.expandByPoint(c);let l=.5;n.left=s.min.x-l,n.right=s.max.x+l,n.bottom=s.min.y-l,n.top=s.max.y+l,n.near=Math.max(.01,-s.max.z-l),n.far=-s.min.z+l,n.updateProjectionMatrix();let u=Math.max(n.right-n.left,n.top-n.bottom)/e.shadow.mapSize.x;e.userData.fixedNormalBias||(e.shadow.normalBias=Math.max(.01,u*1.5))}var gr={"studio-3point":[{id:`key`,type:`directional`,position:[4,6,5],color:`#fff1e0`,intensity:2.6,castShadow:!0,shadow:{softness:6}},{id:`fill`,type:`directional`,position:[-5,2.5,3],color:`#dbe6ff`,intensity:.8},{id:`rim`,type:`directional`,position:[-1.5,4,-6],color:`#ffffff`,intensity:2.2},{id:`sky`,type:`hemisphere`,skyColor:`#ffffff`,groundColor:`#3a3f4a`,intensity:.35}],softbox:[{id:`top`,type:`rect`,position:[0,5,1.5],width:5,height:5,color:`#ffffff`,intensity:2.1},{id:`left`,type:`rect`,position:[-4.5,2,2.5],width:2,height:4.5,color:`#fff6ee`,intensity:2.6},{id:`right`,type:`rect`,position:[4.5,2,2.5],width:2,height:4.5,color:`#eef4ff`,intensity:1.7},{id:`shadow`,type:`directional`,position:[1,8,2.5],color:`#ffffff`,intensity:.7,castShadow:!0,shadow:{softness:10,intensity:.75}},{id:`sky`,type:`hemisphere`,skyColor:`#ffffff`,groundColor:`#50555f`,intensity:.3}],"product-top":[{id:`top`,type:`rect`,position:[0,4.5,.5],width:3,height:3,color:`#ffffff`,intensity:6},{id:`stripL`,type:`rect`,position:[-3.2,1.6,1.2],width:.6,height:4.5,color:`#ffffff`,intensity:10},{id:`stripR`,type:`rect`,position:[3.2,1.6,1.2],width:.6,height:4.5,color:`#ffffff`,intensity:10},{id:`shadow`,type:`directional`,position:[.5,8,1.5],color:`#ffffff`,intensity:.9,castShadow:!0,shadow:{softness:8,intensity:.8}},{id:`sky`,type:`hemisphere`,skyColor:`#ffffff`,groundColor:`#30333a`,intensity:.15}],rim:[{id:`rimCool`,type:`directional`,position:[-5,3,-5],color:`#9fc4ff`,intensity:3.2,castShadow:!0,shadow:{softness:5}},{id:`rimWarm`,type:`directional`,position:[5,3,-5],color:`#ffb27a`,intensity:3},{id:`front`,type:`directional`,position:[0,2,6],color:`#ffffff`,intensity:.35},{id:`ambient`,type:`ambient`,color:`#ffffff`,intensity:.1}],dramatic:[{id:`key`,type:`spot`,position:[5,5,3],color:`#ffe2c0`,intensity:90,angle:26,penumbra:.45,castShadow:!0,shadow:{softness:3}},{id:`rim`,type:`directional`,position:[-3,4,-5],color:`#a9c2ff`,intensity:1.3},{id:`sky`,type:`hemisphere`,skyColor:`#8090b0`,groundColor:`#101012`,intensity:.08}],"golden-hour":[{id:`sun`,type:`directional`,position:[6.5,2,3],color:`#ffb46b`,intensity:3.2,castShadow:!0,shadow:{softness:5}},{id:`sky`,type:`hemisphere`,skyColor:`#8fb4ff`,groundColor:`#4a3020`,intensity:.65},{id:`bounce`,type:`directional`,position:[-4,3,4],color:`#ffd9b0`,intensity:.3}],noon:[{id:`sun`,type:`directional`,position:[2,10,3],color:`#fffaf0`,intensity:3.2,castShadow:!0,shadow:{softness:3}},{id:`sky`,type:`hemisphere`,skyColor:`#bcd8ff`,groundColor:`#6b5a45`,intensity:.75}],overcast:[{id:`sky`,type:`hemisphere`,skyColor:`#e8eef5`,groundColor:`#6f6a60`,intensity:1.4},{id:`top`,type:`directional`,position:[1,8,2],color:`#f2f5ff`,intensity:.6,castShadow:!0,shadow:{softness:14,intensity:.6}}],neon:[{id:`magenta`,type:`rect`,position:[-3.5,1.5,1.5],width:1,height:4,color:`#ff2bd6`,intensity:12},{id:`cyan`,type:`rect`,position:[3.5,1.5,1.5],width:1,height:4,color:`#22e4ff`,intensity:12},{id:`back`,type:`point`,position:[0,3,-3],color:`#7a5cff`,intensity:20},{id:`shadow`,type:`directional`,position:[0,6,3],color:`#b9a6ff`,intensity:.35,castShadow:!0,shadow:{softness:6}},{id:`ambient`,type:`ambient`,color:`#1a1030`,intensity:.25}],moonlight:[{id:`moon`,type:`directional`,position:[-4,7,-3],color:`#9db8ff`,intensity:1.6,castShadow:!0,shadow:{softness:6}},{id:`sky`,type:`hemisphere`,skyColor:`#2a3b66`,groundColor:`#0a0c14`,intensity:.5}]};Object.keys(gr);function _r(e,t,n){let r=e=>{let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t.slice(0,6);return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))};if(!/^#?[0-9a-f]{3,8}$/i.test(e)||!/^#?[0-9a-f]{3,8}$/i.test(t))return e;let i=r(e),a=r(t);return`#`+i.map((e,t)=>Math.round(e+(a[t]-e)*n).toString(16).padStart(2,`0`)).join(``)}function vr(e,t,n){let r=t*Math.PI/180,i=Math.cos(r),a=Math.sin(r);return[(e[0]*i+e[2]*a)*n,e[1]*n,(-e[0]*a+e[2]*i)*n]}function yr(e){if(!e)return[];let t=typeof e==`string`?{preset:e}:e,n=gr[t.preset],r=Pe.find(e=>e.id===t.preset);if(!n||!r)return[];let i=$e(r,t),a=i.num(`intensity`),o=i.num(`rotation`),s=i.num(`scale`),c=i.bool(`castShadow`),l=typeof t.color==`string`?t.color:void 0;return n.map(e=>{let t={...e,id:`rig:${e.id}`};return e.position&&(t.position=vr(e.position,o,s)),e.target&&(t.target=vr(e.target,o,s)),e.width&&(t.width=e.width*s),e.height&&(t.height=e.height*s),e.intensity!==void 0&&(t.intensity=e.intensity*a*(e.type===`point`||e.type===`spot`?s*s:1)),l&&(t.color&&=_r(t.color,l,.45),t.skyColor&&=_r(t.skyColor,l,.45)),c||delete t.castShadow,t})}var br={sunrise:{elevation:2.5,azimuth:70,turbidity:5,rayleigh:2.4,mieCoefficient:.004,mieDirectionalG:.9,exposure:.7,haze:`#f1c1a0`},morning:{elevation:18,azimuth:110,turbidity:2.6,rayleigh:2.4,mieCoefficient:.003,mieDirectionalG:.8,exposure:.2,haze:`#b9cde4`},noon:{elevation:62,azimuth:150,turbidity:2,rayleigh:2.6,mieCoefficient:.003,mieDirectionalG:.8,exposure:.11,haze:`#a9c3e3`},afternoon:{elevation:32,azimuth:220,turbidity:2.4,rayleigh:2.6,mieCoefficient:.003,mieDirectionalG:.8,exposure:.15,haze:`#b4c8de`},"golden-hour":{elevation:6,azimuth:235,turbidity:5,rayleigh:3.6,mieCoefficient:.004,mieDirectionalG:.8,exposure:.36,haze:`#f4c08c`},sunset:{elevation:1.5,azimuth:250,turbidity:8,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.94,exposure:.8,haze:`#e9a07e`},dusk:{elevation:-3,azimuth:255,turbidity:6,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.85,exposure:6,haze:`#5a5f86`}};function xr(e){return!!e&&(e.physical===!0||e.preset!==void 0||e.turbidity!==void 0||e.rayleigh!==void 0)}function Sr(e){let t=br[e.preset??`afternoon`]??br.afternoon,n=e.sun===!1?void 0:e.sun,r=L(n?.elevation,t.elevation),i=L(n?.azimuth,t.azimuth);if(n?.direction&&n.elevation===void 0&&n.azimuth===void 0){let[e,t,a]=n.direction;r=Math.asin(t/(Math.hypot(e,t,a)||1))*180/Math.PI,i=Math.atan2(e,a)*180/Math.PI}return{elevation:r,azimuth:i,turbidity:L(e.turbidity,t.turbidity),rayleigh:L(e.rayleigh,t.rayleigh),mieCoefficient:L(e.mieCoefficient,t.mieCoefficient),mieDirectionalG:L(e.mieDirectionalG,t.mieDirectionalG),exposure:L(e.exposure,1)*t.exposure,haze:t.haze}}function Cr(e,t){let n=e*Math.PI/180,r=t*Math.PI/180;return[Math.cos(n)*Math.sin(r),Math.sin(n),Math.cos(n)*Math.cos(r)]}var wr=[[-4,`#ff6a3a`,0],[0,`#ff8a4c`,.6],[3,`#ff9a52`,1.5],[8,`#ffb46a`,2.4],[16,`#ffdcb4`,2.8],[30,`#fff0dc`,3.1],[60,`#fff8ee`,3.3]];function Tr(e){let t=wr;if(e<=t[0][0])return{color:R(t[0][1]),intensity:0};for(let n=1;n<t.length;n++){let[r,i,a]=t[n],[o,s,c]=t[n-1];if(e<=r){let t=(e-o)/(r-o);return{color:R(s).lerp(R(i),t),intensity:c+(a-c)*t}}}let n=t[t.length-1];return{color:R(n[1]),intensity:n[2]}}var Er=null;function Dr(){return Er??=import(`./chunks/Sky-DGJXlPb_.js`).then(e=>e.Sky.SkyShader),Er}var Or=`
|
|
267
267
|
uniform float uStars;
|
|
268
268
|
uniform float uTime;
|
|
269
269
|
uniform float uExposure;
|
|
@@ -336,7 +336,7 @@ void main() {
|
|
|
336
336
|
gl_FragColor = vec4(col, 1.0);
|
|
337
337
|
#include <tonemapping_fragment>
|
|
338
338
|
#include <colorspace_fragment>
|
|
339
|
-
}`;function Pr(e,t){let n=e.sun===!1?null:e.sun??{},r=z(n?.direction,[.4,.35,-1]);if(n&&(n.elevation!==void 0||n.azimuth!==void 0)&&!n.direction){let e=L(n.elevation,20)*U,t=L(n.azimuth,180)*U;r=[Math.cos(e)*Math.sin(t),Math.sin(e),Math.cos(e)*Math.cos(t)]}let i=new N({uniforms:{uTop:{value:R(e.top??`#2f6fd6`)},uHorizon:{value:R(e.horizon??`#cfe6ff`)},uBottom:{value:R(e.bottom??e.horizon??`#e8eef5`)},uSunDir:{value:new h(...r).normalize()},uSunColor:{value:R(n?.color??`#fff2d6`)},uSunSize:{value:L(n?.size,1)},uSun:{value:+!!n},uStars:{value:Math.min(.5,L(e.stars,0)/2e4)},uTime:{value:0}},vertexShader:Mr,fragmentShader:Nr,side:1,depthWrite:!1,depthTest:!1}),a=new F(new ce(1,48,24),i);return a.frustumCulled=!1,a.renderOrder=-1e3,a.name=`__sky`,a.userData.helper=!0,t.onUpdate(e=>i.uniforms.uTime.value=e),a}function Fr(e,t,n,r,i=!0){let a=new ge,o=new ce(10,64,32),s=o.getAttribute(`position`),c=new Float32Array(s.count*3),l=R(e),u=R(t),d=R(n),f=new k;for(let e=0;e<s.count;e++){let t=s.getY(e)/10;t>=0?f.copy(u).lerp(l,t**.6):f.copy(u).lerp(d,(-t)**.5),c[e*3]=f.r,c[e*3+1]=f.g,c[e*3+2]=f.b}if(o.setAttribute(`color`,new ve(c,3)),a.add(new F(o,new A({vertexColors:!0,side:1,toneMapped:!1}))),r){let e=new F(new Se(r.size,32),new A({color:R(r.color).multiplyScalar(r.power),side:2,toneMapped:!1}));e.position.copy(r.dir.clone().normalize().multiplyScalar(9)),e.lookAt(0,0,0),a.add(e)}if(i){let e=new A({color:R(t).multiplyScalar(1.6),side:2,toneMapped:!1});for(let t=0;t<3;t++){let n=t/3*Math.PI*2+.6,r=new F(new b(5,1.4),e);r.position.set(Math.cos(n)*9,1.5,Math.sin(n)*9),r.lookAt(0,1.5,0),a.add(r)}}return a}function Ir(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}async function Lr(e){let t=e.toLowerCase().split(`?`)[0],n;if(t.endsWith(`.hdr`)){let{HDRLoader:t}=await import(`./chunks/HDRLoader-DBOMWa7O.js`);n=await new t().loadAsync(e)}else if(t.endsWith(`.exr`)){let{EXRLoader:t}=await import(`./chunks/EXRLoader-CBdIpBMT.js`);n=await new t().loadAsync(e)}else n=await
|
|
339
|
+
}`;function Pr(e,t){let n=e.sun===!1?null:e.sun??{},r=z(n?.direction,[.4,.35,-1]);if(n&&(n.elevation!==void 0||n.azimuth!==void 0)&&!n.direction){let e=L(n.elevation,20)*U,t=L(n.azimuth,180)*U;r=[Math.cos(e)*Math.sin(t),Math.sin(e),Math.cos(e)*Math.cos(t)]}let i=new N({uniforms:{uTop:{value:R(e.top??`#2f6fd6`)},uHorizon:{value:R(e.horizon??`#cfe6ff`)},uBottom:{value:R(e.bottom??e.horizon??`#e8eef5`)},uSunDir:{value:new h(...r).normalize()},uSunColor:{value:R(n?.color??`#fff2d6`)},uSunSize:{value:L(n?.size,1)},uSun:{value:+!!n},uStars:{value:Math.min(.5,L(e.stars,0)/2e4)},uTime:{value:0}},vertexShader:Mr,fragmentShader:Nr,side:1,depthWrite:!1,depthTest:!1}),a=new F(new ce(1,48,24),i);return a.frustumCulled=!1,a.renderOrder=-1e3,a.name=`__sky`,a.userData.helper=!0,t.onUpdate(e=>i.uniforms.uTime.value=e),a}function Fr(e,t,n,r,i=!0){let a=new ge,o=new ce(10,64,32),s=o.getAttribute(`position`),c=new Float32Array(s.count*3),l=R(e),u=R(t),d=R(n),f=new k;for(let e=0;e<s.count;e++){let t=s.getY(e)/10;t>=0?f.copy(u).lerp(l,t**.6):f.copy(u).lerp(d,(-t)**.5),c[e*3]=f.r,c[e*3+1]=f.g,c[e*3+2]=f.b}if(o.setAttribute(`color`,new ve(c,3)),a.add(new F(o,new A({vertexColors:!0,side:1,toneMapped:!1}))),r){let e=new F(new Se(r.size,32),new A({color:R(r.color).multiplyScalar(r.power),side:2,toneMapped:!1}));e.position.copy(r.dir.clone().normalize().multiplyScalar(9)),e.lookAt(0,0,0),a.add(e)}if(i){let e=new A({color:R(t).multiplyScalar(1.6),side:2,toneMapped:!1});for(let t=0;t<3;t++){let n=t/3*Math.PI*2+.6,r=new F(new b(5,1.4),e);r.position.set(Math.cos(n)*9,1.5,Math.sin(n)*9),r.lookAt(0,1.5,0),a.add(r)}}return a}function Ir(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}async function Lr(e){let t=e.toLowerCase().split(`?`)[0],n;if(t.endsWith(`.hdr`)){let{HDRLoader:t}=await import(`./chunks/HDRLoader-DBOMWa7O.js`);n=await new t().loadAsync(e)}else if(t.endsWith(`.exr`)){let{EXRLoader:t}=await import(`./chunks/EXRLoader-CBdIpBMT.js`);n=await new t().loadAsync(e)}else n=await Oe(e),n.colorSpace=ae;return n.mapping=303,n}function Rr(e,t){let n=new i({color:e,roughness:t,metalness:0,transparent:!0});return n.onBeforeCompile=e=>{e.vertexShader=`varying vec2 vGroundUv;
|
|
340
340
|
`+e.vertexShader.replace(`#include <begin_vertex>`,`#include <begin_vertex>
|
|
341
341
|
vGroundUv = uv;`),e.fragmentShader=`varying vec2 vGroundUv;
|
|
342
342
|
`+e.fragmentShader.replace(`#include <alphamap_fragment>`,`#include <alphamap_fragment>
|
|
@@ -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-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=`
|
|
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=Fe.find(t=>t.id===e.type),r=t(ze(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=je(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=Je(t),i=r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map,a=await qe(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,Ke(a,e.geometry)}rngFor(e,t){return Ge(t??We(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`&&e.kind!==`photo`;try{switch(e.kind){case`mesh`:{let t=qr(e.geometry),n=await qe(e.material,i,{defaultColor:`#dddddd`});Ke(n,t),a=new F(t,n);break}case`text`:{let{buildText:t}=await import(`./chunks/text-rSo_2Luk.js`),n=await i.track(t(e,i));a=n.object,u=n.letters;break}case`svg`:{let{buildSvg:t}=await import(`./chunks/svg-CLUxY6Zy.js`);a=await i.track(t(e,i));break}case`photo`:{let{buildPhoto:t}=await import(`./chunks/photo-DNf14X7B.js`),n=await i.track(t(e,i));a=n.object,s={object:n.object,dispose:()=>n.dispose()},this.updaters.push((e,t)=>n.update(e,t,{pointer:this.input.pointer,scroll:this.input.scroll,camera:this.camera??null,reduced:this.settleEntrances}));break}case`model`:{let{buildModel:t}=await import(`./chunks/model-BCAl_NRl.js`),n=await i.track(t(e,i));a=n.object,c=n.animator;break}case`instances`:{let t=qr(e.geometry),n=await qe(e.material,i,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});Ke(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=Ie.find(t=>t.id===e.generator),c=ze(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`||e.kind===`photo`?`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(),Le(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=Ae(`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=ke(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=Ae(Me(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:Ge(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:Ae(`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=Ne(this.quality.tier);n?(this.quality=Ae(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}
|