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

Perlin Noize Tunnel [ Away3D 4.1 ]

+ optimizations
/**
 * Copyright FLASHMAFIA ( http://wonderfl.net/user/FLASHMAFIA )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fVUi
 */

package {
    import away3d.containers.View3D;

    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.geom.Vector3D;
    import flash.utils.getTimer;

    [SWF(width='465', height='465')]
    public class PerlinTunnelA3D extends View3D {
        private var tunnel : PerlinNoizeTunnel;
        //private var snapBmd : BitmapData;

        function PerlinTunnelA3D() {
            stage.stageFocusRect = tabChildren = tabEnabled = mouseChildren = mouseEnabled = false;
            stage.scaleMode = 'noScale';
            stage.align = 'TL';
            stage.quality = 'low';
            stage.frameRate = 64;

            super();

            antiAlias = 4;

            camera.z = -10;
            camera.lookAt(new Vector3D(0, 0, 2048));

            tunnel = new PerlinNoizeTunnel(2048);
            scene.addChild(tunnel);

            //Wonderfl.disable_capture();
            //var bm : Bitmap = new Bitmap(snapBmd = new BitmapData(465, 465, false, 0x000000));
            //addChild(bm);

            stage.addEventListener(Event.ENTER_FRAME, oef);
        }

        private function oef(e : Event) : void {
            tunnel.update();

            var t : Number = getTimer();
            camera.x = Math.sin(t / 1024) * 256;
            camera.y = Math.cos(t / 768) * 256;

            render();

            //if (snapBmd) renderer.queueSnapshot(snapBmd);
        }
    }
}

import away3d.containers.ObjectContainer3D;
import away3d.entities.Mesh;
import away3d.materials.TextureMaterial;
import away3d.primitives.ConeGeometry;
import away3d.textures.BitmapTexture;

import flash.display.BitmapData;
import flash.geom.Matrix3D;
import flash.geom.Point;


internal class PerlinNoizeTunnel extends ObjectContainer3D {
    private var bmd : BitmapData;
    private var ofst : Array;
    private var o0 : Point;
    private var o1 : Point;
    private var vx0 : Number;
    private var vy0 : Number;
    private var vx1 : Number;
    private var vy1 : Number;
    private var cone : Mesh;
    private var mat : TextureMaterial;

    function PerlinNoizeTunnel(maxDistance : int) {
        super();

        mat = new TextureMaterial(new BitmapTexture(bmd = new BitmapData(128, 128, false)), false);
        mat.bothSides = true;
        mat.alphaBlending = false;
        // XXX mat.addMethod(new FogMethod(maxDistance * 0.7, maxDistance, 0x0));

        var h : int = maxDistance * 1.2;

        var mtx3d : Matrix3D = new Matrix3D();
        mtx3d.appendTranslation(0, h >> 1, 0);

        var geo : ConeGeometry = new ConeGeometry(465, h, 16, 16, true);
        geo.applyTransformation(mtx3d);

        cone = new Mesh(geo, mat);
        cone.rotationX = 90;
        addChild(cone);

        o0 = new Point(0, 0);
        o1 = new Point(0, 0);
        vx0 = 0.0;
        vx1 = 0.0;
        vy0 = -2 * 1;
        vy1 = -2 * 2;
        ofst = [o0, o1];
    }

    public function update() : void {
        o0.x += vx0;
        o0.y += vy0;
        o1.x += vx1;
        o1.y += vy1;

        bmd.perlinNoise(64, 64, 2, 2222, true, false, 7, false, ofst);

        mat.texture = new BitmapTexture(bmd);

        cone.rotationZ++;
    }
}