AS代码:
1 package
2 {
3 import flash.events.Event;
4 import org.papervision3d.core.clipping.FrustumClipping;
5 import org.papervision3d.materials.ColorMaterial;
6 import org.papervision3d.materials.utils.MaterialsList;
7 import org.papervision3d.objects.primitives.Cube;
8 import org.papervision3d.view.BasicView;
9
10 [SWF(width="640", height="480", frameRate="60")]
11 public class PVCubeRoom extends BasicView
12 {
13
14 private var cube:Cube;
15 public function PVCubeRoom():void
16 {
17 super(640, 480, true, true, "Debug");
18 init();
19 singleRender();
20 addEventListener(Event.ENTER_FRAME, tick);
21 }
22
23 private function init():void
24 {
25
26 renderer.clipping = new FrustumClipping(FrustumClipping.NEAR);
27 camera.z = -200;
28 camera.useCulling = false;
29
30 var matlist:MaterialsList = new MaterialsList( {
31 front:new ColorMaterial(Math.random() * 0xffffff),
32 back:new ColorMaterial(Math.random() * 0xffffff),
33 right:new ColorMaterial(Math.random() * 0xffffff),
34 left:new ColorMaterial(Math.random() * 0xffffff),
35 top:new ColorMaterial(Math.random() * 0xffffff),
36 bottom:new ColorMaterial(Math.random() * 0xffffff)
37 });
38
39 cube = new Cube(matlist, 10000, 10000, 2500, 2, 2, 2, Cube.ALL);
40 scene.addChild(cube);
41 }
42
43
44 private function tick(e:Event):void
45 {
46 singleRender();
47 }
48 }
49 }
50