@fleox/agent3d 0.4.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +45 -14
  2. package/changelog.json +24 -0
  3. package/dist/agent/agent3d.mjs +779 -85
  4. package/dist/agent/chunks/{assets-YBkgdfgy.mjs → assets-DdzHgVcn.mjs} +2 -2
  5. package/dist/agent/chunks/{browser-Dil7VM5m.mjs → browser-nFaRUETt.mjs} +1 -1
  6. package/dist/agent/chunks/{cdp-DLEis_Z3.mjs → cdp-6vF_gP-H.mjs} +1 -1
  7. package/dist/agent/chunks/{check-DP9fRYbK.mjs → check-E7GdPxTt.mjs} +14 -2
  8. package/dist/agent/chunks/{depth-CD_ql3QJ.mjs → depth-Bf7cHwod.mjs} +4 -4
  9. package/dist/agent/chunks/{depth-BZT4gseQ.mjs → depth-DEaogEAi.mjs} +4 -114
  10. package/dist/agent/chunks/{export-CEX5DFLo.mjs → export-BSOqVfPT.mjs} +8 -4
  11. package/dist/agent/chunks/{imageCodec-DeGfmBp3.mjs → imageCodec-DXxqkEQA.mjs} +53 -4
  12. package/dist/agent/chunks/{objects-DuytRxiC.mjs → objects-DvzrcVmK.mjs} +2 -2
  13. package/dist/agent/chunks/{optimizeSizing-B-BBiUkD.mjs → optimizeSizing-Dd8vaSnE.mjs} +24 -1
  14. package/dist/agent/chunks/{package-DjRnLzcU.mjs → package-Bn7PKfXn.mjs} +1 -1
  15. package/dist/agent/chunks/photoPlacement-D-k3mD0T.mjs +138 -0
  16. package/dist/agent/chunks/plate-Cwl35I2T.mjs +604 -0
  17. package/dist/agent/chunks/pngEncode-BMc3U9QC.mjs +119 -0
  18. package/dist/agent/chunks/{render-B05DU4Q5.mjs → render-CCKciCgu.mjs} +76 -11
  19. package/dist/agent/chunks/{scene-DWgXH6As.mjs → scene-DSjsun-3.mjs} +22 -5
  20. package/dist/agent/chunks/{server-Dt_YFvN7.mjs → server-CLvLORgA.mjs} +1 -1
  21. package/dist/agent/chunks/{tools-CZyIc4zw.mjs → tools-Vs74Xopx.mjs} +142 -13
  22. package/dist/runtime/agent3d-photo.js +51 -10
  23. package/dist/runtime/agent3d-runtime.js +23 -23
  24. package/dist/runtime/agent3d-runtime.single.js +405 -134
  25. package/dist/runtime/chunks/photo-Dq-AKlfw.js +526 -0
  26. package/dist/studio/assets/BufferGeometryUtils-BbzK4rCj.js +1 -0
  27. package/dist/studio/assets/{EXRLoader-BKkzlNd8.js → EXRLoader-CuDOo1xG.js} +1 -1
  28. package/dist/studio/assets/{FontLoader-Bzjx8mXt.js → FontLoader-DlBfss5q.js} +1 -1
  29. package/dist/studio/assets/{GLTFLoader-1Zd9N406.js → GLTFLoader-bl1eymL4.js} +1 -1
  30. package/dist/studio/assets/{GroundedSkybox-BEMqNCBD.js → GroundedSkybox-cLn9JVlt.js} +1 -1
  31. package/dist/studio/assets/{HDRLoader-DxB0kxPH.js → HDRLoader-8EiZoQQP.js} +1 -1
  32. package/dist/studio/assets/{OrbitControls-MlE9XiCg.js → OrbitControls-1xEm394I.js} +1 -1
  33. package/dist/studio/assets/{RectAreaLightUniformsLib-ClHrtYY6.js → RectAreaLightUniformsLib-S0AelTmO.js} +1 -1
  34. package/dist/studio/assets/{RoomEnvironment-MJ-jIEC8.js → RoomEnvironment-v4QurKxu.js} +1 -1
  35. package/dist/studio/assets/{SVGLoader-CIYl0nEy.js → SVGLoader-KDBVv02P.js} +1 -1
  36. package/dist/studio/assets/{Sky-DNMfpp92.js → Sky-D8Lp9Zh3.js} +1 -1
  37. package/dist/studio/assets/assets-DICv7P37.js +2 -0
  38. package/dist/studio/assets/camera-HsMeC1mn.js +2 -0
  39. package/dist/studio/assets/catalog-DDg904x2.js +1 -0
  40. package/dist/studio/assets/{editor-DzyukvQl.js → editor-BZLIZJC8.js} +1 -1
  41. package/dist/studio/assets/{extrude-9bG8hr2C.js → extrude-BpJda0hq.js} +1 -1
  42. package/dist/studio/assets/game-DnnuBk26.js +19 -0
  43. package/dist/studio/assets/{generators-BuVeRXnC.js → generators-C4n9MsXd.js} +1 -1
  44. package/dist/studio/assets/index-D-TPNQMQ.css +1 -0
  45. package/dist/studio/assets/index-cDbmaVDl.js +479 -0
  46. package/dist/studio/assets/model-CkPfLOl0.js +2 -0
  47. package/dist/studio/assets/params-BZqUA__U.js +1 -0
  48. package/dist/studio/assets/photo-CPGGCRa-.js +526 -0
  49. package/dist/studio/assets/{physicsHost-z9qn_mpg.js → physicsHost-EkPuIy04.js} +1 -1
  50. package/dist/studio/assets/{postfx-B3jDEaEK.js → postfx-Dp7mgfGJ.js} +2 -2
  51. package/dist/studio/assets/rolldown-runtime-4tVxZq34.js +1 -0
  52. package/dist/studio/assets/runtime-ByR4qfyV.js +572 -0
  53. package/dist/studio/assets/{shaders-bFhELLmD.js → shaders-DoRMwJE_.js} +1 -1
  54. package/dist/studio/assets/svg-n3rkKAm5.js +2 -0
  55. package/dist/studio/assets/text-BkPPDghK.js +3 -0
  56. package/dist/studio/assets/three.module-B9FlcKtd.js +4225 -0
  57. package/dist/studio/index.html +5 -3
  58. package/package.json +1 -1
  59. package/plugin/.claude-plugin/plugin.json +1 -1
  60. package/plugin/skills/agent3d-assets/SKILL.md +42 -27
  61. package/plugin/skills/agent3d-create/SKILL.md +77 -29
  62. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  63. package/plugin/skills/agent3d-create/references/recipes.md +6 -6
  64. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  65. package/plugin/skills/agent3d-edit/references/patch-ops.md +3 -3
  66. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  67. package/plugin/skills/agent3d-publish/SKILL.md +30 -23
  68. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  69. package/templates/hero-scroll-story/README.md +1 -1
  70. package/templates/photo-scroll-story/README.md +29 -0
  71. package/templates/photo-scroll-story/agent3d.json +8 -0
  72. package/templates/photo-scroll-story/assets/depth/lake-depth.png +0 -0
  73. package/templates/photo-scroll-story/assets/depth/street-depth.png +0 -0
  74. package/templates/photo-scroll-story/assets/manifest.json +46 -0
  75. package/templates/photo-scroll-story/assets/textures/lake.webp +0 -0
  76. package/templates/photo-scroll-story/assets/textures/street.webp +0 -0
  77. package/templates/photo-scroll-story/preview.png +0 -0
  78. package/templates/photo-scroll-story/scene.json +112 -0
  79. package/templates/photo-scroll-story/template.json +8 -0
  80. package/templates/photo-title-inside/README.md +31 -0
  81. package/templates/photo-title-inside/agent3d.json +8 -0
  82. package/templates/photo-title-inside/assets/depth/street-depth.png +0 -0
  83. package/templates/photo-title-inside/assets/manifest.json +25 -0
  84. package/templates/photo-title-inside/assets/textures/street.webp +0 -0
  85. package/templates/photo-title-inside/preview.png +0 -0
  86. package/templates/photo-title-inside/scene.json +80 -0
  87. package/templates/photo-title-inside/template.json +8 -0
  88. package/dist/runtime/chunks/photo-w6dwHX7j.js +0 -255
  89. package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +0 -1
  90. package/dist/studio/assets/assets--ehPZf8R.js +0 -1
  91. package/dist/studio/assets/camera-C0sxfRxy.js +0 -2
  92. package/dist/studio/assets/game-DNpTN_Ga.js +0 -19
  93. package/dist/studio/assets/index-BQT0otii.css +0 -1
  94. package/dist/studio/assets/index-C2nMYSoW.js +0 -479
  95. package/dist/studio/assets/model-DQgOrTs4.js +0 -2
  96. package/dist/studio/assets/params-D-Ul6GSt.js +0 -1
  97. package/dist/studio/assets/photo-Dx2IBJ11.js +0 -255
  98. package/dist/studio/assets/runtime-rd9RW3WH.js +0 -572
  99. package/dist/studio/assets/svg-BkV9LeqP.js +0 -2
  100. package/dist/studio/assets/text-Dp8gdjSA.js +0 -3
  101. package/dist/studio/assets/three.module-CnI50X0U.js +0 -4225
