Jump to content

Imported meshes can't be picked deterministically


Rodrico
 Share

Recommended Posts

Hello folks.

First of all sorry for duplicating this as I've already asked for same thing on StackOverflow but I've seen really strong audience in other posts on this forum so I'll do so. :)

I've got grid of cylinder meshes created simply by

var tile = BABYLON.MeshBuilder.CreateCylinder("tile-" + i, { tessellation: 6, height: 0.1 }, scene);

then I have following event callback

    window.addEventListener("click", function (evt) {
        // try to pick an object
        var pickResult = scene.pick(evt.clientX, evt.clientY);
        if (pickResult.pickedMesh != null){
             alert(pickResult.pickedMesh.name)
    });

Then `mouse-click` on one of `tiles` raises `message box` with correct tile name.

When I add some new meshes (3D model inside `.babylon` file) by

 var house;
    BABYLON.SceneLoader.ImportMesh("", "../Content/"
                                  , "house.babylon"
                                  , scene
                                  , function (newMeshes) 
                                    { house = newMeshes[0]; });


For better imagination it's texture of house created from four different meshes which is placed over `grid` of `cylinder` tiles.

It's displayed fine but when `mouse-click` it too much often behave as it would totally ignore there is such a mesh and so `pickResult.pickedMesh` is either `null` or `pickResult.pickedMesh.name` points to tile underlaying my imported mesh in point I've clicked.

Just approximately `5%` of mesh area corresponds properly to `mouse-clicks` (let's say in middle of roof, in middle of walls).

I've tried playing with setting some virtual (hidden) `house.parent` `mesh` for that which would not be created by importing meshes but seems as dead end.

Are you aware about some way how enforce that `scene.pick(evt.clientX, evt.clientY);` would respect mesh hierarchy and would consider all visible parts of overlaying texture please?

Just for completeness I'm working with middle part of this 3D model (removed left and right house from that).

Thanks in advance.

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