Sample of PhoneMaterial
...
@author ...
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import org.papervision3d.core.view.IView;
/**
* ...
* @author ...
*/
public class Pv3d005 extends Sprite
{
private var _view:CustomView;
public function Pv3d005()
{
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
}
private function addedToStageHandler(e:Event):void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.frameRate = 30;
_view = new CustomView();
addChild(_view);
}
}
}
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import org.papervision3d.view.BasicView;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.special.CompositeMaterial;
import org.papervision3d.materials.shadematerials.PhongMaterial;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.core.proto.MaterialObject3D;
internal class CustomView extends BasicView {
private var tf:TextField;
private var cube:Cube;
public function CustomView() {
super(0, 0, true, true);
buildScene();
startRendering();
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(e:Event):void
{
cube.rotationX += 1;
cube.rotationY += 1;
cube.rotationZ += 1;
}
protected function buildScene():void {
var cmat:CompositeMaterial = new CompositeMaterial();
var ml:MaterialsList = new MaterialsList();
var pointLight:PointLight3D;
pointLight = new PointLight3D(true);
pointLight.z = -800;
pointLight.y = 300;
pointLight.x = 300;
var phonemat:PhongMaterial;
phonemat = new PhongMaterial(pointLight,0xffffff, 0xff0000, 0);
cmat.addMaterial(phonemat);
//cmat.addMaterial(new WireframeMaterial(0xff0000, 1, 1));
ml.addMaterial(cmat, "all");
cube = new Cube(ml, 100, 100, 100, 2, 2, 2);
scene.addChild(cube, "cube");
camera.x = 0;
camera.y = 0;
camera.z = -400;
}
}