Skip to content

Commit

Permalink
Merge branch 'eyal0-faster_group_center't push origin master
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethjiang committed May 6, 2017
2 parents 634bd07 + 30649ec commit 953e1d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions octoprint_slicer/static/js/octoprint_slicer.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 : ["???"];
Expand All @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions src/slicer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 953e1d8

Please sign in to comment.