kopia lustrzana https://github.com/OpenBuilds/OpenBuilds-CONTROL
3d viewer fix
rodzic
88daa328ab
commit
9a26d6e72f
|
@ -9,7 +9,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="metro4:init" content="true">
|
<meta name="metro4:init" content="true">
|
||||||
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
|
||||||
<link rel="stylesheet" href="lib/metro4/css/metro-all.css" />
|
<link rel="stylesheet" href="lib/metro4/css/metro-all.min.css" />
|
||||||
<link rel="stylesheet" href="css/buttons.css" />
|
<link rel="stylesheet" href="css/buttons.css" />
|
||||||
<link rel="stylesheet" href="css/main.css" />
|
<link rel="stylesheet" href="css/main.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -17,13 +17,7 @@ $(document).ready(function() {
|
||||||
editor.session.setValue('; No GCODE yet - please Load a GCODE file from the Open GCODE button'); // from samplefile.js
|
editor.session.setValue('; No GCODE yet - please Load a GCODE file from the Open GCODE button'); // from samplefile.js
|
||||||
editor.setShowPrintMargin(false);
|
editor.setShowPrintMargin(false);
|
||||||
editor.getSession().on('change', function() {
|
editor.getSession().on('change', function() {
|
||||||
if (scene.getObjectByName('gcodeobject')) {
|
// parseGcodeInWebWorker(editor.getValue())
|
||||||
// console.log("Existing GCODE object: Cleaning up first")
|
|
||||||
scene.remove(scene.getObjectByName('gcodeobject'))
|
|
||||||
object = false;
|
|
||||||
}
|
|
||||||
resetView();
|
|
||||||
parseGcodeInWebWorker(editor.getValue())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,6 +62,7 @@ $(document).ready(function() {
|
||||||
console.log(data.length)
|
console.log(data.length)
|
||||||
if (data.length > 2) {
|
if (data.length > 2) {
|
||||||
editor.session.setValue(data);
|
editor.session.setValue(data);
|
||||||
|
parseGcodeInWebWorker(data)
|
||||||
$('#controlTab').click()
|
$('#controlTab').click()
|
||||||
if (webgl) {
|
if (webgl) {
|
||||||
$('#gcodeviewertab').click();
|
$('#gcodeviewertab').click();
|
||||||
|
@ -108,6 +103,7 @@ function loadFile(f) {
|
||||||
// cleanupThree();
|
// cleanupThree();
|
||||||
// gcode = this.result;
|
// gcode = this.result;
|
||||||
editor.session.setValue(this.result);
|
editor.session.setValue(this.result);
|
||||||
|
parseGcodeInWebWorker(this.result)
|
||||||
printLog('GCODE Opened: ');
|
printLog('GCODE Opened: ');
|
||||||
};
|
};
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -150,7 +150,7 @@ function drawWorkspace(xmin, xmax, ymin, ymax) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function redrawGrid(xmin, xmax, ymin, ymax) {
|
function redrawGrid(xmin, xmax, ymin, ymax) {
|
||||||
gridsystem.children.length = 0
|
|
||||||
|
|
||||||
sizexmax = xmax;
|
sizexmax = xmax;
|
||||||
sizeymax = ymax;
|
sizeymax = ymax;
|
||||||
|
@ -241,9 +241,12 @@ function redrawGrid(xmin, xmax, ymin, ymax) {
|
||||||
helper.name = "GridHelper50mm"
|
helper.name = "GridHelper50mm"
|
||||||
grid.add(helper);
|
grid.add(helper);
|
||||||
grid.name = "Grid"
|
grid.name = "Grid"
|
||||||
gridsystem.add(grid);
|
|
||||||
|
|
||||||
gridsystem.add(drawRuler(xmin, xmax, ymin, ymax));
|
gridsystem.children.length = 0
|
||||||
|
var ruler = drawRuler(xmin, xmax, ymin, ymax)
|
||||||
|
gridsystem.add(grid);
|
||||||
|
gridsystem.add(ruler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBullseyePosition(x, y, z) {
|
function setBullseyePosition(x, y, z) {
|
||||||
|
@ -345,15 +348,15 @@ function animate() {
|
||||||
scene.remove(scene.children[1])
|
scene.remove(scene.children[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
var documents = new THREE.Group();
|
// var documents = new THREE.Group();
|
||||||
documents.name = "Documents";
|
// documents.name = "Documents";
|
||||||
for (i = 0; i < objectsInScene.length; i++) {
|
// for (i = 0; i < objectsInScene.length; i++) {
|
||||||
documents.add(objectsInScene[i])
|
// documents.add(objectsInScene[i])
|
||||||
}
|
// }
|
||||||
scene.add(documents)
|
// scene.add(documents)
|
||||||
|
//
|
||||||
var toolpaths = new THREE.Group();
|
// var toolpaths = new THREE.Group();
|
||||||
toolpaths.name = "Toolpaths";
|
// toolpaths.name = "Toolpaths";
|
||||||
// for (i = 0; i < toolpathsInScene.length; i++) {
|
// for (i = 0; i < toolpathsInScene.length; i++) {
|
||||||
//
|
//
|
||||||
// if (toolpathsInScene[i].userData.visible) {
|
// if (toolpathsInScene[i].userData.visible) {
|
||||||
|
@ -397,7 +400,7 @@ function animate() {
|
||||||
|
|
||||||
|
|
||||||
function viewExtents(objecttosee) {
|
function viewExtents(objecttosee) {
|
||||||
// console.log("viewExtents. object:", this.object);
|
// console.log("viewExtents. object:", objecttosee);
|
||||||
// console.log("controls:", controls);
|
// console.log("controls:", controls);
|
||||||
//wakeAnimate();
|
//wakeAnimate();
|
||||||
|
|
||||||
|
@ -441,7 +444,7 @@ function viewExtents(objecttosee) {
|
||||||
var fov = 2.2 * Math.atan(maxlen / (2 * dist)) * (180 / Math.PI);
|
var fov = 2.2 * Math.atan(maxlen / (2 * dist)) * (180 / Math.PI);
|
||||||
// console.log("new fov:", fov, " old fov:", controls.object.fov);
|
// console.log("new fov:", fov, " old fov:", controls.object.fov);
|
||||||
if (isNaN(fov)) {
|
if (isNaN(fov)) {
|
||||||
console.log("giving up on viewing extents because fov could not be calculated");
|
// console.log("giving up on viewing extents because fov could not be calculated");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// console.log("fov: ", fov);
|
// console.log("fov: ", fov);
|
||||||
|
@ -559,6 +562,7 @@ $(window).on('resize', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function resetView(object) {
|
function resetView(object) {
|
||||||
|
// console.log(resetView.caller);
|
||||||
if (!object) {
|
if (!object) {
|
||||||
if (objectsInScene.length > 0) {
|
if (objectsInScene.length > 0) {
|
||||||
var insceneGrp = new THREE.Group()
|
var insceneGrp = new THREE.Group()
|
||||||
|
|
|
@ -98,13 +98,8 @@ function initSocket() {
|
||||||
|
|
||||||
socket.on('gcodeupload', function(data) {
|
socket.on('gcodeupload', function(data) {
|
||||||
printLog("Received new GCODE from API")
|
printLog("Received new GCODE from API")
|
||||||
if (scene.getObjectByName('gcodeobject')) {
|
|
||||||
// console.log("Existing GCODE object: Cleaning up first")
|
|
||||||
scene.remove(scene.getObjectByName('gcodeobject'))
|
|
||||||
object = false;
|
|
||||||
}
|
|
||||||
resetView();
|
|
||||||
editor.session.setValue(data);
|
editor.session.setValue(data);
|
||||||
|
parseGcodeInWebWorker(data)
|
||||||
$('#controlTab').click()
|
$('#controlTab').click()
|
||||||
if (webgl) {
|
if (webgl) {
|
||||||
$('#gcodeviewertab').click();
|
$('#gcodeviewertab').click();
|
||||||
|
|
|
@ -6,15 +6,22 @@ var loader = new THREE.ObjectLoader();
|
||||||
|
|
||||||
var worker = new Worker('lib/3dview/workers/gcodeparser.js');
|
var worker = new Worker('lib/3dview/workers/gcodeparser.js');
|
||||||
worker.addEventListener('message', function(e) {
|
worker.addEventListener('message', function(e) {
|
||||||
|
// console.log('webworker message')
|
||||||
|
if (scene.getObjectByName('gcodeobject')) {
|
||||||
|
scene.remove(scene.getObjectByName('gcodeobject'))
|
||||||
|
object = false;
|
||||||
|
}
|
||||||
object = loader.parse(JSON.parse(e.data));
|
object = loader.parse(JSON.parse(e.data));
|
||||||
scene.add(object);
|
if (object) {
|
||||||
redrawGrid(parseInt(object.userData.bbbox2.min.x), parseInt(object.userData.bbbox2.max.x), parseInt(object.userData.bbbox2.min.y), parseInt(object.userData.bbbox2.max.y))
|
scene.add(object);
|
||||||
// animate();
|
redrawGrid(parseInt(object.userData.bbbox2.min.x), parseInt(object.userData.bbbox2.max.x), parseInt(object.userData.bbbox2.min.y), parseInt(object.userData.bbbox2.max.y))
|
||||||
setTimeout(function() {
|
|
||||||
console.log("Reset Camera");
|
|
||||||
viewExtents(object);
|
|
||||||
// animate();
|
// animate();
|
||||||
}, 200);
|
setTimeout(function() {
|
||||||
|
clearSceneFlag = true;
|
||||||
|
resetView();
|
||||||
|
// animate();
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
function parseGcodeInWebWorker(gcode) {
|
function parseGcodeInWebWorker(gcode) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
self.addEventListener('message', function(e) {
|
self.addEventListener('message', function(e) {
|
||||||
|
console.log("New message received by worker", e.data.data.length)
|
||||||
importScripts("/lib/threejs/three.min.js");
|
importScripts("/lib/threejs/three.min.js");
|
||||||
var data = e.data;
|
var data = e.data;
|
||||||
var result = openGCodeFromText(e.data.data)
|
var result = openGCodeFromText(e.data.data)
|
||||||
|
@ -102,7 +103,7 @@ function openGCodeFromText(gcode) {
|
||||||
extruding: false
|
extruding: false
|
||||||
};
|
};
|
||||||
createObjectFromGCode(gcode, object2)
|
createObjectFromGCode(gcode, object2)
|
||||||
console.log(object2)
|
// console.log(object2)
|
||||||
return object2;
|
return object2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "OpenBuildsMachineDriver",
|
"name": "OpenBuildsMachineDriver",
|
||||||
"version": "1.0.88",
|
"version": "1.0.89",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"description": "Machine Interface Driver for OpenBuilds",
|
"description": "Machine Interface Driver for OpenBuilds",
|
||||||
"author": "github.com/openbuilds <webmaster@openbuilds.com>",
|
"author": "github.com/openbuilds <webmaster@openbuilds.com>",
|
||||||
|
|
Ładowanie…
Reference in New Issue