diff --git a/src/kiri/app/alerts.js b/src/kiri/app/alerts.js index 6fa72f1f..a54f1dac 100644 --- a/src/kiri/app/alerts.js +++ b/src/kiri/app/alerts.js @@ -82,36 +82,14 @@ function update(clear) { } } -/** - * Update progress bar display. - * In debug mode, also shows progress status message. - * @param {number} [value=0] - Progress value (0.0 to 1.0) - * @param {string} [msg] - Optional status message to display - */ -function progress(value = 0, msg) { - value = (value * 100).round(4); - api.ui.progress.width = value+'%'; - if (self.debug) { - // console.log(msg, value.round(2)); - api.ui.prostatus.style.display = 'flex'; - if (msg) { - api.ui.prostatus.innerHTML = msg; - } else { - api.ui.prostatus.innerHTML = ''; - } - } -} - export { hide, show, - update, - progress + update }; export default { hide, show, - update, - progress + update }; diff --git a/src/kiri/app/api.js b/src/kiri/app/api.js index 7ecceb8b..d7520350 100644 --- a/src/kiri/app/api.js +++ b/src/kiri/app/api.js @@ -238,7 +238,7 @@ export const api = { import() { api.ui.import.style.display = '' }, layer: visuals.set_visible_layer, local() { console.trace('deprecated') }, - progress: alerts.progress, + progress: visuals.set_progress, slices: visuals.show_slices, tools: showTools }, diff --git a/src/kiri/app/init/sync.js b/src/kiri/app/init/sync.js index 93b10010..bff4f9c9 100644 --- a/src/kiri/app/init/sync.js +++ b/src/kiri/app/init/sync.js @@ -165,7 +165,7 @@ function ui_sync() { preferences.setThreaded(true); preferences.lineTypeSave(); preferences.detailSave(); - preferences.updateStats(); + api.visuals.update_stats(); // optional set-and-lock mode (hides mode menu) let SETMODE = SETUP.mode ? SETUP.mode[0] : null; diff --git a/src/kiri/app/preferences.js b/src/kiri/app/preferences.js index c3e3cc01..8facac53 100644 --- a/src/kiri/app/preferences.js +++ b/src/kiri/app/preferences.js @@ -6,12 +6,10 @@ import { base } from '../../geo/base.js'; import { space } from '../../moto/space.js'; let { client, platform } = api; -let ui, statsTimer; // Lazy initialization to avoid circular dependencies function getUI() { - if (!ui) ui = api.ui; - return ui; + return api.ui; } function settings() { @@ -107,7 +105,7 @@ function booleanSave() { // platform.layout(); api.conf.save(); api.platform.update_size(); - updateStats(); + api.visuals.update_stats(); updateDrawer(); api.event.emit('boolean.update'); space.view.setProjection(control.ortho ? 'orthographic' : 'perspective'); @@ -119,34 +117,6 @@ function updateDrawer() { $c('app', scrolls ? '' : 'hide-scroll', scrolls ? 'hide-scroll' : ''); } -function updateStats() { - if (self.debug !== true) { - return; - } - console.log('updateStats()'); - const ui = getUI(); - let { div, fps, rms, rnfo } = ui.stats; - div.style.display = 'flex'; - clearTimeout(statsTimer); - statsTimer = setInterval(() => { - const nrms = space.view.getRMS().toFixed(1); - const nfps = space.view.getFPS().toFixed(1); - const rend = space.renderInfo(); - const { memory, render } = rend; - if (nfps !== fps.innerText) { - fps.innerText = nfps; - } - if (nrms !== rms.innerText) { - rms.innerText = nrms; - } - if (rnfo.offsetParent !== null) { - rnfo.innerHTML = Object.entries({ ...memory, ...render, render_ms: nrms, frames_sec: nfps }).map(row => { - return `
${row[0]}
` - }).join(''); - } - }, 100); -} - export const preferences = { unitsSave, aniMeshSave, @@ -155,6 +125,5 @@ export const preferences = { speedSave, setThreaded, booleanSave, - updateDrawer, - updateStats + updateDrawer }; diff --git a/src/kiri/app/visuals.js b/src/kiri/app/visuals.js index d9ef410f..3e7201a5 100644 --- a/src/kiri/app/visuals.js +++ b/src/kiri/app/visuals.js @@ -1,9 +1,11 @@ /** Copyright Stewart Allen -- All Rights Reserved */ import { api } from './api.js'; +import { base } from '../../geo/base.js'; import { consts } from '../core/consts.js'; import { settings } from './conf/manager.js'; -import { space as SPACE } from '../../moto/space.js'; +import { space } from '../../moto/space.js'; + import STACKS from './stacks.js'; const { COLOR, VIEWS } = consts; @@ -111,7 +113,7 @@ function setVisibleLayer(h, l) { */ function setWireframe(bool, color, opacity) { api.widgets.each(function(w) { w.setWireframe(bool, color, opacity) }); - SPACE.update(); + space.update(); } /** @@ -129,7 +131,7 @@ function setEdges(bool) { } bool = api.local.getBoolean('model.edges'); api.widgets.each(w => w.setEdges(bool)); - SPACE.update(); + space.update(); } /** @@ -207,7 +209,7 @@ function showSlices(layer) { updateSlider(); // STACKS.setRange is called by slider callback - SPACE.update(); + space.update(); } /** @@ -239,7 +241,59 @@ function updateStackLabelState() { } } +/** + * Update progress bar display. + * In debug mode, also shows progress status message. + * @param {number} [value=0] - Progress value (0.0 to 1.0) + * @param {string} [msg] - Optional status message to display + */ +function setProgress(value = 0, msg) { + value = (value * 100).round(4); + api.ui.progress.width = value+'%'; + if (self.debug) { + // console.log(msg, value.round(2)); + api.ui.prostatus.style.display = 'flex'; + if (msg) { + api.ui.prostatus.innerHTML = msg; + } else { + api.ui.prostatus.innerHTML = ''; + } + } +} + +let statsTimer; + +function updateStats() { + clearTimeout(statsTimer); + let { div, fps, rms, rnfo } = api.ui.stats; + if (api.devel.enabled === false) { + fps.innerText = ''; + rms.innerText = ''; + rnfo.innerHTML = ''; + return; + } + div.style.display = 'flex'; + statsTimer = setInterval(() => { + const nrms = space.view.getRMS().toFixed(1); + const nfps = space.view.getFPS().toFixed(1); + const rend = space.renderInfo(); + const { memory, render } = rend; + if (nfps !== fps.innerText) { + fps.innerText = nfps; + } + if (nrms !== rms.innerText) { + rms.innerText = nrms; + } + if (rnfo.offsetParent !== null) { + rnfo.innerHTML = Object.entries({ ...memory, ...render, render_ms: nrms, frames_sec: nfps }).map(row => { + return `
${row[0]}
` + }).join(''); + } + }, 100); +} + export const visuals = { + set_progress: setProgress, set_wireframe: setWireframe, set_edges: setEdges, unit_scale: unitScale, @@ -247,6 +301,7 @@ export const visuals = { update_slider: updateSlider, update_slider_max: updateSliderMax, update_stack_labels: updateStackLabelState, + update_stats: updateStats, show_slices: showSlices, hide_slices: hideSlices, show_slider: showSlider, diff --git a/src/kiri/mode/fdm/slice.js b/src/kiri/mode/fdm/slice.js index 5bc215da..b6505093 100644 --- a/src/kiri/mode/fdm/slice.js +++ b/src/kiri/mode/fdm/slice.js @@ -119,12 +119,13 @@ export function fdm_slice(settings, widget, onupdate, ondone) { let render = settings.render !== false, { minions } = self.kiri_worker, { process, device, controller } = settings, + { devel, assembly, threaded } = controller, isBelt = device.bedBelt, - isBrick = controller.devel && process.sliceZInterleave, + isBrick = devel && process.sliceZInterleave, isSynth = widget.track.synth, isSupport = widget.track.support, - useAssembly = controller.assembly, - isConcurrent = controller.threaded && minions.concurrent, + useAssembly = assembly, + isConcurrent = threaded && minions.concurrent, topLayers = process.sliceTopLayers || 0, bottomLayers = process.sliceBottomLayers || 0, vaseMode = process.sliceFillType === 'vase' && !isSynth, @@ -343,7 +344,7 @@ export function fdm_slice(settings, widget, onupdate, ondone) { if (changes && !isSynth) { healed = true; slice.changes = changes; - if (self.debug) { + if (devel) { console.log('slice healed', slice.index, slice.z, changes); } }