add origin visualization

This commit is contained in:
Stewart Allen 2020-03-01 19:00:36 -05:00
commit eb2cf80afa
5 changed files with 100 additions and 9 deletions

View file

@ -463,6 +463,7 @@ self.kiri.license = exports.LICENSE;
view: null,
zoomSpeed: 1.0,
reverseZoom: true,
showOrigin: false,
freeLayout: true,
autoLayout: true
},
@ -2066,6 +2067,21 @@ self.kiri.license = exports.LICENSE;
restoreWorkspace(null, true);
}
function updateOrigin() {
if (!settings.controller.showOrigin) {
SPACE.platform.setOrigin();
SPACE.update();
return;
}
if (settings.process.outputOriginCenter) {
SPACE.platform.setOrigin(0,0,0);
} else {
let dev = settings.device;
SPACE.platform.setOrigin(-dev.bedWidth/2,dev.bedDepth/2,0);
}
SPACE.update();
}
function updatePlatformSize() {
var dev = settings.device,
width, depth,
@ -2078,6 +2094,7 @@ self.kiri.license = exports.LICENSE;
height
);
SPACE.platform.setHidden(width > 500 || depth > 500);
updateOrigin();
}
function restoreWorkspace(ondone, skipwidgets) {
@ -2654,6 +2671,7 @@ self.kiri.license = exports.LICENSE;
]),
layout: UC.newGroup('options'),
showOrigin: UC.newBoolean("show origin", booleanSave, {title:"show device or process origin"}),
autoLayout: UC.newBoolean("auto layout", booleanSave, {title:"automatically layout platform\nwhen new items added\nor when arrange clicked\nmore than once"}),
freeLayout: UC.newBoolean("free layout", booleanSave, {title:"permit dragable layout"}),
reverseZoom: UC.newBoolean("invert zoom", booleanSave, {title:"invert mouse wheel\nscroll zoom"}),
@ -2838,10 +2856,12 @@ self.kiri.license = exports.LICENSE;
}
function booleanSave() {
settings.controller.showOrigin = UI.showOrigin.checked;
settings.controller.autoLayout = UI.autoLayout.checked;
settings.controller.freeLayout = UI.freeLayout.checked;
settings.controller.reverseZoom = UI.reverseZoom.checked;
SPACE.view.setZoom(settings.controller.reverseZoom, settings.controller.zoomSpeed);
updateOrigin();
saveSettings();
}
@ -3334,15 +3354,15 @@ self.kiri.license = exports.LICENSE;
UI.setDeviceWidth.value = dev.bedWidth;
UI.setDeviceDepth.value = dev.bedDepth;
UI.setDeviceHeight.value = dev.maxHeight;
UI.setDeviceExtrusion.checked = dev.extrudeAbs;
UI.setDeviceOrigin.checked = proc.outputOriginCenter;
UI.setDeviceRound.checked = dev.bedRound;
UI.setDeviceOrigin.checked = proc.outputOriginCenter;
// FDM
UI.setDeviceFan.value = dev.gcodeFan;
UI.setDeviceTrack.value = dev.gcodeTrack;
UI.setDeviceLayer.value = dev.gcodeLayer.join('\n');
UI.setDeviceFilament.value = dev.filamentSize;
UI.setDeviceNozzle.value = dev.nozzleSize;
UI.setDeviceExtrusion.checked = dev.extrudeAbs;
// CAM
UI.setDeviceMaxSpindle.value = dev.spindleMax;
UI.setDeviceSpindle.value = dev.gcodeSpindle.join('\n');
@ -3389,7 +3409,7 @@ self.kiri.license = exports.LICENSE;
UI.finishingSpindle,
UI.drillSpindle
].forEach(function(e) {
e.parentNode.style.display = dev.spindleMax ? 'block' : 'none';
e.parentNode.style.display = dev.spindleMax >= 0 ? 'none' : 'block';
});
UI.deviceSave.disabled =
@ -3846,6 +3866,7 @@ self.kiri.license = exports.LICENSE;
SPACE.view.setZoom(settings.controller.reverseZoom, settings.controller.zoomSpeed);
SPACE.platform.setZOff(0.2);
UI.showOrigin.checked = settings.controller.showOrigin;
UI.freeLayout.checked = settings.controller.freeLayout;
UI.autoLayout.checked = settings.controller.autoLayout;

