Jump to content

Canvas2D, actionManager on mobile


Virtuell
 Share

Recommended Posts

I'm trying to use canvas2d on mobile. As buttons I use the a rectangle with an actionManager as in this example taken from the canvas2d tutorial. 

http://www.babylonjs-playground.com/#1onkpj#5

However the BABYLON.ActionManager.OnPickTrigger only works occasionaly on mobile and is very unresponsive.

I noticed that the mobile "pointer" is moved to the correct position making it possible to use the OnPointerOverTrigger to trigger the button, but for the computer browser I use the OnPointerOverTrigger for a color transition on the button.

Does anyone have a suggestion for a universal solution for both mobile and computer browsers?

 

Link to comment
Share on other sites

@Nockawa Do you have any suggestions to point me in the right direction for this issue?

I am fairly sure it's a bug in the framework, but for me it's a bit intimidating to attempt to solve it.

For now I am thinking of working around the problem using collision meshes tied to the camera at the position of my buttons and then using OnPickTrigger on the mesh instead.

Link to comment
Share on other sites

@Virtuell why you don't use the pointerEventObservable like it's done on this PG: http://babylonjs-playground.com/#UVDG0#67 I just tested it on tablet and it seems more reliable. Let me know.

For your information the action manager is supported for compatibility reason but the pointerEventObservable is more complete/accurate.

 

Link to comment
Share on other sites

@NockawaThank you!

I tested and researched pointerEventObservable and it seems be feature complete and work as intended :) I'll redo my code to use the pointerEvent instead.

I have been working with Babylon and canvas2d for about a  month and from the documentation the actionmanager seemed to be the way to go, had no idea that it was legacy stuff.

Link to comment
Share on other sites

37 minutes ago, Virtuell said:

@NockawaThank you!

I tested and researched pointerEventObservable and it seems be feature complete and work as intended :) I'll redo my code to use the pointerEvent instead.

I have been working with Babylon and canvas2d for about a  month and from the documentation the actionmanager seemed to be the way to go, had no idea that it was legacy stuff.

Well, "Legacy" may not be the best term I should have used. The ActionManager is a feature made in the scope of a 3D Engine and it's great in this scope. 

Canvas2D was built to serve as a foundation for a GUI Library so the pointerEventObservable was designed accordingly and the requirements are pretty wide.

Then I worked on exposing the ActionManager also for Canvas2D, but as the ActionManager was not design for 2D stuffs, things are more complex to handle (for me).

I'll keep the Trello Card about the bug on mobile but it's no longer a priority to fix. I'll give it another try when I'll be better at debugging on mobile/tablet! :)

Link to comment
Share on other sites

@Nockawa

I got it working using the pointerEventObservable :) It was less code for the same behaviour compared to the actionManager so that's nice.

I did however find that the BABYLON.PrimitivePointerInfo.PointerDown event doesn't work as intended on mobile, I had to use PointerUp to get expected behaviour.
For PointerDown the event seems to register when pressing the Prim2dBase object but isn't triggered correctly until a second press somewhere else.

 

Link to comment
Share on other sites

10 hours ago, Virtuell said:

@Nockawa

I got it working using the pointerEventObservable :) It was less code for the same behaviour compared to the actionManager so that's nice.

I did however find that the BABYLON.PrimitivePointerInfo.PointerDown event doesn't work as intended on mobile, I had to use PointerUp to get expected behaviour.
For PointerDown the event seems to register when pressing the Prim2dBase object but isn't triggered correctly until a second press somewhere else.

 

I take a look right away on this, I've realized that I have a laptop with touch, it should be easier than a tablet to test/debug! :)

Link to comment
Share on other sites

@Virtuell ok I think the bug is fixed, I was indeed firing the event on the wrong primitive sometimes which lead to the behavior you noticed.

if you get the latest sources or wait for a PG update or the next preview build, it should be ok.

Edit: the ActionManager bug "may" have been also fixed at the same time. I wait for a PG update to check for it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...