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

Stereogram

交差法でどうぞ。 
* 具合悪くなるかもしれませんので、お気をつけくだされ。
Get Adobe Flash player
by yasohachi 06 May 2010
/**
 * Copyright yasohachi ( http://wonderfl.net/user/yasohachi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qn22
 */

/**
* 交差法でどうぞ。 
* 具合悪くなるかもしれませんので、お気をつけくだされ。
**/
package
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	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;
	
	[SWF(width="440",height="200",frameRate="30",backgroundColor="0xffffff")]
	public class Stereogram extends Sprite
	{
		public var view1:Viewport3D;
		public var view2:Viewport3D;
		public var camera1:Camera3D;
		public var camera2:Camera3D;
		public var render:BasicRenderEngine;
		public var scene:Scene3D;
		public var cube1:Cube;
		public var cube2:Cube;
		public function Stereogram()
		{
			view1 = new Viewport3D(200,200);
			view1.opaqueBackground = 0x0;
			view1.x = 10;
			this.addChild(view1);
			view2 = new Viewport3D(200,200);
			view2.opaqueBackground = 0x0;
			this.addChild(view2);
			view2.x = 230;
			camera1 = new Camera3D();
			camera1.x += 80;
			camera2 = new Camera3D();
			camera2.x -= 80;
			
			
			scene = new Scene3D();
			
			var light:PointLight3D = new PointLight3D();
			var materialsList:MaterialsList = new MaterialsList( {
				front: new FlatShadeMaterial(light,0x00FFFF),
				back: new FlatShadeMaterial(light,0x00FFFF),
				right: new FlatShadeMaterial(light,0x00FFFF),
				left: new FlatShadeMaterial(light,0x00FFFF),
				top: new FlatShadeMaterial(light,0x00FFFF),
				bottom: new FlatShadeMaterial(light,0x00FFFF)
			});
			
			cube1 = new Cube(materialsList,100,100,100);
			cube2 = new Cube(materialsList,100,100,100);
			cube2.z += 500;
			cube2.x += 100;
			cube2.y += 100;
			scene.addChild(cube1);
			scene.addChild(cube2);
			
			
			var fmat:FlatShadeMaterial = new FlatShadeMaterial(light,0xcccc00);
			var plane:Plane = new Plane(fmat,150,150);
			plane.z = 200;
			plane.x -=80;
			plane.y -=120;
			scene.addChild(plane);
			
			fmat = new FlatShadeMaterial(light,0x6666ff);
			plane = new Plane(fmat,150,150);
			plane.z = 300;
			plane.x -= 120;
			plane.y -= 160;
			scene.addChild(plane);
			
			render = new BasicRenderEngine();
			
			
			this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
		}
		
		public function onEnterFrame(event:Event):void{
			cube1.rotationX += 2;
			cube1.rotationY += 3;
			cube1.rotationZ += 1;
			cube2.rotationX += 3;
			cube2.rotationY += 5;
			cube2.rotationZ += 4;
			render.renderScene(scene,camera1,view1);
			render.renderScene(scene,camera2,view2);
		}
	}
}