代码拉取完成,页面将自动刷新
<!--
* @Author: 李双江
* @Date: 2025/5/7 19:14:03
* @LastEditors: 李双江
* @LastEditTime: 2025/5/7 19:14:03
* @Description:
-->
<template>
<div id="app">
<div class="hero">
<h1>Sphere</h1>
<h2>Packing</h2>
</div>
<canvas id="webgl-canvas"></canvas>
</div>
</template>
<script setup lang="ts">
import Spheres1Background from './sphere.js'
import {onMounted, onUnmounted} from "vue";
import {useIsMobile} from "@/hooks/useIsMobile.mjs";
let sphere = null
onMounted(() => {
sphere= Spheres1Background(document.getElementById('webgl-canvas'), {
count: useIsMobile().value ? 100 : 300,
minSize: 0.3,
maxSize: 1,
gravity: 0.5
})
})
onUnmounted(() => {
sphere!.dispose()
})
</script>
<style scoped lang="scss">
body, html, #app {
margin: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(0, 0, 0, 0.5) 200%);
}
#app {
position: relative;
height: 100%;
font-family: "Montserrat", serif;
}
.hero {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
h1, h2 {
margin: 0;
padding: 0;
color: black;
text-transform: uppercase;
text-shadow: 0 0 20px rgba(255, 255, 255, 1);
line-height: 100%;
user-select: none;
}
h1 {
position: relative;
z-index: 2;
font-size: 100px;
font-weight: 700;
}
h2 {
font-size: 80px;
font-weight: 500;
}
#webgl-canvas {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
z-index: 1;
}
.buttons {
position: fixed;
width: 100%;
bottom: 15px;
z-index: 2;
display: flex;
justify-content: center;
align-items: center;
gap: 15px;
}
button {
font-family: "Montserrat", serif;
background: rgba(255, 255, 255, 0.5);
border-radius: 5px;
border: 1px solid grey;
padding: 4px 8px;
}
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。