@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
- import{In as e,Ln as t,on as n,x as r}from"./three.module-CnI50X0U.js";import{r as i}from"./params-D-Ul6GSt.js";import{n as a,r as o}from"./runtime-rd9RW3WH.js";var s=`
1
+ import{In as e,Ln as t,on as n,x as r}from"./three.module-B9FlcKtd.js";import{r as i}from"./params-BZqUA__U.js";import{n as a,r as o}from"./runtime-ByR4qfyV.js";var s=`
2
2
  varying vec2 vUv;
3
3
  varying vec3 vPos;
4
4
  varying vec3 vNormalV;
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SVGLoader-KDBVv02P.js","./three.module-B9FlcKtd.js","./rolldown-runtime-4tVxZq34.js","./BufferGeometryUtils-BbzK4rCj.js"])))=>i.map(i=>d[i]);
2
+ import{n as e}from"./assets-DICv7P37.js";import{I as t,In as n,P as r,U as i,h as a,ln as o,m as s,rn as c,u as l,x as u,xt as d}from"./three.module-B9FlcKtd.js";import{r as f}from"./num-CQNAlL82.js";import{i as p,n as m,r as h,t as g}from"./extrude-BpJda0hq.js";import{a as _,s as v}from"./runtime-ByR4qfyV.js";import{g as y}from"./index-cDbmaVDl.js";var b=e=>!!e&&e!==`none`&&e!==`transparent`;function x(e,t,n){if(e===`currentColor`)return n;let r=/^url\(\s*['"]?#([^'")]+)['"]?\s*\)/.exec(e);if(r){let e=t.userData?.gradients?.[r[1]]?.stops??[];if(!e.length)return n;let i=new u(e[0].color),a=new u(e[e.length-1].color);return`#${i.lerp(a,.5).getHexString()}`}try{let t=new u;return t.setStyle(e,c),`#${t.getHexString(c)}`}catch{return n}}function S(e,t){let n=new l;for(let t of e.paths)for(let e of t.subPaths)for(let t of e.getPoints(4))n.expandByPoint(t);return(n.isEmpty()?100:Math.max(n.max.x-n.min.x,n.max.y-n.min.y,1e-6))/(t*10)}function C(e,t,n={}){let r=[],i=Math.max(1,Math.round(f(n.curveSegments,12))),a=S(e,i),o=n.currentColor??`#1f2330`;for(let s of e.paths){let e=s.userData?.style??{};if(e.visibility===`hidden`||e.visibility===`collapse`)continue;let c=f(e.opacity,1);if(b(e.fill)){let t=s.toShapes().map(e=>h(e,a));t.length&&r.push({kind:`fill`,color:x(e.fill,s,o),opacity:f(e.fillOpacity,1)*c,shapes:t})}if(n.strokes!==!1&&b(e.stroke)&&f(e.strokeWidth,1)>0){let n=t.getStrokeStyle(f(e.strokeWidth,1),`#000`,e.strokeLineJoin??`miter`,e.strokeLineCap??`butt`,f(e.strokeMiterLimit,4)),l=[];for(let e of s.subPaths){let r=m(e,a);if(r.length<2)continue;let o=t.pointsToStroke(r,n,i);o&&l.push(o)}if(l.length){let t=l.length===1?l[0]:w(l);r.push({kind:`stroke`,color:x(e.stroke,s,o),opacity:f(e.strokeOpacity,1)*c,stroke:t})}}}return r}function w(e){let t=0;for(let n of e)t+=n.getAttribute(`position`).count;let n=new Float32Array(t*3),r=0;for(let t of e){let e=t.getAttribute(`position`).array;n.set(e,r),r+=e.length,t.dispose()}let i=new a;return i.setAttribute(`position`,new s(n,3)),i}function T(e,t=12){let r=new l;for(let i of e){if(i.shapes)for(let e of i.shapes)for(let n of e.getPoints(t))r.expandByPoint(n);if(i.stroke){let e=i.stroke.getAttribute(`position`);for(let t=0;t<e.count;t++)r.expandByPoint(new n(e.getX(t),e.getY(t)))}}return r}function E(e,t,n,i,a){if(e.kind===`stroke`)return e.stroke?g(e.stroke,t):null;if(!e.shapes?.length)return null;if(t<=0)return new o(e.shapes,i);let s=Math.min(n,t*.45),c=new r(e.shapes,{depth:Math.max(t-s*2,t*.05),curveSegments:i,bevelEnabled:s>0,bevelThickness:s,bevelSize:s*.6,bevelOffset:0,bevelSegments:3});return c.translate(0,0,s),c.clearGroups(),p(c,50*Math.PI/180,a)}async function D(n,r){let[{SVGLoader:a},o]=await Promise.all([y(()=>import(`./SVGLoader-KDBVv02P.js`),__vite__mapDeps([0,1,2]),import.meta.url),y(()=>import(`./BufferGeometryUtils-BbzK4rCj.js`).then(e=>e.t),__vite__mapDeps([3,2,1]),import.meta.url)]),s=n.src.trim().startsWith(`<`)?n.src:await e(r.resolveAsset(n.src)),c=new a().parse(s),l=n.material?v(n.material):void 0,u=typeof l?.color==`string`?l.color:void 0,p=Math.max(1,Math.round(f(n.curveSegments,12))),m=C(c,a,{strokes:n.strokes,curveSegments:p,currentColor:u}),h=new i,g=T(m,p);if(!m.length||g.isEmpty())return h;let b=f(n.size,2),x=Math.max(g.max.x-g.min.x,1e-6),S=Math.max(g.max.y-g.min.y,1e-6),w=n.fit??`width`,D=b/(w===`height`?S:w===`max`?Math.max(x,S):x),O=Math.max(0,f(n.depth,.2)),k=O/D,A=f(n.bevel,0)/D,j=f(n.layerGap,O>0?O*.02:b*.002),M=n.keepColors??!n.material,N=new Map,P=async(e,t)=>{let i=M?`${e}|${t}`:`|${t}`,a=N.get(i);if(!a){let o=M?{roughness:.4,metalness:.1,...n.material??{},color:e,...t<1?{opacity:t}:{}}:n.material?{...n.material,...t<1?{opacity:t}:{}}:{color:`#dddddd`,roughness:.4,metalness:.1};a=await _(o,r,{defaultColor:e}),t<1&&(a.transparent=!0),O<=0&&(a.side=2),N.set(i,a)}return a},F=[];for(let e of m){let t=E(e,k,A,p,o);if(!t)continue;t.getAttribute(`normal`)||t.computeVertexNormals();let n=M?`${e.color}|${e.opacity}`:`|${e.opacity}`,r=F[F.length-1];r&&r.key===n?r.geos.push(t):F.push({key:n,color:e.color,opacity:e.opacity,geos:[t]})}let I=new i;for(let[e,n]of F.entries()){for(let e of n.geos){for(let t of Object.keys(e.attributes))[`position`,`normal`,`uv`].includes(t)||e.deleteAttribute(t);e.getAttribute(`uv`)||e.setAttribute(`uv`,new t(new Float32Array(e.getAttribute(`position`).count*2),2))}let r=n.geos.length===1?n.geos[0]:o.mergeGeometries(n.geos.map(e=>e.index?e.toNonIndexed():e),!1)??n.geos[0],i=new d(r,await P(n.color,n.opacity));i.position.z=e*j/D,I.add(i)}let L=(g.min.x+g.max.x)/2,R=(g.min.y+g.max.y)/2;return I.scale.set(D,-D,D),I.position.set(-L*D,R*D,-(O+Math.max(0,F.length-1)*j)/2),h.add(I),h}export{D as buildSvg};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./FontLoader-DlBfss5q.js","./three.module-B9FlcKtd.js","./rolldown-runtime-4tVxZq34.js","./BufferGeometryUtils-BbzK4rCj.js"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./assets-DICv7P37.js";import{In as t,Lt as n,P as r,St as i,U as a,cn as o,h as s,ln as c,xt as l}from"./three.module-B9FlcKtd.js";import{g as u,t as d}from"./index-cDbmaVDl.js";import{r as f}from"./num-CQNAlL82.js";import{i as p,r as m}from"./extrude-BpJda0hq.js";import{a as h}from"./runtime-ByR4qfyV.js";var g=new Map;function _(t){let n=g.get(t);return n||(n=Promise.all([u(()=>import(`./FontLoader-DlBfss5q.js`),__vite__mapDeps([0,1,2]),import.meta.url),e(t)]).then(([e,t])=>new e.FontLoader().parse(t)),n.catch(()=>g.delete(t)),g.set(t,n)),n}var v=e=>{let t=e.normalize(`NFD`);return t.length>1?t[0]:e};function y(e,t,n){let r=e.kerning;if(!r)return 0;let i=r[t]?.[n];if(i!==void 0)return i;let a=v(t),o=v(n);return a===t&&o===n?0:r[a]?.[o]??0}function b(e,t){let n=t.em/e.resolution,r=f(t.letterSpacing,0),i=f(t.lineHeight,1.25)*t.em,a=t.kerning!==!1,o=t=>(e.glyphs[t]??e.glyphs[`?`])?.ha??e.resolution*.5,s=t=>{let i=[],s=0;return t.forEach((c,l)=>{l>0&&(s+=r+(a?y(e,t[l-1],c)*n:0)),i.push(s),s+=o(c)*n}),{xs:i,width:s}},c=[],l=typeof t.maxWidth==`number`&&t.maxWidth>0?t.maxWidth:1/0;for(let e of String(t.text??``).split(`
3
+ `)){if(l===1/0){c.push(Array.from(e));continue}let t=e.split(/ +/),n=[];for(let e of t){let t=n.length?[...n,` `,...Array.from(e)]:Array.from(e);n.length&&s(t).width>l?(c.push(n),n=Array.from(e)):n=t}c.push(n)}let u=[],d=[],p=0;return c.forEach((e,n)=>{for(;e.length&&e[e.length-1]===` `;)e.pop();let{xs:r,width:a}=s(e);p=Math.max(p,a);let o=t.align===`left`?0:t.align===`right`?-a:-a/2;e.forEach((e,t)=>{e.trim()&&u.push({ch:e,x:r[t]+o,line:n})}),d.push({width:a,y:-n*i})}),{glyphs:u,lines:d,lineHeight:i,width:p}}function x(e){let t=e.data;if(t.capHeight&&t.resolution)return t.capHeight/t.resolution;let n=e.generateShapes(`H`,1);if(!n.length)return .72;let r=new c(n);r.computeBoundingBox();let i=r.boundingBox.max.y-r.boundingBox.min.y;return r.dispose(),i>0?i:.72}function S(e,t){let n=e.data,r=f(t.size,1),i=r/x(e),a=Math.max(0,f(t.depth,.2)),o=a>0?Math.max(0,Math.min(f(t.bevel,Math.min(a*.3,r*.035)),a*.45,r*.08)):0,s=Math.round(Math.max(2,Math.min(32,f(t.curveSegments,a>0?5+r*3:8+r*4)))),c=b(n,{text:t.text,em:i,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,align:t.align??`center`,maxWidth:t.maxWidth,kerning:t.kerning});return{size:r,em:i,depth:a,bevel:o,curveSegments:s,layout:c,offsetY:-(r+(c.lines.length?c.lines[c.lines.length-1].y:0))/2,frontZ:a/2,backZ:-a/2}}function C(e){let t=e.bevel;return{depth:Math.max(e.depth-t*2,1e-4),curveSegments:e.curveSegments,bevelEnabled:t>0,bevelThickness:t,bevelSize:t*.6,bevelOffset:0,bevelSegments:3}}function w(e,t,n){let r=n.em/(n.curveSegments*5);return e.generateShapes(t,n.em).map(e=>m(e,r,1,n.curveSegments))}function T(e,t,n,i){let a=w(e,t,n);if(!a.length)return null;if(n.depth<=0)return new c(a,n.curveSegments);let o=new r(a,C(n));return o.translate(0,0,n.backZ+n.bevel),o.clearGroups(),p(o,50*Math.PI/180,i)}function E(e,t){let n=e.outline;if(!n)return null;let r=n===!0?{}:n,i=Math.max(1e-4,f(r.width,t.size*.06)),a=t.depth>0?t.depth*.5:t.size*.01,o=t.frontZ-a;return{width:i,frontZ:o,backZ:o-Math.max(f(r.depth,t.depth>0?t.depth*.6:t.size*.01),1e-4),material:r.material,color:r.color??`#111111`}}function D(e){let t=0;for(let n=0,r=e.length-1;n<e.length;r=n++)t+=(e[r].x-e[n].x)*(e[r].y+e[n].y);return t/2}function O(e,n,r=2){let i=e.filter((t,n)=>{let r=e[(n+1)%e.length];return Math.hypot(r.x-t.x,r.y-t.y)>1e-9}),a=i.length,o=[];if(a<3)return i.map(e=>new t(e.x,e.y));let s=(e,t)=>{let n=t.x-e.x,r=t.y-e.y,i=Math.hypot(n,r)||1;return{x:r/i,y:-n/i}};for(let e=0;e<a;e++){let c=i[(e-1+a)%a],l=i[e],u=i[(e+1)%a],d=s(c,l),f=s(l,u),p=(l.x-c.x)*(u.y-l.y)-(l.y-c.y)*(u.x-l.x),m=d.x*f.x+d.y*f.y;if(p>0&&m<.995){let e=Math.atan2(d.y,d.x),r=Math.atan2(f.y,f.x);for(;r<e;)r+=Math.PI*2;for(;r>e+Math.PI*2;)r-=Math.PI*2;let i=Math.max(1,Math.ceil(Math.abs(r-e)/(Math.PI/8)));for(let a=0;a<=i;a++){let s=e+(r-e)*a/i;o.push(new t(l.x+Math.cos(s)*n,l.y+Math.sin(s)*n))}}else{let e=d.x+f.x,i=d.y+f.y,a=Math.hypot(e,i)||1;e/=a,i/=a;let s=Math.max(e*d.x+i*d.y,1/r);o.push(new t(l.x+e*n/s,l.y+i*n/s))}}return o}function k(e,t){let r=[];for(let i of e){let{shape:e,holes:a}=i.extractPoints(1),s=e.slice();D(s)<0&&(s=s.reverse());let c=new o(O(s,t));for(let e of a){let r=e.slice(),i=Math.abs(D(r));D(r)>0&&(r=r.reverse());let a=r.map(e=>e.x),o=r.map(e=>e.y);if(Math.max(...a)-Math.min(...a)<=2*t||Math.max(...o)-Math.min(...o)<=2*t)continue;let s=O(r,t),l=D(s);l<0&&-l>i*.02&&c.holes.push(new n(s))}r.push(c)}return r}function A(e,t,n,i,a){let o=w(e,t,n);if(!o.length)return null;let s=new r(k(o,i.width),{depth:i.frontZ-i.backZ,curveSegments:1,bevelEnabled:!1});return s.translate(0,0,i.backZ),s.clearGroups(),p(s,40*Math.PI/180,a)}function j(e,t,n){let r=new Map,i=[];for(let n of e.layout.glyphs){r.has(n.ch)||r.set(n.ch,t(n.ch));let a=r.get(n.ch);if(!a)continue;let o=a.clone();o.translate(n.x,e.layout.lines[n.line].y+e.offsetY,0),i.push(o)}for(let e of r.values())e?.dispose();let a;if(!i.length)a=new s;else{a=(i.length===1?i[0].clone():n.mergeGeometries(i,!1))??new s;for(let e of i)e.dispose()}return a.computeBoundingBox(),a.computeBoundingSphere(),a}function M(e,t,n){let r=f(e.stagger,.04),i=t;if(e.order===`reverse`)i=n-1-t;else if(e.order===`center`)i=Math.abs(t-(n-1)/2);else if(e.order===`random`){let e=(t+1)*2654435761;e=(e^e>>>13)>>>0,i=e%1e3/1e3*(n-1)}return f(e.delay,0)+i*r}function N(e,t){return(n,r)=>{let i=e.effect??`rise`,a=Math.max(f(e.duration,.6),.001),o=e.ease??(i===`scale`||i===`spin`?`outBack`:`outCubic`),s=i!==`scale`,c=[],l=[];if(s){let e=[];r.object.traverse(t=>{let n=t.material;if(n&&!t.userData.depthTwin){e.push(t);for(let e of Array.isArray(n)?n:[n])e.userData.baseOpacity===void 0&&(e.userData.baseOpacity=e.opacity),e.userData.baseTransparent===void 0&&(e.userData.baseTransparent=e.transparent),c.push(e)}});for(let t of e)l.push(F(t))}return{update(e){let n=Math.min(Math.max(e/a,0),1),u=d(o,n),f=r.object;if(s){let e=d(`outCubic`,Math.min(1,n*1.6));for(let t of c)t.opacity=t.userData.baseOpacity*e,t.transparent=e<1||t.userData.baseTransparent;for(let t of l)t.visible=e>0&&e<1}switch(n<=0&&(f.visible=!1),i){case`rise`:f.position.y-=(1-u)*t*.6;break;case`drop`:f.position.y+=(1-u)*t*1.2;break;case`scale`:f.scale.multiplyScalar(Math.max(1e-4,u));break;case`spin`:f.rotation.y+=(1-u)*Math.PI,f.scale.multiplyScalar(Math.max(1e-4,Math.min(1,n*2)))}}}}}var P=null;function F(e){P??=new i({colorWrite:!1,depthWrite:!0});let t=new l(e.geometry,P);return t.name=`${e.name}#depth`,t.visible=!1,t.castShadow=!1,t.receiveShadow=!1,t.renderOrder=-1,t.userData.helper=!0,t.userData.depthTwin=!0,e.add(t),t}function I(e,t){let n=e.font??`sans-bold`;return t.resolveAsset(n.includes(`/`)||n.includes(`:`)?n:`library:fonts/${n}`)}function L(e,t,n){let r=e.userData.gradient;r&&(r.uGradMin.value=t,r.uGradMax.value=n)}async function R(e,t){let[n,r]=await Promise.all([_(I(e,t)),u(()=>import(`./BufferGeometryUtils-BbzK4rCj.js`).then(e=>e.t),__vite__mapDeps([3,2,1]),import.meta.url)]),i=S(n,e),o=E(e,i),s=!!e.splitLetters||!!e.reveal,c=i.depth<=0,d=()=>h(e.material,t,{defaultColor:`#ffffff`}),f=()=>o?h(o.material??{color:o.color,roughness:.55},t):null,p=(i.layout.lines.length?i.layout.lines[i.layout.lines.length-1].y:0)+i.offsetY,m=i.size+i.offsetY,g=e=>(c&&(e.side=2),e);if(!s){let t=j(i,e=>T(n,e,i,r),r),a=g(await d());L(a,p,m);let s=new l(t,a);if(o){let t=j(i,e=>A(n,e,i,o,r),r),a=await f();if(a){L(a,p,m);let n=new l(t,a);n.name=`${e.id}/outline`,s.add(n)}}return{object:s,letters:[]}}let v=new a,y=new Map,b=new Map,x=i.size/2,C=[],w=i.layout.glyphs.length,D=0;for(let t of i.layout.glyphs){if(!y.has(t.ch)){let e=T(n,t.ch,i,r),a=0;if(e&&(e.computeBoundingBox(),a=(e.boundingBox.min.x+e.boundingBox.max.x)/2,e.translate(-a,-x,0),e.computeBoundingSphere()),y.set(t.ch,e),o){let e=A(n,t.ch,i,o,r);e?.translate(-a,-x,0),b.set(t.ch,e)}e&&(e.userData.cx=a)}let a=y.get(t.ch);if(!a)continue;let s=a.userData.cx,c=i.layout.lines[t.line].y+i.offsetY,u=g(await d());L(u,p-c-x,m-c-x);let h=new l(a,u);h.position.set(t.x+s,c+x,0);let _=`${e.id}/${D}`;h.name=_,h.userData.a3dId=_;let S=b.get(t.ch);if(S){let e=await f();if(e){L(e,p-c-x,m-c-x);let t=new l(S,e);t.name=`${_}/outline`,h.add(t)}}v.add(h);let E={id:_,object:h,def:{id:_,kind:`text`,text:t.ch}};e.reveal&&(E.reveal={def:{type:`appear`,when:`visible`,delay:M(e.reveal,D,w)},impl:N(e.reveal,i.size)}),C.push(E),D++}return{object:v,letters:C}}export{R as buildText};