refactor color and opacity/edge management
This commit is contained in:
parent
a13bb79f4b
commit
9900161dcd
17 changed files with 795 additions and 64 deletions
|
|
@ -1,6 +1,7 @@
|
|||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
import { api } from '../../app/api.js';
|
||||
import { colorSchemeRegistry } from '../../app/color/schemes.js';
|
||||
import { env, isDark } from './init-ui.js';
|
||||
import { addbox, delbox, clearboxes } from '../../core/boxes.js';
|
||||
import { traceDone } from './cl-trace.js';
|
||||
|
|
@ -225,9 +226,15 @@ export function tabClear() {
|
|||
}
|
||||
|
||||
function boxColor() {
|
||||
return isDark() ? 0x00ddff : 0x0000dd;
|
||||
const mode = 3; // CAM mode ID
|
||||
const theme = isDark() ? 'dark' : 'light';
|
||||
const scheme = colorSchemeRegistry.getScheme(mode, theme);
|
||||
return scheme.operations?.tabs?.color ?? (isDark() ? 0x00ddff : 0x0000dd);
|
||||
}
|
||||
|
||||
function boxOpacity() {
|
||||
return isDark() ? 0.75 : 0.6;
|
||||
const mode = 3; // CAM mode ID
|
||||
const theme = isDark() ? 'dark' : 'light';
|
||||
const scheme = colorSchemeRegistry.getScheme(mode, theme);
|
||||
return scheme.operations?.tabs?.opacity ?? (isDark() ? 0.75 : 0.6);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import { newPoint } from '../../../geo/point.js';
|
||||
import { $ } from '../../../moto/webui.js';
|
||||
import { api } from '../../app/api.js';
|
||||
import { colorSchemeRegistry } from '../../app/color/schemes.js';
|
||||
import { conf } from '../../app/conf/defaults.js';
|
||||
import { addPaintOverlayTexture, updatePaintOverlay } from '../../app/paint.js';
|
||||
|
||||
|
|
@ -271,14 +272,29 @@ function supportStart({ remove } = { remove: false }) {
|
|||
return [ down.widget.mesh ];
|
||||
// return api.widgets.meshes();
|
||||
};
|
||||
// Get paint color from scheme
|
||||
const mode = api.mode.get_id();
|
||||
const theme = api.space.is_dark() ? 'dark' : 'light';
|
||||
const scheme = colorSchemeRegistry.getScheme(mode, theme);
|
||||
const paintColor = scheme.operations?.paint?.overlay ?? 0x4488ff;
|
||||
|
||||
api.widgets.each(w => {
|
||||
// Use pushVisualState to track the paint operation
|
||||
w.pushVisualState('paint', {
|
||||
material: w.mesh.material[0],
|
||||
restoreCallback: () => {
|
||||
w.mesh.material[0] = w.cache.mat;
|
||||
delete w.cache.mat;
|
||||
}
|
||||
});
|
||||
|
||||
let mat = w.cache.mat = w.mesh.material[0];
|
||||
mat = w.mesh.material[0] = mat.clone();
|
||||
mat.needsUpdate = true;
|
||||
if (!w.anno.paint) {
|
||||
w.anno.paint = [];
|
||||
}
|
||||
addPaintOverlayTexture(mat, w.anno.paint, new THREE.Color(0x4488ff));
|
||||
addPaintOverlayTexture(mat, w.anno.paint, new THREE.Color(paintColor));
|
||||
})
|
||||
api.space.update();
|
||||
}
|
||||
|
|
@ -321,8 +337,8 @@ function supportDone() {
|
|||
api.feature.on_mouse_drag = undefined;
|
||||
api.hide.alert(alert);
|
||||
api.widgets.each(w => {
|
||||
w.mesh.material[0] = w.cache.mat;
|
||||
delete w.cache.mat;
|
||||
// Use popVisualState to restore original material
|
||||
w.popVisualState('paint');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue