本帖最后由 花简静 于 2025-8-15 10:38 编辑
<style>
#papa { margin: 30px 0; left: calc(50% - 101px); transform: translateX(-50%); width: clamp(600px, 90vw, 1700px); height: auto; aspect-ratio: 17/9; background: url('https://642303.freep.cn/642303/tu/20250628yssr.webp') no-repeat center/cover; box-shadow: 2px 2px 8px #000; display: grid; place-items: center; z-index: 1; position: relative; }
#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;mix-blend-mode: screen; }
#btnFs { bottom: 30px; color: #eee; }
#player { position: absolute; left: -1000px; }
</style>
<div id="papa">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=2716387077" autoplay loop></audio>
<video id="vid" src="https://video.699pic.com/videos/14/28/53/b_ivr7IbG7Jmzt1583142853.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 { textcanvas } from 'https://638183.freep.cn/638183/3dev/3/textcanvas.js';
import { FS } from 'https://638183.freep.cn/638183/web/ku/FS.js';
basic3(papa);
// canvas文本配置
const setting = {
font: `bold 30px 'Microsoft Yahei', sans-serif`,
fill: true,
fillColor: 'rgba(0,120,120,.6)',
};
const canv = textcanvas('雨声生日快乐', setting);
const texture = new THREE.CanvasTexture(canv);
// 绘制平面几何体
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(2, 1.1, 16, 32),
new THREE.MeshBasicMaterial({ map: texture, wireframe: true, transparent: true })
);
mesh.rotateX(0.8);
mesh.rotateY(0.4);
scene.add(mesh);
// 动画
const animate = () => {
requestAnimationFrame(animate);
const delta = clock.getDelta();
mesh.rotation.z -= delta;
renderer.render(scene, camera);
};
// 交互
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';
};
aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
//动画及全屏
animate();
FS(papa, player);
</script>
|