@fleox/agent3d 0.2.2 → 0.3.0

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 (70) hide show
  1. package/README.md +21 -13
  2. package/changelog.json +24 -0
  3. package/dist/agent/agent3d.mjs +228 -53
  4. package/dist/agent/chunks/{assets-BUUM9TUB.mjs → assets-YBkgdfgy.mjs} +27 -8
  5. package/dist/agent/chunks/{browser-Br1tURgt.mjs → browser-Dil7VM5m.mjs} +1 -1
  6. package/dist/agent/chunks/{cdp-Bdtm4fBN.mjs → cdp-DLEis_Z3.mjs} +1 -1
  7. package/dist/agent/chunks/{check-CfZcfaPs.mjs → check-DP9fRYbK.mjs} +64 -4
  8. package/dist/agent/chunks/depth-0bZsQn6N.mjs +190 -0
  9. package/dist/agent/chunks/depth-Dih8jLqx.mjs +483 -0
  10. package/dist/agent/chunks/{export-BHugc2H7.mjs → export-Cdqt3mt_.mjs} +8 -4
  11. package/dist/agent/chunks/{imageCodec-QM0EXQDJ.mjs → imageCodec-DeGfmBp3.mjs} +3 -3
  12. package/dist/agent/chunks/{objects-DBAws7uf.mjs → objects-DuytRxiC.mjs} +3 -3
  13. package/dist/agent/chunks/{optimizeSizing-CkZ3fZRp.mjs → optimizeSizing-B-BBiUkD.mjs} +51 -3
  14. package/dist/agent/chunks/{package-Dkr2v4or.mjs → package-d5e08XSG.mjs} +2 -1
  15. package/dist/agent/chunks/{render-EHb40avl.mjs → render-B05DU4Q5.mjs} +4 -4
  16. package/dist/agent/chunks/{scene-BgajNvBf.mjs → scene-DWgXH6As.mjs} +2 -2
  17. package/dist/agent/chunks/{server-CACCerkZ.mjs → server-Dt_YFvN7.mjs} +6 -2
  18. package/dist/agent/chunks/{tools-DKxgjQSJ.mjs → tools-Cv6N_YBI.mjs} +60 -6
  19. package/dist/agent/chunks/{tree-BrNYGui2.mjs → tree-CqSj-o8T.mjs} +1 -0
  20. package/dist/agent/ort/LICENSE.txt +9 -0
  21. package/dist/agent/ort/ort-wasm-simd-threaded.wasm +0 -0
  22. package/dist/agent/ort/ort.wasm.bundle.min.mjs +9 -0
  23. package/dist/runtime/agent3d-runtime.js +6 -6
  24. package/dist/runtime/agent3d-runtime.single.js +311 -62
  25. package/dist/runtime/chunks/assets-qnxDnVkj.js +1 -0
  26. package/dist/runtime/chunks/materials-dC4vDNHh.js +107 -0
  27. package/dist/runtime/chunks/{model-DbfZaLni.js → model-BCAl_NRl.js} +1 -1
  28. package/dist/runtime/chunks/photo-BlDYgYFM.js +250 -0
  29. package/dist/runtime/chunks/svg-CLUxY6Zy.js +1 -0
  30. package/dist/runtime/chunks/{text-BaON-ISS.js → text-rSo_2Luk.js} +2 -2
  31. package/dist/studio/assets/assets-BFJsr9Oo.js +1 -0
  32. package/dist/studio/assets/{camera-braC-Y4j.js → camera-DT0xHipx.js} +1 -1
  33. package/dist/studio/assets/{editor-DwKj0yf_.js → editor-BjgHj9g8.js} +1 -1
  34. package/dist/studio/assets/{game-Bd0sO8CA.js → game-BXZEc9HN.js} +3 -3
  35. package/dist/studio/assets/{generators-CFiebqmG.js → generators-DqkPMEzm.js} +1 -1
  36. package/dist/studio/assets/index-DVTzVcBD.js +479 -0
  37. package/dist/studio/assets/{model-Bg7e4Z-9.js → model-BqQW4Dg-.js} +1 -1
  38. package/dist/studio/assets/params-gVpEEiSK.js +1 -0
  39. package/dist/studio/assets/photo-DRoVO5iZ.js +250 -0
  40. package/dist/studio/assets/{physicsHost-CwJdYJ2g.js → physicsHost-DNdZ7AsT.js} +1 -1
  41. package/dist/studio/assets/{postfx-CGkvYb03.js → postfx-JFUGdY0d.js} +1 -1
  42. package/dist/studio/assets/runtime-CMAP4azF.js +572 -0
  43. package/dist/studio/assets/{shaders-Brwuj1zc.js → shaders-C7u6rN_6.js} +12 -12
  44. package/dist/studio/assets/svg-DkIOJjzS.js +2 -0
  45. package/dist/studio/assets/{text-DqnNIq0M.js → text-LISSAism.js} +2 -2
  46. package/dist/studio/index.html +1 -1
  47. package/package.json +2 -1
  48. package/plugin/.claude-plugin/plugin.json +1 -1
  49. package/plugin/skills/agent3d-assets/SKILL.md +40 -25
  50. package/plugin/skills/agent3d-create/SKILL.md +56 -21
  51. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  52. package/plugin/skills/agent3d-create/references/recipes.md +71 -6
  53. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  54. package/plugin/skills/agent3d-edit/references/patch-ops.md +11 -3
  55. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  56. package/plugin/skills/agent3d-publish/SKILL.md +23 -21
  57. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  58. package/templates/hero-photo-3d/README.md +28 -0
  59. package/templates/hero-photo-3d/agent3d.json +8 -0
  60. package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
  61. package/templates/hero-photo-3d/assets/manifest.json +25 -0
  62. package/templates/hero-photo-3d/assets/textures/street.jpg +0 -0
  63. package/templates/hero-photo-3d/preview.png +0 -0
  64. package/templates/hero-photo-3d/scene.json +120 -0
  65. package/templates/hero-photo-3d/template.json +8 -0
  66. package/dist/runtime/chunks/materials-w3EW0g-7.js +0 -107
  67. package/dist/runtime/chunks/svg-CfPIQnDG.js +0 -1
  68. package/dist/studio/assets/index-C87jPees.js +0 -479
  69. package/dist/studio/assets/runtime-DNb5FyOS.js +0 -572
  70. package/dist/studio/assets/svg-Db96jdHi.js +0 -2
