@occluze/umber 0.0.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +62 -2
  2. package/dist/chunks/capture.js +2 -0
  3. package/dist/chunks/covers.js +2 -0
  4. package/dist/chunks/flip.js +2 -0
  5. package/dist/chunks/fx.js +102 -0
  6. package/dist/chunks/gl.js +180 -0
  7. package/dist/chunks/glsl.js +239 -0
  8. package/dist/chunks/inspect.js +6 -0
  9. package/dist/chunks/instances.js +93 -0
  10. package/dist/chunks/layers.js +21 -0
  11. package/dist/chunks/licence.js +2 -0
  12. package/dist/chunks/morph.js +2 -0
  13. package/dist/chunks/restore.js +2 -0
  14. package/dist/chunks/shapes.js +2 -0
  15. package/dist/chunks/sim.js +22 -0
  16. package/dist/chunks/text.js +52 -0
  17. package/dist/chunks/video.js +2 -0
  18. package/dist/chunks/views.js +2 -0
  19. package/dist/chunks/warm.js +2 -0
  20. package/dist/modules/debug.js +36 -0
  21. package/dist/modules/debug.mjs +36 -0
  22. package/dist/modules/handoff.js +2 -0
  23. package/dist/modules/handoff.mjs +2 -0
  24. package/dist/modules/input.js +2 -0
  25. package/dist/modules/input.mjs +2 -0
  26. package/dist/modules/router-swap.js +13 -0
  27. package/dist/modules/router.js +2 -0
  28. package/dist/modules/router.mjs +2 -0
  29. package/dist/modules/scroll.js +2 -0
  30. package/dist/modules/scroll.mjs +2 -0
  31. package/dist/modules/scrub.js +8 -0
  32. package/dist/modules/scrub.mjs +8 -0
  33. package/dist/umber.css +2 -0
  34. package/dist/umber.js +2 -0
  35. package/dist/umber.mjs +2 -0
  36. package/docs/AI-quick.md +178 -0
  37. package/docs/AI.md +2660 -0
  38. package/docs/npm.md +69 -0
  39. package/package.json +118 -8
  40. package/types/debug.d.ts +27 -0
  41. package/types/esm.d.ts +33 -0
  42. package/types/handoff.d.ts +116 -0
  43. package/types/input.d.ts +235 -0
  44. package/types/router.d.ts +181 -0
  45. package/types/scroll.d.ts +132 -0
  46. package/types/scrub.d.ts +74 -0
  47. package/types/umber.d.ts +1532 -0
  48. package/index.js +0 -2
