Jump to content

PickedMesh


Adem
 Share

Recommended Posts

I put some mesh into my imported 3D scene, i tried to register a pick function on the mesh but it's not working.

newScene.onPointerDown = function (evt, pr) { 
var width = newScene.getEngine().getRenderWidth(); 
var height = newScene.getEngine().getRenderHeight(); 
var pickInfo = newScene.pick(width / 2, height / 2);
 if (pickInfo.hit) {
pickInfo.pickedMesh.dispose(); 

};

Link to comment
Share on other sites

I have two ideas what might be wrong:

1)

You code always picks the center of the scene, is that intended?
I mean, you do not reference the pointer position.

2)

Also is your mesh pickable?
mesh.isPickable = true;
If it's not it gets ignored.

 

Here is a playground that uses your pick code, that picks the sphere and disposes it.

http://babylonjs-playground.com/#1YFKMO#0

 

But there is something weird going on here, because disposing the sphere in the click event also removes the ground from the scene.
This seems to me like a bug. Maybe @Deltakosh can have a look, at this.
If you replace the dispose with anything else, for example "pickInfo.pickedMesh.visibility -= 0.1" only the sphere is affected. So the picking works, but dispose called from a pointer event does something strange.

 

Link to comment
Share on other sites

One more question about meshes picking.

I can get one mesh (top one) under cursor using the method: var pickResult = scene.pick............

But how can I get a list of meshes under a cursor position? I mean all meshes under a cursor position.

Link to comment
Share on other sites

17 minutes ago, iTekVR said:

One more question about meshes picking.

I can get one mesh (top one) under cursor using the method: var pickResult = scene.pick............

But how can I get a list of meshes under a cursor position? I mean all meshes under a cursor position.

I found the solution: scene.multiPick

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