I am attempting to determine the volume of an object based on a scale value provided by a form submission.
My goal is to recalculate the scale from the original geometry each time, but I encounter an issue when I update the geometry and then change the scale, as it applies to the updated geometry.
I thought about cloning the geometry and applying the scale only to the cloned version. This way, I could always start from the original geometry whenever the scale value changes. However, I am unsure how to implement this solution.
Here is the code I have so far. Any suggestions?
$(document).on('change', '.scaleBox', function (e) {
if (idfile == $(this).attr('idgl')) {
var val = $(this).val();
if (val <= 0)
val = 0.1;
myObj.scale.set(val, val, val);
myObj.updateMatrix();
myObj.geometry.applyMatrix(myObj.matrix);
myObj.matrix.identity();
myObj.geometry.verticesNeedUpdate = true;
var volume = myVolume(myObj.geometry);
$("#specs-" + idfile).find('.volumeVal').html(myRound(volume, 3));
var box = new THREE.Box3().setFromObject(myObj);
xyzSizes = box.size();
$("#specs-" + idfile).find('.sizesVal').html('x: ' + myRound(xyzSizes.x, 3) + ' y: ' + myRound(xyzSizes.y, 3) + ' z: ' + myRound(xyzSizes.z, 3));
}
});