/**
* ...
* @author 张首尚
*/
public class vb3 extends BasicView
{
private var ppaperPlane;
private var left:Boolean;
private var right:Boolean;
private var forWard:Boolean;
private var backWard:Boolean;
private var qWard:Boolean;
private var eWard:Boolean;
private var camer:SpringCamera3D;
public function vb3(_stage:Stage)
{
super(640, 480,***e,false,CameraType.SPRING);
init(_stage);
}
private function init(_stage:Stage):void
{
camer = SpringCamera3D(this.camera);
camer.useCulling = ***e;
camer.mass = 20;
camer.damping = 4;
camer.stiffness = 1;
camer.positionOffset = new Number3D(0, -150, -150);
camer.lookOffset = new Number3D(0,0,100);
var cm:CompositeMaterial = new CompositeMaterial();
cm.addMaterial(new ColorMaterial(0xFF33FF));
cm.addMaterial(new WireframeMaterial(0xEEEEEE));
cm.doubleSided = ***e;
pp = new PaperPlane(cm);
scene.addChild(pp);
pp.y = 250;
pp.z = -10;
_stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey_Down);
_stage.addEventListener(KeyboardEvent.KEY_UP, onKey_Up);
/*camer.target = pp;*/
this.startRendering();
}
private function onKey_Down(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case "W".charCodeAt():
case Keyboard.UP:
forWard = ***e;
break;
case "S".charCodeAt():
case Keyboard.DOWN:
backWard = ***e;
break;
case "A".charCodeAt():
case Keyboard.LEFT:
left = ***e;
break;
case "D".charCodeAt():
case Keyboard.RIGHT:
right = ***e;
break;
case "Q".charCodeAt():
qWard = ***e;
break;
case "E".charCodeAt():
eWard = ***e;
break;
}
}
private function onKey_Up(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case "W".charCodeAt():
case Keyboard.UP:
forWard = false;
break;
case "S".charCodeAt():
case Keyboard.DOWN:
backWard = false;
break;
case "A".charCodeAt():
case Keyboard.LEFT:
left = false;
break;
case "D".charCodeAt():
case Keyboard.RIGHT:
right = false;
break;
case "Q".charCodeAt():
qWard = false;
break;
case "E".charCodeAt():
eWard = false;
break;
}
}
private function moveObject():void
{
if (this.forWard) {
pp.moveForward(30);
}else if (this.backWard) {
pp.moveBackward(30);
}
if (this.left) {
pp.localRotationY -= 2;
}else if (this.right) {
pp.localRotationY += 2;
}