Jump to content

How to create a rectangular box?


willemmulder
 Share

Recommended Posts

When creating a box, there's the assumption that all sides are of equal length.

 

However, for a rubberband selection in an RTS I'd like to create a rectangular box on the fly (from the screen down to the ground) and then check intersections with all units on the screen to select them.

How could I create a rectangular box, or is there even a better way to do rubberband selection in BabylonJS?

Link to comment
Share on other sites

For the same approach i was just adding a layer on top of the scene node wich holds the properties and creates/updates the node based on property changes.

So always when a property like "width" changes, it does dispose the current node and adds a new one based on the new props.

Link to comment
Share on other sites

Right, so you recreate the Box everytime the 'parent' width property changes and then add the new Box to the scene. That would work... How is the performance?

 

Still it would be nicer I think if we can simply change the width on the box itself and it would update the vertices :-) is that possible somehow, or can we easily update the vertices ourselves?

Link to comment
Share on other sites

@willem it should be possible to to change the vertices, but might be troublesome, especially with complex objects. You have always the option to scale a mesh using the scaling property, did you know about that? http://www.babylonjs-playground.com/#1KJQMZ#0

 

In the first step this will just create a scaling that is not yet applied in the vertices of the mesh, but in a second step you could call bakeCurrentTransformIntoVertices to make your new scaling permanent: http://www.babylonjs-playground.com/#1KJQMZ#1

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