|
|

楼主 |
发表于 2025-6-28 08:20
|
显示全部楼层
帖子代码
- <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/w4/soccerfield.webp') 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; }
- #vid {position: absolute; width: 100%; height: 100%; object-fit: cover; mask: radial-gradient(transparent 20%, red); -webkit-mask: radial-gradient(transparent 20%, red); opacity: 0.5; pointer-events: none; }
- </style>
- <div id="papa">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=2002253707" autoplay loop></audio>
- <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/04/01/54/03/video6364003b0509a.mp4" autoplay loop muted></video>
- <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 texture = new THREE.TextureLoader().load('https://638183.freep.cn/638183/small/2025/soccer.png');
- texture.colorSpace = THREE.SRGBColorSpace;
- texture.center.set(0.5,0.5);
- const vertices = []; // 足球顶点数组
- for (let i = 0; i < 160; i ++) {
- const x = THREE.MathUtils.randFloatSpread(10);
- const y = THREE.MathUtils.randFloatSpread(5);
- const z = THREE.MathUtils.randFloatSpread(5);
- vertices.push(x, y, z);
- }
- // 足球
- const pointsGeometry = new THREE.BufferGeometry();
- pointsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
- const pointsMaterial = new THREE.PointsMaterial({ size: 0.25, map: texture, transparent: true });
- const points = new THREE.Points(pointsGeometry, pointsMaterial);
- scene.add(points);
- // 设计tween动画
- const startPositions = pointsGeometry.getAttribute('position');
- for(let i = 0; i < startPositions.count; i++) {
- const tween = new TWEEN.Tween(startPositions.array)
- .to({ [i * 3]: 0, [i * 3 + 1]: 0, [i * 3 + 2]: 0 }, 3000 * Math.random() + 3000)
- .easing(TWEEN.Easing.Exponential.In)
- .onUpdate(() => startPositions.needsUpdate = true)
- .repeat(Infinity)
- .repeatDelay(1000)
- .yoyo(1500)
- .start();
- }
- // 车削
- const lathePoints = [
- new THREE.Vector2(1, 0.5),
- new THREE.Vector2(1, 0),
- new THREE.Vector2(0.5, -0.5)
- ];
- const latheGeometry = new THREE.LatheGeometry(lathePoints, 24);
- const latheMaterial = new THREE.MeshNormalMaterial({ wireframe: true });
- const lathe = new THREE.Mesh(latheGeometry, latheMaterial);
- scene.add(lathe);
- lathe.rotateX(THREE.MathUtils.degToRad(35));
- lathe.position.set(0, 0.35, 0);
- const animate = () => {
- TWEEN.update();
- const delta = clock.getDelta();
- lathe.rotation.y += delta;
- points.rotation.y += delta / 2;
- pointsMaterial.map.rotation += delta * 2;
- renderer.render(scene, camera);
- requestAnimationFrame(animate);
- };
- papa.onclick = (e) => {
- if (click3(lathe, e)) player.click();
- };
- papa.onmousemove = (e) => {
- papa.title = click3(lathe, e) ? '播放/暂停(Alt+X)' : '';
- papa.style.cursor = click3(lathe, e) ? 'pointer' : 'default';
- };
- const tweens = TWEEN.getAll(); // 获取所有tween动画
- 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 |
赞一个! |
查看全部评分
|