|
|

楼主 |
发表于 2025-6-8 20:00
|
显示全部楼层
帖子代码
- <style>
- #tz { margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); min-height: 80vh; aspect-ratio: 16/9; background: #eee url('https://638183.freep.cn/638183/t24/w4/underground.webp') no-repeat center/cover; box-shadow: 2px 2px 8px #000; display: grid; place-items: center; z-index: 1; position: relative; }
- #btnFs { bottom: 20px; color: #eee; text-align: center; }
- #btnFs:hover { color: red; }
- #player { position: absolute; top: -1000px; }
- </style>
- <div id="tz">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1374221428" autoplay loop></audio>
- <div id="player" title="播放/暂停"></div>
- </div>
- <script type="module">
- import * as THREE from 'https://638183.freep.cn/638183/3dev/build/three.module.min.js';
- import { FS } from 'https://638183.freep.cn/638183/web/ku/FS.js';
- const scene = new THREE.Scene();
- const camera = new THREE.PerspectiveCamera(45, tz.offsetWidth/tz.offsetHeight, 0.1, 1000);
- camera.position.z = 10;
- const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
- renderer.setClearAlpha(0.0);
- renderer.setSize(tz.offsetWidth, tz.offsetHeight);
- const clock = new THREE.Clock();
- tz.appendChild(renderer.domElement);
- const texture = new THREE.TextureLoader().load('https://638183.freep.cn/638183/small/2025/t01.webp');
- const mesh = new THREE.Mesh(
- new THREE.SphereGeometry(1, 64, 64),
- new THREE.MeshBasicMaterial({ map: texture })
- );
- mesh.position.set(0, -2, 0);
- scene.add(mesh);
- const particleContainer = new THREE.Object3D(); // 粒子容器
- const total = 1000;
- for (let i = 0; i < total; i++) {
- const faces = Math.floor(Math.random() * 3 + 1);
- const geometry = new THREE.SphereGeometry(0.4);
- const material = new THREE.MeshBasicMaterial({
- color: new THREE.Color(Math.random(), Math.random(), Math.random()),
- map: texture
- });
- const particle = new THREE.Mesh(geometry, material);
- particle.position.set(
- Math.random() * 100 - 50,
- Math.random() * 100 - 50,
- Math.random() * 300 - 150
- );
- particleContainer.add(particle);
- }
- scene.add(particleContainer);
- const isMess = (event) => {
- const raycaster = new THREE.Raycaster();
- const pointer = new THREE.Vector2();
- let intersects = [];
- pointer.x = (event.offsetX / tz.offsetWidth) * 2 - 1;
- pointer.y = -(event.offsetY / tz.offsetHeight) * 2 + 1;
- raycaster.setFromCamera(pointer, camera);
- intersects = raycaster.intersectObjects([mesh], true);
- return intersects.length > 0;
- }
- tz.onmousemove = (e) => {
- isMess(e)
- ? (tz.style.cursor = 'pointer', tz.title = '播放/暂停 Alt+X')
- : (tz.style.cursor = 'default', tz.title = '');
- };
- tz.onclick = (e) => {
- if (isMess(e)) player.click();
- };
- const animate = () => {
- requestAnimationFrame(animate);
- const delta = clock.getDelta();
- mesh.rotation.x += delta;
- mesh.rotation.y -= delta;
- particleContainer.rotation.x += delta / 5;
- particleContainer.rotation.y -= delta / 5;
- renderer.render(scene, camera);
- };
- window.onresize = () => {
- camera.aspect = tz.offsetWidth / tz.offsetHeight;
- camera.updateProjectionMatrix();
- renderer.setSize(tz.offsetWidth, tz.offsetHeight);
- };
- aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
- animate();
- FS(tz, player);
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +30 |
金钱 +60 |
经验 +30 |
收起
理由
|
花飞飞
| + 30 |
+ 60 |
+ 30 |
很给力! |
查看全部评分
|