fix(selection): selected objects keep their texture (light glow, no wash)

Selecting a textured wall/slab/item replaced its surface with a flat
purple wash. Root cause: the selection highlight clones the material and
tints it, but `NodeMaterial.clone()` on the WebGPU backend drops the
texture-map node assignments, so the clone rendered flat — and a strong
albedo blend + emissive washed whatever was left.

Fix: re-attach the maps from the source material after cloning (shared by
reference) and drop the albedo tint, keeping only a gentle indigo emissive
so the real material/texture stays readable with a soft "selected" glow.
Applied to both highlight paths:
- generic editor highlight (slabs/items) in selection-manager
- wall path (walls are excluded from the generic one), built lazily +
  cached/self-healing so it survives the wall finish's async texture load

Removes the now-dead eager wall `highlightedVisible`/`selection` profile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wassim SAMAD
2026-06-19 17:17:41 -04:00
co-authored by Claude Opus 4.8
parent f2352616d9
commit 8633886eef
3 changed files with 95 additions and 31 deletions
@@ -4,7 +4,7 @@ import { useEffect, useRef } from 'react'
import type { Material } from 'three'
import { type Mesh, Vector3 } from 'three/webgpu'
import useViewer from '../../store/use-viewer'
import { getMaterialsForWall } from './wall-materials'
import { getMaterialsForWall, getSelectionHighlightMaterials } from './wall-materials'
const tmpVec = new Vector3()
const u = new Vector3()
@@ -117,13 +117,13 @@ export const WallCutout = () => {
;(wallMesh as Mesh).material = isDeleteHighlighted
? materials.deleteInvisible
: isSelectionHighlighted
? materials.highlightedInvisible
? getSelectionHighlightMaterials(materials.invisible)
: materials.invisible
} else {
;(wallMesh as Mesh).material = isDeleteHighlighted
? materials.deleteVisible
: isSelectionHighlighted
? materials.highlightedVisible
? getSelectionHighlightMaterials(materials.visible)
: materials.visible
}
})
@@ -156,9 +156,9 @@ export const WallCutout = () => {
)
const current = wallMesh.material as Material | Material[]
snapshot.set(wallMesh, current)
if (current === mats.highlightedVisible || current === mats.deleteVisible) {
if (current === mats.deleteVisible) {
wallMesh.material = mats.visible
} else if (current === mats.highlightedInvisible || current === mats.deleteInvisible) {
} else if (current === mats.deleteInvisible) {
wallMesh.material = mats.invisible
}
})