A problem about HoverController

Software: Other

zyb, Newbie
Posted: 27 November 2014 10:35 AM   Total Posts: 3
import away3d.containers.View3D;
import away3d.primitives.SphereGeometry;
import away3d.textures.BitmapTexture;
import away3d.materials.TextureMaterial;
import away3d.entities.Mesh;
import away3d.controllers.HoverController;
import away3d.cameras.Camera3D;

var 
_startX:Number;
  
var 
_startY:Number;
  
var 
_mouseX:Number;
  
var 
_mouseY:Number;  
var 
view:View3D=new View3D();
var 
camera=new Camera3D();
view.camera.lens.far=5000;
view.camera=camera;
addChild(view);
var 
_camerController:HoverController =new HoverController(view.cameranull001200, -9090);
var 
loader:Loader=new Loader();
var 
bitmapData:quanjing=new quanjing();//this is texture picture
var sphere:SphereGeometry = new SphereGeometry(1000);
var 
bitmapTexture:BitmapTexture = new BitmapTexture(bitmapData);
var 
textureMaterial:TextureMaterial = new TextureMaterial(bitmapTexture);
var 
mesh:Mesh = new Mesh(sphere,textureMaterial);
view.scene.addChild(mesh);
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
stage.addEventListener(MouseEvent.MOUSE_WHEELonMouseWheel);
function 
mouseDownFunction(evt:MouseEvent):void
{
 _startX 
_camerController.panAngle;
 
_startY _camerController.tiltAngle;
 
_mouseX mouseX;
 
_mouseY mouseY;
 
stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
 
stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
}
function mouseMoveFunction(evt:MouseEvent):void
{
        _camerController
.panAngle = (mouseX _mouseX) * .3 _startX;
 
_camerController.tiltAngle = (mouseY _mouseY) * .3 _startY;
}
function mouseUpFunction(evt:MouseEvent):void
{
 stage
.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);
 
stage.removeEventListener(MouseEvent.MOUSE_UP,mouseUpFunction);
 
stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownFunction);
 
trace(view.camera.x+","+view.camera.y+","+view.camera.z+","+_camerController.tiltAngle);
}

addEventListener
(Event.ENTER_FRAME,enterFrameFunction);

function 
enterFrameFunction(evt:Event):void
{
 view
.render();
}
function onMouseWheel(event:MouseEvent) : void
{
 _camerController
.distance -= event.delta*5;
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X