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

【PV3D】shadeMaterial

Get Adobe Flash player
by _ryotaros 17 Jan 2010
    Embed
/**
 * Copyright _ryotaros ( http://wonderfl.net/user/_ryotaros )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2Ayn
 */

package {
     import flash.display.*;
     import flash.events.*;
     import flash.filters.*;
     import flash.geom.*;
     import flash.media.*;
     import flash.net.*;
     import org.papervision3d.core.effects.*;
     import org.papervision3d.core.effects.utils.*;
     import org.papervision3d.view.layer.*;
     import org.papervision3d.objects.*;
     import org.papervision3d.view.*;
     import org.papervision3d.materials.*;
     import org.papervision3d.materials.shadematerials.*;
     import org.papervision3d.materials.utils.*;
     import org.papervision3d.objects.primitives.*;
     import org.papervision3d.lights.*;
     import org.papervision3d.cameras.*;
    
    [SWF(width=465,height=465,backgroundColor =0)]
    public class FlashTest extends BasicView{
    	
    		public var obj:Cube;
    		public var camera2:Camera3D;
    		public var bmpViewport:BitmapViewport3D;
    		
         public function FlashTest () {
         	
         	var light:PointLight3D = new PointLight3D(true, false);
         	scene.addChild(light);
         	
         	var bmp:BitmapData = new BitmapData(500, 500 ,false ,0xFF0000); 
         	bmp.draw(this);

         	
         	
         	//var material:FlatShadeMaterial = new FlatShadeMaterial(light, 0xffffff, 0x111111, 50);
         	//var material:GouraudMaterial = new GouraudMaterial(light, 0xFFFFFF, 0x111111, 100);
         	var material:CellMaterial = new CellMaterial(light, 0xFFFFFF, 0x111111, 10);
			//var material:EnvMapMaterial = new EnvMapMaterial(light, bmp, null, 0x000000);      
   
         	var materials:MaterialsList = new MaterialsList({all:material});    
         	obj = new Cube(materials, 250, 250, 250, 10, 10, 10);
         	obj.x = -250;
         	
         	camera2 = new Camera3D();
         	camera2.target = obj;
         	
         	bmpViewport = new BitmapViewport3D();
         	var mirorMat:BitmapViewportMaterial = new BitmapViewportMaterial(bmpViewport, true);
         	var mirorObj1:Plane = new Plane(mirorMat, 1280, 960);
         	
         	mirorObj1.z = camera2.z = 200;
         	mirorObj1.x = camera2.x = 500;
         	scene.addChild(mirorObj1);
         	
         	addEventListener(Event.ENTER_FRAME, loop);
         	
         	scene.addChild(obj);
         	
         	startRendering();
         	
         }   
         
         public function loop(e:Event):void{
			obj.rotationX += 1;
			obj.rotationY += 2;
			
			renderer.renderScene(scene, camera2, bmpViewport);
			         	
         }

    }
}