willemmulder Posted January 5, 2016 Share Posted January 5, 2016 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? Quote Link to comment Share on other sites More sharing options...
jerome Posted January 5, 2016 Share Posted January 5, 2016 http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box Temechon 1 Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 5, 2016 Author Share Posted January 5, 2016 Ah, thanks! I was looking here http://doc.babylonjs.com/classes/2.1/Mesh which gives different results... Is that an 'error' in the documentation, or are they different functions? Is using such a box to achieve rubber band selection the good way to go, or is there a faster and/or easier way? Quote Link to comment Share on other sites More sharing options...
jerome Posted January 5, 2016 Share Posted January 5, 2016 as for v2.2, the new MeshBuilder class has been added, with many new parameters for each basic shapes. Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 5, 2016 Author Share Posted January 5, 2016 Excellent, thanks! It might be a good idea to update the docs at https://github.com/BabylonJS/Babylon.js/wiki/02-Basic-elements to reflect that. Once I have some more experience with Babylon and I know what to use how and when, I'd make a suggestion as a pull request, but right now I'm not comfortable enough :-) Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 5, 2016 Author Share Posted January 5, 2016 Small additional question: once I have the mesh, how could I update the width, height or depth afterwards? Quote Link to comment Share on other sites More sharing options...
hen Posted January 5, 2016 Share Posted January 5, 2016 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. Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 5, 2016 Author Share Posted January 5, 2016 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? Quote Link to comment Share on other sites More sharing options...
hen Posted January 5, 2016 Share Posted January 5, 2016 Performance is really fast... im doing this in realtime within a persistant MMO editor like shown below.I think there is no property to modify the box itself like that, at least i did not found any.. Quote Link to comment Share on other sites More sharing options...
willemmulder Posted January 5, 2016 Author Share Posted January 5, 2016 All right, thanks, then I'll try to recreate the box at first, and if performance becomes an issue, change that to modify the raw vertices, if that is even possible at all... Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 6, 2016 Share Posted January 6, 2016 @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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.