@fleox/agent3d 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +350 -126
- package/changelog.json +12 -0
- package/dist/agent/agent3d.mjs +16 -16
- package/dist/agent/chunks/{cdp-CaKRRzMX.mjs → cdp-Bdtm4fBN.mjs} +3 -2
- package/dist/agent/chunks/{imageCodec-BpDU9Lsq.mjs → imageCodec-Dz9PFxi9.mjs} +1 -1
- package/dist/agent/chunks/{package-Ck7_Nszg.mjs → package-BOIyp_2B.mjs} +1 -1
- package/dist/agent/chunks/{render-Cbuhz5uW.mjs → render-CN4mgGLQ.mjs} +2 -2
- package/dist/runtime/agent3d-runtime.js +23 -23
- package/dist/runtime/agent3d-runtime.single.js +2 -2
- package/dist/runtime/chunks/{BufferGeometryUtils-Re3wQkXp.js → BufferGeometryUtils-XmME4f7Z.js} +1 -1
- package/dist/runtime/chunks/{EXRLoader-Bzm84si5.js → EXRLoader-CBdIpBMT.js} +1 -1
- package/dist/runtime/chunks/{FontLoader-BocwqK8V.js → FontLoader-dVu9WH2X.js} +1 -1
- package/dist/runtime/chunks/GLTFLoader-Z9Inv-Xm.js +1 -0
- package/dist/runtime/chunks/{GroundedSkybox-esvlRCO0.js → GroundedSkybox-g1ASZWNu.js} +1 -1
- package/dist/runtime/chunks/{HDRLoader-DHrHp8fs.js → HDRLoader-DBOMWa7O.js} +2 -2
- package/dist/{studio/assets/OrbitControls-fcOgB96a.js → runtime/chunks/OrbitControls-BIpWXK4x.js} +1 -1
- package/dist/runtime/chunks/{RectAreaLightUniformsLib-_mZ62yWn.js → RectAreaLightUniformsLib-4ZzgX9vp.js} +1 -1
- package/dist/runtime/chunks/{RoomEnvironment-CL4UR6ZW.js → RoomEnvironment-CXgfLJdO.js} +1 -1
- package/dist/runtime/chunks/{RoundedBoxGeometry-x-ot8ZSh.js → RoundedBoxGeometry-BViRogcJ.js} +1 -1
- package/dist/runtime/chunks/{SVGLoader-hRF0EwD-.js → SVGLoader-CV0U1EIF.js} +1 -1
- package/dist/runtime/chunks/{Sky-BrLN9Fk5.js → Sky-DGJXlPb_.js} +1 -1
- package/dist/runtime/chunks/{extrude-m04mghOS.js → extrude-D6WnITQq.js} +1 -1
- package/dist/runtime/chunks/{game-BoG2S6g4.js → game-BoEiyZrL.js} +3 -3
- package/dist/runtime/chunks/generators-D5JUo0jp.js +331 -0
- package/dist/runtime/chunks/{materials-C2uffFEd.js → materials-Dn-bYrZd.js} +5 -5
- package/dist/runtime/chunks/{model-D-4xZz21.js → model-BCVF3QzB.js} +1 -1
- package/dist/runtime/chunks/{params-DdApDOBw.js → params-C2uoUDJ0.js} +1 -1
- package/dist/runtime/chunks/{physicsHost-DPaVdM0R.js → physicsHost-ChPgysMQ.js} +1 -1
- package/dist/runtime/chunks/{postfx-BpBXjLX3.js → postfx-UgKCbmZs.js} +29 -29
- package/dist/{studio/assets/shaders-BEznGIct.js → runtime/chunks/shaders-Dw6zHdu_.js} +3 -3
- package/dist/runtime/chunks/svg-CmlFY_8O.js +1 -0
- package/dist/runtime/chunks/{text-CmkU-b0C.js → text-D1EQpdSU.js} +2 -2
- package/dist/runtime/chunks/{three.module-W4hp4qHb.js → three.module-DnaBiDAJ.js} +31 -31
- package/dist/runtime/chunks/{toon-B5Jhf37V.js → toon-BsvVk_nK.js} +1 -1
- package/dist/runtime/chunks/{util-THUewKBk.js → util-CyaW1fcW.js} +1 -1
- package/dist/studio/assets/{BufferGeometryUtils-wW9vV1l2.js → BufferGeometryUtils-CAlXAboW.js} +1 -1
- package/dist/studio/assets/{EXRLoader-f8U8jnlr.js → EXRLoader-BKkzlNd8.js} +1 -1
- package/dist/studio/assets/{FontLoader-9sHudKzD.js → FontLoader-Bzjx8mXt.js} +2 -2
- package/dist/studio/assets/GLTFLoader-1Zd9N406.js +1 -0
- package/dist/studio/assets/GroundedSkybox-BEMqNCBD.js +1 -0
- package/dist/studio/assets/{HDRLoader-CkQyrTWY.js → HDRLoader-DxB0kxPH.js} +2 -2
- package/dist/{runtime/chunks/OrbitControls-sjN2MF0e.js → studio/assets/OrbitControls-MlE9XiCg.js} +1 -1
- package/dist/studio/assets/{RectAreaLightUniformsLib-CZHWO9xf.js → RectAreaLightUniformsLib-ClHrtYY6.js} +1 -1
- package/dist/studio/assets/{RoomEnvironment-BsISzuCp.js → RoomEnvironment-MJ-jIEC8.js} +1 -1
- package/dist/studio/assets/{SVGLoader-BIkQDT66.js → SVGLoader-CIYl0nEy.js} +1 -1
- package/dist/studio/assets/{Sky-C282PFL1.js → Sky-DNMfpp92.js} +1 -1
- package/dist/studio/assets/{camera-BhKdE9ej.js → camera-7sEn13L-.js} +2 -2
- package/dist/studio/assets/editor-CnbvVkhU.js +53 -0
- package/dist/studio/assets/{extrude-CnayHczh.js → extrude-9bG8hr2C.js} +1 -1
- package/dist/studio/assets/{game-Dv5s4eMN.js → game-B04KGAK0.js} +3 -3
- package/dist/studio/assets/generators-LSni1Yfc.js +331 -0
- package/dist/studio/assets/{index-Dh-2Y34U.js → index-3LL5NEIH.js} +8 -8
- package/dist/studio/assets/{model-XZSP52pV.js → model-CNddhwmA.js} +2 -2
- package/dist/studio/assets/{physicsHost-C84FddIe.js → physicsHost-hMU_SDiX.js} +1 -1
- package/dist/studio/assets/{postfx-BWWXb8i8.js → postfx-BcCZS0Bq.js} +27 -27
- package/dist/studio/assets/runtime-DY_KqD1x.js +572 -0
- package/dist/{runtime/chunks/shaders-CmeJRio1.js → studio/assets/shaders-BhMCstyv.js} +3 -3
- package/dist/studio/assets/svg-CNKK-h7H.js +2 -0
- package/dist/studio/assets/{text-5DsJJHcj.js → text-BSPI7dk1.js} +3 -3
- package/dist/studio/assets/{three.module-ByMn_ZTv.js → three.module-CnI50X0U.js} +31 -31
- package/dist/studio/index.html +3 -3
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +2 -2
- package/plugin/skills/agent3d-assets/SKILL.md +24 -24
- package/plugin/skills/agent3d-create/SKILL.md +20 -20
- package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
- package/plugin/skills/agent3d-create/references/recipes.md +6 -6
- package/plugin/skills/agent3d-edit/SKILL.md +22 -22
- package/plugin/skills/agent3d-edit/references/patch-ops.md +2 -2
- package/plugin/skills/agent3d-game/SKILL.md +7 -7
- package/plugin/skills/agent3d-publish/SKILL.md +21 -21
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
- package/dist/runtime/chunks/GLTFLoader-DHp1wv6J.js +0 -1
- package/dist/runtime/chunks/generators-OHhFCc2E.js +0 -331
- package/dist/runtime/chunks/svg-B3nZaQFD.js +0 -1
- package/dist/studio/assets/GLTFLoader-C3C_3K62.js +0 -1
- package/dist/studio/assets/GroundedSkybox-BTqmv4fv.js +0 -1
- package/dist/studio/assets/editor-BgY_RoRd.js +0 -1
- package/dist/studio/assets/generators-DVX3bAxe.js +0 -331
- package/dist/studio/assets/runtime-k_MFerbJ.js +0 -572
- package/dist/studio/assets/svg-DT8kx37i.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{In as e,Ln as t,on as n,x as r}from"./three.module-CnI50X0U.js";import{n as i,r as a,u as o}from"./runtime-DY_KqD1x.js";var s=`
|
|
2
2
|
varying vec2 vUv;
|
|
3
3
|
varying vec3 vPos;
|
|
4
4
|
varying vec3 vNormalV;
|
|
@@ -43,7 +43,7 @@ vec3 paletteCycle(float t) {
|
|
|
43
43
|
`,l=`
|
|
44
44
|
#include <tonemapping_fragment>
|
|
45
45
|
#include <colorspace_fragment>
|
|
46
|
-
`;function u(e){return{uColors:{value:Array.from({length:6},(t,n)=>(e[Math.min(n,e.length-1)]??new r(`#ffffff`)).clone())},uCount:{value:Math.max(1,Math.min(6,e.length))}}}function d(e,t,a,
|
|
46
|
+
`;function u(e){return{uColors:{value:Array.from({length:6},(t,n)=>(e[Math.min(n,e.length-1)]??new r(`#ffffff`)).clone())},uCount:{value:Math.max(1,Math.min(6,e.length))}}}function d(e,t,i,a,c={}){return{create(l,d){let f={uTime:{value:0},...i(o(e,l,d))},p=new n({uniforms:f,vertexShader:s,fragmentShader:t,...c});return p.name=`shader:${e}`,p.userData.shader=e,p.userData.setParam=(t,n)=>{let i=a[t];if(!i||!f[i])return;if(t===`colors`){let t=u(o(e,{colors:n},d).colors(`colors`));f.uColors.value=t.uColors.value,f.uCount.value=t.uCount.value;return}let s=f[i].value;s instanceof r?typeof n==`string`&&s.copy(d.color(n)):typeof n==`number`&&(f[i].value=n)},{material:p,update(e){f.uTime.value=e}}}}}var f=`
|
|
47
47
|
float h21(vec2 p) { vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); }
|
|
48
48
|
vec2 h22(vec2 p) { vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973)); q += dot(q, q.yzx + 33.33); return fract((q.xx + q.yz) * q.zy); }
|
|
49
49
|
`,p={gradientMesh:d(`gradientMesh`,`
|
|
@@ -52,7 +52,7 @@ uniform float uSpeed;
|
|
|
52
52
|
uniform float uGrain;
|
|
53
53
|
varying vec2 vUv;
|
|
54
54
|
${a}
|
|
55
|
-
${
|
|
55
|
+
${i}
|
|
56
56
|
void main() {
|
|
57
57
|
float t = uTime * uSpeed;
|
|
58
58
|
vec3 col = meshGradient((vUv - 0.5) * 1.6, t);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SVGLoader-CIYl0nEy.js","./three.module-CnI50X0U.js","./BufferGeometryUtils-CAlXAboW.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{I as e,In as t,P as n,U as r,h as i,ln as a,m as o,rn as s,u as c,x as l,xt as u}from"./three.module-CnI50X0U.js";import{a as d,f,s as p}from"./runtime-DY_KqD1x.js";import{v as m}from"./camera-7sEn13L-.js";import{i as h,n as g,r as _,t as v}from"./extrude-9bG8hr2C.js";import{h as y}from"./index-3LL5NEIH.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 l(e[0].color),a=new l(e[e.length-1].color);return`#${i.lerp(a,.5).getHexString()}`}try{let t=new l;return t.setStyle(e,s),`#${t.getHexString(s)}`}catch{return n}}function S(e,t){let n=new c;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(m(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=m(e.opacity,1);if(b(e.fill)){let t=s.toShapes().map(e=>_(e,a));t.length&&r.push({kind:`fill`,color:x(e.fill,s,o),opacity:m(e.fillOpacity,1)*c,shapes:t})}if(n.strokes!==!1&&b(e.stroke)&&m(e.strokeWidth,1)>0){let n=t.getStrokeStyle(m(e.strokeWidth,1),`#000`,e.strokeLineJoin??`miter`,e.strokeLineCap??`butt`,m(e.strokeMiterLimit,4)),l=[];for(let e of s.subPaths){let r=g(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:m(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 a=new i;return a.setAttribute(`position`,new o(n,3)),a}function T(e,n=12){let r=new c;for(let i of e){if(i.shapes)for(let e of i.shapes)for(let t of e.getPoints(n))r.expandByPoint(t);if(i.stroke){let e=i.stroke.getAttribute(`position`);for(let n=0;n<e.count;n++)r.expandByPoint(new t(e.getX(n),e.getY(n)))}}return r}function E(e,t,r,i,o){if(e.kind===`stroke`)return e.stroke?v(e.stroke,t):null;if(!e.shapes?.length)return null;if(t<=0)return new a(e.shapes,i);let s=Math.min(r,t*.45),c=new n(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(),h(c,50*Math.PI/180,o)}async function D(t,n){let[{SVGLoader:i},a]=await Promise.all([y(()=>import(`./SVGLoader-CIYl0nEy.js`),__vite__mapDeps([0,1]),import.meta.url),y(()=>import(`./BufferGeometryUtils-CAlXAboW.js`).then(e=>e.t),__vite__mapDeps([2,1]),import.meta.url)]),o=t.src.trim().startsWith(`<`)?t.src:await f(n.resolveAsset(t.src)),s=new i().parse(o),c=t.material?p(t.material):void 0,l=typeof c?.color==`string`?c.color:void 0,h=Math.max(1,Math.round(m(t.curveSegments,12))),g=C(s,i,{strokes:t.strokes,curveSegments:h,currentColor:l}),_=new r,v=T(g,h);if(!g.length||v.isEmpty())return _;let b=m(t.size,2),x=Math.max(v.max.x-v.min.x,1e-6),S=Math.max(v.max.y-v.min.y,1e-6),w=t.fit??`width`,D=b/(w===`height`?S:w===`max`?Math.max(x,S):x),O=Math.max(0,m(t.depth,.2)),k=O/D,A=m(t.bevel,0)/D,j=m(t.layerGap,O>0?O*.02:b*.002),M=t.keepColors??!t.material,N=new Map,P=async(e,r)=>{let i=M?`${e}|${r}`:`|${r}`,a=N.get(i);if(!a){let o=M?{roughness:.4,metalness:.1,...t.material??{},color:e,...r<1?{opacity:r}:{}}:t.material?{...t.material,...r<1?{opacity:r}:{}}:{color:`#dddddd`,roughness:.4,metalness:.1};a=await d(o,n,{defaultColor:e}),r<1&&(a.transparent=!0),O<=0&&(a.side=2),N.set(i,a)}return a},F=[];for(let e of g){let t=E(e,k,A,h,a);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 r;for(let[t,n]of F.entries()){for(let t of n.geos){for(let e of Object.keys(t.attributes))[`position`,`normal`,`uv`].includes(e)||t.deleteAttribute(e);t.getAttribute(`uv`)||t.setAttribute(`uv`,new e(new Float32Array(t.getAttribute(`position`).count*2),2))}let r=n.geos.length===1?n.geos[0]:a.mergeGeometries(n.geos.map(e=>e.index?e.toNonIndexed():e),!1)??n.geos[0],i=new u(r,await P(n.color,n.opacity));i.position.z=t*j/D,I.add(i)}let L=(v.min.x+v.max.x)/2,R=(v.min.y+v.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),_.add(I),_}export{D as buildSvg};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./FontLoader-
|
|
2
|
-
import{
|
|
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=[],f=0;return c.forEach((e,n)=>{for(;e.length&&e[e.length-1]===` `;)e.pop();let{xs:r,width:a}=s(e);f=Math.max(f,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:f}}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
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./FontLoader-Bzjx8mXt.js","./three.module-CnI50X0U.js","./BufferGeometryUtils-CAlXAboW.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{In as e,Lt as t,P as n,St as r,U as i,cn as a,h as o,ln as s,xt as c}from"./three.module-CnI50X0U.js";import{a as l,d as u}from"./runtime-DY_KqD1x.js";import{h as d,t as f}from"./index-3LL5NEIH.js";import{v as p}from"./camera-7sEn13L-.js";import{i as m,r as h}from"./extrude-9bG8hr2C.js";var g=new Map;function _(e){let t=g.get(e);return t||(t=Promise.all([d(()=>import(`./FontLoader-Bzjx8mXt.js`),__vite__mapDeps([0,1]),import.meta.url),u(e)]).then(([e,t])=>new e.FontLoader().parse(t)),t.catch(()=>g.delete(e)),g.set(e,t)),t}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=p(t.letterSpacing,0),i=p(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=[],f=0;return c.forEach((e,n)=>{for(;e.length&&e[e.length-1]===` `;)e.pop();let{xs:r,width:a}=s(e);f=Math.max(f,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:f}}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 s(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=p(t.size,1),i=r/x(e),a=Math.max(0,p(t.depth,.2)),o=a>0?Math.max(0,Math.min(p(t.bevel,Math.min(a*.3,r*.035)),a*.45,r*.08)):0,s=Math.round(Math.max(2,Math.min(32,p(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=>h(e,r,1,n.curveSegments))}function T(e,t,r,i){let a=w(e,t,r);if(!a.length)return null;if(r.depth<=0)return new s(a,r.curveSegments);let o=new n(a,C(r));return o.translate(0,0,r.backZ+r.bevel),o.clearGroups(),m(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,p(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(p(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(t,n,r=2){let i=t.filter((e,n)=>{let r=t[(n+1)%t.length];return Math.hypot(r.x-e.x,r.y-e.y)>1e-9}),a=i.length,o=[];if(a<3)return i.map(t=>new e(t.x,t.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 t=0;t<a;t++){let c=i[(t-1+a)%a],l=i[t],u=i[(t+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 t=Math.atan2(d.y,d.x),r=Math.atan2(f.y,f.x);for(;r<t;)r+=Math.PI*2;for(;r>t+Math.PI*2;)r-=Math.PI*2;let i=Math.max(1,Math.ceil(Math.abs(r-t)/(Math.PI/8)));for(let a=0;a<=i;a++){let s=t+(r-t)*a/i;o.push(new e(l.x+Math.cos(s)*n,l.y+Math.sin(s)*n))}}else{let t=d.x+f.x,i=d.y+f.y,a=Math.hypot(t,i)||1;t/=a,i/=a;let s=Math.max(t*d.x+i*d.y,1/r);o.push(new e(l.x+t*n/s,l.y+i*n/s))}}return o}function k(e,n){let r=[];for(let i of e){let{shape:e,holes:o}=i.extractPoints(1),s=e.slice();D(s)<0&&(s=s.reverse());let c=new a(O(s,n));for(let e of o){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*n||Math.max(...o)-Math.min(...o)<=2*n)continue;let s=O(r,n),l=D(s);l<0&&-l>i*.02&&c.holes.push(new t(s))}r.push(c)}return r}function A(e,t,r,i,a){let o=w(e,t,r);if(!o.length)return null;let s=new n(k(o,i.width),{depth:i.frontZ-i.backZ,curveSegments:1,bevelEnabled:!1});return s.translate(0,0,i.backZ),s.clearGroups(),m(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 o;else{a=(i.length===1?i[0].clone():n.mergeGeometries(i,!1))??new o;for(let e of i)e.dispose()}return a.computeBoundingBox(),a.computeBoundingSphere(),a}function M(e,t,n){let r=p(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 p(e.delay,0)+i*r}function N(e,t){return(n,r)=>{let i=e.effect??`rise`,a=Math.max(p(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=f(o,n),d=r.object;if(s){let e=f(`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&&(d.visible=!1),i){case`rise`:d.position.y-=(1-u)*t*.6;break;case`drop`:d.position.y+=(1-u)*t*1.2;break;case`scale`:d.scale.multiplyScalar(Math.max(1e-4,u));break;case`spin`:d.rotation.y+=(1-u)*Math.PI,d.scale.multiplyScalar(Math.max(1e-4,Math.min(1,n*2)))}}}}}var P=null;function F(e){P??=new r({colorWrite:!1,depthWrite:!0});let t=new c(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)),d(()=>import(`./BufferGeometryUtils-CAlXAboW.js`).then(e=>e.t),__vite__mapDeps([2,1]),import.meta.url)]),a=S(n,e),o=E(e,a),s=!!e.splitLetters||!!e.reveal,u=a.depth<=0,f=()=>l(e.material,t,{defaultColor:`#ffffff`}),p=()=>o?l(o.material??{color:o.color,roughness:.55},t):null,m=(a.layout.lines.length?a.layout.lines[a.layout.lines.length-1].y:0)+a.offsetY,h=a.size+a.offsetY,g=e=>(u&&(e.side=2),e);if(!s){let t=j(a,e=>T(n,e,a,r),r),i=g(await f());L(i,m,h);let s=new c(t,i);if(o){let t=j(a,e=>A(n,e,a,o,r),r),i=await p();if(i){L(i,m,h);let n=new c(t,i);n.name=`${e.id}/outline`,s.add(n)}}return{object:s,letters:[]}}let v=new i,y=new Map,b=new Map,x=a.size/2,C=[],w=a.layout.glyphs.length,D=0;for(let t of a.layout.glyphs){if(!y.has(t.ch)){let e=T(n,t.ch,a,r),i=0;if(e&&(e.computeBoundingBox(),i=(e.boundingBox.min.x+e.boundingBox.max.x)/2,e.translate(-i,-x,0),e.computeBoundingSphere()),y.set(t.ch,e),o){let e=A(n,t.ch,a,o,r);e?.translate(-i,-x,0),b.set(t.ch,e)}e&&(e.userData.cx=i)}let i=y.get(t.ch);if(!i)continue;let s=i.userData.cx,l=a.layout.lines[t.line].y+a.offsetY,u=g(await f());L(u,m-l-x,h-l-x);let d=new c(i,u);d.position.set(t.x+s,l+x,0);let _=`${e.id}/${D}`;d.name=_,d.userData.a3dId=_;let S=b.get(t.ch);if(S){let e=await p();if(e){L(e,m-l-x,h-l-x);let t=new c(S,e);t.name=`${_}/outline`,d.add(t)}}v.add(d);let E={id:_,object:d,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,a.size)}),C.push(E),D++}return{object:v,letters:C}}export{R as buildText};
|