Away3d 4.1.4 Gold and Flex 4.10 on Android. Incorrect MouseEvent3D.

Software: Away3D 4.x

Fobius, Newbie
Posted: 25 December 2013 09:31 AM   Total Posts: 4

Hi all. I created a simple test app with away3d. It work nice in the web and mobile actionscript projects. But when I use the same code in flex mobile project, the coordinates of MouseEvent3D are incorrect. Bug was reproduced only on Android devices (iOS did not try yet), on AIR simulator everything is fine.
Here is video with my app.

I searched a lot but did not find the solution of this problem.

private function init(e:Event null):void {
   
   
if (eremoveEventListener(Event.ADDED_TO_STAGEinit);
   
   
_isRotationLocked true;
   
_lastMouseX 0;
   
_lastMouseY 0;
   
_lastTiltAngle 0;
   
_lastPanAngle 0;
   
   
stage.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
_camera = new Camera3D();
   
_scene = new Scene3D();
   
   
_view = new View3D();
   
_view.backgroundColor 0x000000;
   
_view.buttonMode true;
   
_view.scene _scene;
   
_view.camera _camera;
   
_view.forceMouseMove true;
   
   var 
light:DirectionalLight = new DirectionalLight(-1, -11);
   
light.color 0xFFFFFF;
   
light.ambient 0;
   
light.diffuse 1;
   
light.specular 1;
   
_scene.addChild(light);
   
   
_lightPicker = new StaticLightPicker([light]);
   
   
_cameraController = new HoverController(_camera);
   
_cameraController.distance START_CAMERA_DISTANCE;
   
_cameraController.minTiltAngle 0;
   
_cameraController.maxTiltAngle 90;
   
   
onStageResize();
   
stage.addEventListener(Event.RESIZEonStageResize);
   
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOMonStageZoom);
   
stage.addEventListener(TransformGestureEvent.GESTURE_PANonStagePan);
   
stage.addEventListener(MouseEvent.MOUSE_MOVEonMouseMove);
   
   
addChild(_view);
   
addEventListener(Event.ENTER_FRAMEonEnterFrame);
   
   
Parsers.enableAllBundled();
   
   
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEonAssetComplete);
   
   
_loader = new Loader3D();
   
_loader.addEventListener(LoaderEvent.LOAD_ERRORonLoadError);
   
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETEonLoadComplete);
   
_view.addEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
   
_view.addEventListener(MouseEvent.MOUSE_UPonMouseUp);
   
_view.renderer.antiAlias 4;
   
_view.mousePicker PickingType.RAYCAST_BEST_HIT;
   
   
_loader.loadData(BatmanAWD);
   
   
pickingPositionTracer = new Mesh( new SphereGeometry), new ColorMaterial0x00FF000.5 ) );
   
pickingPositionTracer.visible false;
   
pickingPositionTracer.mouseEnabled false;
   
pickingPositionTracer.mouseChildren false;
   
