朵拉 发表于 2025-7-4 20:14

剩下的盛夏(学习马黑黑遇见都是天意效果)

<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://pic1.imgdb.cn/item/6867c18358cb8da5c8907ada.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://file.uhsea.com/2507/6da94a07d65f2a0432622222810d54f3CL.mp3" 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 = Math.random();
            colors = Math.random();
            colors = 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({
                        : THREE.MathUtils.randFloatSpread(10),
                        : THREE.MathUtils.randFloatSpread(10),
                        : 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>

朵拉 发表于 2025-7-4 20:18

@马黑黑
老师 晚上好,学生交作业,请指正{:4_190:}

梦油 发表于 2025-7-4 20:42

欣赏佳作,问候朵拉。

朵拉 发表于 2025-7-4 20:56

梦油 发表于 2025-7-4 20:42
欣赏佳作,问候朵拉。

问好梦油老师,祝您周末愉快{:4_190:}

梦油 发表于 2025-7-4 21:05

朵拉 发表于 2025-7-4 20:56
问好梦油老师,祝您周末愉快

朵拉朋友别客气。

马黑黑 发表于 2025-7-4 21:18

{:4_199:}

红影 发表于 2025-7-4 22:01

这些纷飞的粒子真漂亮。欣赏朵宝好帖{:4_187:}

梦江南 发表于 2025-7-5 07:59

漂亮!欣赏点 赞!{:4_199:}
页: [1]
查看完整版本: 剩下的盛夏(学习马黑黑遇见都是天意效果)