In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2009-8-23

Get Adobe Flash player
by billylo 23 Aug 2009

    Tags

    3d
    Embed
/**
 * Copyright billylo ( http://wonderfl.net/user/billylo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5gBt
 */

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.filters.GlowFilter;
	
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.materials.*;
	import org.papervision3d.materials.WireframeMaterial;
	import org.papervision3d.materials.special.CompositeMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.objects.primitives.Cube;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.Viewport3D;
	import org.papervision3d.view.layer.ViewportLayer;
	import org.papervision3d.view.layer.util.ViewportLayerSortMode;

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

	public class viewportLayerTest01 extends Sprite {
		private var viewport:Viewport3D;
		private var renderer:BasicRenderEngine;
		private var scene:Scene3D;
		private var camera:Camera3D;

		private var cube:Cube;
		private var plane:Plane;
		private var deg:Number=1;
		private var layer1:ViewportLayer;
		private var layer2:ViewportLayer;

		public function viewportLayerTest01():void {

			viewport=new Viewport3D(500,400);
			renderer=new BasicRenderEngine  ;
			scene=new Scene3D;
			camera=new Camera3D(60,10,5000);
			
			viewport.containerSprite.sortMode = ViewportLayerSortMode.Z_SORT;

			addChild(viewport);
			
            var planeMat:WireframeMaterial = new WireframeMaterial(0xFF0000);
            var planecolorMat:ColorMaterial = new ColorMaterial(0xFFFF00);
            var planecompMat:CompositeMaterial = new CompositeMaterial();
            planecompMat.addMaterial(planeMat);
            planecompMat.addMaterial(planecolorMat);
			
			plane=new Plane(planecompMat,500,500,1,1);
			plane.pitch(90);
			plane.y=0;
			
            var cubeMat:WireframeMaterial = new WireframeMaterial(0xFF0000);
            //var cubeMat:BitmapFileMaterial = new BitmapFileMaterial('http://wonderfl.net/img/common/img_h1.gif');
            var colorMat:ColorMaterial = new ColorMaterial(0x00FF00);
            var compMat:CompositeMaterial = new CompositeMaterial();
            compMat.addMaterial(cubeMat);
            compMat.addMaterial(colorMat);
            
            var materialsList:MaterialsList = new MaterialsList({ all:compMat });
            
			cube=new Cube(materialsList,200,200,200,1,1,1);
			cube.y=100;

			scene.addChild(cube);
			
			scene.addChild(plane);
			
			layer1=viewport.getChildLayer(cube);
		        layer2=viewport.getChildLayer(plane);
			trace(layer1);
			trace(layer2);
			//var filter1:GlowFilter = new GlowFilter(0xccffff,1,18,18,4,1,false,false);
			//var filter2:BlurFilter = new BlurFilter(10,10);
			//layer1.filters=[filter2];
			//layer2.filters=[filter1];
                        //cube.filters=[new GlowFilter(0xFF0000, 18,18)];
                       
			addEventListener(Event.ENTER_FRAME,process);
		}
		private function process(evt:Event):void {
			camera.orbit(50,deg,true,plane);
                        deg++;
			renderer.renderScene(scene,camera,viewport);
		}

	}
}