1 Star 0 Fork 0

J.Lee/blog-demos

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.vue 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
lsj 提交于 1个月前 . 退出清理webgl three
<!--
* @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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsj97/blog-demos.git
git@gitee.com:lsj97/blog-demos.git
lsj97
blog-demos
blog-demos
master

搜索帮助