add selector for trace mode. convert widget mesh material to array. bump rev 3.4.D1

This commit is contained in:
Stewart Allen 2022-04-03 14:56:58 -04:00
commit 31bfe837d7
8 changed files with 40 additions and 23 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "grid-apps", "name": "grid-apps",
"version": "3.4.0D", "version": "3.4.1D",
"description": "grid.space 3d slice & modeling tools", "description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>", "author": "Stewart Allen <sa@grid.space>",
"license": "MIT", "license": "MIT",

View file

@ -612,7 +612,7 @@ CAM.init = function(kiri, api) {
} }
}); });
}); });
}, poppedRec.single); }, poppedRec.select === 'lines');
api.feature.hover = true; api.feature.hover = true;
api.feature.hoverAdds = true; api.feature.hoverAdds = true;
func.hover = func.traceHover; func.hover = func.traceHover;
@ -954,7 +954,8 @@ CAM.init = function(kiri, api) {
down: 'camTraceDown', down: 'camTraceDown',
rate: 'camTraceSpeed', rate: 'camTraceSpeed',
plunge: 'camTracePlunge', plunge: 'camTracePlunge',
single: 'camTraceLines', // single: 'camTraceLines',
select: 'camTraceMode'
}).inputs = { }).inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"), tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
sep: UC.newBlank({class:"pop-sep"}), sep: UC.newBlank({class:"pop-sep"}),
@ -966,8 +967,9 @@ CAM.init = function(kiri, api) {
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}), rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
plunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}), plunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}),
sep: UC.newBlank({class:"pop-sep"}), sep: UC.newBlank({class:"pop-sep"}),
single: UC.newBoolean(LANG.cc_sngl_s, undefined, {title:LANG.cc_sngl_l}), // single: UC.newBoolean(LANG.cc_sngl_s, undefined, {title:LANG.cc_sngl_l}),
select: UC.newRow([ select: UC.newSelect(LANG.cc_sele_s, {title:LANG.cc_sele_l}, "select"),
menu: UC.newRow([
UC.newButton(undefined, func.traceAdd, {icon:'<i class="fas fa-plus"></i>'}), UC.newButton(undefined, func.traceAdd, {icon:'<i class="fas fa-plus"></i>'}),
UC.newButton(undefined, func.traceDone, {icon:'<i class="fas fa-check"></i>'}), UC.newButton(undefined, func.traceDone, {icon:'<i class="fas fa-check"></i>'}),
], {class:"ext-buttons f-row"}), ], {class:"ext-buttons f-row"}),

View file

