MouseEvent3D on Mobile broken with Stage3DProxy (i.e. Starling)

Software: Away3D 4.x

Logrey, Newbie
Posted: 14 June 2013 12:42 PM   Total Posts: 12

This is a refiend post from an earlier one, with more info:
http://away3d.com/forum/viewthread/4597/

Basically, when using Stage3DProxy (needed when integrating Starling), the MouseEvent3D system acts incorrectly on mobile (iOS/Android). MouseEvent3D’s don’t seem to fire on the first click. Instead, they require 2 clicks - the first to “get focus”, it seems. And the second to call the event. If you click back-and-forth between objects, it appears to do nothing - you need to click one object at least 2 successive times.

I’m attaching the simple code below (first the broken version, with Stage3DProxy and then a working version without). Thanks for any thoughts or suggestions!

// Stage3D Proxy - incorrect on mobile

package {
 import flash
.display.Sprite;
 
import flash.display.StageAlign;
 
import flash.display.StageScaleMode;
 
import flash.events.Event;
 
import flash.geom.Vector3D;
 
 
import away3d.containers.View3D;
 
import away3d.core.managers.Stage3DManager;
 
import away3d.core.managers.Stage3DProxy;
 
import away3d.entities.Mesh;
 
import away3d.events.MouseEvent3D;
 
import away3d.events.Stage3DEvent;
 
import away3d.materials.ColorMaterial;
 
import away3d.primitives.CubeGeometry;
 
 
[SWF(width=320,height=480,frameRate=60)]
 
public class JunkProject extends Sprite {

  
private var view:View3D;
  
  private var 
stage3DManager Stage3DManager;
  private var 
stage3DProxy Stage3DProxy;
  
  public function 
JunkProject()
  
{
   super
();
   
   
// support autoOrients
   
stage.align StageAlign.TOP_LEFT;
   
stage.scaleMode StageScaleMode.NO_SCALE;
   
   
stage3DManager Stage3DManager.getInstance(stage);
   
   
// Create a new Stage3D proxy to contain the separate views
   
stage3DProxy stage3DManager.getFreeStage3DProxy();
   
stage3DProxy.configureBackBuffer(stage.fullScreenWidth,stage.fullScreenHeight,2,true);
   
stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATEDonContextCreated);
   
stage3DProxy.color 0x0;
  
}
  
  
protected function onContextCreated(Stage3DEvent:Event):void {
   view 
= new View3D();
   
view.stage3DProxy stage3DProxy;
   
view.shareContext true;
   
addChild(view);
   
   
view.camera.position = new Vector3D(0,700,0);
   
view.camera.lookAt(new Vector3D());
   
   
// cube 1
   
var colorMaterial1:ColorMaterial = new ColorMaterial(0x0000FF);
   var 
cube1:Mesh = new Mesh (new CubeGeometry(100,100,100), colorMaterial1);
   
cube1.position = new Vector3D(0,0,0);
   
cube1.mouseEnabled true;
   
cube1.addEventListenerMouseEvent3D.CLICKonCubeClick );
   
view.scene.addChild(cube1);
   
   
// cube 2
   
var colorMaterial2:ColorMaterial = new ColorMaterial(0x00FF00);
   var 
cube2:Mesh = new Mesh (new CubeGeometry(100,100,100),colorMaterial2);
   
cube2.position = new Vector3D(150,0,0);
   
view.scene.addChild(cube2);
   
cube2.mouseEnabled true;
   
cube2.addEventListenerMouseEvent3D.CLICKonCubeClick );
   
   
   
addEventListener(Event.ENTER_FRAMEgameLoop);
  
}  
  
  
protected function gameLoop(e:Event):void {
   stage3DProxy
.clear();
   
   
view.render();
   
   
stage3DProxy.present();
  
}
  
  
private function onCubeClick(e:MouseEvent3D):void {
   Mesh
(e.target).rotationX += 20;
  
}
 }


// Without Stage3D Proxy - correct on mobile

