From 1a7e97462bea21555e45d6c92630b8da223aaaa5 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 26 Sep 2022 13:28:31 -0400 Subject: [PATCH] fix line width override in preview. add more lighting debug --- src/kiri-mode/fdm/prepare.js | 1 + src/kiri/consts.js | 3 ++- src/kiri/function.js | 3 ++- src/kiri/render.js | 3 ++- src/kiri/widget.js | 2 +- src/moto/space.js | 20 +++++++++++--------- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/kiri-mode/fdm/prepare.js b/src/kiri-mode/fdm/prepare.js index cd46a780..f6cc3df5 100644 --- a/src/kiri-mode/fdm/prepare.js +++ b/src/kiri-mode/fdm/prepare.js @@ -770,6 +770,7 @@ FDM.prepare = function(widgets, settings, update) { print.render = render.path(output, (progress, layer) => { update(0.5 + progress * 0.5, "render", layer); }, { + lineWidth: settings.process.sliceLineWidth, toolMode: settings.pmode === 2, tools: device.extruders, thin: isThin, diff --git a/src/kiri/consts.js b/src/kiri/consts.js index 7d613ccd..7a14340d 100644 --- a/src/kiri/consts.js +++ b/src/kiri/consts.js @@ -15,7 +15,8 @@ const COLOR = { slicing_opacity: 0.5, sliced_opacity: 0.0, cam_preview: 0x888888, - cam_preview_opacity: 0.2, + cam_preview_opacity_dark: 0.2, + cam_preview_opacity: 0.1, cam_sliced_opacity: 0.2 }; diff --git a/src/kiri/function.js b/src/kiri/function.js index 3825b54c..4442481a 100644 --- a/src/kiri/function.js +++ b/src/kiri/function.js @@ -265,6 +265,7 @@ function preparePreview(callback, scale = 1, offset = 0) { hide.slider(true); const isCam = mode.is_cam(), pMode = settings.mode; + const isDark = api.space.is_dark(); const isBelt = device.bedBelt || false; view.set_preview(); @@ -272,7 +273,7 @@ function preparePreview(callback, scale = 1, offset = 0) { event.emit('preview.begin', pMode); if (isCam) { - api.widgets.opacity(COLOR.cam_preview_opacity); + api.widgets.opacity(isDark ? COLOR.cam_preview_opacity_dark : COLOR.cam_preview_opacity); api.widgets.each(widget => { widget.setColor(COLOR.cam_preview); }); diff --git a/src/kiri/render.js b/src/kiri/render.js index 2801d62e..9316d3ed 100644 --- a/src/kiri/render.js +++ b/src/kiri/render.js @@ -56,6 +56,7 @@ function path(levels, update, opts = {}) { const arrowSize = arrowAll ? 0.2 : 0.4; const layers = []; const toolMode = opts.toolMode; + const lineWidth = opts.lineWidth; const moveOpt = { face: moveColor, @@ -125,7 +126,7 @@ function path(levels, update, opts = {}) { toolid = toolid || 0; const array = prints[toolid] = prints[toolid] || []; const tool = tools[toolid] || {}; - array.width = (tool.extNozzle || 1) / 2; + array.width = (lineWidth || tool.extNozzle || 1) / 2; array.push(poly); emits++; }; diff --git a/src/kiri/widget.js b/src/kiri/widget.js index d1a91260..6cc6c603 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -290,7 +290,7 @@ class Widget { side: THREE.DoubleSide, color: 0xffff00, specular: 0x202020, - shininess: 125, + shininess: 120, transparent: true, opacity: solid_opacity, clipIntersection: false diff --git a/src/moto/space.js b/src/moto/space.js index 67864a2e..cdbd987b 100644 --- a/src/moto/space.js +++ b/src/moto/space.js @@ -280,24 +280,28 @@ gapp.register("moto.space", [], (root, exports) => { switch (mode) { case 0: array = [ addLight( x1, y0, z1, intensity * 1.5), - addLight( x0, y1, -z1, intensity * 0.7)]; break; + addLight( x0, y1, -z1, intensity * 0.7)]; + break; case 1: array = [ addLight( x1, y1, z1, intensity * 2.5), addLight( x0, y1, -z1, intensity * 0.5), addLight( x0, y0, z1, intensity * 2.5, 0xeeeeee), - addLight( x1, y0, -z1, intensity * 0.5, 0xeeeeee)]; break; + addLight( x1, y0, -z1, intensity * 0.5, 0xeeeeee)]; + break; case 2: array = [ addLight( x1, y1, z1, intensity * 2.5), addLight( x0, y1, -z1, intensity * 0.5), addLight( x0, y0, z1, intensity * 2.5, 0xeeeeee), addLight( x1, y0, -z1, intensity * 0.5, 0xeeeeee), addLight( 0, 0, z2, intensity * 1.2), - addLight( 0, 0, -z2, intensity * 0.8)]; break; + addLight( 0, 0, -z2, intensity * 0.8)]; + break; } - // update tracking cam intensity - cameraLight.intensity = intensity; lightInfo.array = array; + lightInfo.camera = cameraLight; + lightInfo.ambient = skyAmbient; + requestRefresh(); } function updatePlatformPosition() { @@ -1120,10 +1124,8 @@ gapp.register("moto.space", [], (root, exports) => { // camera.updateProjectionMatrix(); }, - lightMode: (mode, intensity) => { - lightInfo.mode = mode; - if (intensity) lightInfo.intensity = intensity; - updateLights(); + lightInfo: () => { + setTimeout(updateLights, 0); return lightInfo; } },