Mouse interaction is “off” by scale of sprites holding the View3D…(?)

Software: Away3D 4.x

Josh Strike, Newbie
Posted: 17 May 2013 04:22 PM   Total Posts: 11

Maybe this has been addressed before - if so I’d really appreciate being pointed in the right direction!

I’m trying to upgrade the StrikeSapphire game code base from Away3d 3.6 to 4.1.1 right now, which is a pretty large undertaking. The site has a custom windowing system in Flash, similar to ASWing, that lets players have more than one game window open at a time, move them and resize them. Window.content is a sprite which in this case is filled with a class that extends View3D.

What’s apparent from testing is that if a View3D in 4.x is a child of a Sprite, resizing the Sprite doesn’t scale the view (which is fine, it’s easy enough to adjust width/height on the view). However, scaling the holding Sprite does scale the mouse interaction areas. Even if the View is then resized, the holding areas are off by a proportionally greater amount. example:

...
view.width 1000;
var 
s:Sprite = new Sprite();
s.addChild(view); 
//clickable areas are lined up perfectly over objects in the view.
s.scaleX s.scaleY 1.3//or by setting width/height
//visible 3D elements stay the same size, but...
//clickable areas are now off to the right and down by 30%.
trace (view.width); //1000. Correct. We did not expect it to scale.
trace (s.width); //1300. Which is odd since the view isn't any larger.
... 

setting the width/height on the view after this does nothing to alleviate the problem; the mouse enabled areas also scale when the view is resized. So they stay 30% of the total view size off from where they’re supposed to be.

The same effect seems to happen if you hit Cmd+/Cmd- in Firefox to zoom the Flash player size. Again, it’s not a problem if the context3d doesn’t scale, but then the mouse hit areas shouldn’t be scaling either, right?

So is this a bug, or… am I missing something? It seems to make it impossible to use 4.x in a windowing-in-Flash environment or even in a browser other than as a single, full-screen game.

   

Avatar
Fabrice Closier, Administrator
Posted: 17 May 2013 07:24 PM   Total Posts: 1265   [ # 1 ]

‘So is this a bug…It seems to make it impossible to use 4.x in a windowing-in-Flash environment’
That’s how Stage3D works. Stage3D is always rendered beneath the displaylist.

   

Josh Strike, Newbie
Posted: 17 May 2013 10:50 PM   Total Posts: 11   [ # 2 ]

Okay, but shouldn’t the mouse positions still match what’s on the Stage3D? Shouldn’t the mouse bounding boxes ignore parent scaling too?
If the mouse BBs scaled only with the parent, or only with the 3d context, this wouldn’t be a problem. But because they scale with both, there’s no way to get them back once the parent is scaled. Even if you multiply the parent’s transform matrix all the way up and apply the inverse to the View3D, the mouse positions are still off.

Mouse positions ought to scale with the View, not the parent, right?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X