@@ -1,4 +1,4 @@
1
- var e=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,t=e=>Array.isArray(e)?e.length>0:e!=null&&e!==!1;function n(n){let r=[],i=(e,t)=>{e&&r.push(t)},a=n??{};i((a.target??{}).kind===`game`,`target.kind is game`),i(t(a.timeline),`timeline`),i(t(a.interactions),`interactions`),i(t(a.postfx),`post effects (postfx)`),i(t(a.physics),`physics`),i(t(a.scripts),`scripts`),i(a.ui?.elements?.length,`ui (HUD)`),i(t(a.audio),`audio`),i(/\{data\./.test(JSON.stringify(n??{})),`data bindings ({data.*} placeholders)`);let o=a.camera;!o||o.type!==`perspective`?r.push(`camera is not perspective`):(i(o.controls&&o.controls!==`none`,`camera.controls "${o.controls}"`),i(o.autoRotate,`camera.autoRotate`),i(t(o.shots),`camera.shots`),i(o.shake,`camera.shake`),i(o.lookAt,`camera.lookAt`),i(o.follow,`camera.follow`));let s=a.environment,c=s?.background;i(c!==void 0&&(typeof c!=`string`||c!==`transparent`&&!e.test(c)),`environment.background is not a #hex colour or transparent`),i(s?.ground,`environment.ground`),i(s?.contactShadows,`environment.contactShadows`),i(s?.rig,`environment.rig (light rig)`);for(let e of a.lights??[])i(e.type===`rect`,`rect lights (visible panels)`),i(e.type===`spot`&&e.volumetric,`volumetric spot lights`);let l=a.objects??[];l.length!==1&&r.push(`${l.length} objects (the lite runtime shows exactly one photo)`);let u=l[0];if(u&&u.kind!==`photo`)r.push(`object "${u.id}" is a ${u.kind}, not a photo`);else if(u){let n=u;i(!!n.depth&&n.mode&&n.mode!==`parallax`,`photo mode "${n.mode}" (lite: parallax or a flat photo)`),i(t(n.children),`photo has children`),i(n.visible===!1,`photo is hidden`),i(t(n.behaviours),`photo behaviours`),i(n.body,`photo physics body`),i(n.href,`photo link (href)`),i(n.attach,`photo attached to the camera`),i(Array.isArray(n.rotation)&&n.rotation.some(e=>e!==0),`photo is rotated`);let r=n.scale;i(r!==void 0&&(typeof r==`number`?!(r>0):!Array.isArray(r)||!(r[0]>0&&r[1]>0)),`photo scale is not positive`),i(n.material?.color!==void 0&&!(typeof n.material.color==`string`&&e.test(n.material.color)),`photo material.color is not a #hex colour`),i(typeof n.src!=`string`||!n.src,`photo has no src`)}return r.length?{ok:!1,reasons:r}:{ok:!0}}var r=/\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;function i(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function a(e){return typeof e!=`string`||!e.includes(`{data.`)?!1:(r.lastIndex=0,r.test(e))}function o(e,t){return e.includes(`{data.`)?e.replace(r,(e,n,r)=>{let a=i(t,n);return a==null||a===``?r??``:typeof a==`object`?JSON.stringify(a):String(a)}):e}var s=/^\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}$/;function c(e,t){if(typeof e!=`string`||!e.includes(`{data.`))return e;let n=s.exec(e.trim());if(!n)return o(e,t);let r=i(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 l(e,t=e.data){let n=!1,r=e=>a(e)?(n=!0,o(e,t)):e,i=e=>{if(typeof e==`string`)return a(e)?(n=!0,c(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},s=e=>{let t=e,n=t.kind===`text`?r(t.text):t.text,a=r(t.href),o=t.kind===`generator`&&t.params?i(t.params):t.params,c=e.children?.map(s);return n===t.text&&a===t.href&&o===t.params&&(!c||c.every((t,n)=>t===e.children[n]))?e:{...e,...t.kind===`text`?{text:n}:{},...t.href===void 0?{}:{href:a},...o===t.params?{}:{params:o},...c?{children:c}:{}}},l=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`||!a(t.openUrl)?e:{...t,openUrl:r(t.openUrl)}});return n.every((e,n)=>e===t[n])?e:{...e,do:n}}),u=(e.objects??[]).map(s),d=r(e.title),f=r(e.ariaLabel),p=e.ui?.elements?.map(e=>{let t=e,n=r(t.text);return n===t.text?e:{...e,text:n}});return n?{...e,title:d,...e.ariaLabel===void 0?{}:{ariaLabel:f},objects:u,...e.ui&&p?{ui:{...e.ui,elements:p}}:{},...l?{interactions:l}:{}}:e}function u(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 d=typeof HTMLElement<`u`?HTMLElement:class{},f=`
1
+ var e=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,t=e=>Array.isArray(e)?e.length>0:e!=null&&e!==!1;function n(n){let r=[],i=(e,t)=>{e&&r.push(t)},a=n??{};i((a.target??{}).kind===`game`,`target.kind is game`),i(t(a.timeline),`timeline`),i(t(a.interactions),`interactions`),i(t(a.postfx),`post effects (postfx)`),i(t(a.physics),`physics`),i(t(a.scripts),`scripts`),i(a.ui?.elements?.length,`ui (HUD)`),i(t(a.audio),`audio`),i(/\{data\./.test(JSON.stringify(n??{})),`data bindings ({data.*} placeholders)`);let o=a.camera;!o||o.type!==`perspective`?r.push(`camera is not perspective`):(i(o.controls&&o.controls!==`none`,`camera.controls "${o.controls}"`),i(o.autoRotate,`camera.autoRotate`),i(t(o.shots),`camera.shots`),i(o.shake,`camera.shake`),i(o.lookAt,`camera.lookAt`),i(o.follow,`camera.follow`));let s=a.environment,c=s?.background;i(c!==void 0&&(typeof c!=`string`||c!==`transparent`&&!e.test(c)),`environment.background is not a #hex colour or transparent`),i(s?.ground,`environment.ground`),i(s?.contactShadows,`environment.contactShadows`),i(s?.rig,`environment.rig (light rig)`);for(let e of a.lights??[])i(e.type===`rect`,`rect lights (visible panels)`),i(e.type===`spot`&&e.volumetric,`volumetric spot lights`);let l=a.objects??[];l.length!==1&&r.push(`${l.length} objects (the lite runtime shows exactly one photo)`);let u=l[0];if(u&&u.kind!==`photo`)r.push(`object "${u.id}" is a ${u.kind}, not a photo`);else if(u){let n=u;i(!!n.depth&&n.mode&&n.mode!==`parallax`,`photo mode "${n.mode}" (lite: parallax or a flat photo)`),i(t(n.children),`photo has children`),i(n.visible===!1,`photo is hidden`),i(t(n.behaviours),`photo behaviours`),i(n.body,`photo physics body`),i(n.href,`photo link (href)`),i(n.attach,`photo attached to the camera`),i(Array.isArray(n.rotation)&&n.rotation.some(e=>e!==0),`photo is rotated`);let r=n.scale;i(r!==void 0&&(typeof r==`number`?!(r>0):!Array.isArray(r)||!(r[0]>0&&r[1]>0)),`photo scale is not positive`),i(n.material?.color!==void 0&&!(typeof n.material.color==`string`&&e.test(n.material.color)),`photo material.color is not a #hex colour`),i(typeof n.src!=`string`||!n.src,`photo has no src`);for(let[t,r]of Object.entries(n.effects??{})){let n=r?.color;i(n!==void 0&&!(typeof n==`string`&&e.test(n)),`photo effects.${t}.color is not a #hex colour`)}}return r.length?{ok:!1,reasons:r}:{ok:!0}}var r=/\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;function i(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function a(e){return typeof e!=`string`||!e.includes(`{data.`)?!1:(r.lastIndex=0,r.test(e))}function o(e,t){return e.includes(`{data.`)?e.replace(r,(e,n,r)=>{let a=i(t,n);return a==null||a===``?r??``:typeof a==`object`?JSON.stringify(a):String(a)}):e}var s=/^\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}$/;function c(e,t){if(typeof e!=`string`||!e.includes(`{data.`))return e;let n=s.exec(e.trim());if(!n)return o(e,t);let r=i(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 l(e,t=e.data){let n=!1,r=e=>a(e)?(n=!0,o(e,t)):e,i=e=>{if(typeof e==`string`)return a(e)?(n=!0,c(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},s=e=>{let t=e,n=t.kind===`text`?r(t.text):t.text,a=r(t.href),o=t.kind===`generator`&&t.params?i(t.params):t.params,c=e.children?.map(s);return n===t.text&&a===t.href&&o===t.params&&(!c||c.every((t,n)=>t===e.children[n]))?e:{...e,...t.kind===`text`?{text:n}:{},...t.href===void 0?{}:{href:a},...o===t.params?{}:{params:o},...c?{children:c}:{}}},l=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`||!a(t.openUrl)?e:{...t,openUrl:r(t.openUrl)}});return n.every((e,n)=>e===t[n])?e:{...e,do:n}}),u=(e.objects??[]).map(s),d=r(e.title),f=r(e.ariaLabel),p=e.ui?.elements?.map(e=>{let t=e,n=r(t.text);return n===t.text?e:{...e,text:n}});return n?{...e,title:d,...e.ariaLabel===void 0?{}:{ariaLabel:f},objects:u,...e.ui&&p?{ui:{...e.ui,elements:p}}:{},...l?{interactions:l}:{}}:e}function u(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 d=typeof HTMLElement<`u`?HTMLElement:class{},f=`
2
2
  :host{display:block;position:relative;width:100%;overflow:hidden;background:var(--agent3d-background,transparent);contain:layout paint;-webkit-tap-highlight-color:transparent}
3
3
  :host([hidden]){display:none}
4
4
  :host([interactive="false"]) ::slotted(*){pointer-events:none}
@@ -17,15 +17,56 @@ var e=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,t=e=>Array.isArray(e)?e.length>0:e!=null
17
17
  :host([status="unsupported"]) .poster,:host([status="error"]) .poster{opacity:1}
18
18
  @media (prefers-reduced-motion:reduce){.loading.indeterminate .bar{animation:none;width:100%;opacity:.3}.poster{transition:none}}
19
19
  @media print{::slotted(canvas),::slotted(img){visibility:hidden}.print{display:block}.loading{display:none}.poster{opacity:1}}
20
- `,p=null;function m(e){try{return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`}catch{return!1}}function h(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``);return!t||!(Number(t[1])>0)||!(Number(t[2])>0)?null:`${t[1]} / ${t[2]}`}function g(){let e=typeof navigator<`u`?navigator:{};if(e.connection?.saveData)return`low`;let t=e.hardwareConcurrency??8,n=e.deviceMemory??8;return t<=2||n<=2?`low`:t<=4||n<=4?`medium`:`high`}function _(e,t){let n=e;if(t.data&&Object.keys(t.data).length&&(n={...n,data:{...n.data??{},...t.data}}),t.loop!=null&&n.timeline){let e=t.loop.trim().toLowerCase(),r=e===`pingpong`?`pingpong`:e!==`false`&&e!==`0`&&e!==`no`;n={...n,timeline:{...n.timeline,loop:r}}}let r=t.quality?t.quality===`auto`?g():t.quality:null;if((t.quality===`low`||t.quality===`medium`||t.quality===`high`||t.quality===`ultra`)&&(n={...n,target:{...n.target,quality:t.quality}}),r===`low`||r===`medium`||r===`high`){let e=r===`low`?1:r===`medium`?1.5:2,t={...n.target,maxDpr:Math.min(n.target?.maxDpr??2,e)};r===`low`&&Object.assign(t,{antialias:!1,shadows:!1}),n={...n,target:t,...r===`low`?{postfx:void 0}:{}}}return l(n)}var v=class extends d{static get observedAttributes(){return[`src`,`poster`,`aspect`,`alt`,`paused`,`loop`,`quality`,`library-base`]}player=null;ready;resolveReady;root=null;posterEl=null;posterBox=null;printEl=null;loadingEl=null;barEl=null;fallbackEl=null;sizeStyle=null;sizeSheet=null;sizeCssText=``;loadToken=0;connected=!1;source=null;dataOverrides={};dataObserver=null;interObs=null;inView=!0;lostTimer=null;wantPlay=null;autoAriaLabel=null;constructor(){super(),this.resetReady()}readySettled=!1;resetReady(){this.readySettled=!1,this.ready=new Promise(e=>this.resolveReady=e)}connectedCallback(){this.connected=!0,this.ensureShadow(),this.updatePoster(),this.applyAspect(null),this.ownerDocument.defaultView?.addEventListener(`beforeprint`,this.onBeforePrint),this.addEventListener(`webglcontextlost`,this.onContextLost,!0),this.addEventListener(`webglcontextrestored`,this.onContextRestored,!0),typeof MutationObserver<`u`&&(this.dataObserver=new MutationObserver(e=>{e.some(e=>e.attributeName?.startsWith(`data-`))&&this.refreshData()}),this.dataObserver.observe(this,{attributes:!0})),typeof IntersectionObserver<`u`&&(this.interObs=new IntersectionObserver(e=>this.inView=e.some(e=>e.isIntersecting)),this.interObs.observe(this)),this.load()}disconnectedCallback(){this.connected=!1,this.loadToken++,this.ownerDocument.defaultView?.removeEventListener(`beforeprint`,this.onBeforePrint),this.removeEventListener(`webglcontextlost`,this.onContextLost,!0),this.removeEventListener(`webglcontextrestored`,this.onContextRestored,!0),this.dataObserver?.disconnect(),this.dataObserver=null,this.interObs?.disconnect(),this.interObs=null,this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null,this.player?.dispose(),this.player=null,this.setStatus(`idle`)}attributeChangedCallback(e,t,n){this.connected&&t!==n&&(e===`poster`||e===`alt`?this.updatePoster():e===`aspect`?this.applyAspect(this.source):e===`paused`?n===null?this.getAttribute(`status`)===`ready`&&this.player?.play():this.player?.pause():e===`src`?(this.source=null,this.load()):this.rebuild())}play(){this.wantPlay=!0,this.hasAttribute(`paused`)&&this.removeAttribute(`paused`),this.player?.play()}pause(){this.wantPlay=!1,this.player?.pause()}async seek(e){await(this.player??await this.ready).seek(e)}get data(){return{...this.source?.data??{},...this.attrData(),...this.dataOverrides}}async setData(e,t={}){this.dataOverrides=t.replace?{...e}:{...this.dataOverrides,...e},await this.rebuild()}trigger(e,t){this.player?.emit?this.player.emit(e,t):this.ready.then(n=>n.emit?.(e,t))}reload(){return this.source=null,this.load()}ensureShadow(){if(this.root||typeof this.attachShadow!=`function`)return;let e=this.ownerDocument;this.root=this.shadowRoot??this.attachShadow({mode:`open`});let t=[];if(m(this.root))p||(p=new CSSStyleSheet,p.replaceSync(f)),this.sizeSheet=new CSSStyleSheet,this.root.adoptedStyleSheets=[p,this.sizeSheet];else{let n=e.createElement(`style`);n.textContent=f,this.sizeStyle=e.createElement(`style`),t=[n,this.sizeStyle]}let n=e.createElement(`slot`);this.posterBox=e.createElement(`div`),this.posterBox.className=`poster`,this.posterBox.setAttribute(`part`,`poster`);let r=e.createElement(`slot`);r.name=`poster`,this.posterEl=e.createElement(`img`),this.posterEl.setAttribute(`part`,`poster-image`),this.posterEl.decoding=`async`,r.appendChild(this.posterEl),this.posterBox.appendChild(r),this.printEl=e.createElement(`img`),this.printEl.className=`print`,this.printEl.alt=``,this.loadingEl=e.createElement(`div`),this.loadingEl.className=`loading indeterminate`,this.loadingEl.setAttribute(`part`,`loading`),this.loadingEl.setAttribute(`aria-hidden`,`true`),this.barEl=e.createElement(`div`),this.barEl.className=`bar`,this.barEl.setAttribute(`part`,`loading-bar`),this.loadingEl.appendChild(this.barEl),this.fallbackEl=e.createElement(`div`),this.fallbackEl.className=`fallback`,this.fallbackEl.setAttribute(`part`,`fallback`);let i=e.createElement(`slot`);i.name=`fallback`,this.fallbackEl.appendChild(i),this.root.append(...t,n,this.posterBox,this.printEl,this.loadingEl,this.fallbackEl)}updatePoster(){let e=this.posterEl;if(!e)return;let t=this.getAttribute(`poster`);e.alt=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``,t?e.getAttribute(`src`)!==t&&(e.src=t):e.removeAttribute(`src`),this.posterBox&&(this.posterBox.hidden=!this.posterSrc()),this.updateFallbackText()}posterSrc(){let e=this.querySelector(`[slot="poster"]`),t=e?.tagName===`IMG`?e:e?.querySelector(`img`);return t?.currentSrc||t?.getAttribute(`src`)||this.getAttribute(`poster`)}updateFallbackText(){let e=this.fallbackEl;if(!e)return;let t=e.querySelector(`slot`),n=!!this.querySelector(`[slot="fallback"]`),r=!!this.posterSrc();e.classList.toggle(`show`,n||!r),t&&!n&&(t.textContent=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``)}setStatus(e){e===`idle`?this.removeAttribute(`status`):this.setAttribute(`status`,e),(e===`unsupported`||e===`error`)&&this.updateFallbackText()}progress(e,t){this.loadingEl&&this.barEl&&t>0&&(this.loadingEl.classList.remove(`indeterminate`),this.barEl.style.width=`${Math.round(Math.min(e,t)/t*100)}%`),this.emit(`agent3d:progress`,{loaded:e,total:t})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}fail(e){this.emit(`agent3d:error`,e),this.emit(`agent3d-error`,e)}onBeforePrint=()=>{let e=this.printEl;if(!e)return;let t=``;try{this.player&&this.getAttribute(`status`)===`ready`&&(t=this.player.snapshot(`image/png`))}catch{}(!t||t.length<32)&&(t=this.posterSrc()??``),t?e.src=t:e.removeAttribute(`src`)};onContextLost=e=>{this.player&&this.inView&&this.getAttribute(`status`)===`ready`&&(e.preventDefault(),this.fail({code:`context-lost`,message:`The WebGL context was lost; restoring.`}),this.setStatus(`loading`),this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{this.lostTimer=null,this.rebuild(!0)},3e3))};onContextRestored=()=>{this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null;let e=this.player;e&&e.update(e.scene).then(()=>this.setStatus(`ready`),()=>void this.rebuild(!0))};childJson(e){let t=this.querySelector(e);if(t?.textContent)try{return JSON.parse(t.textContent)}catch(e){this.fail({code:`invalid-scene`,message:`Invalid inline JSON: ${e.message}`});return}}attrData(){return u(this.dataset??{})}refreshData(){this.source&&this.rebuild()}base(){let e=this.getAttribute(`src`);return e?new URL(`.`,new URL(e,this.ownerDocument.baseURI)).href:this.ownerDocument.baseURI}async fetchScene(){let e=this.childJson(`script[type="application/json"]:not([data-assets])`);if(e)return e;let t=this.getAttribute(`src`);if(!t)return;let n=new URL(t,this.ownerDocument.baseURI).href,r=await fetch(n);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()}async load(){let e=++this.loadToken;if(!this.source){this.setStatus(`loading`);let t;try{if(t=await this.fetchScene(),!t&&this.ownerDocument.readyState===`loading`){if(await new Promise(e=>this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})),e!==this.loadToken)return;t=await this.fetchScene()}}catch(t){if(e!==this.loadToken)return;this.setStatus(`error`),this.fail({code:`scene-load`,message:`Cannot load ${this.getAttribute(`src`)}: ${t.message}`,path:this.getAttribute(`src`)??void 0});return}if(e!==this.loadToken)return;if(!t){this.setStatus(`idle`);return}this.source=t}await this.mount(e)}async rebuild(e=!1){if(!this.connected||!this.source)return;let t=this.player;if(t&&!e&&this.getAttribute(`status`)===`ready`&&this.getAttribute(`library-base`)===this.mountedLibraryBase){let e=this.sceneForMount();this.applySizing(e),await t.update(e)}else await this.mount(++this.loadToken)}sceneForMount(){return _(this.source,{data:{...this.attrData(),...this.dataOverrides},loop:this.getAttribute(`loop`),quality:this.getAttribute(`quality`)})}mountedLibraryBase=null;async mount(e){this.player?.dispose(),this.player=null,this.readySettled&&this.resetReady(),this.setStatus(`loading`);let t=this.sceneForMount();this.applySizing(t);let n=this.childJson(`script[data-assets]`),r={};this.querySelectorAll(`script[type="text/agent3d-script"][data-path]`).forEach(e=>{r[e.getAttribute(`data-path`)]=e.textContent??``});let i=this.getAttribute(`library-base`);this.mountedLibraryBase=i;let a=this.mountPlayer(this,t,{assetBase:this.base(),libraryBase:i?new URL(i,this.ownerDocument.baseURI).href:void 0,assetUrls:n,scriptSources:Object.keys(r).length?r:void 0,onError:t=>{e===this.loadToken&&(t.code===`webgl-unavailable`&&this.setStatus(`unsupported`),this.fail(t))},onEvent:(t,n)=>e===this.loadToken&&this.emit(`agent3d:event`,{name:t,payload:n}),onClick:(t,n)=>e===this.loadToken&&this.emit(`agent3d:click`,{id:t,x:n.x,y:n.y}),onProgress:(t,n)=>e===this.loadToken&&this.progress(t,n)});this.player=a;try{await a.ready}catch{e===this.loadToken&&this.getAttribute(`status`)!==`unsupported`&&this.setStatus(`error`);return}if(e!==this.loadToken)return;let o=(this.getAttribute(`autoplay`)??``).toLowerCase();(this.hasAttribute(`paused`)||this.wantPlay===!1||this.wantPlay!==!0&&(o===`false`||o===`0`||o===`no`))&&a.pause(),this.setStatus(`ready`),this.readySettled=!0,this.resolveReady(a),this.emit(`agent3d:ready`,{player:a}),this.emit(`agent3d-ready`,{player:a})}applyAspect(e){if(!this.sizeStyle&&!this.sizeSheet)return;let t=e?.target,n;n=t?.height?`:host{height:${t.height}}`:t?.kind===`fullscreen`?`:host{height:100vh;height:100dvh}`:`:host{aspect-ratio:${h(e?t?.aspect??this.getAttribute(`aspect`):this.getAttribute(`aspect`)??`16:9`)??`16 / 9`}}`,this.sizeCssText!==n&&(this.sizeCssText=n,this.sizeSheet?this.sizeSheet.replaceSync(n):this.sizeStyle&&(this.sizeStyle.textContent=n))}applySizing(e){if(this.sizeStyle||this.sizeSheet)this.applyAspect(e);else{this.style.display||(this.style.display=`block`),this.style.width||(this.style.width=`100%`),this.style.position||(this.style.position=`relative`);let t=h(e.target?.aspect)??`16 / 9`;e.target?.height?this.style.height=e.target.height:this.style.aspectRatio=t}let t=e.target?.kind===`game`;this.setAttribute(`role`,t?`application`:`img`);let n=this.getAttribute(`aria-label`);(n===null||n===this.autoAriaLabel)&&(this.autoAriaLabel=e.ariaLabel||e.title||`3D scene`,this.setAttribute(`aria-label`,this.autoAriaLabel)),t&&!this.hasAttribute(`tabindex`)&&(this.tabIndex=0),this.updatePoster()}};function y(e,t=`agent3d-scene`){typeof customElements<`u`&&(customElements.get(t)||customElements.define(t,e))}var ee={low:1,medium:1.5,high:2,ultra:3};function b(e,t={}){return e&&e!==`auto`?e:t.deterministic?`high`:t.gpu&&/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i.test(t.gpu)?`low`:t.mobile?(t.memoryGb??4)<=2||(t.cores??8)<=4?`low`:`medium`:t.cores!==void 0&&t.cores<=2||t.memoryGb!==void 0&&t.memoryGb<=2?`low`:t.cores!==void 0&&t.cores<=4||t.memoryGb!==void 0&&t.memoryGb<=4||t.gpu&&/intel|mali|adreno|powervr/i.test(t.gpu)?`medium`:`high`}function x(e){return e.endsWith(`/`)?e:e+`/`}function te(e){let t=x(e.assetBase??`./`),n=x(e.libraryBase??t+`assets/library/`),r=e.assetUrls??{};return e=>{if(r[e])return r[e];if(/^(https?:|data:|blob:|\/)/.test(e))return e;if(e.startsWith(`library:`)){let t=e.slice(8);return t.startsWith(`fonts/`)&&!/\.json$/.test(t)&&(t+=`.typeface.json`),r[`library:`+t]?r[`library:`+t]:n+t}return t+e.replace(/^\.\//,``)}}var S=Math.PI/180;function C(e,t,n){return e<t?t:e>n?n:e}function w(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function T(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function E(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*S/2)*t)/S)}function ne(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``),n=t?Number(t[1])/Number(t[2]):void 0;return n&&Number.isFinite(n)&&n>0?n:void 0}function D(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)}var O={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function re(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??O.width;return{width:o,height:o/r}}function k(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:{let e=Math.min(1,r/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(r),y:t*Math.cos(r),zoom:0}}case`zoom`:return{x:0,y:0,zoom:.5-.5*Math.cos(r)};default:return{x:0,y:0,zoom:0}}}function ie(e){let t=C(w(e?.pointer,1),0,1);return{pointer:t,scroll:C(w(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,w(e?.speed,O.speed)),smoothing:C(w(e?.smoothing,O.smoothing),0,.99)}}function A(e,t){let n=t.reduced?{x:0,y:0,zoom:0}:k(e.auto,e.speed,t.t),r=e.pointer*(t.reduced?.5:1),i=0,a=0,o=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(i=t.gyro.x,a=t.gyro.y,o=+(r>0)):r>0&&(i=t.pointer.x,a=t.pointer.y,o=C(t.pointer.weight,0,1));let s=n.x*(1-o)+i*r*o,c=n.y*(1-o)+a*r*o;return e.scroll>0&&(c+=(C(t.scroll,0,1)*2-1)*e.scroll),{x:C(s,-1,1),y:C(c,-1,1),zoom:n.zoom*(1-o)}}function j(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-C(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function ae(e,t,n){let r=C(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function M(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:C(i/20,-1,1),y:C(-a/20,-1,1)}}function oe(e,t){return Math.max(8,Math.round((e===`low`?12:e===`medium`?20:e===`ultra`?48:32)*(.5+.5*Math.min(1,Math.max(0,t)/.6))))}function se(e,t){let{live:n}=t,r={x:0,y:0,weight:0,init:!1},i=null,a=null,o=null;if(n&&e.gyro&&e.pointer>0&&!t.flat&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;a??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;i=M(e.beta,e.gamma,a,t)};window.addEventListener(`deviceorientation`,e),o=()=>window.removeEventListener(`deviceorientation`,e)}return{offset(t,a,o){let s=o.pointer,c=s.inside?C(s.x,-1,1):0,l=s.inside?C(s.y,-1,1):0,u=+!!s.inside;return!n||!r.init?(r.x=c,r.y=l,r.weight=u,r.init=n):(r.x=j(r.x,c,a,e.smoothing),r.y=j(r.y,l,a,e.smoothing),r.weight=j(r.weight,u,a,e.smoothing)),A(e,{t,pointer:r,gyro:n?i:null,scroll:o.scroll,reduced:o.reduced})},dispose(){o?.(),o=null}}}var N=`uniform sampler2D uMap;uniform vec3 uTint;uniform float uOpacity;uniform float uIntensity;vec4 shade(vec4 c,float a){return vec4(c.rgb*uTint*uIntensity,c.a*a*uOpacity);}
21
- `,P=`uniform sampler2D uDepth;uniform vec2 uView;uniform float uZoom;uniform vec2 uMaxOffset;uniform vec2 uInset;uniform float uFocus;uniform float uWallSlope;const int STEPS=__STEPS__;vec4 parallaxTexel(vec2 vUv){vec2 base=0.5+(vUv-0.5)*uInset*(1.0-0.06*uZoom);vec2 v=uView-(vUv-0.5)*2.0*uZoom;vec2 dir=v*uMaxOffset;vec2 uv=base;if(dot(dir,dir)>1e-10){float stepH=1.0/float(STEPS);float h=1.0;float prevH=1.0+stepH;bool hit=false;for(int i=0;i<=STEPS;i++){h=1.0-float(i)*stepH;float d=textureLod(uDepth,base+(h-uFocus)*dir,0.0).r;if(d>=h){hit=true;break;}prevH=h;}float lo=h,hi=min(prevH,1.0);if(hit){for(int j=0;j<6;j++){float mid=0.5*(lo+hi);float d=textureLod(uDepth,base+(mid-uFocus)*dir,0.0).r;if(d>=mid)lo=mid;else hi=mid;}}uv=base+(lo-uFocus)*dir;vec2 texel=1.0/vec2(textureSize(uDepth,0));vec4 dh=textureLod(uDepth,uv,0.0);vec2 grad=vec2(textureLod(uDepth,uv+vec2(texel.x*1.5,0.0),0.0).r-textureLod(uDepth,uv-vec2(texel.x*1.5,0.0),0.0).r,textureLod(uDepth,uv+vec2(0.0,texel.y*1.5),0.0).r-textureLod(uDepth,uv-vec2(0.0,texel.y*1.5),0.0).r)/3.0;float g=length(grad);vec2 toNear=grad/max(g,1e-6);float dNear=textureLod(uDepth,uv+toNear*texel*3.0,0.0).r;if(hit&&(g>uWallSlope||dh.a<0.5)&&dNear>lo+0.04){vec2 away=-toNear;vec2 probe=uv;for(int k=1;k<=6;k++){vec2 q=uv+away*texel*float(k*2);probe=q;if(textureLod(uDepth,q,0.0).r<lo-0.05)break;}uv=probe+away*texel*2.0;}}return textureGrad(uMap,uv,dFdx(base),dFdy(base));}
22
- `,ce=.02,le=`#version 300 es
20
+ `,p=null;function m(e){try{return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`}catch{return!1}}function h(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``);return!t||!(Number(t[1])>0)||!(Number(t[2])>0)?null:`${t[1]} / ${t[2]}`}function g(){let e=typeof navigator<`u`?navigator:{};if(e.connection?.saveData)return`low`;let t=e.hardwareConcurrency??8,n=e.deviceMemory??8;return t<=2||n<=2?`low`:t<=4||n<=4?`medium`:`high`}function ee(e,t){let n=e;if(t.data&&Object.keys(t.data).length&&(n={...n,data:{...n.data??{},...t.data}}),t.loop!=null&&n.timeline){let e=t.loop.trim().toLowerCase(),r=e===`pingpong`?`pingpong`:e!==`false`&&e!==`0`&&e!==`no`;n={...n,timeline:{...n.timeline,loop:r}}}let r=t.quality?t.quality===`auto`?g():t.quality:null;if((t.quality===`low`||t.quality===`medium`||t.quality===`high`||t.quality===`ultra`)&&(n={...n,target:{...n.target,quality:t.quality}}),r===`low`||r===`medium`||r===`high`){let e=r===`low`?1:r===`medium`?1.5:2,t={...n.target,maxDpr:Math.min(n.target?.maxDpr??2,e)};r===`low`&&Object.assign(t,{antialias:!1,shadows:!1}),n={...n,target:t,...r===`low`?{postfx:void 0}:{}}}return l(n)}var _=class extends d{static get observedAttributes(){return[`src`,`poster`,`aspect`,`alt`,`paused`,`loop`,`quality`,`library-base`]}player=null;ready;resolveReady;root=null;posterEl=null;posterBox=null;printEl=null;loadingEl=null;barEl=null;fallbackEl=null;sizeStyle=null;sizeSheet=null;sizeCssText=``;loadToken=0;connected=!1;source=null;dataOverrides={};dataObserver=null;interObs=null;inView=!0;lostTimer=null;wantPlay=null;autoAriaLabel=null;constructor(){super(),this.resetReady()}readySettled=!1;resetReady(){this.readySettled=!1,this.ready=new Promise(e=>this.resolveReady=e)}connectedCallback(){this.connected=!0,this.ensureShadow(),this.updatePoster(),this.applyAspect(null),this.ownerDocument.defaultView?.addEventListener(`beforeprint`,this.onBeforePrint),this.addEventListener(`webglcontextlost`,this.onContextLost,!0),this.addEventListener(`webglcontextrestored`,this.onContextRestored,!0),typeof MutationObserver<`u`&&(this.dataObserver=new MutationObserver(e=>{e.some(e=>e.attributeName?.startsWith(`data-`))&&this.refreshData()}),this.dataObserver.observe(this,{attributes:!0})),typeof IntersectionObserver<`u`&&(this.interObs=new IntersectionObserver(e=>this.inView=e.some(e=>e.isIntersecting)),this.interObs.observe(this)),this.load()}disconnectedCallback(){this.connected=!1,this.loadToken++,this.ownerDocument.defaultView?.removeEventListener(`beforeprint`,this.onBeforePrint),this.removeEventListener(`webglcontextlost`,this.onContextLost,!0),this.removeEventListener(`webglcontextrestored`,this.onContextRestored,!0),this.dataObserver?.disconnect(),this.dataObserver=null,this.interObs?.disconnect(),this.interObs=null,this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null,this.player?.dispose(),this.player=null,this.setStatus(`idle`)}attributeChangedCallback(e,t,n){this.connected&&t!==n&&(e===`poster`||e===`alt`?this.updatePoster():e===`aspect`?this.applyAspect(this.source):e===`paused`?n===null?this.getAttribute(`status`)===`ready`&&this.player?.play():this.player?.pause():e===`src`?(this.source=null,this.load()):this.rebuild())}play(){this.wantPlay=!0,this.hasAttribute(`paused`)&&this.removeAttribute(`paused`),this.player?.play()}pause(){this.wantPlay=!1,this.player?.pause()}async seek(e){await(this.player??await this.ready).seek(e)}get data(){return{...this.source?.data??{},...this.attrData(),...this.dataOverrides}}async setData(e,t={}){this.dataOverrides=t.replace?{...e}:{...this.dataOverrides,...e},await this.rebuild()}trigger(e,t){this.player?.emit?this.player.emit(e,t):this.ready.then(n=>n.emit?.(e,t))}reload(){return this.source=null,this.load()}ensureShadow(){if(this.root||typeof this.attachShadow!=`function`)return;let e=this.ownerDocument;this.root=this.shadowRoot??this.attachShadow({mode:`open`});let t=[];if(m(this.root))p||(p=new CSSStyleSheet,p.replaceSync(f)),this.sizeSheet=new CSSStyleSheet,this.root.adoptedStyleSheets=[p,this.sizeSheet];else{let n=e.createElement(`style`);n.textContent=f,this.sizeStyle=e.createElement(`style`),t=[n,this.sizeStyle]}let n=e.createElement(`slot`);this.posterBox=e.createElement(`div`),this.posterBox.className=`poster`,this.posterBox.setAttribute(`part`,`poster`);let r=e.createElement(`slot`);r.name=`poster`,this.posterEl=e.createElement(`img`),this.posterEl.setAttribute(`part`,`poster-image`),this.posterEl.decoding=`async`,r.appendChild(this.posterEl),this.posterBox.appendChild(r),this.printEl=e.createElement(`img`),this.printEl.className=`print`,this.printEl.alt=``,this.loadingEl=e.createElement(`div`),this.loadingEl.className=`loading indeterminate`,this.loadingEl.setAttribute(`part`,`loading`),this.loadingEl.setAttribute(`aria-hidden`,`true`),this.barEl=e.createElement(`div`),this.barEl.className=`bar`,this.barEl.setAttribute(`part`,`loading-bar`),this.loadingEl.appendChild(this.barEl),this.fallbackEl=e.createElement(`div`),this.fallbackEl.className=`fallback`,this.fallbackEl.setAttribute(`part`,`fallback`);let i=e.createElement(`slot`);i.name=`fallback`,this.fallbackEl.appendChild(i),this.root.append(...t,n,this.posterBox,this.printEl,this.loadingEl,this.fallbackEl)}updatePoster(){let e=this.posterEl;if(!e)return;let t=this.getAttribute(`poster`);e.alt=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``,t?e.getAttribute(`src`)!==t&&(e.src=t):e.removeAttribute(`src`),this.posterBox&&(this.posterBox.hidden=!this.posterSrc()),this.updateFallbackText()}posterSrc(){let e=this.querySelector(`[slot="poster"]`),t=e?.tagName===`IMG`?e:e?.querySelector(`img`);return t?.currentSrc||t?.getAttribute(`src`)||this.getAttribute(`poster`)}updateFallbackText(){let e=this.fallbackEl;if(!e)return;let t=e.querySelector(`slot`),n=!!this.querySelector(`[slot="fallback"]`),r=!!this.posterSrc();e.classList.toggle(`show`,n||!r),t&&!n&&(t.textContent=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``)}setStatus(e){e===`idle`?this.removeAttribute(`status`):this.setAttribute(`status`,e),(e===`unsupported`||e===`error`)&&this.updateFallbackText()}progress(e,t){this.loadingEl&&this.barEl&&t>0&&(this.loadingEl.classList.remove(`indeterminate`),this.barEl.style.width=`${Math.round(Math.min(e,t)/t*100)}%`),this.emit(`agent3d:progress`,{loaded:e,total:t})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}fail(e){this.emit(`agent3d:error`,e),this.emit(`agent3d-error`,e)}onBeforePrint=()=>{let e=this.printEl;if(!e)return;let t=``;try{this.player&&this.getAttribute(`status`)===`ready`&&(t=this.player.snapshot(`image/png`))}catch{}(!t||t.length<32)&&(t=this.posterSrc()??``),t?e.src=t:e.removeAttribute(`src`)};onContextLost=e=>{this.player&&this.inView&&this.getAttribute(`status`)===`ready`&&(e.preventDefault(),this.fail({code:`context-lost`,message:`The WebGL context was lost; restoring.`}),this.setStatus(`loading`),this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{this.lostTimer=null,this.rebuild(!0)},3e3))};onContextRestored=()=>{this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null;let e=this.player;e&&e.update(e.scene).then(()=>this.setStatus(`ready`),()=>void this.rebuild(!0))};childJson(e){let t=this.querySelector(e);if(t?.textContent)try{return JSON.parse(t.textContent)}catch(e){this.fail({code:`invalid-scene`,message:`Invalid inline JSON: ${e.message}`});return}}attrData(){return u(this.dataset??{})}refreshData(){this.source&&this.rebuild()}base(){let e=this.getAttribute(`src`);return e?new URL(`.`,new URL(e,this.ownerDocument.baseURI)).href:this.ownerDocument.baseURI}async fetchScene(){let e=this.childJson(`script[type="application/json"]:not([data-assets])`);if(e)return e;let t=this.getAttribute(`src`);if(!t)return;let n=new URL(t,this.ownerDocument.baseURI).href,r=await fetch(n);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()}async load(){let e=++this.loadToken;if(!this.source){this.setStatus(`loading`);let t;try{if(t=await this.fetchScene(),!t&&this.ownerDocument.readyState===`loading`){if(await new Promise(e=>this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})),e!==this.loadToken)return;t=await this.fetchScene()}}catch(t){if(e!==this.loadToken)return;this.setStatus(`error`),this.fail({code:`scene-load`,message:`Cannot load ${this.getAttribute(`src`)}: ${t.message}`,path:this.getAttribute(`src`)??void 0});return}if(e!==this.loadToken)return;if(!t){this.setStatus(`idle`);return}this.source=t}await this.mount(e)}async rebuild(e=!1){if(!this.connected||!this.source)return;let t=this.player;if(t&&!e&&this.getAttribute(`status`)===`ready`&&this.getAttribute(`library-base`)===this.mountedLibraryBase){let e=this.sceneForMount();this.applySizing(e),await t.update(e)}else await this.mount(++this.loadToken)}sceneForMount(){return ee(this.source,{data:{...this.attrData(),...this.dataOverrides},loop:this.getAttribute(`loop`),quality:this.getAttribute(`quality`)})}mountedLibraryBase=null;async mount(e){this.player?.dispose(),this.player=null,this.readySettled&&this.resetReady(),this.setStatus(`loading`);let t=this.sceneForMount();this.applySizing(t);let n=this.childJson(`script[data-assets]`),r={};this.querySelectorAll(`script[type="text/agent3d-script"][data-path]`).forEach(e=>{r[e.getAttribute(`data-path`)]=e.textContent??``});let i=this.getAttribute(`library-base`);this.mountedLibraryBase=i;let a=this.mountPlayer(this,t,{assetBase:this.base(),libraryBase:i?new URL(i,this.ownerDocument.baseURI).href:void 0,assetUrls:n,scriptSources:Object.keys(r).length?r:void 0,onError:t=>{e===this.loadToken&&(t.code===`webgl-unavailable`&&this.setStatus(`unsupported`),this.fail(t))},onEvent:(t,n)=>e===this.loadToken&&this.emit(`agent3d:event`,{name:t,payload:n}),onClick:(t,n)=>e===this.loadToken&&this.emit(`agent3d:click`,{id:t,x:n.x,y:n.y}),onProgress:(t,n)=>e===this.loadToken&&this.progress(t,n)});this.player=a;try{await a.ready}catch{e===this.loadToken&&this.getAttribute(`status`)!==`unsupported`&&this.setStatus(`error`);return}if(e!==this.loadToken)return;let o=(this.getAttribute(`autoplay`)??``).toLowerCase();(this.hasAttribute(`paused`)||this.wantPlay===!1||this.wantPlay!==!0&&(o===`false`||o===`0`||o===`no`))&&a.pause(),this.setStatus(`ready`),this.readySettled=!0,this.resolveReady(a),this.emit(`agent3d:ready`,{player:a}),this.emit(`agent3d-ready`,{player:a})}applyAspect(e){if(!this.sizeStyle&&!this.sizeSheet)return;let t=e?.target,n;n=t?.height?`:host{height:${t.height}}`:t?.kind===`fullscreen`?`:host{height:100vh;height:100dvh}`:`:host{aspect-ratio:${h(e?t?.aspect??this.getAttribute(`aspect`):this.getAttribute(`aspect`)??`16:9`)??`16 / 9`}}`,this.sizeCssText!==n&&(this.sizeCssText=n,this.sizeSheet?this.sizeSheet.replaceSync(n):this.sizeStyle&&(this.sizeStyle.textContent=n))}applySizing(e){if(this.sizeStyle||this.sizeSheet)this.applyAspect(e);else{this.style.display||(this.style.display=`block`),this.style.width||(this.style.width=`100%`),this.style.position||(this.style.position=`relative`);let t=h(e.target?.aspect)??`16 / 9`;e.target?.height?this.style.height=e.target.height:this.style.aspectRatio=t}let t=e.target?.kind===`game`;this.setAttribute(`role`,t?`application`:`img`);let n=this.getAttribute(`aria-label`);(n===null||n===this.autoAriaLabel)&&(this.autoAriaLabel=e.ariaLabel||e.title||`3D scene`,this.setAttribute(`aria-label`,this.autoAriaLabel)),t&&!this.hasAttribute(`tabindex`)&&(this.tabIndex=0),this.updatePoster()}};function v(e,t=`agent3d-scene`){typeof customElements<`u`&&(customElements.get(t)||customElements.define(t,e))}var y={low:1,medium:1.5,high:2,ultra:3};function b(e,t={}){return e&&e!==`auto`?e:t.deterministic?`high`:t.gpu&&/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i.test(t.gpu)?`low`:t.mobile?(t.memoryGb??4)<=2||(t.cores??8)<=4?`low`:`medium`:t.cores!==void 0&&t.cores<=2||t.memoryGb!==void 0&&t.memoryGb<=2?`low`:t.cores!==void 0&&t.cores<=4||t.memoryGb!==void 0&&t.memoryGb<=4||t.gpu&&/intel|mali|adreno|powervr/i.test(t.gpu)?`medium`:`high`}function x(e){return e.endsWith(`/`)?e:e+`/`}function te(e){let t=x(e.assetBase??`./`),n=x(e.libraryBase??t+`assets/library/`),r=e.assetUrls??{};return e=>{if(r[e])return r[e];if(/^(https?:|data:|blob:|\/)/.test(e))return e;if(e.startsWith(`library:`)){let t=e.slice(8);return t.startsWith(`fonts/`)&&!/\.json$/.test(t)&&(t+=`.typeface.json`),r[`library:`+t]?r[`library:`+t]:n+t}return t+e.replace(/^\.\//,``)}}var S=Math.PI/180;function C(e,t,n){return e<t?t:e>n?n:e}function w(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function T(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function E(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*S/2)*t)/S)}function ne(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``),n=t?Number(t[1])/Number(t[2]):void 0;return n&&Number.isFinite(n)&&n>0?n:void 0}function D(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)}var O={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function re(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??O.width;return{width:o,height:o/r}}var k=[`zoom`,`dolly`,`pan`,`rise`,`vertigo`],ie=[`pan`,`rise`];function A(e,t){let n=C(t,0,1),r=2*Math.PI*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:return{x:.8*Math.sin(r),y:.8*Math.cos(r),zoom:0};case`zoom`:return{x:0,y:0,zoom:n};case`dolly`:return{x:0,y:.12*n,zoom:1.1*n,push:.12*n};case`pan`:return{x:.85*(2*n-1),y:0,zoom:.15,push:.03};case`rise`:return{x:0,y:.8*(2*n-1),zoom:.2+.25*n,push:.03+.03*n};case`vertigo`:return{x:0,y:0,zoom:0,push:.03*n,vertigo:n};default:return{x:0,y:0,zoom:0}}}function j(e,t,n,r={}){let i=e??`sway`;if(i===`none`)return{x:0,y:0,zoom:0};let a=Math.max(0,t);if(r.loop===!1){let e=r.duration&&r.duration>0?r.duration:a>0?10/a:0,t=e>0?C(n/e,0,1):0;return A(i,.5-.5*Math.cos(Math.PI*t))}let o=2*Math.PI*a/10*n;if(i===`orbit`){let e=Math.min(1,o/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(o),y:t*Math.cos(o),zoom:0}}return k.includes(i)?A(i,ie.includes(i)?.5+.5*Math.sin(o):.5-.5*Math.cos(o)):A(i,o/(2*Math.PI)%1)}function ae(e){let t=C(w(e?.pointer,1),0,1);return{pointer:t,scroll:C(w(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,w(e?.speed,O.speed)),smoothing:C(w(e?.smoothing,O.smoothing),0,.99),loop:e?.loop!==!1,duration:Math.max(0,w(e?.duration,0)),progress:typeof e?.progress==`number`&&Number.isFinite(e.progress)?C(e.progress,0,1):null}}function oe(e,t){let n=t.progress??e.progress,r=n!==null,i=t.reduced?{x:0,y:0,zoom:0}:r?A(e.auto,n):j(e.auto,e.speed,t.t,e),a=e.pointer*(t.reduced?.5:1),o=0,s=0,c=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(o=t.gyro.x,s=t.gyro.y,c=+(a>0)):a>0&&(o=t.pointer.x,s=t.pointer.y,c=C(t.pointer.weight,0,1));let l=i.x*(1-c)+o*a*c,u=i.y*(1-c)+s*a*c;e.scroll>0&&(u+=(C(t.scroll,0,1)*2-1)*e.scroll);let d=r?1:1-c,f={x:C(l,-1,1),y:C(u,-1,1),zoom:i.zoom*d};return i.push&&(f.push=i.push*d),i.vertigo&&(f.vertigo=i.vertigo*d),f}var M=1.5;function se(e,t){let n=e.zoom-M*(e.vertigo??0),r=(1-.06*e.zoom)/((1+(e.push??0))*(1-.06*n));return{zoom:n,inset:[t[0]*r,t[1]*r]}}function N(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-C(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function ce(e,t,n){let r=C(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function P(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:C(i/20,-1,1),y:C(-a/20,-1,1)}}function le(e,t){return Math.max(8,Math.round((e===`low`?12:e===`medium`?20:e===`ultra`?48:32)*(.5+.5*Math.min(1,Math.max(0,t)/.6))))}function ue(e,t){let{live:n}=t,r={x:0,y:0,weight:0,init:!1},i=null,a=null,o=null;if(n&&e.gyro&&e.pointer>0&&!t.flat&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;a??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;i=P(e.beta,e.gamma,a,t)};window.addEventListener(`deviceorientation`,e),o=()=>window.removeEventListener(`deviceorientation`,e)}return{offset(t,a,o){let s=o.pointer,c=s.inside?C(s.x,-1,1):0,l=s.inside?C(s.y,-1,1):0,u=+!!s.inside;return!n||!r.init?(r.x=c,r.y=l,r.weight=u,r.init=n):(r.x=N(r.x,c,a,e.smoothing),r.y=N(r.y,l,a,e.smoothing),r.weight=N(r.weight,u,a,e.smoothing)),oe(e,{t,pointer:r,gyro:n?i:null,scroll:o.scroll,reduced:o.reduced,progress:o.progress})},dispose(){o?.(),o=null}}}var F=`uniform sampler2D uMap;uniform vec3 uTint;uniform float uOpacity;uniform float uIntensity;vec4 shade(vec4 c,float a){return vec4(c.rgb*uTint*uIntensity,c.a*a*uOpacity);}
21
+ `,I=`uniform sampler2D uDepth;uniform sampler2D uPlate;uniform sampler2D uPlateDepth;uniform float uPlateOn;uniform vec2 uView;uniform float uZoom;uniform vec2 uMaxOffset;uniform vec2 uInset;uniform float uFocus;uniform float uWallSlope;const int STEPS=__STEPS__;vec2 pxUv;float photoHitDepth=0.0;vec4 parallaxTexel(vec2 vUv){vec2 base=0.5+(vUv-0.5)*uInset*(1.0-0.06*uZoom);vec2 v=uView-(vUv-0.5)*2.0*uZoom;vec2 dir=v*uMaxOffset;vec2 uv=base;bool onPlate=false;if(dot(dir,dir)>1e-10){float stepH=1.0/float(STEPS);float h=1.0;float prevH=1.0+stepH;bool hit=false;for(int i=0;i<=STEPS;i++){h=1.0-float(i)*stepH;float d=textureLod(uDepth,base+(h-uFocus)*dir,0.0).r;if(d>=h){hit=true;break;}prevH=h;}float lo=h,hi=min(prevH,1.0);if(hit){for(int j=0;j<6;j++){float mid=0.5*(lo+hi);float d=textureLod(uDepth,base+(mid-uFocus)*dir,0.0).r;if(d>=mid)lo=mid;else hi=mid;}}uv=base+(lo-uFocus)*dir;vec2 texel=1.0/vec2(textureSize(uDepth,0));vec4 dh=textureLod(uDepth,uv,0.0);vec2 grad=vec2(textureLod(uDepth,uv+vec2(texel.x*1.5,0.0),0.0).r-textureLod(uDepth,uv-vec2(texel.x*1.5,0.0),0.0).r,textureLod(uDepth,uv+vec2(0.0,texel.y*1.5),0.0).r-textureLod(uDepth,uv-vec2(0.0,texel.y*1.5),0.0).r)/3.0;float g=length(grad);vec2 toNear=grad/max(g,1e-6);float dNear=textureLod(uDepth,uv+toNear*texel*3.0,0.0).r;if(hit&&(g>uWallSlope||dh.a<0.5)&&dNear>lo+0.04&&uPlateOn>0.5){float ph=lo,pprev=lo;bool phit=false;for(int i=0;i<=STEPS;i++){ph=lo-float(i)*stepH;if(textureLod(uPlateDepth,base+(ph-uFocus)*dir,0.0).r>=ph){phit=true;break;}pprev=ph;}float plo=max(ph,0.0),phi=pprev;if(phit){for(int j=0;j<5;j++){float mid=0.5*(plo+phi);if(textureLod(uPlateDepth,base+(mid-uFocus)*dir,0.0).r>=mid)plo=mid;else phi=mid;}}uv=base+(plo-uFocus)*dir;onPlate=true;}else if(hit&&(g>uWallSlope||dh.a<0.5)&&dNear>lo+0.04){vec2 away=-toNear;vec2 probe=uv;for(int k=1;k<=6;k++){vec2 q=uv+away*texel*float(k*2);probe=q;if(textureLod(uDepth,q,0.0).r<lo-0.05)break;}uv=probe+away*texel*2.0;}}pxUv=uv;photoHitDepth=onPlate?textureLod(uPlateDepth,uv,0.0).r:textureLod(uDepth,uv,0.0).r;vec2 gx=dFdx(base),gy=dFdy(base);return onPlate?textureGrad(uPlate,uv,gx,gy):textureGrad(uMap,uv,gx,gy);}
22
+ `,de=.02,L=(e,t,n)=>({type:`number`,default:e,min:t,max:n}),R={fog:{needsDepth:!0,params:{color:{type:`color`,default:`#ffffff`},amount:L(.6,0,1),start:L(.7,0,1),end:L(0,0,1),drift:L(.3,0)}},light:{needsDepth:!1,params:{color:{type:`color`,default:`#ffffff`},intensity:L(1,0),ambient:L(.75,0,1),position:{type:`vec2`,default:[.4,.4],min:-1,max:1},height:L(.6,0),radius:L(.8,0),relief:L(1,0),specular:L(.25,0,1),follow:{type:`enum`,default:`pointer`,options:[`pointer`,`auto`,`none`],animatable:!1}}},reveal:{needsDepth:!0,alpha:!0,params:{progress:L(1,0,1),from:{type:`enum`,default:`far`,options:[`near`,`far`],animatable:!1},softness:L(.15,0,1),duration:L(void 0,0),delay:L(0,0)}},blur:{needsDepth:!1,params:{focus:L(void 0,0,1),amount:L(.6,0,5),range:L(.1,0,1),to:L(void 0,0,1),duration:L(void 0,0),delay:L(0,0)}},frame:{needsDepth:!1,alpha:!0,params:{inset:{type:`vec2`,default:[.12,.12],min:0,max:.45,scalar:!0},threshold:L(.6,0,1),softness:L(.04,0,1),border:L(.015,0,.2),color:{type:`color`,default:`#ffffff`},shadow:L(.35,0,1)}}},z=Object.keys(R);function B(e,t){let n={};for(let r of z){let i=e?.[r],a=R[r];if(!i||typeof i!=`object`||a.needsDepth&&!t.depth)continue;let o={};for(let[e,n]of Object.entries(a.params)){let r=i[e]??n.default;r!==void 0&&(o[e]=n.type===`color`?t.color(typeof r==`string`?r:String(n.default)):n.type===`vec2`?Array.isArray(r)?[w(r[0],0),w(r[1],0)]:typeof r==`number`?[r,r]:[...n.default]:n.type===`enum`?typeof r==`string`&&n.options?.includes(r)?r:n.default:w(r,w(n.default,0)))}r===`blur`&&(o.focus??=C(w(t.focus,.5),0,1)),n[r]=o}return n}var V=`uniform float uFxTime;uniform float uFxAspect;
23
+ `,H=`uniform vec3 uLightColor;uniform vec3 uLightPos;uniform vec4 uLight;
24
+ `,U=`float fxZ(vec2 p,float lod){return(textureLod(uDepth,p,lod).r-1.0)*0.5*uLight.z;}float fxN(vec2 p,float lod,float zc){float z=fxZ(p,lod);return mix(z,zc,smoothstep(0.01,0.04,(z-zc)/max(uLight.z,1e-3)));}
25
+ `,W=e=>`{vec3 L=vec3(uLightPos.xy*vec2(uFxAspect,1.0),uLightPos.z);vec3 n=vec3(0.0,0.0,1.0);vec3 S=vec3(q,0.0);float sh=0.0;
26
+ ${e?G:``}
27
+ vec3 tl=L-S;vec3 l=normalize(tl);float att=1.0/(1.0+max(dot(tl,tl)-L.z*L.z,0.0)/max(uLight.y*uLight.y,1e-4));att*=att*1.6;float df=max(dot(n,l),0.0)*(1.0-0.6*sh);float sp=pow(max(dot(n,normalize(l+vec3(0.0,0.0,1.0))),0.0),40.0)*uLight.w*(1.0-sh);vec3 lit=c.rgb*(uLight.x+df*att*uLightColor)+uLightColor*sp*att*0.35;vec3 k=vec3(0.78);c.rgb=mix(lit,k+(1.0-k)*(1.0-exp((k-lit)/(1.0-k))),step(k,lit));}
28
+ `,G=`vec2 ts=vec2(textureSize(uDepth,0));float lod=max(log2(max(ts.x,ts.y)/160.0),0.0);vec2 e=exp2(lod)*1.5/ts;S.z=fxZ(uv,lod);float z0=fxN(uv+vec2(-e.x,e.y),lod,S.z),z1=fxN(uv+vec2(0.0,e.y),lod,S.z),z2=fxN(uv+e,lod,S.z);float z3=fxN(uv-vec2(e.x,0.0),lod,S.z),z5=fxN(uv+vec2(e.x,0.0),lod,S.z);float z6=fxN(uv-e,lod,S.z),z7=fxN(uv-vec2(0.0,e.y),lod,S.z),z8=fxN(uv+vec2(e.x,-e.y),lod,S.z);vec2 sl=vec2(z2+2.0*z5+z8-z0-2.0*z3-z6,z0+2.0*z1+z2-z6-2.0*z7-z8)/(16.0*e*vec2(uFxAspect,1.0));sl*=smoothstep(0.015,0.05,length(sl));n=normalize(vec3(-3.0*sl,1.0));vec3 sd=normalize(L-S);for(int i=1;i<=8;i++){vec3 P=S+sd*(float(i)*0.035);float zo=fxZ(P.xy/vec2(uFxAspect,1.0)*0.5+0.5,lod);sh=max(sh,clamp((zo-P.z)*24.0,0.0,1.0)*(1.0-smoothstep(0.01,0.03,(zo-S.z)/max(uLight.z,1e-3))));}
29
+ `,fe=`uniform vec3 uFogColor;uniform vec4 uFog;float fxHash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}float fxNoise(vec2 p){vec2 i=floor(p);vec2 f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(fxHash(i),fxHash(i+vec2(1.0,0.0)),f.x),mix(fxHash(i+vec2(0.0,1.0)),fxHash(i+1.0),f.x),f.y);}
30
+ `,K=`{float k=clamp((uFog.y-d)*uFog.z,0.0,1.0);float s=uFxTime*uFog.w;float w=0.65*fxNoise(q*vec2(1.4,2.6)+vec2(s*0.4,s*0.06))+0.35*fxNoise(q*vec2(3.6,6.0)-vec2(s*0.7,-s*0.1));c.rgb=mix(c.rgb,uFogColor,clamp(uFog.x*k*k*(3.0-2.0*k)*(0.6+0.8*w),0.0,1.0));}
31
+ `,pe=`uniform vec3 uReveal;
32
+ `,me=`c.a*=1.0-smoothstep(uReveal.x-uReveal.z,uReveal.x+uReveal.z,uReveal.y>0.5?1.0-d:d);
33
+ `,q=`uniform vec4 uBlur;float fxCoc(float z){return clamp((abs(z-uBlur.x)-uBlur.y)*uBlur.w,0.0,1.0);}
34
+ `,he=`vec2 gc=0.5+(s-0.5)*uInset*(1.0-0.06*uZoom)+(d-uFocus)*(uView-(s-0.5)*2.0*uZoom)*uMaxOffset;
35
+ `,ge=`if(textureLod(uDepth,uv,0.0).a<0.5){vec2 de=2.0/vec2(textureSize(uDepth,0));dc=max(max(textureLod(uDepth,uv+vec2(de.x,0.0),0.0).r,textureLod(uDepth,uv-vec2(de.x,0.0),0.0).r),max(textureLod(uDepth,uv+vec2(0.0,de.y),0.0).r,textureLod(uDepth,uv-vec2(0.0,de.y),0.0).r));}
36
+ `,_e=(e,t,n)=>`{
37
+ ${n?he:`vec2 gc = uv;`}
38
+ float dc=d;
39
+ ${e?ge:``}
40
+ float cc=fxCoc(dc);vec2 R=vec2(uBlur.z,uBlur.z*uFxAspect);float rs=max(cc,0.35);
41
+ float lod = log2(max(rs * uBlur.z * float(textureSize(uMap, 0).x) * ${(.6*(3.14159265/t)**.5).toFixed(3)}, 1.0));
42
+ vec3 acc=mix(c.rgb,textureLod(uMap,gc,lod*cc).rgb,cc);float ws=1.0;
43
+ for (int i = 0; i < ${t}; i++) {
44
+ float fi=float(i)+0.5;
45
+ float r = sqrt(fi / ${t}.0) * rs;
46
+ vec2 p=gc+vec2(cos(fi*2.39996),sin(fi*2.39996))*r*R;
47
+ vec2 dt = ${e?`textureLod(uDepth, p, 0.0).ra`:`vec2(d, 1.0)`};
48
+ float ct=fxCoc(dt.x);float w=clamp(((dt.x<dc-0.03?min(ct,cc):ct)-r)*20.0+0.5,0.0,1.0)*step(0.5,dt.y);vec3 sc=textureLod(uMap,p,lod).rgb;w*=1.0+3.0*max(dot(sc,vec3(0.2126,0.7152,0.0722))-0.7,0.0);acc+=sc*w;ws+=w;}c.rgb=acc/ws;}
49
+ `,J=`uniform vec4 uFrame;uniform vec4 uFrameB;uniform vec3 uFrameColor;float fxBox(vec2 p,vec2 h){vec2 e=abs(p)-h;return length(max(e,0.0))+min(max(e.x,e.y),0.0);}float fxEdge(vec2 p,float w){return smoothstep(0.0,w,-fxBox(p,vec2(uFxAspect,1.0)));}
50
+ `,Y=`float ks=0.0;float jr=6.2832*fract(52.9829*fract(dot(gl_FragCoord.xy,vec2(0.06711,0.00584))));for(int i=0;i<8;i++){float fi=float(i)+0.5;vec2 o=so+0.04*sqrt(fi/8.0)*vec2(cos(fi*2.39996+jr),sin(fi*2.39996+jr));ks+=fxEdge(qs-o,0.25)*smoothstep(uFrameB.x-uFrame.w,uFrameB.x+uFrame.w,textureLod(uDepth,0.5+(s-0.5-o/vec2(2.0*uFxAspect,2.0))*uFrameB.zw,0.0).r);}sh=max(sh,0.1*ks);
51
+ `,ve=`vec2 et=3.0/vec2(textureSize(uDepth,0));dp=min(dp,min(min(textureLod(uDepth,uv+vec2(et.x,0.0),0.0).r,textureLod(uDepth,uv-vec2(et.x,0.0),0.0).r),min(textureLod(uDepth,uv+vec2(0.0,et.y),0.0).r,textureLod(uDepth,uv-vec2(0.0,et.y),0.0).r)));
52
+ `,X=e=>`{vec2 qs=(s*2.0-1.0)*vec2(uFxAspect,1.0);float aa=max(length(fwidth(qs)),1e-5);float din=fxBox(qs,uFrame.xy);float inner=clamp(0.5-din/aa,0.0,1.0);float outer=clamp(0.5-(din-uFrame.z)/aa,0.0,1.0);float dp=d;
53
+ ${e?ve:``}
54
+ float pop=smoothstep(uFrameB.x-uFrame.w,uFrameB.x+uFrame.w,dp)*fxEdge(qs,0.08);vec2 so=vec2(0.03,-0.045);float sh=1.0-smoothstep(-0.03,0.1,fxBox(qs-so,uFrame.xy+uFrame.z));
55
+ ${e?Y:``}
56
+ vec4 o=mix(vec4(0.0,0.0,0.0,uFrameB.y*sh*fxEdge(qs,0.25)),vec4(uFrameColor,1.0),outer);vec4 cp=vec4(c.rgb*c.a,c.a);o=mix(mix(o,cp,inner),cp,pop);c=vec4(o.rgb/max(o.a,1e-4),o.a);}
57
+ `,ye=e=>e===`low`?8:e===`medium`?12:16;function be(e,t,n,r=!1){if(!xe(e))return``;let i=V,a=``;return e.blur&&(i+=q,a+=_e(t,ye(n),r&&t)),e.light&&(i+=H+(t?U:``),a+=W(t)),e.fog&&(i+=fe,a+=K),e.reveal&&(i+=pe,a+=me),e.frame&&(i+=J,a+=X(t)),`${i}vec4 photoFx(vec4 c, vec2 uv, float d, vec2 s) {
58
+ vec2 q = (uv * 2.0 - 1.0) * vec2(uFxAspect, 1.0);
59
+ ${a} return c;
60
+ }
61
+ `}var xe=e=>z.some(t=>e[t]),Se=.3;function Z(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;return[C(e[0]-.7*Math.sin(r),-1,1),C(e[1]-.35*(1-Math.cos(2*r)),-1,1)]}function Ce(e,t){let n=Math.max(t,.001);return-n+C(e,0,1)*(1+2*n)}function Q(e,t,n,r,i,a=!1){if(typeof t!=`number`||typeof n!=`number`||n<=0||a)return e;let o=Math.max(0,i-r)/n;return e+(t-e)*(.5-.5*Math.cos(Math.PI*o))}function we(e,t){let n=B(e,t),r=xe(n),i=!!t.live,a={x:0,y:0,w:0,init:!1},o=0,s=!1;return{state:n,glsl:be(n,t.depth,t.quality,t.parallax),alpha:z.some(e=>n[e]&&R[e].alpha),depthMips:!!n.light&&t.depth,call:(e,n,i=e)=>r?`c = photoFx(c, ${e}, ${t.depth?n:`0.5`}, ${i});`:``,frame:(e,n,r)=>{o=e,s=r.reduced;let c=r.pointer,l=c.inside?C(c.x,-1,1):a.x,u=c.inside?C(c.y,-1,1):a.y,d=+!!c.inside;if(!i||!a.init)a.x=l,a.y=u,a.w=d,a.init=i;else{let e=C(w(t.smoothing,.9),0,.99);a.x=N(a.x,l,n,e),a.y=N(a.y,u,n,e),a.w=N(a.w,d,n,e)}},uniforms:()=>{let e={uFxTime:[o],uFxAspect:[t.aspect]},r=n.light;if(r){let n=r.color,i=r.intensity,c=r.position,l=c;if(!s&&r.follow!==`none`){let e=Z(c,w(t.speed,1),o);l=r.follow===`auto`?e:[e[0]+(a.x-e[0])*a.w,e[1]+(a.y-e[1])*a.w]}e.uLightColor=[n[0]*i,n[1]*i,n[2]*i],e.uLightPos=[l[0],l[1],Math.max(.02,r.height)],e.uLight=[C(r.ambient,0,1),Math.max(.001,r.radius),r.relief,C(r.specular,0,1)]}let i=n.fog;if(i){let t=i.start,n=t-i.end;e.uFogColor=i.color.slice(0,3),e.uFog=[C(i.amount,0,1),t,1/(Math.abs(n)<.001?n<0?-.001:.001:n),Math.max(0,i.drift)]}let c=n.reveal;if(c){let t=c.duration,n=c.progress;if(typeof t==`number`){let e=s||t<=0?1:C((o-c.delay)/t,0,1);n=e*e*(3-2*e)}let r=Math.max(.001,c.softness);e.uReveal=[Ce(n,r),+(c.from===`near`),r]}let l=n.blur;if(l){let t=C(l.range,0,1);e.uBlur=[Q(l.focus,l.to,l.duration,l.delay,o,s),t,Math.max(0,l.amount)/100,1/Se]}let u=n.frame;if(u){let n=u.inset,r=t.aspect;e.uFrame=[Math.max(0,1-2*C(n[0],0,.5))*r,Math.max(0,1-2*C(n[1],0,.5)),Math.max(0,u.border)*2*r,Math.max(.001,u.softness)],e.uFrameB=[u.threshold,C(u.shadow,0,1),...t.inset??[1,1]],e.uFrameColor=u.color.slice(0,3)}return e},get(e,t){let r=n[e],[i,a]=t.split(`.`),o=r?.[i];return a&&Array.isArray(o)?o[+(a===`y`)]:Array.isArray(o)?[...o]:o},set(e,t,r){let i=n[e],[a,o]=t.split(`.`);if(!i||!(a in i)&&!(a in(R[e]?.params??{})))return!1;let s=i[a];if(o&&Array.isArray(s)&&typeof r==`number`)s[+(o===`y`)]=r;else if(Array.isArray(s)&&typeof r==`number`)i[a]=s.map(()=>r);else if(Array.isArray(r))i[a]=r.slice(0,Array.isArray(s)?s.length:r.length);else if(typeof r==`number`&&Number.isFinite(r))i[a]=r;else return!1;return!0}}}var $=/* @__PURE__ */ new WeakMap;function Te(e){let t=$.get(e);if(t===void 0){t=null;let n=e.ownerDocument.defaultView;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement)if(r.parentElement&&n?.getComputedStyle(r).position===`sticky`){t=r;break}e.isConnected&&$.set(e,t)}if(!t){let t=e.getBoundingClientRect();return{top:t.top,height:t.height}}let n=t.parentElement.getBoundingClientRect();return{top:n.top,height:Math.max(1,n.height-t.getBoundingClientRect().height)}}var Ee=`#version 300 es
23
62
  in vec2 aPos;out vec2 vNdc;void main(){vNdc=aPos;gl_Position=vec4(aPos,0.0,1.0);}
24
- `,F=`#version 300 es
63
+ `,De=`#version 300 es
25
64
  precision highp float;precision highp int;precision highp sampler2D;
26
- `,I=`vec4 photoTexel(vec2 uv){return texture(uMap,uv);}
27
- `,L=`vec4 photoTexel(vec2 uv){return parallaxTexel(uv);}
28
- `,R=`uniform vec3 uO;uniform vec3 uF;uniform vec3 uR;uniform vec3 uU;uniform vec2 uClip;uniform vec4 uBg;uniform float uBlend;in vec2 vNdc;out vec4 fragColor;vec3 toSrgb(vec3 v){return mix(pow(v,vec3(0.41666))*1.055-vec3(0.055),v*12.92,vec3(lessThanEqual(v,vec3(0.0031308))));}void main(){vec3 d=uF+uR*vNdc.x+uU*vNdc.y;float t=d.z<0.0?-uO.z/d.z:-1.0;vec2 uv=uO.xy+t*d.xy+0.5;vec2 fw=max(fwidth(uv),vec2(1e-7));vec4 c=photoTexel(uv);vec2 e=min(uv,1.0-uv)/fw;float cover=uO.z>0.0&&t>=uClip.x&&t<=uClip.y?clamp(min(e.x,e.y)+0.5,0.0,1.0):0.0;vec4 s=shade(c,1.0);float a=c.a*uOpacity<0.004?0.0:uBlend>0.5?s.a:1.0;vec4 photo=vec4(toSrgb(s.rgb)*a,a)+uBg*(1.0-a);fragColor=mix(uBg,photo,cover);}
29
- `,ue=(e,t)=>F+N+(e?I:P.replace(`__STEPS__`,String(t))+L)+R,de=[`uMap`,`uDepth`,`uTint`,`uOpacity`,`uIntensity`,`uView`,`uZoom`,`uMaxOffset`,`uInset`,`uFocus`,`uWallSlope`,`uO`,`uF`,`uR`,`uU`,`uClip`,`uBg`,`uBlend`],z=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],B=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],V=e=>{let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function fe(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e??``);if(!n)return t;let r=n[1].length===3?n[1].replace(/./g,`$&$&`):n[1];return[0,2,4].map(e=>parseInt(r.slice(e,e+2),16)/255)}var pe=e=>e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4;function me(e,t){let n=e.camera,r=n.target??[0,0,0],i={x:n.position[0],y:n.position[1],z:n.position[2],set(e,t,n){this.x=e,this.y=t,this.z=n}};D(i,{x:r[0],y:r[1],z:r[2]});let a=[i.x,i.y,i.z],o=z(a,r);Math.hypot(...o)===0&&(o=[0,0,1]),o=V(o);let s=B([0,1,0],o);Math.hypot(...s)===0&&(o=V([o[0],o[1],o[2]+1e-4]),s=B([0,1,0],o)),s=V(s);let c=B(o,s),l=E(w(n.fov,45),T(t,ne(e.target?.aspect)));return{pos:a,right:s,up:c,fwd:[-o[0],-o[1],-o[2]],tanY:Math.tan(l*S/2),near:w(n.near,.1),far:w(n.far,1e3)}}function he(e){return new Promise((t,n)=>{let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>t(r),r.onerror=()=>n(/* @__PURE__ */ Error(`Cannot load texture ${e}`)),r.src=e})}function H(e,t,n={}){let r=t,i=!!n.deterministic,a=te(n),o,s,c=new Promise((e,t)=>(o=e,s=t));c.catch(()=>void 0);let l=e.ownerDocument,u=l.defaultView,d=l.createElement(`canvas`);d.style.cssText=`display:block;width:100%;height:100%;outline:none;touch-action:manipulation;`;let f=u.getComputedStyle(e).position;f&&f!==`static`||(e.style.position=`relative`),e.appendChild(d);let p=null,m=null,h={},g=[],_=null,v=null,y=[1,1],x=`high`,S=!1,T=1,E={x:0,y:0,inside:!1},D=null,k=0,A=0,j=0,M=0,N=0,P=0,F=!1,I=!0,L=!1,R=!1,z=!1,B=!1,V=1,H=1,U=1,W=null,G=[],K=/* @__PURE__ */ new Map,q=()=>r.target??{},ge=()=>r.objects[0],_e=e=>{try{n.onError?.(e)}catch{}n.onError||console.warn(`[agent3d] ${e.code}: ${e.message}`)},J=(e,t,n,r)=>{e.addEventListener(t,n,r),G.push(()=>e.removeEventListener(t,n,r))},ve=()=>{let t=Math.max(1,e.clientWidth||d.clientWidth||300);H=t,U=Math.max(1,e.clientHeight||Math.round(t/(ne(r.target?.aspect)??16/9))),d.width=Math.floor(H*T),d.height=Math.floor(U*T)},ye=()=>{if(D!==null)return D;if(i||B)return C(k/4,0,1);let t=e.getBoundingClientRect(),n=u.innerHeight||1;return C((n-t.top)/(n+t.height),0,1)},be=e=>{if(!p)return;let t=h,n=r.environment?.background,i=q().transparent?[0,0,0,0]:[...fe(typeof n==`string`?n:void 0,[0,0,0]),1];if(p.viewport(0,0,d.width,d.height),!m){p.clearColor(...i),p.clear(p.COLOR_BUFFER_BIT);return}p.useProgram(m),e&&(p.uniform2f(t.uView,e.x,e.y),p.uniform1f(t.uZoom,e.zoom));let a=ge(),o=H/Math.max(U,1),s=me(r,o),c=a.position??[0,0,0],l=a.scale??1,u=y[0]*(typeof l==`number`?l:l[0]),f=y[1]*(typeof l==`number`?l:l[1]),g=(e,t)=>[e[0]*t/u,e[1]*t/f,e[2]*t];p.uniform3f(t.uO,(s.pos[0]-c[0])/u,(s.pos[1]-c[1])/f,s.pos[2]-c[2]),p.uniform3f(t.uF,...g(s.fwd,1)),p.uniform3f(t.uR,...g(s.right,s.tanY*o)),p.uniform3f(t.uU,...g(s.up,s.tanY)),p.uniform2f(t.uClip,s.near,s.far),p.uniform4f(t.uBg,...i),p.drawArrays(p.TRIANGLES,0,3)},Y=e=>{p&&v&&be(v.offset(k,e,{pointer:E,scroll:ye(),reduced:B}))},X=()=>{p&&(ve(),(!A||i)&&be())},xe=e=>{N+=e,N<2||(M<40?P+=e:P=Math.max(0,P-e),P<3||(P=N=0,n.pixelRatio===void 0&&T>1.01?(T=Math.max(1,T*.75),X()):S=!1))},Z=()=>{let e=l.visibilityState===`hidden`,t=F&&!R&&!e&&(I||q().pauseOffscreen===!1)&&!!v;if(t&&!A){j=performance.now();let e=t=>{A=requestAnimationFrame(e);let n=Math.min(Math.max((t-j)/1e3,0),.1);j=t,n>.002&&(M=M?M*.9+1/n*.1:1/n),S&&xe(n),k=Math.max(k+n*V,0),Y(n*V)};A=requestAnimationFrame(e)}else!t&&A&&(cancelAnimationFrame(A),A=0)},Se=e=>{let t=q(),r=globalThis.navigator??{},a;try{let t=e.getExtension(`WEBGL_debug_renderer_info`);a=String(e.getParameter(t?t.UNMASKED_RENDERER_WEBGL:e.RENDERER)??``)}catch{}x=b(t.quality,{deterministic:i,mobile:r.userAgentData?.mobile??/Mobi|Android|iPhone|iPad|iPod/i.test(r.userAgent??``),cores:r.hardwareConcurrency,memoryGb:r.deviceMemory,gpu:a}),S=(t.quality??`auto`)===`auto`&&!i,N=P=0,T=n.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,ee[x]),ve()},Ce=async()=>{let e=ge(),t=0,r=0,i=(i,o,s)=>{let c=he(a(i));if(n.onProgress){t++;let e=()=>{try{n.onProgress?.(++r,t)}catch{}};c.then(e,e)}return c.catch(t=>(_e({code:`asset-load`,message:`${e.id}: ${o}${t.message}${s?` — showing the photo flat`:``}`,path:`objects#${e.id}${s}`}),null))},[o,s]=await Promise.all([i(e.src,``,``),e.depth?i(e.depth,`depth map: `,`.depth`):null]);return{map:o,depth:s}},we=()=>{if(p){for(let e of g)p.deleteTexture(e);g=[],m&&p.deleteProgram(m),m=null}},Te=async()=>{if(_??=await Ce(),R||!p)return;let e=p;Se(e),v?.dispose();let t=ge(),{map:n,depth:r}=_,a=!r;if(v=se(ie(t.motion),{live:!i,flat:a}),!n)return;let o=C(w(t.strength,O.strength),0,1),s=e.createProgram(),c=(t,n)=>{let r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)&&!e.isContextLost())throw Error(`photo shader: ${e.getShaderInfoLog(r)}`);e.attachShader(s,r)};if(c(e.VERTEX_SHADER,le),c(e.FRAGMENT_SHADER,ue(a,oe(x,o))),e.bindAttribLocation(s,0,`aPos`),e.linkProgram(s),!e.getProgramParameter(s,e.LINK_STATUS)&&!e.isContextLost())throw Error(`photo shader: ${e.getProgramInfoLog(s)}`);m=s;for(let t of de)h[t]=e.getUniformLocation(s,t);e.bindBuffer(e.ARRAY_BUFFER,e.createBuffer()),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let l=(t,n,r)=>{let i=e.createTexture();if(g.push(i),e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,r?e.SRGB8_ALPHA8:e.RGBA8,e.RGBA,e.UNSIGNED_BYTE,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.MIRRORED_REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.MIRRORED_REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,r?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),r){e.generateMipmap(e.TEXTURE_2D);let t=e.getExtension(`EXT_texture_filter_anisotropic`);t&&e.texParameterf(e.TEXTURE_2D,t.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(4,e.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT)))}};l(0,n,!0),r&&l(1,r,!1),e.useProgram(s);let u=h;e.uniform1i(u.uMap,0),e.uniform1i(u.uDepth,1);let d=t.material??{},f=fe(d.color,[1,1,1]).map(pe);e.uniform3f(u.uTint,f[0],f[1],f[2]);let ee=C(w(d.opacity,1),0,1);e.uniform1f(u.uOpacity,ee),e.uniform1f(u.uIntensity,Math.max(0,w(d.emissiveIntensity,1))),e.uniform1f(u.uBlend,ee<1||/\.(png|webp)$/i.test(t.src)?1:0);let b=re(t,n.naturalWidth||n.width||1,n.naturalHeight||n.height||1),te=ae(o,b.width,b.height);e.uniform2f(u.uMaxOffset,...te.maxOffset),e.uniform2f(u.uInset,...te.inset),e.uniform1f(u.uFocus,C(w(t.focus,O.focus),0,1)),e.uniform1f(u.uWallSlope,ce),y=[b.width,b.height]},Q=()=>{if(L||R)return;L=!0;let e=q();p=d.getContext(`webgl2`,{alpha:!!e.transparent,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:i}),p?W=Te().then(()=>{R||(k=i?0:B?e.posterTime??0:k,Y(0),!i&&!B&&(F=!0,Z()),o(),z||n.onReady?.(Oe),z=!0)}).catch(e=>{_e({code:`build-error`,message:e.message}),s(e)}):(_e({code:`webgl-unavailable`,message:`WebGL is not available: no WebGL2 context`}),s(/* @__PURE__ */ Error(`webgl-unavailable`)))},Ee=e=>{D=e===null||!Number.isFinite(e)?null:C(e,0,1)},$=(e,t)=>{e!==void 0&&t!==void 0&&(E.x=e,E.y=t),E.inside=!0},De=()=>void 0,Oe={get scene(){return r},canvas:d,ready:c,input:{pointer:$,key:De,click:$,down:$,up:De,swipe:De,scroll:Ee},play(){F=!0,Q(),Z()},pause(){F=!1,Z()},async seek(e){if(L||Q(),await W,!p||!v)return;let t=Math.max(0,e);t<k-1e-9&&(k=0,v.offset(0,0,{pointer:E,scroll:0,reduced:B}));let n=t-k;k=t,Y(n)},time:()=>k,async update(e){await W,JSON.stringify(e.objects[0])!==JSON.stringify(r.objects[0])&&(_=null),r=e,p&&(we(),W=Te(),await W,Y(0))},resize:X,stats:()=>({triangles:+!!m,drawCalls:+!!m,geometries:+!!m,textures:g.length,fps:i?void 0:Math.round(M)||void 0}),inspect:()=>({objects:[],camera:{position:[...r.camera.position],target:[...r.camera.target??[0,0,0]]}}),snapshot(e=`image/png`,t){return be(),d.toDataURL(e,t)},state:()=>({}),pick:()=>null,emit(e,t){for(let n of[...K.get(e)??[]])try{n(t)}catch{}try{n.onEvent?.(e,t)}catch{}},on(e,t){let n=K.get(e);return n||K.set(e,n=/* @__PURE__ */ new Set),n.add(t),()=>n.delete(t)},setScrollProgress:Ee,dispose(){if(!R){R=!0,A&&cancelAnimationFrame(A),A=0;for(let e of G)e();G=[],v?.dispose(),we(),p?.getExtension(`WEBGL_lose_context`)?.loseContext(),p=null,d.remove()}}};if(J(e,`pointermove`,t=>{let n=e.getBoundingClientRect(),r=t;$((r.clientX-n.left)/Math.max(n.width,1)*2-1,-((r.clientY-n.top)/Math.max(n.height,1)*2-1))}),J(e,`pointerenter`,()=>E.inside=!0),J(e,`pointerleave`,()=>E.inside=!1),J(l,`visibilitychange`,Z),ve(),typeof ResizeObserver<`u`){let t=new ResizeObserver(X);t.observe(e),G.push(()=>t.disconnect())}let ke=q(),Ae=n.reducedMotion??(typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),je=ke.reducedMotion??`static`;if(Ae&&!i&&(je===`static`?B=!0:je===`slow`&&(V=.5)),i||ke.lazy===!1||typeof IntersectionObserver>`u`)Q();else{I=!1;let t=new IntersectionObserver(e=>{I=e.some(e=>e.isIntersecting),I&&Q(),Z()},{rootMargin:`200px 0px`});t.observe(e);let n=()=>{if(L||R||l.visibilityState===`hidden`||!e.isConnected)return;let t=e.getBoundingClientRect(),n=u.innerHeight||l.documentElement.clientHeight,r=u.innerWidth||l.documentElement.clientWidth;t.bottom>=-200&&t.top<=n+200&&t.right>=0&&t.left<=r&&(t.width>0||t.height>0)&&(I=!0,Q(),Z())},r=[setTimeout(n,500),setTimeout(n,2e3)],i=u.requestAnimationFrame(()=>i=u.requestAnimationFrame(n));J(u,`load`,n),J(u,`scroll`,n,{passive:!0}),J(l,`visibilitychange`,n),G.push(()=>{t.disconnect();for(let e of r)clearTimeout(e);u.cancelAnimationFrame(i)})}return d.isConnected&&X(),Oe}function U(e,t,n){let r=null,i=!1,a=!1,o=import.meta.url.replace(/[^/?#]*([?#].*)?$/,`agent3d-runtime.js`),s=import(
65
+ `,Oe=`vec4 photoTexel(vec2 uv){return texture(uMap,uv);}
66
+ `,ke=`vec4 photoTexel(vec2 uv){return parallaxTexel(uv);}
67
+ `,Ae=e=>`uniform vec3 uO;uniform vec3 uF;uniform vec3 uR;uniform vec3 uU;uniform vec2 uClip;uniform vec4 uBg;uniform float uBlend;in vec2 vNdc;out vec4 fragColor;vec3 toSrgb(vec3 v){return mix(pow(v,vec3(0.41666))*1.055-vec3(0.055),v*12.92,vec3(lessThanEqual(v,vec3(0.0031308))));}void main(){vec3 d=uF+uR*vNdc.x+uU*vNdc.y;float t=d.z<0.0?-uO.z/d.z:-1.0;vec2 uv=uO.xy+t*d.xy+0.5;vec2 fw=max(fwidth(uv),vec2(1e-7));vec4 c=photoTexel(uv);
68
+ ${e}
69
+ vec2 e=min(uv,1.0-uv)/fw;float cover=uO.z>0.0&&t>=uClip.x&&t<=uClip.y?clamp(min(e.x,e.y)+0.5,0.0,1.0):0.0;vec4 s=shade(c,1.0);float a=c.a*uOpacity<0.004?0.0:uBlend>0.5?s.a:1.0;vec4 photo=vec4(toSrgb(s.rgb)*a,a)+uBg*(1.0-a);fragColor=mix(uBg,photo,cover);}
70
+ `,je=(e,t,n)=>De+F+(e?Oe:I.replace(`__STEPS__`,String(t))+ke)+(n?.glsl??``)+Ae(n?.call(e?`uv`:`pxUv`,e?`textureLod(uDepth, pxUv, 0.0).r`:`photoHitDepth`,`uv`)??``),Me=[`uMap`,`uDepth`,`uPlate`,`uPlateDepth`,`uPlateOn`,`uTint`,`uOpacity`,`uIntensity`,`uView`,`uZoom`,`uMaxOffset`,`uInset`,`uFocus`,`uWallSlope`,`uO`,`uF`,`uR`,`uU`,`uClip`,`uBg`,`uBlend`],Ne=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Pe=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Fe=e=>{let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function Ie(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e??``);if(!n)return t;let r=n[1].length===3?n[1].replace(/./g,`$&$&`):n[1];return[0,2,4].map(e=>parseInt(r.slice(e,e+2),16)/255)}var Le=e=>e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4;function Re(e,t){let n=e.camera,r=n.target??[0,0,0],i={x:n.position[0],y:n.position[1],z:n.position[2],set(e,t,n){this.x=e,this.y=t,this.z=n}};D(i,{x:r[0],y:r[1],z:r[2]});let a=[i.x,i.y,i.z],o=Ne(a,r);Math.hypot(...o)===0&&(o=[0,0,1]),o=Fe(o);let s=Pe([0,1,0],o);Math.hypot(...s)===0&&(o=Fe([o[0],o[1],o[2]+1e-4]),s=Pe([0,1,0],o)),s=Fe(s);let c=Pe(o,s),l=E(w(n.fov,45),T(t,ne(e.target?.aspect)));return{pos:a,right:s,up:c,fwd:[-o[0],-o[1],-o[2]],tanY:Math.tan(l*S/2),near:w(n.near,.1),far:w(n.far,1e3)}}function ze(e){return new Promise((t,n)=>{let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>t(r),r.onerror=()=>n(/* @__PURE__ */ Error(`Cannot load texture ${e}`)),r.src=e})}function Be(e,t,n={}){let r=t,i=!!n.deterministic,a=te(n),o,s,c=new Promise((e,t)=>(o=e,s=t));c.catch(()=>void 0);let l=e.ownerDocument,u=l.defaultView,d=l.createElement(`canvas`);d.style.cssText=`display:block;width:100%;height:100%;outline:none;touch-action:manipulation;`;let f=u.getComputedStyle(e).position;f&&f!==`static`||(e.style.position=`relative`),e.appendChild(d);let p=null,m=null,h={},g=[],ee=null,_=null,v=null,x=[1,1],S=[1,1],T=`high`,E=!1,D=1,k={x:0,y:0,inside:!1},ie=null,A=0,j=0,oe=0,M=0,N=0,P=0,F=!1,I=!0,L=!1,R=!1,z=!1,B=!1,V=1,H=1,U=1,W=null,G=[],fe=/* @__PURE__ */ new Map,K=()=>r.target??{},pe=()=>r.objects[0],me=e=>{try{n.onError?.(e)}catch{}n.onError||console.warn(`[agent3d] ${e.code}: ${e.message}`)},q=(e,t,n,r)=>{e.addEventListener(t,n,r),G.push(()=>e.removeEventListener(t,n,r))},he=()=>{let t=Math.max(1,e.clientWidth||d.clientWidth||300);H=t,U=Math.max(1,e.clientHeight||Math.round(t/(ne(r.target?.aspect)??16/9))),d.width=Math.floor(H*D),d.height=Math.floor(U*D)},ge=()=>{if(ie!==null)return ie;if(i||B)return C(A/4,0,1);let t=Te(e),n=u.innerHeight||1;return C((n-t.top)/(n+t.height),0,1)},_e=e=>{if(!p)return;let t=h,n=r.environment?.background,i=K().transparent?[0,0,0,0]:[...Ie(typeof n==`string`?n:void 0,[0,0,0]),1];if(p.viewport(0,0,d.width,d.height),!m){p.clearColor(...i),p.clear(p.COLOR_BUFFER_BIT);return}p.useProgram(m);for(let[e,t]of Object.entries(v?.uniforms()??{})){let n=p.getUniformLocation(m,e);t.length===1?p.uniform1f(n,t[0]):t.length===2?p.uniform2fv(n,t):t.length===3?p.uniform3fv(n,t):p.uniform4fv(n,t)}if(e){let n=se(e,S);p.uniform2f(t.uView,e.x,e.y),p.uniform1f(t.uZoom,n.zoom),p.uniform2f(t.uInset,...n.inset)}let a=pe(),o=H/Math.max(U,1),s=Re(r,o),c=a.position??[0,0,0],l=a.scale??1,u=x[0]*(typeof l==`number`?l:l[0]),f=x[1]*(typeof l==`number`?l:l[1]),g=(e,t)=>[e[0]*t/u,e[1]*t/f,e[2]*t];p.uniform3f(t.uO,(s.pos[0]-c[0])/u,(s.pos[1]-c[1])/f,s.pos[2]-c[2]),p.uniform3f(t.uF,...g(s.fwd,1)),p.uniform3f(t.uR,...g(s.right,s.tanY*o)),p.uniform3f(t.uU,...g(s.up,s.tanY)),p.uniform2f(t.uClip,s.near,s.far),p.uniform4f(t.uBg,...i),p.drawArrays(p.TRIANGLES,0,3)},J=e=>{v?.frame(A,e,{pointer:k,reduced:B}),p&&_&&_e(_.offset(A,e,{pointer:k,scroll:ge(),reduced:B}))},Y=()=>{p&&(he(),(!j||i)&&_e())},ve=e=>{N+=e,N<2||(M<40?P+=e:P=Math.max(0,P-e),P<3||(P=N=0,n.pixelRatio===void 0&&D>1.01?(D=Math.max(1,D*.75),Y()):E=!1))},X=()=>{let e=l.visibilityState===`hidden`,t=F&&!R&&!e&&(I||K().pauseOffscreen===!1)&&!!_;if(t&&!j){oe=performance.now();let e=t=>{j=requestAnimationFrame(e);let n=Math.min(Math.max((t-oe)/1e3,0),.1);oe=t,n>.002&&(M=M?M*.9+1/n*.1:1/n),E&&ve(n),A=Math.max(A+n*V,0),J(n*V)};j=requestAnimationFrame(e)}else!t&&j&&(cancelAnimationFrame(j),j=0)},ye=e=>{let t=K(),r=globalThis.navigator??{},a;try{let t=e.getExtension(`WEBGL_debug_renderer_info`);a=String(e.getParameter(t?t.UNMASKED_RENDERER_WEBGL:e.RENDERER)??``)}catch{}T=b(t.quality,{deterministic:i,mobile:r.userAgentData?.mobile??/Mobi|Android|iPhone|iPad|iPod/i.test(r.userAgent??``),cores:r.hardwareConcurrency,memoryGb:r.deviceMemory,gpu:a}),E=(t.quality??`auto`)===`auto`&&!i,N=P=0,D=n.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,y[T]),he()},be=async()=>{let e=pe(),t=0,r=0,i=(i,o,s)=>{let c=ze(a(i));if(n.onProgress){t++;let e=()=>{try{n.onProgress?.(++r,t)}catch{}};c.then(e,e)}return c.catch(t=>(me({code:`asset-load`,message:`${e.id}: ${o}${t.message}${s?` — showing the photo flat`:``}`,path:`objects#${e.id}${s}`}),null))},o=e.depth&&e.plate&&e.plateDepth,[s,c,...l]=await Promise.all([i(e.src,``,``),e.depth?i(e.depth,`depth map: `,`.depth`):null,o?i(e.plate,`plate: `,``):null,o?i(e.plateDepth,`plate depth: `,``):null]);return{map:s,depth:c,plate:l}},xe=()=>{if(p){for(let e of g)p.deleteTexture(e);g=[],m&&p.deleteProgram(m),m=null}},Se=async()=>{if(ee??=await be(),R||!p)return;let e=p;ye(e),_?.dispose();let t=pe(),{map:n,depth:r,plate:a}=ee,o=!r;if(_=ue(ae(t.motion),{live:!i,flat:o}),!n)return;let s=C(w(t.strength,O.strength),0,1),c=re(t,n.naturalWidth||n.width||1,n.naturalHeight||n.height||1),l=ae(t.motion);v=we(t.effects,{depth:!o,color:e=>Ie(e,[1,1,1]).map(Le),aspect:c.width/c.height,live:!i,smoothing:l.smoothing,speed:l.speed,focus:t.focus,quality:T,parallax:!o,inset:o?void 0:ce(s,c.width,c.height).inset});let u=e.createProgram(),d=(t,n)=>{let r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)&&!e.isContextLost())throw Error(`photo shader: ${e.getShaderInfoLog(r)}`);e.attachShader(u,r)};if(d(e.VERTEX_SHADER,Ee),d(e.FRAGMENT_SHADER,je(o,le(T,s),v)),e.bindAttribLocation(u,0,`aPos`),e.linkProgram(u),!e.getProgramParameter(u,e.LINK_STATUS)&&!e.isContextLost())throw Error(`photo shader: ${e.getProgramInfoLog(u)}`);m=u;for(let t of Me)h[t]=e.getUniformLocation(u,t);e.bindBuffer(e.ARRAY_BUFFER,e.createBuffer()),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let f=(t,n,r,i=r)=>{let a=e.createTexture();if(g.push(a),e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,r?e.SRGB8_ALPHA8:e.RGBA8,e.RGBA,e.UNSIGNED_BYTE,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.MIRRORED_REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.MIRRORED_REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,i?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),i&&e.generateMipmap(e.TEXTURE_2D),r){let t=e.getExtension(`EXT_texture_filter_anisotropic`);t&&e.texParameterf(e.TEXTURE_2D,t.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(4,e.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT)))}};f(0,n,!0),r&&f(1,r,!1,v.depthMips);let y=!!(r&&a[0]&&a[1]);y&&(f(2,a[0],!0),f(3,a[1],!1)),e.useProgram(u);let b=h;e.uniform1i(b.uMap,0),e.uniform1i(b.uDepth,1),e.uniform1i(b.uPlate,y?2:0),e.uniform1i(b.uPlateDepth,y?3:1),e.uniform1f(b.uPlateOn,+!!y);let te=t.material??{},E=Ie(te.color,[1,1,1]).map(Le);e.uniform3f(b.uTint,E[0],E[1],E[2]);let ne=C(w(te.opacity,1),0,1);e.uniform1f(b.uOpacity,ne),e.uniform1f(b.uIntensity,Math.max(0,w(te.emissiveIntensity,1))),e.uniform1f(b.uBlend,ne<1||v.alpha||/\.(png|webp)$/i.test(t.src)?1:0);let D=ce(s,c.width,c.height);e.uniform2f(b.uMaxOffset,...D.maxOffset),e.uniform2f(b.uInset,...D.inset),S=D.inset,e.uniform1f(b.uFocus,C(w(t.focus,O.focus),0,1)),e.uniform1f(b.uWallSlope,de),x=[c.width,c.height]},Z=()=>{if(L||R)return;L=!0;let e=K();p=d.getContext(`webgl2`,{alpha:!!e.transparent,antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:i}),p?W=Se().then(()=>{R||(A=i?0:B?e.posterTime??0:A,J(0),!i&&!B&&(F=!0,X()),o(),z||n.onReady?.(De),z=!0)}).catch(e=>{me({code:`build-error`,message:e.message}),s(e)}):(me({code:`webgl-unavailable`,message:`WebGL is not available: no WebGL2 context`}),s(/* @__PURE__ */ Error(`webgl-unavailable`)))},Ce=e=>{ie=e===null||!Number.isFinite(e)?null:C(e,0,1)},Q=(e,t)=>{e!==void 0&&t!==void 0&&(k.x=e,k.y=t),k.inside=!0},$=()=>void 0,De={get scene(){return r},canvas:d,ready:c,input:{pointer:Q,key:$,click:Q,down:Q,up:$,swipe:$,scroll:Ce},play(){F=!0,Z(),X()},pause(){F=!1,X()},async seek(e){if(L||Z(),await W,!p||!_)return;let t=Math.max(0,e);t<A-1e-9&&(A=0,_.offset(0,0,{pointer:k,scroll:0,reduced:B}));let n=t-A;A=t,J(n)},time:()=>A,async update(e){await W,JSON.stringify(e.objects[0])!==JSON.stringify(r.objects[0])&&(ee=null),r=e,p&&(xe(),W=Se(),await W,J(0))},resize:Y,stats:()=>({triangles:+!!m,drawCalls:+!!m,geometries:+!!m,textures:g.length,fps:i?void 0:Math.round(M)||void 0}),inspect:()=>({objects:[],camera:{position:[...r.camera.position],target:[...r.camera.target??[0,0,0]]}}),snapshot(e=`image/png`,t){return _e(),d.toDataURL(e,t)},state:()=>({}),pick:()=>null,emit(e,t){for(let n of[...fe.get(e)??[]])try{n(t)}catch{}try{n.onEvent?.(e,t)}catch{}},on(e,t){let n=fe.get(e);return n||fe.set(e,n=/* @__PURE__ */ new Set),n.add(t),()=>n.delete(t)},setScrollProgress:Ce,dispose(){if(!R){R=!0,j&&cancelAnimationFrame(j),j=0;for(let e of G)e();G=[],_?.dispose(),xe(),p?.getExtension(`WEBGL_lose_context`)?.loseContext(),p=null,d.remove()}}};if(q(e,`pointermove`,t=>{let n=e.getBoundingClientRect(),r=t;Q((r.clientX-n.left)/Math.max(n.width,1)*2-1,-((r.clientY-n.top)/Math.max(n.height,1)*2-1))}),q(e,`pointerenter`,()=>k.inside=!0),q(e,`pointerleave`,()=>k.inside=!1),q(l,`visibilitychange`,X),he(),typeof ResizeObserver<`u`){let t=new ResizeObserver(Y);t.observe(e),G.push(()=>t.disconnect())}let Oe=K(),ke=n.reducedMotion??(typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),Ae=Oe.reducedMotion??`static`;if(ke&&!i&&(Ae===`static`?B=!0:Ae===`slow`&&(V=.5)),i||Oe.lazy===!1||typeof IntersectionObserver>`u`)Z();else{I=!1;let t=new IntersectionObserver(e=>{I=e.some(e=>e.isIntersecting),I&&Z(),X()},{rootMargin:`200px 0px`});t.observe(e);let n=()=>{if(L||R||l.visibilityState===`hidden`||!e.isConnected)return;let t=e.getBoundingClientRect(),n=u.innerHeight||l.documentElement.clientHeight,r=u.innerWidth||l.documentElement.clientWidth;t.bottom>=-200&&t.top<=n+200&&t.right>=0&&t.left<=r&&(t.width>0||t.height>0)&&(I=!0,Z(),X())},r=[setTimeout(n,500),setTimeout(n,2e3)],i=u.requestAnimationFrame(()=>i=u.requestAnimationFrame(n));q(u,`load`,n),q(u,`scroll`,n,{passive:!0}),q(l,`visibilitychange`,n),G.push(()=>{t.disconnect();for(let e of r)clearTimeout(e);u.cancelAnimationFrame(i)})}return d.isConnected&&Y(),De}function Ve(e,t,n){let r=null,i=!1,a=!1,o=import.meta.url.replace(/[^/?#]*([?#].*)?$/,`agent3d-runtime.js`),s=import(
30
71
  /* @vite-ignore */
31
- o).then(o=>{if(a)throw Error(`disposed`);return r=o.mountScene(e,t,n),i&&r.pause(),r.ready},e=>{throw n.onError?.({code:`runtime-load`,message:`This scene needs the full runtime (${o}): ${e.message}`}),e});s.catch(()=>void 0);let c={ready:s,play:()=>(i=!1,r?.play()),pause:()=>(i=!0,r?.pause()),seek:async e=>(await s,r.seek(e)),dispose:()=>(a=!0,r?.dispose())};return new Proxy(c,{get(e,t){if(t in c)return c[t];let n=r?.[t];return typeof n==`function`?n.bind(r):n}})}var W=class extends v{mountPlayer(e,t,r){return n(t).ok?H(e,t,r):U(e,t,r)}};y(W);export{W as Agent3DPhotoElement,H as mountPhotoScene};
72
+ o).then(o=>{if(a)throw Error(`disposed`);return r=o.mountScene(e,t,n),i&&r.pause(),r.ready},e=>{throw n.onError?.({code:`runtime-load`,message:`This scene needs the full runtime (${o}): ${e.message}`}),e});s.catch(()=>void 0);let c={ready:s,play:()=>(i=!1,r?.play()),pause:()=>(i=!0,r?.pause()),seek:async e=>(await s,r.seek(e)),dispose:()=>(a=!0,r?.dispose())};return new Proxy(c,{get(e,t){if(t in c)return c[t];let n=r?.[t];return typeof n==`function`?n.bind(r):n}})}var He=class extends _{mountPlayer(e,t,r){return n(t).ok?Be(e,t,r):Ve(e,t,r)}};v(He);export{He as Agent3DPhotoElement,Be as mountPhotoScene};