- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
先导入两个个基本类:import org.papervision3d.view.BasicView; import org.papervision3d.objects.primitives.Cube;
这个类是其他四个类的合体:Scene3D,Viewport3D,Camera3D,BasicRenderEngine,聪明的人为何不直接用这个基本类代替这四个类呢?呵呵
package
{
import flash.display.Scene;
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.view.BasicView;
/**
* ...
* @author 北飘草 ..欢迎和大家一起研究PV3D
*/
public class Main extends BasicView
{
private var colorlist:MaterialsList;
private var cube:Cube;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var red:ColorMaterial = new ColorMaterial(0xff0000);
var green:ColorMaterial = new ColorMaterial(0x00ff00);
var blue:ColorMaterial = new ColorMaterial(0x0000ff);
colorlist = new MaterialsList();
colorlist.addMaterial(red, "front")
colorlist.addMaterial(red, "back")
colorlist.addMaterial(blue, "left")
colorlist.addMaterial(blue ,"right")
colorlist.addMaterial(green, "bottom")
colorlist.addMaterial(green, "top")
cube=new Cube(colorlist,500,500,500)
scene.addChild(cube)
startRendering();
}
override protected function onRenderTick(e:Event=null):void
{
cube.localRotationY += 1;
cube.localRotationX+= 1;
super.onRenderTick()
}
}}
立方体的cube构造函数 第一个是MaterialsList
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/ |
|