天上的云
<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/5/cloud.jpg') 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%; opacity: .5; object-fit: cover; mask: radial-gradient(transparent 20%, red); -webkit-mask: radial-gradient(transparent 20%, red); pointer-events: none; }
#player { position: absolute; bottom: 70px; z-index: 10; filter: hue-rotate(60deg); opacity: .7; transition: filter .7s; cursor: pointer; animation: rot 8s infinite linear var(--state); }
#player:hover { filter: hue-rotate(90deg); }
canvas { filter: grayscale(90%); }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=369303" autoplay loop></audio>
<video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/04/17/59/23/video6364e27b41cd1.mp4" autoplay loop muted></video>
<img id="player" src="https://638183.freep.cn/638183/small/780.webp" width="10%" title="播放/暂停" />
</div>
<script type="module">
import * as THREE from 'https://esm.sh/three';
import { OrbitControls } from "https://esm.sh/three/examples/jsm/controls/OrbitControls";
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, -1, 10);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
tz.appendChild(renderer.domElement);
const controller = new OrbitControls(camera, renderer.domElement);
controller.autoRotate = true;
const geometry = new THREE.DodecahedronGeometry(1.2, 0);
const material = new THREE.MeshNormalMaterial({ transparent: true, opacity: 0.6 });
const dode = new THREE.Mesh(geometry, material);
const mod = new THREE.Mesh(geometry, material);
const sons = [];
for (let i = -2; i <= 2; i ++) {
const son = mod.clone();
if (i === 0) continue;
son.position.set(2 * i, (0.5 - Math.random()) * i * 6, -2 * i);
sons.push(son);
dode.add(son);
}
scene.add(dode);
const animate = () => {
isPlaying ? raf = requestAnimationFrame(animate) : cancelAnimationFrame(raf);
sons.forEach(son => {
son.rotation.x += Math.random() / 100;
son.rotation.y +=Math.random() / 100;
});
controller.update();
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();
};
animate();
FS(tz, player);
</script>
<div id="hEdiv"><pre id="hEpre">
<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/5/cloud.jpg') 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%; opacity: .5; object-fit: cover; mask: radial-gradient(transparent 20%, red); -webkit-mask: radial-gradient(transparent 20%, red); pointer-events: none; }
#player { position: absolute; bottom: 70px; z-index: 10; filter: hue-rotate(60deg); opacity: .7; transition: filter .7s; cursor: pointer; animation: rot 8s infinite linear var(--state); }
#player:hover { filter: hue-rotate(90deg); }
canvas { filter: grayscale(90%); }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=369303" autoplay loop></audio>
<video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/04/17/59/23/video6364e27b41cd1.mp4" autoplay loop muted></video>
<img id="player" src="https://638183.freep.cn/638183/small/780.webp" width="10%" title="播放/暂停" />
</div>
<script type="module">
import * as THREE from 'https://esm.sh/three';
import { OrbitControls } from "https://esm.sh/three/examples/jsm/controls/OrbitControls";
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, -1, 10);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
tz.appendChild(renderer.domElement);
const controller = new OrbitControls(camera, renderer.domElement);
controller.autoRotate = true;
const geometry = new THREE.DodecahedronGeometry(1.2, 0);
const material = new THREE.MeshNormalMaterial({ transparent: true, opacity: 0.6 });
const dode = new THREE.Mesh(geometry, material);
const mod = new THREE.Mesh(geometry, material);
const sons = [];
for (let i = -2; i <= 2; i ++) {
const son = mod.clone();
if (i === 0) continue;
son.position.set(2 * i, (0.5 - Math.random()) * i * 6, -2 * i);
sons.push(son);
dode.add(son);
}
scene.add(dode);
const animate = () => {
isPlaying ? raf = requestAnimationFrame(animate) : cancelAnimationFrame(raf);
sons.forEach(son => {
son.rotation.x += Math.random() / 100;
son.rotation.y +=Math.random() / 100;
});
controller.update();
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();
};
animate();
FS(tz, player);
</script>
</pre></div>
<script type="module">
import hlight from 'https://638183.freep.cn/638183/web/helight/helight1.js';
hlight.hl(hEdiv, hEpre);
</script>
帖子 three.js 特效是十二面几何体的应用演示。
three.js 缓冲几何体十二面体的相关介绍请参阅 three.js几何体之十二面体 - 马黑黑教程专版 - 花潮论坛 - Powered by Discuz! 或可查询网上的资料
震撼!谢谢马老师大佬级精彩分享{:4_191:} 欣赏,欣赏,再欣赏!{:4_187:} 现在黑黑讲解完就有实例,这个太好了,对于理解讲解内容特别好呢{:4_199:} 这十二面体的加入,让帖子另有种玄妙的味道,很赞{:4_199:} 五个十二面体的位置的设置又是一种方式呢,(0.5 - Math.random()) * i * 6,最有意思,竟然是随机值{:4_187:} 这些十二面体也是可以鼠标互动的,想把它们放大缩小或者拖到什么地方都行{:4_199:} 我把它们拖到画面边上,结果它们转到外面去了,半天才转回来,好玩{:4_173:} 红影 发表于 2025-5-15 15:38
我把它们拖到画面边上,结果它们转到外面去了,半天才转回来,好玩
去的区域在相机视线外了 红影 发表于 2025-5-15 15:35
这些十二面体也是可以鼠标互动的,想把它们放大缩小或者拖到什么地方都行
所有的几何体都可以 红影 发表于 2025-5-15 15:33
五个十二面体的位置的设置又是一种方式呢,(0.5 - Math.random()) * i * 6,最有意思,竟然是随机值{:4_187: ...
给它们在Y轴上有一定的起伏 红影 发表于 2025-5-15 15:30
现在黑黑讲解完就有实例,这个太好了,对于理解讲解内容特别好呢
这个不太难吧?下一个是二十面几何体,和这个很接近,过一会就发 梦江南 发表于 2025-5-15 13:39
欣赏,欣赏,再欣赏!
{:4_191:} 杨帆 发表于 2025-5-15 12:47
震撼!谢谢马老师大佬级精彩分享
{:4_190:} 进来后发现跟网站里的排列位置不同。
刷新几次,它们的排列是随机,每次都不一样。。。
{:4_173:} 花飞飞 发表于 2025-5-15 19:08
进来后发现跟网站里的排列位置不同。
刷新几次,它们的排列是随机,每次都不一样。。。
站立的一样随机 相机位置Y轴给了-1,跟教程里的0又有所区别。 找了半天还是没找到颜色是怎么统一成灰色的。。{:4_173:}带着谜团先逛逛去
这颜色与天空的背景到是相搭。。