|
|

楼主 |
发表于 2025-6-10 19:09
|
显示全部楼层
帖子代码
- <style>
- #tz { margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); height: auto; aspect-ratio: 16/9; background: #eee url('https://638183.freep.cn/638183/t24/w4/row.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; 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=1328534807" autoplay loop></audio>
- <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/05/08/05/29/video6365a8c98c8e9.mp4" autoplay loop muted></video>
- <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.set(0, 0, 120);
- const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
- renderer.setSize(tz.offsetWidth, tz.offsetHeight);
- const clock = new THREE.Clock();
- tz.appendChild(renderer.domElement);
- const boxGeometry = new THREE.BoxGeometry(30, 20, 5, 16, 8, 4);
- const ballGeometry = new THREE.SphereGeometry(10, 32, 32);
- const pointsMaterial = new THREE.PointsMaterial({ color: 0x00eeff, size: 1.2 });
- const box = new THREE.Points(boxGeometry, pointsMaterial);
- const ball = new THREE.Points(ballGeometry, pointsMaterial);
- box.rotateX(Math.PI / 4);
- box.position.set(-60, 20, 0);
- box.add(ball);
- scene.add(box);
- 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([box], 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();
- box.rotation.y -= delta;
- renderer.render(scene, camera);
- };
- window.onresize = () => {
- camera.aspect = tz.offsetWidth / tz.offsetHeight;
- camera.updateProjectionMatrix();
- renderer.setSize(tz.offsetWidth, tz.offsetHeight);
- };
- document.onvisibilitychange = () => {
- if (aud.paused) return;
- document.visibilityState === 'hidden' ? clock.stop() : clock.start();
- };
- aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
- animate();
- FS(tz, player);
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +30 |
金钱 +60 |
经验 +30 |
收起
理由
|
花飞飞
| + 30 |
+ 60 |
+ 30 |
很给力! |
查看全部评分
|