|
|

楼主 |
发表于 2025-6-29 11:13
|
显示全部楼层
音频为 枫尚 / 老陈阿 的小串串系列。帖子代码:
- <style>
- #papa { margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); height: auto; aspect-ratio: 16/9; background: url('https://638183.freep.cn/638183/t24/5/2501.jpg') no-repeat center/cover; box-shadow: 2px 2px 8px #000; display: grid; place-items: center; z-index: 1; position: relative; }
- #btnFs { bottom: 30px; color: #eee; }
- #player { position: absolute; left: -1000px; }
- </style>
- <div id="papa">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=2042902830" autoplay loop></audio>
- <div id="player"></div>
- </div>
- <script type="module">
- import { THREE, scene, camera, renderer, clock, basic3, click3 } from 'https://638183.freep.cn/638183/3dev/3/3basic.js?v=1.0';
- import TWEEN from 'https://638183.freep.cn/638183/3dev/examples/jsm/libs/tween.module.js';
- import { FS } from 'https://638183.freep.cn/638183/web/ku/FS.js';
- basic3(papa, aud.paused);
- // 绘制点云球体 :点颜色随机
- const geometry = new THREE.SphereGeometry(0.8, 64, 64);
- const count = geometry.attributes.position.count;
- const colors = new Float32Array(count * 3);
- for (let i = 0; i < count; i++) {
- colors[i * 3] = Math.random();
- colors[i * 3 + 1] = Math.random();
- colors[i * 3 + 2] = Math.random();
- }
- geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
- const material = new THREE.PointsMaterial({ size: 0.05, vertexColors: true });
- const mesh = new THREE.Points(geometry, material);
- scene.add(mesh);
- // 加入 tween 动画 :点从球体飞往各处再折回
- const startPositions = geometry.getAttribute('position');
- for(let i = 0; i < startPositions.count; i++) {
- if (i % 5 === 0) continue; // 排除索引被5整除的点
- const tween = new TWEEN.Tween(startPositions.array)
- .to({
- [i * 3]: THREE.MathUtils.randFloatSpread(10),
- [i * 3 + 1]: THREE.MathUtils.randFloatSpread(10),
- [i * 3 + 2]: THREE.MathUtils.randFloatSpread(10)
- }, 5000 * Math.random() + 6000)
- .delay(2000)
- .easing(TWEEN.Easing.Exponential.Out)
- .onUpdate(() => startPositions.needsUpdate = true)
- .repeat(Infinity)
- .repeatDelay(1500)
- .yoyo(6000)
- .start();
- }
- const animate = () => {
- TWEEN.update();
- const delta = clock.getDelta();
- mesh.rotation.x += delta / 5;
- mesh.rotation.y += delta / 5;
- renderer.render(scene, camera);
- requestAnimationFrame(animate);
- };
- papa.onclick = (e) => {
- if (click3(mesh, e)) player.click();
- };
- papa.onmousemove = (e) => {
- papa.title = click3(mesh, e) ? '播放/暂停(Alt+X)' : '';
- papa.style.cursor = click3(mesh, e) ? 'pointer' : 'default';
- };
- const tweens = TWEEN.getAll();
- aud.onplaying = aud.onpause = () => {
- tweens.forEach(tween => aud.paused ? tween.pause() : tween.resume());
- aud.paused ? clock.stop() : clock.start();
- };
- animate();
- FS(papa, player);
- </script>
复制代码
|
评分
-
| 参与人数 2 | 威望 +70 |
金钱 +140 |
经验 +70 |
收起
理由
|
泡沫
| + 20 |
+ 40 |
+ 20 |
很给力! |
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|