Jump to content

How to set trackNode of a Rectangle2D?


MacSkelly
 Share

Recommended Posts

I want to create a kind of tool tip for my scene. What I basically did was create a Rectangle2D shape and set isVisible to false. When I click on a mesh I want the Rectangle to become visible and to track the mesh that was clicked on. I tried just setting rectangle.trackNode = mesh but it doesn't seem to work. Is there a way to do this? Does the property have a different name like with isVisible and levelVisible?

I basically want to create something similar to this demo:

http://babylonjs-playground.com/#1N9RJY#5

But to have it in such a way that the rectangles only appear when the corresponding mesh has been clicked on.

Link to comment
Share on other sites

Hi @MacSkelly.  First, the property is named trackedNode.  Maybe that was the problem?

Also of interest...  the .trackedNode property is on Group2D objects.  Does it exist on Rectangle2D objects?  I'm showing it as undefined. 

On group2D-class objects, it is showing NULL, by default.  (yay, at least it exists)  :)

http://babylonjs-playground.com/#DEFP2#4

Watch your console... some reports are sent there.  This is a modification of a Nockawa demo.  Lines 49-64 are the fun parts. The node-tracking seems to be working on group2D containers (g1 is a group2D-class item). 

This should get you rolling.  Holler if you have more issues.  And if you ask me why the .trackedNode is named "mesh" instead of "box" (see console messages)... I will have to reply with a delicious "I dunno".  :)  Perhaps "mesh" is a clone or instance of "box"... created by the Canvas2D author.

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