I have created the following scene, and I want to access the segments and update them using a slider as demonstrated this DEMO.
This is what I have:
What I use to create the subdivided cubes:
BV_Subdivide(5);
BV_Subdivide(numOfSubdivisions) {
//Declare a Vector3
var tempV = new THREE.Vector3();
numOfSubdivisions = 5;
for(var i=0; i<bv_List.length; i++) {
//Compute the bounding volumes of all selected objects
bv_List[i].geometry.computeBoundingBox();
bv_List[i].geometry.boundingBox.getSize( tempV );
//Create a new Buffer Geometry for each object
var thisBufferGeometry = new THREE.BoxBufferGeometry(
tempV.x,
tempV.y,
tempV.z,
numOfSubdivisions,
numOfSubdivisions,
numOfSubdivisions
);
//Create a grid BV
var subdividedBox = GridBoxGeometry(thisBufferGeometry, false);
//Calculate the center of the bounding volume
bv_List[i].geometry.boundingBox.getCenter(tempV);
//Update the position of the new BV
subdividedBox.translate(tempV.x, tempV.y, tempV.z);
//Create new LineSegments for each object and assign BV Geometry and Material
var grid = new THREE.LineSegments(subdividedBox, new THREE.LineBasicMaterial({
color: "aqua"
}));
bv_Final_List[i] = grid;
scene_Main.add(grid); //Add Final BV in the scene
}
},
How to update the segments of the buffer geometry after the declaration?
BV_Update() {
for(var i=0; i<bv_Final_List.length; i++) {
//Update segments for each object
//Render?
}
}