PV3D+TweenLite——让3D镜头也缓动起来!
PV3D提供了一个BasicView的类,继承这个类,可以让我们轻易在舞台上创建镜头,3D对象。
public function ThreeDStage(cameraType:String, owner:DisplayObject)
{
super(owner.width, owner.height, false, true, cameraType);

this.camera.focus = 30;
this.camera.zoom = 30;
for (var i:int = 0; i < 40; i ++)
{
var ball:Ball = new Ball(src);
scene.addChild(ball);
}
}
然后添加一个Timer对象,定时执行镜头的移动、旋转。
timer = new Timer(4000, 0);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
在这个监听函数里面,我们使用TweenLite类来移动和旋转镜头。
TweenLite.goto(this.camera, 2.5, {x:360 - Math.round(Math.random() * 720),
y:200 - Math.round(Math.random() * 400),
z:200 - Math.round(Math.random() * 400),
rotationX:40 - Math.round(Math.random() * 80),
rotationY:40 - Math.round(Math.random() * 80),
rotationZ:40 - Math.round(Math.random() * 80),
ease:GetEasingFunction.easingFunction(_tweenType).easeOut,
onComplete:_stopRendering});
这样我们的镜头就具备缓动效果了。
顺便说一下,在这个BasicView类里面,有三个方法,startRendering()和stopRendering()和singleRender()。第一个是开始每帧绘制3D对象,第二个是停止绘制3D对象,第三个是只绘制一次3D对象。
Preview:由于空间过期,请到我的blog查找更新的地址













然后添加一个Timer对象,定时执行镜头的移动、旋转。



在这个监听函数里面,我们使用TweenLite类来移动和旋转镜头。








这样我们的镜头就具备缓动效果了。
顺便说一下,在这个BasicView类里面,有三个方法,startRendering()和stopRendering()和singleRender()。第一个是开始每帧绘制3D对象,第二个是停止绘制3D对象,第三个是只绘制一次3D对象。
Preview:由于空间过期,请到我的blog查找更新的地址

【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步