如何在 three.js 的最新版本中处理和播放骨骼动画
How to handle and play a skeletal animation in three.js in its last version
我知道有 skinning_blending 模型但是因为它有 gui 控件(dat.gui 对于所有其他 threejs 示例)所以代码变得太复杂了我无法得到我为以前的旧 threejs 版本找到了这样的简单方法:
var loader = new THREE.JSONLoader();
loader.load('../assets/models/simpleManMesh2.json', function (model, mat) {
var mat = new THREE.MeshLambertMaterial({color: 0xF0C8C9, skinning: true});
mesh = new THREE.SkinnedMesh(model, mat);
// register the animation
THREE.AnimationHandler.add(model.animation);
var animation = new THREE.Animation(mesh, "saluuut");
scene.add(mesh);
// start the animation
animation.play();
}, '../assets/models');
我得到的错误和其他许多人一样:
THREE.AnimationHandler.add() has been deprecated.
所以我要求的是一个相同的简单代码(没有任何 gui 控件),但它适用于最新版本。最好的问候。
刚才是THREE.Animation()
:
loader.load('yourfile.json',function(geometry,materials){
for(var i in materials)materials[i].skinning=true;
mesh=new THREE.SkinnedMesh(
geometry,
new THREE.MeshFaceMaterial(materials)
);
scene.add(mesh);
animation=new THREE.Animation(mesh,geometry.animations[0]);
animation.play();
});
我知道有 skinning_blending 模型但是因为它有 gui 控件(dat.gui 对于所有其他 threejs 示例)所以代码变得太复杂了我无法得到我为以前的旧 threejs 版本找到了这样的简单方法:
var loader = new THREE.JSONLoader();
loader.load('../assets/models/simpleManMesh2.json', function (model, mat) {
var mat = new THREE.MeshLambertMaterial({color: 0xF0C8C9, skinning: true});
mesh = new THREE.SkinnedMesh(model, mat);
// register the animation
THREE.AnimationHandler.add(model.animation);
var animation = new THREE.Animation(mesh, "saluuut");
scene.add(mesh);
// start the animation
animation.play();
}, '../assets/models');
我得到的错误和其他许多人一样:
THREE.AnimationHandler.add() has been deprecated.
所以我要求的是一个相同的简单代码(没有任何 gui 控件),但它适用于最新版本。最好的问候。
刚才是THREE.Animation()
:
loader.load('yourfile.json',function(geometry,materials){
for(var i in materials)materials[i].skinning=true;
mesh=new THREE.SkinnedMesh(
geometry,
new THREE.MeshFaceMaterial(materials)
);
scene.add(mesh);
animation=new THREE.Animation(mesh,geometry.animations[0]);
animation.play();
});