Hi Guys, I’m new to babylon, so please be gentle. I am interested in creating a function that I can draw a floorplan by picking points on the ground with lines. Like this…
Hopefully, the gif above renders properly. If not, use this link Wall Sample
I know there is a walls playground in the docs. that is clear. What I am unsure about is how to do this by picking the points and seeing it render as you click the points. Is there another playground similar to what I am looking for?
This is more of a software architecture questions than babylon question but you can do any number of things. If you’re just making a box then just get the position where mouse went down on your 2d plane and then adjust the vertices of the box as the cursor position changes (using setVerticesData)
i started a playground, but was not successful in getting any line to render. my goal with this playground was to click 3 points in space and have 2 lines rendered
I did not do it all but got the lines drawing at least for you
Keep in mind scope for things like options and vector. you were defining them inside the callback. That would be a new array of points every time, had the rest worked. Aside from that, you need to use scene.pick with those mouse positions you had
I could use a little help again. I made some changes. My goal is to have a stringer that follows the mouse hover until you click and set the final point. I believe I’m close, however, its adding quite a bit of lines. How can I access the “lines” to remove them in a similar fashion than I am in the vertices. Here’s my latest playground
This works once like desired but then stops showing new points added. If you add options.instance = lines between lines 48 and 49 like I suspect should be done, never works at all.
@br-matt I finally got this routine added to a button so that I can draw lines. The problem I am encountering now is that when I click the button to draw my first set of lines, everything works perfectly. I end the command by removing the observable (not sure if that’s the best approach). If I hit the button again to draw another set of lines, the points resume from the last point that was clicked in the previous set. I need it to start a new set of lines instead. What do i need to modify
@br-matt I created a new PG in typescript. Trying to wrap this routine up but still having an issue. The issue now is when I right click after selecting my lines. I’m trying to delete the stringer that was not committed as a valid point. The problem is, i am updating the vectors array, but the actual lines are not updating. Not quite sure why.