package {
 import flash
.display.Sprite;
 
import flash.display.StageAlign;
 
import flash.display.StageScaleMode;
 
import flash.events.Event;
 
import flash.geom.Vector3D;
 
 
import away3d.containers.View3D;
 
import away3d.entities.Mesh;
 
import away3d.events.MouseEvent3D;
 
import away3d.materials.ColorMaterial;
 
import away3d.primitives.CubeGeometry;
 
 
[SWF(width=320,height=480,frameRate=60)]
 
public class JunkProject extends Sprite {

  
private var view:View3D;
  
  public function 
JunkProject()
  
{
   super
();
   
   
// support autoOrients
   
stage.align StageAlign.TOP_LEFT;
   
stage.scaleMode StageScaleMode.NO_SCALE;
   
   
init();
  
}
  
  
protected function init():void {
   view 
= new View3D();
   
addChild(view);
   
   
view.camera.position = new Vector3D(0,700,0);
   
view.camera.lookAt(new Vector3D());
   
   
// cube 1
   
var colorMaterial1:ColorMaterial = new ColorMaterial(0x0000FF);
   var 
cube1:Mesh = new Mesh (new CubeGeometry(100,100,100), colorMaterial1);
   
cube1.position = new Vector3D(0,0,0);
   
cube1.mouseEnabled true;
   
cube1.addEventListenerMouseEvent3D.CLICKonCubeClick );
   
view.scene.addChild(cube1);
   
   
// cube 2
   
var colorMaterial2:ColorMaterial = new ColorMaterial(0x00FF00);
   var 
cube2:Mesh = new Mesh (new CubeGeometry(100,100,100),colorMaterial2);
   
cube2.position = new Vector3D(150,0,0);
   
view.scene.addChild(cube2);
   
cube2.mouseEnabled true;
   
cube2.addEventListenerMouseEvent3D.CLICKonCubeClick );
   
   
   
addEventListener(Event.ENTER_FRAMEgameLoop);
  
}  
  
  
protected function gameLoop(e:Event):void {
   view
.render();
  
}
  
  
private function onCubeClick(e:MouseEvent3D):void {
   Mesh
(e.target).rotationX += 20;
  
}
 }
   

Logrey, Newbie
Posted: 14 June 2013 01:02 PM   Total Posts: 12   [ # 1 ]

Update:

I was using the new 4.1.1 Beta, and it fails.

I just reverted to: 4.0.11 Gold (which was part of the Adobe Gaming SDK), and it now fires the first time, as expected.

   

Avatar
loth, Sr. Member
Posted: 16 June 2013 07:34 AM   Total Posts: 236   [ # 2 ]

i have no probleme maybe try add this
mesh.pickingCollider = PickingColliderType.AS3_FIRST_ENCOUNTERED;
mesh.mouseEnabled = mesh.mouseChildren = mesh.shaderPickingDetails = true;

   

Matej, Jr. Member
Posted: 17 June 2013 11:14 AM   Total Posts: 38   [ # 3 ]

I tried your changes and it didnt work for me

   

keulu, Newbie
Posted: 08 August 2013 09:58 AM   Total Posts: 1   [ # 4 ]
Logrey - 14 June 2013 01:02 PM

Update:

I was using the new 4.1.1 Beta, and it fails.

I just reverted to: 4.0.11 Gold (which was part of the Adobe Gaming SDK), and it now fires the first time, as expected.

 

I had the same probleme than you.

With away 4.0.9 and starling 1.3 on air mobile, if a run my app on desktop, no problem but on ipad, lots of bugs appear.

as you, just put 2 mesh (1 plane for the ground and 1 cube)

when i clic the first time on the cube, Events fire me the mouseDown and the mouseUp without troubles

but…

when a clic on the ground after the cube, it just fire me a mouse down on the cube.

I just downloaded the away 4.0.11, and the problem seems to be resolved.


i hope that problem stay fixed with all the next release

   

John Brookes, Moderator
Posted: 08 August 2013 11:02 AM   Total Posts: 732   [ # 5 ]

This should now be fixed in 4.1.4 (both the Dev and Master branch of Away3D).

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X