@w0nna_dev/lina-widget 1.0.0 → 1.0.2
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/lina-widget.es.js +2021 -1877
- package/dist/lina-widget.umd.js +211 -208
- package/dist/src/core/orb/OrbRenderer.d.ts +1 -0
- package/dist/src/core/orb/glow.glsl.d.ts +1 -1
- package/dist/src/core/orb/orb.vert.glsl.d.ts +1 -1
- package/dist/src/lina/components/LinaWidget.d.ts +24 -7
- package/dist/src/orb/core/OrbRenderer.d.ts +1 -0
- package/dist/src/orb/shaders/glow.glsl.d.ts +1 -1
- package/dist/src/orb/shaders/orb.vert.glsl.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const glowVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;\n\n // Scale up for glow halo\n vec3 pos = position * 1.3;\n\n // Pre-calculate view intensity for smooth falloff\n vec3 viewDir = normalize(-vPosition);\n vIntensity = pow(1.0 - abs(dot(viewDir, vNormal)), 1.5);\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
2
|
-
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect\n float pulse = sin(uTime * uPulseSpeed) * 0.
|
|
2
|
+
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect - very subtle\n float pulse = sin(uTime * uPulseSpeed * 0.3) * 0.03 + 0.97;\n pulse += uAudioLevel * 0.15;\n\n // Smooth radial glow using pre-calculated intensity\n float glow = vIntensity * uGlowIntensity * pulse;\n\n // Very soft falloff for diffuse glow\n glow = pow(glow, 0.8);\n glow *= smoothstep(0.0, 0.3, vIntensity);\n\n // Color with audio reactivity\n vec3 glowColor = uGlowColor * (1.0 + uAudioLevel * 0.5);\n\n // Softer alpha for more diffuse appearance\n gl_FragColor = vec4(glowColor, glow * 0.4);\n}\n";
|
|
3
3
|
export declare const atmosphereVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = position;\n\n // Scale for outer atmosphere\n vec3 pos = position * 1.5;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
4
4
|
export declare const atmosphereFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uAtmosphereColor;\nuniform float uAtmosphereIntensity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vec3 viewDirection = normalize(cameraPosition - vPosition);\n\n // Inverse fresnel for atmosphere (stronger at edges, fading to center)\n float intensity = pow(1.0 - max(dot(viewDirection, vNormal), 0.0), 3.0);\n\n // Audio pulsing\n float pulse = 1.0 + uAudioLevel * 0.4;\n\n // Breathing animation\n float breathing = sin(uTime * 0.5) * 0.1 + 0.9;\n\n float alpha = intensity * uAtmosphereIntensity * pulse * breathing;\n\n // Fade out at very edges\n alpha *= smoothstep(1.0, 0.3, intensity);\n\n vec3 color = uAtmosphereColor * (1.0 + uAudioLevel * 0.3);\n\n gl_FragColor = vec4(color, alpha * 0.4);\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement\n float baseNoise = fbm(noisePos,
|
|
1
|
+
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement - very smooth, minimal detail\n float baseNoise = fbm(noisePos, 2) * 0.05;\n\n // Audio-reactive displacement - very low frequencies for smooth waves\n float bassDisplacement = snoise(noisePos * 0.3 + t * 0.1) * uAudioBass * 0.08 * uAudioReactivity;\n float midDisplacement = snoise(noisePos * 0.4 + t * 0.12) * uAudioMid * 0.05 * uAudioReactivity;\n float trebleDisplacement = snoise(noisePos * 0.5 + t * 0.15) * uAudioTreble * 0.02 * uAudioReactivity;\n\n // Combine all displacement\n float totalDisplacement = baseNoise + bassDisplacement + midDisplacement + trebleDisplacement;\n\n // Apply morphing strength\n totalDisplacement *= uMorphStrength;\n\n // Add breathing effect - very subtle\n float breathing = sin(uTime * 0.3) * 0.005 * (1.0 + uAudioLevel * 0.2);\n totalDisplacement += breathing;\n\n // Apply displacement along normal\n pos += normal * totalDisplacement;\n\n vDisplacement = totalDisplacement;\n vElevation = pos.y;\n vPosition = pos;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
@@ -1,31 +1,46 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { LinaState, LinaEmotion, LinaColors } from '../core';
|
|
3
|
+
export type CallStatus = 'idle' | 'connecting' | 'active' | 'ending' | 'error' | 'mic-denied';
|
|
3
4
|
export declare class LinaWidget extends LitElement {
|
|
4
5
|
static styles: import('lit').CSSResult;
|
|
5
6
|
private orbRenderer;
|
|
6
7
|
private orbContainerRef;
|
|
7
8
|
private audioSimPhase;
|
|
8
9
|
private animationId;
|
|
10
|
+
private callManager;
|
|
9
11
|
size: number;
|
|
10
12
|
headerLogo: string;
|
|
11
13
|
headerTitle: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
showBranding: boolean;
|
|
15
|
+
version: string;
|
|
16
|
+
agentId: string;
|
|
17
|
+
voiceServiceUrl: string;
|
|
18
|
+
btnStartText: string;
|
|
19
|
+
btnEndText: string;
|
|
17
20
|
colors: Partial<LinaColors>;
|
|
18
21
|
private currentState;
|
|
19
|
-
private
|
|
22
|
+
private callStatus;
|
|
23
|
+
private _hasMicPermission;
|
|
20
24
|
connectedCallback(): void;
|
|
21
25
|
disconnectedCallback(): void;
|
|
22
26
|
firstUpdated(): void;
|
|
27
|
+
private checkMicrophonePermission;
|
|
23
28
|
private initializeOrb;
|
|
29
|
+
private initializeCallManager;
|
|
30
|
+
private handleCallStatusChange;
|
|
24
31
|
private cleanup;
|
|
25
32
|
private startIdleAnimation;
|
|
26
33
|
private startActiveAnimation;
|
|
27
|
-
private
|
|
34
|
+
private connectAudioStream;
|
|
28
35
|
private handleCallClick;
|
|
36
|
+
/**
|
|
37
|
+
* Start a call
|
|
38
|
+
*/
|
|
39
|
+
startCall(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* End the call
|
|
42
|
+
*/
|
|
43
|
+
endCall(): Promise<void>;
|
|
29
44
|
setState(state: LinaState): void;
|
|
30
45
|
setAudioLevel(level: number): void;
|
|
31
46
|
setColors(colors: Partial<LinaColors>): void;
|
|
@@ -36,6 +51,8 @@ export declare class LinaWidget extends LitElement {
|
|
|
36
51
|
setEmotion(emotion: LinaEmotion): void;
|
|
37
52
|
getEmotion(): LinaEmotion | undefined;
|
|
38
53
|
getState(): LinaState;
|
|
54
|
+
getCallStatus(): CallStatus;
|
|
55
|
+
private getButtonContent;
|
|
39
56
|
render(): import('lit-html').TemplateResult<1>;
|
|
40
57
|
}
|
|
41
58
|
declare global {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const glowVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = (modelViewMatrix * vec4(position, 1.0)).xyz;\n\n // Scale up for glow halo\n vec3 pos = position * 1.3;\n\n // Pre-calculate view intensity for smooth falloff\n vec3 viewDir = normalize(-vPosition);\n vIntensity = pow(1.0 - abs(dot(viewDir, vNormal)), 1.5);\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
2
|
-
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect\n float pulse = sin(uTime * uPulseSpeed) * 0.
|
|
2
|
+
export declare const glowFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uGlowColor;\nuniform float uGlowIntensity;\nuniform float uPulseSpeed;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n // Pulsing effect - very subtle\n float pulse = sin(uTime * uPulseSpeed * 0.3) * 0.03 + 0.97;\n pulse += uAudioLevel * 0.15;\n\n // Smooth radial glow using pre-calculated intensity\n float glow = vIntensity * uGlowIntensity * pulse;\n\n // Very soft falloff for diffuse glow\n glow = pow(glow, 0.8);\n glow *= smoothstep(0.0, 0.3, vIntensity);\n\n // Color with audio reactivity\n vec3 glowColor = uGlowColor * (1.0 + uAudioLevel * 0.5);\n\n // Softer alpha for more diffuse appearance\n gl_FragColor = vec4(glowColor, glow * 0.4);\n}\n";
|
|
3
3
|
export declare const atmosphereVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = position;\n\n // Scale for outer atmosphere\n vec3 pos = position * 1.5;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|
|
4
4
|
export declare const atmosphereFragmentShader = "\nuniform float uTime;\nuniform float uAudioLevel;\nuniform vec3 uAtmosphereColor;\nuniform float uAtmosphereIntensity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vec3 viewDirection = normalize(cameraPosition - vPosition);\n\n // Inverse fresnel for atmosphere (stronger at edges, fading to center)\n float intensity = pow(1.0 - max(dot(viewDirection, vNormal), 0.0), 3.0);\n\n // Audio pulsing\n float pulse = 1.0 + uAudioLevel * 0.4;\n\n // Breathing animation\n float breathing = sin(uTime * 0.5) * 0.1 + 0.9;\n\n float alpha = intensity * uAtmosphereIntensity * pulse * breathing;\n\n // Fade out at very edges\n alpha *= smoothstep(1.0, 0.3, intensity);\n\n vec3 color = uAtmosphereColor * (1.0 + uAudioLevel * 0.3);\n\n gl_FragColor = vec4(color, alpha * 0.4);\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement\n float baseNoise = fbm(noisePos,
|
|
1
|
+
export declare const orbVertexShader = "\nuniform float uTime;\nuniform float uAudioBass;\nuniform float uAudioMid;\nuniform float uAudioTreble;\nuniform float uAudioLevel;\nuniform float uMorphStrength;\nuniform float uNoiseScale;\nuniform float uNoiseSpeed;\nuniform float uAudioReactivity;\n\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying vec2 vUv;\nvarying float vDisplacement;\nvarying float vElevation;\n\n// Simplex 3D noise\nvec4 permute(vec4 x) {\n return mod(((x * 34.0) + 1.0) * x, 289.0);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v) {\n const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n vec3 i = floor(v + dot(v, C.yyy));\n vec3 x0 = v - i + dot(i, C.xxx);\n\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min(g.xyz, l.zxy);\n vec3 i2 = max(g.xyz, l.zxy);\n\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy;\n vec3 x3 = x0 - D.yyy;\n\n i = mod(i, 289.0);\n vec4 p = permute(permute(permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n\n float n_ = 1.0 / 7.0;\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_);\n\n vec4 x = x_ * ns.x + ns.yyyy;\n vec4 y = y_ * ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4(x.xy, y.xy);\n vec4 b1 = vec4(x.zw, y.zw);\n\n vec4 s0 = floor(b0) * 2.0 + 1.0;\n vec4 s1 = floor(b1) * 2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n\n vec3 p0 = vec3(a0.xy, h.x);\n vec3 p1 = vec3(a0.zw, h.y);\n vec3 p2 = vec3(a1.xy, h.z);\n vec3 p3 = vec3(a1.zw, h.w);\n\n vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n m = m * m;\n return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\n\n// Fractal Brownian Motion\nfloat fbm(vec3 p, int octaves) {\n float value = 0.0;\n float amplitude = 0.5;\n float frequency = 1.0;\n\n for (int i = 0; i < 6; i++) {\n if (i >= octaves) break;\n value += amplitude * snoise(p * frequency);\n amplitude *= 0.5;\n frequency *= 2.0;\n }\n\n return value;\n}\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n\n vec3 pos = position;\n\n // Time-based animation\n float t = uTime * uNoiseSpeed;\n\n // Multi-layered noise displacement\n vec3 noisePos = pos * uNoiseScale + t * 0.3;\n\n // Base organic movement - very smooth, minimal detail\n float baseNoise = fbm(noisePos, 2) * 0.05;\n\n // Audio-reactive displacement - very low frequencies for smooth waves\n float bassDisplacement = snoise(noisePos * 0.3 + t * 0.1) * uAudioBass * 0.08 * uAudioReactivity;\n float midDisplacement = snoise(noisePos * 0.4 + t * 0.12) * uAudioMid * 0.05 * uAudioReactivity;\n float trebleDisplacement = snoise(noisePos * 0.5 + t * 0.15) * uAudioTreble * 0.02 * uAudioReactivity;\n\n // Combine all displacement\n float totalDisplacement = baseNoise + bassDisplacement + midDisplacement + trebleDisplacement;\n\n // Apply morphing strength\n totalDisplacement *= uMorphStrength;\n\n // Add breathing effect - very subtle\n float breathing = sin(uTime * 0.3) * 0.005 * (1.0 + uAudioLevel * 0.2);\n totalDisplacement += breathing;\n\n // Apply displacement along normal\n pos += normal * totalDisplacement;\n\n vDisplacement = totalDisplacement;\n vElevation = pos.y;\n vPosition = pos;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n}\n";
|