pull/153/head v1.0.196
openbuilds-engineer 2019-10-18 20:55:41 +02:00
rodzic 1ec235a9d3
commit 67b240a60e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 3AB95CA8F41E2655
10 zmienionych plików z 516 dodań i 398 usunięć

Wyświetl plik

@ -1,3 +1,4 @@
v1.0.196: Added menu to troubleshooting tab to selectively disable frontend features for debugging
v1.0.195: Fixed bug related to default state of 3D viewer v1.0.195: Fixed bug related to default state of 3D viewer
v1.0.194: Added option to disable 3D Viewer for slow machines v1.0.194: Added option to disable 3D Viewer for slow machines
v1.0.193: Improved 3D viewer loading speed v1.0.193: Improved 3D viewer loading speed

Wyświetl plik

@ -295,8 +295,6 @@
<li onclick="keyboardShortcutsEditor();"><a href="#"><i class="far fa-edit fa-fw"></i> Customize Shortcut Key Assignments</a></li> <li onclick="keyboardShortcutsEditor();"><a href="#"><i class="far fa-edit fa-fw"></i> Customize Shortcut Key Assignments</a></li>
<li class="divider fg-lightGray"></li> <li class="divider fg-lightGray"></li>
<li onclick="populateGrblBuilderToolForm();"><a href="#"><img src="img/grbl.png" /> Flashing Tool</a></li> <li onclick="populateGrblBuilderToolForm();"><a href="#"><img src="img/grbl.png" /> Flashing Tool</a></li>
<li class="divider fg-lightGray"></li>
<li onclick="viewerdisable()" id="viewerdisabled" class=""><a href="#"><i class="mif-3d-rotation fa-fw" id="3dviewicon"></i> Disable 3D Viewer (For slower computers)</a></li>
</ul> </ul>
</div> </div>
@ -335,6 +333,31 @@
</div> </div>
<div class="section" id="section-troubleshooting"> <div class="section" id="section-troubleshooting">
<div class="group">
<div>
<button id="diagbtn" class="ribbon-button dropdown-toggle">
<span class="icon">
<span class="fa-layers fa-fw">
<i class="fas fa-stethoscope"></i>
</span>
</span>
<span class="caption">Application<br>Diagnostics</span>
</button>
<ul class="ribbon-dropdown grblmode" data-role="dropdown" data-duration="100">
<li onclick="disable3Dviewer = !disable3Dviewer; saveDiagnostics(); location.reload();" id="disable3DviewerTick"><a href="#"><i class="mif-3d-rotation fa-fw"></i> Disable 3D Viewer System (For slower computers)</a></li>
<li class="divider"></li>
<li onclick="disable3Dcontrols = !disable3Dcontrols; saveDiagnostics(); location.reload();" id="disable3DcontrolsTick"><a href="#"><i class="mif-3d-rotation fa-fw"></i> Disable 3D Viewer Interactions</a></li>
<li onclick="disable3Dskybox = !disable3Dskybox; saveDiagnostics(); location.reload();" id="disable3DskyboxTick"><a href="#"><i class="mif-3d-rotation fa-fw"></i> Disable 3D Viewer Skybox/Fog</a></li>
<li onclick="disable3Drealtimepos = !disable3Drealtimepos; saveDiagnostics(); location.reload();" id="disable3DrealtimeposTick"><a href="#"><i class="mif-3d-rotation fa-fw"></i> Disable 3D Viewer Realtime Job Position
Indicator</a></li>
<li onclick="disable3Dgcodepreview = !disable3Dgcodepreview; saveDiagnostics(); location.reload();" id="disable3DgcodepreviewTick"><a href="#"><i class="mif-3d-rotation fa-fw"></i> Disable 3D Viewer GCODE Preview</a></li>
<li class="divider"></li>
<li onclick="disableSerialLog =! disableSerialLog; saveDiagnostics(); location.reload();" id="disableSerialLogTick"><a href="#"><i class="fas fa-fw fa-terminal"></i> Disable Serial Log</a></li>
<li onclick="disableDROupdates = !disableDROupdates; saveDiagnostics(); location.reload();" id="disableDROupdatesTick"><a href="#"><i class="fas fa-fw fa-list-ol"></i> Disable DRO/Status Updates</a></li>
</ul>
</div>
<span class="title">Settings</span>
</div>
<div class="group" style="width: 100px;"> <div class="group" style="width: 100px;">
<button class="ribbon-button" onclick="socket.emit('clearAlarm', 2)"> <button class="ribbon-button" onclick="socket.emit('clearAlarm', 2)">
<span class="icon"> <span class="icon">
@ -1222,12 +1245,15 @@
</script> </script>
<script type="text/javascript" src="lib/fontawesome5/js/all.min.js"></script> <script type="text/javascript" src="lib/fontawesome5/js/all.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script> <script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery-ui.js"></script> <script type="text/javascript" src="lib/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="lib/jquery/jquery-input-history.min.js"></script> <script type="text/javascript" src="lib/jquery/jquery-input-history.min.js"></script>
<script type="text/javascript" src="lib/jquery/jquery-swipe.js"></script> <script type="text/javascript" src="lib/jquery/jquery-swipe.js"></script>
<script type="text/javascript" src="js/diagnostics.js"></script>
<script type="text/javascript" src="lib/qrcode/qrcode.min.js"></script> <script type="text/javascript" src="lib/qrcode/qrcode.min.js"></script>
<script type="text/javascript" src="lib/ace/src-noconflict/ace.js"></script> <script type="text/javascript" src="lib/ace/src-noconflict/ace.js"></script>

