Cube Reflection
...
@author Gustavo Pitombo
http://www.gustavopitombo.com.br
/**
* Copyright pitombo ( http://wonderfl.net/user/pitombo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/dDgw
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import org.papervision3d.core.effects.view.ReflectionView;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
/**
* ...
* @author Gustavo Pitombo
* http://www.gustavopitombo.com.br
*/
public class Cubo3d extends ReflectionView
{
private var Cubo:Cube;
private var light:PointLight3D;
private var mat:FlatShadeMaterial;
private var matList:MaterialsList;
public function Cubo3d()
{
viewportReflection.alpha = .5;
var bg:Sprite = new Sprite();
bg.graphics.beginFill(0x000000,1);
bg.graphics.drawRect(0, 0, 500, 500);
bg.graphics.endFill();
addChildAt(bg,0);
light = new PointLight3D();
mat = new FlatShadeMaterial(light, 0xff3232, 0x00);
matList = new MaterialsList();
matList.addMaterial(mat, "all");
Cubo = new Cube(matList, 300, 300, 300, 2, 2, 2, 0, 0);
Cubo.y = 250;
scene.addChild(Cubo);
var sombra:Sprite = new Sprite();
var matr:Matrix = new Matrix();
matr.createGradientBox(450, 150, Math.PI/2);
sombra.graphics.beginGradientFill("linear", [0x000, 0x000], [0, 1], [0, 255], matr, "pad", "rgb", -10);
sombra.graphics.drawRect(0, 0, 480, 200);
sombra.graphics.endFill();
sombra.y = 250;
addChild(sombra);
addEventListener(Event.ENTER_FRAME, _render, false, 0, true);
}
private function _render(e:Event):void
{
singleRender();
Cubo.rotationX += 1;
Cubo.rotationY += 2;
}
}
}