@fleox/agent3d 0.2.3 → 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.
- package/README.md +20 -13
- package/changelog.json +26 -0
- package/dist/agent/agent3d.mjs +228 -53
- package/dist/agent/chunks/{assets-BUUM9TUB.mjs → assets-YBkgdfgy.mjs} +27 -8
- package/dist/agent/chunks/{browser-Br1tURgt.mjs → browser-Dil7VM5m.mjs} +1 -1
- package/dist/agent/chunks/{cdp-Bdtm4fBN.mjs → cdp-DLEis_Z3.mjs} +1 -1
- package/dist/agent/chunks/{check-CfZcfaPs.mjs → check-DP9fRYbK.mjs} +64 -4
- package/dist/agent/chunks/depth-BZT4gseQ.mjs +483 -0
- package/dist/agent/chunks/depth-CD_ql3QJ.mjs +190 -0
- package/dist/agent/chunks/{export-BHugc2H7.mjs → export-bJwh2SqG.mjs} +12 -6
- package/dist/agent/chunks/{imageCodec-QM0EXQDJ.mjs → imageCodec-DeGfmBp3.mjs} +3 -3
- package/dist/agent/chunks/{objects-DBAws7uf.mjs → objects-DuytRxiC.mjs} +3 -3
- package/dist/agent/chunks/{optimizeSizing-CkZ3fZRp.mjs → optimizeSizing-B-BBiUkD.mjs} +51 -3
- package/dist/agent/chunks/{package-fw4h5vsh.mjs → package-fMbw9UGh.mjs} +2 -1
- package/dist/agent/chunks/{render-EHb40avl.mjs → render-B05DU4Q5.mjs} +4 -4
- package/dist/agent/chunks/{scene-BgajNvBf.mjs → scene-DWgXH6As.mjs} +2 -2
- package/dist/agent/chunks/{server-CACCerkZ.mjs → server-Dt_YFvN7.mjs} +6 -2
- package/dist/agent/chunks/{tools-DKxgjQSJ.mjs → tools-Cm4BqDkO.mjs} +60 -6
- package/dist/agent/chunks/{tree-BrNYGui2.mjs → tree-CqSj-o8T.mjs} +1 -0
- package/dist/agent/ort/LICENSE.txt +9 -0
- package/dist/agent/ort/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/agent/ort/ort.wasm.bundle.min.mjs +9 -0
- package/dist/runtime/agent3d-runtime.js +6 -6
- package/dist/runtime/agent3d-runtime.single.js +311 -62
- package/dist/runtime/chunks/assets-qnxDnVkj.js +1 -0
- package/dist/runtime/chunks/materials-dC4vDNHh.js +107 -0
- package/dist/runtime/chunks/{model-DbfZaLni.js → model-BCAl_NRl.js} +1 -1
- package/dist/runtime/chunks/photo-DNf14X7B.js +250 -0
- package/dist/runtime/chunks/svg-CLUxY6Zy.js +1 -0
- package/dist/runtime/chunks/{text-BaON-ISS.js → text-rSo_2Luk.js} +2 -2
- package/dist/studio/assets/assets-BW5lQkYR.js +1 -0
- package/dist/studio/assets/{camera-Be6lnp3k.js → camera-BgzPVnn-.js} +1 -1
- package/dist/studio/assets/{editor-Mpnz-b2E.js → editor-NkBUKsDB.js} +1 -1
- package/dist/studio/assets/{game-WMgRSJUD.js → game-DARpu0ah.js} +3 -3
- package/dist/studio/assets/{generators-DozXE7ta.js → generators-BjIs-kHx.js} +1 -1
- package/dist/studio/assets/index-L-N-e2KM.js +479 -0
- package/dist/studio/assets/{model-C2bZTK7-.js → model-CqI8j03Z.js} +1 -1
- package/dist/studio/assets/params-DhsDKSDs.js +1 -0
- package/dist/studio/assets/photo-DAHd1yNF.js +250 -0
- package/dist/studio/assets/{physicsHost-CTRsIvfu.js → physicsHost-tEUto2-_.js} +1 -1
- package/dist/studio/assets/{postfx-DQtp0JIy.js → postfx-BGu30OJK.js} +1 -1
- package/dist/studio/assets/runtime-C_qkIpAK.js +572 -0
- package/dist/studio/assets/{shaders-BOb6Uter.js → shaders-Dt6FGXH_.js} +12 -12
- package/dist/studio/assets/svg-ZZt5MdNf.js +2 -0
- package/dist/studio/assets/{text-CGIZs8HE.js → text-B-HM422i.js} +2 -2
- package/dist/studio/index.html +1 -1
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/agent3d-assets/SKILL.md +40 -25
- package/plugin/skills/agent3d-create/SKILL.md +57 -21
- package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
- package/plugin/skills/agent3d-create/references/recipes.md +71 -6
- package/plugin/skills/agent3d-edit/SKILL.md +22 -22
- package/plugin/skills/agent3d-edit/references/patch-ops.md +11 -3
- package/plugin/skills/agent3d-game/SKILL.md +7 -7
- package/plugin/skills/agent3d-publish/SKILL.md +23 -21
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
- package/templates/hero-photo-3d/README.md +28 -0
- package/templates/hero-photo-3d/agent3d.json +8 -0
- package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
- package/templates/hero-photo-3d/assets/manifest.json +25 -0
- package/templates/hero-photo-3d/assets/textures/street.webp +0 -0
- package/templates/hero-photo-3d/preview.png +0 -0
- package/templates/hero-photo-3d/scene.json +120 -0
- package/templates/hero-photo-3d/template.json +8 -0
- package/dist/runtime/chunks/materials-w3EW0g-7.js +0 -107
- package/dist/runtime/chunks/svg-CfPIQnDG.js +0 -1
- package/dist/studio/assets/index-tSGZFEt5.js +0 -479
- package/dist/studio/assets/runtime-NGp1VdnH.js +0 -572
- package/dist/studio/assets/svg-CnUMpv_N.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e.endsWith(`/`)?e:e+`/`}function t(t){let n=e(t.assetBase??`./`),r=e(t.libraryBase??n+`assets/library/`),i=t.assetUrls??{};return e=>{if(i[e])return i[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`),i[`library:`+t]?i[`library:`+t]:r+t}return n+e.replace(/^\.\//,``)}}var n=/* @__PURE__ */ new Map;function r(e){let t=n.get(e);return t||(t=fetch(e).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return t.text()}),t.catch(()=>n.delete(e)),n.set(e,t)),t}async function i(e){return JSON.parse(await r(e))}var a=/* @__PURE__ */ new Map;function o(e){let t=a.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(()=>a.delete(e)),a.set(e,t)),t.then(e=>{let t=e.clone();return t.needsUpdate=!0,t})}export{o as i,i as n,r,t};
|
|
@@ -0,0 +1,107 @@
|
|
|
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{i as b}from"./assets-qnxDnVkj.js";import{c as x,d as S,i as ee,t as C}from"./util-CyaW1fcW.js";import{n as w}from"./params-BCNrVCYZ.js";import{t as T}from"./random-eeej60NW.js";import{t as E}from"./toon-BsvVk_nK.js";var D={map:`color`,emissiveMap:`color`,normalMap:`normal`,roughnessMap:`data`,metalnessMap:`data`,aoMap:`data`,bumpMap:`data`,displacementMap:`data`,alphaMap:`data`},O=class{perm=/* @__PURE__ */ new Uint16Array(512);grads=/* @__PURE__ */ new Float32Array(512);constructor(e){let t=T(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}},k=(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},A=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e||1e-6)));return r*r*(3-2*r)},j=e=>e-Math.floor(e);function M(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+(k(h,g,i)-.5)*r,v=m+.5+(k(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 N={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=j(e*Math.round(r*n)+s*1.8),l=A(0,.7,c)*(1-A(.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=M(e,o,r,1,n);if(k(s.cx,s.cy,n+5)>i)return{m:0,idx:-1};let c=.18+k(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-A(c-.03,c+.01,l),idx:1+Math.floor(k(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=M(e,t,r,i,n);return A(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 k(Math.floor(e*r),Math.floor(t*r),n)},normal(e,t,a){let o=M(e,t,r,1,n),s=k(o.cx,o.cy,n+1)*Math.PI*2,c=Math.sqrt(k(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=j(e*i),r=j(t*i),s=Math.min(n,1-n,r,1-r);return 1-A(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(j(e*r+t*i)-.5)*2;return A(.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=j(e*t)-.5,a=j(r*t)-.5;return 1-A(n-.02,n+.01,Math.hypot(i,a))}}}};Object.keys(N);var P=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)))},F=/* @__PURE__ */ new Map;function I(e){return 2**Math.round(Math.log2(Math.max(32,Math.min(2048,e))))}function L(e,t){let n=t+`:`+JSON.stringify(e),r=F.get(n);if(r)return r;let i=y.find(t=>t.id===e.procedural),a=N[e.procedural];if(!i||!a)throw Error(`Unknown procedural texture "${e.procedural}"`);let o=w(i,e),s=o.int(`seed`),c=I(o.int(`resolution`)),l=a(o,new O(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]=P(a),u[i*4+1]=P(o),u[i*4+2]=P(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 F.size>64&&F.clear(),F.set(n,f),f}function R(e,t){let r=L(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 z(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 B(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 V=null;function H(){if(V)return V;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),V=new d(e),V.colorSpace=u,V}var U={front:0,back:1,double:2},W=8;function G(e,t,n=!1){let r=t.slice(0,W).map(e=>S(e));for(;r.length<W;)r.push(r[r.length-1].clone());let i={uGradColors:{value:r},uGradCount:{value:Math.min(Math.max(t.length,1),W)},uGradMin:{value:-.5},uGradMax:{value:.5}};return B(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[${W}];\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 K(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 q=`
|
|
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 te(e,t,n){let i={value:new r(t*(n?.[0]??1),t*(n?.[1]??n?.[0]??1))};B(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
|
+
`+q+`
|
|
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 ne=Object.keys(D);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 re(e,t,n){for(let r of ne){let a=t[r];if(!a||!(r in e))continue;let o=D[r];if(typeof a==`object`){try{let n=R(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(b(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=z(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=U[u.side]),t.material}i.issue(`unknown-catalog-id`,`Unknown shader "${t}"`,`material.shader`)}let p={};f&&(p.color=S(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=U[u.side]),o.vertexColors&&(p.vertexColors=!0);let m={...p};u.emissive&&(m.emissive=S(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=x(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=x(u.clearcoatRoughness,.1)),u.iridescence!==void 0){e.iridescence=u.iridescence,e.iridescenceIOR=x(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=x(u.sheenRoughness,.6),e.sheenColor=u.sheenColor?S(u.sheenColor):S(f??`#ffffff`).lerp(new c(1,1,1),.5)),u.anisotropy!==void 0&&(e.anisotropy=u.anisotropy,e.anisotropyRotation=x(u.anisotropyRotation,0)*C),u.attenuationColor!==void 0&&(e.attenuationColor=S(u.attenuationColor)),u.attenuationDistance!==void 0&&(e.attenuationDistance=u.attenuationDistance),u.specularIntensity!==void 0&&(e.specularIntensity=u.specularIntensity),u.specularColor!==void 0&&(e.specularColor=S(u.specularColor)),u.dispersion!==void 0&&(e.dispersion=u.dispersion),g=new s(e),u.transmission&&!$(u)&&oe(g);break}case`basic`:g=new l(p);break;case`lambert`:g=new a(m);break;case`toon`:g=E({...h,roughness:x(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:H()??void 0}));break;case`gradient`:g=new t({...h,color:S(u.color??`#ffffff`)}),G(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)&&se(g,u),u.triplanar&&g instanceof t&&te(g,typeof u.triplanar==`number`?u.triplanar:1,u.repeat),re(g,u,i),g}async function ie(e,t,n){let r=await Z(t,n);e.traverse(e=>{let t=e;t.isMesh&&(t.material=r,K(r,t.geometry))})}function Q(e){let t=e.userData.envScale;if(t)return t;let n={value:1};return e.userData.envScale=n,B(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 ae=`vec3 a3dSoftClip(vec3 c) { vec3 e = max(c - 1.0, 0.0); return min(c, 1.0) + e / (1.0 + e); }`;function oe(e){B(e,`transmission-clamp`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>\n${ae}`).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 se(e,t){let n={uA3dGemIor:{value:t.ior??2},uA3dGemDisp:{value:Math.min(.12,(t.dispersion??0)*.012)},uA3dGemTint:{value:t.attenuationColor?S(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,B(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{ie as a,K as i,Z as n,z as o,Q as r,B as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,Nn as t,c as n,d as r,ft as i,pt as a}from"./three.module-DnaBiDAJ.js";import{c as o}from"./util-CyaW1fcW.js";import{a as s}from"./materials-
|
|
1
|
+
import{H as e,Nn as t,c as n,d as r,ft as i,pt as a}from"./three.module-DnaBiDAJ.js";import{c as o}from"./util-CyaW1fcW.js";import{a as s}from"./materials-dC4vDNHh.js";var c=/* @__PURE__ */ new Map;function l(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 u(e){let t=c.get(e);return t||(t=(async()=>{let[{GLTFLoader:t},n]=await Promise.all([import(`./GLTFLoader-Z9Inv-Xm.js`),fetch(e)]);if(!n.ok)throw Error(`HTTP ${n.status} for ${e}`);let r=await n.arrayBuffer(),i=l(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 import(`./meshopt_decoder.module-DXTYc6wn.js`);await e.ready,a.setMeshoptDecoder(e)}let o=e.slice(0,e.lastIndexOf(`/`)+1);return a.parseAsync(r,/^data:/.test(e)?``:o)})(),t.catch(()=>c.delete(e)),c.set(e,t)),t}function d(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 f(c,l){let f=await u(l.resolveAsset(c.src)),{clone:p}=await import(`./SkeletonUtils-DHlReJx3.js`),m=p(f.scene),h=new e;h.add(m),m.updateMatrixWorld(!0);let g=new r().setFromObject(m);if(!g.isEmpty()){let e=g.getSize(new t),n=Math.max(e.x,e.y,e.z),r=c.fit&&n>0?c.fit/n:1;if(m.scale.multiplyScalar(r),c.center!==!1){let e=g.getCenter(new t);m.position.set(-e.x*r,-g.min.y*r,-e.z*r)}}m.traverse(e=>{let t=e;t.isMesh&&(t.castShadow=c.castShadow??!0,t.receiveShadow=c.receiveShadow??!1)}),c.material&&await s(m,c.material,l),c.morph&&d(m,c.morph);let _;if(f.animations.length){let e=new n(m),t=null,r=e=>typeof e==`number`||/^\d+$/.test(String(e))?f.animations[Number(e)]:f.animations.find(t=>t.name===e)??f.animations.find(t=>t.name.toLowerCase().includes(String(e).toLowerCase())),s=/* @__PURE__ */ new Set,u=e=>{let t=r(e);return!t&&!s.has(String(e))&&(s.add(String(e)),l.issue(`asset-load`,`Model ${c.id} has no animation clip "${e}" (clips: ${f.animations.map(e=>e.name).join(`, `)})`,`objects#${c.id}.animation.clip`)),t},d=(n,r={})=>{let s=u(n);if(!s)return;let c=e.clipAction(s);c.setLoop(r.loop===!1?i:a,1/0),c.clampWhenFinished=r.loop===!1,c.timeScale=o(r.speed,1),c.enabled=!0,t&&t!==c?(c.reset().setEffectiveWeight(1).play(),t.crossFadeTo(c,o(r.crossfade,.3),!1)):c.setEffectiveWeight(1).play(),t=c},p=t=>{let n=u(t);if(!n)return null;let r=e.clipAction(n);return r.isRunning()||(r.enabled=!0,r.setLoop(a,1/0),r.play()),r},h={weight(e,t){p(e)?.setEffectiveWeight(Math.max(0,t))},speed(e,t){let n=p(e);n&&(n.timeScale=t)},time(e,t){let n=p(e);n&&(n.paused=!0,n.time=Math.max(0,t))}},g=c.animation??{},v=()=>{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??{}))h.weight(e,t);e.update(0)};_={mixer:e,clips:f.animations,play:d,control:h,reset:v},v()}return{object:h,animator:_}}export{f as buildModel};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import{Dt as e,H as t,Mn as n,Nn as r,Rt as i,b as a,bt as o,d as s,dn as c,en as l,m as u,ot as d,p as f,rn as p,yt as m}from"./three.module-DnaBiDAJ.js";import{i as h}from"./assets-qnxDnVkj.js";import{c as g,r as _,t as v}from"./util-CyaW1fcW.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=_(g(e?.pointer,1),0,1);return{pointer:t,scroll:_(g(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,g(e?.speed,y.speed)),smoothing:_(g(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(_(g(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(_(g(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
|
+
uniform sampler2D uMap;
|
|
3
|
+
uniform vec3 uTint;
|
|
4
|
+
uniform float uOpacity;
|
|
5
|
+
uniform float uIntensity;
|
|
6
|
+
vec4 shade(vec4 c, float a) {
|
|
7
|
+
return vec4(c.rgb * uTint * uIntensity, c.a * a * uOpacity);
|
|
8
|
+
}
|
|
9
|
+
`,E=`
|
|
10
|
+
varying vec2 vUv;
|
|
11
|
+
void main() {
|
|
12
|
+
vUv = uv;
|
|
13
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
14
|
+
}
|
|
15
|
+
`,D=`
|
|
16
|
+
${T}
|
|
17
|
+
uniform sampler2D uDepth;
|
|
18
|
+
uniform vec2 uView;
|
|
19
|
+
uniform float uZoom;
|
|
20
|
+
uniform vec2 uMaxOffset;
|
|
21
|
+
uniform vec2 uInset;
|
|
22
|
+
uniform float uFocus;
|
|
23
|
+
uniform float uWallSlope;
|
|
24
|
+
varying vec2 vUv;
|
|
25
|
+
const int STEPS = __STEPS__;
|
|
26
|
+
void main() {
|
|
27
|
+
// the zoom drift also pushes in slightly (stays inside the inset margin)
|
|
28
|
+
vec2 base = 0.5 + (vUv - 0.5) * uInset * (1.0 - 0.06 * uZoom);
|
|
29
|
+
vec2 v = uView - (vUv - 0.5) * 2.0 * uZoom;
|
|
30
|
+
vec2 dir = v * uMaxOffset;
|
|
31
|
+
vec2 uv = base;
|
|
32
|
+
if (dot(dir, dir) > 1e-10) {
|
|
33
|
+
float stepH = 1.0 / float(STEPS);
|
|
34
|
+
float h = 1.0;
|
|
35
|
+
float prevH = 1.0 + stepH;
|
|
36
|
+
bool hit = false;
|
|
37
|
+
for (int i = 0; i <= STEPS; i++) {
|
|
38
|
+
h = 1.0 - float(i) * stepH;
|
|
39
|
+
float d = textureLod(uDepth, base + (h - uFocus) * dir, 0.0).r;
|
|
40
|
+
if (d >= h) { hit = true; break; }
|
|
41
|
+
prevH = h;
|
|
42
|
+
}
|
|
43
|
+
float lo = h, hi = min(prevH, 1.0);
|
|
44
|
+
if (hit) {
|
|
45
|
+
for (int j = 0; j < 6; j++) {
|
|
46
|
+
float mid = 0.5 * (lo + hi);
|
|
47
|
+
float d = textureLod(uDepth, base + (mid - uFocus) * dir, 0.0).r;
|
|
48
|
+
if (d >= mid) lo = mid; else hi = mid;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
uv = base + (lo - uFocus) * dir;
|
|
52
|
+
// Disocclusion: the ray hit the steep "wall" of a depth edge. Stretching
|
|
53
|
+
// the foreground edge colour reads as a smear: take the colour from just
|
|
54
|
+
// past the edge on the far side instead (the background continues).
|
|
55
|
+
vec2 texel = 1.0 / vec2(textureSize(uDepth, 0));
|
|
56
|
+
vec4 dh = textureLod(uDepth, uv, 0.0);
|
|
57
|
+
vec2 grad = vec2(
|
|
58
|
+
textureLod(uDepth, uv + vec2(texel.x * 1.5, 0.0), 0.0).r - textureLod(uDepth, uv - vec2(texel.x * 1.5, 0.0), 0.0).r,
|
|
59
|
+
textureLod(uDepth, uv + vec2(0.0, texel.y * 1.5), 0.0).r - textureLod(uDepth, uv - vec2(0.0, texel.y * 1.5), 0.0).r) / 3.0;
|
|
60
|
+
float g = length(grad);
|
|
61
|
+
vec2 toNear = grad / max(g, 1e-6);
|
|
62
|
+
float dNear = textureLod(uDepth, uv + toNear * texel * 3.0, 0.0).r;
|
|
63
|
+
if (hit && (g > uWallSlope || dh.a < 0.5) && dNear > lo + 0.04) {
|
|
64
|
+
vec2 away = -toNear;
|
|
65
|
+
vec2 probe = uv;
|
|
66
|
+
for (int k = 1; k <= 6; k++) {
|
|
67
|
+
vec2 q = uv + away * texel * float(k * 2);
|
|
68
|
+
probe = q;
|
|
69
|
+
if (textureLod(uDepth, q, 0.0).r < lo - 0.05) break;
|
|
70
|
+
}
|
|
71
|
+
uv = probe + away * texel * 2.0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
vec4 c = textureGrad(uMap, uv, dFdx(base), dFdy(base));
|
|
75
|
+
if (c.a * uOpacity < 0.004) discard;
|
|
76
|
+
gl_FragColor = shade(c, 1.0);
|
|
77
|
+
#include <tonemapping_fragment>
|
|
78
|
+
#include <colorspace_fragment>
|
|
79
|
+
}
|
|
80
|
+
`,ae=`
|
|
81
|
+
uniform sampler2D uDepth;
|
|
82
|
+
uniform float uRange;
|
|
83
|
+
uniform float uFocus;
|
|
84
|
+
uniform float uEdgeCut;
|
|
85
|
+
uniform vec3 uCam;
|
|
86
|
+
uniform float uPerspective;
|
|
87
|
+
attribute vec4 uvOther;
|
|
88
|
+
varying vec2 vUv;
|
|
89
|
+
varying float vDepth;
|
|
90
|
+
varying float vCut;
|
|
91
|
+
varying float vMotion;
|
|
92
|
+
vec3 displaced(vec3 p, float z) {
|
|
93
|
+
if (uPerspective > 0.5 && uCam.z > z + 1e-3) p.xy = mix(p.xy, uCam.xy, z / uCam.z);
|
|
94
|
+
p.z = z;
|
|
95
|
+
return p;
|
|
96
|
+
}
|
|
97
|
+
void main() {
|
|
98
|
+
vUv = uv;
|
|
99
|
+
vec4 d0 = textureLod(uDepth, uv, 0.0);
|
|
100
|
+
vec4 d1 = textureLod(uDepth, uvOther.xy, 0.0);
|
|
101
|
+
vec4 d2 = textureLod(uDepth, uvOther.zw, 0.0);
|
|
102
|
+
float jump = max(max(abs(d0.r - d1.r), abs(d1.r - d2.r)), abs(d0.r - d2.r));
|
|
103
|
+
bool cut = min(d0.a, min(d1.a, d2.a)) < 0.5 || (uEdgeCut > 0.0 && jump > uEdgeCut);
|
|
104
|
+
vCut = cut ? 1.0 : 0.0;
|
|
105
|
+
vDepth = d0.r;
|
|
106
|
+
vec4 c = projectionMatrix * modelViewMatrix * vec4(displaced(position, (d0.r - uFocus) * uRange), 1.0);
|
|
107
|
+
vMotion = 0.0;
|
|
108
|
+
if (cut) {
|
|
109
|
+
vec4 a = projectionMatrix * modelViewMatrix * vec4(displaced(position, -uFocus * uRange), 1.0);
|
|
110
|
+
vec4 b = projectionMatrix * modelViewMatrix * vec4(displaced(position, (1.0 - uFocus) * uRange), 1.0);
|
|
111
|
+
vMotion = length(b.xy / b.w - a.xy / a.w);
|
|
112
|
+
}
|
|
113
|
+
gl_Position = c;
|
|
114
|
+
}
|
|
115
|
+
`,oe=`
|
|
116
|
+
${T}
|
|
117
|
+
uniform sampler2D uDepth;
|
|
118
|
+
varying vec2 vUv;
|
|
119
|
+
varying float vDepth;
|
|
120
|
+
varying float vCut;
|
|
121
|
+
varying float vMotion;
|
|
122
|
+
void main() {
|
|
123
|
+
if (vCut > 0.5) {
|
|
124
|
+
float d = textureLod(uDepth, vUv, 0.0).r;
|
|
125
|
+
if (abs(d - vDepth) * vMotion > 0.004) discard;
|
|
126
|
+
}
|
|
127
|
+
vec4 c = texture2D(uMap, vUv);
|
|
128
|
+
if (c.a * uOpacity < 0.004) discard;
|
|
129
|
+
gl_FragColor = shade(c, 1.0);
|
|
130
|
+
#include <tonemapping_fragment>
|
|
131
|
+
#include <colorspace_fragment>
|
|
132
|
+
}
|
|
133
|
+
`,se=`
|
|
134
|
+
uniform sampler2D uDepth;
|
|
135
|
+
uniform float uRange;
|
|
136
|
+
uniform float uFocus;
|
|
137
|
+
uniform vec3 uCam;
|
|
138
|
+
uniform float uPerspective;
|
|
139
|
+
uniform vec2 uReach;
|
|
140
|
+
varying vec2 vUv;
|
|
141
|
+
varying float vDepth;
|
|
142
|
+
void main() {
|
|
143
|
+
vUv = uv;
|
|
144
|
+
float d = textureLod(uDepth, uv, 0.0).r;
|
|
145
|
+
for (int i = 1; i <= 2; i++) {
|
|
146
|
+
vec2 r = uReach * float(i) * 0.5;
|
|
147
|
+
d = min(d, textureLod(uDepth, uv + vec2(r.x, 0.0), 0.0).r);
|
|
148
|
+
d = min(d, textureLod(uDepth, uv - vec2(r.x, 0.0), 0.0).r);
|
|
149
|
+
d = min(d, textureLod(uDepth, uv + vec2(0.0, r.y), 0.0).r);
|
|
150
|
+
d = min(d, textureLod(uDepth, uv - vec2(0.0, r.y), 0.0).r);
|
|
151
|
+
d = min(d, textureLod(uDepth, uv + r, 0.0).r);
|
|
152
|
+
d = min(d, textureLod(uDepth, uv - r, 0.0).r);
|
|
153
|
+
d = min(d, textureLod(uDepth, uv + vec2(r.x, -r.y), 0.0).r);
|
|
154
|
+
d = min(d, textureLod(uDepth, uv + vec2(-r.x, r.y), 0.0).r);
|
|
155
|
+
}
|
|
156
|
+
vDepth = d;
|
|
157
|
+
float z = (d - uFocus) * uRange - uRange * 0.02;
|
|
158
|
+
vec3 p = position;
|
|
159
|
+
if (uPerspective > 0.5 && uCam.z > z + 1e-3) p.xy = mix(p.xy, uCam.xy, z / uCam.z);
|
|
160
|
+
p.z = z;
|
|
161
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
|
|
162
|
+
}
|
|
163
|
+
`,O=`
|
|
164
|
+
${T}
|
|
165
|
+
uniform sampler2D uDepth;
|
|
166
|
+
varying vec2 vUv;
|
|
167
|
+
varying float vDepth;
|
|
168
|
+
void main() {
|
|
169
|
+
vec2 uv = vUv;
|
|
170
|
+
float d = textureLod(uDepth, uv, 0.0).r;
|
|
171
|
+
if (d > vDepth + 0.04) {
|
|
172
|
+
vec2 texel = 1.0 / vec2(textureSize(uDepth, 0));
|
|
173
|
+
vec2 grad = vec2(
|
|
174
|
+
textureLod(uDepth, uv + vec2(texel.x * 2.0, 0.0), 0.0).r - textureLod(uDepth, uv - vec2(texel.x * 2.0, 0.0), 0.0).r,
|
|
175
|
+
textureLod(uDepth, uv + vec2(0.0, texel.y * 2.0), 0.0).r - textureLod(uDepth, uv - vec2(0.0, texel.y * 2.0), 0.0).r);
|
|
176
|
+
vec2 away = length(grad) > 1e-5 ? -normalize(grad) : vec2(0.0);
|
|
177
|
+
// walk towards the background until the depth reaches this surface's
|
|
178
|
+
for (int k = 1; k <= 24; k++) {
|
|
179
|
+
uv = vUv + away * texel * float(k * 3);
|
|
180
|
+
if (textureLod(uDepth, uv, 0.0).r <= vDepth + 0.04) break;
|
|
181
|
+
}
|
|
182
|
+
uv += away * texel * 2.0;
|
|
183
|
+
}
|
|
184
|
+
vec4 c = texture2D(uMap, uv);
|
|
185
|
+
if (c.a * uOpacity < 0.004) discard;
|
|
186
|
+
gl_FragColor = shade(c, 1.0);
|
|
187
|
+
#include <tonemapping_fragment>
|
|
188
|
+
#include <colorspace_fragment>
|
|
189
|
+
}
|
|
190
|
+
`,ce=`
|
|
191
|
+
${T}
|
|
192
|
+
uniform sampler2D uDepth;
|
|
193
|
+
uniform vec2 uView;
|
|
194
|
+
uniform float uZoom;
|
|
195
|
+
uniform vec2 uMaxOffset;
|
|
196
|
+
uniform vec2 uInset;
|
|
197
|
+
uniform float uFocus;
|
|
198
|
+
uniform float uCenter;
|
|
199
|
+
uniform float uLo;
|
|
200
|
+
uniform float uHi;
|
|
201
|
+
uniform float uFeather;
|
|
202
|
+
uniform float uBackground;
|
|
203
|
+
varying vec2 vUv;
|
|
204
|
+
void main() {
|
|
205
|
+
// the zoom drift also pushes in slightly (stays inside the inset margin)
|
|
206
|
+
vec2 base = 0.5 + (vUv - 0.5) * uInset * (1.0 - 0.06 * uZoom);
|
|
207
|
+
vec2 v = uView - (vUv - 0.5) * 2.0 * uZoom;
|
|
208
|
+
// Each layer moves with the depth it shows, clamped to its band: a smooth
|
|
209
|
+
// surface crossing two bands stays continuous (no tear at the band edge);
|
|
210
|
+
// only real depth jumps separate the layers. Fixed-point solve, from the
|
|
211
|
+
// band centre.
|
|
212
|
+
vec2 dir = v * uMaxOffset;
|
|
213
|
+
vec2 uv = base + (uCenter - uFocus) * dir;
|
|
214
|
+
for (int i = 0; i < 3; i++) {
|
|
215
|
+
float di = clamp(textureLod(uDepth, uv, 0.0).r, uLo, uHi);
|
|
216
|
+
uv = base + (di - uFocus) * dir;
|
|
217
|
+
}
|
|
218
|
+
vec4 dd = textureLod(uDepth, uv, 0.0);
|
|
219
|
+
float d = dd.r;
|
|
220
|
+
// soft slice edges, but hard on marked depth edges (alpha 0): a blend of
|
|
221
|
+
// two layers there would draw a thin double outline
|
|
222
|
+
float a = uBackground > 0.5 ? 1.0 : dd.a < 0.5 ? step(uLo, d) : smoothstep(uLo - uFeather, uLo + uFeather, d);
|
|
223
|
+
if (a < 0.004) discard;
|
|
224
|
+
vec2 cuv = uv;
|
|
225
|
+
// covered by nearer content
|
|
226
|
+
if (d > uHi + uFeather) {
|
|
227
|
+
bool found = false;
|
|
228
|
+
vec2 reach = v * uMaxOffset * 1.25;
|
|
229
|
+
for (int k = 1; k <= 16; k++) {
|
|
230
|
+
vec2 q = uv + reach * (float(k) / 16.0);
|
|
231
|
+
vec4 dq = textureLod(uDepth, q, 0.0);
|
|
232
|
+
if (dq.r <= uHi && dq.a >= 0.5 && (uBackground > 0.5 || dq.r >= uLo - uFeather)) {
|
|
233
|
+
// step past the edge's blended texels
|
|
234
|
+
vec2 texel = 1.0 / vec2(textureSize(uMap, 0));
|
|
235
|
+
cuv = q + normalize(reach) * texel * 3.0;
|
|
236
|
+
found = true;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Nothing of this band to extend: let the layers below show (the
|
|
241
|
+
// background keeps the source texel).
|
|
242
|
+
if (!found && uBackground < 0.5) discard;
|
|
243
|
+
}
|
|
244
|
+
vec4 c = textureGrad(uMap, cuv, dFdx(base), dFdy(base));
|
|
245
|
+
gl_FragColor = shade(c, a);
|
|
246
|
+
if (gl_FragColor.a < 0.004) discard;
|
|
247
|
+
#include <tonemapping_fragment>
|
|
248
|
+
#include <colorspace_fragment>
|
|
249
|
+
}
|
|
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 a(1,1,1)},uOpacity:{value:_(g(r.opacity,1),0,1)},uIntensity:{value:Math.max(0,g(r.emissiveIntensity,1))}}}function A(e,t,n,r){let i=new p({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),s=new Float32Array(i*12),c=0,l=(n,r,i)=>{let l=[n,r,i];for(let n=0;n<3;n++){let[r,i]=l[n],u=l[(n+1)%3],d=l[(n+2)%3];a.set([(r-.5)*e,(i-.5)*t,0],c*3),o.set([r,i],c*2),s.set([u[0],u[1],d[0],d[1]],c*4),c++}};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;l([i,o],[a,o],[a,s]),l([i,o],[a,s],[i,s])}let d=new u;return d.setAttribute(`position`,new f(a,3)),d.setAttribute(`uv`,new f(o,2)),d.setAttribute(`uvOther`,new f(s,4)),d}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(a,u){let[f,p]=await Promise.all([h(u.resolveAsset(a.src)),a.depth?h(u.resolveAsset(a.depth)).catch(e=>(u.issue(`asset-load`,`${a.id}: depth map: ${e.message} — showing the photo flat`,`objects#${a.id}.depth`),null)):Promise.resolve(null)]);f.colorSpace=l,f.wrapS=f.wrapT=e,f.anisotropy=4,f.needsUpdate=!0,p&&(p.colorSpace=``,p.premultiplyAlpha=!1,p.wrapS=p.wrapT=e,p.generateMipmaps=!1,p.minFilter=d,p.magFilter=d,p.needsUpdate=!0);let b=le(f),{width:T,height:j}=ee(a,b.w,b.h),M=_(g(a.strength,y.strength),0,1),N=_(g(a.focus,y.focus),0,1),P=_(g(a.material?.opacity,1),0,1),F=P<1||/\.(png|webp)$/i.test(a.src),I=te(a.motion),L=p?a.mode??`parallax`:`flat`,R=new t,z=new t;R.add(z);let B=[],V=[],H=[],U=[],W=null,G=()=>{let e=new i(T,j);return V.push(e),e};if(L===`flat`){let e=a.material??{},t=new o({map:f,transparent:F,opacity:P,toneMapped:!1,fog:!1});e.color&&t.color.copy(u.color(e.color)),t.color.multiplyScalar(Math.max(0,g(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),t={...k(f,a,u),uDepth:{value:p},uView:{value:new n},uZoom:{value:0},uMaxOffset:{value:new n(...e.maxOffset)},uInset:{value:new n(...e.inset)},uFocus:{value:N},uWallSlope:{value:.02}},r=A(E,D.replace(`__STEPS__`,String(de(u.quality,M))),t,F);B.push(r),H.push(r),z.add(new m(G(),r))}else if(L===`mesh`){let[e,t]=ne(g(a.segments,y.segments),T,j),o=w(M,T),l=ue(T,j,e,t);l.boundingBox=new s(new r(-T/2,-j/2,-N*o),new r(T/2,j/2,(1-N)*o)),l.boundingSphere=l.boundingBox.getBoundingSphere(new c),V.push(l);let d={...k(f,a,u),uDepth:{value:p},uRange:{value:o},uFocus:{value:N},uEdgeCut:{value:_(g(a.edgeCut,y.edgeCut),0,1)},uCam:{value:new r(0,0,1e6)},uPerspective:{value:0}};W=d;let h=A(ae,oe,d,P<1);h.side=2,B.push(h);let v=new m(l,h);v.renderOrder=1,z.add(v);{let r=new i(T,j,Math.max(1,Math.round(e/2)),Math.max(1,Math.round(t/2)));r.boundingBox=l.boundingBox.clone(),r.boundingSphere=l.boundingSphere.clone(),V.push(r);let a=new n(6/e,6/t),o=A(se,O,{...d,uReach:{value:a}},P<1);o.side=2,B.push(o);let s=new m(r,o);s.renderOrder=0,s.raycast=()=>void 0,z.add(s)}}else{let e=C(M,T,j),t=G(),r=re(g(a.layers,y.layers),N,M,T),i=_(g(a.edgeCut,y.edgeCut),0,1);r.forEach((r,o)=>{let s=A(E,ce,{...k(f,a,u),uDepth:{value:p},uView:{value:new n},uZoom:{value:0},uMaxOffset:{value:new n(...e.maxOffset)},uInset:{value:new n(...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(s),H.push(s);let c=new m(t,s);c.position.z=r.z,c.renderOrder=o,c.userData.a3dPhotoLayer=o,z.add(c),U.push({mesh:c,band:r})})}let K=!u.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 r,Q=!1,$=M*8*v;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();f.dispose(),p?.dispose()}}}export{j as buildPhoto};
|
|
@@ -0,0 +1 @@
|
|
|
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{r as d}from"./assets-qnxDnVkj.js";import{c as f}from"./util-CyaW1fcW.js";import{i as p,n as m,r as h,t as g}from"./extrude-D6WnITQq.js";import{n as _,o as v}from"./materials-dC4vDNHh.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(f(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=f(e.opacity,1);if(y(e.fill)){let t=s.toShapes().map(e=>h(e,a));t.length&&r.push({kind:`fill`,color:b(e.fill,s,o),opacity:f(e.fillOpacity,1)*c,shapes:t})}if(n.strokes!==!1&&y(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]:C(l);r.push({kind:`stroke`,color:b(e.stroke,s,o),opacity:f(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?g(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(),p(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?v(n.material):void 0,l=typeof c?.color==`string`?c.color:void 0,p=Math.max(1,Math.round(f(n.curveSegments,12))),m=S(s,i,{strokes:n.strokes,curveSegments:p,currentColor:l}),h=new t,g=w(m,p);if(!m.length||g.isEmpty())return h;let y=f(n.size,2),b=Math.max(g.max.x-g.min.x,1e-6),x=Math.max(g.max.y-g.min.y,1e-6),C=n.fit??`width`,E=y/(C===`height`?x:C===`max`?Math.max(b,x):b),D=Math.max(0,f(n.depth,.2)),O=D/E,k=f(n.bevel,0)/E,A=f(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 _(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 m){let t=T(e,O,k,p,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=(g.min.x+g.max.x)/2,L=(g.min.y+g.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),h.add(F),h}export{E as buildSvg};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ft as e,H as t,Mn as n,N as r,an as i,bt as a,m as o,on as s,yt as c}from"./three.module-DnaBiDAJ.js";import{
|
|
2
|
-
`)){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=[],
|
|
1
|
+
import{Ft as e,H as t,Mn as n,N as r,an as i,bt as a,m as o,on as s,yt as c}from"./three.module-DnaBiDAJ.js";import{n as l}from"./assets-qnxDnVkj.js";import{t as u}from"./easing-CXSz2e6P.js";import{c as d}from"./util-CyaW1fcW.js";import{i as f,r as p}from"./extrude-D6WnITQq.js";import{n as m}from"./materials-dC4vDNHh.js";var h=/* @__PURE__ */ new Map;function g(e){let t=h.get(e);return t||(t=Promise.all([import(`./FontLoader-dVu9WH2X.js`),l(e)]).then(([e,t])=>new e.FontLoader().parse(t)),t.catch(()=>h.delete(e)),h.set(e,t)),t}var _=e=>{let t=e.normalize(`NFD`);return t.length>1?t[0]:e};function v(e,t,n){let r=e.kerning;if(!r)return 0;let i=r[t]?.[n];if(i!==void 0)return i;let a=_(t),o=_(n);return a===t&&o===n?0:r[a]?.[o]??0}function y(e,t){let n=t.em/e.resolution,r=d(t.letterSpacing,0),i=d(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?v(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(`
|
|
2
|
+
`)){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=[],f=[],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})}),f.push({width:a,y:-n*i})}),{glyphs:u,lines:f,lineHeight:i,width:p}}function b(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 x(e,t){let n=e.data,r=d(t.size,1),i=r/b(e),a=Math.max(0,d(t.depth,.2)),o=a>0?Math.max(0,Math.min(d(t.bevel,Math.min(a*.3,r*.035)),a*.45,r*.08)):0,s=Math.round(Math.max(2,Math.min(32,d(t.curveSegments,a>0?5+r*3:8+r*4)))),c=y(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 S(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 C(e,t,n){let r=n.em/(n.curveSegments*5);return e.generateShapes(t,n.em).map(e=>p(e,r,1,n.curveSegments))}function w(e,t,n,i){let a=C(e,t,n);if(!a.length)return null;if(n.depth<=0)return new s(a,n.curveSegments);let o=new r(a,S(n));return o.translate(0,0,n.backZ+n.bevel),o.clearGroups(),f(o,50*Math.PI/180,i)}function T(e,t){let n=e.outline;if(!n)return null;let r=n===!0?{}:n,i=Math.max(1e-4,d(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(d(r.depth,t.depth>0?t.depth*.6:t.size*.01),1e-4),material:r.material,color:r.color??`#111111`}}function E(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 D(e,t,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 n(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 n(l.x+Math.cos(s)*t,l.y+Math.sin(s)*t))}}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 n(l.x+e*t/s,l.y+i*t/s))}}return o}function O(t,n){let r=[];for(let a of t){let{shape:t,holes:o}=a.extractPoints(1),s=t.slice();E(s)<0&&(s=s.reverse());let c=new i(D(s,n));for(let t of o){let r=t.slice(),i=Math.abs(E(r));E(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=D(r,n),l=E(s);l<0&&-l>i*.02&&c.holes.push(new e(s))}r.push(c)}return r}function k(e,t,n,i,a){let o=C(e,t,n);if(!o.length)return null;let s=new r(O(o,i.width),{depth:i.frontZ-i.backZ,curveSegments:1,bevelEnabled:!1});return s.translate(0,0,i.backZ),s.clearGroups(),f(s,40*Math.PI/180,a)}function A(e,t,n){let r=/* @__PURE__ */ 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 j(e,t,n){let r=d(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 d(e.delay,0)+i*r}function M(e,t){return(n,r)=>{let i=e.effect??`rise`,a=Math.max(d(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(P(t))}return{update(e){let n=Math.min(Math.max(e/a,0),1),d=u(o,n),f=r.object;if(s){let e=u(`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-d)*t*.6;break;case`drop`:f.position.y+=(1-d)*t*1.2;break;case`scale`:f.scale.multiplyScalar(Math.max(1e-4,d));break;case`spin`:f.rotation.y+=(1-d)*Math.PI,f.scale.multiplyScalar(Math.max(1e-4,Math.min(1,n*2)))}}}}}var N=null;function P(e){N??=new a({colorWrite:!1,depthWrite:!0});let t=new c(e.geometry,N);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 F(e,t){let n=e.font??`sans-bold`;return t.resolveAsset(n.includes(`/`)||n.includes(`:`)?n:`library:fonts/${n}`)}function I(e,t,n){let r=e.userData.gradient;r&&(r.uGradMin.value=t,r.uGradMax.value=n)}async function L(e,n){let[r,i]=await Promise.all([g(F(e,n)),import(`./BufferGeometryUtils-XmME4f7Z.js`).then(e=>e.t)]),a=x(r,e),o=T(e,a),s=!!e.splitLetters||!!e.reveal,l=a.depth<=0,u=()=>m(e.material,n,{defaultColor:`#ffffff`}),d=()=>o?m(o.material??{color:o.color,roughness:.55},n):null,f=(a.layout.lines.length?a.layout.lines[a.layout.lines.length-1].y:0)+a.offsetY,p=a.size+a.offsetY,h=e=>(l&&(e.side=2),e);if(!s){let t=A(a,e=>w(r,e,a,i),i),n=h(await u());I(n,f,p);let s=new c(t,n);if(o){let t=A(a,e=>k(r,e,a,o,i),i),n=await d();if(n){I(n,f,p);let r=new c(t,n);r.name=`${e.id}/outline`,s.add(r)}}return{object:s,letters:[]}}let _=new t,v=/* @__PURE__ */ new Map,y=/* @__PURE__ */ new Map,b=a.size/2,S=[],C=a.layout.glyphs.length,E=0;for(let t of a.layout.glyphs){if(!v.has(t.ch)){let e=w(r,t.ch,a,i),n=0;if(e&&(e.computeBoundingBox(),n=(e.boundingBox.min.x+e.boundingBox.max.x)/2,e.translate(-n,-b,0),e.computeBoundingSphere()),v.set(t.ch,e),o){let e=k(r,t.ch,a,o,i);e?.translate(-n,-b,0),y.set(t.ch,e)}e&&(e.userData.cx=n)}let n=v.get(t.ch);if(!n)continue;let s=n.userData.cx,l=a.layout.lines[t.line].y+a.offsetY,m=h(await u());I(m,f-l-b,p-l-b);let g=new c(n,m);g.position.set(t.x+s,l+b,0);let x=`${e.id}/${E}`;g.name=x,g.userData.a3dId=x;let T=y.get(t.ch);if(T){let e=await d();if(e){I(e,f-l-b,p-l-b);let t=new c(T,e);t.name=`${x}/outline`,g.add(t)}}_.add(g);let D={id:x,object:g,def:{id:x,kind:`text`,text:t.ch}};e.reveal&&(D.reveal={def:{type:`appear`,when:`visible`,delay:j(e.reveal,E,C)},impl:M(e.reveal,a.size)}),S.push(D),E++}return{object:_,letters:S}}export{L as buildText};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"./index-L-N-e2KM.js";function t(e){return e.endsWith(`/`)?e:e+`/`}function n(e){let n=t(e.assetBase??`./`),r=t(e.libraryBase??n+`assets/library/`),i=e.assetUrls??{};return e=>{if(i[e])return i[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`),i[`library:`+t]?i[`library:`+t]:r+t}return n+e.replace(/^\.\//,``)}}var r=new Map;function i(e){let t=r.get(e);return t||(t=fetch(e).then(t=>{if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return t.text()}),t.catch(()=>r.delete(e)),r.set(e,t)),t}async function a(e){return JSON.parse(await i(e))}var o=new Map;function s(t){let n=o.get(t);return n||(n=e(()=>import(`./three.module-CnI50X0U.js`).then(e=>e.a).then(e=>new Promise((n,r)=>{new e.TextureLoader().load(t,n,void 0,()=>r(Error(`Cannot load texture ${t}`)))})),[],import.meta.url),n.catch(()=>o.delete(t)),o.set(t,n)),n.then(e=>{let t=e.clone();return t.needsUpdate=!0,t})}export{s as i,a as n,i as r,n as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./OrbitControls-MlE9XiCg.js","./three.module-CnI50X0U.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{In as e,It as t,Ln as n,Rt as r,wn as i,x as a}from"./three.module-CnI50X0U.js";import{h as o}from"./index-
|
|
2
|
+
import{In as e,It as t,Ln as n,Rt as r,wn as i,x as a}from"./three.module-CnI50X0U.js";import{h as o}from"./index-L-N-e2KM.js";var s=Math.PI/180;function c(e,t,n){return e<t?t:e>n?n:e}function l(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function u(e,t){return typeof e==`boolean`?e:t}function d(e,t){return typeof e==`string`?e:t}function f(e,t){return Array.isArray(e)&&e.length>=3&&e.every(e=>typeof e==`number`)?[e[0],e[1],e[2]]:t}function p(e,t){return typeof e==`string`?[e]:Array.isArray(e)&&e.length&&e.every(e=>typeof e==`string`)?e:t}var m=new Map;function h(e,t=`#ffffff`){let n=typeof e==`string`&&e?e:t,r=m.get(n);if(!r){r=new a;try{r.setStyle(n)}catch{r.setStyle(t)}m.size>512&&m.clear(),m.set(n,r)}return r.clone()}function g(e,t){let n={};if(e)for(let t of e.params)t.default!==void 0&&(n[t.name]=t.default);for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function _(e,t){let n=c(e,0,.999);return n<=0?1:1-n**(t*60)}function v(e){let t=Math.sin(e*127.1+311.7)*43758.5453123;return t-Math.floor(t)}function y(e){e.traverse(e=>{let t=e;t.geometry&&t.geometry.dispose();let n=t.material;if(n)for(let e of Array.isArray(n)?n:[n])b(e)})}function b(e){for(let t of Object.values(e))t instanceof i&&t.dispose();e.dispose()}function x(e){let t=new Set;return e.traverse(e=>{let n=e.material;if(n&&!e.userData.depthTwin)for(let e of Array.isArray(n)?n:[n])t.add(e)}),[...t]}function S(e){let t=(Math.floor(e)|0)^2654435769,n=()=>{t=t+2654435769|0;let e=t;return e=Math.imul(e^e>>>16,2246822507),e=Math.imul(e^e>>>13,3266489909),(e^e>>>16)>>>0},r=n(),i=n(),a=n(),o=n(),s=()=>{r>>>=0,i>>>=0,a>>>=0,o>>>=0;let e=(r+i|0)+o|0;return o=o+1|0,r=i^i>>>9,i=a+(a<<3)|0,a=a<<21|a>>>11,a=a+e|0,(e>>>0)/4294967296};for(let e=0;e<12;e++)s();return{next:s,range:(e,t)=>e+(t-e)*s(),int:(e,t)=>e+Math.floor(s()*(t-e+1)),pick:e=>e[Math.floor(s()*e.length)]}}function C(e,t){let n=(e|0)^2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return n>>>0}var w=new Uint8Array(512),T=new Uint8Array(512);{let e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;let t=S(1337);for(let n=255;n>0;n--){let r=Math.floor(t.next()*(n+1)),i=e[n];e[n]=e[r],e[r]=i}for(let t=0;t<512;t++)w[t]=e[t&255],T[t]=w[t]%12}var E=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),D=.5*(Math.sqrt(3)-1),O=(3-Math.sqrt(3))/6;function k(e,t){let n=(e+t)*D,r=Math.floor(e+n),i=Math.floor(t+n),a=(r+i)*O,o=e-(r-a),s=t-(i-a),c=+(o>s),l=o>s?0:1,u=o-c+O,d=s-l+O,f=o-1+2*O,p=s-1+2*O,m=r&255,h=i&255,g=0,_=.5-o*o-s*s;if(_>0){let e=T[m+w[h]]*3;_*=_,g+=_*_*(E[e]*o+E[e+1]*s)}let v=.5-u*u-d*d;if(v>0){let e=T[m+c+w[h+l]]*3;v*=v,g+=v*v*(E[e]*u+E[e+1]*d)}let y=.5-f*f-p*p;if(y>0){let e=T[m+1+w[h+1]]*3;y*=y,g+=y*y*(E[e]*f+E[e+1]*p)}return 70*g}var A=1/3,j=1/6;function M(e,t,n){let r=(e+t+n)*A,i=Math.floor(e+r),a=Math.floor(t+r),o=Math.floor(n+r),s=(i+a+o)*j,c=e-(i-s),l=t-(a-s),u=n-(o-s),d,f,p,m,h,g;c>=l?l>=u?[d,f,p,m,h,g]=[1,0,0,1,1,0]:c>=u?[d,f,p,m,h,g]=[1,0,0,1,0,1]:[d,f,p,m,h,g]=[0,0,1,1,0,1]:l<u?[d,f,p,m,h,g]=[0,0,1,0,1,1]:c<u?[d,f,p,m,h,g]=[0,1,0,0,1,1]:[d,f,p,m,h,g]=[0,1,0,1,1,0];let _=c-d+j,v=l-f+j,y=u-p+j,b=c-m+2*j,x=l-h+2*j,S=u-g+2*j,C=c-1+3*j,D=l-1+3*j,O=u-1+3*j,k=i&255,M=a&255,N=o&255,P=0,F=(e,t,n,r)=>{let i=.6-e*e-t*t-n*n;if(i>0){let a=r*3;i*=i,P+=i*i*(E[a]*e+E[a+1]*t+E[a+2]*n)}};return F(c,l,u,T[k+w[M+w[N]]]),F(_,v,y,T[k+d+w[M+f+w[N+p]]]),F(b,x,S,T[k+m+w[M+h+w[N+g]]]),F(C,D,O,T[k+1+w[M+1+w[N+1]]]),32*P}function N(e,t,n,r=2,i=.5){let a=0,o=1,s=1,c=0;for(let l=0;l<n;l++)a+=o*k(e*s+l*17.31,t*s-l*9.17),c+=o,o*=i,s*=r;return c>0?a/c:0}function P(e,t,n,r,i=2,a=.5){let o=0,s=1,c=1,l=0;for(let u=0;u<r;u++)o+=s*M(e*c+u*17.31,t*c-u*9.17,n*c+u*3.7),l+=s,s*=a,c*=i;return l>0?o/l:0}function F(e,t,n,r=2,i=.5){let a=0,o=1,s=1,c=0;for(let l=0;l<n;l++){let n=1-Math.abs(k(e*s+l*31.7,t*s+l*11.3));a+=o*n*n,c+=o,o*=i,s*=r}return c>0?a/c:0}function I(e,i){let a=l(e.near,.1),o=l(e.far,1e3),s;if(e.type===`orthographic`){let n=l(e.zoom,10)/2;s=new t(-n*i,n*i,n,-n,a,o)}else s=new r(l(e.fov,45),i,a,o);s.position.set(...e.position);let c=e.target??[0,0,0];return B(s.position,new n(c[0],c[1],c[2])),s.lookAt(c[0],c[1],c[2]),s}function L(e,t){return!t||!(e>0)||e>=t?1:Math.min(t/e,3)}function R(e,t){return t<=1?e:Math.min(100,2*Math.atan(Math.tan(e*s/2)*t)/s)}function z(e,n,i,a){let o=L(i,a);if(e.userData.fitScale=o,e instanceof r)e.aspect=i,e.fov=R(l(e.userData.restFov,l(n.fov,45)),o),e.updateProjectionMatrix();else if(e instanceof t){let t=(e.userData.zoomHeight??l(n.zoom,10))/2*o;e.left=-t*i,e.right=t*i,e.top=t,e.bottom=-t,e.updateProjectionMatrix()}}function B(e,t){let n=t.x-e.x,r=t.y-e.y,i=t.z-e.z,a=Math.hypot(n,r,i);if(a<1e-9)return;let o=-1e-4/a;e.set(e.x+n*o,e.y+r*o,e.z+i*o)}async function V(i,a,u,d){let f=new n(...i.target??[0,0,0]),p={position:new n(...i.position),target:f.clone(),fov:l(i.fov,45),zoom:l(i.zoom,10)},m=i.controls??`none`,h=p.position.clone(),g=p.target.clone(),v=new e,y=new n,b=!0,x=null;if(m===`orbit`&&u&&!d){let{OrbitControls:e}=await o(async()=>{let{OrbitControls:e}=await import(`./OrbitControls-MlE9XiCg.js`);return{OrbitControls:e}},__vite__mapDeps([0,1]),import.meta.url),t=new e(a,u);t.target.copy(p.target),t.enableDamping=!0,t.dampingFactor=.08,t.enableZoom=i.orbitZoom!==!1,t.enablePan=!1;let n=i.orbitLimits??{};n.minDistance!==void 0&&(t.minDistance=n.minDistance),n.maxDistance!==void 0&&(t.maxDistance=n.maxDistance),n.minPolar!==void 0&&(t.minPolarAngle=n.minPolar*s),n.maxPolar!==void 0&&(t.maxPolarAngle=n.maxPolar*s),n.minAzimuth!==void 0&&(t.minAzimuthAngle=n.minAzimuth*s),n.maxAzimuth!==void 0&&(t.maxAzimuthAngle=n.maxAzimuth*s),i.autoRotate&&(t.autoRotate=!0,t.autoRotateSpeed=i.autoRotate/360*60),x=t}let S=new n,C=new n;return{rest:p,shake:y,orbit:x,update(e,o,u){if(a instanceof r){a.userData.restFov=p.fov;let e=R(p.fov,l(a.userData.fitScale,1));a.fov!==e&&(a.fov=e,a.updateProjectionMatrix())}else if(a instanceof t&&l(a.userData.zoomHeight,l(i.zoom,10))!==p.zoom){a.userData.zoomHeight=p.zoom;let e=(a.right-a.left)/Math.max(a.top-a.bottom,1e-6),t=p.zoom/2*l(a.userData.fitScale,1);a.left=-t*e,a.right=t*e,a.top=t,a.bottom=-t,a.updateProjectionMatrix()}if(x){x.update(),a.position.add(y);return}let d=S.copy(p.position),f=g;if(m===`scroll`&&i.scrollPath?.length){let e=i.scrollPath,t=c(u.scroll,0,1)*(e.length-1),r=Math.min(Math.floor(t),e.length-2),a=e.length===1?0:t-Math.max(r,0),o=a*a*(3-2*a),s=e[Math.max(r,0)],l=e[Math.min(Math.max(r,0)+1,e.length-1)];d.set(...s.position).lerp(new n(...l.position),o);let p=new n(...s.target??i.target??[0,0,0]),m=new n(...l.target??i.target??[0,0,0]);f.copy(p.lerp(m,o))}else if(m===`follow`&&u.followTarget){let e=i.follow??{target:``},t=u.followTarget.getWorldPosition(new n),r=new n(...e.offset??[0,4,8]),a=t.clone().add(r),s=t.clone().add(new n(0,0,-l(e.lookAhead,0))),c=b?1:_(l(e.smoothing,.85),o);h.lerp(a,c),f.lerp(s,c),d=S.copy(h)}else f.copy(p.target);if(u.lookAt&&f.copy(u.lookAt),i.autoRotate&&m!==`follow`){let t=i.autoRotate*s*e,r=d.clone().sub(f);r.applyAxisAngle(new n(0,1,0),t),d.copy(f).add(r)}if(m===`parallax`){let e=i.parallax??{},t=l(e.strength,.5),r=_(l(e.smoothing,.92),o);v.x+=(u.pointer.x*t-v.x)*r,v.y+=(u.pointer.y*t*.6-v.y)*r;let s=f.clone().sub(d).normalize(),c=new n().crossVectors(s,a.up).normalize(),p=new n().crossVectors(c,s).normalize();d.addScaledVector(c,v.x).addScaledVector(p,v.y)}if(i.shake){let t=i.shake,r=l(t.speed,.5),o=l(t.amount,.03),c=l(t.rotation,.4)*s,u=l(t.seed,1)*17.31,p=t=>k(e*r+u,t*7.13)*.75+k(e*r*2.7+u,t*7.13+3.1)*.25,m=f.clone().sub(d),h=m.length()||1;m.divideScalar(h);let g=new n().crossVectors(m,a.up).normalize(),_=new n().crossVectors(g,m).normalize();d.addScaledVector(g,p(0)*o).addScaledVector(_,p(1)*o),C.copy(f).addScaledVector(g,Math.tan(p(2)*c)*h).addScaledVector(_,Math.tan(p(3)*c)*h)}else C.copy(f);a.position.copy(d).add(y),B(a.position,C),a.lookAt(C),b=!1},dispose(){x?.dispose()}}}export{g as C,f as S,x as _,N as a,d as b,k as c,s as d,u as f,v as g,y as h,S as i,M as l,p as m,V as n,P as o,c as p,z as r,C as s,I as t,F as u,l as v,h as x,_ as y};
|