View file

@ -1,7 +1,7 @@
var exports = {
COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE:"See the license.md file included with the source distribution",
VERSION:"1.6.4"
VERSION:"1.6.5"
};
if (!module) var module = {};
module.exports = exports;

View file

@ -39,6 +39,7 @@ let gs_moto_space = exports;
mouseUpSelect,
mouseHover,
mouseDrag,
gridOrigin,
gridUnitMinor,
gridUnitMajor,
gridView,
@ -229,6 +230,74 @@ let gs_moto_space = exports;
Space.scene.add(gridView);
}
function setOrigin(x, y, z) {
if (gridOrigin) {
Space.scene.remove(gridOrigin);
}
if (x === undefined) {
gridOrigin = null;
return;
}
let cmat = new THREE.MeshPhongMaterial({
color: 0xcceeff,
specular: 0xcceeff,
shininess: 5,
transparent: true,
opacity: 0.5,
side: THREE.DoubleSide
});
let rmat = new THREE.MeshPhongMaterial({
color: 0x88aadd,
transparent: true,
opacity: 0.5,
side: THREE.DoubleSide
});
let PIP = Math.PI/2;
let pi1, pi2, pi3, pi4;
gridOrigin = new THREE.Group();
gridOrigin.add(pi1 = new THREE.Mesh(
new THREE.CircleGeometry(4.6, 50, PIP*0, PIP*1),
cmat
));
pi1.position.x = 0.25;
pi1.position.y = 0.25;
gridOrigin.add(pi2 = new THREE.Mesh(
new THREE.CircleGeometry(4.6, 50, PIP*1, PIP*1),
cmat
));
pi2.position.x = -0.25;
pi2.position.y = 0.25;
gridOrigin.add(pi3 = new THREE.Mesh(
new THREE.CircleGeometry(4.6, 50, PIP*2, PIP*1),
cmat
));
pi3.position.x = -0.25;
pi3.position.y = -0.25;
gridOrigin.add(pi4 = new THREE.Mesh(
new THREE.CircleGeometry(4.6, 50, PIP*3, PIP*1),
cmat
));
pi4.position.x = 0.25;
pi4.position.y = -0.25;
gridOrigin.add(new THREE.Mesh(
new THREE.RingGeometry(5, 5.5, 50),
rmat
));
gridOrigin.add(new THREE.Mesh(
new THREE.PlaneGeometry(0.5, 10),
rmat
));
gridOrigin.add(new THREE.Mesh(
new THREE.PlaneGeometry(10, 0.5),
rmat
));
gridOrigin.rotation.x = -PI2;
gridOrigin.position.x = x;
gridOrigin.position.y = z;
gridOrigin.position.z = y;
Space.scene.add(gridOrigin);
}
function refresh() {
refreshRequested = false;
viewControl.update();
@ -477,6 +546,7 @@ let gs_moto_space = exports;
tweenTo: tweenPlatform,
setSize: setPlatformSizeUpdateGrid,
setColor: setPlatformColor,
setOrigin: setOrigin,
setGrid: setGrid,
add: function(o) { WORLD.add(o) },

View file

@ -22,8 +22,8 @@
],
"scripts": {
"start": "node js/web-server debug",
"start-web": "node js/web-server nolocal",
"update": "git pull && git submodule update --recursive --remote && npm update"
"start-secure": "node js/web-server nolocal",
"update": "git pull && npm i"
},
"dependencies": {
"buffer-crc32": "^0.2.13",

View file

@ -19,7 +19,7 @@ to start a local instance of the apps. then open
### Other Start Options
```
npm run-script start-web
npm run-script start-secure
```
serves code as obfuscated, compressed bundles. this is the mode used to run on a public
web site, so you can't use "localhost" to test. to accommodate this, alias "debug" to 127.0.0.1
@ -28,6 +28,6 @@ then access the apps from http://debug:8080/
## More Information
* [Facebook Group](https://www.facebook.com/groups/660020084206828/)
* [Wiki](https://github.com/GridSpace/KiriMoto/wiki)
* [Twitter](https://twitter.com/grid_space_3d)
* [YouTube Tutorials](https://www.youtube.com/c/gridspace)
* [Twitter](https://twitter.com/grid_space_3d)
* [Wiki](https://github.com/GridSpace/grid-apps/wiki)