forked from: Sandy Movie Material
// forked from runouw's Sandy Movie Material
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*
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(frameRate=30)]
private var scene:Scene3D;
private var camera:Camera3D;
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();
sprite.graphics.beginFill(0xAAAAFF);
sprite.graphics.moveTo(0,0);
sprite.graphics.lineTo(500,0);
sprite.graphics.lineTo(500,500);
sprite.graphics.lineTo(0,500);
sprite.graphics.lineTo(0,0);
sprite.graphics.endFill();
for(var i:int = 0;i<100;i++){
sprite.graphics.beginFill(Math.random()*0xFFFFFF);
sprite.graphics.drawCircle( Math.random()*450+25, Math.random()*450+25, 5+Math.random()*20);
sprite.graphics.endFill();
}
//sprite.filters = [ new BlurFilter (20, 20, 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 function enterFrameHandler( event : Event ) : void {
box.rotateY+=3;
scene.render();
}
}
}