I'm attempting to create a box out of lines on the floor of a babylonjs project, I know I need to create a vector for each point, but I can't figure out what the marker points would need.
posOne = new BABYLON.Vector3(10, 0, -100)
posTwo = new BABYLON.Vector3(-100, 0, 10)
posThree = new BABYLON.Vector3(100, 0, 10)
posFour = new BABYLON.Vector3(10, 0, 100)
const updatePath = () => {
path = [];
path.push(posOne);
path.push(posTwo);
path.push(posThree);
path.push(posFour);
};
updatePath();
var linesMesh = BABYLON.Mesh.CreateLines("lines", path, scene, true);
I have this so far, but I can't seem to connect the lines or get them to form a square. I'm really bad at maths, so it would be interesting to know the theory behind this!
first - a playground: http://www.babylonjs-playground.com/#XBGEQ
To create a box you will need to connect 5 points (the last point beint the same as the first one). If oyu want them to be at the same height, the y axis (as you understood also) should stay 0. Then, it is all a matter of understanding where the next dot is.
let's say the box should be 10 units wide. the "upper" left corent is (-5, 0, 5), because the x is negative and z is positive forward. The next point, the "upper" right corner is (5,0,5). From there you go "down" (actually towards you) to (5,0,-5) and eventually to (-5,0,-5). Afterwards, just add the first point to complete the box.