Wyświetl plik

@ -0,0 +1,86 @@
var disable3Dviewer = false;
var disable3Dcontrols = false;
var disable3Dskybox = false;
var disable3Drealtimepos = false;
var disable3Dgcodepreview = false;
var disableSerialLog = false; // todo also hide tab when set to true
var disableDROupdates = false;
function saveDiagnostics() {
localStorage.setItem('disable3Dviewer', disable3Dviewer);
localStorage.setItem('disable3Dcontrols', disable3Dcontrols);
localStorage.setItem('disable3Dskybox', disable3Dskybox);
localStorage.setItem('disable3Drealtimepos', disable3Drealtimepos);
localStorage.setItem('disable3Dgcodepreview', disable3Dgcodepreview);
localStorage.setItem('disableSerialLog', disableSerialLog);
localStorage.setItem('disableDROupdates', disableDROupdates);
}
function initDiagnostics() {
if (localStorage.getItem('disable3Dviewer')) {
if (JSON.parse(localStorage.getItem('disable3Dviewer')) == true) {
disable3Dviewer = true;
$('#disable3DviewerTick').addClass("checked");
}
} else {
disable3Dviewer = false;
}
if (localStorage.getItem('disable3Dcontrols')) {
if (JSON.parse(localStorage.getItem('disable3Dcontrols')) == true) {
disable3Dcontrols = true;
$('#disable3DcontrolsTick').addClass("checked");
}
} else {
disable3Dcontrols = false;
}
if (localStorage.getItem('disable3Dskybox')) {
if (JSON.parse(localStorage.getItem('disable3Dskybox')) == true) {
disable3Dskybox = true;
$('#disable3DskyboxTick').addClass("checked");
}
} else {
disable3Dskybox = false;
}
if (localStorage.getItem('disable3Drealtimepos')) {
if (JSON.parse(localStorage.getItem('disable3Drealtimepos')) == true) {
disable3Drealtimepos = true;
$('#disable3DrealtimeposTick').addClass("checked");
}
} else {
disable3Drealtimepos = false;
}
if (localStorage.getItem('disable3Dgcodepreview')) {
if (JSON.parse(localStorage.getItem('disable3Dgcodepreview')) == true) {
disable3Dgcodepreview = true;
$('#disable3DgcodepreviewTick').addClass("checked");
}
} else {
disable3Dgcodepreview = false;
}
if (localStorage.getItem('disableSerialLog')) {
if (JSON.parse(localStorage.getItem('disableSerialLog')) == true) {
disableSerialLog = true;
$('#disableSerialLogTick').addClass("checked");
$('#consoletab').hide()
$('#gcodeeditortab').click()
}
} else {
disableSerialLog = false;
}
if (localStorage.getItem('disableDROupdates')) {
if (JSON.parse(localStorage.getItem('disableDROupdates')) == true) {
disableDROupdates = true;
$('#disableDROupdatesTick').addClass("checked");
}
} else {
disableDROupdates = false;
}
};
initDiagnostics();

Wyświetl plik

