diff --git a/octoprint_slicer/static/js/octoprint_slicer.min.js b/octoprint_slicer/static/js/octoprint_slicer.min.js index 18ba7a7..7eff874 100644 --- a/octoprint_slicer/static/js/octoprint_slicer.min.js +++ b/octoprint_slicer/static/js/octoprint_slicer.min.js @@ -32754,7 +32754,7 @@ function SlicerViewModel(parameters) { } }; - self.sliceRequestData = function (slicingVM, group) { + self.sliceRequestData = function (slicingVM, groupCenter) { var destinationFilename = slicingVM._sanitize(slicingVM.destinationFilename()); var destinationExtensions = slicingVM.data[slicingVM.slicer()] && slicingVM.data[slicingVM.slicer()].extensions && slicingVM.data[slicingVM.slicer()].extensions.destination ? slicingVM.data[slicingVM.slicer()].extensions.destination : ["???"]; @@ -32763,9 +32763,8 @@ function SlicerViewModel(parameters) { })) { destinationFilename = destinationFilename + "." + destinationExtensions[0]; } - var groupCenter = new Vector3(0, 0, 0); - if (group) { - groupCenter = new Box3().setFromObject(group).getCenter(); + if (!groupCenter) { + groupCenter = new Vector3(0, 0, 0); } var data = { command: "slice", @@ -32813,11 +32812,14 @@ function SlicerViewModel(parameters) { var form = new FormData(); var group = new Group(); + var groupBox3 = new Box3(); forEach$1(self.stlViewPort.models(), function (model) { group.add(model.clone(true)); + groupBox3.expandByPoint(model.userData.box3FromObject().min); + groupBox3.expandByPoint(model.userData.box3FromObject().max); }); - sliceRequestData = self.sliceRequestData(self.slicingViewModel, group); + sliceRequestData = self.sliceRequestData(self.slicingViewModel, groupBox3.getCenter()); var tempFilename = self.tempSTLFilename(); form.append("file", self.blobFromModel(group), tempFilename); diff --git a/src/slicer.js b/src/slicer.js index ebde77c..4e04694 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -329,7 +329,7 @@ function SlicerViewModel(parameters) { } } - self.sliceRequestData = function(slicingVM, group) { + self.sliceRequestData = function(slicingVM, groupCenter) { var destinationFilename = slicingVM._sanitize(slicingVM.destinationFilename()); var destinationExtensions = slicingVM.data[slicingVM.slicer()] && slicingVM.data[slicingVM.slicer()].extensions && slicingVM.data[slicingVM.slicer()].extensions.destination @@ -340,9 +340,8 @@ function SlicerViewModel(parameters) { })) { destinationFilename = destinationFilename + "." + destinationExtensions[0]; } - var groupCenter = new THREE.Vector3(0,0,0); - if (group) { - groupCenter = new THREE.Box3().setFromObject(group).getCenter(); + if (!groupCenter) { + groupCenter = new THREE.Vector3(0,0,0); } var data = { command: "slice", @@ -391,11 +390,14 @@ function SlicerViewModel(parameters) { var form = new FormData(); var group = new THREE.Group(); + let groupBox3 = new THREE.Box3(); forEach(self.stlViewPort.models(), function (model) { group.add(model.clone(true)); + groupBox3.expandByPoint(model.userData.box3FromObject().min); + groupBox3.expandByPoint(model.userData.box3FromObject().max); }); - sliceRequestData = self.sliceRequestData(self.slicingViewModel, group); + sliceRequestData = self.sliceRequestData(self.slicingViewModel, groupBox3.getCenter()); var tempFilename = self.tempSTLFilename(); form.append("file", self.blobFromModel(group), tempFilename);