Action Enhancements

I have a use case for which I’d like to use pure actions, but I don’t see how. In this, PG (Babylon.js Playground), the behavior I want is that the avatar visibility changes when the pointer enters the plane, as long as no buttons are held, e.g. the avatar is being dragged. However, if the pointer entered the plane with buttons held, it should still capture on any movement within the plane without buttons held. There are 2 issues that make this impossible with pure actions, FWICT.

  1. This may actually be a bug, but sourceEvent is not set on the action event for pointerin triggers. In other words, if line 37 and 38 are uncommented, then the visibility will never change. It would be useful to have access to the sourceEvent so I could determine what buttons are being held.
  2. The pointer in trigger is a one shot thing. If the trigger causes the action to fire and I didn’t take action for whatever reason, the only way to get the trigger to fire again is to make the pointer exit and reenter the mesh. It would be nice to have some sort of trigger reset I could call that would tell the action manager to fire the trigger on the next movement that is within the mesh. Without that, the only way I can see to satisfy the requirements is to use a pointer observable to trigger the visibility change on pointermove, which defats the purpose of using actions.

As an aside, it would be really nice if the PredicateCondition could receive the action event so predicates could be based on the event rather than only based on things external to the action event. I find many cases where I need to include a condition in the action code versus in the predicate so I have access to the event.

1 Like

Thanks for this request. PR #13518 should give you what you need in the action’s callback.

For the trigger reset request I’ll defer to our input guru @PolygonalSun.

4 Likes

So, for the PointerOut and PointerOver triggers, they specifically are designed to work in the same fashion as “pointerout” and “pointerover” events. This is why you would have to exit and re-enter to trigger the callbacks for those triggers. If there’s a behavior that you want while inside, you might be able to create that behavior by adding some actions to your avatar object to produce the desired results.