本帖最后由 花简静 于 2025-8-15 10:41 编辑
<style>
#tz { --size: 9vw; margin: 30px 0; left: calc(50% - 91px); transform: translateX(-50%); width: clamp(600px, 90vw, 1700px); min-height: 80vh; aspect-ratio: 17/9; background: #eee url('https://642303.freep.cn/642303/tu/20250601zjdh01.webp') no-repeat center/cover; box-shadow: 2px 2px 8px #000; display: grid; place-items: center; z-index: 1; position: relative; }
#player { position: absolute; width: var(--size); height: var(--size); cursor: pointer; background: none; border-radius: 50%; }
#btnFs { bottom: 20px; color: #eee; text-align: center; }
#btnFs:hover { color: red; }
#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;opacity: .11; }
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1840697024" autoplay loop></audio>
<video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/24/11/01/15/25/07/video672482533234e.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 clock = new THREE.Clock();
const camera = new THREE.PerspectiveCamera(-60, tz.offsetWidth / tz.offsetHeight, 0.1, 1000);
camera.position.set(-5.5, -2, 11);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
tz.appendChild(renderer.domElement);
let limit= 100, pos = 0, step = 2;
const ambLight = new THREE.AmbientLight(0xffd700);
const dirLight = new THREE.DirectionalLight(0xffffff, 2);
dirLight.position.set(pos, 50, 100);
const ball = new THREE.Mesh(
new THREE.SphereGeometry(0.5),
new THREE.MeshPhongMaterial({ color: 0xffffff, shininess: 140 })
);
ball.position.z = Math.cos(Math.PI * 0.5);
const pan = new THREE.Mesh(
new THREE.CircleGeometry(2, 20),
new THREE.MeshLambertMaterial({ wireframe: true })
);
pan.rotateY(Math.PI / 5);
scene.add(ball, pan, ambLight, dirLight);
const animate = () => {
requestAnimationFrame(animate);
const delta = clock.getDelta();
pos -= 100 * delta * step;
if (pos > limit || pos < -limit) step = -step;
dirLight.position.set(pos, 50, 100);
pan.rotation.z += delta / 2;
renderer.render(scene, camera);
};
window.onresize = () => {
camera.aspect = tz.offsetWidth / tz.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
}
aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
animate();
FS(tz, player);
</script>
|