mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
fix(relationships): keep filtered galaxy edges restrained
Use one ambient edge budget and opacity across graph scopes so filtered views do not become denser or brighter than the panorama.
This commit is contained in:
1 parent
c13f885eee
commit
d5ad36dee6
5 files changed
+16
-25
No files matched your search
@@ -81,13 +81,11 @@ const props = withDefaults(
|
||||
graph: RelationshipGalaxyRenderGraph
|
||||
selectedKey?: string | null
|
||||
safeInsetRight?: number
|
||||
emphasizeEdges?: boolean
|
||||
label: string
|
||||
}>(),
|
||||
{
|
||||
selectedKey: null,
|
||||
safeInsetRight: 0,
|
||||
emphasizeEdges: false,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -194,7 +192,7 @@ function renderGraph(shouldFit = false) {
|
||||
hoveredKey.value = null
|
||||
labelFrame = 0
|
||||
labels.value = []
|
||||
ambientVisibleEdgeIds = selectRelationshipGalaxy3DAmbientEdgeIds(model, props.emphasizeEdges)
|
||||
ambientVisibleEdgeIds = selectRelationshipGalaxy3DAmbientEdgeIds(model)
|
||||
selectedVisibleEdgeIds = selectRelationshipGalaxy3DSelectedEdgeIds(model)
|
||||
primarySelectedEdgeIds = selectRelationshipGalaxy3DPrimarySelectedEdgeIds(model)
|
||||
|
||||
@@ -228,7 +226,7 @@ function applyGraphState() {
|
||||
sceneModel.value = model
|
||||
updateSelectedVisibleLabelKeys()
|
||||
rebuildNeighborKeys(model)
|
||||
ambientVisibleEdgeIds = selectRelationshipGalaxy3DAmbientEdgeIds(model, props.emphasizeEdges)
|
||||
ambientVisibleEdgeIds = selectRelationshipGalaxy3DAmbientEdgeIds(model)
|
||||
selectedVisibleEdgeIds = selectRelationshipGalaxy3DSelectedEdgeIds(model)
|
||||
primarySelectedEdgeIds = selectRelationshipGalaxy3DPrimarySelectedEdgeIds(model)
|
||||
|
||||
@@ -472,7 +470,7 @@ function addThinEdgePaths(
|
||||
function getEdgeLayerOpacity(bucket: 'dim' | 'normal' | 'highlight'): number {
|
||||
if (bucket === 'highlight') return 0.76
|
||||
if (bucket === 'normal' && props.selectedKey) return 0.09
|
||||
if (bucket === 'normal') return props.emphasizeEdges ? 0.2 : 0.14
|
||||
if (bucket === 'normal') return 0.14
|
||||
return 0.028
|
||||
}
|
||||
|
||||
@@ -1215,7 +1213,7 @@ onMounted(async () => {
|
||||
await initCanvas()
|
||||
})
|
||||
|
||||
watch([() => props.graph, () => props.selectedKey, () => props.emphasizeEdges], applyGraphState, {
|
||||
watch([() => props.graph, () => props.selectedKey], applyGraphState, {
|
||||
flush: 'post',
|
||||
})
|
||||
|
||||
|
||||
+8
-1
@@ -120,13 +120,20 @@ test('builds restrained foreground and background fog veils around communities',
|
||||
|
||||
test('keeps the panorama edge hierarchy bounded while preserving the strongest relationships', () => {
|
||||
const scene = createScene(100, 500)
|
||||
const visible = selectRelationshipGalaxy3DAmbientEdgeIds(scene, false)
|
||||
const visible = selectRelationshipGalaxy3DAmbientEdgeIds(scene)
|
||||
|
||||
assert.equal(visible.size, 170)
|
||||
assert.equal(visible.has('edge-0'), true)
|
||||
assert.equal(visible.has('edge-499'), false)
|
||||
})
|
||||
|
||||
test('keeps compact filtered graphs within the same restrained ambient edge cap', () => {
|
||||
const scene = createScene(150, 500)
|
||||
const visible = selectRelationshipGalaxy3DAmbientEdgeIds(scene)
|
||||
|
||||
assert.equal(visible.size, 200)
|
||||
})
|
||||
|
||||
test('keeps only direct relationship lines in the selected overlay', () => {
|
||||
const scene = createScene(100, 120)
|
||||
const selected = selectRelationshipGalaxy3DSelectedEdgeIds(scene)
|
||||
|
||||
@@ -87,11 +87,8 @@ export function buildRelationshipGalaxy3DFogVeils(model: RelationshipGalaxy3DSce
|
||||
)
|
||||
}
|
||||
|
||||
export function selectRelationshipGalaxy3DAmbientEdgeIds(
|
||||
model: RelationshipGalaxy3DScene,
|
||||
emphasizeEdges: boolean
|
||||
): Set<string> {
|
||||
const limit = clamp(Math.round(model.nodes.length * (emphasizeEdges ? 2.4 : 1.7)), 32, emphasizeEdges ? 260 : 200)
|
||||
export function selectRelationshipGalaxy3DAmbientEdgeIds(model: RelationshipGalaxy3DScene): Set<string> {
|
||||
const limit = clamp(Math.round(model.nodes.length * 1.7), 32, 200)
|
||||
return new Set(
|
||||
[...model.edges]
|
||||
.sort(compareAmbientEdges)
|
||||
|
||||
@@ -61,7 +61,6 @@ const props = withDefaults(
|
||||
selectedKey?: string | null
|
||||
privacyMode?: boolean
|
||||
safeInsetRight?: number
|
||||
emphasizeEdges?: boolean
|
||||
label: string
|
||||
ownerLabel: string
|
||||
}>(),
|
||||
@@ -69,7 +68,6 @@ const props = withDefaults(
|
||||
selectedKey: null,
|
||||
privacyMode: false,
|
||||
safeInsetRight: 0,
|
||||
emphasizeEdges: false,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -347,7 +345,7 @@ function renderGraph(shouldFit = false) {
|
||||
const targetX = target.x + offsetX
|
||||
const targetY = target.y + offsetY
|
||||
|
||||
const alpha = edge.visibility === 2 ? (props.emphasizeEdges ? 0.26 : 0.22) : props.emphasizeEdges ? 0.1 : 0.07
|
||||
const alpha = edge.visibility === 2 ? 0.22 : 0.07
|
||||
const width = Math.min(1.4, Math.max(0.4, Math.log10(edge.weight + 1) * 0.75))
|
||||
const edgeColor = getNodeColor(source)
|
||||
edgeLayer.moveTo(sourceX, sourceY).lineTo(targetX, targetY).stroke({ color: edgeColor, width, alpha })
|
||||
@@ -776,14 +774,7 @@ onMounted(async () => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [
|
||||
props.graph.nodes,
|
||||
props.graph.edges,
|
||||
props.selectedKey,
|
||||
props.privacyMode,
|
||||
props.safeInsetRight,
|
||||
props.emphasizeEdges,
|
||||
],
|
||||
() => [props.graph.nodes, props.graph.edges, props.selectedKey, props.privacyMode, props.safeInsetRight],
|
||||
() => {
|
||||
renderGraph(false)
|
||||
},
|
||||
|
||||
@@ -697,7 +697,6 @@ onBeforeUnmount(() => {
|
||||
:graph="threeCanvasRenderGraph"
|
||||
:selected-key="threeCanvasSelectedKey"
|
||||
:safe-inset-right="detailPanelSafeInsetRight"
|
||||
:emphasize-edges="graphScope === 'friends'"
|
||||
:label="t('relationships.canvas.label3d')"
|
||||
@fallback="handleThreeCanvasFallback"
|
||||
@select-node="selectRenderNode"
|
||||
@@ -709,7 +708,6 @@ onBeforeUnmount(() => {
|
||||
:selected-key="canvasSelectedKey"
|
||||
:privacy-mode="privacyMode"
|
||||
:safe-inset-right="detailPanelSafeInsetRight"
|
||||
:emphasize-edges="graphScope === 'friends'"
|
||||
:label="t('relationships.canvas.label')"
|
||||
:owner-label="t('relationships.owner.me')"
|
||||
@select-node="selectNode"
|
||||
|
||||
Reference in new issue
Block a user