Multiple MouseEvent3D = SLOOOW

Software: Away3D 4.x

Lucid, Member
Posted: 27 March 2012 02:13 PM   Total Posts: 93

I am building a mobile application for iOS and Android. In this project I’m adding several spheres (meshes) to the view and, for each mesh, adding a MouseEvent3D event listener. The only reason I’m adding the listener to each mesh to get the get the name of the mesh selected. All of this works fine but I’ve noticed a substantial reduction in performance when each of the meshes has individual MouseEvent3D listeners attached to it. Is there a way to add a single listener, say to the View (3D), to return the child (target) name that was clicked on?

Currently I’ve got a vector types to Mesh:
internal var mesh:Vector.<Mesh> = new Vector.<Mesh>;

and for each mesh, I have to currently add individual MouseEvent3D listeners, like this:
mesh.mouseEnabled=true;    mesh.addEventListener(MouseEvent3D.DOUBLE_CLICK,itemDouble);

Is there a way to add a single event listener (instead of multiple) that would let me simply get the name of the child clicked on?

Thoughts?

   

Lucid, Member
Posted: 27 March 2012 02:26 PM   Total Posts: 93   [ # 1 ]

Currently, if I set:
view.mouseEnabled=true; // also tried false
view.mouseChildren=true;
view.addEventListener(MouseEvent.MOUSE_DOWN,viewDown)

when I trace(event.target)
all I get is: [object Sprite]
regardless of whether I click on 3D object (mesh) in the view or not.

I’ve tried setting each mesh mouseEnabled=true as well.

How do I get the name of individual children in the view/scene without having to apply individual MouseEvent3D listeners to every object in the scene?

   

Mr Margaret Scratcher, Sr. Member
Posted: 27 March 2012 02:31 PM   Total Posts: 344   [ # 2 ]

I’ve also wanted to do this as well, have you tried

trace (e.target.name) ?

thats’s if you;ve given it a name, I find it a bit hard to get my head around the fact that

var test:MovieClip = new MovieClip is not necessarily called “test”

other than that you could set an .extra.name for each of the spheres and

trace (e.target.extra.name)

   

Lucid, Member
Posted: 27 March 2012 02:42 PM   Total Posts: 93   [ # 3 ]

I’ll begin conducting more tests based on your suggestions.

However, adding the .extra.name parameter to a mesh yields an error:

mesh.extra.name = String(mesh);
or
mesh.extra.name = “test”

both yield errors.

   

Lucid, Member
Posted: 27 March 2012 02:47 PM   Total Posts: 93   [ # 4 ]

When I add an event listener to the view:
view.mouseEnabled=true; // also tried false
view.mouseChildren=true;
view.addEventListener(MouseEvent.MOUSE_DOWN,viewDown)

and then trace(event.target.name) from the listener function (viewDown), I always get the string ‘instance19’ in the debugging window, regardless of whether I click on an object (mesh) or not.

   

Avatar
Fabrice Closier, Administrator
Posted: 27 March 2012 03:37 PM   Total Posts: 1265   [ # 5 ]

Depending on your application and also the shape of your mesh, you may want to consider to set the mesh.mouseHitMethod.
mesh.mouseHitMethod = MouseHitMethod.BOUNDS_ONLY;

As the name says, it doesn’t traverse and hittest the geometry.
It fires the event if the bounding box is hitted, which is very often enough.
A speed vs precision story…

I have seen quite significant fps changes in few cases.

   

Lucid, Member
Posted: 27 March 2012 03:51 PM   Total Posts: 93   [ # 6 ]

@ Fabrice

Yes, that did it! Huge performance jump!

Thanks again Fabrice. You’ve provided the answer to yet another of my puzzles. Incredible.

   

Ontheronix, Jr. Member
Posted: 29 March 2012 06:22 PM   Total Posts: 37   [ # 7 ]

Some more information in the docs of the MouseHitMethod would come in handy smile (There is none at the moment)

   

jeffrey9700, Newbie
Posted: 29 March 2012 08:47 PM   Total Posts: 14   [ # 8 ]

Do you have the application running on an ipad2 with the MouseEvent3D working?

   

Avatar
Fabrice Closier, Administrator
Posted: 29 March 2012 09:13 PM   Total Posts: 1265   [ # 9 ]

News from the Away3D garage: An issue on IOS regarding the pb errors (ME3D) has been reproduced and fixed, and is (or will be very soon pushed to dev branch)

   

jeffrey9700, Newbie
Posted: 29 March 2012 09:17 PM   Total Posts: 14   [ # 10 ]

great, thanks!

   

GEUNWOO JANG, Newbie
Posted: 24 April 2012 01:26 AM   Total Posts: 3   [ # 11 ]

iOS will receive the following error.

“The depthAndStencil flag in the application descriptor must match the enableDepthAndStencil Boolean passed to configureBackBuffer on the Context3D object.”

code line
away3d.core.managers.Stage3DProxy
private function onContext3DUpdate (event: Event): void
_context3D.configureBackBuffer (_backBufferWidth, _backBufferHeight, _antiAlias, _enableDepthAndStencil);

_enableDepthAndStencil does not match the Boolean value.
When you assign a value to false to force the action.
Why is it so?

In addition, MouseEvent3D from any of the iOS support possible?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X