@lofcz/orb-ui 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/orb-ui.cjs +10 -20
- package/dist/orb-ui.js +96 -91
- package/package.json +1 -1
package/dist/orb-ui.cjs
CHANGED
|
@@ -218,7 +218,6 @@ uniform float u_glow;
|
|
|
218
218
|
uniform float u_tilt;
|
|
219
219
|
uniform float u_listen;
|
|
220
220
|
uniform float u_speak;
|
|
221
|
-
uniform float u_beat;
|
|
222
221
|
uniform float u_surge;
|
|
223
222
|
uniform vec3 u_deep;
|
|
224
223
|
uniform vec3 u_shallow;
|
|
@@ -259,12 +258,10 @@ void main() {
|
|
|
259
258
|
|
|
260
259
|
float t = u_time;
|
|
261
260
|
float front = swellHeight(q.x, t, u_swell) + rippleHeight(q.x, t, u_ripple);
|
|
262
|
-
// The voice
|
|
263
|
-
//
|
|
264
|
-
float column = exp(-q.x * q.x *
|
|
265
|
-
float voice =
|
|
266
|
-
voice += u_speak * 0.02 * sin(q.x * 9.0 - t * 7.0) * (0.5 + 0.5 * u_beat);
|
|
267
|
-
voice += u_surge * 0.02;
|
|
261
|
+
// The voice is a tide, not a tremor: while she speaks the water rises a little
|
|
262
|
+
// in the middle of the orb and rolls in slow, rounder swells.
|
|
263
|
+
float column = exp(-q.x * q.x * 2.4);
|
|
264
|
+
float voice = u_surge * 0.05 * column + u_surge * 0.015 * sin(q.x * 2.6 - t * 0.9 + 0.4);
|
|
268
265
|
front += voice;
|
|
269
266
|
float waterline = u_level + front;
|
|
270
267
|
float d = q.y - waterline;
|
|
@@ -276,10 +273,9 @@ void main() {
|
|
|
276
273
|
float backBand = 1.0 - smoothstep(0.0, 0.06, abs(q.y - backline));
|
|
277
274
|
|
|
278
275
|
vec3 water = mix(u_shallow, u_deep, smoothstep(0.0, 1.05 + u_speak * 0.6, depth));
|
|
279
|
-
water = mix(water, u_shallow * 1.3,
|
|
280
|
-
float caustic = sin(q.x *
|
|
281
|
-
|
|
282
|
-
caustic = pow(max(caustic, 0.0), 3.0) * exp(-depth * 1.6) * (0.28 + u_glow * 0.45 + u_speak * 0.3);
|
|
276
|
+
water = mix(water, u_shallow * 1.3, u_surge * 0.18 * exp(-depth * 1.8));
|
|
277
|
+
float caustic = sin(q.x * 6.0 + front * 4.0 + t * 0.8) * sin(q.y * 5.0 - t * 0.6 + q.x * 1.5);
|
|
278
|
+
caustic = pow(max(caustic, 0.0), 3.0) * exp(-depth * 1.6) * (0.28 + u_glow * 0.45 + u_surge * 0.2);
|
|
283
279
|
water = mix(water, u_shallow * 1.25, caustic);
|
|
284
280
|
float shaft = pow(max(sin(q.x * 3.0 + t * 0.27), 0.0), 5.0) * exp(-depth * 2.2);
|
|
285
281
|
water = mix(water, u_light, shaft * 0.08 * (0.4 + u_glow));
|
|
@@ -293,15 +289,9 @@ void main() {
|
|
|
293
289
|
|
|
294
290
|
vec3 color = d < 0.0 ? water : air;
|
|
295
291
|
|
|
296
|
-
// Spray: droplets thrown up over the crest on loud beats.
|
|
297
|
-
float dropletField = sin(q.x * 41.0 + t * 6.5) * sin(q.y * 37.0 - t * 9.0 + q.x * 3.0);
|
|
298
|
-
float spray = pow(max(dropletField, 0.0), 14.0)
|
|
299
|
-
* u_speak * (0.4 + 0.6 * u_beat)
|
|
300
|
-
* smoothstep(0.0, 0.05, d) * (1.0 - smoothstep(0.1, 0.3, d)) * column;
|
|
301
|
-
color = mix(color, u_foam, clamp(spray * 0.8, 0.0, 0.7));
|
|
302
292
|
|
|
303
|
-
float foamWidth = 30.0 -
|
|
304
|
-
float foam = exp(-abs(d) * foamWidth) * (0.6 +
|
|
293
|
+
float foamWidth = 30.0 - u_surge * 8.0;
|
|
294
|
+
float foam = exp(-abs(d) * foamWidth) * (0.6 + u_surge * 0.3 + u_listen * 0.15);
|
|
305
295
|
float crest = smoothstep(0.35, 1.0, front / max(u_swell * 1.85, 0.001));
|
|
306
296
|
foam += crest * exp(-abs(d) * 16.0) * (0.22 + u_speak * 0.3);
|
|
307
297
|
color = mix(color, u_foam, clamp(foam, 0.0, 0.92));
|
|
@@ -318,4 +308,4 @@ void main() {
|
|
|
318
308
|
// perimeter so translucent edge pixels cannot become a bright outline.
|
|
319
309
|
gl_FragColor = vec4(color * edge, edge);
|
|
320
310
|
}
|
|
321
|
-
`,ye=.72;function Z(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function Q(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function be(e,t){let n=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!n)return t;let r=parseInt(n[1],16);return[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255]}function xe(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function $([e,t,n],r){return`rgba(${Math.round(e*255)}, ${Math.round(t*255)}, ${Math.round(n*255)}, ${r})`}function Se(e,t){let n=ge[e],r=e=>{let r=be(n[e],[0,0,0]),i=t?.[e];return i?be(i,r):r};return{deep:r(`deep`),shallow:r(`shallow`),foam:r(`foam`),glow:r(`glow`),sky:r(`sky`),horizon:r(`horizon`)}}function Ce(e,t,n){let r=e.createShader(t);if(r){if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){e.deleteShader(r);return}return r}}function we(e,t,n){let r=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!r)return;let i=Ce(r,r.VERTEX_SHADER,_e),a=Ce(r,r.FRAGMENT_SHADER,ve);if(!i||!a){i&&r.deleteShader(i),a&&r.deleteShader(a);return}let o=r.createProgram(),s=r.createBuffer();if(!o||!s){o&&r.deleteProgram(o),s&&r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}if(r.attachShader(o,i),r.attachShader(o,a),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS)){r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}let c=()=>{r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a)},l=r.getAttribLocation(o,`a_position`),u=e=>r.getUniformLocation(o,e),d={resolution:u(`u_resolution`),time:u(`u_time`),level:u(`u_level`),swell:u(`u_swell`),ripple:u(`u_ripple`),glow:u(`u_glow`),tilt:u(`u_tilt`),listen:u(`u_listen`),speak:u(`u_speak`),beat:u(`u_beat`),surge:u(`u_surge`),deep:u(`u_deep`),shallow:u(`u_shallow`),foam:u(`u_foam`),light:u(`u_light`),sky:u(`u_sky`),horizon:u(`u_horizon`)};if(l<0||Object.values(d).some(e=>!e)){c();return}let f=Math.min(window.devicePixelRatio||1,2),p=Math.max(1,Math.round(t*f));return e.width=p,e.height=p,r.viewport(0,0,p,p),r.useProgram(o),r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(l),r.vertexAttribPointer(l,2,r.FLOAT,!1,0,0),r.uniform2f(d.resolution,p,p),r.uniform3fv(d.deep,n.deep),r.uniform3fv(d.shallow,n.shallow),r.uniform3fv(d.foam,n.foam),r.uniform3fv(d.light,n.glow),r.uniform3fv(d.sky,n.sky),r.uniform3fv(d.horizon,n.horizon),{draw(e){r.uniform1f(d.time,e.time),r.uniform1f(d.level,e.level),r.uniform1f(d.swell,e.swell),r.uniform1f(d.ripple,e.ripple),r.uniform1f(d.glow,e.glow),r.uniform1f(d.tilt,e.tilt),r.uniform1f(d.listen,e.listen),r.uniform1f(d.speak,e.speak),r.uniform1f(d.beat,e.beat),r.uniform1f(d.surge,e.surge),r.drawArrays(r.TRIANGLES,0,6)},destroy:c}}function Te(e,t,n,r){switch(e){case`connecting`:return{swell:.03,speed:.32,glow:.3+.2*Math.sin(r*2.6),tiltAmplitude:.02,levelOffset:0,corona:.32+.12*Math.sin(r*2.6),reach:.28,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:1,pulse:.5};case`listening`:return{swell:.045+t*.05,speed:.5+t*.5,glow:.42+t*.5,tiltAmplitude:.03,levelOffset:t*.05,corona:.38+t*.32,reach:.28+t*.22,ringEvery:1.6-t*.5,ringStrength:.3+t*.35,ringInward:!0,orbit:0,sweep:0,pulse:.3};case`thinking`:return{swell:.05,speed:.7,glow:.6+.25*Math.sin(r*3.1),tiltAmplitude:.06,levelOffset:.01,corona:.45+.15*Math.sin(r*3.1),reach:.38,ringEvery:0,ringStrength:0,ringInward:!0,orbit:1,sweep:0,pulse:1};case`speaking`:return{swell:.06+n*.08,speed:.8+n*.7,glow:.6+n*.3,tiltAmplitude:.04,levelOffset:.03+n*.06,corona:.5+n*.3,reach:.3+n*.28,ringEvery:1.3-n*.4,ringStrength:.3+n*.3,ringInward:!1,orbit:0,sweep:0,pulse:.2};case`error`:return{swell:.02,speed:.2,glow:.06,tiltAmplitude:.01,levelOffset:-.04,corona:.08,reach:.15,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:0,pulse:0};default:return{swell:.036,speed:.36,glow:.28,tiltAmplitude:.028,levelOffset:0,corona:.3,reach:.24,ringEvery:5,ringStrength:.25,ringInward:!1,orbit:0,sweep:0,pulse:.35}}}var Ee=.1,De=7.5,Oe=1.6,ke=4.3,Ae=60,je=2.2,Me=.7,Ne=2.8,Pe=4;function Fe(){return Array.from({length:Pe},(e,t)=>({angle:t/Pe*Math.PI*2,speed:(.9+t%3*.35)*(t%2==0?1:-1),radius:1.14+t%2*.1,size:.018+t%2*.008,wobble:.7+t*.37}))}function Ie(e,t,n,r){let i=e.getContext(`2d`);if(!i)return;let a=Math.min(window.devicePixelRatio||1,2),o=t*je;e.width=Math.max(1,Math.round(o*a)),e.height=e.width,i.scale(a,a);let s=o/2,c=t/2,l=r===`dark`?xe(n.shallow,n.glow,.35):n.shallow,u=r===`dark`?xe(n.glow,n.foam,.4):n.deep,d=r===`dark`?n.shallow:n.deep,f=r===`dark`?1:.75,p=(e,t,n)=>{i.beginPath(),i.arc(e,t,n,0,Math.PI*2)};return{draw(e){i.clearRect(0,0,o,o),i.globalCompositeOperation=r===`dark`?`lighter`:`source-over`;let t=c*(1+e.reach+e.pulse*.04+Math.sin(e.breath)*.02),n=Z(e.corona*(r===`dark`?.55:.5)),a=i.createRadialGradient(s,s,c*.9,s,s,t);a.addColorStop(0,$(l,n)),a.addColorStop(.3,$(l,n*.5)),a.addColorStop(.65,$(l,n*.15)),a.addColorStop(1,$(l,0)),i.fillStyle=a,p(s,s,t),i.fill();let m=Z(e.speak+e.listen*.6);if(m>.01){let e=c*(1.02+m*.5),t=i.createRadialGradient(s,s,c*.95,s,s,e);t.addColorStop(0,$(l,.35*m*f)),t.addColorStop(.4,$(u,.1*m*f)),t.addColorStop(1,$(u,0)),i.fillStyle=t,p(s,s,e),i.fill()}let h=Z((.3+e.glow*.35+e.speak*.2+e.listen*.25)*f),g=c*(1.06+e.speak*.04),_=i.createRadialGradient(s,s,c*.97,s,s,g);_.addColorStop(0,$(u,h)),_.addColorStop(1,$(u,0)),i.fillStyle=_,p(s,s,c*1.15),i.fill();for(let t of e.rings){let n=Z((e.time-t.born)/Ne),r=1-(1-n)**2.2,a=t.inward?1-r:r,o=c*(1+Me*a),d=Z((t.inward?(1-a)**.6*(1-n**4):(1-n)**1.3)*t.strength);if(d<.005)continue;let m=c*(.008+t.strength*.012)*(1-a*.4);i.lineWidth=m*4,i.strokeStyle=$(l,d*.18),p(s,s,o),i.stroke(),i.lineWidth=m,i.strokeStyle=$(u,d*.45*f),p(s,s,o),i.stroke()}if(e.orbit>.01){for(let t of[1.14,1.24])i.lineWidth=c*.006,i.strokeStyle=$(l,.12*e.orbit*f),p(s,s,c*t),i.stroke();for(let t of e.orbiters){let n=Math.sin(e.time*t.wobble)*.05,r=c*(t.radius+n),a=.8+e.orbit*.7,o=t.speed>0?1:-1;for(let n=0;n<14;n+=1){let d=n/14*a,m=t.angle-o*d,h=s+Math.cos(m)*r,g=s+Math.sin(m)*r,_=(1-n/14)**2*e.orbit;i.fillStyle=$(n===0?u:l,Z(_*(n===0?1:.7)*f)),p(h,g,c*t.size*(1-n/14*.7)),i.fill()}let d=c*t.size*5,m=s+Math.cos(t.angle)*r,h=s+Math.sin(t.angle)*r,g=i.createRadialGradient(m,h,0,m,h,d);g.addColorStop(0,$(l,.5*e.orbit)),g.addColorStop(1,$(l,0)),i.fillStyle=g,p(m,h,d),i.fill()}}if(e.sweep>.01){let t=[{orbitRadius:c*1.12,start:e.time*2,span:Math.PI*.55,width:.025}];for(let{orbitRadius:n,start:r,span:a,width:o}of t){let t=i.createConicGradient(r,s,s);t.addColorStop(0,$(u,0)),t.addColorStop(a/(Math.PI*2),$(u,.7*e.sweep*f)),t.addColorStop(a/(Math.PI*2)+.001,$(u,0)),t.addColorStop(1,$(u,0)),i.lineWidth=c*o,i.strokeStyle=t,i.beginPath(),i.arc(s,s,n,r,r+a),i.stroke(),i.lineWidth=c*.01,i.strokeStyle=$(d,.2*e.sweep*f),p(s,s,n),i.stroke()}}}}}function Le({state:n,volume:r,size:i,scheme:a=`light`,palette:o,className:s,style:c,disabled:l=!1,interactive:u=!1,onClick:d,...f}){let p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useRef)(n),_=(0,e.useRef)(r),v=(0,e.useRef)(!1);he(()=>{g.current=n,_.current=r},[n,r]);let y=i*ye,b=Se(a,o),x=JSON.stringify(b);(0,e.useEffect)(()=>{let e=p.current,t=m.current,n=h.current;if(!e||!t||!n)return;let r=JSON.parse(x),i=window.matchMedia(`(prefers-reduced-motion: reduce)`),o=()=>{v.current=i.matches};o(),i.addEventListener(`change`,o);let s=we(e,y,r);s||(e.style.background=`linear-gradient(180deg, ${$(r.sky,1)} 0%, ${$(r.horizon,1)} 44%, ${$(r.shallow,1)} 48%, ${$(r.deep,1)} 100%)`);let c=Ie(t,y,r,a),l=0,u=performance.now(),d=0,f=0,b=0,S=0,C=Z(_.current),w=0,T=0,E=.036,D=.36,O=.26,k=.028,A=0,j=.3,M=.24,N=0,P=0,F=.3,I=0,L=0,R=0,z=0,B=0,V=[],H=Fe(),U=e=>{let t=Math.min((e-u)/1e3,.05);u=e;let r=g.current,i=v.current,a=Z(_.current);C=i?0:Q(C,a,a>C?14:6,t);let o=r===`listening`?C:0,p=r===`speaking`?C:0;w=Q(w,o,o>w?16:6,t),T=Q(T,p,p>T?11:4.5,t),f+=t;let m=Te(r,w,T,f);if(E=Q(E,m.swell,2.4,t),D=Q(D,m.speed,2.4,t),O=Q(O,m.glow,3.2,t),k=Q(k,m.tiltAmplitude,1.8,t),A=Q(A,m.levelOffset,3,t),j=Q(j,m.corona,m.corona>j?6:2.5,t),M=Q(M,m.reach,m.reach>M?7:2.5,t),N=Q(N,m.orbit,3,t),P=Q(P,m.sweep,3,t),F=Q(F,m.pulse,2.5,t),z+=((r===`speaking`?a:0)-R)*Ae*t,z*=Math.exp(-15*t),R+=z*t,!i){d+=t*D,b+=t*Math.PI*2/De,S+=t*.31,I+=t*Math.PI*2/Oe,L+=t*Math.PI*2*ke*(.8+T*.4);for(let e of H)e.angle+=t*e.speed*(.6+N*.9);for(B+=t,m.ringEvery>0&&(r!==`speaking`||T>.04)&&(r!==`listening`||w>.03)&&B>=m.ringEvery&&(B=0,V.push({born:f,strength:m.ringStrength,inward:m.ringInward}));V.length>0&&f-V[0].born>Ne;)V.shift()}let h=Ee+A+Math.sin(b)*.022,y=Math.sin(S)*k+Math.sin(S*2.3+.7)*.006,x=i?0:(.5+.5*Math.sin(L))*T,W=i?0:R;s?.draw({time:d,level:h,swell:i?.012:E,ripple:i?0:w,glow:O,tilt:i?0:y,listen:w,speak:T,beat:x,surge:W});let G=(.5+.5*Math.sin(I))*F,K=1+G*.018+Math.sin(b)*.005+W*.045+x*.012+w*.02;n.style.transform=i?`none`:`scale(${K})`,c?.draw({time:f,corona:i?j*.6:j,reach:M,glow:O,speak:T,listen:w,orbit:i?0:N,sweep:i?0:P,pulse:G,breath:b,rings:i?[]:V,orbiters:H}),l=requestAnimationFrame(U)};return l=requestAnimationFrame(U),()=>{cancelAnimationFrame(l),i.removeEventListener(`change`,o),s?.destroy()}},[y,x,a]);let S={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...c},C=y*je,w=(0,t.jsxs)(`span`,{ref:h,style:{position:`relative`,display:`block`,width:y,height:y,borderRadius:`50%`,lineHeight:0,cursor:u?l?`not-allowed`:`pointer`:`default`,transformOrigin:`center`,willChange:`transform`},children:[(0,t.jsx)(`canvas`,{ref:m,"aria-hidden":`true`,"data-ocean-aura":``,style:{position:`absolute`,left:(y-C)/2,top:(y-C)/2,display:`block`,width:C,height:C,pointerEvents:`none`}}),(0,t.jsx)(`canvas`,{ref:p,"aria-hidden":`true`,"data-ocean-surface":``,style:{position:`absolute`,inset:0,display:`block`,width:y,height:y,borderRadius:`50%`,boxShadow:`0 ${y*.06}px ${y*.22}px ${$(b.deep,a===`dark`?.55:.28)}`}})]});return u?(0,t.jsx)(`button`,{...f,type:`button`,className:s,disabled:l,onClick:l?void 0:d,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:l?`not-allowed`:`pointer`,...S},children:w}):(0,t.jsx)(`div`,{...f,className:s,style:S,children:w})}function Re({signal:i,state:a,volume:s,adapter:c,theme:l=`debug`,size:u=200,scheme:d,palette:f,className:p,style:m,disabled:h=!1,interactive:g=!0,onStart:_,onStop:v,renderTheme:y,...x}){let[S,C]=(0,e.useState)({state:`idle`});(0,e.useEffect)(()=>{if(C({state:`idle`}),c)return c.subscribe(C)},[c]);let w=i??S,T=n(a,i,S),D=r(s,T,w),O=w.inputVolume??0,k=w.outputVolume??0,A=(0,e.useMemo)(()=>({...w,state:T,inputVolume:O,outputVolume:k}),[w,O,k,T]),j=T!==`idle`&&T!==`error`,M=(0,e.useCallback)(()=>{if(!h)return _?_():c?.start?.()},[c,h,_]),N=(0,e.useCallback)(()=>{if(!h)return v?v():c?.stop?.()},[c,h,v]),P=(0,e.useCallback)(()=>j?N():M(),[j,M,N]),F=j?!!(c?.stop||v):!!(c?.start||_),I=g&&F,L=I&&!h?P:void 0,R=x[`aria-label`]??(I?`${j?`Stop`:`Start`} voice session`:void 0),z={...x,"aria-label":R};if(y){let e={...x,type:`button`,disabled:h||!I,onClick:L,"data-orb-ui-state":T,"aria-label":R};return y({state:T,signal:A,inputVolume:O,outputVolume:k,activity:D,size:u,isActive:j,interactive:I,disabled:h,start:M,stop:N,toggle:P,rootProps:{className:p,style:{width:u,height:u,...m},"data-orb-ui-theme":`custom`,"data-orb-ui-state":T},controlProps:e})}let B={state:T,volume:D,size:u,className:p,style:m,disabled:h,...z},V={...B,interactive:I};switch(l){case`circle`:return(0,t.jsx)(b,{...V,onClick:L});case`bars`:return(0,t.jsx)(E,{...V,onClick:L});case`cloud`:return(0,t.jsx)(ne,{...V,onClick:L});case`radial`:return(0,t.jsx)(me,{...V,onClick:L});case`ocean`:return(0,t.jsx)(Le,{...V,scheme:d,palette:f,onClick:L});default:return(0,t.jsx)(o,{...B,disabled:h||!g,onStart:h||!g?void 0:M,onStop:h||!g?void 0:N})}}exports.Orb=Re,exports.VoiceOrb=Re;
|
|
311
|
+
`,ye=.72;function Z(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function Q(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function be(e,t){let n=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!n)return t;let r=parseInt(n[1],16);return[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255]}function xe(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function $([e,t,n],r){return`rgba(${Math.round(e*255)}, ${Math.round(t*255)}, ${Math.round(n*255)}, ${r})`}function Se(e,t){let n=ge[e],r=e=>{let r=be(n[e],[0,0,0]),i=t?.[e];return i?be(i,r):r};return{deep:r(`deep`),shallow:r(`shallow`),foam:r(`foam`),glow:r(`glow`),sky:r(`sky`),horizon:r(`horizon`)}}function Ce(e,t,n){let r=e.createShader(t);if(r){if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){e.deleteShader(r);return}return r}}function we(e,t,n){let r=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!r)return;let i=Ce(r,r.VERTEX_SHADER,_e),a=Ce(r,r.FRAGMENT_SHADER,ve);if(!i||!a){i&&r.deleteShader(i),a&&r.deleteShader(a);return}let o=r.createProgram(),s=r.createBuffer();if(!o||!s){o&&r.deleteProgram(o),s&&r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}if(r.attachShader(o,i),r.attachShader(o,a),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS)){r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}let c=()=>{r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a)},l=r.getAttribLocation(o,`a_position`),u=e=>r.getUniformLocation(o,e),d={resolution:u(`u_resolution`),time:u(`u_time`),level:u(`u_level`),swell:u(`u_swell`),ripple:u(`u_ripple`),glow:u(`u_glow`),tilt:u(`u_tilt`),listen:u(`u_listen`),speak:u(`u_speak`),surge:u(`u_surge`),deep:u(`u_deep`),shallow:u(`u_shallow`),foam:u(`u_foam`),light:u(`u_light`),sky:u(`u_sky`),horizon:u(`u_horizon`)};if(l<0||Object.values(d).some(e=>!e)){c();return}let f=Math.min(window.devicePixelRatio||1,2),p=Math.max(1,Math.round(t*f));return e.width=p,e.height=p,r.viewport(0,0,p,p),r.useProgram(o),r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(l),r.vertexAttribPointer(l,2,r.FLOAT,!1,0,0),r.uniform2f(d.resolution,p,p),r.uniform3fv(d.deep,n.deep),r.uniform3fv(d.shallow,n.shallow),r.uniform3fv(d.foam,n.foam),r.uniform3fv(d.light,n.glow),r.uniform3fv(d.sky,n.sky),r.uniform3fv(d.horizon,n.horizon),{draw(e){r.uniform1f(d.time,e.time),r.uniform1f(d.level,e.level),r.uniform1f(d.swell,e.swell),r.uniform1f(d.ripple,e.ripple),r.uniform1f(d.glow,e.glow),r.uniform1f(d.tilt,e.tilt),r.uniform1f(d.listen,e.listen),r.uniform1f(d.speak,e.speak),r.uniform1f(d.surge,e.surge),r.drawArrays(r.TRIANGLES,0,6)},destroy:c}}function Te(e,t,n,r){switch(e){case`connecting`:return{swell:.03,speed:.32,glow:.3+.2*Math.sin(r*2.6),tiltAmplitude:.02,levelOffset:0,corona:.3+.1*Math.sin(r*2.6),reach:.24,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:1,pulse:.5};case`listening`:return{swell:.045+t*.03,speed:.45+t*.25,glow:.42+t*.5,tiltAmplitude:.03,levelOffset:t*.05,corona:.36+t*.3,reach:.24+t*.1,ringEvery:1.6-t*.5,ringStrength:.3+t*.35,ringInward:!0,orbit:0,sweep:0,pulse:.3};case`thinking`:return{swell:.05,speed:.7,glow:.5+.1*Math.sin(r*1.6),tiltAmplitude:.045,levelOffset:.01,corona:.38+.08*Math.sin(r*1.6),reach:.28,ringEvery:0,ringStrength:0,ringInward:!0,orbit:1,sweep:0,pulse:1};case`speaking`:return{swell:.055+n*.045,speed:.5+n*.25,glow:.55+n*.3,tiltAmplitude:.035,levelOffset:.02+n*.05,corona:.45+n*.3,reach:.24+n*.1,ringEvery:0,ringStrength:.3,ringInward:!1,orbit:0,sweep:0,pulse:.2};case`error`:return{swell:.02,speed:.2,glow:.06,tiltAmplitude:.01,levelOffset:-.04,corona:.08,reach:.15,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:0,pulse:0};default:return{swell:.036,speed:.36,glow:.28,tiltAmplitude:.028,levelOffset:0,corona:.3,reach:.22,ringEvery:6,ringStrength:.25,ringInward:!1,orbit:0,sweep:0,pulse:.35}}}var Ee=.1,De=7.5,Oe=3.2,ke=14,Ae=1.7,je=.3,Me=2.2,Ne=3,Pe=9,Fe=3.2,Ie=14,Le=.45,Re=.25,ze=.085;function Be(){return Array.from({length:Ne},(e,t)=>({angle:t/Ne*Math.PI*2,speed:(.55+t%3*.2)*(t%2==0?1:-1),radius:1.12+t%2*.08,size:.016+t%2*.006,wobble:.7+t*.37}))}function Ve(e,t,n,r){let i=e.getContext(`2d`);if(!i)return;let a=Math.min(window.devicePixelRatio||1,2),o=t*Ae;e.width=Math.max(1,Math.round(o*a)),e.height=e.width,i.scale(a,a);let s=o/2,c=t/2,l=r===`dark`?xe(n.shallow,n.glow,.35):n.shallow,u=r===`dark`?xe(n.glow,n.foam,.4):n.deep,d=r===`dark`?n.shallow:n.deep,f=r===`dark`?1:.75,p=(e,t,n)=>{i.beginPath(),i.arc(e,t,n,0,Math.PI*2)};return{draw(e){i.clearRect(0,0,o,o),i.globalCompositeOperation=r===`dark`?`lighter`:`source-over`;let t=c*(1+e.reach+e.pulse*.03+Math.sin(e.breath)*.015),n=Z(e.corona*(r===`dark`?.55:.5)),a=i.createRadialGradient(s,s,c*.9,s,s,t);a.addColorStop(0,$(l,n)),a.addColorStop(.3,$(l,n*.5)),a.addColorStop(.65,$(l,n*.15)),a.addColorStop(1,$(l,0)),i.fillStyle=a,p(s,s,t),i.fill();let m=Z(e.speak+e.listen*.6);if(m>.01){let e=c*(1.02+m*.5),t=i.createRadialGradient(s,s,c*.95,s,s,e);t.addColorStop(0,$(l,.35*m*f)),t.addColorStop(.4,$(u,.1*m*f)),t.addColorStop(1,$(u,0)),i.fillStyle=t,p(s,s,e),i.fill()}let h=Z((.3+e.glow*.35+e.speak*.2+e.listen*.25)*f),g=c*(1.06+e.speak*.04),_=i.createRadialGradient(s,s,c*.97,s,s,g);_.addColorStop(0,$(u,h)),_.addColorStop(1,$(u,0)),i.fillStyle=_,p(s,s,c*1.15),i.fill();for(let t of e.rings){let n=Z((e.time-t.born)/Me),r=1-(1-n)**2.2,a=t.inward?1-r:r,o=c*(1+je*a),d=Z((t.inward?(1-a)**.6*(1-n**4):(1-n)**1.3)*t.strength);if(d<.005)continue;let m=c*(.01+t.strength*.014)*(1-a*.3);i.lineWidth=m*4,i.strokeStyle=$(l,d*.16),p(s,s,o),i.stroke(),i.lineWidth=m,i.strokeStyle=$(u,d*.4*f),p(s,s,o),i.stroke()}if(e.orbit>.01)for(let t of e.orbiters){let n=Math.sin(e.time*t.wobble)*.05,r=c*(t.radius+n),a=.8+e.orbit*.7,o=t.speed>0?1:-1;for(let n=0;n<14;n+=1){let d=n/14*a,m=t.angle-o*d,h=s+Math.cos(m)*r,g=s+Math.sin(m)*r,_=(1-n/14)**2*e.orbit;i.fillStyle=$(n===0?u:l,Z(_*(n===0?1:.7)*f)),p(h,g,c*t.size*(1-n/14*.7)),i.fill()}let d=c*t.size*5,m=s+Math.cos(t.angle)*r,h=s+Math.sin(t.angle)*r,g=i.createRadialGradient(m,h,0,m,h,d);g.addColorStop(0,$(l,.35*e.orbit)),g.addColorStop(1,$(l,0)),i.fillStyle=g,p(m,h,d),i.fill()}if(e.sweep>.01){let t=[{orbitRadius:c*1.12,start:e.time*2,span:Math.PI*.55,width:.025}];for(let{orbitRadius:n,start:r,span:a,width:o}of t){let t=i.createConicGradient(r,s,s);t.addColorStop(0,$(u,0)),t.addColorStop(a/(Math.PI*2),$(u,.7*e.sweep*f)),t.addColorStop(a/(Math.PI*2)+.001,$(u,0)),t.addColorStop(1,$(u,0)),i.lineWidth=c*o,i.strokeStyle=t,i.beginPath(),i.arc(s,s,n,r,r+a),i.stroke(),i.lineWidth=c*.01,i.strokeStyle=$(d,.2*e.sweep*f),p(s,s,n),i.stroke()}}}}}function He({state:n,volume:r,size:i,scheme:a=`light`,palette:o,className:s,style:c,disabled:l=!1,interactive:u=!1,onClick:d,...f}){let p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useRef)(n),_=(0,e.useRef)(r),v=(0,e.useRef)(!1);he(()=>{g.current=n,_.current=r},[n,r]);let y=i*ye,b=Se(a,o),x=JSON.stringify(b);(0,e.useEffect)(()=>{let e=p.current,t=m.current,n=h.current;if(!e||!t||!n)return;let r=JSON.parse(x),i=window.matchMedia(`(prefers-reduced-motion: reduce)`),o=()=>{v.current=i.matches};o(),i.addEventListener(`change`,o);let s=we(e,y,r);s||(e.style.background=`linear-gradient(180deg, ${$(r.sky,1)} 0%, ${$(r.horizon,1)} 44%, ${$(r.shallow,1)} 48%, ${$(r.deep,1)} 100%)`);let c=Ve(t,y,r,a),l=0,u=performance.now(),d=0,f=0,b=0,S=0,C=Z(_.current),w=0,T=0,E=.036,D=.36,O=.26,k=.028,A=0,j=.3,M=.24,N=0,P=0,F=.3,I=0,L=0,R=0,z=Re,B=0,V=0,H=!1,U=0,W=[],G=Be(),K=e=>{let t=Math.min((e-u)/1e3,.05);u=e;let r=g.current,i=v.current,a=Z(_.current);C=i?0:Q(C,a,a>C?4:1.5,t);let o=r===`listening`?C:0,p=r===`speaking`?C:0;w=Q(w,o,o>w?4:1.5,t),T=Q(T,p,p>T?4:1.5,t),f+=t;let m=Te(r,w,T,f);E=Q(E,m.swell,2.4,t),D=Q(D,m.speed,2.4,t),O=Q(O,m.glow,3.2,t),k=Q(k,m.tiltAmplitude,1.8,t),A=Q(A,m.levelOffset,3,t),j=Q(j,m.corona,m.corona>j?6:2.5,t),M=Q(M,m.reach,m.reach>M?7:2.5,t),N=Q(N,m.orbit,3,t),P=Q(P,m.sweep,3,t),F=Q(F,m.pulse,2.5,t),R+=((r===`speaking`?C:0)-L)*ke*t,R*=Math.exp(-8*t),L+=R*t;let h=r===`speaking`&&!i;z=Math.max(h?a:0,Re,z-(z-Re)*Le*t);let y=h?Z(a/z):0;if(B=Q(B,y,y>B?Pe:Fe,t),V=Q(V,B,Ie,t),!i){d+=t*D,b+=t*Math.PI*2/De,S+=t*.31,I+=t*Math.PI*2/Oe;for(let e of G)e.angle+=t*e.speed*(.6+N*.9);U+=t;let e=V>.55;for(h?e&&!H&&U>=1&&(U=0,W.push({born:f,strength:m.ringStrength,inward:!1})):m.ringEvery>0&&(r!==`listening`||w>.03)&&U>=m.ringEvery&&(U=0,W.push({born:f,strength:m.ringStrength,inward:m.ringInward})),H=e;W.length>0&&f-W[0].born>Me;)W.shift()}let x=Ee+A+Math.sin(b)*.022,ee=Math.sin(S)*k+Math.sin(S*2.3+.7)*.006,q=i?0:Z(L);s?.draw({time:d,level:x,swell:i?.012:E,ripple:i?0:w,glow:O,tilt:i?0:ee,listen:w,speak:T,surge:q});let J=(.5+.5*Math.sin(I))*F,Y=V**.85*ze,te=1+J*.012+Math.sin(b)*.005+Y+w*.015;n.style.transform=i?`none`:`scale(${te})`,c?.draw({time:f,corona:i?j*.6:j+V*.2,reach:M,glow:O,speak:Math.max(T,V*.8),listen:w,orbit:i?0:N,sweep:i?0:P,pulse:J,breath:b,rings:i?[]:W,orbiters:G}),l=requestAnimationFrame(K)};return l=requestAnimationFrame(K),()=>{cancelAnimationFrame(l),i.removeEventListener(`change`,o),s?.destroy()}},[y,x,a]);let S={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...c},C=y*Ae,w=(0,t.jsxs)(`span`,{ref:h,style:{position:`relative`,display:`block`,width:y,height:y,borderRadius:`50%`,lineHeight:0,cursor:u?l?`not-allowed`:`pointer`:`default`,transformOrigin:`center`,willChange:`transform`},children:[(0,t.jsx)(`canvas`,{ref:m,"aria-hidden":`true`,"data-ocean-aura":``,style:{position:`absolute`,left:(y-C)/2,top:(y-C)/2,display:`block`,width:C,height:C,pointerEvents:`none`}}),(0,t.jsx)(`canvas`,{ref:p,"aria-hidden":`true`,"data-ocean-surface":``,style:{position:`absolute`,inset:0,display:`block`,width:y,height:y,borderRadius:`50%`,boxShadow:`0 ${y*.06}px ${y*.22}px ${$(b.deep,a===`dark`?.55:.28)}`}})]});return u?(0,t.jsx)(`button`,{...f,type:`button`,className:s,disabled:l,onClick:l?void 0:d,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:l?`not-allowed`:`pointer`,...S},children:w}):(0,t.jsx)(`div`,{...f,className:s,style:S,children:w})}function Ue({signal:i,state:a,volume:s,adapter:c,theme:l=`debug`,size:u=200,scheme:d,palette:f,className:p,style:m,disabled:h=!1,interactive:g=!0,onStart:_,onStop:v,renderTheme:y,...x}){let[S,C]=(0,e.useState)({state:`idle`});(0,e.useEffect)(()=>{if(C({state:`idle`}),c)return c.subscribe(C)},[c]);let w=i??S,T=n(a,i,S),D=r(s,T,w),O=w.inputVolume??0,k=w.outputVolume??0,A=(0,e.useMemo)(()=>({...w,state:T,inputVolume:O,outputVolume:k}),[w,O,k,T]),j=T!==`idle`&&T!==`error`,M=(0,e.useCallback)(()=>{if(!h)return _?_():c?.start?.()},[c,h,_]),N=(0,e.useCallback)(()=>{if(!h)return v?v():c?.stop?.()},[c,h,v]),P=(0,e.useCallback)(()=>j?N():M(),[j,M,N]),F=j?!!(c?.stop||v):!!(c?.start||_),I=g&&F,L=I&&!h?P:void 0,R=x[`aria-label`]??(I?`${j?`Stop`:`Start`} voice session`:void 0),z={...x,"aria-label":R};if(y){let e={...x,type:`button`,disabled:h||!I,onClick:L,"data-orb-ui-state":T,"aria-label":R};return y({state:T,signal:A,inputVolume:O,outputVolume:k,activity:D,size:u,isActive:j,interactive:I,disabled:h,start:M,stop:N,toggle:P,rootProps:{className:p,style:{width:u,height:u,...m},"data-orb-ui-theme":`custom`,"data-orb-ui-state":T},controlProps:e})}let B={state:T,volume:D,size:u,className:p,style:m,disabled:h,...z},V={...B,interactive:I};switch(l){case`circle`:return(0,t.jsx)(b,{...V,onClick:L});case`bars`:return(0,t.jsx)(E,{...V,onClick:L});case`cloud`:return(0,t.jsx)(ne,{...V,onClick:L});case`radial`:return(0,t.jsx)(me,{...V,onClick:L});case`ocean`:return(0,t.jsx)(He,{...V,scheme:d,palette:f,onClick:L});default:return(0,t.jsx)(o,{...B,disabled:h||!g,onStart:h||!g?void 0:M,onStop:h||!g?void 0:N})}}exports.Orb=Ue,exports.VoiceOrb=Ue;
|
package/dist/orb-ui.js
CHANGED
|
@@ -472,21 +472,21 @@ function M({ state: e, volume: n, size: r, className: a, style: s, disabled: c =
|
|
|
472
472
|
}
|
|
473
473
|
//#endregion
|
|
474
474
|
//#region src/themes/cloud/CloudTheme.tsx
|
|
475
|
-
var N = typeof window < "u" ? n : t, P = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", F = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", I = .55, L = .204, R = .2145, z = .063, B = "#5659dc", V = 1.178, H = 180, U = 300, W = 1350, G = 246,
|
|
476
|
-
function
|
|
475
|
+
var N = typeof window < "u" ? n : t, P = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", F = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", I = .55, L = .204, R = .2145, z = .063, B = "#5659dc", V = 1.178, H = 180, U = 300, W = 1350, G = 246, K = 420, ee = 354, te = 480;
|
|
476
|
+
function q(e, t = 0, n = 1) {
|
|
477
477
|
return Math.min(n, Math.max(t, e));
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function J(e, t, n, r) {
|
|
480
480
|
return e + (t - e) * (1 - Math.exp(-n * r));
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function ne(e) {
|
|
483
483
|
return 1 - (1 - e) ** 3;
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function re(e, t, n) {
|
|
486
486
|
return e + (t - e) * n;
|
|
487
487
|
}
|
|
488
488
|
function ie(e, t, n) {
|
|
489
|
-
let r =
|
|
489
|
+
let r = q((e - t) / (n - t));
|
|
490
490
|
return r * r * (3 - 2 * r);
|
|
491
491
|
}
|
|
492
492
|
function Y(e) {
|
|
@@ -553,9 +553,9 @@ function oe(e, t) {
|
|
|
553
553
|
}
|
|
554
554
|
function se(e) {
|
|
555
555
|
if (e <= H) return z;
|
|
556
|
-
if (e <= 480) return
|
|
556
|
+
if (e <= 480) return re(z, V, ne((e - H) / U));
|
|
557
557
|
let t = e - H - U;
|
|
558
|
-
return t >= W ? 1 : 1 + .17799999999999994 * (1 -
|
|
558
|
+
return t >= W ? 1 : 1 + .17799999999999994 * (1 - q(t / W)) ** 2;
|
|
559
559
|
}
|
|
560
560
|
function ce({ state: e, volume: n, size: r, className: a, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
|
|
561
561
|
let p = i(null), m = i(null), h = i(null), g = i(e), _ = i(n), v = i(u), y = i(!1);
|
|
@@ -576,30 +576,30 @@ function ce({ state: e, volume: n, size: r, className: a, style: c, disabled: l
|
|
|
576
576
|
i(), r.addEventListener("change", i);
|
|
577
577
|
let a = oe(e, b);
|
|
578
578
|
a || (e.style.background = "linear-gradient(180deg, #626afb 2%, #8f9dfb 32%, #dde6fd 52%, #c9d3fb 84%)");
|
|
579
|
-
let o = 0, s = performance.now(), c = g.current, l = Y(c) ? s : void 0, u =
|
|
579
|
+
let o = 0, s = performance.now(), c = g.current, l = Y(c) ? s : void 0, u = q(_.current), d = 1, f = +!!Y(c), x = 1, S = +(c === "connecting"), C = 0, w = (r) => {
|
|
580
580
|
let i = Math.min((r - s) / 1e3, .05);
|
|
581
581
|
s = r;
|
|
582
582
|
let p = g.current, m = y.current;
|
|
583
583
|
p !== c && (Y(p) && !Y(c) && (l = r), (p === "idle" || p === "error") && (l = void 0), c = p);
|
|
584
|
-
let h =
|
|
585
|
-
u = m ? 0 :
|
|
584
|
+
let h = q(_.current);
|
|
585
|
+
u = m ? 0 : J(u, h, h > u ? 11 : 6, i);
|
|
586
586
|
let b = 1;
|
|
587
587
|
p === "listening" && (b = 1 - u * L), p === "speaking" && (b = 1 + u * R);
|
|
588
588
|
let T = Math.abs(b - 1) > Math.abs(d - 1) ? 12 : 6;
|
|
589
|
-
d = m ? 1 :
|
|
589
|
+
d = m ? 1 : J(d, b, T, i);
|
|
590
590
|
let E = Y(p), D = p === "idle" && v.current, O = E || D ? 1 : 0;
|
|
591
|
-
f = m ? O :
|
|
591
|
+
f = m ? O : J(f, O, 14, i);
|
|
592
592
|
let k = E || D ? 1 : .92;
|
|
593
|
-
x = m ? k :
|
|
593
|
+
x = m ? k : J(x, k, 12, i);
|
|
594
594
|
let A = d * x;
|
|
595
595
|
D && (A = z);
|
|
596
596
|
let j = +!D, M = D ? f : 0;
|
|
597
597
|
if (E && l !== void 0 && !m) {
|
|
598
|
-
let e = r - l, t = se(e), n =
|
|
599
|
-
A = t *
|
|
598
|
+
let e = r - l, t = se(e), n = q((e - H - U) / W);
|
|
599
|
+
A = t * re(1, d, n), j = ie(e, G, K), M = f * (1 - ie(e, ee, te)), e >= 1830 && (l = void 0);
|
|
600
600
|
}
|
|
601
601
|
let N = +(p === "connecting");
|
|
602
|
-
S = m ? N :
|
|
602
|
+
S = m ? N : J(S, N, 18, i), e.style.opacity = String(f * j), e.style.transform = `scale(${A})`, t.style.opacity = String(M), t.style.transform = `scale(${A})`, n.style.opacity = String(S), n.style.transform = `rotate(${m ? 45 : r * .34}deg)`;
|
|
603
603
|
let P = .24, F = .1;
|
|
604
604
|
p === "listening" ? (P = .72 + u * .78, F = .28 + u * .32) : p === "speaking" && (P = 1.65 + u * 1.55, F = .66 + u * .34), m || (C += i * P), a?.draw(C, F), o = requestAnimationFrame(w);
|
|
605
605
|
};
|
|
@@ -946,7 +946,7 @@ var xe = typeof window < "u" ? n : t, Se = {
|
|
|
946
946
|
sky: "#0b1a2b",
|
|
947
947
|
horizon: "#1c4661"
|
|
948
948
|
}
|
|
949
|
-
}, Ce = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", we = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_level;\nuniform float u_swell;\nuniform float u_ripple;\nuniform float u_glow;\nuniform float u_tilt;\nuniform float u_listen;\nuniform float u_speak;\nuniform float
|
|
949
|
+
}, Ce = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", we = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_level;\nuniform float u_swell;\nuniform float u_ripple;\nuniform float u_glow;\nuniform float u_tilt;\nuniform float u_listen;\nuniform float u_speak;\nuniform float u_surge;\nuniform vec3 u_deep;\nuniform vec3 u_shallow;\nuniform vec3 u_foam;\nuniform vec3 u_light;\nuniform vec3 u_sky;\nuniform vec3 u_horizon;\n\nfloat swellHeight(float x, float t, float swell) {\n return swell * (\n sin(x * 2.1 + t * 0.9) +\n 0.55 * sin(x * 3.7 - t * 0.63 + 1.3) +\n 0.3 * sin(x * 6.3 + t * 1.21 + 2.1)\n );\n}\n\nfloat rippleHeight(float x, float t, float ripple) {\n return ripple * 0.028 * sin(x * 12.0 - t * 5.2) * sin(x * 7.5 + t * 3.7);\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 p = (uv - 0.5) * 2.0;\n float radius = length(p);\n float edge = 1.0 - smoothstep(0.985, 1.0, radius);\n\n if (edge <= 0.0) discard;\n\n float z = sqrt(max(0.0, 1.0 - radius * radius));\n vec3 normal = vec3(p, z);\n\n // The water sits behind a curved glass front: coordinates bend toward the\n // centre near the rim, so the sea reads as inside a sphere, not painted on.\n vec2 q = p * (1.0 - 0.22 * (1.0 - z));\n float c = cos(u_tilt);\n float s = sin(u_tilt);\n q = vec2(q.x * c - q.y * s, q.x * s + q.y * c);\n\n float t = u_time;\n float front = swellHeight(q.x, t, u_swell) + rippleHeight(q.x, t, u_ripple);\n // The voice is a tide, not a tremor: while she speaks the water rises a little\n // in the middle of the orb and rolls in slow, rounder swells.\n float column = exp(-q.x * q.x * 2.4);\n float voice = u_surge * 0.05 * column + u_surge * 0.015 * sin(q.x * 2.6 - t * 0.9 + 0.4);\n front += voice;\n float waterline = u_level + front;\n float d = q.y - waterline;\n float depth = max(0.0, -d);\n\n // A second, slower swell further back gives the water a body to look into.\n float back = swellHeight(q.x * 0.8 + 1.7, t * 0.72, u_swell * 0.8);\n float backline = u_level - 0.16 + back;\n float backBand = 1.0 - smoothstep(0.0, 0.06, abs(q.y - backline));\n\n vec3 water = mix(u_shallow, u_deep, smoothstep(0.0, 1.05 + u_speak * 0.6, depth));\n water = mix(water, u_shallow * 1.3, u_surge * 0.18 * exp(-depth * 1.8));\n float caustic = sin(q.x * 6.0 + front * 4.0 + t * 0.8) * sin(q.y * 5.0 - t * 0.6 + q.x * 1.5);\n caustic = pow(max(caustic, 0.0), 3.0) * exp(-depth * 1.6) * (0.28 + u_glow * 0.45 + u_surge * 0.2);\n water = mix(water, u_shallow * 1.25, caustic);\n float shaft = pow(max(sin(q.x * 3.0 + t * 0.27), 0.0), 5.0) * exp(-depth * 2.2);\n water = mix(water, u_light, shaft * 0.08 * (0.4 + u_glow));\n water = mix(water, mix(u_shallow, u_foam, 0.3), backBand * 0.14 * step(0.0, -d));\n water = mix(water, u_deep, exp(-depth * 24.0) * 0.18);\n\n vec3 air = mix(u_horizon, u_sky, smoothstep(0.0, 0.85, d));\n float sun = exp(-length(q - vec2(-0.36, 0.58)) * 3.1);\n air = mix(air, u_light, sun * (0.22 + u_glow * 0.36));\n air = mix(air, u_light, exp(-max(d, 0.0) * 6.0) * 0.1 * u_glow);\n\n vec3 color = d < 0.0 ? water : air;\n\n\n float foamWidth = 30.0 - u_surge * 8.0;\n float foam = exp(-abs(d) * foamWidth) * (0.6 + u_surge * 0.3 + u_listen * 0.15);\n float crest = smoothstep(0.35, 1.0, front / max(u_swell * 1.85, 0.001));\n foam += crest * exp(-abs(d) * 16.0) * (0.22 + u_speak * 0.3);\n color = mix(color, u_foam, clamp(foam, 0.0, 0.92));\n\n // Glass: a Fresnel rim, one soft specular, and a little weight at the bottom.\n float fresnel = pow(1.0 - z, 2.8);\n color = mix(color, mix(u_foam, u_light, 0.5), fresnel * 0.32);\n vec3 lightDir = normalize(vec3(-0.48, 0.7, 0.54));\n float spec = pow(max(dot(normal, lightDir), 0.0), 48.0);\n color = mix(color, vec3(1.0), spec * 0.4);\n color *= 1.0 - 0.18 * smoothstep(0.1, 1.0, -p.y) * (1.0 - z * 0.6);\n\n // The drawing buffer uses premultiplied alpha. Premultiply the antialiased\n // perimeter so translucent edge pixels cannot become a bright outline.\n gl_FragColor = vec4(color * edge, edge);\n}\n", Te = .72;
|
|
950
950
|
function Z(e, t = 0, n = 1) {
|
|
951
951
|
return Math.min(n, Math.max(t, e));
|
|
952
952
|
}
|
|
@@ -1034,7 +1034,6 @@ function Ae(e, t, n) {
|
|
|
1034
1034
|
tilt: u("u_tilt"),
|
|
1035
1035
|
listen: u("u_listen"),
|
|
1036
1036
|
speak: u("u_speak"),
|
|
1037
|
-
beat: u("u_beat"),
|
|
1038
1037
|
surge: u("u_surge"),
|
|
1039
1038
|
deep: u("u_deep"),
|
|
1040
1039
|
shallow: u("u_shallow"),
|
|
@@ -1063,7 +1062,7 @@ function Ae(e, t, n) {
|
|
|
1063
1062
|
1
|
|
1064
1063
|
]), r.STATIC_DRAW), r.enableVertexAttribArray(l), r.vertexAttribPointer(l, 2, r.FLOAT, !1, 0, 0), r.uniform2f(d.resolution, p, p), r.uniform3fv(d.deep, n.deep), r.uniform3fv(d.shallow, n.shallow), r.uniform3fv(d.foam, n.foam), r.uniform3fv(d.light, n.glow), r.uniform3fv(d.sky, n.sky), r.uniform3fv(d.horizon, n.horizon), {
|
|
1065
1064
|
draw(e) {
|
|
1066
|
-
r.uniform1f(d.time, e.time), r.uniform1f(d.level, e.level), r.uniform1f(d.swell, e.swell), r.uniform1f(d.ripple, e.ripple), r.uniform1f(d.glow, e.glow), r.uniform1f(d.tilt, e.tilt), r.uniform1f(d.listen, e.listen), r.uniform1f(d.speak, e.speak), r.uniform1f(d.
|
|
1065
|
+
r.uniform1f(d.time, e.time), r.uniform1f(d.level, e.level), r.uniform1f(d.swell, e.swell), r.uniform1f(d.ripple, e.ripple), r.uniform1f(d.glow, e.glow), r.uniform1f(d.tilt, e.tilt), r.uniform1f(d.listen, e.listen), r.uniform1f(d.speak, e.speak), r.uniform1f(d.surge, e.surge), r.drawArrays(r.TRIANGLES, 0, 6);
|
|
1067
1066
|
},
|
|
1068
1067
|
destroy: c
|
|
1069
1068
|
};
|
|
@@ -1076,8 +1075,8 @@ function je(e, t, n, r) {
|
|
|
1076
1075
|
glow: .3 + .2 * Math.sin(r * 2.6),
|
|
1077
1076
|
tiltAmplitude: .02,
|
|
1078
1077
|
levelOffset: 0,
|
|
1079
|
-
corona: .
|
|
1080
|
-
reach: .
|
|
1078
|
+
corona: .3 + .1 * Math.sin(r * 2.6),
|
|
1079
|
+
reach: .24,
|
|
1081
1080
|
ringEvery: 0,
|
|
1082
1081
|
ringStrength: 0,
|
|
1083
1082
|
ringInward: !1,
|
|
@@ -1086,13 +1085,13 @@ function je(e, t, n, r) {
|
|
|
1086
1085
|
pulse: .5
|
|
1087
1086
|
};
|
|
1088
1087
|
case "listening": return {
|
|
1089
|
-
swell: .045 + t * .
|
|
1090
|
-
speed: .
|
|
1088
|
+
swell: .045 + t * .03,
|
|
1089
|
+
speed: .45 + t * .25,
|
|
1091
1090
|
glow: .42 + t * .5,
|
|
1092
1091
|
tiltAmplitude: .03,
|
|
1093
1092
|
levelOffset: t * .05,
|
|
1094
|
-
corona: .
|
|
1095
|
-
reach: .
|
|
1093
|
+
corona: .36 + t * .3,
|
|
1094
|
+
reach: .24 + t * .1,
|
|
1096
1095
|
ringEvery: 1.6 - t * .5,
|
|
1097
1096
|
ringStrength: .3 + t * .35,
|
|
1098
1097
|
ringInward: !0,
|
|
@@ -1103,11 +1102,11 @@ function je(e, t, n, r) {
|
|
|
1103
1102
|
case "thinking": return {
|
|
1104
1103
|
swell: .05,
|
|
1105
1104
|
speed: .7,
|
|
1106
|
-
glow: .
|
|
1107
|
-
tiltAmplitude: .
|
|
1105
|
+
glow: .5 + .1 * Math.sin(r * 1.6),
|
|
1106
|
+
tiltAmplitude: .045,
|
|
1108
1107
|
levelOffset: .01,
|
|
1109
|
-
corona: .
|
|
1110
|
-
reach: .
|
|
1108
|
+
corona: .38 + .08 * Math.sin(r * 1.6),
|
|
1109
|
+
reach: .28,
|
|
1111
1110
|
ringEvery: 0,
|
|
1112
1111
|
ringStrength: 0,
|
|
1113
1112
|
ringInward: !0,
|
|
@@ -1116,15 +1115,15 @@ function je(e, t, n, r) {
|
|
|
1116
1115
|
pulse: 1
|
|
1117
1116
|
};
|
|
1118
1117
|
case "speaking": return {
|
|
1119
|
-
swell: .
|
|
1120
|
-
speed: .
|
|
1121
|
-
glow: .
|
|
1122
|
-
tiltAmplitude: .
|
|
1123
|
-
levelOffset: .
|
|
1124
|
-
corona: .
|
|
1125
|
-
reach: .
|
|
1126
|
-
ringEvery:
|
|
1127
|
-
ringStrength: .3
|
|
1118
|
+
swell: .055 + n * .045,
|
|
1119
|
+
speed: .5 + n * .25,
|
|
1120
|
+
glow: .55 + n * .3,
|
|
1121
|
+
tiltAmplitude: .035,
|
|
1122
|
+
levelOffset: .02 + n * .05,
|
|
1123
|
+
corona: .45 + n * .3,
|
|
1124
|
+
reach: .24 + n * .1,
|
|
1125
|
+
ringEvery: 0,
|
|
1126
|
+
ringStrength: .3,
|
|
1128
1127
|
ringInward: !1,
|
|
1129
1128
|
orbit: 0,
|
|
1130
1129
|
sweep: 0,
|
|
@@ -1152,8 +1151,8 @@ function je(e, t, n, r) {
|
|
|
1152
1151
|
tiltAmplitude: .028,
|
|
1153
1152
|
levelOffset: 0,
|
|
1154
1153
|
corona: .3,
|
|
1155
|
-
reach: .
|
|
1156
|
-
ringEvery:
|
|
1154
|
+
reach: .22,
|
|
1155
|
+
ringEvery: 6,
|
|
1157
1156
|
ringStrength: .25,
|
|
1158
1157
|
ringInward: !1,
|
|
1159
1158
|
orbit: 0,
|
|
@@ -1162,27 +1161,27 @@ function je(e, t, n, r) {
|
|
|
1162
1161
|
};
|
|
1163
1162
|
}
|
|
1164
1163
|
}
|
|
1165
|
-
var Me = .1, Ne = 7.5, Pe =
|
|
1166
|
-
function
|
|
1167
|
-
return Array.from({ length:
|
|
1168
|
-
angle: t /
|
|
1169
|
-
speed: (.
|
|
1170
|
-
radius: 1.
|
|
1171
|
-
size: .
|
|
1164
|
+
var Me = .1, Ne = 7.5, Pe = 3.2, Fe = 14, Ie = 1.7, Le = .3, Re = 2.2, ze = 3, Be = 9, Ve = 3.2, He = 14, Ue = .45, We = .25, Ge = .085;
|
|
1165
|
+
function Ke() {
|
|
1166
|
+
return Array.from({ length: ze }, (e, t) => ({
|
|
1167
|
+
angle: t / ze * Math.PI * 2,
|
|
1168
|
+
speed: (.55 + t % 3 * .2) * (t % 2 == 0 ? 1 : -1),
|
|
1169
|
+
radius: 1.12 + t % 2 * .08,
|
|
1170
|
+
size: .016 + t % 2 * .006,
|
|
1172
1171
|
wobble: .7 + t * .37
|
|
1173
1172
|
}));
|
|
1174
1173
|
}
|
|
1175
|
-
function
|
|
1174
|
+
function qe(e, t, n, r) {
|
|
1176
1175
|
let i = e.getContext("2d");
|
|
1177
1176
|
if (!i) return;
|
|
1178
|
-
let a = Math.min(window.devicePixelRatio || 1, 2), o = t *
|
|
1177
|
+
let a = Math.min(window.devicePixelRatio || 1, 2), o = t * Ie;
|
|
1179
1178
|
e.width = Math.max(1, Math.round(o * a)), e.height = e.width, i.scale(a, a);
|
|
1180
1179
|
let s = o / 2, c = t / 2, l = r === "dark" ? De(n.shallow, n.glow, .35) : n.shallow, u = r === "dark" ? De(n.glow, n.foam, .4) : n.deep, d = r === "dark" ? n.shallow : n.deep, f = r === "dark" ? 1 : .75, p = (e, t, n) => {
|
|
1181
1180
|
i.beginPath(), i.arc(e, t, n, 0, Math.PI * 2);
|
|
1182
1181
|
};
|
|
1183
1182
|
return { draw(e) {
|
|
1184
1183
|
i.clearRect(0, 0, o, o), i.globalCompositeOperation = r === "dark" ? "lighter" : "source-over";
|
|
1185
|
-
let t = c * (1 + e.reach + e.pulse * .
|
|
1184
|
+
let t = c * (1 + e.reach + e.pulse * .03 + Math.sin(e.breath) * .015), n = Z(e.corona * (r === "dark" ? .55 : .5)), a = i.createRadialGradient(s, s, c * .9, s, s, t);
|
|
1186
1185
|
a.addColorStop(0, $(l, n)), a.addColorStop(.3, $(l, n * .5)), a.addColorStop(.65, $(l, n * .15)), a.addColorStop(1, $(l, 0)), i.fillStyle = a, p(s, s, t), i.fill();
|
|
1187
1186
|
let m = Z(e.speak + e.listen * .6);
|
|
1188
1187
|
if (m > .01) {
|
|
@@ -1192,22 +1191,19 @@ function He(e, t, n, r) {
|
|
|
1192
1191
|
let h = Z((.3 + e.glow * .35 + e.speak * .2 + e.listen * .25) * f), g = c * (1.06 + e.speak * .04), _ = i.createRadialGradient(s, s, c * .97, s, s, g);
|
|
1193
1192
|
_.addColorStop(0, $(u, h)), _.addColorStop(1, $(u, 0)), i.fillStyle = _, p(s, s, c * 1.15), i.fill();
|
|
1194
1193
|
for (let t of e.rings) {
|
|
1195
|
-
let n = Z((e.time - t.born) /
|
|
1194
|
+
let n = Z((e.time - t.born) / Re), r = 1 - (1 - n) ** 2.2, a = t.inward ? 1 - r : r, o = c * (1 + Le * a), d = Z((t.inward ? (1 - a) ** .6 * (1 - n ** 4) : (1 - n) ** 1.3) * t.strength);
|
|
1196
1195
|
if (d < .005) continue;
|
|
1197
|
-
let m = c * (.
|
|
1198
|
-
i.lineWidth = m * 4, i.strokeStyle = $(l, d * .
|
|
1196
|
+
let m = c * (.01 + t.strength * .014) * (1 - a * .3);
|
|
1197
|
+
i.lineWidth = m * 4, i.strokeStyle = $(l, d * .16), p(s, s, o), i.stroke(), i.lineWidth = m, i.strokeStyle = $(u, d * .4 * f), p(s, s, o), i.stroke();
|
|
1199
1198
|
}
|
|
1200
|
-
if (e.orbit > .01) {
|
|
1201
|
-
|
|
1202
|
-
for (let
|
|
1203
|
-
let
|
|
1204
|
-
|
|
1205
|
-
let d = n / 14 * a, m = t.angle - o * d, h = s + Math.cos(m) * r, g = s + Math.sin(m) * r, _ = (1 - n / 14) ** 2 * e.orbit;
|
|
1206
|
-
i.fillStyle = $(n === 0 ? u : l, Z(_ * (n === 0 ? 1 : .7) * f)), p(h, g, c * t.size * (1 - n / 14 * .7)), i.fill();
|
|
1207
|
-
}
|
|
1208
|
-
let d = c * t.size * 5, m = s + Math.cos(t.angle) * r, h = s + Math.sin(t.angle) * r, g = i.createRadialGradient(m, h, 0, m, h, d);
|
|
1209
|
-
g.addColorStop(0, $(l, .5 * e.orbit)), g.addColorStop(1, $(l, 0)), i.fillStyle = g, p(m, h, d), i.fill();
|
|
1199
|
+
if (e.orbit > .01) for (let t of e.orbiters) {
|
|
1200
|
+
let n = Math.sin(e.time * t.wobble) * .05, r = c * (t.radius + n), a = .8 + e.orbit * .7, o = t.speed > 0 ? 1 : -1;
|
|
1201
|
+
for (let n = 0; n < 14; n += 1) {
|
|
1202
|
+
let d = n / 14 * a, m = t.angle - o * d, h = s + Math.cos(m) * r, g = s + Math.sin(m) * r, _ = (1 - n / 14) ** 2 * e.orbit;
|
|
1203
|
+
i.fillStyle = $(n === 0 ? u : l, Z(_ * (n === 0 ? 1 : .7) * f)), p(h, g, c * t.size * (1 - n / 14 * .7)), i.fill();
|
|
1210
1204
|
}
|
|
1205
|
+
let d = c * t.size * 5, m = s + Math.cos(t.angle) * r, h = s + Math.sin(t.angle) * r, g = i.createRadialGradient(m, h, 0, m, h, d);
|
|
1206
|
+
g.addColorStop(0, $(l, .35 * e.orbit)), g.addColorStop(1, $(l, 0)), i.fillStyle = g, p(m, h, d), i.fill();
|
|
1211
1207
|
}
|
|
1212
1208
|
if (e.sweep > .01) {
|
|
1213
1209
|
let t = [{
|
|
@@ -1223,7 +1219,7 @@ function He(e, t, n, r) {
|
|
|
1223
1219
|
}
|
|
1224
1220
|
} };
|
|
1225
1221
|
}
|
|
1226
|
-
function
|
|
1222
|
+
function Je({ state: e, volume: n, size: r, scheme: a = "light", palette: c, className: l, style: u, disabled: d = !1, interactive: f = !1, onClick: p, ...m }) {
|
|
1227
1223
|
let h = i(null), g = i(null), _ = i(null), v = i(e), y = i(n), b = i(!1);
|
|
1228
1224
|
xe(() => {
|
|
1229
1225
|
v.current = e, y.current = n;
|
|
@@ -1238,53 +1234,62 @@ function Ue({ state: e, volume: n, size: r, scheme: a = "light", palette: c, cla
|
|
|
1238
1234
|
o(), i.addEventListener("change", o);
|
|
1239
1235
|
let s = Ae(e, x, r);
|
|
1240
1236
|
s || (e.style.background = `linear-gradient(180deg, ${$(r.sky, 1)} 0%, ${$(r.horizon, 1)} 44%, ${$(r.shallow, 1)} 48%, ${$(r.deep, 1)} 100%)`);
|
|
1241
|
-
let c =
|
|
1237
|
+
let c = qe(t, x, r, a), l = 0, u = performance.now(), d = 0, f = 0, p = 0, m = 0, S = Z(y.current), w = 0, T = 0, E = .036, D = .36, O = .26, k = .028, A = 0, j = .3, M = .24, N = 0, P = 0, F = .3, I = 0, L = 0, R = 0, z = We, B = 0, V = 0, H = !1, U = 0, W = [], G = Ke(), K = (e) => {
|
|
1242
1238
|
let t = Math.min((e - u) / 1e3, .05);
|
|
1243
1239
|
u = e;
|
|
1244
1240
|
let r = v.current, i = b.current, a = Z(y.current);
|
|
1245
|
-
S = i ? 0 : Q(S, a, a > S ?
|
|
1241
|
+
S = i ? 0 : Q(S, a, a > S ? 4 : 1.5, t);
|
|
1246
1242
|
let o = r === "listening" ? S : 0, h = r === "speaking" ? S : 0;
|
|
1247
|
-
w = Q(w, o, o > w ?
|
|
1243
|
+
w = Q(w, o, o > w ? 4 : 1.5, t), T = Q(T, h, h > T ? 4 : 1.5, t), f += t;
|
|
1248
1244
|
let g = je(r, w, T, f);
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1245
|
+
E = Q(E, g.swell, 2.4, t), D = Q(D, g.speed, 2.4, t), O = Q(O, g.glow, 3.2, t), k = Q(k, g.tiltAmplitude, 1.8, t), A = Q(A, g.levelOffset, 3, t), j = Q(j, g.corona, g.corona > j ? 6 : 2.5, t), M = Q(M, g.reach, g.reach > M ? 7 : 2.5, t), N = Q(N, g.orbit, 3, t), P = Q(P, g.sweep, 3, t), F = Q(F, g.pulse, 2.5, t), R += ((r === "speaking" ? S : 0) - L) * Fe * t, R *= Math.exp(-8 * t), L += R * t;
|
|
1246
|
+
let _ = r === "speaking" && !i;
|
|
1247
|
+
z = Math.max(_ ? a : 0, We, z - (z - We) * Ue * t);
|
|
1248
|
+
let x = _ ? Z(a / z) : 0;
|
|
1249
|
+
if (B = Q(B, x, x > B ? Be : Ve, t), V = Q(V, B, He, t), !i) {
|
|
1250
|
+
d += t * D, p += t * Math.PI * 2 / Ne, m += t * .31, I += t * Math.PI * 2 / Pe;
|
|
1251
|
+
for (let e of G) e.angle += t * e.speed * (.6 + N * .9);
|
|
1252
|
+
U += t;
|
|
1253
|
+
let e = V > .55;
|
|
1254
|
+
for (_ ? e && !H && U >= 1 && (U = 0, W.push({
|
|
1255
|
+
born: f,
|
|
1256
|
+
strength: g.ringStrength,
|
|
1257
|
+
inward: !1
|
|
1258
|
+
})) : g.ringEvery > 0 && (r !== "listening" || w > .03) && U >= g.ringEvery && (U = 0, W.push({
|
|
1253
1259
|
born: f,
|
|
1254
1260
|
strength: g.ringStrength,
|
|
1255
1261
|
inward: g.ringInward
|
|
1256
|
-
}));
|
|
1262
|
+
})), H = e; W.length > 0 && f - W[0].born > Re;) W.shift();
|
|
1257
1263
|
}
|
|
1258
|
-
let
|
|
1264
|
+
let C = Me + A + Math.sin(p) * .022, ee = Math.sin(m) * k + Math.sin(m * 2.3 + .7) * .006, te = i ? 0 : Z(L);
|
|
1259
1265
|
s?.draw({
|
|
1260
1266
|
time: d,
|
|
1261
|
-
level:
|
|
1267
|
+
level: C,
|
|
1262
1268
|
swell: i ? .012 : E,
|
|
1263
1269
|
ripple: i ? 0 : w,
|
|
1264
1270
|
glow: O,
|
|
1265
|
-
tilt: i ? 0 :
|
|
1271
|
+
tilt: i ? 0 : ee,
|
|
1266
1272
|
listen: w,
|
|
1267
1273
|
speak: T,
|
|
1268
|
-
|
|
1269
|
-
surge: W
|
|
1274
|
+
surge: te
|
|
1270
1275
|
});
|
|
1271
|
-
let
|
|
1272
|
-
n.style.transform = i ? "none" : `scale(${
|
|
1276
|
+
let q = (.5 + .5 * Math.sin(I)) * F, J = V ** .85 * Ge, ne = 1 + q * .012 + Math.sin(p) * .005 + J + w * .015;
|
|
1277
|
+
n.style.transform = i ? "none" : `scale(${ne})`, c?.draw({
|
|
1273
1278
|
time: f,
|
|
1274
|
-
corona: i ? j * .6 : j,
|
|
1279
|
+
corona: i ? j * .6 : j + V * .2,
|
|
1275
1280
|
reach: M,
|
|
1276
1281
|
glow: O,
|
|
1277
|
-
speak: T,
|
|
1282
|
+
speak: Math.max(T, V * .8),
|
|
1278
1283
|
listen: w,
|
|
1279
1284
|
orbit: i ? 0 : N,
|
|
1280
1285
|
sweep: i ? 0 : P,
|
|
1281
|
-
pulse:
|
|
1286
|
+
pulse: q,
|
|
1282
1287
|
breath: p,
|
|
1283
|
-
rings: i ? [] :
|
|
1284
|
-
orbiters:
|
|
1285
|
-
}), l = requestAnimationFrame(
|
|
1288
|
+
rings: i ? [] : W,
|
|
1289
|
+
orbiters: G
|
|
1290
|
+
}), l = requestAnimationFrame(K);
|
|
1286
1291
|
};
|
|
1287
|
-
return l = requestAnimationFrame(
|
|
1292
|
+
return l = requestAnimationFrame(K), () => {
|
|
1288
1293
|
cancelAnimationFrame(l), i.removeEventListener("change", o), s?.destroy();
|
|
1289
1294
|
};
|
|
1290
1295
|
}, [
|
|
@@ -1300,7 +1305,7 @@ function Ue({ state: e, volume: n, size: r, scheme: a = "light", palette: c, cla
|
|
|
1300
1305
|
justifyContent: "center",
|
|
1301
1306
|
position: "relative",
|
|
1302
1307
|
...u
|
|
1303
|
-
}, T = x *
|
|
1308
|
+
}, T = x * Ie, E = /* @__PURE__ */ s("span", {
|
|
1304
1309
|
ref: _,
|
|
1305
1310
|
style: {
|
|
1306
1311
|
position: "relative",
|
|
@@ -1369,7 +1374,7 @@ function Ue({ state: e, volume: n, size: r, scheme: a = "light", palette: c, cla
|
|
|
1369
1374
|
}
|
|
1370
1375
|
//#endregion
|
|
1371
1376
|
//#region src/components/Orb/Orb.tsx
|
|
1372
|
-
function
|
|
1377
|
+
function Ye({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", size: p = 200, scheme: m, palette: h, className: g, style: _, disabled: v = !1, interactive: y = !0, onStart: b, onStop: x, renderTheme: S, ...C }) {
|
|
1373
1378
|
let [w, T] = a({ state: "idle" });
|
|
1374
1379
|
t(() => {
|
|
1375
1380
|
if (T({ state: "idle" }), u) return u.subscribe(T);
|
|
@@ -1468,7 +1473,7 @@ function We({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", si
|
|
|
1468
1473
|
...W,
|
|
1469
1474
|
onClick: B
|
|
1470
1475
|
});
|
|
1471
|
-
case "ocean": return /* @__PURE__ */ o(
|
|
1476
|
+
case "ocean": return /* @__PURE__ */ o(Je, {
|
|
1472
1477
|
...W,
|
|
1473
1478
|
scheme: m,
|
|
1474
1479
|
palette: h,
|
|
@@ -1483,4 +1488,4 @@ function We({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", si
|
|
|
1483
1488
|
}
|
|
1484
1489
|
}
|
|
1485
1490
|
//#endregion
|
|
1486
|
-
export {
|
|
1491
|
+
export { Ye as Orb, Ye as VoiceOrb };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/orb-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "React voice agent UI components with audio-reactive adapters for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom voice AI apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/orb-ui.cjs",
|