@@ -1,107 +0,0 @@
1
- import{Ct as e,Et as t,Gt as n,Mn as r,Qt as i,St as a,T as o,Tt as s,b as c,bt as l,en as u,h as d,ht as f,kn as p,n as m,ot as h,st as g,wt as _}from"./three.module-DnaBiDAJ.js";import{a as v,c as y}from"./catalog--OTp4gjy.js";import{c as b,d as x,i as ee,t as S}from"./util-CyaW1fcW.js";import{n as te}from"./params-BCNrVCYZ.js";import{t as ne}from"./random-eeej60NW.js";import{t as C}from"./toon-BsvVk_nK.js";function w(e){return e.endsWith(`/`)?e:e+`/`}function T(e){let t=w(e.assetBase??`./`),n=w(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 E=/* @__PURE__ */ new Map;function D(e){let t=E.get(e);return t||(t=fetch(e).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return t.text()}),t.catch(()=>E.delete(e)),E.set(e,t)),t}async function O(e){return JSON.parse(await D(e))}var k=/* @__PURE__ */ new Map;function A(e){let t=k.get(e);return t||(t=import(`./three.module-DnaBiDAJ.js`).then(e=>e.a).then(t=>new Promise((n,r)=>{new t.TextureLoader().load(e,n,void 0,()=>r(/* @__PURE__ */ Error(`Cannot load texture ${e}`)))})),t.catch(()=>k.delete(e)),k.set(e,t)),t.then(e=>{let t=e.clone();return t.needsUpdate=!0,t})}var j={map:`color`,emissiveMap:`color`,normalMap:`normal`,roughnessMap:`data`,metalnessMap:`data`,aoMap:`data`,bumpMap:`data`,displacementMap:`data`,alphaMap:`data`},M=class{perm=/* @__PURE__ */ new Uint16Array(512);grads=/* @__PURE__ */ new Float32Array(512);constructor(e){let t=ne(e),n=Array.from({length:256},(e,t)=>t);for(let e=255;e>0;e--){let r=Math.floor(t.next()*(e+1));[n[e],n[r]]=[n[r],n[e]]}for(let e=0;e<512;e++)this.perm[e]=n[e&255];for(let e=0;e<256;e++){let n=t.next()*Math.PI*2;this.grads[e*2]=Math.cos(n),this.grads[e*2+1]=Math.sin(n)}}g(e,t,n,r,i,a){let o=(e%n+n)%n,s=(t%r+r)%r,c=this.perm[this.perm[o&255]+s&511]&255;return this.grads[c*2]*i+this.grads[c*2+1]*a}noise(e,t,n,r){let i=Math.floor(e),a=Math.floor(t),o=e-i,s=t-a,c=o*o*o*(o*(o*6-15)+10),l=s*s*s*(s*(s*6-15)+10),u=this.g(i,a,n,r,o,s),d=this.g(i+1,a,n,r,o-1,s),f=this.g(i,a+1,n,r,o,s-1),p=this.g(i+1,a+1,n,r,o-1,s-1);return(u+(d-u)*c+(f-u)*l+(u-d-f+p)*c*l)*1.4}fbm(e,t,n,r,i=n){let a=0,o=.5,s=0,c=n,l=i;for(let n=0;n<r;n++)a+=o*this.noise(e*c,t*l,c,l),s+=o,o*=.5,c*=2,l*=2;return a/s}},N=(e,t,n)=>{let r=Math.imul(e|0,374761393)+Math.imul(t|0,668265263)+Math.imul(n|0,2246822519)|0;return r=Math.imul(r^r>>>13,1274126177),r^=r>>>16,(r>>>0)/4294967296},P=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e||1e-6)));return r*r*(3-2*r)},F=e=>e-Math.floor(e);function I(e,t,n,r,i){let a=e*n,o=t*n,s=Math.floor(a),c=Math.floor(o),l=9,u=9,d=0,f=0;for(let e=-1;e<=1;e++)for(let t=-1;t<=1;t++){let p=s+t,m=c+e,h=(p%n+n)%n,g=(m%n+n)%n,_=p+.5+(N(h,g,i)-.5)*r,v=m+.5+(N(h,g,i+17)-.5)*r,y=Math.hypot(_-a,v-o);y<l?(u=l,l=y,d=h,f=g):y<u&&(u=y)}return{f1:l,f2:u,cx:d,cy:f}}var L={marble(e,t){let n=e.num(`scale`),r=Math.max(1,Math.round(2*n)),i=2+e.num(`veins`)*22,a=e.num(`turbulence`);return{h(e,n){let o=t.fbm(e,n,r*2,5),s=t.fbm(e+.37,n+.71,r*2,5),c=t.fbm(e+o*.12*a,n+s*.12*a,r*3,6),l=(e*.6+n)*r+a*2.6*c,u=(1-Math.abs(Math.sin(Math.PI*l)))**i,d=t.fbm(e+.5,n,r*6,5),f=(1-Math.abs(Math.sin(Math.PI*(l*2.3+d*3))))**(i*2.5)*.45,p=(t.fbm(e,n+.3,r*2,4)*.5+.5)*.18;return Math.min(1,u*.9+f+p)}}},wood(e,t){let n=e.num(`scale`),r=e.num(`rings`),i=e.num(`grain`),a=Math.max(1,Math.round(n));return{h(e,o){let s=t.fbm(e,o,2*a,4,1*a),c=F(e*Math.round(r*n)+s*1.8),l=P(0,.7,c)*(1-P(.85,1,c)),u=t.noise(e*64*a,o*3*a,64*a,3*a)*.5+.5;return Math.min(1,Math.max(0,l*.75+u*i*.35+(s*.5+.5)*.15))}}},terrazzo(e,t,n){let r=Math.max(2,Math.round(10*e.num(`scale`)/e.num(`chipSize`))),i=e.num(`density`),a=Math.max(1,e.colors(`colors`).length-1),o=(e,o)=>{let s=I(e,o,r,1,n);if(N(s.cx,s.cy,n+5)>i)return{m:0,idx:-1};let c=.18+N(s.cx,s.cy,n+9)*.3,l=s.f1+t.noise(e*r*4,o*r*4,r*4,r*4)*.08;return{m:1-P(c-.03,c+.01,l),idx:1+Math.floor(N(s.cx,s.cy,n+3)*a)}};return{h(e,t){return o(e,t).m},pick(e,t){let n=o(e,t);return n.m>.5?n.idx:-1}}},carbon(e,t){let n=Math.max(2,Math.round(8*e.num(`scale`)));return{h(e,r){let i=e*n,a=r*n,o=Math.floor(i),s=Math.floor(a),c=i-o,l=a-s,u=((o+s)%4+4)%4<2,d=u?l:c,f=u?e:r,p=Math.sin(Math.PI*d),m=t.noise(f*n*2,d*40,n*2,40)*.5+.5;return Math.min(1,p*(u?.85:.45)*(.75+m*.25))}}},noise(e,t){let n=Math.max(1,Math.round(4*e.num(`scale`))),r=e.int(`octaves`),i=e.num(`contrast`);return{h:(e,a)=>Math.min(1,Math.max(0,.5+t.fbm(e,a,n,r)*.5*i*1.6))}},voronoi(e,t,n){let r=Math.max(1,Math.round(8*e.num(`scale`))),i=e.num(`jitter`);return{h(e,t){let a=I(e,t,r,i,n);return P(0,.25,a.f2-a.f1)}}},flakes(e,t,n){let r=Math.max(4,Math.round(64*e.num(`scale`))),i=e.num(`strength`);return{h(e,t){return N(Math.floor(e*r),Math.floor(t*r),n)},normal(e,t,a){let o=I(e,t,r,1,n),s=N(o.cx,o.cy,n+1)*Math.PI*2,c=Math.sqrt(N(o.cx,o.cy,n+2))*i,l=Math.cos(s)*c,u=Math.sin(s)*c;a[0]=l,a[1]=u,a[2]=Math.sqrt(Math.max(0,1-l*l-u*u))}}},brushed(e,t){let n=Math.max(1,Math.round(e.num(`scale`))),r=e.num(`streaks`),i=Math.max(8,Math.round(300*r*n));return{h(e,r){let a=t.noise(e*2*n,r*i,2*n,i)*.5+.5,o=t.noise(e*6*n,r*i*2.5,6*n,Math.round(i*2.5))*.5+.5,s=t.fbm(e,r,3*n,3)*.5+.5;return Math.min(1,Math.max(0,a*.5+o*.3+s*.2))}}},grid(e,t,n,r){let i=Math.max(1,Math.round(e.int(`cells`)*e.num(`scale`))),a=i/r,o=Math.max(e.num(`lineWidth`)*.5,a*.75);return{h(e,t){let n=F(e*i),r=F(t*i),s=Math.min(n,1-n,r,1-r);return 1-P(o-a*.5,o+a*.5,s)}}},checker(e){let t=Math.max(1,Math.round(e.int(`cells`)*e.num(`scale`)));return{h:(e,n)=>Math.floor(e*t)+Math.floor(n*t)&1?1:0}},stripes(e){let t=Math.max(1,Math.round(e.int(`count`)*e.num(`scale`))),n=e.num(`angle`)*Math.PI/180,r=Math.round(Math.cos(n)*t),i=Math.round(Math.sin(n)*t),a=Math.max(.002,e.num(`softness`));return{h(e,t){let n=Math.abs(F(e*r+t*i)-.5)*2;return P(.5-a*2,.5+a*2,n)}}},dots(e){let t=Math.max(1,Math.round(e.int(`cells`)*e.num(`scale`))),n=e.num(`radius`);return{h(e,r){let i=F(e*t)-.5,a=F(r*t)-.5;return 1-P(n-.02,n+.01,Math.hypot(i,a))}}}};Object.keys(L);var R=e=>{let t=e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;return Math.max(0,Math.min(255,Math.round(t*255)))},z=/* @__PURE__ */ new Map;function re(e){return 2**Math.round(Math.log2(Math.max(32,Math.min(2048,e))))}function ie(e,t){let n=t+`:`+JSON.stringify(e),r=z.get(n);if(r)return r;let i=y.find(t=>t.id===e.procedural),a=L[e.procedural];if(!i||!a)throw Error(`Unknown procedural texture "${e.procedural}"`);let o=te(i,e),s=o.int(`seed`),c=re(o.int(`resolution`)),l=a(o,new M(s),s,c),u=new Uint8Array(c*c*4),d=new Float32Array(c*c);for(let e=0;e<c;e++){let t=(e+.5)/c;for(let n=0;n<c;n++)d[e*c+n]=l.h((n+.5)/c,t)}if(t===`color`){let e=o.colors(`colors`).map(e=>[e.r,e.g,e.b]),t=e.length;for(let n=0;n<c;n++)for(let r=0;r<c;r++){let i=n*c+r,a,o,s,f=l.pick?l.pick((r+.5)/c,(n+.5)/c):-1;if(f>=0)[a,o,s]=e[Math.min(f,t-1)];else if(l.pick)[a,o,s]=e[0];else{let n=Math.min(1,Math.max(0,d[i]))*(t-1),r=Math.min(t-2,Math.floor(n)),c=t>1?n-r:0,l=e[Math.max(0,r)],u=e[Math.min(t-1,r+1)];a=l[0]+(u[0]-l[0])*c,o=l[1]+(u[1]-l[1])*c,s=l[2]+(u[2]-l[2])*c}u[i*4]=R(a),u[i*4+1]=R(o),u[i*4+2]=R(s),u[i*4+3]=255}}else if(t===`normal`){let e=[0,0,1],t=c/256*2;for(let n=0;n<c;n++)for(let r=0;r<c;r++){let i=n*c+r,a,o,s;if(l.normal)l.normal((r+.5)/c,(n+.5)/c,e),[a,o,s]=e;else{let e=(e,t)=>d[(t+c)%c*c+(e+c)%c],i=(e(r+1,n-1)+2*e(r+1,n)+e(r+1,n+1)-e(r-1,n-1)-2*e(r-1,n)-e(r-1,n+1))/8,l=(e(r-1,n+1)+2*e(r,n+1)+e(r+1,n+1)-e(r-1,n-1)-2*e(r,n-1)-e(r+1,n-1))/8;a=-i*t,o=-l*t,s=1;let u=Math.hypot(a,o,s);a/=u,o/=u,s/=u}u[i*4]=Math.round((a*.5+.5)*255),u[i*4+1]=Math.round((o*.5+.5)*255),u[i*4+2]=Math.round((s*.5+.5)*255),u[i*4+3]=255}}else for(let e=0;e<c*c;e++){let t=Math.round(Math.min(1,Math.max(0,d[e]))*255);u[e*4]=u[e*4+1]=u[e*4+2]=t,u[e*4+3]=255}let f={data:u,size:c};return z.size>64&&z.clear(),z.set(n,f),f}function ae(e,t){let r=ie(e,t),a=new o(r.data,r.size,r.size,n,p);return a.colorSpace=t===`color`?u:``,a.wrapS=a.wrapT=i,a.magFilter=h,a.minFilter=g,a.generateMipmaps=!0,a.anisotropy=4,a.needsUpdate=!0,a.name=`procedural:${e.procedural}`,a}v.map(e=>e.id);function B(e){let t=e??{},n={...(t.preset?v.find(e=>e.id===t.preset):void 0)?.props??{}};for(let[e,r]of Object.entries(t))r!==void 0&&e!==`preset`&&(n[e]=r);return n.type||=n.shader?`shader`:n.gradient?`gradient`:`standard`,n}function V(e,t,n){let r=e.userData.a3dPatches;if(!r){r=e.userData.a3dPatches=[];let t=e.onBeforeCompile;if(t!==f.prototype.onBeforeCompile){let n=e.customProgramCacheKey.call(e);r.push({key:`own(${n})`,patch:(n,r)=>t.call(e,n,r)})}}if(r.some(e=>e.key===t))return;r.push({key:t,patch:n});let i=r;e.onBeforeCompile=(e,t)=>{for(let n of i)n.patch(e,t)},e.customProgramCacheKey=()=>`agent3d:`+i.map(e=>e.key).join(`+`),e.needsUpdate=!0}var H=null;function U(){if(H)return H;if(typeof document>`u`)return null;let e=document.createElement(`canvas`);e.width=e.height=256;let t=e.getContext(`2d`);if(!t)return null;let n=t.createRadialGradient(97.28,81.92,5.12,128,128,133.12);n.addColorStop(0,`#ffffff`),n.addColorStop(.25,`#e6e6ea`),n.addColorStop(.7,`#7d7f88`),n.addColorStop(1,`#2a2b30`),t.fillStyle=n,t.fillRect(0,0,256,256);let r=t.createRadialGradient(128,128,102.4,128,128,128);return r.addColorStop(0,`rgba(255,255,255,0)`),r.addColorStop(1,`rgba(200,210,255,0.35)`),t.fillStyle=r,t.fillRect(0,0,256,256),H=new d(e),H.colorSpace=u,H}var W={front:0,back:1,double:2},G=8;function K(e,t,n=!1){let r=t.slice(0,G).map(e=>x(e));for(;r.length<G;)r.push(r[r.length-1].clone());let i={uGradColors:{value:r},uGradCount:{value:Math.min(Math.max(t.length,1),G)},uGradMin:{value:-.5},uGradMax:{value:.5}};return V(e,n?`gradient-emissive`:`gradient`,e=>{Object.assign(e.uniforms,i),e.vertexShader=`varying float vGradY;
2
- `+e.vertexShader.replace(`#include <begin_vertex>`,`#include <begin_vertex>
3
- vGradY = position.y;`);let t=`varying float vGradY;\nuniform vec3 uGradColors[${G}];\nuniform int uGradCount;\nuniform float uGradMin;\nuniform float uGradMax;\n`+e.fragmentShader.replace(`vec4 diffuseColor = vec4( diffuse, opacity );`,`float gT = clamp((vGradY - uGradMin) / max(uGradMax - uGradMin, 1e-5), 0.0, 1.0);
4
- vec3 gCol = uGradColors[0];
5
- if (uGradCount > 1) {
6
- float f = gT * float(uGradCount - 1);
7
- for (int i = 0; i < 7; i++) {
8
- if (i < uGradCount - 1) gCol = mix(gCol, uGradColors[i + 1], clamp(f - float(i), 0.0, 1.0));
9
- }
10
- }
11
- vec4 diffuseColor = vec4( diffuse * gCol, opacity );`);n&&(t=t.replace(`#include <emissivemap_fragment>`,`#include <emissivemap_fragment>
12
- totalEmissiveRadiance *= gCol;`)),e.fragmentShader=t}),e.userData.gradient=i,i}function q(e,t){for(let n of Array.isArray(e)?e:[e]){let e=n.userData.gradient;if(!e)continue;t.boundingBox||t.computeBoundingBox();let r=t.boundingBox;e.uGradMin.value=r.min.y,e.uGradMax.value=r.max.y}}var oe=`
13
- varying vec3 vTriPos;
14
- varying vec3 vTriNormal;
15
- uniform vec2 uTriScale;
16
- vec3 triW() {
17
- vec3 w = pow(abs(normalize(vTriNormal)), vec3(4.0));
18
- return w / max(w.x + w.y + w.z, 1e-5);
19
- }
20
- vec4 triSample(sampler2D tex) {
21
- vec3 w = triW();
22
- vec3 p = vTriPos;
23
- return texture2D(tex, p.zy * uTriScale) * w.x + texture2D(tex, p.xz * uTriScale) * w.y + texture2D(tex, p.xy * uTriScale) * w.z;
24
- }
25
- `;function se(e,t,n){let i={value:new r(t*(n?.[0]??1),t*(n?.[1]??n?.[0]??1))};V(e,`triplanar`,e=>{e.uniforms.uTriScale=i,e.vertexShader=`varying vec3 vTriPos;
26
- varying vec3 vTriNormal;
27
- `+e.vertexShader.replace(`#include <begin_vertex>`,`#include <begin_vertex>
28
- vTriPos = position;
29
- vTriNormal = normal;`);let t=e.fragmentShader;t=t.replace(`#include <common>`,`#include <common>
30
- `+oe+`
31
- #if defined( USE_NORMALMAP_TANGENTSPACE ) && !defined( USE_NORMALMAP_OBJECTSPACE )
32
- uniform mat3 normalMatrix;
33
- #endif
34
- `),t=t.replace(`#include <map_fragment>`,`#ifdef USE_MAP
35
- diffuseColor *= triSample( map );
36
- #endif`),t=t.replace(`#include <roughnessmap_fragment>`,`float roughnessFactor = roughness;
37
- #ifdef USE_ROUGHNESSMAP
38
- roughnessFactor *= triSample( roughnessMap ).g;
39
- #endif`),t=t.replace(`#include <metalnessmap_fragment>`,`float metalnessFactor = metalness;
40
- #ifdef USE_METALNESSMAP
41
- metalnessFactor *= triSample( metalnessMap ).b;
42
- #endif`),t=t.replace(`#include <emissivemap_fragment>`,`#ifdef USE_EMISSIVEMAP
43
- totalEmissiveRadiance *= triSample( emissiveMap ).rgb;
44
- #endif`),t=t.replace(`#include <normal_fragment_maps>`,`#if defined( USE_NORMALMAP_TANGENTSPACE )
45
- {
46
- vec3 tw = triW();
47
- vec3 on = normalize( vTriNormal );
48
- vec3 p = vTriPos;
49
- vec3 tx = texture2D( normalMap, p.zy * uTriScale ).xyz * 2.0 - 1.0;
50
- vec3 ty = texture2D( normalMap, p.xz * uTriScale ).xyz * 2.0 - 1.0;
51
- vec3 tz = texture2D( normalMap, p.xy * uTriScale ).xyz * 2.0 - 1.0;
52
- tx.xy *= normalScale; ty.xy *= normalScale; tz.xy *= normalScale;
53
- tx = vec3( tx.xy + on.zy, abs( tx.z ) * on.x );
54
- ty = vec3( ty.xy + on.xz, abs( ty.z ) * on.y );
55
- tz = vec3( tz.xy + on.xy, abs( tz.z ) * on.z );
56
- vec3 objN = normalize( tx.zyx * tw.x + ty.xzy * tw.y + tz.xyz * tw.z );
57
- normal = normalize( normalMatrix * objN ) * faceDirection;
58
- }
59
- #else
60
- #include <normal_fragment_maps>
61
- #endif`),e.fragmentShader=t})}var ce=Object.keys(j);function J(e,t,n){e.colorSpace=n?u:``,(t.repeat||t.triplanar)&&(e.wrapS=e.wrapT=i,t.repeat&&!t.triplanar&&e.repeat.set(t.repeat[0],t.repeat[1])),e.anisotropy=Math.max(e.anisotropy,4)}function Y(e,t,n,r){let i=e;i[t]=n,t===`map`&&!r.color&&e.color?.set(16777215),t===`emissiveMap`&&!r.emissive&&e.emissive?.set(16777215),t===`alphaMap`&&(e.transparent=r.transparent??!0),e.needsUpdate=!0}function le(e,t,n){for(let r of ce){let a=t[r];if(!a||!(r in e))continue;let o=j[r];if(typeof a==`object`){try{let n=ae(a,o);J(n,t,o===`color`),n.wrapS=n.wrapT=i,Y(e,r,n,t)}catch(e){n.issue(`unknown-catalog-id`,e.message,`material.${String(r)}`)}continue}let s=n.resolveAsset(a);n.track(A(s).then(n=>{J(n,t,o===`color`),Y(e,r,n,t)}).catch(e=>n.issue(`asset-load`,e.message,a)))}}function X(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}async function Z(n,i,o={}){let u=B(n),d=u.type??`standard`,f=u.color??(n?.preset?void 0:o.defaultColor);if(d===`shader`){let e=await i.shaders().catch(()=>({})),t=u.shader??`plasma`,n=e[t];if(n){let e={...u.uniforms??{}};u.color&&e.color===void 0&&(e.color=u.color),u.gradient&&e.colors===void 0&&(e.colors=u.gradient),u.opacity!==void 0&&e.opacity===void 0&&(e.opacity=u.opacity);let t=n.create(e,i);if(t.update){let e=t.update.bind(t);i.onUpdate(t=>e(t))}return u.side&&(t.material.side=W[u.side]),t.material}i.issue(`unknown-catalog-id`,`Unknown shader "${t}"`,`material.shader`)}let p={};f&&(p.color=x(f)),u.opacity!==void 0&&(p.opacity=u.opacity),(u.transparent!==void 0||u.opacity!==void 0&&u.opacity<1)&&(p.transparent=u.transparent??!0),u.wireframe&&(p.wireframe=!0),u.side&&(p.side=W[u.side]),o.vertexColors&&(p.vertexColors=!0);let m={...p};u.emissive&&(m.emissive=x(u.emissive)),u.emissiveIntensity!==void 0&&(m.emissiveIntensity=u.emissiveIntensity),u.flatShading&&(m.flatShading=!0),u.bumpScale!==void 0&&(m.bumpScale=u.bumpScale),u.normalScale!==void 0&&(m.normalScale=new r(u.normalScale,u.normalScale)),u.aoMapIntensity!==void 0&&(m.aoMapIntensity=u.aoMapIntensity),u.displacementScale!==void 0&&(m.displacementScale=u.displacementScale);let h={...m};u.metalness!==void 0&&(h.metalness=u.metalness),h.roughness=b(u.roughness,.5),u.envMapIntensity!==void 0&&(h.envMapIntensity=u.envMapIntensity);let g;switch(d){case`physical`:{let e={...h};if(u.transmission!==void 0&&(e.transmission=u.transmission),u.thickness!==void 0&&(e.thickness=u.thickness),u.ior!==void 0&&(e.ior=u.ior),u.clearcoat!==void 0&&(e.clearcoat=u.clearcoat,e.clearcoatRoughness=b(u.clearcoatRoughness,.1)),u.iridescence!==void 0){e.iridescence=u.iridescence,e.iridescenceIOR=b(u.iridescenceIOR,1.6);let[t,n]=u.iridescenceThicknessRange??[180,600];e.iridescenceThicknessMinimum=t,e.iridescenceThicknessMaximum=n}u.sheen!==void 0&&(e.sheen=u.sheen,e.sheenRoughness=b(u.sheenRoughness,.6),e.sheenColor=u.sheenColor?x(u.sheenColor):x(f??`#ffffff`).lerp(new c(1,1,1),.5)),u.anisotropy!==void 0&&(e.anisotropy=u.anisotropy,e.anisotropyRotation=b(u.anisotropyRotation,0)*S),u.attenuationColor!==void 0&&(e.attenuationColor=x(u.attenuationColor)),u.attenuationDistance!==void 0&&(e.attenuationDistance=u.attenuationDistance),u.specularIntensity!==void 0&&(e.specularIntensity=u.specularIntensity),u.specularColor!==void 0&&(e.specularColor=x(u.specularColor)),u.dispersion!==void 0&&(e.dispersion=u.dispersion),g=new s(e),u.transmission&&!$(u)&&fe(g);break}case`basic`:g=new l(p);break;case`lambert`:g=new a(m);break;case`toon`:g=C({...h,roughness:b(u.roughness,.75)});break;case`normal`:g=new _(X({flatShading:!!u.flatShading,wireframe:!!u.wireframe,side:p.side,transparent:p.transparent,opacity:u.opacity??1}));break;case`matcap`:g=new e(X({...p,flatShading:!!u.flatShading,matcap:U()??void 0}));break;case`gradient`:g=new t({...h,color:x(u.color??`#ffffff`)}),K(g,ee(u.gradient,[`#3a86ff`,`#ff006e`]),!!u.gradientEmissive);break;default:g=new t(h)}return u.envMapIntensity!==void 0&&g instanceof t&&u.envMapIntensity!==1&&(Q(g).value=u.envMapIntensity),g instanceof s&&$(u)&&pe(g,u),u.triplanar&&g instanceof t&&se(g,typeof u.triplanar==`number`?u.triplanar:1,u.repeat),le(g,u,i),g}async function ue(e,t,n){let r=await Z(t,n);e.traverse(e=>{let t=e;t.isMesh&&(t.material=r,q(r,t.geometry))})}function Q(e){let t=e.userData.envScale;if(t)return t;let n={value:1};return e.userData.envScale=n,V(e,`env-scale`,e=>{e.uniforms.uA3dEnvScale=n,e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
62
- uniform float uA3dEnvScale;`).replace(`#include <lights_fragment_maps>`,`#include <lights_fragment_maps>
63
- #if defined( RE_IndirectSpecular ) && defined( RE_IndirectDiffuse )
64
- radiance *= uA3dEnvScale;
65
- clearcoatRadiance *= uA3dEnvScale;
66
- iblIrradiance *= uA3dEnvScale;
67
- #endif`)}),n}var de=`vec3 a3dSoftClip(vec3 c) { vec3 e = max(c - 1.0, 0.0); return min(c, 1.0) + e / (1.0 + e); }`;function fe(e){V(e,`transmission-clamp`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${de}`).replace(`#include <transmission_fragment>`,m.transmission_fragment.replace(`material.transmissionAlpha = mix(`,`transmitted.rgb = a3dSoftClip( transmitted.rgb );
68
- material.transmissionAlpha = mix(`))})}function $(e){return(e.transmission??0)>=.5&&(e.ior??1.5)>=1.7&&(e.roughness??.5)<=.15}function pe(e,t){let n={uA3dGemIor:{value:t.ior??2},uA3dGemDisp:{value:Math.min(.12,(t.dispersion??0)*.012)},uA3dGemTint:{value:t.attenuationColor?x(t.attenuationColor):new c(1,1,1)},uA3dGemEnv:Q(e),uA3dGemAmount:{value:Math.min(.85,.45+Math.max(0,(t.ior??2)-1.5)*.45)}};e.userData.gemSparkle=n,V(e,`gem-sparkle`,e=>{Object.assign(e.uniforms,n),e.vertexShader=e.vertexShader.replace(`#include <common>`,`#include <common>
69
- varying vec3 vA3dJ0; varying vec3 vA3dJ1; varying vec3 vA3dJ2;
70
- vec3 a3dGemHash(vec3 p) { p = fract(p * vec3(0.1031, 0.1030, 0.0973)); p += dot(p, p.yxz + 33.33); return fract((p.xxy + p.yxx) * p.zyx); }`).replace(`#include <beginnormal_vertex>`,`#include <beginnormal_vertex>
71
- vec3 a3dOn = floor(objectNormal * 64.0 + 0.5);
72
- vA3dJ0 = normalMatrix * (a3dGemHash(a3dOn + 1.7) - 0.5);
73
- vA3dJ1 = normalMatrix * (a3dGemHash(a3dOn + 9.3) - 0.5);
74
- vA3dJ2 = normalMatrix * (a3dGemHash(a3dOn + 23.1) - 0.5);`),e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
75
- varying vec3 vA3dJ0; varying vec3 vA3dJ1; varying vec3 vA3dJ2;
76
- uniform float uA3dGemIor; uniform float uA3dGemDisp; uniform vec3 uA3dGemTint; uniform float uA3dGemEnv; uniform float uA3dGemAmount;`).replace(`#include <opaque_fragment>`,`#if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_PMREM )
77
- {
78
- vec3 gV = normalize(geometryViewDir);
79
- vec3 gN = normalize(normal);
80
- vec3 sp = vec3(0.0);
81
- vec3 iors = vec3(uA3dGemIor - uA3dGemDisp, uA3dGemIor, uA3dGemIor + uA3dGemDisp);
82
- for (int k = 0; k < 3; k++) {
83
- vec3 J = k == 0 ? vA3dJ0 : (k == 1 ? vA3dJ1 : vA3dJ2);
84
- vec3 fn = normalize(-gN + J * 1.6);
85
- for (int c = 0; c < 3; c++) {
86
- vec3 rd = refract(-gV, gN, 1.0 / iors[c]);
87
- vec3 d = normalize(reflect(rd, fn));
88
- // A second inner bounce off the next fake facet: the exit ray swings a
89
- // lot with the view angle, so faces break into light / dark areas.
90
- vec3 J2 = k == 0 ? vA3dJ1 : (k == 1 ? vA3dJ2 : vA3dJ0);
91
- d = normalize(reflect(d, normalize(d * -0.5 + J2 * 2.0 + gN * 0.3)));
92
- sp[c] += getIBLRadiance(d, d, 0.0)[c];
93
- }
94
- }
95
- sp *= uA3dGemEnv / 3.0;
96
- // Contrast: facets catching bright light flash, the others go dark.
97
- // Relative to the environment's average brightness (its irradiance), so it
98
- // works on a uniformly light softbox as well as on a dark studio.
99
- vec3 avgEnv = (getIBLIrradiance(gN) + getIBLIrradiance(-gN)) / (2.0 * PI) * uA3dGemEnv / max(envMapIntensity, 1e-3);
100
- float la = max(dot(avgEnv, vec3(0.2126, 0.7152, 0.0722)), 1e-3);
101
- float l = dot(sp, vec3(0.2126, 0.7152, 0.0722));
102
- sp *= smoothstep(0.7 * la, 1.6 * la, l) * 1.6;
103
- float F = pow(1.0 - saturate(dot(gN, gV)), 5.0);
104
- outgoingLight = mix(outgoingLight, sp * uA3dGemTint + outgoingLight * 0.25, uA3dGemAmount * (1.0 - F));
105
- }
106
- #endif
107
- #include <opaque_fragment>`)})}export{ue as a,O as c,q as i,D as l,Z as n,B as o,Q as r,T as s,V as t,A as u};
@@ -1 +0,0 @@
1
- import{F as e,H as t,Mn as n,N as r,b as i,en as a,m as o,on as s,p as c,u as l,yt as u}from"./three.module-DnaBiDAJ.js";import{l as d,n as f,o as p}from"./materials-w3EW0g-7.js";import{c as m}from"./util-CyaW1fcW.js";import{i as h,n as g,r as _,t as v}from"./extrude-D6WnITQq.js";var y=e=>!!e&&e!==`none`&&e!==`transparent`;function b(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 a=new i(e[0].color),o=new i(e[e.length-1].color);return`#${a.lerp(o,.5).getHexString()}`}try{let t=new i;return t.setStyle(e,a),`#${t.getHexString(a)}`}catch{return n}}function x(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 S(e,t,n={}){let r=[],i=Math.max(1,Math.round(m(n.curveSegments,12))),a=x(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(y(e.fill)){let t=s.toShapes().map(e=>_(e,a));t.length&&r.push({kind:`fill`,color:b(e.fill,s,o),opacity:m(e.fillOpacity,1)*c,shapes:t})}if(n.strokes!==!1&&y(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]:C(l);r.push({kind:`stroke`,color:b(e.stroke,s,o),opacity:m(e.strokeOpacity,1)*c,stroke:t})}}}return r}function C(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 o;return i.setAttribute(`position`,new c(n,3)),i}function w(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 T(e,t,n,i,a){if(e.kind===`stroke`)return e.stroke?v(e.stroke,t):null;if(!e.shapes?.length)return null;if(t<=0)return new s(e.shapes,i);let o=Math.min(n,t*.45),c=new r(e.shapes,{depth:Math.max(t-o*2,t*.05),curveSegments:i,bevelEnabled:o>0,bevelThickness:o,bevelSize:o*.6,bevelOffset:0,bevelSegments:3});return c.translate(0,0,o),c.clearGroups(),h(c,50*Math.PI/180,a)}async function E(n,r){let[{SVGLoader:i},a]=await Promise.all([import(`./SVGLoader-CV0U1EIF.js`),import(`./BufferGeometryUtils-XmME4f7Z.js`).then(e=>e.t)]),o=n.src.trim().startsWith(`<`)?n.src:await d(r.resolveAsset(n.src)),s=new i().parse(o),c=n.material?p(n.material):void 0,l=typeof c?.color==`string`?c.color:void 0,h=Math.max(1,Math.round(m(n.curveSegments,12))),g=S(s,i,{strokes:n.strokes,curveSegments:h,currentColor:l}),_=new t,v=w(g,h);if(!g.length||v.isEmpty())return _;let y=m(n.size,2),b=Math.max(v.max.x-v.min.x,1e-6),x=Math.max(v.max.y-v.min.y,1e-6),C=n.fit??`width`,E=y/(C===`height`?x:C===`max`?Math.max(b,x):b),D=Math.max(0,m(n.depth,.2)),O=D/E,k=m(n.bevel,0)/E,A=m(n.layerGap,D>0?D*.02:y*.002),j=n.keepColors??!n.material,M=/* @__PURE__ */ new Map,N=async(e,t)=>{let i=j?`${e}|${t}`:`|${t}`,a=M.get(i);if(!a){let o=j?{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 f(o,r,{defaultColor:e}),t<1&&(a.transparent=!0),D<=0&&(a.side=2),M.set(i,a)}return a},P=[];for(let e of g){let t=T(e,O,k,h,a);if(!t)continue;t.getAttribute(`normal`)||t.computeVertexNormals();let n=j?`${e.color}|${e.opacity}`:`|${e.opacity}`,r=P[P.length-1];r&&r.key===n?r.geos.push(t):P.push({key:n,color:e.color,opacity:e.opacity,geos:[t]})}let F=new t;for(let[t,n]of P.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 N(n.color,n.opacity));i.position.z=t*A/E,F.add(i)}let I=(v.min.x+v.max.x)/2,L=(v.min.y+v.max.y)/2;return F.scale.set(E,-E,E),F.position.set(-I*E,L*E,-(D+Math.max(0,P.length-1)*A)/2),_.add(F),_}export{E as buildSvg};