Hello, everybody! I have a really confusing problem with light position. I have a HoverCamera3D and DirectionalLight3D on stage and I am trying to move light source with the camera.
After spending tons of the time I have founded really weird solution light.moveTo(camera.x,-camera.z,-camera.y); (z and y are messed and with - sign). Results are exactly what I am looking for http://files.rightinpoint.com/tailor_65s6d562/messed_axises/tailor2.html When I try more logical solution, like light.moveTo(camera.x,camera.y,camera.z); I got weird results like http://files.rightinpoint.com/tailor_65s6d562/correct_axises/tailor2.html Full code function initListeners():void { addEventListener( Event.ENTER_FRAME, onEnterFrame ); stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); } /** * Navigation and render loop */ function onEnterFrame(event:Event):void { view.camera.moveTo(obj.x,obj.y,obj.z); view.camera.rotationY=mouseX/2; view.camera.rotationX=mouseY/2; view.camera.moveBackward(5); if (move) { camera.targetpanangle = 0.3*(stage.mouseX - lastMouseX) + lastPanAngle; camera.targettiltangle = 0.3*(stage.mouseY - lastMouseY) + lastTiltAngle; } camera.hover(); light.moveTo(camera.x,-camera.z,-camera.y); trace(""); trace("X:"+camera.x); trace("y:"+camera.y); trace("z:"+camera.z); view.render(); } /** * Mouse down listener for navigation */ function onMouseDown(event:MouseEvent):void { lastPanAngle = camera.targetpanangle; lastTiltAngle = camera.targettiltangle; lastMouseX = stage.mouseX; lastMouseY = stage.mouseY; move = true; stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave); } /** * Mouse up listener for navigation */ function onMouseUp(event:MouseEvent):void { move = false; stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave); } /** * Mouse stage leave listener for navigation */ function onStageMouseLeave(event:Event):void { move = false; stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave); } }
