@fleox/agent3d 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +10 -10
  2. package/changelog.json +11 -0
  3. package/dist/agent/agent3d.mjs +11 -11
  4. package/dist/agent/chunks/{depth-Dih8jLqx.mjs → depth-BZT4gseQ.mjs} +1 -1
  5. package/dist/agent/chunks/{depth-0bZsQn6N.mjs → depth-CD_ql3QJ.mjs} +1 -1
  6. package/dist/agent/chunks/{export-Cdqt3mt_.mjs → export-bJwh2SqG.mjs} +4 -2
  7. package/dist/agent/chunks/{package-d5e08XSG.mjs → package-fMbw9UGh.mjs} +1 -1
  8. package/dist/agent/chunks/{tools-Cv6N_YBI.mjs → tools-Cm4BqDkO.mjs} +4 -4
  9. package/dist/runtime/agent3d-runtime.js +2 -2
  10. package/dist/runtime/agent3d-runtime.single.js +75 -75
  11. package/dist/runtime/chunks/{photo-BlDYgYFM.js → photo-DNf14X7B.js} +9 -9
  12. package/dist/studio/assets/{assets-BFJsr9Oo.js → assets-BW5lQkYR.js} +1 -1
  13. package/dist/studio/assets/{camera-DT0xHipx.js → camera-BgzPVnn-.js} +1 -1
  14. package/dist/studio/assets/{editor-BjgHj9g8.js → editor-NkBUKsDB.js} +1 -1
  15. package/dist/studio/assets/{game-BXZEc9HN.js → game-DARpu0ah.js} +3 -3
  16. package/dist/studio/assets/{generators-DqkPMEzm.js → generators-BjIs-kHx.js} +1 -1
  17. package/dist/studio/assets/{index-DVTzVcBD.js → index-L-N-e2KM.js} +8 -8
  18. package/dist/studio/assets/{model-BqQW4Dg-.js → model-CqI8j03Z.js} +1 -1
  19. package/dist/studio/assets/{params-gVpEEiSK.js → params-DhsDKSDs.js} +1 -1
  20. package/dist/studio/assets/{photo-DRoVO5iZ.js → photo-DAHd1yNF.js} +9 -9
  21. package/dist/studio/assets/{physicsHost-DNdZ7AsT.js → physicsHost-tEUto2-_.js} +1 -1
  22. package/dist/studio/assets/{postfx-JFUGdY0d.js → postfx-BGu30OJK.js} +1 -1
  23. package/dist/studio/assets/{runtime-CMAP4azF.js → runtime-C_qkIpAK.js} +4 -4
  24. package/dist/studio/assets/{shaders-C7u6rN_6.js → shaders-Dt6FGXH_.js} +1 -1
  25. package/dist/studio/assets/{svg-DkIOJjzS.js → svg-ZZt5MdNf.js} +1 -1
  26. package/dist/studio/assets/{text-LISSAism.js → text-B-HM422i.js} +1 -1
  27. package/dist/studio/index.html +1 -1
  28. package/package.json +1 -1
  29. package/plugin/.claude-plugin/plugin.json +1 -1
  30. package/plugin/skills/agent3d-assets/SKILL.md +27 -27
  31. package/plugin/skills/agent3d-create/SKILL.md +28 -27
  32. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  33. package/plugin/skills/agent3d-create/references/recipes.md +6 -6
  34. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  35. package/plugin/skills/agent3d-edit/references/patch-ops.md +2 -2
  36. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  37. package/plugin/skills/agent3d-publish/SKILL.md +21 -21
  38. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  39. package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
  40. package/templates/hero-photo-3d/assets/manifest.json +3 -3
  41. package/templates/hero-photo-3d/assets/textures/street.webp +0 -0
  42. package/templates/hero-photo-3d/scene.json +1 -1
  43. package/templates/hero-photo-3d/assets/textures/street.jpg +0 -0
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./GLTFLoader-1Zd9N406.js","./three.module-CnI50X0U.js","./BufferGeometryUtils-CAlXAboW.js","./SkeletonUtils-CG5akqME.js"])))=>i.map(i=>d[i]);
2
- import{Ln as e,U as t,c as n,d as r,ht as i,mt as a}from"./three.module-CnI50X0U.js";import{v as o}from"./camera-DT0xHipx.js";import{o as s}from"./runtime-CMAP4azF.js";import{h as c}from"./index-DVTzVcBD.js";var l=new Map;function u(e){let t=new Uint8Array(e),n;if(t.byteLength>=20&&new DataView(e).getUint32(0,!0)===1179937895){let r=new DataView(e).getUint32(12,!0);n=new TextDecoder().decode(t.subarray(20,20+r))}else n=new TextDecoder().decode(t);try{let e=JSON.parse(n);return Array.isArray(e.extensionsUsed)?e.extensionsUsed.filter(e=>typeof e==`string`):[]}catch{return[]}}async function d(e){let t=l.get(e);return t||(t=(async()=>{let[{GLTFLoader:t},n]=await Promise.all([c(()=>import(`./GLTFLoader-1Zd9N406.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),fetch(e)]);if(!n.ok)throw Error(`HTTP ${n.status} for ${e}`);let r=await n.arrayBuffer(),i=u(r);if(i.includes(`KHR_draco_mesh_compression`))throw Error(`${e} uses Draco compression (KHR_draco_mesh_compression), which the Agent3D runtime does not decode. Re-export it without Draco (Blender: uncheck "Compression"), or convert it to meshopt with gltfpack (\`gltfpack -i in.glb -o out.glb -cc\`), then run \`agent3d assets optimize\`.`);let a=new t;if(i.includes(`EXT_meshopt_compression`)){let{MeshoptDecoder:e}=await c(async()=>{let{MeshoptDecoder:e}=await import(`./meshopt_decoder.module-DXTYc6wn.js`);return{MeshoptDecoder:e}},[],import.meta.url);await e.ready,a.setMeshoptDecoder(e)}let o=e.slice(0,e.lastIndexOf(`/`)+1);return a.parseAsync(r,/^data:/.test(e)?``:o)})(),t.catch(()=>l.delete(e)),l.set(e,t)),t}function f(e,t){e.traverse(e=>{let n=e;if(n.isMesh&&n.morphTargetDictionary&&n.morphTargetInfluences)for(let[e,r]of Object.entries(t)){let t=n.morphTargetDictionary[e];t!==void 0&&typeof r==`number`&&(n.morphTargetInfluences[t]=r)}})}async function p(l,u){let p=await d(u.resolveAsset(l.src)),{clone:m}=await c(async()=>{let{clone:e}=await import(`./SkeletonUtils-CG5akqME.js`);return{clone:e}},[],import.meta.url),h=m(p.scene),g=new t;g.add(h),h.updateMatrixWorld(!0);let _=new r().setFromObject(h);if(!_.isEmpty()){let t=_.getSize(new e),n=Math.max(t.x,t.y,t.z),r=l.fit&&n>0?l.fit/n:1;if(h.scale.multiplyScalar(r),l.center!==!1){let t=_.getCenter(new e);h.position.set(-t.x*r,-_.min.y*r,-t.z*r)}}h.traverse(e=>{let t=e;t.isMesh&&(t.castShadow=l.castShadow??!0,t.receiveShadow=l.receiveShadow??!1)}),l.material&&await s(h,l.material,u),l.morph&&f(h,l.morph);let v;if(p.animations.length){let e=new n(h),t=null,r=e=>typeof e==`number`||/^\d+$/.test(String(e))?p.animations[Number(e)]:p.animations.find(t=>t.name===e)??p.animations.find(t=>t.name.toLowerCase().includes(String(e).toLowerCase())),s=new Set,c=e=>{let t=r(e);return!t&&!s.has(String(e))&&(s.add(String(e)),u.issue(`asset-load`,`Model ${l.id} has no animation clip "${e}" (clips: ${p.animations.map(e=>e.name).join(`, `)})`,`objects#${l.id}.animation.clip`)),t},d=(n,r={})=>{let s=c(n);if(!s)return;let l=e.clipAction(s);l.setLoop(r.loop===!1?a:i,1/0),l.clampWhenFinished=r.loop===!1,l.timeScale=o(r.speed,1),l.enabled=!0,t&&t!==l?(l.reset().setEffectiveWeight(1).play(),t.crossFadeTo(l,o(r.crossfade,.3),!1)):l.setEffectiveWeight(1).play(),t=l},f=t=>{let n=c(t);if(!n)return null;let r=e.clipAction(n);return r.isRunning()||(r.enabled=!0,r.setLoop(i,1/0),r.play()),r},m={weight(e,t){f(e)?.setEffectiveWeight(Math.max(0,t))},speed(e,t){let n=f(e);n&&(n.timeScale=t)},time(e,t){let n=f(e);n&&(n.paused=!0,n.time=Math.max(0,t))}},g=l.animation??{},_=()=>{e.stopAllAction(),t=null,d(g.clip??0,g),g.offset&&t&&(t.time=Math.max(0,g.offset));for(let[e,t]of Object.entries(g.blend??{}))m.weight(e,t);e.update(0)};v={mixer:e,clips:p.animations,play:d,control:m,reset:_},_()}return{object:g,animator:v}}export{p as buildModel};
2
+ import{Ln as e,U as t,c as n,d as r,ht as i,mt as a}from"./three.module-CnI50X0U.js";import{v as o}from"./camera-BgzPVnn-.js";import{o as s}from"./runtime-C_qkIpAK.js";import{h as c}from"./index-L-N-e2KM.js";var l=new Map;function u(e){let t=new Uint8Array(e),n;if(t.byteLength>=20&&new DataView(e).getUint32(0,!0)===1179937895){let r=new DataView(e).getUint32(12,!0);n=new TextDecoder().decode(t.subarray(20,20+r))}else n=new TextDecoder().decode(t);try{let e=JSON.parse(n);return Array.isArray(e.extensionsUsed)?e.extensionsUsed.filter(e=>typeof e==`string`):[]}catch{return[]}}async function d(e){let t=l.get(e);return t||(t=(async()=>{let[{GLTFLoader:t},n]=await Promise.all([c(()=>import(`./GLTFLoader-1Zd9N406.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),fetch(e)]);if(!n.ok)throw Error(`HTTP ${n.status} for ${e}`);let r=await n.arrayBuffer(),i=u(r);if(i.includes(`KHR_draco_mesh_compression`))throw Error(`${e} uses Draco compression (KHR_draco_mesh_compression), which the Agent3D runtime does not decode. Re-export it without Draco (Blender: uncheck "Compression"), or convert it to meshopt with gltfpack (\`gltfpack -i in.glb -o out.glb -cc\`), then run \`agent3d assets optimize\`.`);let a=new t;if(i.includes(`EXT_meshopt_compression`)){let{MeshoptDecoder:e}=await c(async()=>{let{MeshoptDecoder:e}=await import(`./meshopt_decoder.module-DXTYc6wn.js`);return{MeshoptDecoder:e}},[],import.meta.url);await e.ready,a.setMeshoptDecoder(e)}let o=e.slice(0,e.lastIndexOf(`/`)+1);return a.parseAsync(r,/^data:/.test(e)?``:o)})(),t.catch(()=>l.delete(e)),l.set(e,t)),t}function f(e,t){e.traverse(e=>{let n=e;if(n.isMesh&&n.morphTargetDictionary&&n.morphTargetInfluences)for(let[e,r]of Object.entries(t)){let t=n.morphTargetDictionary[e];t!==void 0&&typeof r==`number`&&(n.morphTargetInfluences[t]=r)}})}async function p(l,u){let p=await d(u.resolveAsset(l.src)),{clone:m}=await c(async()=>{let{clone:e}=await import(`./SkeletonUtils-CG5akqME.js`);return{clone:e}},[],import.meta.url),h=m(p.scene),g=new t;g.add(h),h.updateMatrixWorld(!0);let _=new r().setFromObject(h);if(!_.isEmpty()){let t=_.getSize(new e),n=Math.max(t.x,t.y,t.z),r=l.fit&&n>0?l.fit/n:1;if(h.scale.multiplyScalar(r),l.center!==!1){let t=_.getCenter(new e);h.position.set(-t.x*r,-_.min.y*r,-t.z*r)}}h.traverse(e=>{let t=e;t.isMesh&&(t.castShadow=l.castShadow??!0,t.receiveShadow=l.receiveShadow??!1)}),l.material&&await s(h,l.material,u),l.morph&&f(h,l.morph);let v;if(p.animations.length){let e=new n(h),t=null,r=e=>typeof e==`number`||/^\d+$/.test(String(e))?p.animations[Number(e)]:p.animations.find(t=>t.name===e)??p.animations.find(t=>t.name.toLowerCase().includes(String(e).toLowerCase())),s=new Set,c=e=>{let t=r(e);return!t&&!s.has(String(e))&&(s.add(String(e)),u.issue(`asset-load`,`Model ${l.id} has no animation clip "${e}" (clips: ${p.animations.map(e=>e.name).join(`, `)})`,`objects#${l.id}.animation.clip`)),t},d=(n,r={})=>{let s=c(n);if(!s)return;let l=e.clipAction(s);l.setLoop(r.loop===!1?a:i,1/0),l.clampWhenFinished=r.loop===!1,l.timeScale=o(r.speed,1),l.enabled=!0,t&&t!==l?(l.reset().setEffectiveWeight(1).play(),t.crossFadeTo(l,o(r.crossfade,.3),!1)):l.setEffectiveWeight(1).play(),t=l},f=t=>{let n=c(t);if(!n)return null;let r=e.clipAction(n);return r.isRunning()||(r.enabled=!0,r.setLoop(i,1/0),r.play()),r},m={weight(e,t){f(e)?.setEffectiveWeight(Math.max(0,t))},speed(e,t){let n=f(e);n&&(n.timeScale=t)},time(e,t){let n=f(e);n&&(n.paused=!0,n.time=Math.max(0,t))}},g=l.animation??{},_=()=>{e.stopAllAction(),t=null,d(g.clip??0,g),g.offset&&t&&(t.time=Math.max(0,g.offset));for(let[e,t]of Object.entries(g.blend??{}))m.weight(e,t);e.update(0)};v={mixer:e,clips:p.animations,play:d,control:m,reset:_},_()}return{object:g,animator:v}}export{p as buildModel};
@@ -1 +1 @@
1
- import{x as e}from"./three.module-CnI50X0U.js";import{C as t,D as n}from"./index-DVTzVcBD.js";var r=(t,n)=>{try{return t?t.color(n).clone():new e(n)}catch{return new e(n)}};function i(e,t,n){let i=t??{},a=t=>{let n=e.params.find(e=>e.name===t);if(!n)throw Error(`${e.id}: no catalog param "${t}"`);return n},o=e=>{let t=a(e),n=i[e];return n===void 0?t.default:n},s=(e,t)=>{let n=a(e);return n.min!==void 0&&t<n.min&&(t=n.min),n.max!==void 0&&t>n.max&&(t=n.max),t},c=e=>{let t=o(e);return typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isFinite(t)||(t=a(e).default),s(e,typeof t==`number`?t:0)};return{num:c,numOrNull:e=>i[e]===null?null:c(e),int:e=>Math.round(c(e)),bool:e=>{let t=o(e);return typeof t==`boolean`?t:!!a(e).default},str:e=>{let t=a(e),n=o(e);return typeof n==`string`&&(!t.options||t.options.includes(n))?n:t.default},color:e=>{let t=o(e);return r(n,typeof t==`string`?t:String(a(e).default??`#ffffff`))},colors:e=>{let t=o(e);return typeof t==`string`&&(t=[t]),Array.isArray(t)&&t.length!==0||(t=a(e).default),t.map(e=>r(n,typeof e==`string`?e:`#ffffff`))},vec3:e=>{let t=o(e),n=a(e).default??[0,0,0];return Array.isArray(t)?[0,1,2].map(e=>typeof t[e]==`number`?t[e]:n[e]):[...n]},raw:e=>o(e)}}var a=(e,t)=>{let n=e.find(e=>e.id===t);if(!n)throw Error(`unknown catalog id ${t}`);return n},o=(e,n,r)=>i(a(t,e),n,r),s=(e,t,r)=>i(a(n,e),t,r);export{i as n,s as r,o as t};
1
+ import{x as e}from"./three.module-CnI50X0U.js";import{C as t,D as n}from"./index-L-N-e2KM.js";var r=(t,n)=>{try{return t?t.color(n).clone():new e(n)}catch{return new e(n)}};function i(e,t,n){let i=t??{},a=t=>{let n=e.params.find(e=>e.name===t);if(!n)throw Error(`${e.id}: no catalog param "${t}"`);return n},o=e=>{let t=a(e),n=i[e];return n===void 0?t.default:n},s=(e,t)=>{let n=a(e);return n.min!==void 0&&t<n.min&&(t=n.min),n.max!==void 0&&t>n.max&&(t=n.max),t},c=e=>{let t=o(e);return typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isFinite(t)||(t=a(e).default),s(e,typeof t==`number`?t:0)};return{num:c,numOrNull:e=>i[e]===null?null:c(e),int:e=>Math.round(c(e)),bool:e=>{let t=o(e);return typeof t==`boolean`?t:!!a(e).default},str:e=>{let t=a(e),n=o(e);return typeof n==`string`&&(!t.options||t.options.includes(n))?n:t.default},color:e=>{let t=o(e);return r(n,typeof t==`string`?t:String(a(e).default??`#ffffff`))},colors:e=>{let t=o(e);return typeof t==`string`&&(t=[t]),Array.isArray(t)&&t.length!==0||(t=a(e).default),t.map(e=>r(n,typeof e==`string`?e:`#ffffff`))},vec3:e=>{let t=o(e),n=a(e).default??[0,0,0];return Array.isArray(t)?[0,1,2].map(e=>typeof t[e]==`number`?t[e]:n[e]):[...n]},raw:e=>o(e)}}var a=(e,t)=>{let n=e.find(e=>e.id===t);if(!n)throw Error(`unknown catalog id ${t}`);return n},o=(e,n,r)=>i(a(t,e),n,r),s=(e,t,r)=>i(a(n,e),t,r);export{i as n,s as r,o as t};
@@ -1,4 +1,4 @@
1
- import{Bt as e,In as t,Ln as n,St as r,U as i,ct as a,d as o,h as s,kt as c,m as l,mn as u,on as d,rn as f,x as p,xt as m}from"./three.module-CnI50X0U.js";import{i as h}from"./assets-BFJsr9Oo.js";import{d as g,p as _,v}from"./camera-DT0xHipx.js";var y={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function b(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??y.width;return{width:o,height:o/r}}function x(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:{let e=Math.min(1,r/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(r),y:t*Math.cos(r),zoom:0}}case`zoom`:return{x:0,y:0,zoom:.5-.5*Math.cos(r)};default:return{x:0,y:0,zoom:0}}}function ee(e){let t=_(v(e?.pointer,1),0,1);return{pointer:t,scroll:_(v(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,v(e?.speed,y.speed)),smoothing:_(v(e?.smoothing,y.smoothing),0,.99)}}function te(e,t){let n=t.reduced?{x:0,y:0,zoom:0}:x(e.auto,e.speed,t.t),r=e.pointer*(t.reduced?.5:1),i=0,a=0,o=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(i=t.gyro.x,a=t.gyro.y,o=+(r>0)):r>0&&(i=t.pointer.x,a=t.pointer.y,o=_(t.pointer.weight,0,1));let s=n.x*(1-o)+i*r*o,c=n.y*(1-o)+a*r*o;return e.scroll>0&&(c+=(_(t.scroll,0,1)*2-1)*e.scroll),{x:_(s,-1,1),y:_(c,-1,1),zoom:n.zoom*(1-o)}}function S(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-_(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function C(e,t,n){let r=_(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function ne(e,t,n){let r=Math.round(_(v(e,y.segments),2,1024));return t>=n?[r,Math.max(1,Math.round(r*n/t))]:[Math.max(1,Math.round(r*t/n)),r]}function w(e,t){return _(e,0,1)*t*.25}function re(e,t,n,r){let i=Math.round(_(v(e,y.layers),2,16)),a=[],o=_(n,0,1)*r*.1;for(let e=0;e<i;e++){let n=e/i,s=(e+1)/i,c=(n+s)/2;a.push({lo:n,hi:s,center:c,feather:.35/i,z:(c-t)*o+e*.001*r,background:e===0})}return a}function ie(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:_(i/20,-1,1),y:_(-a/20,-1,1)}}var T=`
1
+ import{Bt as e,In as t,Ln as n,St as r,U as i,ct as a,d as o,h as s,kt as c,m as l,mn as u,on as d,rn as f,x as p,xt as m}from"./three.module-CnI50X0U.js";import{i as h}from"./assets-BW5lQkYR.js";import{d as g,p as _,v}from"./camera-BgzPVnn-.js";var y={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9};function ee(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??y.width;return{width:o,height:o/r}}function b(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:{let e=Math.min(1,r/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(r),y:t*Math.cos(r),zoom:0}}case`zoom`:return{x:0,y:0,zoom:.5-.5*Math.cos(r)};default:return{x:0,y:0,zoom:0}}}function te(e){let t=_(v(e?.pointer,1),0,1);return{pointer:t,scroll:_(v(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,v(e?.speed,y.speed)),smoothing:_(v(e?.smoothing,y.smoothing),0,.99)}}function x(e,t){let n=t.reduced?{x:0,y:0,zoom:0}:b(e.auto,e.speed,t.t),r=e.pointer*(t.reduced?.5:1),i=0,a=0,o=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(i=t.gyro.x,a=t.gyro.y,o=+(r>0)):r>0&&(i=t.pointer.x,a=t.pointer.y,o=_(t.pointer.weight,0,1));let s=n.x*(1-o)+i*r*o,c=n.y*(1-o)+a*r*o;return e.scroll>0&&(c+=(_(t.scroll,0,1)*2-1)*e.scroll),{x:_(s,-1,1),y:_(c,-1,1),zoom:n.zoom*(1-o)}}function S(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-_(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function C(e,t,n){let r=_(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function ne(e,t,n){let r=Math.round(_(v(e,y.segments),2,1024));return t>=n?[r,Math.max(1,Math.round(r*n/t))]:[Math.max(1,Math.round(r*t/n)),r]}function w(e,t){return _(e,0,1)*t*.25}function re(e,t,n,r){let i=Math.round(_(v(e,y.layers),2,16)),a=[],o=_(n,0,1)*r*.1;for(let e=0;e<i;e++){let n=e/i,s=(e+1)/i,c=(n+s)/2;a.push({lo:n,hi:s,center:c,feather:.35/i,z:(c-t)*o+e*.001*r,background:e===0})}return a}function ie(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:_(i/20,-1,1),y:_(-a/20,-1,1)}}var T=`
2
2
  uniform sampler2D uMap;
3
3
  uniform vec3 uTint;
4
4
  uniform float uOpacity;
@@ -12,7 +12,7 @@ void main() {
12
12
  vUv = uv;
13
13
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
14
14
  }
15
- `,ae=`
15
+ `,D=`
16
16
  ${T}
17
17
  uniform sampler2D uDepth;
18
18
  uniform vec2 uView;
@@ -22,7 +22,7 @@ uniform vec2 uInset;
22
22
  uniform float uFocus;
23
23
  uniform float uWallSlope;
24
24
  varying vec2 vUv;
25
- const int STEPS = 32;
25
+ const int STEPS = __STEPS__;
26
26
  void main() {
27
27
  // the zoom drift also pushes in slightly (stays inside the inset margin)
28
28
  vec2 base = 0.5 + (vUv - 0.5) * uInset * (1.0 - 0.06 * uZoom);
@@ -77,7 +77,7 @@ void main() {
77
77
  #include <tonemapping_fragment>
78
78
  #include <colorspace_fragment>
79
79
  }
80
- `,oe=`
80
+ `,ae=`
81
81
  uniform sampler2D uDepth;
82
82
  uniform float uRange;
83
83
  uniform float uFocus;
@@ -112,7 +112,7 @@ void main() {
112
112
  }
113
113
  gl_Position = c;
114
114
  }
115
- `,se=`
115
+ `,oe=`
116
116
  ${T}
117
117
  uniform sampler2D uDepth;
118
118
  varying vec2 vUv;
@@ -130,7 +130,7 @@ void main() {
130
130
  #include <tonemapping_fragment>
131
131
  #include <colorspace_fragment>
132
132
  }
133
- `,ce=`
133
+ `,se=`
134
134
  uniform sampler2D uDepth;
135
135
  uniform float uRange;
136
136
  uniform float uFocus;
@@ -160,7 +160,7 @@ void main() {
160
160
  p.z = z;
161
161
  gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
162
162
  }
163
- `,le=`
163
+ `,O=`
164
164
  ${T}
165
165
  uniform sampler2D uDepth;
166
166
  varying vec2 vUv;
@@ -187,7 +187,7 @@ void main() {
187
187
  #include <tonemapping_fragment>
188
188
  #include <colorspace_fragment>
189
189
  }
190
- `,D=`
190
+ `,ce=`
191
191
  ${T}
192
192
  uniform sampler2D uDepth;
193
193
  uniform vec2 uView;
@@ -247,4 +247,4 @@ void main() {
247
247
  #include <tonemapping_fragment>
248
248
  #include <colorspace_fragment>
249
249
  }
250
- `;function O(e){let t=e.image;return{w:t?.naturalWidth||t?.width||1,h:t?.naturalHeight||t?.height||1}}function k(e,t,n){let r=t.material??{};return{uMap:{value:e},uTint:{value:r.color?n.color(r.color):new p(1,1,1)},uOpacity:{value:_(v(r.opacity,1),0,1)},uIntensity:{value:Math.max(0,v(r.emissiveIntensity,1))}}}function A(e,t,n,r){let i=new d({vertexShader:e,fragmentShader:t,uniforms:n,transparent:r,toneMapped:!1,fog:!1,side:0});return i.depthWrite=!r,i}function ue(e,t,n,r){let i=n*r*2,a=new Float32Array(i*9),o=new Float32Array(i*6),c=new Float32Array(i*12),u=0,d=(n,r,i)=>{let s=[n,r,i];for(let n=0;n<3;n++){let[r,i]=s[n],l=s[(n+1)%3],d=s[(n+2)%3];a.set([(r-.5)*e,(i-.5)*t,0],u*3),o.set([r,i],u*2),c.set([l[0],l[1],d[0],d[1]],u*4),u++}};for(let e=0;e<r;e++)for(let t=0;t<n;t++){let i=t/n,a=(t+1)/n,o=e/r,s=(e+1)/r;d([i,o],[a,o],[a,s]),d([i,o],[a,s],[i,s])}let f=new s;return f.setAttribute(`position`,new l(a,3)),f.setAttribute(`uv`,new l(o,2)),f.setAttribute(`uvOther`,new l(c,4)),f}async function j(s,l){let[d,p]=await Promise.all([h(l.resolveAsset(s.src)),s.depth?h(l.resolveAsset(s.depth)).catch(e=>(l.issue(`asset-load`,`${s.id}: depth map: ${e.message} — showing the photo flat`,`objects#${s.id}.depth`),null)):Promise.resolve(null)]);d.colorSpace=f,d.wrapS=d.wrapT=c,d.anisotropy=4,d.needsUpdate=!0,p&&(p.colorSpace=``,p.premultiplyAlpha=!1,p.wrapS=p.wrapT=c,p.generateMipmaps=!1,p.minFilter=a,p.magFilter=a,p.needsUpdate=!0);let x=O(d),{width:T,height:j}=b(s,x.w,x.h),M=_(v(s.strength,y.strength),0,1),N=_(v(s.focus,y.focus),0,1),P=_(v(s.material?.opacity,1),0,1),F=P<1||/\.(png|webp)$/i.test(s.src),I=ee(s.motion),L=p?s.mode??`parallax`:`flat`,R=new i,z=new i;R.add(z);let B=[],V=[],H=[],U=[],W=null,G=()=>{let t=new e(T,j);return V.push(t),t};if(L===`flat`){let e=s.material??{},t=new r({map:d,transparent:F,opacity:P,toneMapped:!1,fog:!1});e.color&&t.color.copy(l.color(e.color)),t.color.multiplyScalar(Math.max(0,v(e.emissiveIntensity,1))),F&&(t.alphaTest=P<1?0:.004),B.push(t),z.add(new m(G(),t))}else if(L===`parallax`){let e=C(M,T,j),n=A(E,ae,{...k(d,s,l),uDepth:{value:p},uView:{value:new t},uZoom:{value:0},uMaxOffset:{value:new t(...e.maxOffset)},uInset:{value:new t(...e.inset)},uFocus:{value:N},uWallSlope:{value:.02}},F);B.push(n),H.push(n),z.add(new m(G(),n))}else if(L===`mesh`){let[r,i]=ne(v(s.segments,y.segments),T,j),a=w(M,T),c=ue(T,j,r,i);c.boundingBox=new o(new n(-T/2,-j/2,-N*a),new n(T/2,j/2,(1-N)*a)),c.boundingSphere=c.boundingBox.getBoundingSphere(new u),V.push(c);let f={...k(d,s,l),uDepth:{value:p},uRange:{value:a},uFocus:{value:N},uEdgeCut:{value:_(v(s.edgeCut,y.edgeCut),0,1)},uCam:{value:new n(0,0,1e6)},uPerspective:{value:0}};W=f;let h=A(oe,se,f,P<1);h.side=2,B.push(h);let g=new m(c,h);g.renderOrder=1,z.add(g);{let n=new e(T,j,Math.max(1,Math.round(r/2)),Math.max(1,Math.round(i/2)));n.boundingBox=c.boundingBox.clone(),n.boundingSphere=c.boundingSphere.clone(),V.push(n);let a=new t(6/r,6/i),o=A(ce,le,{...f,uReach:{value:a}},P<1);o.side=2,B.push(o);let s=new m(n,o);s.renderOrder=0,s.raycast=()=>void 0,z.add(s)}}else{let e=C(M,T,j),n=G(),r=re(v(s.layers,y.layers),N,M,T),i=_(v(s.edgeCut,y.edgeCut),0,1);r.forEach((r,a)=>{let o=A(E,D,{...k(d,s,l),uDepth:{value:p},uView:{value:new t},uZoom:{value:0},uMaxOffset:{value:new t(...e.maxOffset)},uInset:{value:new t(...e.inset)},uFocus:{value:N},uCenter:{value:r.center},uLo:{value:r.lo},uHi:{value:r.hi},uFeather:{value:i>0?Math.min(r.feather,i):.002},uBackground:{value:+!!r.background}},!r.background||F);B.push(o),H.push(o);let c=new m(n,o);c.position.z=r.z,c.renderOrder=a,c.userData.a3dPhotoLayer=a,z.add(c),U.push({mesh:c,band:r})})}let K=!l.deterministic,q={x:0,y:0,weight:0,init:!1},J=null,Y=null,X=null;if(K&&I.gyro&&I.pointer>0&&L!==`flat`&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;Y??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;J=ie(e.beta,e.gamma,Y,t)};window.addEventListener(`deviceorientation`,e),X=()=>window.removeEventListener(`deviceorientation`,e)}let Z=new n,Q=!1,$=M*8*g;return{object:R,update:(e,t,n)=>{if(L===`flat`)return;let r=n.pointer,i=r.inside?_(r.x,-1,1):0,a=r.inside?_(r.y,-1,1):0,o=+!!r.inside;!K||!q.init?(q.x=i,q.y=a,q.weight=o,q.init=K):(q.x=S(q.x,i,t,I.smoothing),q.y=S(q.y,a,t,I.smoothing),q.weight=S(q.weight,o,t,I.smoothing));let s=te(I,{t:e,pointer:q,gyro:K?J:null,scroll:n.scroll,reduced:n.reduced});for(let e of H)e.uniforms.uView.value.set(s.x,s.y),e.uniforms.uZoom.value=s.zoom;let c=!!n.camera&&!!n.camera.isPerspectiveCamera;if(n.camera&&!Q&&L!==`parallax`&&(n.camera.updateMatrixWorld(),R.updateWorldMatrix(!0,!1),Z.setFromMatrixPosition(n.camera.matrixWorld),R.worldToLocal(Z),Q=!0),L===`mesh`)z.rotation.set(s.y*$,-s.x*$,0),z.position.z=s.zoom*w(M,T)*.5,W&&(W.uCam.value.copy(Z),W.uPerspective.value=c&&Z.z>0?1:0);else if(L===`layers`&&Q){let e=Z.z;for(let{mesh:t,band:n}of U)if(c&&e>n.z+.001){let r=(e-n.z)/e;t.scale.set(r,r,1),t.position.set(Z.x*n.z/e,Z.y*n.z/e,n.z)}else t.scale.set(1,1,1),t.position.set(0,0,n.z)}},dispose(){X?.(),X=null;for(let e of B)e.dispose();for(let e of V)e.dispose();d.dispose(),p?.dispose()}}}export{j as buildPhoto};
250
+ `;function le(e){let t=e.image;return{w:t?.naturalWidth||t?.width||1,h:t?.naturalHeight||t?.height||1}}function k(e,t,n){let r=t.material??{};return{uMap:{value:e},uTint:{value:r.color?n.color(r.color):new p(1,1,1)},uOpacity:{value:_(v(r.opacity,1),0,1)},uIntensity:{value:Math.max(0,v(r.emissiveIntensity,1))}}}function A(e,t,n,r){let i=new d({vertexShader:e,fragmentShader:t,uniforms:n,transparent:r,toneMapped:!1,fog:!1,side:0});return i.depthWrite=!r,i}function ue(e,t,n,r){let i=n*r*2,a=new Float32Array(i*9),o=new Float32Array(i*6),c=new Float32Array(i*12),u=0,d=(n,r,i)=>{let s=[n,r,i];for(let n=0;n<3;n++){let[r,i]=s[n],l=s[(n+1)%3],d=s[(n+2)%3];a.set([(r-.5)*e,(i-.5)*t,0],u*3),o.set([r,i],u*2),c.set([l[0],l[1],d[0],d[1]],u*4),u++}};for(let e=0;e<r;e++)for(let t=0;t<n;t++){let i=t/n,a=(t+1)/n,o=e/r,s=(e+1)/r;d([i,o],[a,o],[a,s]),d([i,o],[a,s],[i,s])}let f=new s;return f.setAttribute(`position`,new l(a,3)),f.setAttribute(`uv`,new l(o,2)),f.setAttribute(`uvOther`,new l(c,4)),f}function de(e,t){return Math.max(8,Math.round((e===`low`?12:e===`medium`?20:e===`ultra`?48:32)*(.5+.5*Math.min(1,Math.max(0,t)/.6))))}async function j(s,l){let[d,p]=await Promise.all([h(l.resolveAsset(s.src)),s.depth?h(l.resolveAsset(s.depth)).catch(e=>(l.issue(`asset-load`,`${s.id}: depth map: ${e.message} — showing the photo flat`,`objects#${s.id}.depth`),null)):Promise.resolve(null)]);d.colorSpace=f,d.wrapS=d.wrapT=c,d.anisotropy=4,d.needsUpdate=!0,p&&(p.colorSpace=``,p.premultiplyAlpha=!1,p.wrapS=p.wrapT=c,p.generateMipmaps=!1,p.minFilter=a,p.magFilter=a,p.needsUpdate=!0);let b=le(d),{width:T,height:j}=ee(s,b.w,b.h),M=_(v(s.strength,y.strength),0,1),N=_(v(s.focus,y.focus),0,1),P=_(v(s.material?.opacity,1),0,1),F=P<1||/\.(png|webp)$/i.test(s.src),I=te(s.motion),L=p?s.mode??`parallax`:`flat`,R=new i,z=new i;R.add(z);let B=[],V=[],H=[],U=[],W=null,G=()=>{let t=new e(T,j);return V.push(t),t};if(L===`flat`){let e=s.material??{},t=new r({map:d,transparent:F,opacity:P,toneMapped:!1,fog:!1});e.color&&t.color.copy(l.color(e.color)),t.color.multiplyScalar(Math.max(0,v(e.emissiveIntensity,1))),F&&(t.alphaTest=P<1?0:.004),B.push(t),z.add(new m(G(),t))}else if(L===`parallax`){let e=C(M,T,j),n={...k(d,s,l),uDepth:{value:p},uView:{value:new t},uZoom:{value:0},uMaxOffset:{value:new t(...e.maxOffset)},uInset:{value:new t(...e.inset)},uFocus:{value:N},uWallSlope:{value:.02}},r=A(E,D.replace(`__STEPS__`,String(de(l.quality,M))),n,F);B.push(r),H.push(r),z.add(new m(G(),r))}else if(L===`mesh`){let[r,i]=ne(v(s.segments,y.segments),T,j),a=w(M,T),c=ue(T,j,r,i);c.boundingBox=new o(new n(-T/2,-j/2,-N*a),new n(T/2,j/2,(1-N)*a)),c.boundingSphere=c.boundingBox.getBoundingSphere(new u),V.push(c);let f={...k(d,s,l),uDepth:{value:p},uRange:{value:a},uFocus:{value:N},uEdgeCut:{value:_(v(s.edgeCut,y.edgeCut),0,1)},uCam:{value:new n(0,0,1e6)},uPerspective:{value:0}};W=f;let h=A(ae,oe,f,P<1);h.side=2,B.push(h);let g=new m(c,h);g.renderOrder=1,z.add(g);{let n=new e(T,j,Math.max(1,Math.round(r/2)),Math.max(1,Math.round(i/2)));n.boundingBox=c.boundingBox.clone(),n.boundingSphere=c.boundingSphere.clone(),V.push(n);let a=new t(6/r,6/i),o=A(se,O,{...f,uReach:{value:a}},P<1);o.side=2,B.push(o);let s=new m(n,o);s.renderOrder=0,s.raycast=()=>void 0,z.add(s)}}else{let e=C(M,T,j),n=G(),r=re(v(s.layers,y.layers),N,M,T),i=_(v(s.edgeCut,y.edgeCut),0,1);r.forEach((r,a)=>{let o=A(E,ce,{...k(d,s,l),uDepth:{value:p},uView:{value:new t},uZoom:{value:0},uMaxOffset:{value:new t(...e.maxOffset)},uInset:{value:new t(...e.inset)},uFocus:{value:N},uCenter:{value:r.center},uLo:{value:r.lo},uHi:{value:r.hi},uFeather:{value:i>0?Math.min(r.feather,i):.002},uBackground:{value:+!!r.background}},!r.background||F);B.push(o),H.push(o);let c=new m(n,o);c.position.z=r.z,c.renderOrder=a,c.userData.a3dPhotoLayer=a,z.add(c),U.push({mesh:c,band:r})})}let K=!l.deterministic,q={x:0,y:0,weight:0,init:!1},J=null,Y=null,X=null;if(K&&I.gyro&&I.pointer>0&&L!==`flat`&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;Y??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;J=ie(e.beta,e.gamma,Y,t)};window.addEventListener(`deviceorientation`,e),X=()=>window.removeEventListener(`deviceorientation`,e)}let Z=new n,Q=!1,$=M*8*g;return{object:R,update:(e,t,n)=>{if(L===`flat`)return;let r=n.pointer,i=r.inside?_(r.x,-1,1):0,a=r.inside?_(r.y,-1,1):0,o=+!!r.inside;!K||!q.init?(q.x=i,q.y=a,q.weight=o,q.init=K):(q.x=S(q.x,i,t,I.smoothing),q.y=S(q.y,a,t,I.smoothing),q.weight=S(q.weight,o,t,I.smoothing));let s=x(I,{t:e,pointer:q,gyro:K?J:null,scroll:n.scroll,reduced:n.reduced});for(let e of H)e.uniforms.uView.value.set(s.x,s.y),e.uniforms.uZoom.value=s.zoom;let c=!!n.camera&&!!n.camera.isPerspectiveCamera;if(n.camera&&!Q&&L!==`parallax`&&(n.camera.updateMatrixWorld(),R.updateWorldMatrix(!0,!1),Z.setFromMatrixPosition(n.camera.matrixWorld),R.worldToLocal(Z),Q=!0),L===`mesh`)z.rotation.set(s.y*$,-s.x*$,0),z.position.z=s.zoom*w(M,T)*.5,W&&(W.uCam.value.copy(Z),W.uPerspective.value=c&&Z.z>0?1:0);else if(L===`layers`&&Q){let e=Z.z;for(let{mesh:t,band:n}of U)if(c&&e>n.z+.001){let r=(e-n.z)/e;t.scale.set(r,r,1),t.position.set(Z.x*n.z/e,Z.y*n.z/e,n.z)}else t.scale.set(1,1,1),t.position.set(0,0,n.z)}},dispose(){X?.(),X=null;for(let e of B)e.dispose();for(let e of V)e.dispose();d.dispose(),p?.dispose()}}}export{j as buildPhoto};