compensate WireEDM previews when origin bounds checked

This commit is contained in:
Stewart Allen 2024-06-13 22:13:03 -04:00
commit 4d811972f6
4 changed files with 18 additions and 6 deletions

View file

@ -83,10 +83,18 @@ function init(kiri, api, driver) {
}
});
api.event.on("mode.set", (mode) => {
});
// api.event.on("mode.set", (mode) => { });
api.event.on("view.set", (mode) => {
// api.event.on("view.set", (mode) => { });
api.event.on("preview.view", view => {
const process = api.conf.get().process;
if (!process.ctOriginBounds) return;
const bounds = new THREE.Box3().expandByObject(view);
api.platform.set_bounds(new THREE.Box3(
new THREE.Vector3(bounds.min.x, bounds.min.z, bounds.min.y),
new THREE.Vector3(bounds.max.x, bounds.max.z, bounds.max.y),
));
});
// Surface Selection Buttons

View file

@ -332,9 +332,11 @@ function preparePreview(callback, scale = 1, offset = 0) {
startTime = Date.now();
stacks.clear();
const stack = stacks.create('print', space.world)
const view = stack.obj.view;
output.forEach(layer => {
stack.add(layer);
});
event.emit('preview.view', view);
// rotate stack for belt beds
if (isBelt && widgets[0].belt) {
let ri = widgets[0].belt;

View file

@ -1968,8 +1968,8 @@ gapp.register("kiri.init", [], (root, exports) => {
ctOutSpeed: newInput(LANG.ou_sped_s, {title:LANG.ou_sped_l, convert:toInt}),
ctAdaptive: newBoolean('adaptive speed', onBooleanClick, {modes:WEDM, title:'controller determines best cutting speed based on material feedback at runtime'}),
separator: newBlank({ class:"set-sep", driven }),
ctOriginBounds: newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l}),
ctOriginCenter: newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l}),
ctOriginBounds: newBoolean(LANG.or_bnds_s, onBooleanClick, {title:LANG.or_bnds_l, show:() => !ui.ctOriginCenter.checked}),
ctOriginCenter: newBoolean(LANG.or_cntr_s, onBooleanClick, {title:LANG.or_cntr_l, show:() => !ui.ctOriginBounds.checked}),
separator: newBlank({ class:"set-sep", driven, modes:WEDM }),
ctOriginOffX: newInput(LANG.or_offx_s, {title:LANG.or_offx_l, convert:toFloat, modes:WEDM}),
ctOriginOffY: newInput(LANG.or_offy_s, {title:LANG.or_offy_l, convert:toFloat, modes:WEDM}),

View file

@ -842,6 +842,8 @@ gapp.register("kiri.main", [], (root, exports) => {
viewMode = mode;
platform.deselect();
selection.update_info();
// clear any bounds forced by, for example, WireEDM previews
api.platform.set_bounds();
// disable clear in non-arrange modes
['view-arrange','act-slice','act-preview','act-animate'].forEach(el => {
$(el).classList.remove('selected')