_scene.addChild(pickingPositionTracer);
  
}
  
  
private function onMouseMove(e:MouseEvent):void { 
   
if (Math.abs(_lastMouseX stage.mouseX) > 50 || Math.abs(_lastMouseY stage.mouseY) > 50lockPicker(true100);
  
}
  
  
private function onMouseDown(e:MouseEvent):void {
   _lastMouseX 
stage.mouseX;
   
_lastMouseY stage.mouseY;
   
_lastPanAngle _cameraController.panAngle;
   
_lastTiltAngle _cameraController.tiltAngle;
   
_isRotationLocked false;
   
stage.addEventListener(Event.MOUSE_LEAVEonMouseLeave);
  
}
  
  
private function onMouseUp(e:MouseEvent):void {
   _isRotationLocked 
true;
  
}
  
  
private function onMouseLeave(e:Event):void {
   _isRotationLocked 
true;
   
stage.removeEventListener(Event.MOUSE_LEAVEonMouseLeave);
  
}
  
  
private function onStageResize(e:Event null):void {
   _view
.width stage.fullScreenWidth;
   
_view.height stage.fullScreenHeight;
  
}

  
private function onLoadComplete(e:LoaderEvent):void {
   _loader
.removeEventListener(LoaderEvent.LOAD_ERRORonLoadError);
   
_loader.removeEventListener(LoaderEvent.RESOURCE_COMPLETEonLoadComplete);
   
_view.scene.addChild(_loader);
   
_loader.START_OFFSET_Y;
   
_loader.START_OFFSET_X;
   
   
_batmanBodyMesh.pickingCollider PickingColliderType.AS3_FIRST_ENCOUNTERED;
   
_batmanHeadMesh.pickingCollider PickingColliderType.AS3_FIRST_ENCOUNTERED;
   
   
_batmanBodyMesh.mouseEnabled true;
   
_batmanBodyMesh.mouseChildren true;
   
_batmanBodyMesh.shaderPickingDetails true;
   
_batmanBodyMesh.addEventListener(MouseEvent3D.CLICKonBatmanClick);
   
   
_batmanHeadMesh.mouseEnabled true;
   
_batmanHeadMesh.mouseChildren true;
   
_batmanHeadMesh.shaderPickingDetails true;
   
_batmanHeadMesh.addEventListener(MouseEvent3D.CLICKonBatmanClick);
   
   
_cameraController.tiltAngle 0;
   
_cameraController.panAngle 180;
  
}
  
  
private function onEnterFrame(e:Event):void {
   
if (!_isRotationLocked && !_isCameraLocked{
    _cameraController
.panAngle .3 * (stage.mouseX _lastMouseX) + _lastPanAngle;
    
_cameraController.tiltAngle.3 * (stage.mouseY _lastMouseY) + _lastTiltAngle;
   

   
   _lightPicker
.lights[0].rotationX _camera.rotationX;
   
_lightPicker.lights[0].rotationY _camera.rotationY;
   
_lightPicker.lights[0].rotationZ _camera.rotationZ
   
   if (
_isCameraLocked{
    trace
("rotation locked");
   
}
   _view
.render()
  
}

  
private function onAssetComplete(e:AssetEvent):void {
   
if (e.asset.assetType == AssetType.MESH{
    
switch (e.asset.name{
     
case "objBatman_skin":
      
_batmanBodyMesh e.asset as Mesh;
      
_batmanBodyMesh.material.lightPicker _lightPicker;
      break;
     case 
"objBatman_Head_Skin":
      
_batmanHeadMesh e.asset as Mesh;
      
_batmanHeadMesh.material.lightPicker _lightPicker;
      break;
    
}
   }
  }
  
  
private function onBatmanClick(e:MouseEvent3D):void {
   pickingPositionTracer
.visible true;
   
pickingPositionTracer.position e.scenePosition;
   if (!
_isPickerLocked{
    
if (e.currentTarget.material.ambientTexturee.currentTarget.material.ambientTexture null;
    else 
e.currentTarget.material.ambientTexture e.currentTarget.material.normalMap;
   
}
  } 
   

Avatar
Baks, Newbie
Posted: 12 January 2014 04:08 PM   Total Posts: 22   [ # 1 ]

Hello

Did you solved this problem? I have same .. wrong MouseEvent3D position on android.

i tested many variants:
add event to mesh on an abjectContainer3D and then detect e.target.parent .. nothing

add touchevents .. nothing

add MouseEvent3D.Click .. nothing

add MouseEvent3D.MouseDown .. nothing

:( who can give us some good trick ?

 

   

Fobius, Newbie
Posted: 12 January 2014 05:02 PM   Total Posts: 4   [ # 2 ]

Hi. No, I did not solve this. I am not sure, but think it works good on tablets and the problem reproduces on phone devices. I spent a lot of time searching, but find nothing, so I decided to rewrite project without flex. It will be faster than waiting and searching.

 

   

Avatar
Baks, Newbie
Posted: 12 January 2014 05:11 PM   Total Posts: 22   [ # 3 ]
Fobius - 12 January 2014 05:02 PM

Hi. No, I did not solve this. I am not sure, but think it works good on tablets and the problem reproduces on phone devices. I spent a lot of time searching, but find nothing, so I decided to rewrite project without flex. It will be faster than waiting and searching.

Thank you, Fobius

I tested on android tablet.. nothing. totally same problem as you described.
it seems away3d not optimized for tablets yet..

maybe some one from away3d guru have solution ?

 

 

 

   

Fobius, Newbie
Posted: 12 January 2014 05:21 PM   Total Posts: 4   [ # 4 ]

I tested on my Asus tf101 (android 4.0.2) and it works good. The problem reproduced in Samsung galaxy xcover2 and LG l7 p715 (android 4.1.2)

 

   

Fobius, Newbie
Posted: 12 January 2014 06:05 PM   Total Posts: 4   [ # 5 ]
Baks - 12 January 2014 05:11 PM

it seems away3d not optimized for tablets yet..

It works perfect without flex, on pure ActioScript mobile project.

 

   

Avatar
Baks, Newbie
Posted: 12 January 2014 06:14 PM   Total Posts: 22   [ # 6 ]
Fobius - 12 January 2014 06:05 PM
Baks - 12 January 2014 05:11 PM

it seems away3d not optimized for tablets yet..

It works perfect without flex, on pure ActioScript mobile project.

hmm. I use Flex Mobile Project. maybe this is my problem ))
I already have menus, flex logic. so, i need to wait any solution from away team for flex

 

 

   

Avatar
Baks, Newbie
Posted: 27 January 2014 11:50 AM   Total Posts: 22   [ # 7 ]

hm. I am alone with this problem .. strange

 

   

John Brookes, Moderator
Posted: 27 January 2014 01:07 PM   Total Posts: 732   [ # 8 ]

To get any help. You would need to post
a SIMPLE, CODE and ASSETS example project that shows the issue.
Then it can be run and tested.

 

   

Avatar
Baks, Newbie
Posted: 27 January 2014 04:20 PM   Total Posts: 22   [ # 9 ]
JohnBrookes - 27 January 2014 01:07 PM

To get any help. You would need to post
a SIMPLE, CODE and ASSETS example project that shows the issue.
Then it can be run and tested.

I prepared test. colored cube. when you mouse click on it then color changes

 

File Attachments
Demo1.zip  (File Size: 1659KB - Downloads: 329)
   

Avatar
Baks, Newbie
Posted: 27 January 2014 04:21 PM   Total Posts: 22   [ # 10 ]

please test

 

   

John Brookes, Moderator
Posted: 27 January 2014 06:22 PM   Total Posts: 732   [ # 11 ]

try a .zip file. For some reason forums not working with rar

 

   

Avatar
Baks, Newbie
Posted: 27 January 2014 10:04 PM   Total Posts: 22   [ # 12 ]

i updated post with archive

 

   

John Brookes, Moderator
Posted: 28 January 2014 01:16 PM   Total Posts: 732   [ # 13 ]

Ok found the reason.
In your Main.mxml you have

applicationDPI=“160”

As I undertsand that will scale your flex stuff (never really used flex much)
So mouse events will have a different mouse position than what the view expects.
The view is working non scaled. Thats why you can click certain place on screen and the event fires.

As for the fix. Again im not a flex guy, but im guessing you could add the view to a non DPI scaled flex doodah thang. wink
Something like that smile

 

   

Avatar
Baks, Newbie
Posted: 29 January 2014 06:13 PM   Total Posts: 22   [ # 14 ]

Hi, John

It’s very good news! really hidden bug smile
I removed applicationDPI=“160” and now all is fine

Thank’s you very much wink

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X