gpt4 book ai didi

javascript - Three.js动画混合器无法播放?

转载 作者:行者123 更新时间:2023-11-28 03:34:08 25 4
gpt4 key购买 nike

好的,我已经将fbx成功加载到从Blender中导出的Three.js中,并且选中了所有动画框。香港专业教育学院尝试了搅拌机的所有导出设置,不是吗。

这就是我引入模型的方式,并且我能够准确地确定fbx是否具有动画:

var geoFromScene = new THREE.Geometry();
var FBXLoader = require('three-fbx-loader');
var loader = new FBXLoader();
loader.load(string, function ( object ) {

object.traverse( function ( child ) {
if ( child.isMesh ) {
child.castShadow = true;
child.receiveShadow = true;

geoFromScene = (new THREE.Geometry()).fromBufferGeometry(child.geometry);

}


} );

var theModel = new THREE.Mesh();
theModel.geometry = geoFromScene;
theModel.material = material;
theModel.position.set(5,5,-8);
//theModel.rotation.set(new THREE.Vector3( 0, MATH.pi/2, 0));
theModel.scale.set(0.1, 0.1, 0.1);
localThis.scene.add(theModel);

localThis.mixer = new THREE.AnimationMixer(theModel);

if(theModel.animations[0])
{
var action = localThis.mixer.clipAction(theModel.animations[0]);
action.play();
} else {
console.log("No animations");
}

} );


在更新中(确实有效,因为我可以打印animation.time):

this.mixer.update(this.clock.getDelta());


但是该模型只是静态的。怎么了

更新:

来自示例副本的代码粘贴-

var geoFromScene = new THREE.Geometry();
var FBXLoader = require('three-fbx-loader');
var loader = new FBXLoader();
loader.load( string, function ( object ) {
localThis.mixer = new THREE.AnimationMixer( object );
var action = localThis.mixer.clipAction( object.animations[ 0 ] );
action.play();

object.traverse( function ( child ) {
if ( child.isMesh ) {
child.castShadow = true;
child.receiveShadow = true;
}
} );

object.position.set(5,5,-8)
object.scale.set(0.1, 0.1, 0.1);
localThis.scene.add( object );


} );


在动画中

this.mixer.update(this.clock.getDelta());


我所得到的只是模型电枢-

enter image description here

新的方法:

var FBXLoader = require('wge-three-fbx-loader'); //https://www.npmjs.com/package/wge-three-fbx-loader
var loader = new FBXLoader();
loader.load( string, function ( object ) {

最佳答案

使用NPM软件包Three-fbx-loader时,我遇到了同样的问题,该软件包已经几年没有更新了。如果在加载FBX之后检查object.animations中的任何AnimationClip对象,您会注意到所有剪辑的持续时间为0,并且轨迹为空数组。

我终于通过使用wge-three-fbx-loader来使动画正确加载和播放。

关于javascript - Three.js动画混合器无法播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57896611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com