TurretDefence.as
package
{
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.core.base.Object3D;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import away3d.cameras.HoverCamera3D;
import s_camera_setting;
import turret.turret_assembly_set;
import turret_operate.main_operation_class;
public class TurretDefence extends Sprite
{
public var load_turret:ObjectContainer3D = new turret_assembly_set().turret_set;
//public var turret_direction_operation:Object3D = new turret_assembly_set().turret_set_gun_body;
public var load_camera_setting:s_camera_setting = new s_camera_setting(load_turret);
//protected var camera_state:HoverCamera3D = new s_camera_setting(load_turret).S_Camera;
//public var load_operation_system:main_operation_class;
public var scene:Scene3D;
public var camera:Camera3D;
public var view:View3D;
protected var lastStageX:Number;
protected var lastStageY:Number;
public function TurretDefence():void
{
initUI();
initEngine();
initScene();
initListener();
}
protected function initEngine():void{
view = new View3D();
scene = view.scene;
camera = view.camera;
addChild(view);
view.x = stage.stageWidth/2;
view.y = stage.stageHeight/2;
view.camera = load_camera_setting.S_Camera;
view.camera.z = -1000;
}
protected function initListener():void{
addEventListener(Event.ENTER_FRAME,onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
}
protected function onEnterFrame(event:Event):void{
view.render();
}
protected function initScene():void{
}
protected function initUI():void{
}
protected function onMouseMove(event:MouseEvent):void{
var y_axis_rotation:int = (event.stageX - lastStageX);
var x_axis_rotation:int = (event.stageY - lastStageY);
load_camera_setting.s_camera_rotation(x_axis_rotation,y_axis_rotation);
lastStageX = event.stageX;
lastStageY = event.stageY;
}
}
}
s_camera_setting
package
{
import away3d.cameras.HoverCamera3D;
import away3d.containers.ObjectContainer3D;
//import away3d.core.base.Object3D;
import flash.display.Sprite;
public class s_camera_setting extends Sprite
{
public var S_Camera:HoverCamera3D;
public function s_camera_setting($target:ObjectContainer3D)
{
S_Camera = new HoverCamera3D(
{
target: $target,
distance: 300,
mintiltangle: 5,
tiltAngle: 45
}
);
}
public function s_camera_rotation($x_axis:int, $y_axis:int){
S_Camera.panAngle += $y_axis;
S_Camera.tiltAngle += $x_axis;
}
}
}
Main.as
package
{
public class Main extends TurretDefence
{
public function Main()
{
super();
scene.addChild(load_turret);
}
}
}
i problem use hovercamera3d.
i think will ‘view.camera = load_camera_setting.S_Camera;’ is wrong code but i can’t fix it.
i want get MouseEvent to rotate view camera.
the project stats are show modified tilt&panAngle;. but rotation isn’t change.