Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用CreateFromMorphTargetSequence Three.js加载带有动画的三维模型_Javascript_Three.js_Gltf - Fatal编程技术网

Javascript 使用CreateFromMorphTargetSequence Three.js加载带有动画的三维模型

Javascript 使用CreateFromMorphTargetSequence Three.js加载带有动画的三维模型,javascript,three.js,gltf,Javascript,Three.js,Gltf,我正在尝试加载此GBL文件并播放动画。此代码返回以下错误: TypeError:无法读取Function.CreateFromMorphTargetSequence处未定义的属性“length” function Animate() { if(window.anim_flag) { // Hotspot_Ring_Anim(); requestAnimationFrame(Animate); renderer.clear(); TW

我正在尝试加载此GBL文件并播放动画。此代码返回以下错误:

TypeError:无法读取Function.CreateFromMorphTargetSequence处未定义的属性“length”

function Animate() {
    if(window.anim_flag)
    {
    // Hotspot_Ring_Anim();
    requestAnimationFrame(Animate);
        renderer.clear();
        TWEEN.update();
        orbit.update();
        if (mixer.length > 0) {
        var delta = clock.getDelta();
        for (var i = 0; i < mixer.length; i++) {
            mixer[i].update(delta);
            }
        }
        renderer.render(scene, camera);

    }
    
}


function Add_Hotspot_Rings(id,px,py,pz,rx,ry,rz,sx,sy,sz) {
  const loader = new GLTFLoader();

  // Optional: Provide a DRACOLoader instance to decode compressed mesh data
  const dracoLoader = new DRACOLoader();
  dracoLoader.setDecoderPath(  '../jsm/draco/'  );
  loader.setDRACOLoader( dracoLoader );

  loader.load( '../Models/ABB_Clinic_AnimatedRings_Lowpoly_02.glb', function ( gltf ) {
    const model = gltf.scene;
    model.name = 'hotspot_rings';

    model.position.set(px,py,pz);
    model.rotation.set(0,ry,rz);
    model.scale.set(0.90, 0.3, 0.90);
    scene.add(model);

    // MORPH
    const mixerr = new THREE.AnimationMixer( model );
    const clips = model.animations;

    const morphClip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'RingsRising', model.morphTargets );
    mixerr.clipAction(morphClip).setDuration(1).play();

    mixer.push(mixerr);
    window.anim_flag= true;
    Animate();

  }, undefined, function ( error ) {

    console.error( error );

  } );
}
function Animate(){
if(窗口动画标志)
{
//热点_环_动画();
请求动画帧(动画);
.clear();
TWEEN.update();
update();
如果(mixer.length>0){
var delta=clock.getDelta();
对于(变量i=0;i
如何解决此错误并在播放动画时加载模型

const morphClip=3.AnimationClip.CreateFromMorphTargetSequence('RingsRising',model.morphTargets)

Object3D
的实例没有
morphTargets
属性

从glTF资源播放动画应如下所示:

const animations=gltf.animations;
const mixer=新的3.AnimationMixer(模型);
mixer.clipAction(动画[0]).setDuration(1.play();
实例: