generated from cameronking4/VapiBlocks
-
Notifications
You must be signed in to change notification settings - Fork 8
/
glob.tsx
62 lines (57 loc) · 1.66 KB
/
glob.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React, { useState, useEffect } from 'react';
import AbstractBall from '@/components/abstract-ball';
import ConfigSheet from '@/components/examples/config-drawer';
import useWebRTCAudioSession from '@/hooks/use-webrtc';
import { Button } from '@/components/ui/button';
import { MicIcon, PhoneOff } from 'lucide-react';
const globConfig = {
perlinTime: 50.0,
perlinDNoise: 2.5,
chromaRGBr: 7.5,
chromaRGBg: 5,
chromaRGBb: 7,
chromaRGBn: 0,
chromaRGBm: 1.0,
sphereWireframe: false,
spherePoints: false,
spherePsize: 1.0,
cameraSpeedY: 0.0,
cameraSpeedX: 0.0,
cameraZoom: 175,
cameraGuide: false,
perlinMorph: 5.5,
};
const ParentComponent: React.FC = () => {
const { currentVolume, isSessionActive, handleStartStopClick } = useWebRTCAudioSession('alloy');
const [config, setConfig] = useState(globConfig);
useEffect(() => {
if (!isSessionActive) {
setConfig(globConfig);
return;
}
// Only update when volume changes and session is active
if (isSessionActive && currentVolume > 0.01) {
setConfig({
...globConfig,
perlinTime: 20.0,
perlinMorph: 25.0,
});
} else {
setConfig({
...globConfig,
});
}
}, [isSessionActive, currentVolume]);
return (
<div style={{ width: '100%', height: '100%' }}>
<ConfigSheet config={config} setConfig={setConfig} />
<AbstractBall {...config} />
<div className="flex justify-center mt-4">
<Button onClick={handleStartStopClick} className='m-2'>
{isSessionActive ? <PhoneOff size={18} /> : <MicIcon size={18} />}
</Button>
</div>
</div>
);
};
export default ParentComponent;