fixed importing buffer geometry with bounding bug

This commit is contained in:
casperlamboo 2015-06-01 12:06:11 +02:00
parent 389dcc27d2
commit 67362c4ba8
5 changed files with 20 additions and 19 deletions

View File

@ -30,7 +30,7 @@ function init () {
var scene = createScene(); var scene = createScene();
var localIp = location.hash.substring(1); var localIp = location.hash.substring(1);
doodleBox = new D3D.Box(localIp); //doodleBox = new D3D.Box(localIp);
var printer = new D3D.Printer().updateConfig(USER_SETTINGS).updateConfig(PRINTER_SETTINGS["ultimaker"]); var printer = new D3D.Printer().updateConfig(USER_SETTINGS).updateConfig(PRINTER_SETTINGS["ultimaker"]);
@ -69,6 +69,7 @@ function init () {
mesh.rotation.x = -Math.PI/2; mesh.rotation.x = -Math.PI/2;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1; mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
mesh.position.y = -9.260265119962973e-17;
mesh.position.x = 100; mesh.position.x = 100;
mesh.position.z = 100; mesh.position.z = 100;

View File

@ -2,14 +2,6 @@
* *
* Slicer * Slicer
* *
* TODO (optimalisatie)
* sorteer lijnen op laagste hoogte -> stop loop wanneer hij een lijn zonder intersectie heeft gevonden
* verwijder lijnen die ooit interactie gehad hebben, maar nu niet meer
* helft van lijnen toevoegen omdat 4face altijd recht is, en 3face dus te veel data bevat
*
* omliggende lagen -> difference && sum omliggende lijnen
* voor laag 5 = 5 diff (3 && 4 && 6 && 7))
*
******************************************************/ ******************************************************/
D3D.Slicer = function () { D3D.Slicer = function () {
@ -137,8 +129,8 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
//still error in first layer, so remove first layer & last layer //still error in first layer, so remove first layer & last layer
//see https://github.com/Doodle3D/Doodle3D-Slicer/issues/1 //see https://github.com/Doodle3D/Doodle3D-Slicer/issues/1
for (var layer = 1; layer < layersIntersections.length-1; layer ++) { //for (var layer = 1; layer < layersIntersections.length-1; layer ++) {
//for (var layer = 0; layer < layersIntersections.length; layer ++) { for (var layer = 0; layer < layersIntersections.length; layer ++) {
var layerIntersections = layersIntersections[layer]; var layerIntersections = layersIntersections[layer];
var y = layer * layerHeight; var y = layer * layerHeight;

View File

@ -10,7 +10,7 @@ D3D.SlicerWorker = function () {
switch (event.data["cmd"]) { switch (event.data["cmd"]) {
case "PROGRESS": case "PROGRESS":
var progress = event.data["progress"]; var progress = event.data["progress"];
var procent = (progress.sliceLayer + progress.dataLayer + progress.gcodeLayer) / progress.totalLayers / 3; var procent = (progress.sliceLayer + progress.dataLayer + progress.gcodeLayer) / (progress.totalLayers * 3 - 5);
progressBar.style.width = procent * 100 + "%"; progressBar.style.width = procent * 100 + "%";
break; break;
@ -50,7 +50,10 @@ D3D.SlicerWorker.prototype.setMesh = function (mesh) {
this.worker.postMessage({ this.worker.postMessage({
"cmd": "SET_MESH", "cmd": "SET_MESH",
"geometry": geometry, "geometry": {
"attributes": geometry.attributes,
"attributesKeys": geometry.attributesKeys
},
"matrix": mesh.matrix.toArray() "matrix": mesh.matrix.toArray()
}, buffers); }, buffers);
}; };

View File

@ -24,6 +24,10 @@ self.addEventListener("message", function (event) {
switch (event.data["cmd"]) { switch (event.data["cmd"]) {
case "SET_MESH": case "SET_MESH":
//hack...
//because boundings loses functions when converting
event.data["geometry"].boundingBox = event.data["geometry"].boundingSphere = null;
var geometry = new THREE.Geometry().fromBufferGeometry(event.data["geometry"]); var geometry = new THREE.Geometry().fromBufferGeometry(event.data["geometry"]);
var matrix = new THREE.Matrix4().fromArray(event.data["matrix"]); var matrix = new THREE.Matrix4().fromArray(event.data["matrix"]);

View File

@ -31,20 +31,21 @@ function init () {
var scene = createScene(); var scene = createScene();
var localIp = location.hash.substring(1); var localIp = location.hash.substring(1);
//doodleBox = new D3D.Box(localIp); doodleBox = new D3D.Box(localIp);
var slicer = new D3D.SlicerWorker(); var slicer = new D3D.SlicerWorker();
slicer.setSettings(USER_SETTINGS, PRINTER_SETTINGS["ultimaker"]); slicer.setSettings(USER_SETTINGS, PRINTER_SETTINGS["ultimaker"]);
var loader = new THREE.STLLoader(); var loader = new THREE.STLLoader();
loader.load("models/stanford_bunny_high.stl", function (geometry) { loader.load("models/dom.stl", function (geometry) {
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
var material = new THREE.MeshPhongMaterial({color: 0x00ff00, wireframe: false}); var material = new THREE.MeshPhongMaterial({color: 0x00ff00, wireframe: false});
var mesh = new THREE.Mesh(geometry, material); var mesh = new THREE.Mesh(geometry, material);
mesh.rotation.x = -Math.PI/2; mesh.rotation.x = -Math.PI/2;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.5; mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
mesh.position.y = -9.260265119962973e-17; //mesh.position.y = -9.260265119962973e-17;
mesh.position.x = 100; mesh.position.x = 100;
mesh.position.z = 100; mesh.position.z = 100;