Jump to content

Picking a submesh


Recommended Posts

Hey ho,


another two quick (and hopefully easy) question, please have a look here:




1) I am trying to create a tiles ground with 4 submeshes.  I start with zero submeshes. I am pushing submeshes 4 times... I end up with 8 submeshes... ... ... eh? I feel like I am missing something here, please tell me what's going on. I assume the 8 submeshes are the triangles that I see in the wireframe... but why?


2) How can I pick a submesh? The scene.pick returns the clicked mesh, but how would I determine the submesh at the clicked position? (Edit: I searched and didn't find anything about picking a submesh at all, but somebody must have done that before, I think. Maybe it's too easy so nobody else ever asked :-/ )



Easy questions, right? Enlighten me please! :D

Link to comment
Share on other sites

Hi iiceman,

1) as you said, you actively push the submashes to the array. This is already done for you in the submashes constructor so you are technically pushing the same object twice. Remove your push and it's be fine :-)

2) at the current state it's not directly possible. But since you get a face id, it should be possible to calculate the sub mesh that you hit. Just make sure it's not -1 .

Link to comment
Share on other sites

I see I see, thanks for the quick answer... :)


for 1) I had the push thing from here: http://makina-corpus.com/blog/metier/2014/how-to-use-multimaterials-with-a-tiled-ground-in-babylonjs ... so I guess it just changed and this tutorial is not up to date? I am gonna try out as soon as I get home.


for 2) calculating would be okay for me... but for other, more complex meshes with submeshes it would be nice to get the picked submesh in the pickResult, too. I think about something...can't be that hard to implement... I guess :P

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.

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.


  • Recently Browsing   0 members

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