【发布时间】:2017-10-11 05:25:59
【问题描述】:
我正在制作我动画的 3d json 模型的副本,如果我在场景中只有 1 个模型,它就可以工作。
但是当我尝试制作一些副本时,会出现以下错误:
未捕获的类型错误:无法读取未定义的属性“0”。
以下函数是错误引用的地方:
for(i =0; i < enemics_generats; i++ ){
var enemic = dolent.clone(true); //Clone from original model
enemic.name = i.toString();
if (i > 5){//set 5 visible, the rest invisble
enemic.visible = false;
}
else{
enemic.visible = true;
}
enemic.box = new THREE.Box3().setFromObject(enemic);//Box collider
enemic.box_helper = new THREE.BoxHelper( enemic ); //Box to be displayed on the scene
//ERROR IS ON THIS 2 FOLLOWING LANES
enemic.mixer = new THREE.AnimationMixer( enemic );
enemic.mixer.clipAction( enemic.animations[ 0 ] ).play(); //HERE IS WHERE THE ERROR APPEARS
enemics.push(enemic);//Add to the array
scene.add(enemic);//Add to scene
scene.add(enemic.box_helper);
}
感谢您的宝贵时间。
【问题讨论】:
-
动画属性或函数的定义位置。
-
JSON 加载器从文件中读取动画,并将它们存储在动画属性中。
-
所以,“dolent”(这是原始加载的模型)里面有动画。
-
你可以输出敌人看它是否有动画
-
我找到了一个部分解决方案,我只是播放“Dolent 动画”,他的所有副本都应该相同。
标签: javascript animation three.js