@@ -0,0 +1,239 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var S={hash:{used:/\bumberHash\s*\(/,defined:/\bfloat\s+umberHash\s*\(/,code:`float umberHash(vec2 p){
3
+ p=fract(p*vec2(123.34,456.21));
4
+ p+=dot(p,p+45.32);
5
+ return fract(p.x*p.y);
6
+ }
7
+ float umberHash(vec3 p){
8
+ p=fract(p*vec3(0.1031,0.1030,0.0973));
9
+ p+=dot(p,p.yxz+33.33);
10
+ return fract((p.x+p.y)*p.z);
11
+ }`},noise2:{used:/\bnoise\s*\(/,defined:/\bfloat\s+noise\s*\(\s*(?:in\s+)?vec2\b/,needs:["hash"],code:`float noise(vec2 p){
12
+ vec2 i=floor(p);
13
+ vec2 f=fract(p);
14
+ vec2 k=f*f*(3.0-2.0*f);
15
+ return mix(mix(umberHash(i),umberHash(i+vec2(1.0,0.0)),k.x),mix(umberHash(i+vec2(0.0,1.0)),umberHash(i+vec2(1.0,1.0)),k.x),k.y);
16
+ }`},noise3:{used:/\bnoise\s*\(/,defined:/\bfloat\s+noise\s*\(\s*(?:in\s+)?vec3\b/,needs:["hash"],code:`float noise(vec3 p){
17
+ vec3 i=floor(p);
18
+ vec3 f=fract(p);
19
+ vec3 k=f*f*(3.0-2.0*f);
20
+ vec2 e=vec2(1.0,0.0);
21
+ float a=mix(mix(umberHash(i),umberHash(i+e.xyy),k.x),mix(umberHash(i+e.yxy),umberHash(i+e.xxy),k.x),k.y);
22
+ float b=mix(mix(umberHash(i+e.yyx),umberHash(i+e.xyx),k.x),mix(umberHash(i+e.yxx),umberHash(i+e.xxx),k.x),k.y);
23
+ return mix(a,b,k.z);
24
+ }`},fbm:{used:/\bfbm\s*\(/,defined:/\bfloat\s+fbm\s*\(\s*(?:in\s+)?vec2\b/,needs:["noise2"],code:`float fbm(vec2 p){
25
+ float v=0.0;
26
+ float a=0.5;
27
+ for(int i=0;i<4;i++){
28
+ v+=a*noise(p);
29
+ p=p*2.03+17.0;
30
+ a*=0.5;
31
+ }
32
+ return v/0.9375;
33
+ }`},screenPx:{used:/\bscreenPx\s*\(/,defined:/\bvec2\s+screenPx\s*\(/,code:`#ifdef UMBER_FRAGMENT
34
+ vec2 screenPx(){
35
+ return uSurface.xy+vec2(gl_FragCoord.x,uCanvas.y-gl_FragCoord.y)/uCanvas*uSurface.zw;
36
+ }
37
+ #endif`},screenUv:{used:/\bscreenUv\s*\(/,defined:/\bvec2\s+screenUv\s*\(/,needs:["screenPx"],code:`#ifdef UMBER_FRAGMENT
38
+ vec2 screenUv(){
39
+ return screenPx()/uViewport;
40
+ }
41
+ #endif`},screen:{used:/\buScreen\b/,defined:/(vec2|#define)\s+uScreen\b/,code:"#define uScreen ((uRect.xy + uRect.zw * 0.5) / uViewport * 2.0 - 1.0)"},samplePrev:{used:/\bsamplePrev\s*\(/,defined:/\bvec4\s+samplePrev\s*\(/,code:`vec4 samplePrev(vec2 uv){
42
+ vec2 f=uv;
43
+ if(uFit<1.5){
44
+ vec2 ratio=uSize/max(uPrevSize,vec2(1.0));
45
+ float s=uFit<0.5?max(ratio.x,ratio.y):min(ratio.x,ratio.y);
46
+ vec2 scaled=uPrevSize*s;
47
+ f=(uv*uSize-(uSize-scaled)*uFitPosition)/scaled;
48
+ }
49
+ vec4 c=texture(uPrev,f);
50
+ if(uFit>0.5&&uFit<1.5&&(f.x<0.0||f.y<0.0||f.x>1.0||f.y>1.0))c=vec4(0.0);
51
+ return c;
52
+ }`},rotate2d:{used:/\brotate2d\s*\(/,defined:/\bmat2\s+rotate2d\s*\(/,code:`mat2 rotate2d(float a){
53
+ float c=cos(a);
54
+ float s=sin(a);
55
+ return mat2(c,s,-s,c);
56
+ }`}};var O={info(){},warn:(e,...t)=>console.warn("[umber]",e,...t),once:(e,...t)=>console.warn("[umber]",e,...t),error:(e,...t)=>console.error("[umber]",e,...t)},y=O;function A(e){e&&(y=e)}var I=/^[ \t]*#include[ \t]+["<]?([\w-]+)[">]?[ \t]*$/gm,F=new Set("if else for while do switch case default return break continue discard uniform in out inout const struct precision layout highp mediump lowp flat smooth centroid invariant".split(" "));function w({effects:e,shader:t,...s},i,c){let l=new Set,d=[],E=()=>({code:[],seen:new Set}),k=E(),p=E(),u=(o,r)=>o.replace(I,(a,n)=>{if(r.seen.has(n))return"";r.seen.add(n),l.add(n);let f=c.get(n);return f==null?d.includes(n)||d.push(n):r.code.push(`// chunk: ${n}
57
+ ${u(f,r)}`),""}),x=(o,r)=>{if(!o)return o;let a={};for(let n in o)typeof o[n]=="string"&&(a[n]=r(o[n]));return a},b=e.map(({name:o,def:r})=>({name:o,def:{...r,vertex:x(r.vertex,a=>u(a,k)),fragment:x(r.fragment,a=>u(a,p))}})),B=t&&{name:t.name,def:{...t.def,head:u(t.def.head||"",p),fragment:u(t.def.fragment,p)}},C=b.map(({def:o})=>D(`${o.vertex?.head||""}
58
+ ${o.fragment?.head||""}`)),g=new Map;for(let o of[...C,D(B?.def.head||"")])for(let r of o)g.set(r,(g.get(r)||0)+1);if(b.forEach((o,r)=>{let a=[...C[r]].filter(h=>g.get(h)>1);if(!a.length)return;let n=new RegExp(`(^|[^.\\w])(${a.join("|")})\\b`,"g"),f=h=>h.replace(n,`$1e${r}_$2`);o.def={...o.def,vertex:x(o.def.vertex,f),fragment:x(o.def.fragment,f)}}),d.length){for(let o of d)i.missing.push(`chunk:${o}`),y.warn(`#include "${o}": no chunk has that name, so this element shows its DOM. Define it with gl.chunk("${o}", glsl).`,i.el);return i.setStatus("error"),null}return{...s,effects:b,shader:B,chunks:{vertex:k.code.join(`
59
+
60
+ `),fragment:p.code.join(`
61
+
62
+ `)},included:[...l]}}function D(e){let t="",s=0;for(let c of e.replace(/\/\/.*|\/\*[\s\S]*?\*\//g,""))(c==="}"||c===")")&&s--,s||(t+=c),(c==="{"||c==="(")&&s++;t=t.replace(/\b(uniform|in|out|precision|layout)\b[^;]*;/g,"");let i=new Set;for(let c of t.matchAll(/#define\s+(\w+)|\b(\w+)\s+(\w+)\s*[(=;,[]/g)){let l=c[1]||c[3];!F.has(l)&&!F.has(c[2]||"")&&i.add(l)}return i}var P={quad:"t*t",cubic:"t*t*t",quart:"t*t*t*t",quint:"t*t*t*t*t",sine:"1.0-cos(t*PI*0.5)",expo:"t<=0.0?0.0:pow(2.0,10.0*t-10.0)",circ:"1.0-sqrt(1.0-t*t)"},m={};for(let e in P){let t=`${e}In`;m[t]={code:`float ${t}(float t){
63
+ t=clamp(t,0.0,1.0);
64
+ return ${P[e]};
65
+ }`},m[`${e}Out`]={needs:[t],code:`float ${e}Out(float t){
66
+ return 1.0-${t}(1.0-t);
67
+ }`},m[`${e}InOut`]={needs:[t],code:`float ${e}InOut(float t){
68
+ return t<0.5?${t}(t*2.0)*0.5:1.0-${t}(2.0-t*2.0)*0.5;
69
+ }`}}var R={...m,umberBezierAxis:{code:`float umberBezierAxis(float t,float p1,float p2){
70
+ float c=3.0*p1;
71
+ float b=3.0*(p2-p1)-c;
72
+ return(((1.0-c-b)*t+b)*t+c)*t;
73
+ }`},cubicBezier:{needs:["umberBezierAxis"],code:`float cubicBezier(float x,vec4 h){
74
+ if(x<=0.0||x>=1.0)return clamp(x,0.0,1.0);
75
+ float lo=0.0;
76
+ float hi=1.0;
77
+ for(int i=0;i<20;i++){
78
+ float t=(lo+hi)*0.5;
79
+ if(umberBezierAxis(t,h.x,h.z)<x)lo=t;
80
+ else hi=t;
81
+ }
82
+ return umberBezierAxis((lo+hi)*0.5,h.y,h.w);
83
+ }`},umberEase:{needs:["cubicBezier"],code:`float umberEase(float t){
84
+ return cubicBezier(t,vec4(0.625,0.05,0.0,1.0));
85
+ }`},stagger:{code:`float stagger(float progress,float index,float count,float overlap){
86
+ float o=1.0-clamp(overlap,0.0,1.0);
87
+ float w=1.0/(1.0+max(count-1.0,0.0)*o);
88
+ return clamp((progress-index*w*o)/w,0.0,1.0);
89
+ }`}};var z={umberHash3u:{code:`uvec3 umberHash3u(uvec3 v){
90
+ v=v*0x9E3779B9u+v.yzx;
91
+ v^=v>>16u;
92
+ v=v*0x85EBCA6Bu+v.zxy;
93
+ v^=v>>13u;
94
+ v*=0xC2B2AE35u;
95
+ v^=v>>16u;
96
+ return v;
97
+ }`},umberRand3:{needs:["umberHash3u"],code:`vec3 umberRand3(vec3 p){
98
+ return vec3(umberHash3u(uvec3(ivec3(floor(p+0.5)))))*(1.0/4294967296.0);
99
+ }`},snoise:{needs:["umberRand3"],code:`float umberCorner(vec2 i,vec2 x){
100
+ float t=max(0.5-dot(x,x),0.0);
101
+ float a=umberRand3(vec3(i,0.0)).x*6.28318530718;
102
+ t*=t;
103
+ return t*t*dot(vec2(cos(a),sin(a)),x);
104
+ }
105
+ float snoise(vec2 p){
106
+ const float F=0.36602540378;
107
+ const float G=0.2113248654;
108
+ vec2 i=floor(p+(p.x+p.y)*F);
109
+ vec2 x0=p-i+(i.x+i.y)*G;
110
+ vec2 o=x0.x>x0.y?vec2(1.0,0.0):vec2(0.0,1.0);
111
+ return 99.2*(umberCorner(i,x0)+umberCorner(i+o,x0-o+G)+umberCorner(i+1.0,x0-1.0+2.0*G));
112
+ }
113
+ float umberCorner(vec3 i,vec3 x){
114
+ float t=max(0.5-dot(x,x),0.0);
115
+ vec3 h=umberRand3(i);
116
+ float z=h.x*2.0-1.0;
117
+ float a=h.y*6.28318530718;
118
+ float r=sqrt(1.0-z*z);
119
+ t*=t;
120
+ return t*t*dot(vec3(r*cos(a),r*sin(a),z),x);
121
+ }
122
+ float snoise(vec3 p){
123
+ vec3 i=floor(p+(p.x+p.y+p.z)/3.0);
124
+ vec3 x0=p-i+(i.x+i.y+i.z)/6.0;
125
+ vec3 big=x0.x>=x0.y?(x0.x>=x0.z?vec3(1.0,0.0,0.0):vec3(0.0,0.0,1.0)):(x0.y>=x0.z?vec3(0.0,1.0,0.0):vec3(0.0,0.0,1.0));
126
+ vec3 mid=1.0-(x0.x<x0.y?(x0.x<x0.z?vec3(1.0,0.0,0.0):vec3(0.0,0.0,1.0)):(x0.y<x0.z?vec3(0.0,1.0,0.0):vec3(0.0,0.0,1.0)));
127
+ return 108.0*(umberCorner(i,x0)+umberCorner(i+big,x0-big+1.0/6.0)+umberCorner(i+mid,x0-mid+2.0/6.0)+umberCorner(i+1.0,x0-0.5));
128
+ }`},pnoise:{needs:["umberRand3"],code:`float umberSlope(vec2 i,vec2 period,float spin,vec2 x){
129
+ float a=umberRand3(vec3(mod(i,period),1.0)).x*6.28318530718+spin;
130
+ return dot(vec2(cos(a),sin(a)),x);
131
+ }
132
+ float pnoise(vec2 p,vec2 period,float spin){
133
+ vec2 n=max(floor(period+0.5),1.0);
134
+ vec2 i=floor(p);
135
+ vec2 f=p-i;
136
+ vec2 u=f*f*f*(f*(f*6.0-15.0)+10.0);
137
+ float a=umberSlope(i,n,spin,f);
138
+ float b=umberSlope(i+vec2(1.0,0.0),n,spin,f-vec2(1.0,0.0));
139
+ float c=umberSlope(i+vec2(0.0,1.0),n,spin,f-vec2(0.0,1.0));
140
+ float d=umberSlope(i+1.0,n,spin,f-1.0);
141
+ return 1.41421356*mix(mix(a,b,u.x),mix(c,d,u.x),u.y);
142
+ }`},cellular:{needs:["umberRand3"],code:`vec2 cellular(vec2 p){
143
+ vec2 i=floor(p);
144
+ vec2 f=p-i;
145
+ vec2 d=vec2(8.0);
146
+ for(int y= -1;y<=1;y++)
147
+ for(int x= -1;x<=1;x++){
148
+ vec2 c=vec2(float(x),float(y));
149
+ float l=length(c+umberRand3(vec3(i+c,2.0)).xy-f);
150
+ if(l<d.x)d=vec2(l,d.x);
151
+ else if(l<d.y)d.y=l;
152
+ }
153
+ return d;
154
+ }
155
+ vec2 cellular(vec3 p){
156
+ vec3 i=floor(p);
157
+ vec3 f=p-i;
158
+ vec2 d=vec2(8.0);
159
+ for(int z= -1;z<=1;z++)
160
+ for(int y= -1;y<=1;y++)
161
+ for(int x= -1;x<=1;x++){
162
+ vec3 c=vec3(float(x),float(y),float(z));
163
+ float l=length(c+umberRand3(i+c)-f);
164
+ if(l<d.x)d=vec2(l,d.x);
165
+ else if(l<d.y)d.y=l;
166
+ }
167
+ return d;
168
+ }`}};var L={sdCircle:{code:`float sdCircle(vec2 p,float r){
169
+ return length(p)-r;
170
+ }`},sdBox:{code:`float sdBox(vec2 p,vec2 b){
171
+ vec2 d=abs(p)-b;
172
+ return length(max(d,0.0))+min(max(d.x,d.y),0.0);
173
+ }`},sdSegment:{code:`float sdSegment(vec2 p,vec2 a,vec2 b){
174
+ vec2 pa=p-a;
175
+ vec2 ba=b-a;
176
+ return length(pa-ba*clamp(dot(pa,ba)/max(dot(ba,ba),1e-8),0.0,1.0));
177
+ }`},opRound:{code:`float opRound(float d,float r){
178
+ return d-r;
179
+ }`},opOnion:{code:`float opOnion(float d,float w){
180
+ return abs(d)-w;
181
+ }`},opSmoothUnion:{code:`float opSmoothUnion(float a,float b,float k){
182
+ float h=clamp(0.5+0.5*(b-a)/max(k,1e-6),0.0,1.0);
183
+ return mix(b,a,h)-k*h*(1.0-h);
184
+ }`},opSmoothSubtract:{code:`float opSmoothSubtract(float a,float b,float k){
185
+ float h=clamp(0.5-0.5*(a+b)/max(k,1e-6),0.0,1.0);
186
+ return mix(a,-b,h)+k*h*(1.0-h);
187
+ }`},opSmoothIntersect:{code:`float opSmoothIntersect(float a,float b,float k){
188
+ float h=clamp(0.5-0.5*(b-a)/max(k,1e-6),0.0,1.0);
189
+ return mix(b,a,h)+k*h*(1.0-h);
190
+ }`},aa:{code:`#ifdef UMBER_FRAGMENT
191
+ float aa(float d){
192
+ return clamp(0.5-d/max(length(vec2(dFdx(d),dFdy(d))),1e-6),0.0,1.0);
193
+ }
194
+ #endif`}};var H={blendNormal:{code:`vec3 blendNormal(vec3 base,vec3 top,float opacity){
195
+ return mix(base,top,opacity);
196
+ }`},blendAdd:{code:`vec3 blendAdd(vec3 base,vec3 top,float opacity){
197
+ return mix(base,min(base+top,1.0),opacity);
198
+ }`},blendScreen:{code:`vec3 blendScreen(vec3 base,vec3 top,float opacity){
199
+ return mix(base,base+top-base*top,opacity);
200
+ }`},blendMultiply:{code:`vec3 blendMultiply(vec3 base,vec3 top,float opacity){
201
+ return mix(base,base*top,opacity);
202
+ }`}};var G={umberBayer2:{code:`float umberBayer2(vec2 p){
203
+ p=mod(floor(p),2.0);
204
+ return mod(2.0*p.x+3.0*p.y,4.0);
205
+ }`},bayer4:{needs:["umberBayer2"],code:`float bayer4(vec2 p){
206
+ return(4.0*umberBayer2(p)+umberBayer2(p*0.5)+0.5)/16.0;
207
+ }`},bayer8:{needs:["umberBayer2"],code:`float bayer8(vec2 p){
208
+ return(16.0*umberBayer2(p)+4.0*umberBayer2(p*0.5)+umberBayer2(p*0.25)+0.5)/64.0;
209
+ }`},blueNoise:{code:`const uint umberBlue[64]=uint[64](
210
+ 0xA9D7054Au,0x772B5FE1u,0x31BDE549u,0x2DDF1F4Eu,0x7333A2FEu,0xD4FB890Bu,0x698C159Au,0xC29678F0u,
211
+ 0xECC37E63u,0x1C3AB14Du,0xB041F358u,0x123FD30Au,0x145524E7u,0xBC67CE97u,0xC723A582u,0x8BAB5E85u,
212
+ 0xF5B59D45u,0xEB017A29u,0x5070CC32u,0xD62F1BF9u,0x866CCA03u,0x4BADE240u,0x38DD0D90u,0x75B9E39Fu,
213
+ 0xDA1A37F8u,0x6B20A15Au,0x7CB45CFFu,0x52916806u,0xBA9562A7u,0xBFD17608u,0xED199B2Eu,0xDC253CC1u,
214
+ 0xE84CC50Eu,0x1146F634u,0x8D43D581u,0x7FA3D056u,0x832272EEu,0xB69364ACu,0x28A861F1u,0x4717FA74u,
215
+ 0x99CF39AEu,0x5726E013u,0xC8E40236u,0x8E60B70Cu,0x54FD00DBu,0xA47DC43Du,0x4F876EC0u,0x27E93598u,
216
+ 0xB888669Eu,0xD907EA71u,0xDE16FC48u,0x537BD26Au,0x102CBE3Eu,0x846530A0u,0x2AB39421u,0xC909AA44u,
217
+ 0xCB79E61Du,0xEFB251F4u,0x8059CD3Bu,0xF28A18F7u,0x425D8FAFu,0x0FC6921Eu,0xD8046DA6u,0x6F5BBB9Cu
218
+ );
219
+ float blueNoise(vec2 p){
220
+ ivec2 q=ivec2(mod(floor(p),16.0));
221
+ int i=q.y*16+q.x;
222
+ return(float((umberBlue[i>>2]>>(uint(i&3)*8u))&255u)+0.5)/256.0;
223
+ }`},dither:{code:`vec3 dither(vec3 color,float threshold,float levels){
224
+ float n=max(levels-1.0,1.0);
225
+ return floor(color*n+threshold)/n;
226
+ }`}};var $={srgbToLinear:{code:`vec3 srgbToLinear(vec3 c){
227
+ return mix(c/12.92,pow((max(c,0.0)+0.055)/1.055,vec3(2.4)),step(0.04045,c));
228
+ }`},linearToSrgb:{code:`vec3 linearToSrgb(vec3 c){
229
+ return mix(c*12.92,1.055*pow(max(c,0.0),vec3(1.0/2.4))-0.055,step(0.0031308,c));
230
+ }`},linearToOklab:{code:`vec3 linearToOklab(vec3 c){
231
+ vec3 lms=c*mat3(0.4122214708,0.5363325363,0.0514459929,0.2119034982,0.6806995451,0.1073969566,0.0883024619,0.2817188376,0.6299787005);
232
+ lms=sign(lms)*pow(abs(lms),vec3(1.0/3.0));
233
+ return lms*mat3(0.2104542553,0.7936177850,-0.0040720468,1.9779984951,-2.4285922050,0.4505937099,0.0259040371,0.7827717662,-0.8086757660);
234
+ }`},oklabToLinear:{code:`vec3 oklabToLinear(vec3 c){
235
+ vec3 lms=c*mat3(1.0,0.3963377774,0.2158037573,1.0,-0.1055613458,-0.0638541728,1.0,-0.0894841775,-1.2914855480);
236
+ return(lms*lms*lms)*mat3(4.0767416621,-3.3077115913,0.2309699292,-1.2684380046,2.6097574011,-0.3413193965,-0.0041960863,-0.7034186147,1.7076147010);
237
+ }`},mixOklab:{needs:["srgbToLinear","linearToSrgb","linearToOklab","oklabToLinear"],code:`vec3 mixOklab(vec3 a,vec3 b,float t){
238
+ return linearToSrgb(oklabToLinear(mix(linearToOklab(srgbToLinear(a)),linearToOklab(srgbToLinear(b)),t)));
239
+ }`}};var v={...R,...z,...L,...H,...G,...$},M="(?:float|u?int|bool|void|[iu]?vec[234]|mat[234])",T={};for(let e in v)T[e]={used:new RegExp(`\\b${e}\\s*\\(`),defined:new RegExp(`\\b${M}\\s+${e}\\s*\\(`),code:v[e].code,needs:v[e].needs};var se={...S,...T},N=e=>`// ${e}() from the helper pack`;function ie(e){A(e.host.log);let t=e.registry.chunks;for(let s in v)t.has(s)||t.set(s,N(s));return w}export{v as GLSL,se as GLSL_HELPERS,ie as glsl,N as packChunk};
@@ -0,0 +1,6 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var h="[data-gl]",O=new Set(["data-gl","data-gl-effect","data-gl-shader","data-gl-layer","data-gl-instances"]),P=[...O,"style","class","hidden","media","disabled","data-gl-src","src","srcset","sizes","data-gl-occlude","data-gl-pass","data-gl-under"];var C="[data-gl-occlude]",B=h+","+C;var b={scrub:"modules/scrub.js"};function l(e){if(!e||typeof e.tagName!="string")return"<?>";let n=e.tagName.toLowerCase();if(e.id)return`<${n}#${e.id}>`;let t=typeof e.className=="string"?e.className.trim().split(/\s+/)[0]:"";return t?`<${n}.${t}>`:`<${n}>`}function x(e,n){let t="",s=3;for(let r of n){let i=U(e.toLowerCase(),r.toLowerCase());i<s&&(t=r,s=i)}return t}function U(e,n){let t=Array.from({length:n.length+1},(s,r)=>r);for(let s=1;s<=e.length;s++){let r=t[0];t[0]=s;for(let i=1;i<=n.length;i++){let a=t[i];t[i]=Math.min(t[i]+1,t[i-1]+1,r+(e[s-1]===n[i-1]?0:1)),r=a}}return t[n.length]}var I=e=>!!e.backgroundImage&&e.backgroundImage!=="none"||!/^(transparent|rgba\(.*,\s*0\))$/.test(e.backgroundColor||"transparent"),z=["transform","translate","rotate","scale","perspective","filter","backdropFilter","clipPath","maskImage","webkitMaskImage"],D=e=>e.position!=="static"&&e.zIndex!=="auto"||/fixed|sticky/.test(e.position)||parseFloat(e.opacity)<1||z.some(n=>(e[n]||"none")!=="none")||e.isolation==="isolate"||(e.mixBlendMode||"normal")!=="normal"||/\b(layout|paint|strict|content)\b/.test(e.contain)||/^(size|inline-size)$/.test(e.containerType)||/\b(transform|translate|rotate|scale|perspective|filter|opacity|clip-path|mask|isolation|mix-blend-mode|contain)\b/.test(e.willChange);function k(e,n){let t=parseInt(getComputedStyle(n).zIndex,10);if(!(t>0))return null;let s=null,r="auto",i=[];for(let a=e;a&&a!==document.body&&a!==document.documentElement;a=a.parentElement){let d=getComputedStyle(a);I(d)&&!(a===e&&e.getAttribute("data-gl")==="shader")&&i.push(a),D(d)&&(s=a,r=d.position!=="static"?d.zIndex:"auto")}return!s||r==="auto"||+r<t||!i.some(a=>s.contains(a))?null:`${l(s)} (z-index ${r}, with a background) covers Umber's canvas (z-index ${t}): GL inside it is hidden. Drop that z-index (and give it data-gl-occlude if it must still cover the GL elements before it) or move the background behind the content.`}var L="https://umber.occluze.com";var w=(e,n)=>{let t=x(e,n);return t?` (did you mean "${t}"?)`:""},_=(e,n)=>{if(e==="umber.css")return"Umber's canvas host is not fixed: umber.css is not on this page, so GL is off and the DOM shows. Link umber.css in <head> on every page.";let t=e.slice(e.lastIndexOf(" has ")+5).split(":")[0];return`${e}, which makes Umber's fixed canvas ${t==="zoom"?"scale":"scroll or turn"} with the page, so GL is off and the DOM shows. Move the ${t} to a wrapper element inside <body>${n?"":", or move the [data-gl-host] element out of it"}.`},A={disabled:"switched off (devices: false, data-gl-disable on <body>, or ?umber=off in the URL)","no-webgl2":"this browser has no WebGL2",device:'a device or screen this site keeps effects off (devices: "desktop" / data-gl-devices, or media / data-gl-media)',editor:"inside the Webflow Designer / Editor (createGL({ designer: true }) runs it there)","forced-colors":"forced colours (Windows High Contrast) are on","reduced-motion":'the visitor prefers reduced motion and reducedMotion is "off"',"save-data":"the browser asks to save data (createGL({ respectSaveData: false }) ignores that)",context:"a WebGL2 context could not be created","load-failed":"chunks/gl.js failed to load","load-timeout":"chunks/gl.js took more than 4 s to download",unlicensed:"this domain isn't on an Umber licence (list it under Umber in your occluze dashboard)","context-lost":"the WebGL context was lost more than 2 times",error:"an error inside a GL frame (see the [umber] error before this)",server:"not in a browser",destroyed:"gl.destroy() was called"},S=e=>A[e]||e,p={host:_,reason:S,off:e=>`GL off: ${S(e)}`,type:(e,n,t)=>`data-gl="${n}" on ${l(e)} is not a GL type${w(n,t)}; it is drawn as an image. Use one of: ${t.join(", ")}.`,effect:(e,n,t)=>`data-gl-effect="${n}" on ${l(e)}: no effect with that name${w(n,t)}. Define it first with gl.effect("${n}", {...}): Umber ships no effects ("Writing effects" in ${L}/docs.md). Known: ${t.join(", ")||"none yet"}.`,shader:(e,n,t)=>`data-gl="shader" on ${l(e)} needs data-gl-shader="name" and gl.shader("${n||"name"}", { fragment: "..." })${n?w(n,t):""}.`,glyph:()=>'glyph() is for data-gl="text" planes; on other planes it answers one line, word and character covering the whole element.',busy:e=>`createGL({ busy }): "${e}" is not a selector; ignored.`,gpu:e=>`?umber-gpu=${e} is ignored: use 0-5, m0-m5, low, mid or high.`,texture:e=>`${e}: a canvas, bitmap, video or numbers need gl.texture(source) from the input module (modules/input.js).`,own:e=>`module "${e}": plane.${e} is Umber's own. Rename the module.`,useTwice:e=>`gl.use(): a module named "${e}" is in use already; keeping the first one.`,use:()=>"gl.use(module) needs an Umber module (an object with a name), for example Scrub from @occluze/umber/scrub.",module:(e,n)=>{let t=n.charAt(0).toUpperCase()+n.slice(1);return`data-gl-${n} on ${l(e)}: no module "${n}". Load ${b[n]} next to umber.js, or gl.use(${t}) with import { ${t} } from "@occluze/umber/${n}".`},slow:e=>`A GL element took more than ${e}s to load, so its normal DOM image/text is shown instead (slow network or a very large image? Use a smaller image).`,set:(e,n,t,s)=>`plane.set("${n}") on ${l(e)}: no effect on this plane has a uniform "${n}", so no shader reads it${w(n,t)}. Effects here: ${s}. Declare it in the effect's uniforms: { ${n}: 0 }.`,play:()=>'plane.play(): this plane has no effect with a `play` uniform. Add one (gl.effect(name, { play: "uShow", ... })) or use plane.tween(name, { value: 1 }).',image:()=>"data-gl element has no image. Put an <img> inside it or set data-gl-src.",cors:(e,n)=>`${l(e)}: its image ${n} could not become a texture, so the DOM image shows (not found, or on another domain without CORS headers? Serve it with Access-Control-Allow-Origin, or from this site's own domain).`,oval:e=>`${l(e)}: its rounded corners have different shapes (across / down), and GL draws one shape for all of them, so its DOM shows. Give every rounded corner the same proportion, or use clip-path for the shape.`,webgl2:()=>"WebGL2 is not available here; the site runs without GL.",glsl:(e,n,t,s)=>{if(e==="link")return`shader link failed (${n}): ${t}`;let r=Number((t.match(/ERROR: \d+:(\d+)/)||[])[1]||0),i=s.split(`
3
+ `).map((a,d)=>`${String(d+1).padStart(4)}${d+1===r?" >":" "} ${a}`).slice(Math.max(0,r-6),r+3).join(`
4
+ `);return`${e} shader error in "${n}":
5
+ ${t}
6
+ ${i}`},hostless:e=>`createGL({ host: "${e}" }): no such element; Umber made its own canvas host.`,tween:e=>`An Umber tween needs a number in { value }, got ${JSON.stringify(e)}.`,trigger:e=>`Unknown play trigger "${String(e)}". Use auto (default), scroll, load, manual or hover.`,edge:e=>`play start "${String(e)}": the first word is the element's edge (top, center or bottom). Using "top".`,line:e=>`play start "${String(e)}": the second word is a line on the screen (top, center, bottom, 80% or 600px).`,ease:e=>`Unknown ease "${String(e)}". Use "umber" (default), "linear", "ease-out", "cubic-bezier(a, b, c, d)", "linear(0, 0.6 40%, 1)", "spring(0.3)", or quad/cubic/quart/quint/sine/expo/circ with .in, .out or .inOut (e.g. "expo.out").`,var:e=>`"${e}": its custom property is not set here. Set it, or give var() a fallback.`,losses:e=>`WebGL context lost ${e} times; the plain DOM shows for the rest of this visit. Too many or too large GL images? Use smaller images or fewer data-gl elements.`,lost:()=>"WebGL context lost; the DOM shows until it is restored.",devicesThrew:()=>"createGL({ devices }) threw; GL stays off.",install:e=>`module "${e}" install failed`,handler:(e,n)=>`a ${e}"${n}" handler threw:`,undo:()=>"gl.scope(): cleaning up one of its objects failed",scopeFn:()=>"gl.scope(fn): fn threw (what it made before that is still in the scope)",scopeAsync:()=>"gl.scope(async fn): fn rejected",frame:()=>"a frame callback threw:",tracker:()=>"a tracker failed to measure its element",absent:(e,n)=>`${e}: ${typeof n=="string"?`nothing matches "${n}"`:"no element given"}.`,unplaced:e=>`${e}: the element is not in the page yet. Call it after the element is added.`,noViews:()=>"gl.attach() is not available in this build (no chunks/views.js).",version:(e,n,t)=>`modules/${e}.js ${n} with umber.js ${t}: load both from the same version.`,scroll:e=>`createGL({ scroll }) ${e?"needs a Lenis instance, an element, or { y, velocity }":"got something Umber can't read"}. Using the window scroll instead.`,devices:e=>`createGL({ devices: ${JSON.stringify(e)} }) is not "desktop", "all", false or a function; using "desktop".`,twice:()=>"createGL() was called twice; returning the existing engine. Call gl.destroy() first to start fresh.",uniformImage:()=>"uniform texture failed",script:(e,n)=>`umber.js ${e} was loaded twice (Umber ${n} is already on the page); keeping the first copy.`,added:()=>"gl.add(): this element has data-gl already; returning its plane.",attachOff:e=>`gl.attach(): off on this device (${e})`,destroy:()=>"gl.destroy(el): no element given (a selector that found nothing?), so nothing was destroyed. gl.destroy() with no argument ends the engine.",change:(e,n)=>`${e?`<html> still matches "${e}"`:"gl.transition() was not ended"} after ${n} s, so Umber ended it. ${e?"Take that flag off":"Call the end() it returns"} once the new page is in.`,renderer:()=>"gl.attach(el, { renderer, scene, camera }) needs your THREE.WebGLRenderer as `renderer`.",view:()=>"gl.view() draws on Umber's canvas, which is off on this device (createGL devices). gl.attach() with its own canvas can run this scene here.",define:e=>`gl.${e}(name, ${e==="chunk"?"glsl":"definition"}) needs a name and a ${e==="chunk"?"GLSL string":"definition object"}.`,loop:()=>"gl.render() was called while Umber runs its own loop (two loops?). Use createGL({ loop: false }) to drive it yourself.",render:()=>"gl.render() was called twice in one frame (two loops call it?). Call it from one loop only, with the frame time in ms: gsap.ticker.add((t) => gl.render(t * 1000)).",captureDpr:(e,n,t)=>`Frame-by-frame capture: GL draws at DPR ${+n.toFixed(2)}, not ${e}: this GPU draws at most ${t} px a side. Export smaller for GL as sharp as the text.`,captureWait:(e,n)=>`Frame-by-frame capture: ${l(e)} still isn't drawn after ${n} s; frames no longer wait for it. gl.inspect(el) says why.`};var T=(e,n)=>`${l(e.el)} has data-gl but is ${Math.round(e.doc.w)}\xD7${Math.round(e.doc.h)} px after ${n/1e3} s, so it draws nothing: hidden (display: none), or it has no size yet (an <img> without width/height, an empty box). Give it a size or aspect-ratio, or leave data-gl off hidden elements.`,W="The [data-gl-host] element left with a page swap and the new page has none, so Umber put it back first in <body>. Keep it across swaps (data-turbo-permanent, transition:persist, hx-preserve) or put one on every page.";function j(e,n){let t=typeof e=="string"?document.querySelector(e):e;if(!t||t.nodeType!==1)return n.log.warn(`gl.inspect(): ${typeof e=="string"?`nothing matches "${e}"`:"no element given"}.`),null;let s=t.matches(h)?t:t.closest(h)||t,r;if(n.stage)r=H(n.stage,s);else{let d=n.off?[`GL is off for this visit: ${p.reason(n.off)}`]:n.loading?["the GL runtime (chunks/gl.js) is still loading"]:[s.matches(h)?"GL has not started: no frame ran yet":"not a GL element: it has no data-gl attribute"];r={el:s,kind:null,status:"none",drawn:!1,why:d}}let i=r.notes?.length?` (${r.notes.join("; ")})`:"",a=r.drawn?`drawn${i}`:`not drawn: ${r.why.join("; ")}${i}`;return console.log(`[umber] inspect ${l(s)}: ${a}`,r),r}function H(e,n){let t=e.plane(n),s=[],r=[];if(e.failed?s.push("GL stepped aside after an error (see the [umber] error above); the DOM shows for this visit"):e.lost?s.push("the WebGL context is lost; the DOM shows until the browser gives it back"):e.hostReason?s.push(`GL is off: ${p.host(e.hostReason,e.ownHost)}`):e.paused&&s.push(e.forcedPause?"forced colours (High Contrast) are on: GL is paused":"gl.pause() was called (gl.resume() draws again)"),!t)return n.matches("[data-gl]")?n.isConnected?document.body?.hasAttribute("data-gl-disable")?s.push("<body> has data-gl-disable"):s.push("no plane yet (it arrived this frame; or call gl.scan(el))"):s.push("it is not in the page"):s.push("not a GL element: it has no data-gl attribute (and is not a gl.view() element)"),{el:n,kind:null,status:"none",drawn:!1,why:s,notes:r,source:"",tier:e.tier,effects:[],uniforms:{},program:null,rect:null,inView:!1,near:!1,texture:"none",modules:[],clips:[],geometry:null};for(let o of t.missing)o.startsWith("shader:")?s.push(`its shader "${o.slice(7)}" is not defined: gl.shader("${o.slice(7)||"name"}", { fragment })`):o.startsWith("module:")?s.push(`it needs the "${o.slice(7)}" module: load ${b[o.slice(7)]||`modules/${o.slice(7)}.js`}`):o.startsWith("chunk:")?s.push(o[6]?`#include "${o.slice(6)}" names no chunk: gl.chunk("${o.slice(6)}", glsl)`:"chunks/glsl.js (#include, shared helper names) is still downloading; its DOM shows until then"):r.push(`effect "${o}" is not defined (gl.effect("${o}", {...})); it draws without it`);let i=t.rect,a=window.innerWidth||e.screen.width,d=window.innerHeight||e.screen.height,M=a!==e.viewport.width||d!==e.viewport.height?`; the canvas is ${e.viewport.width}\xD7${e.viewport.height}`:"";if(t.domReason)s.push(`its DOM shows: ${(t.domReason==="oval"?p.oval(t.geomEl):t.domReason).replace(/^<[^>]+>: /,"")}`);else if(t.status==="error"||t.textureState==="error")s.push("it gave up and shows its DOM (see its [umber] warning: load failed, CORS, slow load or a shader error)");else if(!t.el.isConnected)s.push("it is not in the page");else{let o=t.measured&&(t.doc.w===0||t.doc.h===0);o&&s.push(`its box is ${Math.round(t.doc.w)}\xD7${Math.round(t.doc.h)} px (display: none, or no size yet)`),t.kind==="layer"?t._layer?.ready||s.push(e.layers?e.layers.waiting(t):"chunks/layers.js (three.js layers) is still downloading"):e.videoWaiting.has(t)?s.push("chunks/video.js (video and module frames) is still downloading; its DOM shows until then"):t.program?t.program.ready()||s.push("its shader is still compiling; its DOM shows until then"):s.push("it has no shader program (a compile error? see the console)"),t.kind!=="layer"&&t.kind!=="shader"&&!t.texture?.ready&&(t._mods.feed?s.push(`waiting for the first frame from its module (${t._mods.list.map(g=>g.name).join(", ")})`):t.textureState==="none"?o||s.push("its pixels have not started loading (it loads when it comes near the screen)"):t.textureState==="queued"?s.push("decoded, waiting for its GPU upload (one per frame)"):t.kind==="video"?s.push('its video has no frame yet (paused with preload="none", or still buffering)'):t.kind==="text"&&!e.text?s.push("chunks/text.js (GL text) is still downloading; the DOM text shows until then"):s.push(`its ${t.kind==="text"?"text is being painted":"image is loading"}`)),t.shapeWait&&s.push("chunks/shapes.js (what cuts, turns or tilts it) is still downloading; its DOM shows until then"),o||(t.opacity<=.001&&t._layer?.def.followOpacity!==!1?s.push("its opacity (or a parent's) is 0"):i[0]<a&&i[0]+i[2]>0&&i[1]<d&&i[1]+i[3]>0?t.clips?.cutBy&&e.shapes&&s.push(e.shapes.cutBy(t.clips.cutBy)):s.push(`it is off screen (at ${Math.round(i[0])}, ${Math.round(i[1])} px; the screen is ${a}\xD7${d}${M})`)),t.morphHidden&&s.push("a data-gl-id morph is drawing it right now (flying in)");let c=k(t.el,e.hostEl);c&&s.push(c)}let G=e.shapes?.report(t,r)||[];t.backHidden&&!t.domReason&&s.push("its back faces the viewer (backface-visibility: hidden), like its DOM");for(let o of t.nodes)o.tag!=="html"&&(o.filter!=="none"||o.backdropFilter!=="none")&&r.push(`${l(o.el)} has a CSS filter; GL draws the element without it`);let m=t.size,u=t.drawXf,$=[];for(let[o,c]of[[0,0],[m[0],0],[m[0],m[1]],[0,m[1]]]){let g=u[2]*o+u[5]*c+u[8];$.push([(u[0]*o+u[3]*c+u[6])/g,(u[1]*o+u[4]*c+u[7])/g])}let R={transform:t.level===2?"3d":t.level===1?"2d":"none",size:[m[0],m[1]],corners:$,live:V(e,t,performance.now())},v={},E=t.program?.state==="ok"?t.program.uniforms:null;for(let o in t.uniforms){let c=t.uniforms[o].value;v[o]={value:c instanceof e.Texture?`texture ${c.width}\xD7${c.height}`:ArrayBuffer.isView(c)?Array.from(c):c,used:E?E.has(o):null}}let f=t.media,N=t.kind==="shader"?`shader "${t.shader?.name||n.getAttribute("data-gl-shader")||""}"`:t.kind==="layer"?`layer "${t._layer?.name||""}"`:t.kind==="text"?"the element's text":t.kind==="group"?"the GL planes inside it (a group)":t._mods.feed?`module ${t._mods.list.map(o=>o.name).join(", ")}`:n.getAttribute("data-gl-src")||(f instanceof HTMLVideoElement||f instanceof HTMLImageElement?f.currentSrc||f.src:""),y=t.scrub;return{el:n,kind:t.kind,status:t.status,drawn:s.length===0&&t.status==="ready",why:s,notes:r,source:N,tier:y&&typeof y.tier=="string"?`${e.tier} \xB7 scrub ${y.tier}`:e.tier,effects:t.effects.map(o=>({name:o.name,options:{...o.options}})),uniforms:v,program:t.programKey?{key:t.programKey,ready:!!t.program?.ready()}:null,rect:{x:i[0],y:i[1],width:i[2],height:i[3]},inView:t.inView,near:t.near,texture:t.textureState,modules:t._mods.list.map(o=>o.name),clips:G,geometry:R}}function V(e,n,t){return n.animUntil>t?n.animUntil===1/0?n.animLabel:`${n.animLabel}, ${((n.animUntil-t)/1e3).toFixed(2)} s left`:n.scrollLinked?n.animLabel:n.el.hasAttribute("data-gl-live")?"data-gl-live":n.live?"a sticky or fixed parent":e.isLive(t)?"live mode (a page change, gl.live())":null}export{W as hostLeft,j as print,p as words,T as zero};
@@ -0,0 +1,93 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var I={info(){},warn:(s,...e)=>console.warn("[umber]",s,...e),once:(s,...e)=>console.warn("[umber]",s,...e),error:(s,...e)=>console.error("[umber]",s,...e)},x=I;function R(s){s&&(x=s)}function S(s){if(typeof s=="number"||typeof s=="boolean")return"float";if(Array.isArray(s)||ArrayBuffer.isView(s)){let e=s.length;return e===2?"vec2":e===3?"vec3":e===4?"vec4":e===9?"mat3":e===16?"mat4":null}return typeof s=="string"?"sampler2D":s&&typeof s=="object"?"highp sampler2D":null}var P=3,F=["float","vec2","vec3","vec4"],E="gl_Position = vec4(0.0, 0.0, 2.0, 1.0); return;";function $(s,e,n){let t=e.mode,o=t==="chars"||t==="words"||t==="lines",r=`uniform float uInstances;
3
+ uniform float uUmberWhole;
4
+ uniform vec4 uUmberInst;
5
+ float instance;
6
+ `,i=r+`flat out float vUmberInstance;
7
+ `,u=r+`flat in float vUmberInstance;
8
+ `,m=`instance = float(gl_InstanceID);
9
+ ${t==="echo"?`instance = uInstances - 1.0 - instance;
10
+ `:""}vUmberInstance = instance;
11
+ `,l=`instance = vUmberInstance;
12
+ `;if(t==="tiles"){let a=`tile = vec4(mod(instance, uUmberInst.x), floor(instance / uUmberInst.x), uUmberInst.xy);
13
+ tileCenter = (tile.xy + 0.5) / tile.zw;
14
+ `;i+=`vec4 tile;
15
+ vec2 tileCenter;
16
+ `,u+=`vec4 tile;
17
+ vec2 tileCenter;
18
+ `,m+=`${a}uv = (tile.xy + aPosition) / tile.zw;
19
+ vUv = uv;
20
+ `,l+=a}else if(o)i+=`layout(location = 1) in vec4 unitBox;
21
+ layout(location = 2) in vec4 unitValue;
22
+ flat out vec4 vUmberBox;
23
+ flat out vec4 vUmberUnit;
24
+ `,u+=`flat in vec4 vUmberBox;
25
+ flat in vec4 vUmberUnit;
26
+ vec4 unitBox;
27
+ vec4 unitValue;
28
+ `,m+=`vUmberBox = unitBox;
29
+ vUmberUnit = unitValue;
30
+ if (uUmberWhole < 0.5) {
31
+ uv = unitBox.xy + aPosition * unitBox.zw;
32
+ vUv = uv;
33
+ }
34
+ `,l+=`unitBox = vUmberBox;
35
+ unitValue = vUmberUnit;
36
+ `;else if(t==="echo")i+=`layout(location = 1) in vec2 echoOffset;
37
+ flat out vec2 vUmberEcho;
38
+ `,u+=`flat in vec2 vUmberEcho;
39
+ vec2 echoOffset;
40
+ `,m+=`vUmberEcho = echoOffset;
41
+ if (instance > 0.5 && dot(echoOffset, echoOffset) < 0.0025) { ${E} }
42
+ pos.xy += echoOffset;
43
+ `,l+=`echoOffset = vUmberEcho;
44
+ `;else if(t==="ink"){let a=v=>`int umberW = int(uUmberInst.y);
45
+ inkPoint = texelFetch(uUmberInk, ivec2(${v} % umberW, ${v} / umberW), 0);
46
+ `,h=`uniform highp sampler2D uUmberInk;
47
+ vec4 inkPoint;
48
+ `;i+=h,u+=h,m+=`${a("gl_InstanceID")}if (uUmberWhole < 0.5) {
49
+ if (inkPoint.w < 0.5) { ${E} }
50
+ uv = inkPoint.xy + (aPosition - 0.5) * uUmberInst.x / uSize;
51
+ vUv = uv;
52
+ }
53
+ `,l+=a("int(instance + 0.5)")}for(let a of n)i+=`layout(location = ${a.loc}) in ${F[a.size-1]} ${a.name};
54
+ `;let c=s.effects.map(({def:a})=>`${a.vertex?.head||""}
55
+ ${a.vertex?.main||""}`).join(`
56
+ `),d=s.effects.map(({def:a})=>`${a.vertex?.head||""}
57
+ ${a.fragment?.head||""}`).join(`
58
+ `),f={...s.uniforms};delete f.uUmberInk;for(let a in s.uniforms){let h=S(s.uniforms[a]);!h?.includes("sampler")||!new RegExp(`\\b${a}\\b`).test(c)||new RegExp(`uniform\\s+(\\w+\\s+)?\\w+\\s+${a}\\b`).test(d)||(i+=`uniform ${h} ${a};
59
+ `,u+=`uniform ${h} ${a};
60
+ `,delete f[a])}let p=s.chunks||{vertex:"",fragment:""};return{...s,uniforms:f,effects:[{name:"instances",def:{vertex:{main:m},fragment:{uv:l}}},...s.effects],chunks:{vertex:`// instances
61
+ ${i}
62
+ ${p.vertex}`,fragment:`// instances
63
+ ${u}
64
+ ${p.fragment}`}}}var k=.1,b=256,C=.05,M=["lines","words","chars"],B=`
65
+ float umberRand(uint x) {
66
+ x ^= x >> 16; x *= 0x7feb352du; x ^= x >> 15; x *= 0x846ca68bu; x ^= x >> 16;
67
+ return float(x) / 4294967295.0;
68
+ }
69
+ // The plane's object-fit (shaders.ts fitUv) with the plane's own numbers.
70
+ vec2 umberFit(vec2 uv) {
71
+ if (uFitMode > 1.5) return uv;
72
+ vec2 r = uPlane / max(uImg, vec2(1.0));
73
+ float s = uFitMode < 0.5 ? max(r.x, r.y) : min(r.x, r.y);
74
+ vec2 sc = uImg * s;
75
+ return (uv * uPlane - (uPlane - sc) * uFitPos) / sc;
76
+ }
77
+ vec4 color(vec2 uv) {
78
+ vec2 id = floor(uv * uSize);
79
+ float n = id.y * uSize.x + id.x;
80
+ if (n >= uCount) return vec4(0.0);
81
+ uint base = uint(n) * 151u + 7u;
82
+ for (int k = 0; k < 48; k++) {
83
+ uint s = base * 48u + uint(k) * 3u;
84
+ vec2 p = vec2(umberRand(s), umberRand(s + 1u));
85
+ vec2 f = umberFit(p);
86
+ if (f.x < 0.0 || f.y < 0.0 || f.x > 1.0 || f.y > 1.0) continue;
87
+ vec4 c = texture(uSource, f);
88
+ float ink = uLuma > 0.5 ? dot(c.rgb, vec3(0.2126, 0.7152, 0.0722)) * c.a : c.a;
89
+ if (ink > 0.02 + 0.96 * umberRand(s + 2u)) return vec4(p, ink, 1.0);
90
+ }
91
+ return vec4(0.0);
92
+ }
93
+ `;function N(s){let e=Math.imul(s^2654435769,2246822507);return e=Math.imul(e^e>>>13,3266489909),((e^e>>>16)>>>0)/4294967296}var w=class{constructor(e,n,t,o){this.stage=e;this.plane=n;this.spec=t;this.grid=null;this.vao=null;this.cols=[];this.attrs=[];this.ja=new Float32Array(4);this.hist=new Float64Array(b*3);this.head=0;this.ca=0;this.moving=!1;this.version=-1;this.seeds=null;this.seeded=null;this.qc=new Float64Array(4);this.fx=null;this.gl=e.gl,this.count=t.count;let r=t.mode,i=r==="chars"||r==="words"||r==="lines";this.whole=i||r==="ink",r==="tiles"&&this.ja.set([t.cols,t.rows]),i&&this.cols.push(this.column(1,4),this.column(2,4)),r==="echo"&&this.cols.push(this.column(1,2));let u=P,m=new Set;for(let{name:l,def:c}of o)for(let d in c.attributes||{}){if(m.has(d))continue;m.add(d);let f=c.attributes[d],p=typeof f=="function"?f(0,this.count):0,a=typeof f=="number"?f:Array.isArray(p)||ArrayBuffer.isView(p)?p.length:1;if(!(a>=1&&a<=4)||u>15){x.warn(`effect "${l}": attribute ${d} ${u>15?"is one too many (13 per plane)":"needs a size of 1 to 4 (a number, or a function returning 1 to 4 numbers)"}; it is left out.`,n.el);continue}this.attrs.push({name:d,size:a,loc:u});let h=this.column(u++,a);h.name=d,h.fill=f,this.cols.push(h)}if(this.xb(),this.key=`|i:${r}${this.attrs.map(l=>`,${l.name}${l.size}`).join("")}`,r==="ink"){this.ja[0]=t.size;let l=this;n.uniforms.uUmberInk={value:{get texture(){return l.seeds?.texture||null}}},e.loadFx().then(c=>{this.fx=c,e.markDirty()})}this.api=this.handle()}column(e,n){return{loc:e,size:n,data:new Float32Array(Math.max(1,this.count)*n),buf:null,held:0,dirty:!0}}xb(){for(let e of this.cols)if(e.name){e.data.length!==Math.max(1,this.count)*e.size&&(e.data=new Float32Array(Math.max(1,this.count)*e.size));for(let n=0;n<this.count;n++){let t=typeof e.fill=="function"?e.fill(n,this.count):null;for(let o=0;o<e.size;o++)e.data[n*e.size+o]=t==null?N(n*4+o+e.loc*65536):typeof t=="number"?t:+t[o]||0}e.dirty=!0}}handle(){let e=this,n=t=>{let o=e.cols.find(r=>r.name===t);return o||x.warn(`plane.instances: no attribute "${t}" (effects declare them: attributes: { ${t}: 2 }). It has: ${e.attrs.map(r=>r.name).join(", ")||"none"}.`,e.plane.el),o};return{get count(){return e.count},get mode(){return e.spec.mode},data(t){return n(t)?.data||null},set(t,o){let r=n(t);return r&&(r.data.set(Array.prototype.slice.call(o,0,r.data.length)),this.update(t)),this},update(t){for(let o of e.cols)o.name&&(!t||o.name===t)&&(o.dirty=!0);e.stage.markDirty()}}}build(e){return $(e,this.spec,this.attrs)}wrap(e){return this.grid!==e&&this.drop(),this.grid=e,this}update(e,n){let t=this.spec.mode;return t==="echo"?this.echo(e,n):t==="ink"?this.ink():t==="chars"||t==="words"||t==="lines"?this.units():!1}at(e){return(this.head+e)%b*3}push(e,n,t){let o=this.at(this.ca);this.ca<b?this.ca++:this.head=(this.head+1)%b,this.hist[o]=e,this.hist[o+1]=n,this.hist[o+2]=t}echo(e,n){let t=this.hist,o=n[0],r=n[1];this.ca||this.push(e,o,r);let i=this.at(this.ca-1);e-t[i]>C&&this.push(e-1/60,t[i+1],t[i+2]),i=this.at(this.ca-1);let u=this.count*this.spec.delay+k;e>t[i]&&(this.ca<2||t[i]-t[this.at(this.ca-2)]>=u/(b-4))?this.push(e,o,r):(t[i]=Math.max(t[i],e),t[i+1]=o,t[i+2]=r);let m=e-u;for(;this.ca>2&&t[this.at(1)]<m;)this.head=(this.head+1)%b,this.ca--;let l=this.cols[0],c=l.data,d=!1,f=this.ca-1;for(let a=1;a<this.count;a++){let h=e-a*this.spec.delay;for(;f>0&&t[this.at(f)]>h;)f--;let v=this.at(f),g=this.at(Math.min(f+1,this.ca-1)),U=t[g]>t[v]?Math.min(1,Math.max(0,(h-t[v])/(t[g]-t[v]))):0,y=(this.count-1-a)*2;c[y]=t[v+1]+(t[g+1]-t[v+1])*U-o,c[y+1]=t[v+2]+(t[g+2]-t[v+2])*U-r,(Math.abs(c[y])>.05||Math.abs(c[y+1])>.05)&&(d=!0)}let p=d||this.moving;return this.moving=d,p&&(l.dirty=!0),p}units(){let e=this.plane,n=e.text,t=n?.[this.spec.mode];if(!n||!t?.length)return!1;let[o,r]=this.cols,i=!1;if(n.version!==this.version||this.whole){if(this.version=n.version,this.whole=!1,this.count!==t.length){this.count=t.length;for(let f of this.cols)f.data=new Float32Array(this.count*f.size);this.xb()}let c=e.layoutW+2*e.pad||1,d=e.layoutH+2*e.pad||1;t.forEach((f,p)=>{let a=f.box;o.data.set([(a.x+e.pad)/c,(a.y+e.pad)/d,a.w/c,a.h/d],p*4)}),o.dirty=i=!0}let u=n.values,m=n.base[M.indexOf(this.spec.mode)]*4,l=r.data;for(let c=0;c<this.count*4;c++)l[c]!==u[m+c]&&(l[c]=u[m+c]||0,r.dirty=i=!0);return i}ink(){let e=this.plane,n=e.texture,t=this.fx,o=n?.ready?n.texture:null,r=e.text?e.text.version:o,i=this.qc,u=e.fit<2?Math.round(e.size[0]/(e.size[1]||1)*1e3):0,m=i[0]===u&&i[1]===e.fit&&i[2]===e.fitPosition[0]&&i[3]===e.fitPosition[1];if(!t||!o||r===this.seeded&&m||this.stage.lost)return!1;this.seeded=r,i[0]=u,i[1]=e.fit,i[2]=e.fitPosition[0],i[3]=e.fitPosition[1];let l=this.count,c=Math.min(256,Math.ceil(Math.sqrt(l)));return this.ja[1]=c,this.seeds||(this.seeds=t.make({width:c,height:Math.ceil(l/c),type:"half",quiet:!0,msaa:0,attachments:1}),this.seeds.type==="u8"&&x.once(`data-gl-instances="ink": this GPU can't render to half-float targets, so particles sit on a grid of 1/255 of the plane (visible on large planes).`)),this.seeds.draw(B,{uSource:{get texture(){return e.texture?.texture||null}},uPlane:new Float32Array(e.size),uImg:new Float32Array([n.width,n.height]),uFitMode:e.fit,uFitPos:new Float32Array(e.fitPosition),uLuma:this.spec.luma?1:0,uCount:l}),this.whole=!1,!0}draw(){let e=this.gl,n=this.grid;if(!this.vao){this.vao=e.createVertexArray(),e.bindVertexArray(this.vao),e.bindBuffer(e.ARRAY_BUFFER,n.buffers[0]),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.buffers[1]);for(let r of this.cols)r.buf=e.createBuffer(),r.held=0,r.dirty=!0,e.bindBuffer(e.ARRAY_BUFFER,r.buf),e.enableVertexAttribArray(r.loc),e.vertexAttribPointer(r.loc,r.size,e.FLOAT,!1,0,0),e.vertexAttribDivisor(r.loc,1)}for(let r of this.cols)r.dirty&&(r.dirty=!1,e.bindBuffer(e.ARRAY_BUFFER,r.buf),r.held!==r.data.length?e.bufferData(e.ARRAY_BUFFER,r.data,e.DYNAMIC_DRAW):e.bufferSubData(e.ARRAY_BUFFER,0,r.data),r.held=r.data.length);let t=this.plane.program,o=this.whole?1:this.count;t.set("uInstances",this.count),t.set("uUmberWhole",this.whole?1:0),t.set("uUmberInst",this.ja),e.bindVertexArray(this.vao),e.drawElementsInstanced(e.TRIANGLES,n.count,e.UNSIGNED_SHORT,0,o)}drop(){let e=this.gl;if(this.vao&&!this.stage.lost){e.deleteVertexArray(this.vao);for(let n of this.cols)e.deleteBuffer(n.buf)}this.vao=null}lost(){this.vao=null,this.grid=null,this.seeded=null,this.spec.mode==="ink"&&(this.whole=!0)}dispose(){this.drop(),this.seeds?.release(),this.seeds=null}};var D=["chars","words","lines"],_=s=>s!==void 0&&/^-?[\d.]+$/.test(s)?+s:NaN;function z(s){let e=s&&typeof s=="object"?Object.entries(s).map(([r,i])=>`${r} ${Array.isArray(i)?i.join("x"):i}`).join(" "):String(s),n={mode:"count",count:1,cols:8,rows:8,delay:.05,size:2,luma:!1},t=!1,o=e.toLowerCase().split(/[\s,]+/).filter(Boolean);if(!o.length)return"it is empty";for(let r=0;r<o.length;r++){let i=o[r],u=_(o[r+1]),m=/^(\d+)x(\d+)$/.exec(i);if(m)n.mode="tiles",n.cols=+m[1],n.rows=+m[2];else if(!isNaN(_(i)))n.count=_(i),t=!0;else if(D.includes(i))n.mode=i;else if(i==="luma"||i==="alpha")n.luma=i==="luma";else if(i==="tiles")n.mode="tiles";else if(i==="echo"||i==="ink"||i==="count")n.mode=i,isNaN(u)||(n.count=u,t=!0,r++);else if(i==="delay"||i==="size"){if(isNaN(u))return`"${i}" needs a number after it`;n[i]=u,r++}else if(i!=="units"&&i!=="source")return`"${i}" is not a word it knows`}return t||(n.count=n.mode==="echo"?6:n.mode==="ink"?2e3:1),n.mode==="tiles"&&(n.count=n.cols*n.rows),!(n.count>=1)||!(n.cols>=1)||!(n.rows>=1)?"its count is below 1":(n.count=Math.min(Math.round(n.count),n.mode==="echo"?64:65536),n.mode==="tiles"&&n.cols*n.rows>65536?`${n.cols} x ${n.rows} tiles is more than 65536`:(n.delay=Math.max(.001,n.delay),n.size=Math.max(.5,n.size),n))}var A=class{constructor(e){this.stage=e}part(e,n){let t=z(n),o=e.el;if(typeof t=="string"){x.warn(`data-gl-instances="${typeof n=="object"?JSON.stringify(n):n}": ${t}, so it draws once. Write a count ("64"), "tiles 24x16", "chars", "words", "lines", "echo 6" or "ink 3000".`,o);return}if((t.mode==="chars"||t.mode==="words"||t.mode==="lines")&&e.kind!=="text"){x.warn(`data-gl-instances="${t.mode}" is for data-gl="text" planes (one quad per ${t.mode.slice(0,-1)}); this one draws once.`,o);return}if(t.mode==="ink"&&e.kind==="shader"){x.warn(`data-gl-instances="ink" seeds particles from an image, video or text plane's pixels; a shader surface has none to read, so it draws once.`,o);return}let i=new w(this.stage,e,t,e.effects);e._inst=i,Object.defineProperty(e,"instances",{value:i.api,configurable:!0,enumerable:!0}),e._mods.list.push({name:"instances",binding:{update:u=>i.update(u.time,e.rect),lost:()=>i.lost(),destroy:()=>i.dispose()}})}};function K(s){return R(s.host.log),new A(s)}export{A as Instances,K as instances};
@@ -0,0 +1,21 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var F={info(){},warn:(a,...e)=>console.warn("[umber]",a,...e),once:(a,...e)=>console.warn("[umber]",a,...e),error:(a,...e)=>console.error("[umber]",a,...e)},m=F;function I(a){a&&(m=a)}function C(a){if(!a||typeof a.tagName!="string")return"<?>";let e=a.tagName.toLowerCase();if(a.id)return`<${e}#${a.id}>`;let r=typeof a.className=="string"?a.className.trim().split(/\s+/)[0]:"";return r?`<${e}.${r}>`:`<${e}>`}var D="uniformMatrix2fv,uniformMatrix3fv,uniformMatrix4fv,,,,,,,,,uniformMatrix2x3fv,uniformMatrix2x4fv,uniformMatrix3x2fv,uniformMatrix3x4fv,uniformMatrix4x2fv,uniformMatrix4x3fv".split(","),L=class{constructor(e,r,t,i="program"){this.gl=e;this.vertex=r;this.fragment=t;this.label=i;this.uniforms=new Map;this.samplers=[];this.state="pending";this.error=null;this.shaders=[];this.Ka=globalThis.occluzeCapture?.version==1?null:e.getExtension("KHR_parallel_shader_compile");let s=N(e,e.VERTEX_SHADER,r),n=N(e,e.FRAGMENT_SHADER,t),o=e.createProgram();e.attachShader(o,s),e.attachShader(o,n),e.bindAttribLocation(o,0,"aPosition"),e.linkProgram(o),this.program=o,this.shaders=[s,n],this.Ka||this.finalize()}ready(){return this.state!=="pending"?this.state==="ok":this.Ka&&!this.gl.getProgramParameter(this.program,this.Ka.COMPLETION_STATUS_KHR)?!1:(this.finalize(),this.state==="ok")}get failed(){return this.state==="failed"}finalize(){let e=this.gl,r=this.program;if(!e.getProgramParameter(r,e.LINK_STATUS)){let[i,s]=this.shaders;this.error=G(e,i,"vertex",this.vertex,this.label)||G(e,s,"fragment",this.fragment,this.label)||["link",this.label,e.getProgramInfoLog(r)||"",""],this.Pa(),e.deleteProgram(r),this.state="failed";return}this.Pa();let t=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let i=0;i<t;i++){let s=e.getActiveUniform(r,i);if(!s)continue;let n=s.name.replace(/\[0\]$/,""),o=e.getUniformLocation(r,s.name);o&&(this.uniforms.set(n,{loc:o,type:s.type,size:s.size}),(s.type===e.SAMPLER_2D||s.type===e.UNSIGNED_INT_SAMPLER_2D)&&this.samplers.push(n))}this.state="ok"}Pa(){for(let e of this.shaders)this.gl.deleteShader(e);this.shaders=[]}set(e,r){let t=this.state==="ok"?this.uniforms.get(e):void 0;if(!t||r==null)return;let i=this.gl,s=t.type;if(typeof r=="number"){if(t.last===r)return;t.last=r,s===i.FLOAT?i.uniform1f(t.loc,r):s===i.UNSIGNED_INT?i.uniform1ui(t.loc,r):i.uniform1i(t.loc,r);return}let n=r,o=t.last;if(o?.length===n.length){let h=n.length;for(;h--&&o[h]===n[h];);if(h<0)return}else o=t.last=[];for(let h=0;h<n.length;h++)o[h]=n[h];s===i.FLOAT_VEC2?i.uniform2fv(t.loc,n):s===i.FLOAT_VEC3?i.uniform3fv(t.loc,n,0,Math.min(n.length,t.size*3)):s===i.FLOAT_VEC4?i.uniform4fv(t.loc,n):D[s-i.FLOAT_MAT2]?i[D[s-i.FLOAT_MAT2]](t.loc,!1,n):s===i.FLOAT?i.uniform1fv(t.loc,n):i[`uniform${n.length/t.size}${s===i.UNSIGNED_INT||s>=i.UNSIGNED_INT_VEC2?"u":""}iv`]?.(t.loc,n)}dispose(){this.Pa(),this.state!=="failed"&&this.gl.deleteProgram(this.program)}};function N(a,e,r){let t=a.createShader(e);return a.shaderSource(t,r),a.compileShader(t),t}function G(a,e,r,t,i){return e&&!a.getShaderParameter(e,a.COMPILE_STATUS)?[r,i,a.getShaderInfoLog(e)||"",t]:null}var O=`#version 300 es
3
+ layout(location=0)in vec2 aPosition;
4
+ uniform vec2 uCanvas;
5
+ uniform vec4 uRect;
6
+ out vec2 vUv;
7
+ void main(){
8
+ vUv=aPosition;
9
+ vec2 px=uRect.xy+aPosition*uRect.zw;
10
+ gl_Position=vec4(px/uCanvas*2.0-1.0,0.0,1.0);
11
+ }
12
+ `,W=`#version 300 es
13
+ precision highp float;
14
+ in vec2 vUv;
15
+ uniform sampler2D uImage;
16
+ uniform float uAlpha;
17
+ out vec4 outColor;
18
+ void main(){
19
+ outColor=texture(uImage,vUv)*uAlpha;
20
+ }
21
+ `,A=class{constructor(e){this.gl=e;this.program=null;this.qa=[];this.rect=[]}get(){return this.program||=new L(this.gl,O,W,"layer fade")}draw(e,r,t,i,s){let n=this.get();if(!n.ready())return!1;let o=this.gl,h=this.qa,c=this.rect;return h[0]=i.width,h[1]=i.height,c[0]=r.x,c[1]=r.y,c[2]=r.dw,c[3]=r.dh,o.useProgram(n.program),n.set("uCanvas",h),n.set("uRect",c),n.set("uAlpha",t),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,e),n.set("uImage",0),s.draw(),!0}forget(){this.program=null}dispose(){this.program?.dispose(),this.program=null}};function w(a,e,r){a.bindFramebuffer(a.FRAMEBUFFER,null),a.viewport(0,0,e,r),a.disable(a.SCISSOR_TEST),a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.frontFace(a.CCW),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.disable(a.SAMPLE_COVERAGE),a.depthMask(!0),a.colorMask(!0,!0,!0,!0),a.enable(a.BLEND),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),a.useProgram(null),a.bindVertexArray(null),a.activeTexture(a.TEXTURE0),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL)}function M(a,e,r,t){return t.x=Math.round(a.x*r),t.y=Math.round((e-a.y-a.height)*r),t.width=Math.max(0,Math.round(a.width*r)),t.height=Math.max(0,Math.round(a.height*r)),t}var P=class{constructor(e){this.stage=e;this.Yb={x:0,y:0,width:0,height:0};this.full={x:0,y:0,width:0,height:0};this.ask={x:0,y:0,width:0,height:0};this.view={px:{x:0,y:0,width:0,height:0},dpr:1,clip:{x:0,y:0,width:0,height:0}};this.fade=new A(e.gl)}upright(e){this.stage.warnOnce(e,`${C(e.el)}: a three.js layer is drawn upright; GL can't turn or tilt a layer's own drawing. Turn the camera in your scene instead.`)}begin(e,r){w(this.stage.gl,this.stage.canvas.width,this.stage.canvas.height);for(let t of e)t._layer?.ready&&this.captured(t)&&this.capture(t,r,this.scale(t))}create(e){let r=this.stage,t=e.el,i=t.getAttribute("data-gl-layer")||"",s=r.registry.layers.get(i);return!s||typeof s.render!="function"?(m.warn(`data-gl="layer" needs data-gl-layer="name" and gl.layer("${i||"name"}", { setup, render }).`),e.setStatus("error"),!1):(t.hasAttribute("data-gl-effect")&&m.once(`data-gl-effect is ignored on layers ("${i}"): a layer draws itself.`),this.build(e,i,s,r.readOptions(t,"data-gl-layer",s.options||{})),!0)}build(e,r,t,i){e._layer=new U(r,t,this.context(e,r,i),this,e),this.fade.get()}setup(e){let r=this.stage,t=e._layer;e.textureState="loading";let i=++t.gen,s;try{s=t.def.setup?.(t.ctx)}catch(n){return this.failed(e,"setup",n)}Promise.resolve(s).then(n=>{if(i!==t.gen||!r.planes.includes(e)||r.lost){try{typeof n=="function"&&n()}catch(o){m.error(`layer "${t.name}" cleanup failed`,o)}return}w(r.gl,r.canvas.width,r.canvas.height),t.cleanup=n,t.ready=!0,t.sizeKey=-1,e.textureState="ready",e.resolveLoaded(),r.wake(2)},n=>{i===t.gen&&this.failed(e,"setup",n)})}failed(e,r,t){m.error(`layer "${e._layer?.name}" ${r} failed; its element keeps its DOM content.`,t),e._layer&&(e._layer.ready=!1),e.textureState="error",e.setStatus("error")}cut(e,r){let t=e.clips?.ga?e.clips.scissorPx:null;if(!t)return r;let i=this.Yb;return i.x=Math.max(r.x,t[0]),i.y=Math.max(r.y,t[1]),i.width=Math.max(0,Math.min(r.x+r.width,t[0]+t[2])-i.x),i.height=Math.max(0,Math.min(r.y+r.height,t[1]+t[3])-i.y),i}context(e,r,t){let i=this.stage,s=this,n={name:r,el:e.el,gl:i.gl,canvas:i.canvas,options:t,state:{},engine:i.host.engine,rect:{x:0,y:0,width:0,height:0},px:{x:0,y:0,width:0,height:0},viewport:i.viewport,dpr:1,mouse:{x:.5,y:.5},scrollVelocity:0,opacity:1,time:0,frame:null,get reducedMotion(){return i.reducedMotion},wake(o){i.wake(o)},busy(o){o?e.busyReasons.add(`layer:${r}`):e.busyReasons.delete(`layer:${r}`),i.markDirty()},three(o){let h=n.px;if(o.resetState?.(),o.autoClear=!1,o.setViewport?.(h.x,h.y,h.width,h.height),e._layer?.def.scissor!==!1){let c=e._layer?.clip||s.cut(e,h);o.setScissor?.(c.x,c.y,c.width,c.height),o.setScissorTest?.(!0)}}};return n}draw(e,r,t){let i=this.stage,s=e._layer,n=s.ctx,o=e.rect;n.rect.x=o[0],n.rect.y=o[1],n.rect.width=o[2],n.rect.height=o[3],t?(Object.assign(n.px,t.px),n.dpr=t.dpr):(n.dpr=i.dpr*i.scale,M(n.rect,i.viewport.height,n.dpr,n.px)),s.clip=t?t.clip:null,n.time=i.time,n.frame=r,n.scrollVelocity=i.velocity,n.opacity=e.opacity,n.mouse.x=(i.pointer.x-o[0])/Math.max(o[2],1),n.mouse.y=(i.pointer.y-o[1])/Math.max(o[3],1);let h=i.gl,c=n.px.width*65536+n.px.height;try{if(c!==s.sizeKey&&(s.sizeKey=c,s.def.resize?.(n)),s.def.scissor!==!1){let d=s.clip||this.cut(e,n.px);h.enable(h.SCISSOR_TEST),h.scissor(d.x,d.y,d.width,d.height)}h.viewport(n.px.x,n.px.y,n.px.width,n.px.height),h.depthMask(!0),h.clear(h.DEPTH_BUFFER_BIT),s.def.render(n)}catch(d){this.failed(e,"render",d)}w(h,i.canvas.width,i.canvas.height)}capture(e,r,t){let i=this.stage,s=i.gl,n=e._layer,o=i.canvas.width,h=i.canvas.height,c=i.dpr*i.scale,d=this.full,y=this.ask;if(n.def.scissor!==!1){let p=e.rect;y.x=p[0],y.y=p[1],y.width=p[2],y.height=p[3],M(y,i.viewport.height,c,d)}else d.x=d.y=0,d.width=o,d.height=h;let g=Math.max(0,d.x),u=Math.max(0,d.y),l=Math.min(o,d.x+d.width)-g,f=Math.min(h,d.y+d.height)-u;if(n.def.scissor!==!1&&e.clips?.ga){y.x=g,y.y=u,y.width=l,y.height=f;let p=this.cut(e,y);g=p.x,u=p.y,l=p.width,f=p.height}if(l<1||f<1)return this.freeFade(e);let R=t<1?0:g,x=t<1?0:u,_=Math.max(1,Math.round(l*t)),b=Math.max(1,Math.round(f*t)),T=this.view,v=T.clip;if(v.x=R,v.y=x,v.width=_,v.height=b,T.px.x=Math.round(R-(g-d.x)*t),T.px.y=Math.round(x-(u-d.y)*t),T.px.width=Math.max(0,Math.round(d.width*t)),T.px.height=Math.max(0,Math.round(d.height*t)),T.dpr=c*t,s.enable(s.SCISSOR_TEST),s.scissor(R,x,_,b),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),this.draw(e,r,t<1?T:void 0),n.clip=null,!n.ready)return this.freeFade(e);let E=n.fade;if(!E||E.width!==_||E.height!==b){let p=E?.texture||s.createTexture();if(!p)return;s.bindTexture(s.TEXTURE_2D,p),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,_,b,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),E=n.fade={texture:p,width:_,height:b,x:g,y:u,dw:l,dh:f}}E.x=g,E.y=u,E.dw=l,E.dh=f,s.bindTexture(s.TEXTURE_2D,E.texture),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,R,x,_,b)}scale(e){let r=e._layer?.def.dpr,t=this.stage.dpr*this.stage.scale;return r&&r>0&&r<t-.01?r/t:1}alpha(e){return e._layer?.def.followOpacity===!1?1:e.opacity}captured(e){return this.scale(e)<1||this.alpha(e)<.999}drawFade(e,r){let t=this.stage;if(!this.fade.draw(e._layer.fade.texture,e._layer.fade,this.alpha(e),t.canvas,t.programs.grid(1))){let i=this.fade.get();i.failed&&m.once(`layer fade: ${i.error[2]}`),this.draw(e,r)}}waiting(e){return e.near?"its layer is still setting up":"its layer sets up when it comes near the screen"}freeFade(e){let r=e._layer;r?.fade&&(this.stage.lost||this.stage.gl.deleteTexture(r.fade.texture),r.fade=null)}render(e,r){e._layer.fade&&this.captured(e)?this.drawFade(e,r):(this.freeFade(e),this.draw(e,r))}},U=class{constructor(e,r,t,i,s){this.name=e;this.def=r;this.ctx=t;this.owner=i;this.plane=s;this.ready=!1;this.sizeKey=-1;this.gen=0;this.fade=null;this.clip=null}stop(){try{typeof this.cleanup=="function"&&this.cleanup()}catch(e){m.error(`layer "${this.name}" cleanup failed`,e)}}lost(){this.stop(),this.cleanup=void 0,this.ready=!1,this.gen++,this.fade=null}dispose(){this.stop(),this.gen++,this.owner.freeFade(this.plane)}};var S=class{constructor(e){this.stage=e;this.renderer=null;this.entries=new Set}create(e,r={}){if(this.renderer)return this.renderer;let t=e?.WebGLRenderer;if(typeof t!="function")return m.warn('gl.renderer(THREE) needs the three.js module itself: import * as THREE from "three"; gl.renderer(THREE).'),null;let i=this.stage;if(i.lost)return null;let s;try{s=new t({...r,canvas:i.canvas,context:i.gl})}catch(n){return m.error("gl.renderer(THREE): three.js could not use Umber's WebGL2 context",n),null}return s.autoClear=!1,s.setPixelRatio?.(1),s.setSize?.(i.canvas.width,i.canvas.height,!1),this.renderer=s,w(i.gl,i.canvas.width,i.canvas.height),i.wake(1),s}resized(e,r){this.renderer?.setSize?.(e,r,!1)}view(e){let r=this.stage,t=e.options;!t.render&&!this.renderer&&m.warn("gl.view() draws with gl.renderer(THREE): call (and await) that first, or pass render(f) to draw yourself.");let i=null,s=!1,n=this,o=()=>r.reducedMotion,h={time:0,dt:0,ratio:1,frame:0,width:0,height:0,dpr:1,rect:e.tracker.rect,progress:0,velocity:0,reducedMotion:!1,renderer:null,scene:t.scene,camera:t.camera,view:e.view},c=l=>{let f=l.frame;return h.time=l.time,h.dt=f?.dt??0,h.ratio=f?.ratio??1,h.frame=f?.frame??0,h.width=l.rect.width,h.height=l.rect.height,h.dpr=l.dpr,h.rect=e.tracker.rect,h.progress=i?.progress??0,h.velocity=f?.scroll.velocity??0,h.reducedMotion=o(),h.renderer=n.renderer,h},d=typeof t.dpr=="number"?t.dpr:Array.isArray(t.dpr)?t.dpr[1]:void 0,y={setup:t.setup?()=>t.setup({el:e.el,renderer:n.renderer,scene:t.scene,camera:t.camera,view:e.view}):void 0,render(l){let f=c(l);t.animate?.(f)===!0&&!f.reducedMotion?i.busyReasons.add("view:animate"):i.busyReasons.delete("view:animate");let x=n.renderer;x&&l.three(x),t.render?t.render(f):x?.render(t.scene,t.camera),s||(s=!0,e.setStatus("ready"))},resize(l){let f=t.camera;t.aspect!==!1&&f?.isPerspectiveCamera&&l.rect.height>0&&(f.aspect=l.rect.width/l.rect.height,f.updateProjectionMatrix?.()),t.resize?.(c(l)),e.emit("resize")},animate:!1,scissor:t.scissor,followOpacity:t.followOpacity,dpr:d};if(r.plane(e.el))return m.warn("gl.view(el): this element already has a GL plane (data-gl); give the view its own element.",e.el),null;i=r.addView(e.el,y);let g={plane:i,state:e,redraw:()=>s=!1};this.entries.add(g);let u=i;u.on("error",()=>e.setStatus("error","render")),u.on("destroy",()=>{this.entries.delete(g),e.destroyed||e.view.destroy()});for(let l of e.busy)u.busyReasons.add(`view:${l}`);return e.wanted&&r.wake(e.wanted),{wake(l){r.wake(l)},busy(){for(let l of[...u.busyReasons])l.startsWith("view:")&&l!=="view:animate"&&u.busyReasons.delete(l);for(let l of e.busy)u.busyReasons.add(`view:${l}`);r.markDirty()},get width(){return Math.round(u.rect[2])},get height(){return Math.round(u.rect[3])},get dpr(){return u._layer?.ctx.dpr||0},destroy(){u.destroyed||r.removePlane(u)}}}lost(){for(let{state:e,redraw:r}of this.entries)r(),e.setStatus("lost"),e.emit("lost")}restored(){for(let{state:e}of this.entries)e.emit("restored")}dispose(){try{this.renderer?.dispose?.()}catch(e){m.error("the shared three.js renderer failed to dispose",e)}this.renderer=null}};function ie(a){I(a.host.log),a.layers=new P(a);let e=a.views=new S(a);for(let r of a.planes.slice())r.kind==="layer"&&!r._layer&&r.el.isConnected&&a.rebuild(r);return e}export{ie as layers};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ var c="https://umber.occluze.com/v1/check?h=",a=/^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/;function r(){let o=location.hostname;if(!o||a.test(o))return Promise.resolve(!0);let e=new AbortController,n=setTimeout(()=>e.abort(),4e3),s=AbortSignal.any&&AbortSignal.timeout?AbortSignal.any([e.signal,AbortSignal.timeout(4e3)]):e.signal;return fetch(c+encodeURIComponent(o),{credentials:"omit",signal:s}).then(t=>t.ok?t.json():null).then(t=>t?.ok===!0?!0:(console.warn(t?.ok===!1?`Umber: ${o} isn't on an Umber licence, so this page shows without GL. List the domain under Umber in your occluze dashboard (occluze.com/dashboard).`:`Umber: couldn't check ${o}'s licence at umber.occluze.com, so this page shows without GL.`),!1)).catch(()=>(console.warn(`Umber: couldn't check ${o}'s licence at umber.occluze.com, so this page shows without GL.`),!1)).finally(()=>clearTimeout(n))}export{r as ok};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function y(n){let t=[],s=/[\s,]*(\S+)([^,]*)/g;for(let e;(e=s.exec(n||""))&&e[1];){let i=e[1].replace(/,+$/,"");i!==e[1]&&(s.lastIndex=e.index+e[0].indexOf(e[1])+e[1].length),t.push([i,i!==e[1]?"1x":e[2].trim()||"1x"])}return t}function m(n){let t=/^calc\((.+)\)$/.exec(n);if(t){let i=t[1].trim().split(/\s+([+-])\s+/),o=m(i[0]);for(let r=1;r<i.length;r+=2)o+=(i[r]==="-"?-1:1)*m(i[r+1]);return o}let s=/^([\d.]+)(vw|px|r?em)$/.exec(n),e=s?Number(s[1]):NaN;return s?s[2]==="vw"?innerWidth*e/100:s[2]==="px"?e:e*16:innerWidth}function N(n){let t=[],s=0,e=0;for(let i=0;i<=n.length;i++){let o=n[i];o==="("?s++:o===")"?s--:!s&&(o===","||o===void 0)&&(t.push(n.slice(e,i).trim()),e=i+1)}for(let i of t){let o=-1;for(let a=0,c=0;a<i.length;a++)i[a]==="("?c++:i[a]===")"?c--:!c&&/\s/.test(i[a])&&(o=a);let r=o>0?i.slice(0,o):"";if(i&&(!r||matchMedia(r).matches))return m(i.slice(o+1))}return innerWidth}function w(n){let t=n.ownerDocument?.baseURI||document.baseURI,s=a=>a?new URL(a,t).href:"",e=y(n.getAttribute("srcset")).map(([a,c])=>({url:a,n:parseFloat(c)||1,w:c.endsWith("w")})),i=n.getAttribute("src");if(i&&!e.some(a=>a.w||a.n==1)&&e.push({url:i,n:1,w:!1}),!e.length)return"";let o=window.devicePixelRatio||1,r=o;return e[0].w&&(r=N(n.getAttribute("sizes")||"")*o),e.sort((a,c)=>a.n-c.n),s((e.find(a=>a.n>=r)||e[e.length-1]).url)}var R={duration:1,ease:"umber"},M=3e3,P=3e3,X=8;function C(n,t){return n.includes(`data-gl-id="${t}"`)||n.includes(`data-gl-id='${t}'`)||n.includes(`data-gl-id=${t}`)}var A=(n,t)=>n.querySelector(`[data-gl-id="${t.replace(/["\\]/g,"\\$&")}"]`);function x(n){return n&&typeof n=="object"&&"html"in n&&(n=n.html),typeof n=="string"?n?t=>C(n,t):null:n&&typeof n.querySelector=="function"?t=>!!A(n,t):null}function E(n){return n[2]>0&&n[3]>0&&n[0]<window.innerWidth&&n[0]+n[2]>0&&n[1]<window.innerHeight&&n[1]+n[3]>0}var k=n=>n.opacity<=.001&&E(n.rect);function v(n){let t=n.media,s=[n.el.getAttribute("data-gl-src")||""];if(t&&t.tagName==="IMG"){let e=t;s.push(e.currentSrc,e.getAttribute("src")||"",...y(e.getAttribute("srcset")).map(i=>i[0]))}return s.filter(Boolean).map(e=>new URL(e,document.baseURI).href)}function F(n,t){let s=v(n);return v(t).some(e=>s.includes(e))}var b=n=>{n.morphHidden=!1,n.el.removeAttribute("data-gl-morphing")},z=(n,t)=>n.Ba&&n.Ba!==t&&b(n.Ba);function H(n,t){let{from:s,to:e}=n,i=s.drawXf,o=s.rect;if(!e.level&&O(n.originXf)){i[0]=i[4]=i[8]=1,i[1]=i[2]=i[3]=i[5]=0,i[6]=o[0],i[7]=o[1],s.size[0]=o[2],s.size[1]=o[3],s.level=0;return}let r=n.originXf,a=e.drawXf,c=r[8]||1,h=a[8]||1;for(let u=0;u<9;u++)i[u]=r[u]/c+(a[u]/h-r[u]/c)*t;s.size[0]=n.originSize[0]+(e.size[0]-n.originSize[0])*t,s.size[1]=n.originSize[1]+(e.size[1]-n.originSize[1])*t,s.level=1,s.xfReason=null;let l=s.size[0]/2,d=s.size[1]/2,f=i[2]*l+i[5]*d+i[8],p=s.shaderRect;p[0]=(i[0]*l+i[3]*d+i[6])/f-l,p[1]=(i[1]*l+i[4]*d+i[7])/f-d,p[2]=s.size[0],p[3]=s.size[1]}function O(n){return n[0]===1&&n[1]===0&&n[2]===0&&n[3]===0&&n[4]===1&&n[5]===0&&n[8]===1}var S=n=>(n.sx=NaN,n),g=class{constructor(t){this.host=t;this.snapshots=new Map;this.flights=[];this.parked=new Set;this.later=new Map;this.gen=0;this.yc=t=>{t.el.isConnected&&this.host.transitioning&&!t.destroyed||(this.parked.delete(t),t.destroyed||this.La(t,!0))}}snap(t,s,e=0,i=null){let o=this.host,r=t.scrolls?o.scrollX:o.pageX,a=t.scrolls?o.scrollY:o.pageY;return{plane:t,rect:t.rect.slice(),xf:t.drawXf.slice(),size:t.size.slice(),radius:t.radius.slice(),ky:t.radiusKy,opacity:t.opacity,frozen:s,Ba:i,until:e,sx:r,sy:a,ex:t.doc.x-r,ey:t.doc.y-a}}get busy(){return this.flights.length>0}holds(t){for(let s of this.snapshots.values())if(s.plane===t)return!0;return!1}capture(t,s=!1){s||this.settle(),t&&typeof t.then=="function"&&(this.known(t),t=void 0);let e=x(t);if(!s)for(let o of this.flights.slice()){let{from:r,to:a}=o;if(!e||!e(o.id)){r.rect.set(a.rect),r.radius.set(a.radius),r.radiusKy=a.radiusKy,r.drawXf.set(a.drawXf),r.size.set(a.size),r.opacity=1,this.finish(o,this.host.drawable(a));continue}this.flights.splice(this.flights.indexOf(o),1),this.snapshots.set(o.id,S(this.snap(o.from,!0,0,o.to)))}let i=this.host.planes.filter(o=>o.visible).concat(this.host.planes.filter(o=>!o.visible&&k(o)));for(let o of i){let r=o.el.getAttribute("data-gl-id");!r||o.kind==="layer"||this.snapshots.has(r)||o.status!=="ready"||o.morphHidden||e&&!e(r)||(this.snapshots.set(r,this.snap(o,!!e)),e&&this.host.detach(o))}t&&typeof t=="object"&&!("html"in t)&&this.preload(t),this.snapshots.size&&this.host.markDirty()}known(t){if(t&&typeof t.then=="function"){let e=this.gen;t.then(i=>e===this.gen&&this.known(i),()=>{});return}let s=x(t);if(s){for(let[e,i]of this.snapshots)i.frozen||i.until||(s(e)?this.host.planes.includes(i.plane)&&(this.snapshots.set(e,this.snap(i.plane,!0)),this.host.detach(i.plane)):this.drop(e));typeof t=="object"&&t&&!("html"in t)&&this.preload(t)}}preload(t){for(let s of this.snapshots.keys()){let e=A(t,s),i=e?.matches("img")?e:e?.querySelector("img"),o=i&&!i.parentElement?.querySelector("source")&&w(i);o&&fetch(o,{mode:"cors",credentials:"omit"}).catch(()=>{})}}keep(t){let s=t.el.getAttribute("data-gl-id");return!s||this.snapshots.has(s)||t.kind==="layer"||t.status!=="ready"||t.morphHidden||this.host.reducedMotion||!t.visible&&!k(t)?!1:(this.wait(s,this.snap(t,!1,performance.now()+P)),!0)}wait(t,s){let e=[...this.snapshots].filter(([,i])=>i.until).sort((i,o)=>i[1].until-o[1].until);e.length>=X&&this.drop(e[0][0]),this.snapshots.set(t,s),setTimeout(()=>this.snapshots.get(t)===s&&this.drop(t),s.until-performance.now())}drop(t){let s=this.snapshots.get(t);s&&(this.snapshots.delete(t),this.release(s),this.host.markDirty())}forget(t){for(let[s,e]of this.snapshots)if(e.plane===t)return this.snapshots.delete(s),!0;return!1}claim(t){let s=t.el.getAttribute("data-gl-id");for(let h of this.flights.slice())h.id===s&&!h.to.el.isConnected&&this.Qb(h);let e=s?this.snapshots.get(s):void 0,i=this.host;if(!s||!e||t.kind==="layer"||i.reducedMotion)return!1;if(!i.onScreen(t.el))return i.changing&&e.plane.el.isConnected&&this.later.set(s,t),!1;this.later.delete(s),this.snapshots.delete(s),z(e,t);let o=e.plane,r=e.frozen?e:this.snap(o,!1);e.frozen||i.detach(o);let a=i.readOptions(t.el,"data-gl-morph",R),c=Math.max(0,Number(a.duration)||0);this.flights.push({id:s,from:o,to:t,origin:r.rect,originXf:r.xf,originSize:r.size,originRadius:r.radius,originKy:r.ky,originOpacity:r.opacity,start:i.now,duration:c,ease:i.ease(a.ease),doneAt:0,same:F(o,t)}),o.opacity=r.opacity,t.morphIn=!0,t.morphHidden=!0;for(let h of t._play.playables.keys())t.uniforms[h]&&(t.uniforms[h].value=1);t.el.setAttribute("data-gl-morphing","");for(let h of o._play.playables.keys()){let l=o.uniforms[h];l&&l.value<1&&i.tweens.to(l,{value:1,duration:Math.max(.3,c),ease:"cubic.out"})}return i.markDirty(),!0}retry(){let t=[];for(let[s,e]of this.later){let i=this.snapshots.get(s);i?.plane.el.isConnected&&e.el.isConnected||(this.later.delete(s),i&&e.el.isConnected&&this.host.planes.includes(e)&&this.claim(e)?t.push(e):i&&this.drop(s))}return t}Qb(t){this.flights.splice(this.flights.indexOf(t),1),b(t.to),this.wait(t.id,S(this.snap(t.from,!0,performance.now()+P)))}settle(t=!0){t&&(this.later.clear(),this.gen++);for(let[s,e]of this.snapshots)!t&&(e.until||this.later.has(s))||this.drop(s);this.Vb()}Vb(){this.parked.forEach(this.yc)}update(t){if(this.snapshots.size&&this.follow(),this.parked.size&&this.Vb(),!this.flights.length)return!1;for(let s=this.flights.length;s--;){let e=this.flights[s],{from:i,to:o}=e;if(!this.host.planes.includes(o)||o.status==="error"||o.textureState==="error"){o.status!=="error"&&!o.el.isConnected&&(this.host.changing||!i.el.isConnected&&this.host.transitioning)?this.Qb(e):this.finish(e,!1);continue}let r=e.duration>0?Math.min(1,(t-e.start)/(e.duration*1e3)):1,a=e.ease(r),c=o.rect;for(let l=0;l<4;l++)i.rect[l]=e.origin[l]+(c[l]-e.origin[l])*a,i.radius[l]=e.originRadius[l]+(o.radius[l]-e.originRadius[l])*a;if(i.radiusKy=e.originKy+(o.radiusKy-e.originKy)*a,H(e,a),i.opacity=e.originOpacity+((this.host.transitioning?1:o.opacity)-e.originOpacity)*a,r<1)continue;e.doneAt||(e.doneAt=t),(o.opacity>=.99||!this.host.transitioning)&&this.host.drawable(o)?this.finish(e,!0):t-e.doneAt>M&&this.finish(e,!1)}return!0}follow(){let t=this.host;for(let s of this.snapshots.values()){let e=s.plane;if(!s.frozen||s.sx!==s.sx)continue;let i=e.scrolls?t.scrollX:t.pageX,o=e.scrolls?t.scrollY:t.pageY;if(i===s.sx&&o===s.sy)continue;let r=e.el.isConnected?e.el.getBoundingClientRect():null;if(!r?.width){s.sx=NaN;continue}let a=e.pinned?r.left-s.ex:s.sx-i,c=e.pinned?r.top-s.ey:s.sy-o;if(s.sx=i,s.sy=o,s.ex=r.left,s.ey=r.top,!a&&!c)continue;let h=e.rect,l=e.shaderRect,d=e.drawXf;h[0]+=a,h[1]+=c,l[0]+=a,l[1]+=c;for(let f=0;f<9;f+=3)d[f]+=a*d[f+2],d[f+1]+=c*d[f+2];s.rect.set(h),s.xf.set(d),t.markDirty()}}draw(t){if(this.snapshots.size)for(let s of this.snapshots.values())s.frozen&&!this.host.planes.includes(s.plane)&&t(s.plane);for(let s of this.flights){let{from:e,to:i}=s,o=e.texture;s.same&&i.texture?.ready&&e.kind==="image"&&(e.texture=i.texture),t(e),e.texture=o}}cancel(){for(let t of this.flights.slice())this.finish(t,!1);this.settle(),this.parked.forEach(t=>this.La(t,!0)),this.parked.clear()}finish(t,s){if(this.flights.splice(this.flights.indexOf(t),1),s){t.to.morphHidden=!1;let e=t.to.el;this.host.host.loadCovers?.().then(i=>i.landed(e,this.host.hostEl,this.host.host.log),()=>{})}else b(t.to);this.La(t.from,!s),this.host.markDirty()}La(t,s){t.el.isConnected?this.host.transitioning&&!s?this.parked.add(t):this.host.attach(t):this.host.discard(t)}release(t){z(t);let s=t.plane;this.host.planes.includes(s)||this.La(s,!0)}};function T(n){return n.morph=new g(n)}export{T as morph};
@@ -0,0 +1,2 @@
1
+ /*! Umber v0.2.1 | (c) Ravi Klaassens | UNLICENSED */
2
+ function l(e){if(e.failed||e.destroyed||e.gl.isContextLost())return;e.lost=!1,e.media.onLost();for(let t of e.subsystems)t.restored?.();e.planes.some(t=>t._layer)&&e.layers?.fade.get();let n=e.media.textureUrls;e.media.textureUrls=new Map;for(let t of e.planes){for(let o in t.uniforms){let r=t.uniforms[o],s=n.get(r.value);s&&(r.value=e.media.textureFromUrl(s))}if(t.status==="error"){t.videoCleanup&&e.programs.prepare(t);continue}if(t.setStatus(e.inactive?null:"loading"),t.status="loading",t.loadingSince=0,t._layer){t.near&&e.loadMedia(t);continue}e.programs.prepare(t),t.shader?t.textureState="ready":t.near&&e.loadMedia(t),t._mods.tell(o=>o.restored?.())}e.invalidate(),e.wake(2),e.views?.restored(),e.host.emit("restored")}export{l as restored};