@ -74,6 +74,11 @@ const LISTS = {
{ name: "800" }, { name: "800" },
{ name: "900" } { name: "900" }
], ],
select: [
{ name: "loops" },
{ name: "lines" },
// { name: "surface" }
],
trace: [ trace: [
{ name: "follow" }, { name: "follow" },
{ name: "clear" } { name: "clear" }

View file

@ -263,9 +263,8 @@ function platformSelect(widget, shift, recurse = true) {
platform.select(widget, false, recurse); platform.select(widget, false, recurse);
} }
} else { } else {
let { mesh } = widget;
// prevent selection in slice view // prevent selection in slice view
if (!mesh.material.visible) { if (!widget.isVisible()) {
return; return;
} }
if (!shift) { if (!shift) {

View file

@ -300,19 +300,18 @@ class Widget {
loadGeometry(geometry) { loadGeometry(geometry) {
const mesh = new THREE.Mesh( const mesh = new THREE.Mesh(
geometry, geometry,
new THREE.MeshPhongMaterial({ [ new THREE.MeshPhongMaterial({
color: 0xffff00, color: 0xffff00,
specular: 0x202020, specular: 0x202020,
shininess: 125, shininess: 125,
transparent: true, transparent: true,
opacity: solid_opacity opacity: solid_opacity
}) }) ]
); );
mesh.renderOrder = 1; mesh.renderOrder = 1;
// fix invalid normals
// geometry.computeFaceNormals();
geometry.computeVertexNormals(); geometry.computeVertexNormals();
mesh.material.side = THREE.DoubleSide; geometry.addGroup(0, Infinity, 0);
mesh.material[0].side = THREE.DoubleSide;
mesh.castShadow = true; mesh.castShadow = true;
mesh.receiveShadow = true; mesh.receiveShadow = true;
mesh.widget = this; mesh.widget = this;
@ -362,7 +361,7 @@ class Widget {
if (save) { if (save) {
this.color = color; this.color = color;
} }
let material = this.mesh.material; let material = this.getMaterial();
material.color.set(this.meta.disabled ? avgc(0x888888, color, 3) : color); material.color.set(this.meta.disabled ? avgc(0x888888, color, 3) : color);
} }
@ -370,19 +369,28 @@ class Widget {
return this.color; return this.color;
} }
getMaterial() {
return this.mesh.material[0];
}
isVisible() {
return this.getMaterial().visible;
}
/** /**
* @param {number} value * @param {number} value
*/ */
setOpacity(value) { setOpacity(value) {
const mesh = this.mesh; const mesh = this.mesh;
const mat = this.getMaterial();
if (value <= 0.0) { if (value <= 0.0) {
mesh.material.transparent = solid_opacity < 1.0; mat.transparent = solid_opacity < 1.0;
mesh.material.opacity = solid_opacity; mat.opacity = solid_opacity;
mesh.material.visible = false; mat.visible = false;
} else if (inRange(value, 0.0, solid_opacity)) { } else if (inRange(value, 0.0, solid_opacity)) {
mesh.material.transparent = value < 1.0; mat.transparent = value < 1.0;
mesh.material.opacity = value; mat.opacity = value;
mesh.material.visible = true; mat.visible = true;
} }
} }
@ -474,10 +482,11 @@ class Widget {
_move(x, y, z, abs) { _move(x, y, z, abs) {
let mesh = this.mesh, let mesh = this.mesh,
mat = this.getMaterial(),
pos = this.track.pos, pos = this.track.pos,
zcut = this.track.zcut || 0; zcut = this.track.zcut || 0;
// do not allow moves in pure slice view // do not allow moves in pure slice view
if (!mesh.material.visible) return; if (!mat.visible) return;
if (abs) { if (abs) {
mesh.position.set(x, y, z - zcut); mesh.position.set(x, y, z - zcut);
pos.x = (x || 0); pos.x = (x || 0);
@ -896,7 +905,7 @@ const Group = Widget.Groups = {
h: group[0].track.box.h, h: group[0].track.box.h,
move: (x,y,z,abs) => { move: (x,y,z,abs) => {
group.forEach(widget => { group.forEach(widget => {
widget.mesh.material.visible = true; widget.getMaterial().visible = true;
widget._move(x, y, z, abs); widget._move(x, y, z, abs);
}); });
} }

View file

@ -15,7 +15,7 @@ gapp.main("main.kiri", [], (root) => {
const modfns = root.kirimod = ( root.kirimod || [] ); const modfns = root.kirimod = ( root.kirimod || [] );
const kiri = root.kiri = { const kiri = root.kiri = {
beta: 3400, beta: 3401,
driver: {}, // driver modules driver: {}, // driver modules
load(fn) { load(fn) {
modfns.push(fn); modfns.push(fn);

View file

@ -3,7 +3,7 @@
let terms = { let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution", LICENSE: "See the license.md file included with the source distribution",
VERSION: "3.4.D0" VERSION: "3.4.D1"
}; };
if (typeof(module) === 'object') { if (typeof(module) === 'object') {

View file

@ -436,6 +436,8 @@ self.kiri.lang['en-us'] = {
cc_plng_l: ["max z axis speed in","workspace units / minute"], cc_plng_l: ["max z axis speed in","workspace units / minute"],
cc_sngl_s: "select lines only", cc_sngl_s: "select lines only",
cc_sngl_l: ["select only single edges","instead of connected polylines"], cc_sngl_l: ["select only single edges","instead of connected polylines"],
cc_sele_s: "select",
cc_sele_l: ["select lines for follow","select loops for clear","select surface for pocket"],
// CNC COMMON // CNC COMMON
cc_menu: "limits", cc_menu: "limits",