马黑黑 发表于 2025-5-16 20:11

纯能量

本帖最后由 马黑黑 于 2025-5-16 21:38 编辑 <br /><br /><style>
        #tz { --state: running; margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); min-height: 80vh; aspect-ratio: 16/9; background: url('https://638183.freep.cn/638183/t24/webp3/e.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; }
        #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; }
        #player { position: absolute; top: 20px; right: 20px; z-index: 10; filter: hue-rotate(60deg); opacity: .7; transition: filter .7s; cursor: pointer; animation: rot 8s infinite linear var(--state); }
        #player:hover { filter: unset; }
        @keyframes rot { to { transform: rotate(360deg); } }
</style>

<div id="tz">
        <audio id="aud" src="https://music.163.com/song/media/outer/url?id=2051382659" autoplay loop></audio>
        <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/25/03/19/17/38/49/video67da90a941c5f.mp4" autoplay loop muted></video>
        <img id="player" src="https://638183.freep.cn/638183/small/fi2.webp" width="10%" title="播放/暂停" />
</div>

<script type="module">
        import * as THREE from 'https://638183.freep.cn/638183/web/ku/three.module.min.js';
        import { FS } from 'https://638183.freep.cn/638183/web/ku/fscreen.js';

        let isPlaying = true, raf;

        const scene = new THREE.Scene;
        const camera = new THREE.PerspectiveCamera(75, tz.offsetWidth / tz.offsetHeight, 0.1, 1000);
        camera.position.set(0, 0, 10);
        const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
        renderer.setSize(tz.offsetWidth, tz.offsetHeight);
        tz.appendChild(renderer.domElement);

        const ring_geometry = new THREE.RingGeometry();
        const torus_geometry = new THREE.TorusGeometry();
        const material = new THREE.MeshNormalMaterial({ side: THREE.DoubleSide });
        const ring_mess = new THREE.Mesh(ring_geometry, material);
        const torus_mess = new THREE.Mesh(torus_geometry, material);
        const torus_mess1 = torus_mess.clone();
        torus_mess.position.set(3, 0, 0);
        torus_mess1.position.set(-3, 0, 0);
        ring_mess.add(torus_mess, torus_mess1);
        ring_mess.rotateY(0.5);
        scene.add(ring_mess);

        const animate = () => {
                isPlaying ? raf = requestAnimationFrame(animate) : cancelAnimationFrame(raf);
                ring_mess.rotation.x += 0.01;
                ring_mess.rotation.y += 0.01;
                renderer.render(scene, camera);
        };

        window.onresize = () => {
                renderer.setSize(tz.offsetWidth, tz.offsetHeight);
                renderer.render(scene, camera);
        };

        tz.onclick = (e) => {
                if (e.target.id !== 'player') return;
                isPlaying = !aud.paused;
                animate();
        };

        aud.onseeked = () => cancelAnimationFrame(raf);

        isPlaying = !aud.paused;
        animate();
        FS(tz, player);
</script>

马黑黑 发表于 2025-5-16 20:11

本帖最后由 马黑黑 于 2025-5-16 21:39 编辑

帖子代码(刚刚更换了 three.js 模块资源):

<style>
        #tz { --state: running; margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); min-height: 80vh; aspect-ratio: 16/9; background: url('https://638183.freep.cn/638183/t24/webp3/e.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; }
        #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; }
        #player { position: absolute; top: 20px; right: 20px; z-index: 10; filter: hue-rotate(60deg); opacity: .7; transition: filter .7s; cursor: pointer; animation: rot 8s infinite linear var(--state); }
        #player:hover { filter: unset; }
        @keyframes rot { to { transform: rotate(360deg); } }
</style>

<div id="tz">
        <audio id="aud" src="https://music.163.com/song/media/outer/url?id=2051382659" autoplay loop></audio>
        <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/25/03/19/17/38/49/video67da90a941c5f.mp4" autoplay loop muted></video>
        <img id="player" src="https://638183.freep.cn/638183/small/fi2.webp" width="10%" title="播放/暂停" />
</div>

