away3d / away3d-core-fp11

Away3D engine for Flash Player 11
http://www.away3d.com
Other
640 stars 273 forks source link

About MouseEvent3D and mouseChildren property behavior #639

Open SharpEdgeMarshall opened 11 years ago

SharpEdgeMarshall commented 11 years ago

tl;dr: The target property of a MouseEvent3D should always point to the first ObjectContainer3D found that have mouseChildren=false in the capture phase.

From AS3 documentation on mouseChildren property:

"...This property is useful when you create a button with an instance of the Sprite class (instead of using the SimpleButton class). When you use a Sprite instance to create a button, you can choose to decorate the button by using the addChild() method to add additional Sprite instances. This process can cause unexpected behavior with mouse events because the Sprite instances you add as children can become the target object of a mouse event when you expect the parent instance to be the target object. To ensure that the parent instance serves as the target objects for mouse events, you can set the mouseChildren property of the parent instance to false..."

That's how it works in Stage and i think it should work the same way in Stage3D ( the properties have the same name and we can say ObjectContainer3D is a sort of Sprite)

So i'm expecting to use this property i.e. when i have an ObjectContainer3D that groups multiple children and i want to make it look like the events are dispatched from the ObjectContainer3D and not from the children of it.

EDIT: I think that should be changed "isIgnored(entity:Entity)" function (line 162) in RaycastPicker Class and not ignore entities that have _ancestorAllorMouseEnabled = false, later Mouse3DManager is already checking for _ancestorsAllowMouseEnabled and using parent if false( Line 137).

TESTED and working

FROM:
if (_onlyMouseEnabled && (!entity._ancestorsAllowMouseEnabled || !entity.mouseEnabled))

TO:
if (_onlyMouseEnabled && !entity.mouseEnabled)

Also Mouse3DManager needs a change at line 141 inside fireMouseEvents() function:

FROM:
for (i = 0; i < len; ++i) {
                // Only dispatch from first implicitly enabled object ( one that is not a child of a mouseChildren = false hierarchy ).
                event = _queuedEvents[i];
                dispatcher = event.object;

                while (dispatcher && !dispatcher._ancestorsAllowMouseEnabled)
                    dispatcher = dispatcher.parent;

                if (dispatcher)
                    dispatcher.dispatchEvent(event);
            }

TO:

for (i = 0; i < len; ++i) {
                // Only dispatch from first implicitly enabled object ( one that is not a child of a mouseChildren = false hierarchy ).
                event = _queuedEvents[i];
                dispatcher = event.object;

                while (dispatcher && !dispatcher._ancestorsAllowMouseEnabled)
                 {
                    dispatcher = dispatcher.parent;
                    event.object = dispatcher;
                 } 

                if (dispatcher)
                    dispatcher.dispatchEvent(event);
            }

I hope it's clear what i mean.

SharpEdgeMarshall commented 10 years ago

Guys what's happening to Away3D? I'm a big fan and i'm trying to support the project but it seems dead! Why no one follow the Issues?