use DirectionalLights instead of PointLights for performance. and add ability to toggle anti-aliasing

This commit is contained in:
Stewart Allen 2022-01-28 16:54:53 -05:00
commit 5107d1758c
7 changed files with 68 additions and 23 deletions

View file

@ -54,7 +54,6 @@
selectedTool = null,
editTools = null,
maxTool = 0,
fpsTimer = null,
platformColor,
contextInt;
@ -162,6 +161,9 @@
if (control.assembly != UI.assembly.checked) {
KIRI.client.wasm(UI.assembly.checked);
}
if (control.antiAlias != UI.antiAlias.checked) {
API.show.alert('Page Reload Required to Change Aliasing');
}
control.decals = UI.decals.checked;
control.danger = UI.danger.checked;
control.showOrigin = UI.showOrigin.checked;
@ -169,6 +171,7 @@
control.autoLayout = UI.autoLayout.checked;
control.freeLayout = UI.freeLayout.checked;
control.autoSave = UI.autoSave.checked;
control.antiAlias = UI.antiAlias.checked;
control.reverseZoom = UI.reverseZoom.checked;
control.dark = UI.dark.checked;
control.exportOcto = UI.exportOcto.checked;
@ -190,7 +193,7 @@
maxpass: control.decimate ? 10 : 0
});
UC.setHoverPop(false);
updateFPS();
updateStats();
if (control.decals && !control.dark) {
// disable decals in dark mode
loadDeviceTexture(currentDevice, deviceTexture);
@ -203,13 +206,20 @@
}
}
function updateFPS() {
clearTimeout(fpsTimer);
UI.fps.style.display = 'block';
function updateStats() {
if (self.debug !== true) {
return;
}
let { div, fps, rms } = UI.stats;
div.style.display = 'flex';
setInterval(() => {
const nv = SPACE.view.getFPS().toFixed(2);
if (nv !== UI.fps.innerText) {
UI.fps.innerText = nv;
const nfps = SPACE.view.getFPS().toFixed(2);
const nrms = SPACE.view.getRMS().toFixed(2);
if (nfps !== fps.innerText) {
fps.innerText = nfps;
}
if (nrms !== rms.innerText) {
rms.innerText = nrms;
}
}, 100);
}
@ -1460,6 +1470,7 @@
SPACE.sky.showGrid(false);
SPACE.sky.setColor(controller.dark ? 0 : 0xffffff);
SPACE.setAntiAlias(controller.antiAlias);
SPACE.init(container, function (delta) {
let vars = API.var;
if (vars.layer_max === 0 || !delta) return;
@ -1521,7 +1532,12 @@
faces: $('mesh-faces'),
},
fps: $('fps'),
stats: {
fps: $('fps'),
rms: $('rms'),
div: $('stats'),
},
load: $('load-file'),
speeds: $('speeds'),
speedbar: $('speedbar'),
@ -1679,6 +1695,7 @@
], {class:"ext-buttons f-row gcode-macros"}),
lprefs: UC.newGroup(LANG.op_menu, $('prefs-gen1'), {inline: true}),
antiAlias: UC.newBoolean(LANG.op_anta_s, booleanSave, {title:LANG.op_anta_l}),
reverseZoom: UC.newBoolean(LANG.op_invr_s, booleanSave, {title:LANG.op_invr_l}),
ortho: UC.newBoolean(LANG.op_orth_s, booleanSave, {title:LANG.op_orth_l}),
dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}),
@ -2516,6 +2533,7 @@
UI.showSpeeds.checked = control.showSpeeds;
UI.freeLayout.checked = control.freeLayout;
UI.autoLayout.checked = control.autoLayout;
UI.antiAlias.checked = control.antiAlias;
UI.reverseZoom.checked = control.reverseZoom;
UI.autoSave.checked = control.autoSave;
UI.decimate.checked = control.decimate;
@ -2526,7 +2544,7 @@
UI.devel.checked = control.devel;
lineTypeSave();
detailSave();
updateFPS();
updateStats();
// optional set-and-lock mode (hides mode menu)
let SETMODE = SETUP.mode ? SETUP.mode[0] : null;