mirror of
https://github.com/CNCKitchen/stlTexturizer.git
synced 2026-04-07 22:11:32 +00:00
feat: enhance exclusion overlay visibility and improve wireframe rendering
This commit is contained in:
+3
-3
@@ -490,10 +490,10 @@ function paintAt(e) {
|
|||||||
function refreshExclusionOverlay() {
|
function refreshExclusionOverlay() {
|
||||||
if (!currentGeometry) return;
|
if (!currentGeometry) return;
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
// Include Only mode: grey out the complement (non-selected faces) so only the
|
// Include Only mode: tint the complement (non-selected faces) with a pastel blue
|
||||||
// selected faces show the texture preview beneath.
|
// so the model stays visible against the dark background before any faces are painted.
|
||||||
const maskGeo = buildExclusionOverlayGeo(currentGeometry, excludedFaces, true);
|
const maskGeo = buildExclusionOverlayGeo(currentGeometry, excludedFaces, true);
|
||||||
setExclusionOverlay(maskGeo, 0x222222, 0.88);
|
setExclusionOverlay(maskGeo, 0x8ab4d4, 0.96);
|
||||||
} else {
|
} else {
|
||||||
setExclusionOverlay(buildExclusionOverlayGeo(currentGeometry, excludedFaces), 0xff6600);
|
setExclusionOverlay(buildExclusionOverlayGeo(currentGeometry, excludedFaces), 0xff6600);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-9
@@ -339,19 +339,24 @@ function _buildWireframe(geometry) {
|
|||||||
wireframeLines = null;
|
wireframeLines = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EdgesGeometry gives one segment per unique triangle edge
|
// WireframeGeometry gives every triangle edge; EdgesGeometry skips edges
|
||||||
const edgesGeo = new THREE.EdgesGeometry(geometry, 1);
|
// between near-coplanar faces so large flat STL regions lose their grid lines.
|
||||||
|
const wireGeo = new THREE.WireframeGeometry(geometry);
|
||||||
// Convert to LineSegmentsGeometry (required by LineMaterial / LineSegments2)
|
const lsGeo = new LineSegmentsGeometry();
|
||||||
const lsGeo = new LineSegmentsGeometry().fromEdgesGeometry(edgesGeo);
|
lsGeo.setPositions(wireGeo.attributes.position.array);
|
||||||
edgesGeo.dispose();
|
wireGeo.dispose();
|
||||||
|
|
||||||
const lsMat = new LineMaterial({
|
const lsMat = new LineMaterial({
|
||||||
color: 0xffffff,
|
color: 0xffffff,
|
||||||
opacity: 0.75,
|
opacity: 0.65,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
linewidth: 1.5, // pixels — works on all desktop GPUs
|
linewidth: 1.2,
|
||||||
depthTest: true,
|
depthTest: true,
|
||||||
|
// Pull lines slightly in front so they beat the base mesh AND the
|
||||||
|
// exclusion overlay (polygonOffsetFactor -1,-1) in the depth test.
|
||||||
|
polygonOffset: true,
|
||||||
|
polygonOffsetFactor: -2,
|
||||||
|
polygonOffsetUnits: -2,
|
||||||
resolution: new THREE.Vector2(
|
resolution: new THREE.Vector2(
|
||||||
renderer.domElement.width * renderer.getPixelRatio(),
|
renderer.domElement.width * renderer.getPixelRatio(),
|
||||||
renderer.domElement.height * renderer.getPixelRatio(),
|
renderer.domElement.height * renderer.getPixelRatio(),
|
||||||
@@ -359,7 +364,7 @@ function _buildWireframe(geometry) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
wireframeLines = new LineSegments2(lsGeo, lsMat);
|
wireframeLines = new LineSegments2(lsGeo, lsMat);
|
||||||
wireframeLines.renderOrder = 1;
|
wireframeLines.renderOrder = 3; // draw after base mesh (0), overlays (1-2)
|
||||||
// Add to meshGroup so it's automatically removed when a new model is loaded
|
// Add to meshGroup so it's automatically removed when a new model is loaded
|
||||||
meshGroup.add(wireframeLines);
|
meshGroup.add(wireframeLines);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user