away3D操纵三维物体之多边形载物旋转实例

/*在fb下新建as项目运行此实例*/

Basic07_group.as

package{
import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.core.math.Number3D;
import away3d.primitives.Cube;
import away3d.primitives.RegularPolygon;
import away3d.primitives.Sphere;

import flash.display.Sprite;
import flash.events.Event;
import flash.text.*;

[SWF(width="500", height="400", frameRate="60", backgroundColor="#FFFFFF")]

public class Basic07_group extends Sprite{
private var view:View3D;
private var label:TextField;
private var group:ObjectContainer3D;
private var disc:RegularPolygon;
private var cube:Cube;
private var sphere:Sphere;

public function Basic07_group(){
view = new View3D({x:250, y:200}); // create a viewport
addChild(view);
view.camera.y = 300; // Move camera up
// Point it toward scene center again, so the target is right (setting y does not change where the camera is pointing)
view.camera.lookAt(new Number3D(0, 0, 0));
group = new ObjectContainer3D();
view.scene.addChild(group);
disc = new RegularPolygon({radius:250, y:-25, sides:20, pushback:true}); // attach objects to group(this is a polygon---多边形)
group.addChild(disc);
cube = new Cube({depth:50, width:50, height:50, z:200});
group.addChild(cube);
sphere = new Sphere({radius:25, z:-200});
group.addChild(sphere);
this.addEventListener(Event.ENTER_FRAME, update); // render the view
}

private function update(e:Event):void{
group.rotationY += 0.5; // Rotate group
cube.rotationY -= 0.5; // Counter-rotate the cube so it always faces the viewer
view.render(); // re-render the view
}

}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值