I’ve create a grid with lines but i cant dispose that, “linebuilder” not defined :///
PS: to playground migration dont work for and for upload my html support it’s very convenient for me
i try all solution, getmeshes, by tags, by id, name. But delete lines its impossible
linebuilder is not a mesh, how to remove lines ?
const GridSwitch = BABYLON.GUI.Button.CreateSimpleButton("GridSwitch", "#️⃣");
GridSwitch.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
GridSwitch.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
GridSwitch.onPointerClickObservable.add(() => {
createLines(10, 10 , 1);
});
advancedTexture.addControl(GridSwitch);
-----
-----
-----
let linebuilder;
function createLines(numCellsX, numCellsZ, cellSize, points, p1, p2, p3, colors, c1, c2 , c3) {
for (var x = 0; x < numCellsX; x++) {
for (var z = 0; z < numCellsZ; z++) {
const points = [
new BABYLON.Vector3((x * cellSize) - 5, 0, (z * cellSize) - 5),
new BABYLON.Vector3(((x+1) * cellSize) - 5, 0, (z * cellSize) - 5),
new BABYLON.Vector3(((x+1) * cellSize) - 5, 0, ((z+1) * cellSize) - 5),
]
const colors = [
new BABYLON.Color4( 0, 0, 0, 1), // black
new BABYLON.Color4( 0, 0, 0, 1), // black
new BABYLON.Color4( 0, 0, 0, 1), // black
]
linebuilder = BABYLON.MeshBuilder.CreateLines("linename", {points: points, colors: colors
// });
}, scene);
}
}
}
---
---
---
const mystery3 = BABYLON.GUI.Button.CreateSimpleButton("mystery3", "♒");
mystery3.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
mystery3.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
mystery3.onPointerClickObservable.add(() => {
linebuilder.dispose();
});
advancedTexture.addControl(mystery3);