remove decal option, persist and make outline option configurable
This commit is contained in:
parent
424db47bfd
commit
7fb6f2f3c2
6 changed files with 13 additions and 89 deletions
|
|
@ -17,7 +17,6 @@ const asPoints = false;
|
|||
// tint points below z=0 with red
|
||||
function add_red_neg_z(material) {
|
||||
material.onBeforeCompile = (shader) => {
|
||||
console.log({ OBC: shader });
|
||||
shader.vertexShader = shader.vertexShader.replace(
|
||||
`#include <worldpos_vertex>`,
|
||||
`
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ function device_from_code(code,mode) {
|
|||
noclone: valueOf(code.no_clone, false),
|
||||
mode: mode || code.mode || '',
|
||||
internal: 0,
|
||||
imageURL: valueOf(set.image_url, ""),
|
||||
imageScale: valueOf(set.image_scale, 0.75),
|
||||
imageAnchor: valueOf(set.image_anchor, 0),
|
||||
bedHeight: valueOf(set.bed_height, 2.5),
|
||||
|
|
@ -905,7 +904,6 @@ const conf = exports({
|
|||
view: null,
|
||||
dark: false,
|
||||
shiny: false,
|
||||
decals: false,
|
||||
drawer: false,
|
||||
scrolls: true,
|
||||
zoomSpeed: 1.0,
|
||||
|
|
@ -920,6 +918,7 @@ const conf = exports({
|
|||
autoLayout: true,
|
||||
spaceRandoX: false,
|
||||
spaceLayout: 1,
|
||||
outline: 20,
|
||||
units: "mm",
|
||||
exportOcto: false,
|
||||
exportGhost: false,
|
||||
|
|
@ -956,6 +955,7 @@ const conf = exports({
|
|||
widget: {},
|
||||
// legacy localStorage settings (like octo print)
|
||||
local: {
|
||||
'model.outline': false,
|
||||
'cam.anim.model': false,
|
||||
'cam.anim.stock': false,
|
||||
'cam.anim.speed': 3
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
|
||||
let currentDevice = null,
|
||||
deviceURL = null,
|
||||
deviceTexture = null,
|
||||
deviceFilter = null,
|
||||
deviceImage = null,
|
||||
selectedTool = null,
|
||||
|
|
@ -179,7 +178,6 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
api.show.alert('Page Reload Required to Change Aliasing');
|
||||
}
|
||||
control.shiny = ui.shiny.checked;
|
||||
control.decals = ui.decals.checked;
|
||||
control.drawer = ui.drawer.checked;
|
||||
control.scrolls = ui.scrolls.checked;
|
||||
control.showOrigin = ui.showOrigin.checked;
|
||||
|
|
@ -207,12 +205,6 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
api.platform.update_size();
|
||||
updateStats();
|
||||
updateDrawer();
|
||||
if (control.decals && !control.dark) {
|
||||
// disable decals in dark mode
|
||||
loadDeviceTexture(currentDevice, deviceTexture);
|
||||
} else {
|
||||
clearDeviceTexture();
|
||||
}
|
||||
api.event.emit('boolean.update');
|
||||
if (doAlert) {
|
||||
api.show.alert("change requires page refresh");
|
||||
|
|
@ -882,15 +874,6 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
|
||||
uc.refresh(1);
|
||||
filamentSourceEditUpdate();
|
||||
|
||||
if (dev.imageURL) {
|
||||
if (dev.imageURL !== deviceURL) {
|
||||
deviceURL = dev.imageURL;
|
||||
loadDeviceImage(dev);
|
||||
}
|
||||
} else {
|
||||
clearDeviceTexture();
|
||||
}
|
||||
} catch (e) {
|
||||
console.log({error:e, device:code, devicename});
|
||||
api.show.alert(`invalid or deprecated device: "${devicename}"`, 10);
|
||||
|
|
@ -902,74 +885,6 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
api.event.settings();
|
||||
}
|
||||
|
||||
function clearDeviceTexture() {
|
||||
if (deviceImage) {
|
||||
space.world.remove(deviceImage);
|
||||
deviceImage = null;
|
||||
deviceURL = null;
|
||||
}
|
||||
}
|
||||
|
||||
function loadDeviceImage(dev, url) {
|
||||
let turl = url || dev.imageURL;
|
||||
if (!turl) return;
|
||||
new THREE.TextureLoader().load(turl, texture => {
|
||||
loadDeviceTexture(dev, texture);
|
||||
}, inc => {
|
||||
console.log({load_inc: inc});
|
||||
}, error => {
|
||||
console.log({load_error: error, turl});
|
||||
clearDeviceTexture();
|
||||
});
|
||||
}
|
||||
|
||||
function loadDeviceTexture(dev, texture) {
|
||||
clearDeviceTexture();
|
||||
deviceTexture = texture;
|
||||
let { decals, dark } = api.conf.get().controller;
|
||||
// disable decals in dark mode
|
||||
if (!(texture && decals && !dark)) {
|
||||
return;
|
||||
}
|
||||
let { width, height } = texture.image;
|
||||
let { bedWidth, bedDepth, bedHeight } = dev;
|
||||
let scale = dev.imageScale || 0.75;
|
||||
let img_ratio = width / height;
|
||||
if (scale <= 1) {
|
||||
let dev_ratio = bedWidth / bedDepth;
|
||||
if (dev_ratio > img_ratio) {
|
||||
scale *= bedDepth / height;
|
||||
} else {
|
||||
scale *= bedWidth / width;
|
||||
}
|
||||
} else if (scale > 1) {
|
||||
scale = (scale / Math.max(width, height));
|
||||
}
|
||||
width *= scale;
|
||||
height *= scale;
|
||||
let pos = null;
|
||||
if (true) switch (dev.imageAnchor) {
|
||||
case 1: pos = { x: -(bedWidth - width)/2, y: (bedDepth - height)/2 }; break;
|
||||
case 2: pos = { x: 0, y: (bedDepth - height)/2 }; break;
|
||||
case 3: pos = { x: (bedWidth - width)/2, y: (bedDepth - height)/2 }; break;
|
||||
case 4: pos = { x: -(bedWidth - width)/2, y: 0 }; break;
|
||||
case 5: pos = { x: (bedWidth - width)/2, y: 0 }; break;
|
||||
case 6: pos = { x: -(bedWidth - width)/2, y: -(bedDepth - height)/2 }; break;
|
||||
case 7: pos = { x: 0, y: -(bedDepth - height)/2 }; break;
|
||||
case 8: pos = { x: (bedWidth - width)/2, y: -(bedDepth - height)/2 }; break;
|
||||
}
|
||||
let geometry = new THREE.PlaneGeometry(width, height, 1),
|
||||
material = new THREE.MeshBasicMaterial({ map: texture, transparent: true }),
|
||||
mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.position.z = -bedHeight;
|
||||
mesh.renderOrder = -1;
|
||||
if (pos) {
|
||||
mesh.position.x = pos.x;
|
||||
mesh.position.y = pos.y;
|
||||
}
|
||||
space.world.add(deviceImage = mesh);
|
||||
}
|
||||
|
||||
function updateDeviceName(newname) {
|
||||
let selected = api.device.get(),
|
||||
devs = settings().devices;
|
||||
|
|
@ -1792,11 +1707,11 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
showOrigin: newBoolean(LANG.op_shor_s, booleanSave, {title:LANG.op_shor_l}),
|
||||
showRulers: newBoolean(LANG.op_shru_s, booleanSave, {title:LANG.op_shru_l}),
|
||||
showSpeeds: newBoolean(LANG.op_sped_s, speedSave, {title:LANG.op_sped_l}),
|
||||
decals: newBoolean(LANG.op_decl_s, booleanSave, {title:LANG.op_decl_s}),
|
||||
shiny: newBoolean(LANG.op_shny_s, booleanSave, {title:LANG.op_shny_l, modes:FDM}),
|
||||
lineType: newSelect(LANG.op_line_s, {title: LANG.op_line_l, action: lineTypeSave, modes:FDM}, "linetype"),
|
||||
animesh: newSelect(LANG.op_anim_s, {title: LANG.op_anim_l, action: aniMeshSave, modes:CAM}, "animesh"),
|
||||
units: newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, action: unitsSave, modes:CAM}, "units"),
|
||||
outline: newInput(LANG.op_spoa_s, {title:LANG.op_spoa_l, convert:toFloat, size:3}),
|
||||
_____: newGroup(LANG.lo_menu, $('prefs-lay'), {inline: true}),
|
||||
autoSave: newBoolean(LANG.op_save_s, booleanSave, {title:LANG.op_save_l}),
|
||||
autoLayout: newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}),
|
||||
|
|
|
|||
|
|
@ -389,6 +389,12 @@ gapp.register("kiri.main", [], (root, exports) => {
|
|||
}
|
||||
|
||||
function setOutline(bool) {
|
||||
if (bool && bool.toggle) {
|
||||
api.local.toggle('model.outline');
|
||||
} else {
|
||||
api.local.set('model.outline', bool);
|
||||
}
|
||||
bool = api.local.getBoolean('model.outline');
|
||||
api.widgets.each(w => w.setOutline(bool));
|
||||
SPACE.update();
|
||||
}
|
||||
|
|
@ -886,6 +892,7 @@ gapp.register("kiri.main", [], (root, exports) => {
|
|||
setVisibleLayer();
|
||||
setWidgetVisibility(true);
|
||||
api.widgets.opacity(1);
|
||||
api.view.outline(api.local.getBoolean('model.outline'));
|
||||
break;
|
||||
case VIEWS.SLICE:
|
||||
$('act-slice').classList.add('selected');
|
||||
|
|
|
|||
|
|
@ -848,6 +848,7 @@ class Widget {
|
|||
let edges = new THREE.EdgesGeometry(mesh.geometry, angle);
|
||||
let material = new THREE.LineBasicMaterial({ color: 0 });
|
||||
this.outline = new THREE.LineSegments(edges, material);
|
||||
this.outline.renderOrder = -20;
|
||||
mesh.add(this.outline);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,6 +284,8 @@ self.kiri.lang['en-us'] = {
|
|||
op_free_l: ["permit dragable layout","no effect in laser mode"],
|
||||
op_spcr_s: "spacing",
|
||||
op_spcr_l: ["spacing between objects","during auto layout","in workspace units","in belt mode, use 0","to auto-space by height"],
|
||||
op_spoa_s: "outline",
|
||||
op_spoa_l: ["surface angle triggering an outline to be rendered"],
|
||||
op_spcx_s: "random X",
|
||||
op_spcx_l: ["in belt mode, randomly","layout the part on X","to even belt wear"],
|
||||
op_orth_s: "orthographic",
|
||||
|
|
|
|||
Loading…
Reference in a new issue