秦王破阵
<style>#tz { --state: running; margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); heiggt: auto; aspect-ratio: 16/9; background: #eee url('https://638183.freep.cn/638183/t24/webp3/qwpv.webp') no-repeat center/cover; box-shadow: 2px 2px 8px #000; display: grid; place-items: center; z-index: 1; position: relative; }
#player { position: absolute; bottom: 100px; width: 8%; height: auto; aspect-ratio: 1/1; cursor: pointer; background: url('https://638183.freep.cn/638183/small/dcjm.webp') no-repeat center/cover; animation: rot 8s linear infinite var(--state); }
#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; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1840551391" autoplay loop></audio>
<video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/04/20/05/38/video636500127957c.mp4" autoplay loop muted></video>
<div id="player" title="播放/暂停"></div>
</div>
<script type="importmap">
{
"imports": {
"three": "https://638183.freep.cn/638183/3dev/build/three.module.min.js",
"three/addons/": "https://638183.freep.cn/638183/3dev/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { FS } from 'https://638183.freep.cn/638183/web/ku/FS.js';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, tz.offsetWidth / tz.offsetHeight, 1, 1000);
camera.position.set(10, 10, -10);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
tz.appendChild(renderer.domElement);
const clock = new THREE.Clock();
const controls = new OrbitControls(camera, renderer.domElement);
let mixer, gbl = 'https://638183.freep.cn/638183/web/3models/Parrot.glb';
new GLTFLoader().load(gbl, function (gltf) {
const model = gltf.scene;
const scale = 0.06;
model.scale.set(scale, scale, scale);
model.position.set(0, 2.5, 0);
scene.add(model, new THREE.AmbientLight(0x00ffee), new THREE.PointLight(0xffffff, 200));
mixer = new THREE.AnimationMixer(model);
if (gltf.animations.length > 0) {
const clip = mixer.clipAction(gltf.animations);
clip.play();
}
animate();
}, undefined, (err) => console.log(err));
window.onresize = () => {
camera.aspect = tz.offsetWidth / tz.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
}
function animate() {
requestAnimationFrame(animate);
const delta = clock.getDelta();
mixer.update(delta);
renderer.render(scene, camera);
}
aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
FS(tz, player);
</script> 帖子代码
<style>
#tz { --state: running; margin: 30px 0; left: calc(50% - 81px); transform: translateX(-50%); width: clamp(600px, 90vw, 1400px); heiggt: auto; aspect-ratio: 16/9; background: #eee url('https://638183.freep.cn/638183/t24/webp3/qwpv.webp') no-repeat center/cover; box-shadow: 2px 2px 8px #000; display: grid; place-items: center; z-index: 1; position: relative; }
#player { position: absolute; bottom: 100px; width: 8%; height: auto; aspect-ratio: 1/1; cursor: pointer; background: url('https://638183.freep.cn/638183/small/dcjm.webp') no-repeat center/cover; animation: rot 8s linear infinite var(--state); }
#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; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1840551391" autoplay loop></audio>
<video id="vid" src="https://bpic.588ku.com/video_listen/588ku_video/22/11/04/20/05/38/video636500127957c.mp4" autoplay loop muted></video>
<div id="player" title="播放/暂停"></div>
</div>
<script type="importmap">
{
"imports": {
"three": "https://638183.freep.cn/638183/3dev/build/three.module.min.js",
"three/addons/": "https://638183.freep.cn/638183/3dev/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { FS } from 'https://638183.freep.cn/638183/web/ku/FS.js';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, tz.offsetWidth / tz.offsetHeight, 1, 1000);
camera.position.set(10, 10, -10);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
tz.appendChild(renderer.domElement);
const clock = new THREE.Clock();
const controls = new OrbitControls(camera, renderer.domElement);
let mixer, gbl = 'https://638183.freep.cn/638183/web/3models/Parrot.glb';
new GLTFLoader().load(gbl, function (gltf) {
const model = gltf.scene;
const scale = 0.06;
model.scale.set(scale, scale, scale);
model.position.set(0, 2.5, 0);
scene.add(model, new THREE.AmbientLight(0x00ffee), new THREE.PointLight(0xffffff, 200));
mixer = new THREE.AnimationMixer(model);
if (gltf.animations.length > 0) {
const clip = mixer.clipAction(gltf.animations);
clip.play();
}
animate();
}, undefined, (err) => console.log(err));
window.onresize = () => {
camera.aspect = tz.offsetWidth / tz.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(tz.offsetWidth, tz.offsetHeight);
}
function animate() {
requestAnimationFrame(animate);
const delta = clock.getDelta();
mixer.update(delta);
renderer.render(scene, camera);
}
aud.onplaying = aud.onpause = () => aud.paused ? clock.stop() : clock.start();
FS(tz, player);
</script>
本帖使用 glTF 模型制作 ThreeJS 3d 图像,模型URL在 42 行代码:
gbl = 'https://638183.freep.cn/638183/web/3models/Parrot.glb'
鹦鹉是 ThreeJS 提供的 glTF 建模资源,类似的还有:
鹳 :Stork
火烈鸟 :Flamingo
这两个都上传了,地址修改一下即可,就是替换掉 Parrot 即可 第 33 行代码:
camera.position.set(10, 10, -10);
设置相机的位置。由于引入了轨道控制器 OrbitControls ,相机是可以手动翻转、伸缩的,上面的代码只是相机位置的初始位置,目的是调整鹦鹉的姿态,实际使用时可以视情况改变相应数据,xyz轴上的数据每一个建议在 -10 ~ 10 之间。
第 50~53行代码:
if (gltf.animations.length > 0) {
const clip = mixer.clipAction(gltf.animations);
clip.play();
}
判断模型是否自带动画,如果是,运行它的第一个动画。
有些模型是静态模型,如果需要加入动画,需要帖子制作者自己设计基于 ThreeJS 的其它动画,代码放在 animate 函数内。 顺便提一下:使用 win10 操作系统的朋友可以使用系统自带的 “画图3D” 制作 .glb 模型,不过它是否能制作带动画的模型我不太清楚。win11不再提供画图3D程序,但应该有 “3D查看器”(win10 也有这个),它也可以简单制作3D模型。 马黑黑 发表于 2025-6-4 13:35
顺便提一下:使用 win10 操作系统的朋友可以使用系统自带的 “画图3D” 制作 .glb 模型,不过它是否能制作 ...
这个3D模型还能自己画啊,从来没想过,这个太难了,细节太多,还需要转换视角才能观看和画出其他角度里的内容。就算有这个功能,也没那么容易操作呢{:4_173:} 马黑黑 发表于 2025-6-4 13:31
第 33 行代码:
camera.position.set(10, 10, -10);
嗯嗯,帖子里的鹦鹉可以自己鼠标去操控了,能互动的特别有趣{:4_187:} 马黑黑 发表于 2025-6-4 13:23
本帖使用 glTF 模型制作 ThreeJS 3d 图像,模型URL在 42 行代码:
gbl = 'https://638183.freep.cn/ ...
黑黑太细心了,还上传了鹳和火烈鸟的模型呢。现在知道四种模型了,这两个还有鹦鹉和马{:4_173:} 斗胆外行问黑黑老师,这个3D 模型用AI能绘制吗? 马黑黑 发表于 2025-6-4 13:23
本帖使用 glTF 模型制作 ThreeJS 3d 图像,模型URL在 42 行代码:
gbl = 'https://638183.freep.cn/ ...
去看了那两个,感觉除了头部不一样,身体很像白鹤啊{:4_173:} 这个帖子特别好,可以知道怎么加入3D模型了{:4_199:} 红影 发表于 2025-6-4 15:38
这个3D模型还能自己画啊,从来没想过,这个太难了,细节太多,还需要转换视角才能观看和画出其他角度里的 ...
可以先用模板画个简单的试试 梦江南 发表于 2025-6-4 15:42
斗胆外行问黑黑老师,这个3D 模型用AI能绘制吗?
可以的,你用豆包试试 红影 发表于 2025-6-4 15:39
嗯嗯,帖子里的鹦鹉可以自己鼠标去操控了,能互动的特别有趣
不误触就好{:4_170:} 红影 发表于 2025-6-4 15:40
黑黑太细心了,还上传了鹳和火烈鸟的模型呢。现在知道四种模型了,这两个还有鹦鹉和马
3d模型网上免费的也有一大把,就是两个问题:
一是要注册才能下载。国内的用QQ号、微信等,国外的用邮箱、油管、Apple ID 等;
二是文件都很大。
红影 发表于 2025-6-4 15:44
去看了那两个,感觉除了头部不一样,身体很像白鹤啊
都是禽类(bird),都差不多的 红影 发表于 2025-6-4 15:47
这个帖子特别好,可以知道怎么加入3D模型了
前面那个专门的帖子不更清楚吗 马黑黑 发表于 2025-6-4 17:24
可以的,你用豆包试试
谢谢,我去试试。 梦江南 发表于 2025-6-4 17:45
谢谢,我去试试。
豆包无所不能的 挺好玩的,谢谢马老师经典分享{:4_191:}