Skip to content

Commit d12678f

Browse files
jochem25claude
andcommitted
fix: ghost mode opacity 0.85→0.15 and restore selected element to full opacity
Ghost mode was nearly invisible because opacity was 0.85 (almost opaque). Also, the selected element was ghosted along with everything else. Now: non-selected elements are truly transparent, selected element stays opaque. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5c8ba74 commit d12678f

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

viewer/src/engine/ViewerEngine.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const DEFAULT_BACKGROUND = "#1a1a2e";
3131
const HIGHLIGHT_OPACITY = 0.6;
3232

3333

34-
/** Ghost mode: high opacity to wash out non-selected elements */
35-
const GHOST_OPACITY = 0.85;
34+
/** Ghost mode: low opacity makes non-selected elements nearly invisible */
35+
const GHOST_OPACITY = 0.15;
3636

3737
/** Callbacks for engine events */
3838
export interface ViewerEngineCallbacks {
@@ -526,7 +526,7 @@ export class ViewerEngine {
526526
}
527527
}
528528

529-
// Ghost ALL meshes, then un-ghost selected ones
529+
// Ghost ALL meshes
530530
for (const obj of this.modelObjects.values()) {
531531
obj.traverse((child) => {
532532
if (!(child instanceof THREE.Mesh)) return;
@@ -548,6 +548,23 @@ export class ViewerEngine {
548548
});
549549
}
550550

551+
// Un-ghost selected element: restore to full opacity
552+
for (const mesh of selectedMeshes) {
553+
const child = mesh as THREE.Mesh;
554+
const materials = Array.isArray(child.material)
555+
? child.material
556+
: [child.material];
557+
for (const mat of materials) {
558+
if (!mat) continue;
559+
const saved = this.savedMaterials.get(mat);
560+
if (saved) {
561+
mat.opacity = saved.opacity || 1.0;
562+
mat.transparent = saved.transparent;
563+
mat.needsUpdate = true;
564+
}
565+
}
566+
}
567+
551568
this._isolated = true;
552569
}
553570

0 commit comments

Comments
 (0)