Best options for animation in THREE.JS

前端 未结 5 474
鱼传尺愫
鱼传尺愫 2020-12-29 14:39

What is the best options for animations (texture animations, moving objects, hiding/showing object,...) in three.js ? Do you use extra lib. such as tween.js or something els

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 14:58

    Copy paste this:

    window.requestAnimFrame = (function(){
      return  window.requestAnimationFrame       ||
              window.webkitRequestAnimationFrame ||
              window.mozRequestAnimationFrame    ||
              window.oRequestAnimationFrame      ||
              window.msRequestAnimationFrame     ||
              function( callback ){
                window.setTimeout(callback, 1000 / 60);
              };
    })();
    
    (function animloop(){
      requestAnimFrame(animloop);
      render();
    })();
    
    function render()
    {
    // DO YOUR STUFF HERE (UPDATES AND DRAWING TYPICALLY)
    }
    

    The original author is: http://paulirish.com/2011/requestanimationframe-for-smart-animating/

提交回复
热议问题