feat: 在 App.vue 中优化动画性能,添加页面可见性检测,支持动画暂停和恢复,同时更新粒子背景组件的粒子更新逻辑,提升整体用户体验。

This commit is contained in:
Cat Tom
2025-03-26 12:42:13 +08:00
parent 35e8fda1b8
commit 298b5410bb
2 changed files with 53 additions and 6 deletions

View File

@@ -199,15 +199,14 @@ const animate = () => {
const time = Date.now() * 0.00005
particles.material.uniforms.time.value = time
if (time % 2 === 0) {
updateParticles()
}
// 更新粒子位置
updateParticles(time)
renderer.render(scene, camera)
}
}
const updateParticles = () => {
const updateParticles = (time) => {
const positions = particles.geometry.attributes.position.array
for (let i = 0; i < config.particleCount; i++) {