马黑黑 发表于 2025-5-18 19:51

新的开始

<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/newbegin.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: 240px; height: 240px; cursor: pointer; background: none; }
        #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; }
</style>

<div id="tz">
        <audio id="aud" src="https://music.163.com/song/media/outer/url?id=449127" autoplay loop></audio>
        <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/25/03/14/23/16/59/video67d4486b30cdd.mp4" autoplay loop muted></video>
        <div id="player" title="播放/暂停"></div>
</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';

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

        const geometry = new THREE.TorusKnotGeometry();
        const material = new THREE.MeshBasicMaterial({ wireframe: true });
        const torusknot = new THREE.Mesh(geometry, material);
        scene.add(torusknot);

        const animate = () => {
                requestAnimationFrame(animate);
                const delta = clock.getDelta();
                torusknot.rotation.x += delta;
                torusknot.rotation.y -= delta;
                renderer.render(scene, camera);
        };

        tz.onclick = (e) => {
                if (e.target.id !== 'player') return;
                aud.paused ? clock.stop() : clock.start();
        }

        window.onresize = () => {
                camera.aspect = tz.offsetWidth / tz.offsetHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(tz.offsetWidth, tz.offsetHeight);
        }

        animate();
        FS(tz, player);
</script>

马黑黑 发表于 2025-5-18 19:52

帖子代码


<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/newbegin.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: 240px; height: 240px; cursor: pointer; background: none; }
        #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; }
</style>

<div id="tz">
        <audio id="aud" src="https://music.163.com/song/media/outer/url?id=449127" autoplay loop></audio>
        <video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/25/03/14/23/16/59/video67d4486b30cdd.mp4" autoplay loop muted></video>
        <div id="player" title="播放/暂停"></div>
</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';

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

        const geometry = new THREE.TorusKnotGeometry();
        const material = new THREE.MeshBasicMaterial({ wireframe: true });
        const torusknot = new THREE.Mesh(geometry, material);
        scene.add(torusknot);

        const animate = () => {
                requestAnimationFrame(animate);
                const delta = clock.getDelta();
                torusknot.rotation.x += delta;
                torusknot.rotation.y -= delta;
                renderer.render(scene, camera);
        };

        tz.onclick = (e) => {
                if (e.target.id !== 'player') return;
                aud.paused ? clock.stop() : clock.start();
        }

        window.onresize = () => {
                camera.aspect = tz.offsetWidth / tz.offsetHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(tz.offsetWidth, tz.offsetHeight);
        }

        animate();
        FS(tz, player);
</script>

马黑黑 发表于 2025-5-18 19:54

关于圆环扭结几何体,更多资料请参阅 three.js几何体之圆环缓冲扭结几何体 - 马黑黑教程专版 - 花潮论坛 - Powered by Discuz! 或在网上查找更详细的资料

马黑黑 发表于 2025-5-18 19:57

three.js 核心库链接自国内公共CDN,道理上不再存在连接不上的问题,但不可预知的因素依然存在,如有打开帖子不正常的,请告知一声,谢谢

马黑黑 发表于 2025-5-18 19:58

手机竖看时视频的logo会很明显,请横着看

杨帆 发表于 2025-5-18 20:04

我这儿显示正常。马老师辛苦了,谢谢精彩分享{:4_191:}

红影 发表于 2025-5-18 20:48

这个不是用的贴图,而是直接用的线框,也很奇妙。
现在这个扭扭糖的两种表现方式都见到了{:4_187:}

红影 发表于 2025-5-18 20:53

这样的制作很有种恢弘大气的感觉,那么遥远的路和广阔的场景,还有扑面而来的粒子效果{:4_199:}

花飞飞 发表于 2025-5-18 21:20

今天忙的时候,还想晚上能看到什么奇妙的效果,现在看来果然震撼。。
跟教程相比只保留自身旋转正好可以全方位无死角把整体都呈现在眼前。。
线框纹理有透视感,立体感超强。。{:4_173:}

花飞飞 发表于 2025-5-18 21:22

整个背景图公路由近到远,纵深感和透视的感觉满满。。
最远处还加了个金光闪闪的粒子散落效果。。。
壮观。。全屏更好看{:4_173:}

花飞飞 发表于 2025-5-18 21:27

播放和暂停直接由主体图案控制了。。。
无限循环的莫比乌斯环和克莱因瓶都无始无终,作品名称叫新的开始。。
就是无论哪一刻都可以当做开始的意思吧。。{:4_173:}

马黑黑 发表于 2025-5-18 22:02

花飞飞 发表于 2025-5-18 21:27
播放和暂停直接由主体图案控制了。。。
无限循环的莫比乌斯环和克莱因瓶都无始无终,作品名称叫新的开始。 ...

理解正确

马黑黑 发表于 2025-5-18 22:02

花飞飞 发表于 2025-5-18 21:22
整个背景图公路由近到远,纵深感和透视的感觉满满。。
最远处还加了个金光闪闪的粒子散落效果。。。
壮观 ...

{:4_190:}

马黑黑 发表于 2025-5-18 22:03

花飞飞 发表于 2025-5-18 21:20
今天忙的时候,还想晚上能看到什么奇妙的效果,现在看来果然震撼。。
跟教程相比只保留自身旋转正好可以全 ...

矮油,说话那么动听

马黑黑 发表于 2025-5-18 22:03

红影 发表于 2025-5-18 20:53
这样的制作很有种恢弘大气的感觉,那么遥远的路和广阔的场景,还有扑面而来的粒子效果

{:4_190:}

马黑黑 发表于 2025-5-18 22:03

杨帆 发表于 2025-5-18 20:04
我这儿显示正常。马老师辛苦了,谢谢精彩分享

{:4_190:}

马黑黑 发表于 2025-5-18 22:04

红影 发表于 2025-5-18 20:48
这个不是用的贴图,而是直接用的线框,也很奇妙。
现在这个扭扭糖的两种表现方式都见到了

蔗糖做的{:4_170:}

花飞飞 发表于 2025-5-18 22:08

马黑黑 发表于 2025-5-18 22:02
理解正确

{:4_173:}新的开始令人期待又充满希望

花飞飞 发表于 2025-5-18 22:09

马黑黑 发表于 2025-5-18 22:02


茶好,贴子也好

花飞飞 发表于 2025-5-18 22:10

马黑黑 发表于 2025-5-18 22:03
矮油,说话那么动听

或者可能也许大概沉默更动听些。{:4_173:}
页: [1] 2 3 4
查看完整版本: 新的开始