Javascript 设置动画时Threejs更新对象位置(混合器导出、变形动画)

Javascript 设置动画时Threejs更新对象位置(混合器导出、变形动画),javascript,animation,canvas,three.js,Javascript,Animation,Canvas,Three.js,我已将blender导出的动画加载到我的场景中。我试图实现的是单击对象,对象在其关键帧中设置了50%的动画并停止,然后如果我再次单击对象,剩余的50%关键帧将被迭代 到目前为止,我已经将对象的动画设置为50%。问题是在click eventhandler中找不到交集 function mousedown( event ) { event.preventDefault(); // update mouse object mouse.x = ( event.clientX

我已将blender导出的动画加载到我的场景中。我试图实现的是单击对象,对象在其关键帧中设置了50%的动画并停止,然后如果我再次单击对象,剩余的50%关键帧将被迭代

到目前为止,我已经将对象的动画设置为50%。问题是在click eventhandler中找不到交集

function mousedown( event ) 
{
    event.preventDefault();

    // update mouse object
    mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
    mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;

    // find intersections

    // create a reay with origin at the mouse position
    //   and direction into the scene (camera direction)
    var vector = new THREE.Vector3( mouse.x, mouse.y, 1 );

    var ray = projector.pickingRay( vector.clone(), camera );

    //Check for intersections
    var intersects = ray.intersectObjects( targetList , true);

    // if there is one (or more) intersections
    if ( intersects.length > 0 )
    {
        console.log(intersects);
        //Start animating - animation is a global var in this scene triggering
        //the animation.
        animation = true;

    }
    else
    {
        console.log("No intersections");        
    }

}
当对象第一次被实例化时,这就起作用了。不过,在对象“设置动画”后,它就不起作用了。经过一些调试后,我可以看到,即使在对象移动之后(动画的前50%已播放完毕),对象的几何体的位置=(0,0,0)

这似乎可以解释为什么mousedown事件没有拾取交叉点,因为在“世界”中,对象实际上没有定位在屏幕上看起来的位置

下面是加载对象的代码:

jsonLoader.load("assets/models/cheese01.js", function(geometry){
    geometry.computeMorphNormals();
    geometry.computeVertexNormals(); 
    // geometry.computeBoundingSphere();
    // geometry.normalsNeedUpdate = true; 
    // verticesNeedUpdate = true; 

    var material = new THREE.MeshLambertMaterial({
        color: 0xaa1100,
        morphTargets: true,
        morphNormals: true,
        wrapAround: true
    });

    var mesh = new THREE.MorphAnimMesh(geometry, material);

    mesh.castShadow = true;
    mesh.receiveShadow = true;

    mesh.duration = 3000;
    mesh.time = 0;
    mesh.scale.set( 1, 1, 1 );

    mesh.rotation.x = degToRad(175);

    mesh.matrixAutoUpdate = false;
    mesh.updateMatrix();

    geometry.normalsNeedUpdate = true;

    mesh.parseAnimations();

    scene.add(mesh);
    //Objects subject to intersection checks (from mouse click)
    targetList.push(mesh);
    //Objects to animate
    morphs.push(mesh);

 });
为任何帮助提前干杯