Jump to content

Canvas2D - Track a Polygon issue


Recommended Posts

Right now the tag is set to be positioned at 0,0,0 of the tracked Mesh frame of reference. If I'm not mistaken PolygonMeshBuilder generates a single Mesh. So I'm not quite sure of what you want to achieve.

You want more than one text for a given mesh? I don't really understand what you would like to have, please give me more detail.

Link to comment
Share on other sites

PolygonMeshBuilder create a new Mesh when you call the build() method. You can add a tracked group for this mesh. But if you create three separate entities with one single call to build(), you will only have one Group2D that can track them.

I hope I'm clear enough

Link to comment
Share on other sites

Sorry, maybe my english is not as good as I want it to be. Or

But if I understand well, as I create 2 PolygonMeshBuilder like this:

  var poly1 = BABYLON.Polygon.Parse("-2 0 -2 2 -4 3 -6 2 -6 0");
  var pmb1 = new BABYLON.PolygonMeshBuilder("poly1", poly1, scene).build();
  var poly2 = BABYLON.Polygon.Parse("-12 -10 -12 -8 -14 -7 -16 -8 -16 -10");
  var pmb2 = new BABYLON.PolygonMeshBuilder("poly2", poly2, scene).build();

I have two meshes (pmb1 and pmb2), so it should work. No ?

Link to comment
Share on other sites

yes it should!

sorry, I just spent "more time" at your playground and you're right it should work, I didn't understand correctly the first time I read your post, I investigate right now.

I'm in the middle of a move out to change country, I'm pretty busy right now! :)

I get back to you in few minutes.


Link to comment
Share on other sites

OK, I understood what's going on: Poly1 and Poly2 have the same World Position, so the two labels are overlapping and you only see one of them.

I've changed the position of pmb2 in this PG: http://www.babylonjs-playground.com/#1V3CAT#150

you can see the three label now.

What I think you should do: create each polygon mesh with their vertices relative to the 0,0,0 reference of frame (like you did for poly1 but not for poly2), then rely on the position property of the mesh to set the position where you want it to be.
What you did is creating poly2 with vertices at a left position but at the same world position as poly1, which is not the best way to do what you're trying to.


Link to comment
Share on other sites

It's because I have the list of polygons with the real coordinates. This is not natural for me to add this step ;).

Maybe the constructor of  PolygonMeshBuilder should include this parameter (at less as an option) if we are supposed to do like that ?


Anyway, thanks ! it works.

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