Jump to content

Action triggered even if other mesh was clicked


Kesshi
 Share

Recommended Posts

In this playground: http://www.babylonjs-playground.com/#1XJSAN
there is a red and a white box. The red box has a click action attached to it.
The problem is that the action is triggered even if i click on the white box.
In line 33 i enabled "constantlyUpdateMeshUnderPointer" because i was thinking this is the solution but it doesn't help.
Is there something else i need to do?
The strange thing is that the mouse cursor is not changing when the mouse is over the white box ... so for the cursor the handling is correct.

One more question. Is it possible to define which cursor is shown for a mesh? Lets say the move or resize cursor.
 

Link to comment
Share on other sites

@Deltakosh  This is a nice addition, but...

On 2/26/2016 at 9:15 AM, Kesshi said:

I wouldn't call this a solution. Its a workaround. :)
I would need to attach an Action to every mesh in my scene .. and i have a lot.
So this is not an option. :)

...he doesn't want to use any actionManagers, if I understand him correctly.  Or maybe ONLY a single scene.actionManager.  He needs something more like http://playground.babylonjs.com/?11

Maybe.  :)  (is ?11 working at all?  hmm.)

Link to comment
Share on other sites

2 hours ago, Deltakosh said:

This is a really good question.

I added a way for you to define the predicate used to select meshes when picking:

http://www.babylonjs-playground.com/#1XJSAN#4

Thank you. I think this should help me. :)
What about my second question:
Is it possible to define which cursor is shown for a mesh? Lets say the move or resize cursor.

Link to comment
Share on other sites

But if he has 4000 pickable mesh, he needs an AM on each one, right?

Hi again, K.  Are you cool with having an AM on each pickable mesh?  Sounds like you are.  I must have misunderstood.  Or maybe you have no other choice.  :)

You would have preferred to avoid that, right?

Link to comment
Share on other sites

@Wingnut

sat = true

guru = teacher

satguru = the one and only true teacher  - I am the man !! :P

Ok, something weird here

http://www.babylonjs-playground.com/#1XJSAN#6

i changed your

"tActionBox.isPickable = false;" to "tActionBox.isPickable = true;"

and now both tCube and tActionBox send out alert on being clicked/

 

Link to comment
Share on other sites

@satguru please have a look at the version from deltacosh again: http://www.babylonjs-playground.com/#1XJSAN#4

the important part is at line 33 - 39.
With this new predicates you can create your own rules to define which mesh should be picked and which not.
The problem in my initial version was that the white box wasn't picked (it was ignored because it had no action), therefore only the red box was picked.
If you change the predicate to "return mesh.isPickable;" it means all meshes which have "isPickable == true" will be considered in the picking.
No other condotion need to be fulfilled. (like if there is an action or not)
You could also just change it to "return true" to pick every mesh without any condition.
 

Link to comment
Share on other sites

I think the way the triggers are named, creates some confusion

Instead of onPickUpTrigger, onPickDownTrigger maybe they should be called onPointerUpTtrigger, onPointerDownTrigger

Picking and  Pointer events are two different things

Picking helps in determining if the pointer can be considered as being on top of a mesh and thus 
1. if  the cursor should change to a hand cursor and
2. if pointer events should lead to some actions

@Kesshi, In your first example, and like you pointed out,  there is inconsistency in the behavior of the  cursor and the action.

The cursor does not change to hand when it is  on the white box- which means the system thinks that the cursor is  on top of white box and not the red box  (or put another way - white box is pickable and the picking system picks that as it is in front of the red box)

The action behaves differently
The action takes place when the cursor is on the white box  and the pointer is clicked - which means, for action, the system thinks that the cursor is on the red box  (or put another way - white box is not pickable and the picking system ignores the white box even though it is in front of the red box and picks the red box instead)

I like the idea of predicate but I wonder if it  should be at the action level rather than at the scene level.
 

Link to comment
Share on other sites

ok i have questions about action manager

1. why we need have actionManager system  when we have picking system.

2. dos it have any benefits ?(picking is not have that?)

3. if it good and useful for all system why we need picking too. 

4. and last question is that why actionManager not use picking system.

 

for example if we have just picking system in base and have actionManager use that picking system  we  solved problem(first problem in this post) 

box1.registerActionManager(...);

box2.isPickable = true;

so box1 don't answer when box1 is fired pick but is not happen now

http://www.babylonjs-playground.com/#1XJSAN#13

Link to comment
Share on other sites

@NasimiAsl

actionManager does more than picking for example  OnIntersectionEnterTrigger , OnIntersectionExitTrigger , OnKeyDownTrigger , OnKeyUpTrigger

"isPickable" is ignored if you use your own predicate

for example here

 

var myPickableTest =  function (mesh) { return mesh == ground; };

var pickinfo = scene.pick(scene.pointerX, scene.pointerY,myPickableTest );

Here we ignore "isPickable" and only pick if the mesh is ground.

 

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...