|
|

楼主 |
发表于 2025-6-24 08:10
|
显示全部楼层
帖子代码
- <style>
- #tz { 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/xy.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); pointer-events: none; }
- </style>
- <div id="tz">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=31445474" autoplay loop></audio>
- <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/05/18/16/40/video63663808aba6e.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';
- import { FS } from 'https://638183.freep.cn/638183/web/ku/FS.js';
- FS(tz, player);
- basic3(tz);
- const group = new THREE.Group(), sGroup = new THREE.Group;
- const tt = 40, poses = [ [0, 0, 0], [-2, 0, 0], [2, 0, 0], [0, 0, -2], [0, 0, 2] ];
- // 圆环
- for (let i = 0; i < tt; i ++) {
- const ellipse = drawEllipse(1.2, 0.8);
- ellipse.rotateY(THREE.MathUtils.degToRad(360 / tt * i));
- group.add(ellipse);
- }
- // 球
- poses.forEach( (pos, key) => {
- const texture = new THREE.TextureLoader().load('https://638183.freep.cn/638183/small/texture/wdrop.jpg');
- texture.colorSpace = THREE.SRGBColorSpace;
- const mesh = new THREE.Mesh(
- new THREE.SphereGeometry(0.25),
- new THREE.MeshBasicMaterial({ map: texture })
- );
- mesh.position.set(pos[0], pos[1], pos[2]);
- if (key === 0) mesh.scale.set(2, 2, 2);
- sGroup.add(mesh);
- });
-
- sGroup.rotateX(-0.15);
- group.add(sGroup);
- scene.add(group);
- animate();
- aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
- tz.onclick = (e) => { if (click3(group, e)) player.click() };
- tz.onmousemove = (e) => {
- tz.title = click3(group, e) ? '播放/暂停' : '';
- tz.style.cursor = click3(group, e) ? 'pointer' : 'default';
- }
- // 绘制圆环函数
- function drawEllipse(r1, r2) {
- const curve = new THREE.EllipseCurve(0, 0, r1, r2, 0, 2 * Math.PI, false, 0);
- const arc = new THREE.Line(
- new THREE.BufferGeometry().setFromPoints( curve.getPoints(50) ),
- new THREE.LineDashedMaterial( { color: 0xffffff * Math.random(), dashSize: 0.02, gapSize: 0.02 } )
- );
- arc.computeLineDistances(); // 显示虚线必须计算线距
- return arc;
- }
- function animate() {
- requestAnimationFrame(animate);
- const delta = clock.getDelta();
- group.rotation.y += delta / 5;
- sGroup.children.forEach(child => child.rotation.y += delta);
- renderer.render(scene, camera);
- }
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|