Hi, I’m trying to demonstrate BoundingVolumeSUBDIVISION, and I was thinking if it’s able to subdivide a Box3Helper. Or how to convert the Box3Helper to an object?
My Example:
createBoundingVolumes() {
for(var i=0; i<groupOfObjects.length; i++) {
var BV = new THREE.BoxHelper( groupOfObjects[i], 0xffff00 );
var box3 = new THREE.Box3();
box3.setFromObject(BV);
scene_Main.add(BV);
}
stage_6_declared = true;
}
Is there a way to return the bufferGeometry of BoxHelper?
I tried using this
function BV_Create(){
for(var i=0; i<groupOfObjects.length; i++) {
var BV = new THREE.BoxHelper( groupOfObjects[i], 0xffff00 );
BV.update();
bv_List[i] = BV;
bv_List[i].material.visible = false; //Set true in draw() function
scene_Main.add(BV); //Add object to the scene
}
},
function BV_Subdivide() {
for(var i=0; i<bv_List.length; i++) {
var thisBufferGeometry = new THREE.BoxBufferGeometry().fromGeometry(bv_List[i]); //Also tried bv_List[i].geometry
var subdividedBox = GridBoxGeometry(thisBufferGeometry, true / false);
var grid = new THREE.LineSegments(subdividedBox, new THREE.LineBasicMaterial({
color: "aqua"
}));
scene_Main.add(grid);
}
},
The BoxBufferGeometry can’t be constructed the way you’ve tried. Please try:
//Declare a Vector3
var tempV = new THREE.Vector3();
...
// In the loop:
bv_List[i].computeBoundingBox();
bv_List[i].boundingBox.getSize( tempV );
var thisBufferGeometry = new THREE.BoxBufferGeometry( tempV.x, tempV.y, tempV.z, segmentsX, segmentsY, segmentsZ );
segmentsX, Y, Z are the number of subdivisions on each axis.