fateriddle

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

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?

Share this post


Link to post
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..

Share this post


Link to post
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)

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.