preserve doubleside on flats, frontside on solids

This commit is contained in:
Stewart Allen 2022-01-30 14:14:00 -05:00
commit 83f814d42b
3 changed files with 10 additions and 10 deletions

View file

@ -170,7 +170,7 @@
Object.values(COLOR).forEach(color => {
color.flat = true;
color.line = 1
color.opacity = 0.5;
color.opacity = 1;
});
} else {
Object.keys(COLOR).forEach(key => {

View file

@ -232,14 +232,14 @@
slice.unioned.forEach(poly => {
poly = poly.clone(true);//.move(widget.track.pos);
render
.setLayer("layers", { line: 0x010101, face: 0x0099cc, opacity: 0.2 })
.setLayer("layers", { line: 0x010101, face: 0x0099cc, opacity: 0.4 })
.addAreas([poly], { outline: true });
});
} else if (slice.tops) {
slice.tops.forEach(top => {
let poly = top.poly;//.clone(true).move(widget.track.pos);
render
.setLayer("layers", { line: 0x010101, face: 0xfcba03, opacity: 0.2 })
.setLayer("layers", { line: 0x010101, face: 0xfcba03, opacity: 0.4 })
.addAreas([poly], { outline: true });
});
}
@ -247,7 +247,7 @@
if (slice.supports) {
slice.supports.forEach(poly => {
render
.setLayer("support", { line: 0x010101, face: 0xfcba03, opacity: 0.2 })
.setLayer("support", { line: 0x010101, face: 0xfcba03, opacity: 0.4 })
.addAreas([poly], { outline: true });
});
}

View file

@ -151,9 +151,9 @@
if (faces.length) {
const mat = [];
if (cface) {
cface.forEach(c => { mat.push(newMat(c)) });
cface.forEach(c => { mat.push(newMat(c, true)) });
} else {
mat.push(newMat(color));
mat.push(newMat(color, true));
}
mat.forEach(m => m.visible = defstate);
const geo = new THREE.BufferGeometry();
@ -236,7 +236,7 @@
return mat;
}
function createStandardMaterial(color) {
function createStandardMaterial(color, flat) {
return new THREE.MeshStandardMaterial({
emissive,
roughness,
@ -244,18 +244,18 @@
transparent: color.opacity != 1,
opacity: color.opacity || 1,
color: color.face,
side: THREE.FrontSide
side: flat ? THREE.DoubleSide : THREE.FrontSide
});
}
function createPhongMaterial(color) {
function createPhongMaterial(color, flat) {
return new THREE.MeshPhongMaterial({
shininess,
specular,
transparent: color.opacity != 1,
opacity: color.opacity || 1,
color: color.face,
side: THREE.FrontSide
side: flat ? THREE.DoubleSide : THREE.FrontSide
});
}