@ -21,6 +21,9 @@ function getChangelog() {
} }
$(document).ready(function() { $(document).ready(function() {
initDiagnostics(); // run second time to ensure checkboxes are ticked
if (!isJogWidget) { if (!isJogWidget) {
init3D(); init3D();
} }
@ -79,7 +82,7 @@ $(document).ready(function() {
editor.session.setValue(data); editor.session.setValue(data);
parseGcodeInWebWorker(data) parseGcodeInWebWorker(data)
$('#controlTab').click() $('#controlTab').click()
if (!setViewerDisableUI() || !webgl) { if (!webgl) {
$('#gcodeviewertab').click(); $('#gcodeviewertab').click();
} else { } else {
$('#gcodeeditortab').click() $('#gcodeeditortab').click()
@ -122,7 +125,7 @@ function loadFile(f) {
r.readAsText(f); r.readAsText(f);
r.onload = function(event) { r.onload = function(event) {
editor.session.setValue(this.result); editor.session.setValue(this.result);
if (!setViewerDisableUI() || !webgl) { if (webgl) {
printLog('<span class="fg-red">[ GCODE Parser ]</span><span class="fg-green"> GCODE File Loaded, please wait while we render a preview... </span>'); printLog('<span class="fg-red">[ GCODE Parser ]</span><span class="fg-green"> GCODE File Loaded, please wait while we render a preview... </span>');
} else { } else {
printLog('<span class="fg-red">[ GCODE Parser ]</span><span class="fg-green"> GCODE File Loaded </span>'); printLog('<span class="fg-red">[ GCODE Parser ]</span><span class="fg-green"> GCODE File Loaded </span>');
@ -180,12 +183,17 @@ function versionCompare(v1, v2, options) {
} }
var webgl = (function() { var webgl = (function() {
// console.log("Testing WebGL") if (disable3Dviewer) {
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch (e) {
return false; return false;
} else {
// console.log("Testing WebGL")
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch (e) {
return false;
}
} }
})(); })();
function saveGcode() { function saveGcode() {
@ -245,36 +253,36 @@ function invokeSaveAsDialog(file, fileName) {
} }
} }
function setViewerDisableUI() { // function setViewerDisableUI() {
if (localStorage.getItem('viewerDisable')) { // if (localStorage.getItem('viewerDisable')) {
if (JSON.parse(localStorage.getItem('viewerDisable')) == true) { // if (JSON.parse(localStorage.getItem('viewerDisable')) == true) {
$('#viewerdisabled').removeClass("checked"); // $('#viewerdisabled').removeClass("checked");
} else { // } else {
$('#viewerdisabled').addClass("checked"); // $('#viewerdisabled').addClass("checked");
} // }
} else { // } else {
$('#viewerdisabled').removeClass("checked"); // $('#viewerdisabled').removeClass("checked");
return false; // return false;
} // }
return (!JSON.parse(localStorage.getItem('viewerDisable'))) // return (!JSON.parse(localStorage.getItem('viewerDisable')))
} // }
//
function viewerdisable() { // function viewerdisable() {
console.log("viewerdisable") // console.log("viewerdisable")
if (localStorage.getItem('viewerDisable')) { // if (localStorage.getItem('viewerDisable')) {
if (JSON.parse(localStorage.getItem('viewerDisable')) == true) { // if (JSON.parse(localStorage.getItem('viewerDisable')) == true) {
console.log("viewerdisable disabled") // console.log("viewerdisable disabled")
localStorage.setItem('viewerDisable', false); // localStorage.setItem('viewerDisable', false);
location.reload(); // location.reload();
} else { // } else {
console.log("viewerdisable enabled") // console.log("viewerdisable enabled")
localStorage.setItem('viewerDisable', true); // localStorage.setItem('viewerDisable', true);
location.reload(); // location.reload();
} // }
} else { // } else {
console.log("viewerdisable defaulted") // console.log("viewerdisable defaulted")
localStorage.setItem('viewerDisable', false); // localStorage.setItem('viewerDisable', false);
location.reload(); // location.reload();
} // }
setViewerDisableUI() // setViewerDisableUI()
} // }

Wyświetl plik

@ -273,8 +273,10 @@ function setJogPanel(val, status) {
$('#zPos').html('0.00'); $('#zPos').html('0.00');
if (!isJogWidget && webgl) { if (!isJogWidget && webgl) {
if (!simRunning) { if (!simRunning) {
if (!setViewerDisableUI() || !webgl) { if (webgl) {
cone.visible = false; if (!disable3Drealtimepos) {
cone.visible = false;
}
} }
} }
} }
@ -296,7 +298,9 @@ function setJogPanel(val, status) {
if (!isJogWidget && webgl) { if (!isJogWidget && webgl) {
if (object) { if (object) {
if (!simRunning) { if (!simRunning) {
cone.visible = false; if (!disable3Drealtimepos) {
cone.visible = false;
}
// update3Dprogress(object.children.length) // update3Dprogress(object.children.length)
} }
} }
@ -317,8 +321,10 @@ function setJogPanel(val, status) {
} }
if (!isJogWidget && webgl) { if (!isJogWidget && webgl) {
if (!simRunning) { if (!simRunning) {
if (!setViewerDisableUI() || !webgl) { if (webgl) {
cone.visible = true; if (!disable3Drealtimepos) {
cone.visible = true;
}
} }
} }
} }
@ -337,7 +343,9 @@ function setJogPanel(val, status) {
} }
if (!isJogWidget && webgl) { if (!isJogWidget && webgl) {
if (!simRunning) { if (!simRunning) {
cone.visible = true; if (!disable3Drealtimepos) {
cone.visible = true;
}
} }
} }
} else if (val == 5) { // Alarm State } else if (val == 5) { // Alarm State
@ -356,8 +364,10 @@ function setJogPanel(val, status) {
} }
if (!isJogWidget && webgl) { if (!isJogWidget && webgl) {
if (!simRunning) { if (!simRunning) {
if (!setViewerDisableUI() || !webgl) { if (webgl) {
cone.visible = false; if (!disable3Drealtimepos) {
cone.visible = false;
}
} }
} }
} }
@ -381,7 +391,9 @@ function setJogPanel(val, status) {
$('#zPos').html('0.00'); $('#zPos').html('0.00');
if (!isJogWidget && webgl) { if (!isJogWidget && webgl) {
if (!simRunning) { if (!simRunning) {
cone.visible = false; if (!disable3Drealtimepos) {
cone.visible = false;
}
} }
} }
} }

Wyświetl plik

@ -89,55 +89,59 @@ function drawWorkspace(xmin, xmax, ymin, ymax) {
scene.fog = new THREE.Fog(0xffffff, 1, 20000); scene.fog = new THREE.Fog(0xffffff, 1, 20000);
// SKYDOME // SKYDOME
var uniforms = { if (!disable3Dskybox) {
topColor: { var uniforms = {
value: new THREE.Color(0x0077ff) topColor: {
}, value: new THREE.Color(0x0077ff)
bottomColor: { },
value: new THREE.Color(0xffffff) bottomColor: {
}, value: new THREE.Color(0xffffff)
offset: { },
value: -63 offset: {
}, value: -63
exponent: { },
value: 0.71 exponent: {
} value: 0.71
}; }
uniforms.topColor.value.copy(hemiLight.color); };
uniforms.topColor.value.copy(hemiLight.color);
scene.fog.color.copy(uniforms.bottomColor.value); scene.fog.color.copy(uniforms.bottomColor.value);
var vertexShader = document.getElementById('vertexShader').textContent; var vertexShader = document.getElementById('vertexShader').textContent;
var fragmentShader = document.getElementById('fragmentShader').textContent; var fragmentShader = document.getElementById('fragmentShader').textContent;
var skyGeo = new THREE.SphereGeometry(9900, 64, 15); var skyGeo = new THREE.SphereGeometry(9900, 64, 15);
var skyMat = new THREE.ShaderMaterial({ var skyMat = new THREE.ShaderMaterial({
vertexShader: vertexShader, vertexShader: vertexShader,
fragmentShader: fragmentShader, fragmentShader: fragmentShader,
uniforms: uniforms, uniforms: uniforms,
side: THREE.DoubleSide side: THREE.DoubleSide
}); });
sky = new THREE.Mesh(skyGeo, skyMat); sky = new THREE.Mesh(skyGeo, skyMat);
sky.name = "Skydome" sky.name = "Skydome"
workspace.add(sky); workspace.add(sky);
}
cone = new THREE.Mesh(new THREE.CylinderGeometry(0, 5, 40, 15, 1, false), new THREE.MeshPhongMaterial({ if (!disable3Drealtimepos) {
color: 0x0000ff, cone = new THREE.Mesh(new THREE.CylinderGeometry(0, 5, 40, 15, 1, false), new THREE.MeshPhongMaterial({
specular: 0x0000ff, color: 0x0000ff,
shininess: 00 specular: 0x0000ff,
})); shininess: 00
cone.overdraw = true; }));
cone.rotation.x = -90 * Math.PI / 180; cone.overdraw = true;
cone.position.x = 20; cone.rotation.x = -90 * Math.PI / 180;
cone.position.y = 0; cone.position.x = 20;
cone.position.z = 0; cone.position.y = 0;
cone.material.opacity = 0.6; cone.position.z = 0;
cone.material.transparent = true; cone.material.opacity = 0.6;
cone.castShadow = false; cone.material.transparent = true;
cone.visible = false; cone.castShadow = false;
cone.name = "Simulation Marker" cone.visible = false;
workspace.add(cone) cone.name = "Simulation Marker"
workspace.add(cone)
}
gridsystem.name = "Grid System" gridsystem.name = "Grid System"
workspace.add(gridsystem) workspace.add(gridsystem)
redrawGrid(xmin, xmax, ymin, ymax, false); redrawGrid(xmin, xmax, ymin, ymax, false);
@ -283,32 +287,33 @@ function setBullseyePosition(x, y, z) {
} }
function init3D() { function init3D() {
if (!setViewerDisableUI()) {
if (webgl) {
console.log('WebGL Support found! success: this application will work optimally on this device!');
printLog("<span class='fg-red'>[ 3D Viewer ] </span><span class='fg-green'>WebGL Support found! success: this application will work optimally on this device!</span>")
renderer = new THREE.WebGLRenderer({
autoClearColor: true,
antialias: false,
preserveDrawingBuffer: true
});
// ThreeJS Render/Control/Camera
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 20000);
camera.position.z = 295;
$('#renderArea').append(renderer.domElement); if (webgl) {
renderer.setClearColor(0xffffff, 1); // Background color of viewer = transparent console.log('WebGL Support found! success: this application will work optimally on this device!');
// renderer.setSize(window.innerWidth - 10, window.innerHeight - 10); printLog("<span class='fg-red'>[ 3D Viewer ] </span><span class='fg-green'>WebGL Support found! success: this application will work optimally on this device!</span>")
renderer.clear(); renderer = new THREE.WebGLRenderer({
autoClearColor: true,
antialias: false,
preserveDrawingBuffer: true
});
// ThreeJS Render/Control/Camera
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 20000);
camera.position.z = 295;
sceneWidth = document.getElementById("renderArea").offsetWidth, $('#renderArea').append(renderer.domElement);
sceneHeight = document.getElementById("renderArea").offsetHeight; renderer.setClearColor(0xffffff, 1); // Background color of viewer = transparent
camera.aspect = sceneWidth / sceneHeight; // renderer.setSize(window.innerWidth - 10, window.innerHeight - 10);
renderer.setSize(sceneWidth, sceneHeight) renderer.clear();
camera.updateProjectionMatrix();
sceneWidth = document.getElementById("renderArea").offsetWidth,
sceneHeight = document.getElementById("renderArea").offsetHeight;
camera.aspect = sceneWidth / sceneHeight;
renderer.setSize(sceneWidth, sceneHeight)
camera.updateProjectionMatrix();
if (!disable3Dcontrols) {
controls = new THREE.OrbitControls(camera, renderer.domElement); controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.target.set(0, 0, 0); // view direction perpendicular to XY-plane controls.target.set(0, 0, 0); // view direction perpendicular to XY-plane
@ -323,37 +328,29 @@ function init3D() {
controls.enableZoom = true; // optional controls.enableZoom = true; // optional
controls.maxDistance = 8000; // limit max zoom out controls.maxDistance = 8000; // limit max zoom out
controls.enableKeys = false; // Disable Keyboard on canvas controls.enableKeys = false; // Disable Keyboard on canvas
}
drawWorkspace();
// Picking stuff drawWorkspace();
projector = new THREE.Projector();
mouseVector = new THREE.Vector3();
raycaster.linePrecision = 1
setTimeout(function() { // Picking stuff
resetView() projector = new THREE.Projector();
animate(); mouseVector = new THREE.Vector3();
}, 200) raycaster.linePrecision = 1
setTimeout(function() {
resetView()
animate();
}, 200)
} else {
console.log('No WebGL Support found on this computer! Disabled 3D Viewer - Sorry!');
printLog('No WebGL Support found on this computer! Disabled 3D Viewer - Sorry!');
$('#gcodeviewertab').hide()
$('#consoletab').click()
return false;
};
} else { } else {
console.log('3D Viewer Disabled from the Tools and Wizards menu'); console.log('No WebGL Support found on this computer! Disabled 3D Viewer - Sorry!');
printLog('3D Viewer Disabled from the Tools and Wizards menu'); printLog('No WebGL Support found on this computer! Disabled 3D Viewer - Sorry!');
$('#gcodeviewertab').hide() $('#gcodeviewertab').hide()
$('#consoletab').click() $('#consoletab').click()
return false; return false;
} };
} }
@ -366,43 +363,10 @@ function animate() {
scene.remove(scene.children[1]) scene.remove(scene.children[1])
} }
// var documents = new THREE.Group();
// documents.name = "Documents";
// for (i = 0; i < objectsInScene.length; i++) {
// documents.add(objectsInScene[i])
// }
// scene.add(documents)
//
// var toolpaths = new THREE.Group();
// toolpaths.name = "Toolpaths";
// for (i = 0; i < toolpathsInScene.length; i++) {
//
// if (toolpathsInScene[i].userData.visible) {
// if (toolpathsInScene[i].userData.inflated) {
// if (toolpathsInScene[i].userData.inflated.userData.pretty) {
// if (toolpathsInScene[i].userData.inflated.userData.pretty.children.length > 0) {
// toolpaths.add(toolpathsInScene[i].userData.inflated.userData.pretty);
// } else {
// toolpaths.add(toolpathsInScene[i].userData.inflated);
// }
// } else {
// toolpaths.add(toolpathsInScene[i].userData.inflated);
// }
// };
// }
// }
// scene.add(toolpaths)
// if (fancysim == true) {
// scene.add(simgcodeobj)
// } else {
if (object) { if (object) {
scene.add(object) scene.add(object)
} }
// }
clearSceneFlag = false; clearSceneFlag = false;
} // end clearSceneFlag } // end clearSceneFlag
@ -415,84 +379,84 @@ function animate() {
} }
} }
function viewExtents(objecttosee) { function viewExtents(objecttosee) {
// console.log("viewExtents. object:", objecttosee); if (!disable3Dcontrols) {
// console.log("controls:", controls); // console.log("viewExtents. object:", objecttosee);
//wakeAnimate(); // console.log("controls:", controls);
//wakeAnimate();
// lets override the bounding box with a newly // lets override the bounding box with a newly
// generated one // generated one
// get its bounding box // get its bounding box
if (objecttosee) { if (objecttosee) {
// console.log(objecttosee) // console.log(objecttosee)
var helper = new THREE.BoxHelper(objecttosee); var helper = new THREE.BoxHelper(objecttosee);
helper.update(); helper.update();
var box3 = new THREE.Box3(); var box3 = new THREE.Box3();
box3.setFromObject(helper); box3.setFromObject(helper);
var minx = box3.min.x; var minx = box3.min.x;
var miny = box3.min.y; var miny = box3.min.y;
var maxx = box3.max.x; var maxx = box3.max.x;
var maxy = box3.max.y; var maxy = box3.max.y;
var minz = box3.min.z; var minz = box3.min.z;
var maxz = box3.max.z; var maxz = box3.max.z;
controls.reset(); controls.reset();
var lenx = maxx - minx; var lenx = maxx - minx;
var leny = maxy - miny; var leny = maxy - miny;
var lenz = maxz - minz; var lenz = maxz - minz;
var centerx = minx + (lenx / 2); var centerx = minx + (lenx / 2);
var centery = miny + (leny / 2); var centery = miny + (leny / 2);
var centerz = minz + (lenz / 2); var centerz = minz + (lenz / 2);
// console.log("lenx:", lenx, "leny:", leny, "lenz:", lenz); // console.log("lenx:", lenx, "leny:", leny, "lenz:", lenz);
var maxlen = Math.max(lenx, leny, lenz); var maxlen = Math.max(lenx, leny, lenz);
var dist = 2 * maxlen; var dist = 2 * maxlen;
// center camera on gcode objects center pos, but twice the maxlen // center camera on gcode objects center pos, but twice the maxlen
controls.object.position.x = centerx; controls.object.position.x = centerx;
controls.object.position.y = centery; controls.object.position.y = centery;
controls.object.position.z = centerz + dist; controls.object.position.z = centerz + dist;
controls.target.x = centerx; controls.target.x = centerx;
controls.target.y = centery; controls.target.y = centery;
controls.target.z = centerz; controls.target.z = centerz;
// console.log("maxlen:", maxlen, "dist:", dist); // console.log("maxlen:", maxlen, "dist:", dist);
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);
controls.object.fov = fov; controls.object.fov = fov;
var L = dist; var L = dist;
var camera2 = controls.object; var camera2 = controls.object;
var vector = controls.target.clone(); var vector = controls.target.clone();
var l = (new THREE.Vector3()).subVectors(camera2.position, vector).length(); var l = (new THREE.Vector3()).subVectors(camera2.position, vector).length();
var up = camera.up.clone(); var up = camera.up.clone();
var quaternion = new THREE.Quaternion(); var quaternion = new THREE.Quaternion();
// Zoom correction // Zoom correction
camera2.translateZ(L - l); camera2.translateZ(L - l);
// console.log("up:", up); // console.log("up:", up);
up.y = 1; up.y = 1;
up.x = 0; up.x = 0;
up.z = 0; up.z = 0;
quaternion.setFromAxisAngle(up, 0); quaternion.setFromAxisAngle(up, 0);
camera2.position.applyQuaternion(quaternion); camera2.position.applyQuaternion(quaternion);
up.y = 0; up.y = 0;
up.x = 1; up.x = 1;
up.z = 0; up.z = 0;
quaternion.setFromAxisAngle(up, 0); quaternion.setFromAxisAngle(up, 0);
camera2.position.applyQuaternion(quaternion); camera2.position.applyQuaternion(quaternion);
up.y = 0; up.y = 0;
up.x = 0; up.x = 0;
up.z = 1; up.z = 1;
quaternion.setFromAxisAngle(up, 0); quaternion.setFromAxisAngle(up, 0);
camera2.lookAt(vector); camera2.lookAt(vector);
controls.object.updateProjectionMatrix(); controls.object.updateProjectionMatrix();
}
} }
} }
}; };
@ -564,7 +528,9 @@ function fixRenderSize() {
//renderer.setSize(window.innerWidth, window.innerHeight); //renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = sceneWidth / sceneHeight; camera.aspect = sceneWidth / sceneHeight;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
controls.reset(); if (!disable3Dcontrols) {
controls.reset();
}
setTimeout(function() { setTimeout(function() {
resetView(); resetView();
}, 10); }, 10);

Wyświetl plik

@ -38,24 +38,26 @@ function showGrbl(bool) {
} }
function printLog(string) { function printLog(string) {
if (document.getElementById("console") !== null) { if (!disableSerialLog) {
if (string.isString) { if (document.getElementById("console") !== null) {
// split(/\r\n|\n|\r/); if (string.isString) {
string = string.replace(/\r\n|\n|\r/, "<br />"); // split(/\r\n|\n|\r/);
} string = string.replace(/\r\n|\n|\r/, "<br />");
if ($('#console p').length > 100) { }
// remove oldest if already at 300 lines if ($('#console p').length > 100) {
$('#console p').first().remove(); // remove oldest if already at 300 lines
} $('#console p').first().remove();
var template = '<p class="pf">'; }
var time = new Date(); var template = '<p class="pf">';
var time = new Date();
template += '<span class="fg-brandColor1">[' + (time.getHours() < 10 ? '0' : '') + time.getHours() + ":" + (time.getMinutes() < 10 ? '0' : '') + time.getMinutes() + ":" + (time.getSeconds() < 10 ? '0' : '') + time.getSeconds() + ']</span> '; template += '<span class="fg-brandColor1">[' + (time.getHours() < 10 ? '0' : '') + time.getHours() + ":" + (time.getMinutes() < 10 ? '0' : '') + time.getMinutes() + ":" + (time.getSeconds() < 10 ? '0' : '') + time.getSeconds() + ']</span> ';
template += string; template += string;
$('#console').append(template); $('#console').append(template);
$('#console').scrollTop(($("#console")[0].scrollHeight - $("#console").height()) + 20); $('#console').scrollTop(($("#console")[0].scrollHeight - $("#console").height()) + 20);
}
} }
} };
function initSocket() { function initSocket() {
socket = io.connect(server); // socket.io init socket = io.connect(server); // socket.io init
@ -79,7 +81,7 @@ function initSocket() {
editor.session.setValue(data); editor.session.setValue(data);
parseGcodeInWebWorker(data) parseGcodeInWebWorker(data)
$('#controlTab').click() $('#controlTab').click()
if (!setViewerDisableUI() || !webgl) { if (webgl) {
$('#gcodeviewertab').click(); $('#gcodeviewertab').click();
} else { } else {
$('#gcodeeditortab').click() $('#gcodeeditortab').click()
@ -298,41 +300,49 @@ function initSocket() {
$('#runStatus').html("Controller: " + status.comms.runStatus); $('#runStatus').html("Controller: " + status.comms.runStatus);
if (unit == "mm") { if (!disableDROupdates) {
var xpos = status.machine.position.work.x + unit; if (unit == "mm") {
var ypos = status.machine.position.work.y + unit; var xpos = status.machine.position.work.x + unit;
var zpos = status.machine.position.work.z + unit; var ypos = status.machine.position.work.y + unit;
} else if (unit == "in") { var zpos = status.machine.position.work.z + unit;
var xpos = (status.machine.position.work.x / 25.4).toFixed(2) + unit; } else if (unit == "in") {
var ypos = (status.machine.position.work.y / 25.4).toFixed(2) + unit; var xpos = (status.machine.position.work.x / 25.4).toFixed(2) + unit;
var zpos = (status.machine.position.work.z / 25.4).toFixed(2) + unit; var ypos = (status.machine.position.work.y / 25.4).toFixed(2) + unit;
} var zpos = (status.machine.position.work.z / 25.4).toFixed(2) + unit;
}
if ($('#xPos').html() != xpos) { if ($('#xPos').html() != xpos) {
$('#xPos').html(xpos); $('#xPos').html(xpos);
} }
if ($('#yPos').html() != ypos) { if ($('#yPos').html() != ypos) {
$('#yPos').html(ypos); $('#yPos').html(ypos);
} }
if ($('#zPos').html() != zpos) { if ($('#zPos').html() != zpos) {
$('#zPos').html(zpos); $('#zPos').html(zpos);
}
} else {
$('#xPos').html('disabled');
$('#yPos').html('disabled');
$('#zPos').html('disabled');
} }
if (webgl) { if (webgl) {
if (!isJogWidget) { if (!disable3Drealtimepos) {
if (!simRunning) { if (!isJogWidget) {
if (object) { if (!simRunning) {
if (object.userData.inch) { if (object) {
cone.position.x = status.machine.position.work.x * 0.0393701 // if (object.userData.inch) {
cone.position.y = status.machine.position.work.y * 0.0393701 // cone.position.x = status.machine.position.work.x * 0.0393701
cone.position.z = (parseFloat(status.machine.position.work.z * 0.0393701) + 20) // cone.position.y = status.machine.position.work.y * 0.0393701
} else { // cone.position.z = (parseFloat(status.machine.position.work.z * 0.0393701) + 20)
// } else {
cone.position.x = status.machine.position.work.x cone.position.x = status.machine.position.work.x
cone.position.y = status.machine.position.work.y cone.position.y = status.machine.position.work.y
cone.position.z = (parseFloat(status.machine.position.work.z) + 20) cone.position.z = (parseFloat(status.machine.position.work.z) + 20)
// }
} }
}
}
} }
} }
} }

Wyświetl plik

@ -59,74 +59,76 @@ function convertParsedDataToObject(parsedData) {
function parseGcodeInWebWorker(gcode) { function parseGcodeInWebWorker(gcode) {
if (!setViewerDisableUI() || !webgl) { if (webgl) {
simstop() if (!disable3Dgcodepreview) {
scene.remove(object) simstop()
object = false; scene.remove(object)
object = false;
// var worker = new Worker('lib/3dview/workers/gcodeparser.js'); // var worker = new Worker('lib/3dview/workers/gcodeparser.js');
var worker = new Worker('lib/3dview/workers/litegcodeviewer.js'); var worker = new Worker('lib/3dview/workers/litegcodeviewer.js');
worker.addEventListener('message', function(e) { worker.addEventListener('message', function(e) {
console.log('webworker message', e) console.log('webworker message', e)
if (scene.getObjectByName('gcodeobject')) { if (scene.getObjectByName('gcodeobject')) {
scene.remove(scene.getObjectByName('gcodeobject')) scene.remove(scene.getObjectByName('gcodeobject'))
object = false; object = false;
}
object = convertParsedDataToObject(e.data);
if (object && object.userData.lines.length > 1) {
worker.terminate();
scene.add(object);
if (object.userData.inch) {
// console.log(scaling)
object.scale.x = 25.4
object.scale.y = 25.4
object.scale.z = 25.4
} }
redrawGrid(Math.floor(object.userData.bbbox2.min.x), Math.ceil(object.userData.bbbox2.max.x), Math.floor(object.userData.bbbox2.min.y), Math.ceil(object.userData.bbbox2.max.y), object.userData.inch) object = convertParsedDataToObject(e.data);
// animate(); if (object && object.userData.lines.length > 1) {
setTimeout(function() { worker.terminate();
if (webgl) { scene.add(object);
$('#gcodeviewertab').click(); if (object.userData.inch) {
// console.log(scaling)
object.scale.x = 25.4
object.scale.y = 25.4
object.scale.z = 25.4
} }
clearSceneFlag = true; redrawGrid(Math.floor(object.userData.bbbox2.min.x), Math.ceil(object.userData.bbbox2.max.x), Math.floor(object.userData.bbbox2.min.y), Math.ceil(object.userData.bbbox2.max.y), object.userData.inch)
resetView();
// animate(); // animate();
var timeremain = object.userData.lines[object.userData.lines.length - 1].p2.timeMinsSum; setTimeout(function() {
if (webgl) {
if (!isNaN(timeremain)) { $('#gcodeviewertab').click();
var mins_num = parseFloat(timeremain, 10); // don't forget the second param
var hours = Math.floor(mins_num / 60);
var minutes = Math.floor((mins_num - ((hours * 3600)) / 60));
var seconds = Math.floor((mins_num * 60) - (hours * 3600) - (minutes * 60));
// Appends 0 when unit is less than 10
if (hours < 10) {
hours = "0" + hours;
} }
if (minutes < 10) { clearSceneFlag = true;
minutes = "0" + minutes; resetView();
} // animate();
if (seconds < 10) { var timeremain = object.userData.lines[object.userData.lines.length - 1].p2.timeMinsSum;
seconds = "0" + seconds;
}
var formattedTime = hours + ':' + minutes + ':' + seconds;
console.log('Remaining time: ', formattedTime)
// output formattedTime to UI here
$('#timeRemaining').html(" / " + formattedTime);
printLog("<span class='fg-red'>[ GCODE Parser ]</span><span class='fg-green'> GCODE Preview Rendered Succesfully: Estimated GCODE Run Time: </span><span class='badge inline bg-darkGreen fg-white'>" + formattedTime + "</span>")
}
}, 200);
$('#3dviewicon').removeClass('fa-pulse')
$('#3dviewlabel').html(' 3D View')
}
}, false);
worker.postMessage({ if (!isNaN(timeremain)) {
'data': gcode var mins_num = parseFloat(timeremain, 10); // don't forget the second param
}); var hours = Math.floor(mins_num / 60);
$('#3dviewicon').addClass('fa-pulse') var minutes = Math.floor((mins_num - ((hours * 3600)) / 60));
$('#3dviewlabel').html(' 3D View (rendering, please wait...)') var seconds = Math.floor((mins_num * 60) - (hours * 3600) - (minutes * 60));
// populateToolChanges(gcode)
// Appends 0 when unit is less than 10
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var formattedTime = hours + ':' + minutes + ':' + seconds;
console.log('Remaining time: ', formattedTime)
// output formattedTime to UI here
$('#timeRemaining').html(" / " + formattedTime);
printLog("<span class='fg-red'>[ GCODE Parser ]</span><span class='fg-green'> GCODE Preview Rendered Succesfully: Estimated GCODE Run Time: </span><span class='badge inline bg-darkGreen fg-white'>" + formattedTime + "</span>")
}
}, 200);
$('#3dviewicon').removeClass('fa-pulse');
$('#3dviewlabel').html(' 3D View')
}
}, false);
worker.postMessage({
'data': gcode
});
$('#3dviewicon').addClass('fa-pulse');
$('#3dviewlabel').html(' 3D View (rendering, please wait...)')
// populateToolChanges(gcode)
}
} }
}; };
@ -160,22 +162,23 @@ function sim(startindex) {
$('#runSimBtn').hide() $('#runSimBtn').hide()
$('#stopSimBtn').show() $('#stopSimBtn').show()
clearSceneFlag = true; clearSceneFlag = true;
$("#conetext").show(); if (!disable3Drealtimepos) {
cone.visible = true $("#conetext").show();
var posx = object.userData.lines[0].p2.x; //- (sizexmax/2); cone.visible = true
var posy = object.userData.lines[0].p2.y; //- (sizeymax/2); var posx = object.userData.lines[0].p2.x; //- (sizexmax/2);
var posz = object.userData.lines[0].p2.z + 20; var posy = object.userData.lines[0].p2.y; //- (sizeymax/2);
cone.position.x = posx; var posz = object.userData.lines[0].p2.z + 20;
cone.position.y = posy; cone.position.x = posx;
cone.position.z = posz; cone.position.y = posy;
cone.material = new THREE.MeshPhongMaterial({ cone.position.z = posz;
color: 0x28a745, cone.material = new THREE.MeshPhongMaterial({
specular: 0x0000ff, color: 0x28a745,
shininess: 100, specular: 0x0000ff,
opacity: 0.9, shininess: 100,
transparent: true opacity: 0.9,
}) transparent: true
})
}
simRunning = true; simRunning = true;
// timefactor = 1; // timefactor = 1;
$('#simspeedval').text(timefactor); $('#simspeedval').text(timefactor);
@ -260,24 +263,26 @@ function runSim() {
var simTimeInSec = simTime * 60; var simTimeInSec = simTime * 60;
// console.log(simTimeInSec) // console.log(simTimeInSec)
if (!object.userData.lines[simIdx].args.isFake) { if (!object.userData.lines[simIdx].args.isFake) {
TweenMax.to(cone.position, simTimeInSec, { if (!disable3Drealtimepos) {
x: posx, TweenMax.to(cone.position, simTimeInSec, {
y: posy, x: posx,
z: posz + 20, y: posy,
onComplete: function() { z: posz + 20,
if (simRunning == false) { onComplete: function() {
//return if (simRunning == false) {
simstop(); //return
} else {
simIdx++;
if (simIdx < object.userData.lines.length) {
runSim();
} else {
simstop(); simstop();
} else {
simIdx++;
if (simIdx < object.userData.lines.length) {
runSim();
} else {
simstop();
}
} }
} }
} })
}) }
} else { } else {
if (simRunning == false) { if (simRunning == false) {
//return //return
@ -350,25 +355,27 @@ function runSimArc() {
// console.log(simTimeInSec) // console.log(simTimeInSec)
if (!object.userData.lines[simIdx].args.isFake) { if (!object.userData.lines[simIdx].args.isFake) {
TweenMax.to(cone.position, simTimeInSec, { if (!disable3Drealtimepos) {
x: posx, TweenMax.to(cone.position, simTimeInSec, {
y: posy, x: posx,
z: posz + 20, y: posy,
onComplete: function() { z: posz + 20,
if (simRunning == false) { onComplete: function() {
//return if (simRunning == false) {
simstop(); //return
} else { simstop();
arcIdx++;
if (simIdx < object.userData.lines[simIdx].p2.threeObjArc.object.userData.points.length) {
runSimArc();
} else { } else {
simIdx++; arcIdx++;
runSim(); if (simIdx < object.userData.lines[simIdx].p2.threeObjArc.object.userData.points.length) {
runSimArc();
} else {
simIdx++;
runSim();
}
} }
} }
} })
}) }
} else { } else {
if (simRunning == false) { if (simRunning == false) {
//return //return
@ -393,6 +400,8 @@ function simstop() {
// timefactor = 1; // timefactor = 1;
$('#simspeedval').text(timefactor); $('#simspeedval').text(timefactor);
editor.gotoLine(0) editor.gotoLine(0)
cone.visible = false; if (!disable3Drealtimepos) {
cone.visible = false;
}
clearSceneFlag = true; clearSceneFlag = true;
} }

Wyświetl plik

@ -1,6 +1,6 @@
{ {
"name": "OpenBuildsCONTROL", "name": "OpenBuildsCONTROL",
"version": "1.0.195", "version": "1.0.196",
"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>",