fix wireframe opacity preference

This commit is contained in:
Stewart Allen 2022-11-15 22:15:14 -05:00
commit 15abef24fd
3 changed files with 17 additions and 8 deletions

View file

@ -2,6 +2,12 @@
Full docs @ https://docs.grid.space/projects/kiri-moto Full docs @ https://docs.grid.space/projects/kiri-moto
# Release 3.8
* refactor object/group storage model in Mesh:Tool
# Release 3.7 (2022-11-12) # Release 3.7 (2022-11-12)
* add CAM axes scaling gcode header directive * add CAM axes scaling gcode header directive

View file

@ -146,8 +146,10 @@ const selection = {
update() { update() {
for (let group of groups) { for (let group of groups) {
group.select(false); group.select(false);
group.wireframe(prefs.map.space.wire || false, prefs.map.wireframe.opacity);
group.normals(prefs.map.space.norm || false); group.normals(prefs.map.space.norm || false);
group.wireframe(prefs.map.space.wire || false, {
opacity: prefs.map.wireframe.opacity}
);
} }
api.updateFog(); api.updateFog();
// prevent selection of model and its group // prevent selection of model and its group

View file

@ -24,6 +24,7 @@ const worker = moto.client.fn;
let materials = mesh.material = { let materials = mesh.material = {
// model unselected // model unselected
normal: new MeshPhongMaterial({ normal: new MeshPhongMaterial({
flatShading: true,
side: DoubleSide, side: DoubleSide,
transparent: true, transparent: true,
shininess: 125, shininess: 125,
@ -33,6 +34,7 @@ let materials = mesh.material = {
}), }),
// model selected // model selected
select: new MeshPhongMaterial({ select: new MeshPhongMaterial({
flatShading: true,
side: DoubleSide, side: DoubleSide,
transparent: true, transparent: true,
shininess: 125, shininess: 125,
@ -42,6 +44,7 @@ let materials = mesh.material = {
}), }),
// model selected as tool // model selected as tool
tool: new MeshPhongMaterial({ tool: new MeshPhongMaterial({
flatShading: true,
side: DoubleSide, side: DoubleSide,
transparent: true, transparent: true,
shininess: 125, shininess: 125,
@ -51,6 +54,7 @@ let materials = mesh.material = {
}), }),
// face selected (for groups ranges) // face selected (for groups ranges)
face: new MeshPhongMaterial({ face: new MeshPhongMaterial({
flatShading: true,
side: DoubleSide, side: DoubleSide,
transparent: true, transparent: true,
shininess: 100, shininess: 100,
@ -59,6 +63,7 @@ let materials = mesh.material = {
opacity: 1 opacity: 1
}), }),
wireframe: new MeshBasicMaterial({ wireframe: new MeshBasicMaterial({
flatShading: true,
side: DoubleSide, side: DoubleSide,
wireframe: true, wireframe: true,
color: 0x0, color: 0x0,
@ -71,7 +76,7 @@ let materials = mesh.material = {
mesh.model = class MeshModel extends mesh.object { mesh.model = class MeshModel extends mesh.object {
constructor(data, id) { constructor(data, id) {
super(id); super(id);
let { file, mesh, vertices, indices, normals } = data; let { file, mesh, vertices, indices } = data;
if (!mesh) { if (!mesh) {
dbug.error(`'${file}' missing mesh data`); dbug.error(`'${file}' missing mesh data`);
@ -100,7 +105,7 @@ mesh.model = class MeshModel extends mesh.object {
}; };
this.file = file || 'unnamed'; this.file = file || 'unnamed';
this.load(mesh || vertices, indices, normals); this.load(mesh || vertices, indices);
} }
get type() { get type() {
@ -192,7 +197,7 @@ mesh.model = class MeshModel extends mesh.object {
}); });
} }
load(vertices, indices, normals) { load(vertices, indices) {
let geo = new BufferGeometry(); let geo = new BufferGeometry();
geo.setAttribute('position', new BufferAttribute(vertices, 3)); geo.setAttribute('position', new BufferAttribute(vertices, 3));
if (indices) { if (indices) {
@ -200,9 +205,6 @@ mesh.model = class MeshModel extends mesh.object {
geo.setIndex(new BufferAttribute(indices, 1)); geo.setIndex(new BufferAttribute(indices, 1));
geo = geo.toNonIndexed(); geo = geo.toNonIndexed();
} }
if (!normals) {
geo.computeVertexNormals();
}
let meh = this.mesh = new Mesh(geo, [ let meh = this.mesh = new Mesh(geo, [
this.mats.normal, this.mats.normal,
@ -226,7 +228,6 @@ mesh.model = class MeshModel extends mesh.object {
let was = this.wireframe(false); let was = this.wireframe(false);
let geo = this.mesh.geometry; let geo = this.mesh.geometry;
geo.setAttribute('position', new BufferAttribute(vertices, 3)); geo.setAttribute('position', new BufferAttribute(vertices, 3));
geo.setAttribute('normal', undefined);
if (indices) { if (indices) {
geo.setIndex(new BufferAttribute(indices, 1)); geo.setIndex(new BufferAttribute(indices, 1));
} }