Jump to content

Actions vs Observables question.


Zephos
 Share

Recommended Posts

Hi all,

So I am currently using an observer to detect the user picking a mesh and I use that to make the camera look at the mesh. Now, I also want to highlight the mesh when the user hovers over it, but it looks like the only way that is supported to do that is with actions.

That lead me to wondering why there are two seemingly separate paradigms for this kind of thing. I found the explanation given here a bit vague: https://doc.babylonjs.com/features/events

Mainly I just want to know how to compartmentalize the two systems so I can easily choose between them based on the circumstances. If possible, I would like to stick to just one paradigm to not muddle my code with various ways of doing the same thing.

I think I should be able to implement the highlighting behavior with either one, as long as the POINTERMOVE event type has a pickResult (not sure if it does).

Are there any obvious reasons to chose one method over the other? How should I be thinking about these features in relation to each other?

Thanks

 

Link to comment
Share on other sites

Quote

Now, I also want to highlight the mesh when the user hovers over it

You can also use observables (onPointerObservable) which come with pickresult.

 

Both paradigms are equivalent and really depend on your coding style 

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