- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
package
{
import flash.display.Shape;
import org.papervision3d.materials.BitmapColorMaterial;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.view.BasicView;
import org.papervision3d.cameras.CameraType;
import org.papervision3d.cameras.SpringCamera3D;
import org.papervision3d.cameras.DebugCamera3D;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.events.FileLoadEvent;
import org.papervision3d.materials.BitmapFileMaterial;
import flash.events.Event;
/**
* ...
* @author 张首尚
*/
public class vb2 extends BasicView
{
private var sp:Sphere;
private var imgArray:Array = ["assets/1.jpg","assets/2.jpg","assets/3.jpg","assets/4.jpg"];
public function vb2()
{
super(640, 480, ***e, ***e, CameraType.DEBUG);
init();
}
private function init():void
{
var bm:BitmapFileMaterial = new BitmapFileMaterial("assets/1.jpg");
bm.addEventListener(FileLoadEvent.LOAD_COMPLETE, onLoadComplete);
bm.precise = ***e;
bm.smooth = ***e;
sp = new Sphere(bm, 200, 24, 18);
scene.addChild(sp);
for (var i:int = 0; i < 100; i++ ) {
var pllane;
if (i % 2 == 0) {
pl = new Plane(new BitmapFileMaterial(imgArray[Math.round(Math.random() * 3)], ***e), 200, 200, 2, 2);
}else {
pl = new Plane(new ColorMaterial(Math.random() * 0xFFFFFF, 1), 100, 100, 1, 1);
}
pl.material.doubleSided = ***e;
scene.addChild(pl);
pl.x = Math.random() * 20000 - 10000;
pl.y = Math.random() * 1500 - 500;
pl.z = Math.random() * 20000 - 10000;
pl.localRotationY = Math.random() * 180 - 90;
}
camera.z = -2000;
camera.focus = 20;
camera.far = 20000;
}
private function onLoadComplete(evt:FileLoadEvent):void
{
this.startRendering();
}
override protected function onRenderTick(e:Event=null):void
{
super.onRenderTick();
sp.localRotationY += 2;
}
}
}
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/ |
|