alternativa test01b : change fillmaterial
/**
* Copyright IPFix ( http://wonderfl.net/user/IPFix )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7bMB
*/
// forked from Gobelins_IPFix's alternativa test01 : box, fillmaterial and "cellshading"
package {
import flash.events.MouseEvent;
import alternativ7.engine3d.core.Camera3D;
import alternativ7.engine3d.core.Object3DContainer;
import alternativ7.engine3d.core.View;
import alternativ7.engine3d.materials.FillMaterial;
import alternativ7.engine3d.primitives.Box;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import frocessing.color.ColorHSV;
[SWF(backgroundColor="#DDDDDD", width="465", height="465", frameRate="60")]
public class HelloAlternativa3D extends Sprite {
private var rootContainer:Object3DContainer = new Object3DContainer();
private var camera:Camera3D;
private var color:ColorHSV;
private var box:Box;
public function HelloAlternativa3D() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
color = new ColorHSV(0);
camera = new Camera3D();
camera.view = new View(stage.stageWidth, stage.stageHeight);
addChild(camera.view);
addChild(camera.diagram);
camera.rotationX = -120*Math.PI/180;
camera.y = -800;
camera.z = 400;
rootContainer.addChild(camera);
box = new Box(400, 400, 400, 1, 1, 1);
var material:FillMaterial = new FillMaterial(color.value, 1, 2,0xFFFFFF);
box.setMaterialToAllFaces(material);
rootContainer.addChild(box);
camera.view.width = stage.stageWidth;
camera.view.height = stage.stageHeight;
camera.render();
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
}
private function onMove(e:MouseEvent):void {
var material:FillMaterial = new FillMaterial(color.value, 1, 2,0xFFFFFF);
box.setMaterialToAllFaces(material);
box.rotationZ = (e.stageX/stage.stageWidth)*Math.PI;
camera.y = -600-(e.stageY/stage.stageHeight)*400;
camera.render();
color.h++;
}
}
}