HoverCamera3d is evil!
On Jan 31, 7:21 am, "[email protected]" <[email protected]> wrote: > Good time of the day, > > I have found that HoverCamera3D does not work at all with the latest > trunk. > For instance the code bellow works perfectly with away 2.2. and > earlier verisons but does not work at all with the latest trunk, > throwing packs of errors. > > package > { > import flash.display.MovieClip; > import flash.events.*; > import away3d.cameras.*; > import away3d.containers.*; > import away3d.primitives.*; > import away3d.core.math.*; > import away3d.core.base.*; > import away3d.materials.*; > > /** > * ... > * @author DefaultUser (Tools -> Custom Arguments...) > */ > public class MainSite extends MovieClip > { > public var view:View3D; > private var sphere:Sphere; > public var lastMouseX:Number = 0; > public var lastMouseY:Number = 0; > public var dragX:Number=1; > public var dragY:Number = 1; > private var camera:HoverCamera3D; > > public function MainSite() { > init3DObjects(); > initCamera(); > stage.addEventListener(MouseEvent.MOUSE_MOVE, > rotateAround); > } > > public function init3DObjects() > { > this.sphere=new Sphere(); > this.view=new View3D({x:this.stage.stageWidth/ > 2,y:this.stage.stageHeight/2}); > this.addChild(this.view); > this.view.scene.addChild(this.sphere); > this.addEventListener(Event.ENTER_FRAME, > this.enterFrame); > } > > public function enterFrame(e:Event) { > view.render(); > } > > public function initCamera():void > { > this.camera = new HoverCamera3D(); > this.camera.distance = 1000; > this.camera.tiltangle = 45; > this.camera.targettiltangle = 50; > this.camera.maxtiltangle = 90; > this.camera.mintiltangle = -30; > this.camera.targetpanangle = 0; > this.camera.panangle=0; > this.camera.yfactor = 1; > this.camera.steps = 8; > this.camera.zoom = 7; > this.camera.position=new Number3D(0,0,1000); > this.view.camera=this.camera; > this.camera.hover(); > } > > public function rotateAround(e) > { > this.followMouse(); > this.camera.targetpanangle += dragX; > this.camera.targettiltangle += dragY; > this.camera.hover(); > } > > public function followMouse() > { > this.dragX = (stage.mouseX - this.lastMouseX); > this.dragY = (stage.mouseY - this.lastMouseY); > > this.lastMouseX = stage.mouseX; > this.lastMouseY = stage.mouseY; > } > > } > > } > > Best regards, > Anton Kulaga
