仙剑人物MMD制作详细教程,包含模型提取和3DMAX简单操作

好的,下面是生成用threejs加载mmd模型并导入外部动作的html代码: ```html <!DOCTYPE html> <html> <head> <title>Loading MMD Model</title> <meta charset="utf-8"> <style> body { margin: 0; overflow: hidden; background-color: #000; } canvas { width: 100%; height: 100%; } </style> </head> <body> <script src="https://cdn.jsdelivr.net/npm/three@0.131.2/build/three.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/three-mmd-loader@0.5.4/lib/ammo.js"></script> <script src="https://cdn.jsdelivr.net/npm/three-mmd-loader@0.5.4/lib/MMDLoader.js"></script> <script> // Create a renderer var renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // Create a scene var scene = new THREE.Scene(); scene.background = new THREE.Color(0x000000); // Create a camera var camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 1, 1000); camera.position.set(0, 1.6, -5); // Load the model and animation var loader = new THREE.MMDLoader(); loader.loadWithAnimation( 'model.pmx', 'motion.vmd', function (mmd) { // Add the model to the scene scene.add(mmd.mesh); // Set the animation to loop and play mmd.playAnimation(); mmd.loop = true; // Resize the model to fit var box = new THREE.Box3().setFromObject(mmd.mesh); var size = new THREE.Vector3(); box.getSize(size); var scale = 1 / size.y; mmd.mesh.scale.set(scale, scale, scale); // Render the scene var clock = new THREE.Clock(); function animate() { var delta = clock.getDelta(); mmd.update(delta); renderer.render(scene, camera); requestAnimationFrame(animate); } animate(); }, function (xhr) { console.log((xhr.loaded / xhr.total * 100) + '% loaded'); }, function (error) { console.log('An error occurred'); console.log(error); } ); </script> </body> </html> ``` 我希望这段代码能帮到您!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值