<script type="module">
        import * as THREE from 'https://638183.freep.cn/638183/web/ku/three.module.min.js';
        import { FS } from 'https://638183.freep.cn/638183/web/ku/fscreen.js';

        let isPlaying = true, raf;

        const scene = new THREE.Scene;
        const camera = new THREE.PerspectiveCamera(75, tz.offsetWidth / tz.offsetHeight, 0.1, 1000);
        camera.position.set(0, 0, 10);
        const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
        renderer.setSize(tz.offsetWidth, tz.offsetHeight);
        tz.appendChild(renderer.domElement);

        const ring_geometry = new THREE.RingGeometry();
        const torus_geometry = new THREE.TorusGeometry();
        const material = new THREE.MeshNormalMaterial({ side: THREE.DoubleSide });
        const ring_mess = new THREE.Mesh(ring_geometry, material);
        const torus_mess = new THREE.Mesh(torus_geometry, material);
        const torus_mess1 = torus_mess.clone();
        torus_mess.position.set(3, 0, 0);
        torus_mess1.position.set(-3, 0, 0);
        ring_mess.add(torus_mess, torus_mess1);
        ring_mess.rotateY(0.5);
        scene.add(ring_mess);

        const animate = () => {
                isPlaying ? raf = requestAnimationFrame(animate) : cancelAnimationFrame(raf);
                ring_mess.rotation.x += 0.01;
                ring_mess.rotation.y += 0.01;
                renderer.render(scene, camera);
        };

        window.onresize = () => {
                renderer.setSize(tz.offsetWidth, tz.offsetHeight);
                renderer.render(scene, camera);
        };

        tz.onclick = (e) => {
                if (e.target.id !== 'player') return;
                isPlaying = !aud.paused;
                animate();
        };

        aud.onseeked = () => cancelAnimationFrame(raf);

        isPlaying = !aud.paused;
        animate();
        FS(tz, player);
</script>

马黑黑 发表于 2025-5-16 20:13

帖子使用了两种 three.js 圆环几何体,更多圆环几何体资料请参与:


three.js几何体之二维圆环和三维圆环 - 马黑黑教程专版 - 花潮论坛 - Powered by Discuz!

花飞飞 发表于 2025-5-16 20:34

大赞个,刚好不容易看到了全貌。。。
时尚丽人视频做背景。。。
两个立体的甜甜圈和中间{:4_170:}圆环构成完美效果

马黑黑 发表于 2025-5-16 20:35

花飞飞 发表于 2025-5-16 20:34
大赞个,刚好不容易看到了全貌。。。
时尚丽人视频做背景。。。
两个立体的甜甜圈和中间圆环构 ...

这个构图是有说法的

花飞飞 发表于 2025-5-16 20:36

色彩炫酷,一眼震撼。。。{:4_173:}
相当神奇的3D效果。。。

马黑黑 发表于 2025-5-16 20:37

花飞飞 发表于 2025-5-16 20:36
色彩炫酷,一眼震撼。。。
相当神奇的3D效果。。。

这个其实是简单的

小辣椒 发表于 2025-5-16 20:51

我就看见一个编织网的图,后面一个美女在走路,播放权按钮也是不能停止

小辣椒 发表于 2025-5-16 20:51

感觉我特效看不见{:4_198:}

马黑黑 发表于 2025-5-16 20:53

小辣椒 发表于 2025-5-16 20:51
感觉我特效看不见

应该是你的网下载不了 three.js 资源

马黑黑 发表于 2025-5-16 20:54

小辣椒 发表于 2025-5-16 20:51
我就看见一个编织网的图,后面一个美女在走路,播放权按钮也是不能停止

要么是你的网络不支持来自 https://esm.sh 的 three.js 的资源,要么就是你的浏览器出了问题

马黑黑 发表于 2025-5-16 20:56

小辣椒 发表于 2025-5-16 20:51
感觉我特效看不见

你试着用手机流量看一眼

红影 发表于 2025-5-16 21:24

两个立体的圆环,当中用一个二维圆环相连,这个效果真奇妙{:4_199:}

红影 发表于 2025-5-16 21:25

音乐也有趣,《纯能量》,怪不得美女走得这么气势,原来能量很足啊{:4_173:}

红影 发表于 2025-5-16 21:28

马黑黑 发表于 2025-5-16 20:35
这个构图是有说法的

很好奇,这有什么说法啊{:4_173:}

马黑黑 发表于 2025-5-16 21:29

红影 发表于 2025-5-16 21:28
很好奇,这有什么说法啊

胡说

马黑黑 发表于 2025-5-16 21:29

红影 发表于 2025-5-16 21:25
音乐也有趣,《纯能量》,怪不得美女走得这么气势,原来能量很足啊

{:4_181:}

马黑黑 发表于 2025-5-16 21:30

红影 发表于 2025-5-16 21:24
两个立体的圆环,当中用一个二维圆环相连,这个效果真奇妙

这个帖子没有使用相机绕场景

红影 发表于 2025-5-16 21:31

马黑黑 发表于 2025-5-16 21:29
胡说

哦,还以为真有什么说法呢{:4_173:}

红影 发表于 2025-5-16 21:37

马黑黑 发表于 2025-5-16 21:30
这个帖子没有使用相机绕场景

嗯,three.js做动态可以有各种方式{:4_187:}
页: [1] 2 3 4 5 6
查看完整版本: 纯能量