Add tentacles
All checks were successful
On Push Deploy / deploy (push) Successful in 20s

This commit is contained in:
Johnny322
2026-02-10 16:18:05 +01:00
parent 7cea64e8fe
commit 05d6a3a9bc
2 changed files with 59 additions and 40 deletions

View File

@@ -178,13 +178,17 @@
'--ray-hue': rayHue.toFixed(0)
}"
></div>
<div
class="pulse-rays"
:style="{
'--ray': rayLevel.toFixed(3),
'--ray-hue': rayHue.toFixed(0)
}"
></div>
<div class="pulse-tentacles">
<span
v-for="(level, index) in tentacleLevels"
:key="index"
class="tentacle"
:style="{
'--level': level.toFixed(3),
'--index': index
}"
></span>
</div>
<audio
ref="player"
v-if="currentClipUrl"
@@ -283,7 +287,8 @@ export default {
mediaElement: null as HTMLAudioElement | null,
rayLevel: 0,
rayHue: 200,
isAnswerClip: false
isAnswerClip: false,
tentacleLevels: Array.from({ length: 12 }, () => 0)
}
},
async mounted() {
@@ -369,6 +374,7 @@ export default {
this.frequencyData = new Uint8Array(analyser.frequencyBinCount)
this.pulseLevel = 0
this.rayLevel = 0
this.tentacleLevels = this.tentacleLevels.map(() => 0)
},
teardownAudio() {
if (this.rafId) {
@@ -389,6 +395,7 @@ export default {
this.isPlaying = false
this.pulseLevel = 0
this.rayLevel = 0
this.tentacleLevels = this.tentacleLevels.map(() => 0)
},
startPulse() {
if (!this.analyser || !this.analyserData || !this.frequencyData) return
@@ -428,6 +435,19 @@ export default {
this.rayLevel = this.rayLevel * 0.78 + rayTarget * 0.22
const hueTarget = 180 + highAvg * 120
this.rayHue = this.rayHue * 0.8 + hueTarget * 0.2
const bandCount = this.tentacleLevels.length
const binSize = Math.max(1, Math.floor(freq.length / bandCount))
for (let i = 0; i < bandCount; i += 1) {
const start = i * binSize
const end = i === bandCount - 1 ? freq.length : start + binSize
let bandSum = 0
for (let j = start; j < end; j += 1) bandSum += freq[j]
const avg = bandSum / Math.max(1, end - start) / 255
const shaped = Math.pow(Math.min(1, avg * 1.4), 1.6)
this.tentacleLevels[i] =
this.tentacleLevels[i] * 0.6 + shaped * 0.4
}
this.rafId = requestAnimationFrame(tick)
}