I try add line
Segments for boxGeometry and it become infinity adding new LineSegments:
Infinity:
function checkAnswer () {
//console.log(node);
let valueBoard1 = document.querySelector("input[name = board_depth_balk]").value;
let valueBoard2 = document.querySelector("input[name = board_height_balk]").value;
let valueBoard3 = document.querySelector("input[name = board_width_balk]").value;
let idBoard = document.querySelector("input[name = board_depth_balk]").id;
//idBoard = document.querySelector("input[name = board_height_balk]").id;
//idBoard = document.querySelector("input[name = board_width_balk]").id;
idBoard = Number(idBoard);
console.log(idBoard);
for(let j = 0; j < scene.children.length; j++){
if(scene.children[j].customIdLine == idBoard){ scene.remove(scene.children[j]);
}
}
for(let i = 0; i < scene.children.length; i++){
if(scene.children[i].customId == idBoard ){
board_depth_balk = valueBoard1;
board_height_balk = valueBoard2;
board_width_balk = valueBoard3;
board_geometry = new THREE.BoxGeometry(board_width_balk,board_height_balk,board_depth_balk);
let board_material = new THREE.MeshBasicMaterial({ color: color_texture });
var board = new THREE.Mesh( board_geometry, board_material );
board.name = "board";
board.customId = idBoard;
board.width = board_width_balk;
board.height = board_height_balk;
board.depth = board_depth_balk;
board.position.x = scene.children[i].position.x;
board.position.y = scene.children[i].position.y;
board.position.z = scene.children[i].position.z;
scene.remove(scene.children[i]);
scene.add(board);
console.log(i);
let edges_new = new THREE.EdgesGeometry( board_geometry );
let line_material_new = new THREE.LineBasicMaterial( { color: 0xffffff } )
let line_new = new THREE.LineSegments( edges_new, line_material_new );
line_new.customIdLine = idBoard;
line_new.position.x = board.position.x;
line_new.position.y = board.position.y;
line_new.position.z = board.position.z;
scene.add(line_new);
console.log(line_new);
}
}
}
normal behavior
function checkAnswer () {
//console.log(node);
let valueBoard1 = document.querySelector("input[name = board_depth_balk]").value;
let valueBoard2 = document.querySelector("input[name = board_height_balk]").value;
let valueBoard3 = document.querySelector("input[name = board_width_balk]").value;
let idBoard = document.querySelector("input[name = board_depth_balk]").id;
//idBoard = document.querySelector("input[name = board_height_balk]").id;
//idBoard = document.querySelector("input[name = board_width_balk]").id;
idBoard = Number(idBoard);
console.log(idBoard);
for(let j = 0; j < scene.children.length; j++){
if(scene.children[j].customIdLine == idBoard){ scene.remove(scene.children[j]);
}
}
for(let i = 0; i < scene.children.length; i++){
if(scene.children[i].customId == idBoard ){
board_depth_balk = valueBoard1;
board_height_balk = valueBoard2;
board_width_balk = valueBoard3;
board_geometry = new THREE.BoxGeometry(board_width_balk,board_height_balk,board_depth_balk);
let board_material = new THREE.MeshBasicMaterial({ color: color_texture });
var board = new THREE.Mesh( board_geometry, board_material );
board.name = "board";
board.customId = idBoard;
board.width = board_width_balk;
board.height = board_height_balk;
board.depth = board_depth_balk;
board.position.x = scene.children[i].position.x;
board.position.y = scene.children[i].position.y;
board.position.z = scene.children[i].position.z;
scene.remove(scene.children[i]);
scene.add(board);
console.log(i);
}
}
//for loope become infinity
let edges_new = new THREE.EdgesGeometry( board_geometry );
let line_material_new = new THREE.LineBasicMaterial( { color: 0xffffff } )
let line_new = new THREE.LineSegments( edges_new, line_material_new );
line_new.customIdLine = idBoard;
line_new.position.x = board.position.x;
line_new.position.y = board.position.y;
line_new.position.z = board.position.z;
scene.add(line_new);
console.log(line_new);
}
input working with addEventListener
Why it’s happen?