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.194: Added option to disable 3D Viewer for slow machines
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 class="divider fg-lightGray"></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>
</div>
@ -335,6 +333,31 @@
</div>
<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;">
<button class="ribbon-button" onclick="socket.emit('clearAlarm', 2)">
<span class="icon">
@ -1222,12 +1245,15 @@
</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-ui.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="js/diagnostics.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>

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

@ -633,4 +633,4 @@ var grblConfigDesc = {
$130: "This sets the maximum travel from end to end for each axis in mm. This is only useful if you have soft limits (and homing) enabled, as this is only used by Grbl's soft limit feature to check if you have exceeded your machine limits with a motion command.",
$131: "This sets the maximum travel from end to end for each axis in mm. This is only useful if you have soft limits (and homing) enabled, as this is only used by Grbl's soft limit feature to check if you have exceeded your machine limits with a motion command.",
$132: "This sets the maximum travel from end to end for each axis in mm. This is only useful if you have soft limits (and homing) enabled, as this is only used by Grbl's soft limit feature to check if you have exceeded your machine limits with a motion command."
}
}

Wyświetl plik

@ -21,6 +21,9 @@ function getChangelog() {
}
$(document).ready(function() {
initDiagnostics(); // run second time to ensure checkboxes are ticked
if (!isJogWidget) {
init3D();
}
@ -79,7 +82,7 @@ $(document).ready(function() {
editor.session.setValue(data);
parseGcodeInWebWorker(data)
$('#controlTab').click()
if (!setViewerDisableUI() || !webgl) {
if (!webgl) {
$('#gcodeviewertab').click();
} else {
$('#gcodeeditortab').click()
@ -122,7 +125,7 @@ function loadFile(f) {
r.readAsText(f);
r.onload = function(event) {
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>');
} else {
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() {
// console.log("Testing WebGL")
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch (e) {
if (disable3Dviewer) {
return false;
} else {
// console.log("Testing WebGL")
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch (e) {
return false;
}
}
})();
function saveGcode() {
@ -245,36 +253,36 @@ function invokeSaveAsDialog(file, fileName) {
}
}
function setViewerDisableUI() {
if (localStorage.getItem('viewerDisable')) {
if (JSON.parse(localStorage.getItem('viewerDisable')) == true) {
$('#viewerdisabled').removeClass("checked");
} else {
$('#viewerdisabled').addClass("checked");
}
} else {
$('#viewerdisabled').removeClass("checked");
return false;
}
return (!JSON.parse(localStorage.getItem('viewerDisable')))
}
function viewerdisable() {
console.log("viewerdisable")
if (localStorage.getItem('viewerDisable')) {
if (JSON.parse(localStorage.getItem('viewerDisable')) == true) {
console.log("viewerdisable disabled")
localStorage.setItem('viewerDisable', false);
location.reload();
} else {
console.log("viewerdisable enabled")
localStorage.setItem('viewerDisable', true);
location.reload();
}
} else {
console.log("viewerdisable defaulted")
localStorage.setItem('viewerDisable', false);
location.reload();
}
setViewerDisableUI()
}
// function setViewerDisableUI() {
// if (localStorage.getItem('viewerDisable')) {
// if (JSON.parse(localStorage.getItem('viewerDisable')) == true) {
// $('#viewerdisabled').removeClass("checked");
// } else {
// $('#viewerdisabled').addClass("checked");
// }
// } else {
// $('#viewerdisabled').removeClass("checked");
// return false;
// }
// return (!JSON.parse(localStorage.getItem('viewerDisable')))
// }
//
// function viewerdisable() {
// console.log("viewerdisable")
// if (localStorage.getItem('viewerDisable')) {
// if (JSON.parse(localStorage.getItem('viewerDisable')) == true) {
// console.log("viewerdisable disabled")
// localStorage.setItem('viewerDisable', false);
// location.reload();
// } else {
// console.log("viewerdisable enabled")
// localStorage.setItem('viewerDisable', true);
// location.reload();
// }
// } else {
// console.log("viewerdisable defaulted")
// localStorage.setItem('viewerDisable', false);
// location.reload();
// }
// setViewerDisableUI()
// }

Wyświetl plik

@ -273,8 +273,10 @@ function setJogPanel(val, status) {
$('#zPos').html('0.00');
if (!isJogWidget && webgl) {
if (!simRunning) {
if (!setViewerDisableUI() || !webgl) {
cone.visible = false;
if (webgl) {
if (!disable3Drealtimepos) {
cone.visible = false;
}
}
}
}
@ -296,7 +298,9 @@ function setJogPanel(val, status) {
if (!isJogWidget && webgl) {
if (object) {
if (!simRunning) {
cone.visible = false;
if (!disable3Drealtimepos) {
cone.visible = false;
}
// update3Dprogress(object.children.length)
}
}
@ -317,8 +321,10 @@ function setJogPanel(val, status) {
}
if (!isJogWidget && webgl) {
if (!simRunning) {
if (!setViewerDisableUI() || !webgl) {
cone.visible = true;
if (webgl) {
if (!disable3Drealtimepos) {
cone.visible = true;
}
}
}
}
@ -337,7 +343,9 @@ function setJogPanel(val, status) {
}
if (!isJogWidget && webgl) {
if (!simRunning) {
cone.visible = true;
if (!disable3Drealtimepos) {
cone.visible = true;
}
}
}
} else if (val == 5) { // Alarm State
@ -356,8 +364,10 @@ function setJogPanel(val, status) {
}
if (!isJogWidget && webgl) {
if (!simRunning) {
if (!setViewerDisableUI() || !webgl) {
cone.visible = false;
if (webgl) {
if (!disable3Drealtimepos) {
cone.visible = false;
}
}
}
}
@ -381,7 +391,9 @@ function setJogPanel(val, status) {
$('#zPos').html('0.00');
if (!isJogWidget && webgl) {
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);
// SKYDOME
var uniforms = {
topColor: {
value: new THREE.Color(0x0077ff)
},
bottomColor: {
value: new THREE.Color(0xffffff)
},
offset: {
value: -63
},
exponent: {
value: 0.71
}
};
uniforms.topColor.value.copy(hemiLight.color);
if (!disable3Dskybox) {
var uniforms = {
topColor: {
value: new THREE.Color(0x0077ff)
},
bottomColor: {
value: new THREE.Color(0xffffff)
},
offset: {
value: -63
},
exponent: {
value: 0.71
}
};
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 fragmentShader = document.getElementById('fragmentShader').textContent;
var vertexShader = document.getElementById('vertexShader').textContent;
var fragmentShader = document.getElementById('fragmentShader').textContent;
var skyGeo = new THREE.SphereGeometry(9900, 64, 15);
var skyMat = new THREE.ShaderMaterial({
vertexShader: vertexShader,
fragmentShader: fragmentShader,
uniforms: uniforms,
side: THREE.DoubleSide
});
var skyGeo = new THREE.SphereGeometry(9900, 64, 15);
var skyMat = new THREE.ShaderMaterial({
vertexShader: vertexShader,
fragmentShader: fragmentShader,
uniforms: uniforms,
side: THREE.DoubleSide
});
sky = new THREE.Mesh(skyGeo, skyMat);
sky.name = "Skydome"
workspace.add(sky);
sky = new THREE.Mesh(skyGeo, skyMat);
sky.name = "Skydome"
workspace.add(sky);
}
cone = new THREE.Mesh(new THREE.CylinderGeometry(0, 5, 40, 15, 1, false), new THREE.MeshPhongMaterial({
color: 0x0000ff,
specular: 0x0000ff,
shininess: 00
}));
cone.overdraw = true;
cone.rotation.x = -90 * Math.PI / 180;
cone.position.x = 20;
cone.position.y = 0;
cone.position.z = 0;
cone.material.opacity = 0.6;
cone.material.transparent = true;
cone.castShadow = false;
cone.visible = false;
cone.name = "Simulation Marker"
workspace.add(cone)
if (!disable3Drealtimepos) {
cone = new THREE.Mesh(new THREE.CylinderGeometry(0, 5, 40, 15, 1, false), new THREE.MeshPhongMaterial({
color: 0x0000ff,
specular: 0x0000ff,
shininess: 00
}));
cone.overdraw = true;
cone.rotation.x = -90 * Math.PI / 180;
cone.position.x = 20;
cone.position.y = 0;
cone.position.z = 0;
cone.material.opacity = 0.6;
cone.material.transparent = true;
cone.castShadow = false;
cone.visible = false;
cone.name = "Simulation Marker"
workspace.add(cone)
}
gridsystem.name = "Grid System"
workspace.add(gridsystem)
redrawGrid(xmin, xmax, ymin, ymax, false);
@ -283,32 +287,33 @@ function setBullseyePosition(x, y, z) {
}
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);
renderer.setClearColor(0xffffff, 1); // Background color of viewer = transparent
// renderer.setSize(window.innerWidth - 10, window.innerHeight - 10);
renderer.clear();
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;
sceneWidth = document.getElementById("renderArea").offsetWidth,
sceneHeight = document.getElementById("renderArea").offsetHeight;
camera.aspect = sceneWidth / sceneHeight;
renderer.setSize(sceneWidth, sceneHeight)
camera.updateProjectionMatrix();
$('#renderArea').append(renderer.domElement);
renderer.setClearColor(0xffffff, 1); // Background color of viewer = transparent
// renderer.setSize(window.innerWidth - 10, window.innerHeight - 10);
renderer.clear();
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.target.set(0, 0, 0); // view direction perpendicular to XY-plane
@ -323,37 +328,29 @@ function init3D() {
controls.enableZoom = true; // optional
controls.maxDistance = 8000; // limit max zoom out
controls.enableKeys = false; // Disable Keyboard on canvas
}
drawWorkspace();
// Picking stuff
projector = new THREE.Projector();
mouseVector = new THREE.Vector3();
raycaster.linePrecision = 1
drawWorkspace();
setTimeout(function() {
resetView()
animate();
}, 200)
// Picking stuff
projector = new THREE.Projector();
mouseVector = new THREE.Vector3();
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 {
console.log('3D Viewer Disabled from the Tools and Wizards menu');
printLog('3D Viewer Disabled from the Tools and Wizards menu');
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;
}
};
}
@ -366,43 +363,10 @@ function animate() {
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) {
scene.add(object)
}
// }
clearSceneFlag = false;
} // end clearSceneFlag
@ -415,84 +379,84 @@ function animate() {
}
}
function viewExtents(objecttosee) {
// console.log("viewExtents. object:", objecttosee);
// console.log("controls:", controls);
//wakeAnimate();
if (!disable3Dcontrols) {
// console.log("viewExtents. object:", objecttosee);
// console.log("controls:", controls);
//wakeAnimate();
// lets override the bounding box with a newly
// generated one
// get its bounding box
if (objecttosee) {
// console.log(objecttosee)
var helper = new THREE.BoxHelper(objecttosee);
helper.update();
var box3 = new THREE.Box3();
box3.setFromObject(helper);
var minx = box3.min.x;
var miny = box3.min.y;
var maxx = box3.max.x;
var maxy = box3.max.y;
var minz = box3.min.z;
var maxz = box3.max.z;
// lets override the bounding box with a newly
// generated one
// get its bounding box
if (objecttosee) {
// console.log(objecttosee)
var helper = new THREE.BoxHelper(objecttosee);
helper.update();
var box3 = new THREE.Box3();
box3.setFromObject(helper);
var minx = box3.min.x;
var miny = box3.min.y;
var maxx = box3.max.x;
var maxy = box3.max.y;
var minz = box3.min.z;
var maxz = box3.max.z;
controls.reset();
controls.reset();
var lenx = maxx - minx;
var leny = maxy - miny;
var lenz = maxz - minz;
var centerx = minx + (lenx / 2);
var centery = miny + (leny / 2);
var centerz = minz + (lenz / 2);
var lenx = maxx - minx;
var leny = maxy - miny;
var lenz = maxz - minz;
var centerx = minx + (lenx / 2);
var centery = miny + (leny / 2);
var centerz = minz + (lenz / 2);
// console.log("lenx:", lenx, "leny:", leny, "lenz:", lenz);
var maxlen = Math.max(lenx, leny, lenz);
var dist = 2 * maxlen;
// center camera on gcode objects center pos, but twice the maxlen
controls.object.position.x = centerx;
controls.object.position.y = centery;
controls.object.position.z = centerz + dist;
controls.target.x = centerx;
controls.target.y = centery;
controls.target.z = centerz;
// console.log("maxlen:", maxlen, "dist:", dist);
var fov = 2.2 * Math.atan(maxlen / (2 * dist)) * (180 / Math.PI);
// console.log("new fov:", fov, " old fov:", controls.object.fov);
if (isNaN(fov)) {
// console.log("giving up on viewing extents because fov could not be calculated");
return;
} else {
// console.log("fov: ", fov);
controls.object.fov = fov;
var L = dist;
var camera2 = controls.object;
var vector = controls.target.clone();
var l = (new THREE.Vector3()).subVectors(camera2.position, vector).length();
var up = camera.up.clone();
var quaternion = new THREE.Quaternion();
// console.log("lenx:", lenx, "leny:", leny, "lenz:", lenz);
var maxlen = Math.max(lenx, leny, lenz);
var dist = 2 * maxlen;
// center camera on gcode objects center pos, but twice the maxlen
controls.object.position.x = centerx;
controls.object.position.y = centery;
controls.object.position.z = centerz + dist;
controls.target.x = centerx;
controls.target.y = centery;
controls.target.z = centerz;
// console.log("maxlen:", maxlen, "dist:", dist);
var fov = 2.2 * Math.atan(maxlen / (2 * dist)) * (180 / Math.PI);
// console.log("new fov:", fov, " old fov:", controls.object.fov);
if (isNaN(fov)) {
// console.log("giving up on viewing extents because fov could not be calculated");
return;
} else {
// console.log("fov: ", fov);
controls.object.fov = fov;
var L = dist;
var camera2 = controls.object;
var vector = controls.target.clone();
var l = (new THREE.Vector3()).subVectors(camera2.position, vector).length();
var up = camera.up.clone();
var quaternion = new THREE.Quaternion();
// Zoom correction
camera2.translateZ(L - l);
// console.log("up:", up);
up.y = 1;
up.x = 0;
up.z = 0;
quaternion.setFromAxisAngle(up, 0);
camera2.position.applyQuaternion(quaternion);
up.y = 0;
up.x = 1;
up.z = 0;
quaternion.setFromAxisAngle(up, 0);
camera2.position.applyQuaternion(quaternion);
up.y = 0;
up.x = 0;
up.z = 1;
quaternion.setFromAxisAngle(up, 0);
camera2.lookAt(vector);
controls.object.updateProjectionMatrix();
// Zoom correction
camera2.translateZ(L - l);
// console.log("up:", up);
up.y = 1;
up.x = 0;
up.z = 0;
quaternion.setFromAxisAngle(up, 0);
camera2.position.applyQuaternion(quaternion);
up.y = 0;
up.x = 1;
up.z = 0;
quaternion.setFromAxisAngle(up, 0);
camera2.position.applyQuaternion(quaternion);
up.y = 0;
up.x = 0;
up.z = 1;
quaternion.setFromAxisAngle(up, 0);
camera2.lookAt(vector);
controls.object.updateProjectionMatrix();
}
}
}
};
@ -564,7 +528,9 @@ function fixRenderSize() {
//renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = sceneWidth / sceneHeight;
camera.updateProjectionMatrix();
controls.reset();
if (!disable3Dcontrols) {
controls.reset();
}
setTimeout(function() {
resetView();
}, 10);

Wyświetl plik

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

Wyświetl plik

@ -59,74 +59,76 @@ function convertParsedDataToObject(parsedData) {
function parseGcodeInWebWorker(gcode) {
if (!setViewerDisableUI() || !webgl) {
simstop()
scene.remove(object)
object = false;
if (webgl) {
if (!disable3Dgcodepreview) {
simstop()
scene.remove(object)
object = false;
// var worker = new Worker('lib/3dview/workers/gcodeparser.js');
var worker = new Worker('lib/3dview/workers/litegcodeviewer.js');
worker.addEventListener('message', function(e) {
console.log('webworker message', e)
if (scene.getObjectByName('gcodeobject')) {
scene.remove(scene.getObjectByName('gcodeobject'))
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
// var worker = new Worker('lib/3dview/workers/gcodeparser.js');
var worker = new Worker('lib/3dview/workers/litegcodeviewer.js');
worker.addEventListener('message', function(e) {
console.log('webworker message', e)
if (scene.getObjectByName('gcodeobject')) {
scene.remove(scene.getObjectByName('gcodeobject'))
object = false;
}
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)
// animate();
setTimeout(function() {
if (webgl) {
$('#gcodeviewertab').click();
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
}
clearSceneFlag = true;
resetView();
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)
// animate();
var timeremain = object.userData.lines[object.userData.lines.length - 1].p2.timeMinsSum;
if (!isNaN(timeremain)) {
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;
setTimeout(function() {
if (webgl) {
$('#gcodeviewertab').click();
}
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);
clearSceneFlag = true;
resetView();
// animate();
var timeremain = object.userData.lines[object.userData.lines.length - 1].p2.timeMinsSum;
worker.postMessage({
'data': gcode
});
$('#3dviewicon').addClass('fa-pulse')
$('#3dviewlabel').html(' 3D View (rendering, please wait...)')
// populateToolChanges(gcode)
if (!isNaN(timeremain)) {
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) {
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()
$('#stopSimBtn').show()
clearSceneFlag = true;
$("#conetext").show();
cone.visible = true
var posx = object.userData.lines[0].p2.x; //- (sizexmax/2);
var posy = object.userData.lines[0].p2.y; //- (sizeymax/2);
var posz = object.userData.lines[0].p2.z + 20;
cone.position.x = posx;
cone.position.y = posy;
cone.position.z = posz;
cone.material = new THREE.MeshPhongMaterial({
color: 0x28a745,
specular: 0x0000ff,
shininess: 100,
opacity: 0.9,
transparent: true
})
if (!disable3Drealtimepos) {
$("#conetext").show();
cone.visible = true
var posx = object.userData.lines[0].p2.x; //- (sizexmax/2);
var posy = object.userData.lines[0].p2.y; //- (sizeymax/2);
var posz = object.userData.lines[0].p2.z + 20;
cone.position.x = posx;
cone.position.y = posy;
cone.position.z = posz;
cone.material = new THREE.MeshPhongMaterial({
color: 0x28a745,
specular: 0x0000ff,
shininess: 100,
opacity: 0.9,
transparent: true
})
}
simRunning = true;
// timefactor = 1;
$('#simspeedval').text(timefactor);
@ -260,24 +263,26 @@ function runSim() {
var simTimeInSec = simTime * 60;
// console.log(simTimeInSec)
if (!object.userData.lines[simIdx].args.isFake) {
TweenMax.to(cone.position, simTimeInSec, {
x: posx,
y: posy,
z: posz + 20,
onComplete: function() {
if (simRunning == false) {
//return
simstop();
} else {
simIdx++;
if (simIdx < object.userData.lines.length) {
runSim();
} else {
if (!disable3Drealtimepos) {
TweenMax.to(cone.position, simTimeInSec, {
x: posx,
y: posy,
z: posz + 20,
onComplete: function() {
if (simRunning == false) {
//return
simstop();
} else {
simIdx++;
if (simIdx < object.userData.lines.length) {
runSim();
} else {
simstop();
}
}
}
}
})
})
}
} else {
if (simRunning == false) {
//return
@ -350,25 +355,27 @@ function runSimArc() {
// console.log(simTimeInSec)
if (!object.userData.lines[simIdx].args.isFake) {
TweenMax.to(cone.position, simTimeInSec, {
x: posx,
y: posy,
z: posz + 20,
onComplete: function() {
if (simRunning == false) {
//return
simstop();
} else {
arcIdx++;
if (simIdx < object.userData.lines[simIdx].p2.threeObjArc.object.userData.points.length) {
runSimArc();
if (!disable3Drealtimepos) {
TweenMax.to(cone.position, simTimeInSec, {
x: posx,
y: posy,
z: posz + 20,
onComplete: function() {
if (simRunning == false) {
//return
simstop();
} else {
simIdx++;
runSim();
arcIdx++;
if (simIdx < object.userData.lines[simIdx].p2.threeObjArc.object.userData.points.length) {
runSimArc();
} else {
simIdx++;
runSim();
}
}
}
}
})
})
}
} else {
if (simRunning == false) {
//return
@ -393,6 +400,8 @@ function simstop() {
// timefactor = 1;
$('#simspeedval').text(timefactor);
editor.gotoLine(0)
cone.visible = false;
if (!disable3Drealtimepos) {
cone.visible = false;
}
clearSceneFlag = true;
}

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "OpenBuildsCONTROL",
"version": "1.0.195",
"version": "1.0.196",
"license": "AGPL-3.0",
"description": "Machine Interface Driver for OpenBuilds",
"author": "github.com/openbuilds <webmaster@openbuilds.com>",