Jump to content

How do you know you pick the correct object, if the object consists of 99 meshes?


fateriddle
 Share

Recommended Posts

I read the picking collision part of the document, https://doc.babylonjs.com/babylon101/picking_collisions

And 

//When click event is raised
window.addEventListener("click", function () {
   // We try to pick an object
   var pickResult = scene.pick(scene.pointerX, scene.pointerY);
}),

Is really helpful. But if I import a new asset ( gltf ) into my scene, it is more than likely the object consists of 20-40 meshes, then how do I know if I hit the object, even if the pickResult.hit === true?

Link to comment
Share on other sites

There Always a way to hack or bruteforce crack THE code...

IF u can code u can iterate over all meshes in THE array..

And My car object has Windows,tyres, etx in it, i also hear about getmeshbyname method i think.

And with your pickresult method u can att least console.log (picked.mesh)

So there is a way for sure..

Link to comment
Share on other sites

We are not like all popular frameworks :) We keep the forum only because then you only have one place to search (and to maintain).

So as @droggam mentioned, you can mark all meshes as pickable (and while doing that, you can use the mesh.tag to store some info for you that you could then use to determine that the picked mesh was actually part of a big group)

 

Other option: on picking, you can use pickedMesh.isDescendantOf(yourRootMesh)

Link to comment
Share on other sites

9 hours ago, Deltakosh said:

We are not like all popular frameworks :) We keep the forum only because then you only have one place to search (and to maintain).

Thanks for the answer. Sometimes it is just a quick question followed by some back and forth, and discord do help because of its format.

Right now I kinda have 10-20 questions, and I don't know how ppl here will feel if I spam them all out and occupy the whole front page. Also the longer waiting in forum is a thing.

I don't necessary think discord will be an overlay to this fantastic forum, they serve different purposes. As user, I throw / answer quick questions in discord, and sometimes just read ppl there talking about new trends or how they do things, which helps a lot.

But again I fully understand your decisions, and thanks for helping!

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