km: improve dark mode / switching. mt: add worker log to ui

This commit is contained in:
Stewart Allen 2022-01-07 16:46:05 -05:00
commit d0d9e99ede
5 changed files with 39 additions and 9 deletions

View file

@ -1879,16 +1879,19 @@
gridMinor = unitMM ? 5 : 25.4 / 10; gridMinor = unitMM ? 5 : 25.4 / 10;
if (updateDark) { if (updateDark) {
if (ctrl.dark) { if (ctrl.dark) {
SPACE.platform.setGrid(gridMajor, gridMinor, 0x999999, 0x333333); SPACE.platform.setFont({rulerColor:'#888888'});
SPACE.platform.opacity(0.8); SPACE.platform.setGrid(gridMajor, gridMinor, 0x666666, 0x333333);
SPACE.platform.opacity(0.05);
SPACE.sky.setColor(0); SPACE.sky.setColor(0);
DOC.body.classList.add('dark'); DOC.body.classList.add('dark');
} else { } else {
SPACE.platform.setFont({rulerColor:'#333333'});
SPACE.platform.setGrid(gridMajor, gridMinor, 0x999999, 0xcccccc); SPACE.platform.setGrid(gridMajor, gridMinor, 0x999999, 0xcccccc);
SPACE.platform.opacity(0.2); SPACE.platform.opacity(0.2);
SPACE.sky.setColor(0xffffff); SPACE.sky.setColor(0xffffff);
DOC.body.classList.remove('dark'); DOC.body.classList.remove('dark');
} }
SPACE.platform.setSize();
} }
SPACE.platform.setRulers(ruler, ruler, 1 / unitScale(), 'X', isBelt ? 'Z' : 'Y'); SPACE.platform.setRulers(ruler, ruler, 1 / unitScale(), 'X', isBelt ? 'Z' : 'Y');
// SPACE.platform.setGZOff(height/2 - 0.1); // SPACE.platform.setGZOff(height/2 - 0.1);

View file

@ -122,6 +122,9 @@ let log = mesh.api.log = {
}, },
}; };
// bind endpoint for worker to log in the ui
gapp.broker.subscribe("mesh.log", log.emit);
// create html elements // create html elements
function ui_build() { function ui_build() {
// set app version // set app version

View file

@ -18,6 +18,7 @@ if (moto.client) return;
gapp.register('moto.client', [ gapp.register('moto.client', [
"add.array", // dep: add.array "add.array", // dep: add.array
"moto.broker", // dep: moto.broker
]); ]);
function dispatch(topic, message) { function dispatch(topic, message) {
@ -211,6 +212,12 @@ let client = moto.client = {
return; return;
} }
// handle special case for broker publish
if (reply.publish) {
gapp.broker.publish(reply.publish, reply.message);
return;
}
if (worker.run === null) { if (worker.run === null) {
console.log({client_unhandled: e}); console.log({client_unhandled: e});
throw "message on idle worker"; throw "message on idle worker";

View file

@ -78,6 +78,9 @@
yon: undefined, yon: undefined,
factor: undefined, factor: undefined,
view: undefined view: undefined
},
psize = {
}, },
timers = {}, timers = {},
fontColor = '#333333', fontColor = '#333333',
@ -253,11 +256,17 @@
requestRefresh(); requestRefresh();
} }
function setPlatformSize(width, depth, height, maxz) { function setPlatformSize(
width = psize.width || 300,
depth = psize.depth || 300,
height = psize.height || 2.5,
maxz = psize.maxz
) {
psize = { width, depth, height, maxz };
if (isRound) { if (isRound) {
platform.scale.set(width || 300, height || 5, depth || 175); platform.scale.set(width, height, depth);
} else { } else {
platform.scale.set(width || 300, depth || 175, height || 5); platform.scale.set(width, depth, height);
} }
viewControl.maxDistance = Math.max(width,depth) * 4; viewControl.maxDistance = Math.max(width,depth) * 4;
updatePlatformPosition(); updatePlatformPosition();
@ -291,7 +300,7 @@
{x: width/2, z: depth/2, y: maxz}, {x: width/2, z: depth/2, y: maxz},
{x: -width/2, z: depth/2, y: maxz}, {x: -width/2, z: depth/2, y: maxz},
]; ];
SCENE.add(volume = makeLinesFromPoints(points, 0xdddddd)); SCENE.add(volume = makeLinesFromPoints(points, grid.colorMinor));
showVolume(volumeOn); showVolume(volumeOn);
} }
} }
@ -437,7 +446,10 @@
if (!unitMajor) { if (!unitMajor) {
return; return;
} }
if (unitMajor !== grid.unitMajor || unitMinor !== grid.unitMinor) { if (
unitMajor !== grid.unitMajor || unitMinor !== grid.unitMinor ||
colorMajor !== grid.colorMajor || colorMinor !== grid.colorMinor
) {
grid.unitMajor = unitMajor; grid.unitMajor = unitMajor;
grid.unitMinor = unitMinor; grid.unitMinor = unitMinor;
grid.colorMajor = colorMajor || grid.colorMajor; grid.colorMajor = colorMajor || grid.colorMajor;
@ -1189,12 +1201,12 @@
trackPlane.rotation.x = PI2; trackPlane.rotation.x = PI2;
let sky = new THREE.Mesh( let sky = new THREE.Mesh(
new THREE.BoxGeometry(50000, 50000, 50000, 1, 1, 1), new THREE.BoxGeometry(3000, 3000, 3000, 1, 1, 1),
skyMaterial = skyMaterial =
new THREE.MeshBasicMaterial({ color: skyColor, side: THREE.DoubleSide }) new THREE.MeshBasicMaterial({ color: skyColor, side: THREE.DoubleSide })
), ),
skygrid = new THREE.Mesh( skygrid = new THREE.Mesh(
new THREE.BoxGeometry(5000, 5000, 5000, 10, 10, 10), new THREE.BoxGeometry(3000, 3000, 3000, 10, 10, 10),
skyGridMaterial = skyGridMaterial =
new THREE.MeshBasicMaterial({ color: skyGridColor, side: THREE.DoubleSide }) new THREE.MeshBasicMaterial({ color: skyGridColor, side: THREE.DoubleSide })
); );

View file

@ -34,6 +34,11 @@ const dispatch = moto.worker = {
} }
}, },
// allow workers to publish messages on the client side
publish(topic, message) {
dispatch.send({publish: topic, message});
},
ready() { ready() {
dispatch.send({ready: true}); dispatch.send({ready: true});
}, },