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

forked from: Some random geometry - true 3D now :)

// forked from makc3d's Some random geometry - true 3D now :)
package 
{ 
	import flash.display.*
	import flash.events.*
	import flash.geom.*

	import alternativ5.engine3d.controllers.*
	import alternativ5.engine3d.core.*
	import alternativ5.engine3d.display.*
	import alternativ5.engine3d.materials.*
	import alternativ5.engine3d.primitives.*
	import alternativ5.types.*

	[SWF(backgroundColor="0")]
	public class RandomGeomAnaglyph extends Sprite 
	{ 

		private var scene:Scene3D;
		private var swarm:Array = [];
		private var viewL:View;
		private var viewR:View;

		private var camNode:Object3D;
		private var m:Number = -10;

		public function RandomGeomAnaglyph () 
		{
			scene = new Scene3D; scene.root = new Object3D;

			viewL = new View; viewL.camera = new Camera3D;
			viewL.width = viewL.height = 465;
			viewL.camera.z = -100; viewL.camera.x = -2;
			addChild (viewL); viewL.transform.colorTransform =
				new ColorTransform (1, 0, 0);

			viewR = new View; viewR.camera = new Camera3D;
			viewR.width = viewR.height = 465;
			viewR.camera.z = -100; viewR.camera.x = +2;
			addChild (viewR); viewR.transform.colorTransform =
				new ColorTransform (0, 1, 1);

			viewR.blendMode = BlendMode.ADD;
			viewL.x -= 6; viewR.x += 6;

			camNode = new Object3D;
			camNode.addChild (viewL.camera);
			camNode.addChild (viewR.camera);
			scene.root.addChild (camNode);

			for (var i:int = 0; i < 10; i++)
			{
				var b:BoxElement = new BoxElement;
				b.box = new Box;
				b.box.rotationX = 2 * Math.PI * Math.random ();
				b.box.rotationY = 2 * Math.PI * Math.random ();
				b.box.rotationZ = 2 * Math.PI * Math.random ();
				swarm.push (b);
			}

			addEventListener (Event.ENTER_FRAME, function (e:Event):void {
				camNode.rotationX += 0.05;
				camNode.rotationY += 0.05;
				camNode.rotationZ += 0.05;
				scene.calculate (); if (m > 30) return;

				var b:BoxElement, i:int, sc:Number;
				for each (b in swarm) {
					var coords:Point3D = b.box.coords;
					var angles:Point3D = new Point3D (
						b.box.rotationX, b.box.rotationY, b.box.rotationZ);
					sc = b.box.scaleX;

					b.box = new Box (2, 2, 2);
					b.box.cloneMaterialToAllSurfaces (
						new FillMaterial (0, 1, BlendMode.NORMAL, 2,
							(100 + 3*m) * 0x10101));

					b.box.x = coords.x +
						10 * Math.cos (angles.z);
					b.box.y = coords.y +
						10 * Math.sin (angles.z) * Math.sin (angles.x);
					b.box.z = coords.z +
						10 * Math.sin (angles.z) * Math.cos (angles.x);

					b.box.rotationX = angles.x + b.drx;
					b.box.rotationY = angles.y + b.dry;
					b.box.rotationZ = angles.z + b.drz;

					b.box.scaleX = b.ds * sc;
					b.box.scaleY = b.ds * sc;
					b.box.scaleZ = b.ds * sc;

					b.box.mobility = 100-m++;
					if (m > 0) scene.root.addChild (b.box);
				}

			});

		}

	} 
} 

import alternativ5.engine3d.primitives.Box;
class BoxElement {
	public var box:Box;
	public var dx:Number;
	public var dy:Number;
	public var dz:Number;
	public var drx:Number = 0.3 * Math.random ();
	public var dry:Number = 0.3 * Math.random ();
	public var drz:Number = 0.3 * Math.random ();
	public var ds:Number = 1.2//0.6 + 0.2 * Math.random ();
}