3D画布导览

时间:2018-06-19 17:43:42

标签: javascript 3d setinterval

我想创建一个JavaScript函数,该函数在声明的所有位置上依次调用以下函数,每次移动之间等待几秒钟。

function actionsToolbar(action) {
else if(action=='tour' || action=='tour_on') { 
  	    presenter.animateToTrackballPosition([0.179, 0.291, 4.6983, 13.865, 1.28]);
		presenter.animateToTrackballPosition([0.179, 0.291, 13.178, 22.002, 1.28]);
		presenter.animateToTrackballPosition([0.179, 0.291, 32.086, 26.127, 1.28]);
		presenter.animateToTrackballPosition([0.123, 0.197, 33.346, 26.241, 1.28]);
		presenter.animateToTrackballPosition([0.018, -0.0766, 33.346, 26.24, 1.28]);
		presenter.animateToTrackballPosition([0.018, -0.0766, -8.823, 29.99, 1.25]);

                                   }
   }

1 个答案:

答案 0 :(得分:0)

问题解决了!

 else if(action=='tour' || action=='tour_on') { 
     loop(
         function() { presenter.animateToTrackballPosition([0.179, 0.291, 4.6983, 13.865, 1.28]); }, 
         function() { presenter.animateToTrackballPosition([0.179, 0.291, 13.178, 22.002, 1.28]); },
         function() { presenter.animateToTrackballPosition([0.179, 0.291, 32.086, 26.127, 1.28]); },
         function() { presenter.animateToTrackballPosition([0.123, 0.197, 33.346, 26.241, 1.28]); },
         function() { presenter.animateToTrackballPosition([0.018, -0.0766, 33.346, 26.24, 1.28]); },
         function() { presenter.animateToTrackballPosition([0.018, -0.0766, -8.823, 29.99, 1.25]); }
		 );
  	 
     }
   }

   function loop() {
    var args = arguments;
    if (args.length <= 0)
        return;
    (function chain(i) {
        if (i >= args.length || typeof args[i] !== 'function')
            return;
        window.setTimeout(function() {
            args[i]();
            chain(i + 1);
        }, 2000);
    })(0);
}