课程第7章好多都有问题啊, 漏写了好多代码, 但是依然能运行,7-12, 7-9
来源:7-12 跳跃模型旋转开发

qq_yu_52
2019-05-06
课程第7章课程好多都有问题啊, 漏写了好多代码和逻辑,7-12, 7-9等课程
希望老师还是检查一下吧
写回答
2回答
-
熊出没
2019-05-22
第7-8、7-9这两节里面的代码接不起来
showup方法的参数在这两节都不一样,TweenAnimation也是两节不一样,customAnimation.to方法里面发for循环
import Tween from './tween'; const customAnimation=exports.customAnimation={} customAnimation.to=function(duration,from,to,type){ console.log('customAnimation to') for(let prop in to){ TweenAnimation(from[prop],to[prop],duration,type,(value,complete)=>{ from[prop]=value }) } } const TweenAnimation=exports.TweenAnimation=function TweenAnimation(from,to,duration,type,callback){ console.log("TweenAnimation") // 帧数(以毫秒计算) const frameCount=duration*1000/17; // 初始帧 let start=-1; // 开始时间 const startTime=Date.now(); // 结束时间 let lastTime=Date.now() const tweenFn=Tween[type]; const options={ callback:function(){}, type:'Linear', duration:300 } if(callback){ options.callback=callback } if(type){ options.type=type } if(duration){ options.duration=duration } const step=function (step){ const currentTime=Date.now(); const interval=currentTime-lastTime; let fps; if(interval){ fps=Math.ceil(1000/interval) } else { requestAnimationFrame(step) return; } if(fps>=30){ start++ } else { const _start=Math.floor(interval/17); start=start+_start; } console.log(interval,start,frameCount) const value=tweenFn(start,from,to - from,frameCount); if(start<=frameCount){ options.callback(value) requestAnimationFrame(step) } else { options.callback(to,true) } lastTime=Date.now() requestAnimationFrame(step); } step() }
按照7-9的写下来,还是报错
00 -
千迦
2019-05-07
额 代码课程提供的源码里是完整的 你可以参考一下,现在哪块不太对?
00
相似问题