forked from: Sandy Movie Material
// forked from runouw's Sandy Movie Material
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*
import flash.geom.*
import sandy.core.Scene3D;
import sandy.core.data.*;
import sandy.core.scenegraph.*;
import sandy.materials.*;
import sandy.materials.attributes.*;
import sandy.primitive.*;
public class TheCode extends Sprite {
[SWF(width="465",height="465",backgroundColor="0xFFFFFF",frameRate="30")]
private var scene:Scene3D;
private var camera:Camera3D;
public var bmd:BitmapData;
public var point1:Point = new Point();
public var point2:Point = new Point();
public var point3:Point = new Point();
public function TheCode() {
camera = new Camera3D( stage.stageWidth, stage.stageHeight);
camera.z = -400;
var root:Group = createScene();
scene = new Scene3D( "scene", this, camera, root );
//scene.light.setDirection(0, 0, 1);
addEventListener( Event.ENTER_FRAME, enterFrameHandler );
}
private var box:Box
private function createScene():Group {
var g:Group = new Group();
box = new Box( "box",100,100,100);
box.rotateX = 30;
box.rotateY = 30;
var clip:MovieClip = new MovieClip();
var sprite:Sprite = new Sprite();
bmd = new BitmapData(100, 100, false, 0xCCCCCCCC);
var bitmap:Bitmap = new Bitmap(bmd);
sprite.addChild(bitmap);
sprite.filters = [ new BlurFilter (15, 15, 2) ];
clip.addChild(sprite);
//this.addChild(sprite);
box.appearance = new Appearance(new MovieMaterial(clip,40));
//box.appearance.lightingEnable = true;
g.addChild( box );
return g;
}
private var seed:int = Math.random()*100
private function enterFrameHandler( event : Event ) : void {
point1.x += 5;
point1.y += 2;
point2.x -= 2;
point2.y += 2;
point3.x += 1;
point3.y += 6;
var channels:uint = BitmapDataChannel.RED | BitmapDataChannel.BLUE | BitmapDataChannel.GREEN;
bmd.perlinNoise(50, 80, 4, seed, false, false, channels, false, [point1,point2,point3]);
//bmd.colorTransform(bmd.rect, new ColorTransform(1,1,1,1, 255,255,255, 255));
bmd.applyFilter(bmd, bmd.rect, new Point(), new BlurFilter (3, 3, 2));
box.rotateY+=3;
scene.render();
}
}
}