2016-12-08 1 views
0

안녕하세요, 저는 Collada 모델에서 kfAnimation 애니메이션으로 작업하고 있습니다. 나는 트랙볼 컨트롤을 포함 할하지만 난 크기의 스택을 초과 할 때 나는 내 코드가 왜TrackballControls with Collada kfAnimation Three JS

 function init() { 

        initRender(); 
        // Camera 
        initCamera(); 
        // Scene 
        initScene(); 
        //controlls 
        initControls(); 

        initGrid(); 

        loadObjectAnimatedFrames(); 


        window.addEventListener('resize', onWindowResize, false); 
       } 
    function loadObjectAnimatedFrames(){ 
        loader = loader.load('sources/crack-animated.dae', function (collada) { 
        model = collada.scene; 
        animations = collada.animations; 
        kfAnimationsLength = animations.length; 
        //model.scale.x = model.scale.y = model.scale.z = 0.125; // 1/8 scale, modeled in cm 

        for (var i = 0; i < kfAnimationsLength; ++i) { 
         var animation = animations[ i ]; 
         var kfAnimation = new THREE.KeyFrameAnimation(animation); 
         kfAnimation.timeScale = 1; 
         kfAnimations.push(kfAnimation); 
        } 
        start(); 
        animate(lastTimestamp); 
        scene.add(model); 
        }); 
       } 
    function initControls(){ 

        controls = new THREE.TrackballControls(camera); 
        controls.minDistance = 100; 
        controls.maxDistance = 1800; 
        controls.addEventListener('change',render); 

        } 
function animate(timestamp) { 
       var frameTime = (timestamp - lastTimestamp) * 0.001; 
       if (progress >= 0 && progress < 48) { 
        for (var i = 0; i < kfAnimationsLength; ++i) { 
         kfAnimations[ i ].update(frameTime); 
        } 
       } else if (progress >= 48) { 
        for (var i = 0; i < kfAnimationsLength; ++i) { 
         kfAnimations[ i ].stop(); 
        } 
        progress = 0; 
        start(); 
       } 
       //pointLight.position.copy(camera.position); 
       progress += frameTime; 
       lastTimestamp = timestamp; 

       render(); 

      } 

다음 나는 기능을 애니메이션 내부 통제 업데이트를 넣고 시작 시도 몰라하지만 난 그게 많이 소비 생각 자원의 또한 내부 렌더링을 시도했지만 동일한 결과가 나타납니다.

도움을 주셔서 감사합니다. 좀 더 실험적으로 도움이 되었기를 바랍니다.

답변

0

마지막으로 나는 해결책을 발견하고 난 그냥 controls.update를 추가하려면이 후 dampingFactor

function initControls(){ 
       controls = new THREE.TrackballControls(camera, renderer.domElement); 
       //controls.addEventListener('change', render); // add this only if there is no animation loop (requestAnimationFrame) 
       controls.enableDamping = true; 
       controls.dampingFactor = 0.25; 
       controls.enableZoom = false; 
      } 

enableDamping 및 옵션 이었다();

renderer.render(scene, camera); 
      requestAnimationFrame(animate);