Skip to content

Commit 25cad67

Browse files
feat(cientos): mirror DecalDebugUI layer hover to 3D edges
1 parent 8d35ed0 commit 25cad67

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎packages/cientos/src/core/abstractions/Decal/DebugUI/LayerList.vue‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ function editById(id: string) {
7474
session.value?.beginEditById(id)
7575
}
7676
77+
// Mirror pointer-hover on a list row to the 3D edges helper, so the user
78+
// can scrub the list and see which decal is which. Composes with 3D
79+
// pointer hover through the session's `enteredEntries` set.
80+
function hoverById(id: string, on: boolean) {
81+
session.value?.setHoveredById(id, on)
82+
}
83+
7784
function toggleVisibility(event: Event, entry: DecalJsonEntry) {
7885
event.stopPropagation()
7986
if (!session.value) { return }
@@ -189,6 +196,8 @@ function reset() {
189196
]"
190197
:draggable="true"
191198
@click="editById(entry.id)"
199+
@mouseenter="hoverById(entry.id, true)"
200+
@mouseleave="hoverById(entry.id, false)"
192201
@dragstart="(e) => onDragStart(e, entry, group.meshName)"
193202
@dragover="(e) => onDragOver(e, entry, group.meshName)"
194203
@dragleave="onDragLeave(entry)"

‎packages/cientos/src/core/abstractions/Decal/Decal.vue‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ watch(stampedEntries, (entries) => {
440440
setZIndex: newZ => setZIndexForId(id, newZ),
441441
setVisibility: visible => setVisibilityForId(id, visible),
442442
remove: () => removeForId(id),
443+
setHovered: (on) => {
444+
const fresh = stampedEntries.value.find(e => e.id === id)
445+
if (!fresh) { return }
446+
if (on) { session.setHoveredEntry(fresh) }
447+
else { session.clearHoveredEntry(fresh) }
448+
},
443449
})
444450
registeredIds.add(id)
445451
}

‎packages/cientos/src/core/abstractions/Decal/useDecalEditor.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface DecalEntryActions {
8585
setZIndex: (newZ: number) => void
8686
setVisibility: (visible: boolean) => void
8787
remove: () => void
88+
setHovered: (on: boolean) => void
8889
}
8990

9091
interface HistoryEntry {
@@ -175,6 +176,12 @@ export interface DecalEditorSession {
175176
setVisibilityById: (id: string, visible: boolean) => boolean
176177
/** Remove a decal by id without entering edit mode. Returns `true` if a decal was removed. */
177178
removeById: (id: string) => boolean
179+
/**
180+
* Drive the 3D-side hover state from a non-3D surface (layer panel,
181+
* thumbnail strip, …). Composes with pointer-driven hover via the same
182+
* `enteredEntries` set, so external + 3D hover don't fight each other.
183+
*/
184+
setHoveredById: (id: string, on: boolean) => boolean
178185

179186
/**
180187
* Register a JSON-array setter for one Decal's mesh. Required for
@@ -624,6 +631,13 @@ function createSession(): DecalEditorSession {
624631
return true
625632
}
626633

634+
function setHoveredById(id: string, on: boolean): boolean {
635+
const actions = getEntryActions(id, 'setHoveredById')
636+
if (!actions) { return false }
637+
actions.setHovered(on)
638+
return true
639+
}
640+
627641
const meshNameByUuid = new Map<string, string>()
628642
function registerDecalData(meshUuid: string, meshName: string | null, setter: DecalDataSetter) {
629643
dataSetterRegistry.set(meshUuid, setter)
@@ -779,6 +793,7 @@ function createSession(): DecalEditorSession {
779793
setZIndexById,
780794
setVisibilityById,
781795
removeById,
796+
setHoveredById,
782797

783798
registerDecalData,
784799
unregisterDecalData,

0 commit comments

Comments
 (0)