refactor(relationships): clarify immersive galaxy framing

This commit is contained in:
digua committed 2026-07-01 01:06:36 +08:00
1 parent 33eab9b98c
commit b71f18f8f0
3 files changed
+11 -9

No files matched your search

@@ -18,7 +18,7 @@ import { buildRelationshipVisibleLabelKeys } from '../relationship-galaxy-connec
import {
applyRelationshipGalaxy3DSafeArea,
buildRelationshipGalaxy3DViewOffset,
buildRelationshipGalaxy3DFitCameraPose,
buildRelationshipGalaxy3DImmersiveCameraPose,
type RelationshipGalaxy3DCameraPose,
} from '../relationship-galaxy-3d-camera'
import { maskRelationshipGalaxyPrivateText } from '../relationship-galaxy-privacy'
@@ -615,7 +615,7 @@ function fitView() {
if (!camera || !controls) return
hasUserMovedCamera = false
const pose = applySafeAreaToCameraPose(buildRelationshipGalaxy3DFitCameraPose(sceneModel.value.bounds))
const pose = applySafeAreaToCameraPose(buildRelationshipGalaxy3DImmersiveCameraPose(sceneModel.value.bounds))
startCameraFlight(
new THREE.Vector3(pose.position.x, pose.position.y, pose.position.z),
new THREE.Vector3(pose.target.x, pose.target.y, pose.target.z),
@@ -7,11 +7,11 @@ import test from 'node:test'
import {
applyRelationshipGalaxy3DSafeArea,
buildRelationshipGalaxy3DViewOffset,
buildRelationshipGalaxy3DFitCameraPose,
buildRelationshipGalaxy3DImmersiveCameraPose,
} from './relationship-galaxy-3d-camera'
test('fits the panorama with enough padding for a selected relationship network', () => {
const pose = buildRelationshipGalaxy3DFitCameraPose({
test('frames the 3D panorama tightly for an immersive default view', () => {
const pose = buildRelationshipGalaxy3DImmersiveCameraPose({
minX: -5000,
maxX: 5000,
minY: -3600,
@@ -28,9 +28,11 @@ export interface RelationshipGalaxy3DViewOffset {
height: number
}
const FIT_CAMERA_PADDING_SCALE = 0.9
// The default 3D galaxy view intentionally uses tight, immersive framing.
// Edge nodes may sit near or slightly beyond the viewport instead of always being fully contained.
const IMMERSIVE_CAMERA_PADDING_SCALE = 0.9
export function buildRelationshipGalaxy3DFitCameraPose(
export function buildRelationshipGalaxy3DImmersiveCameraPose(
bounds: RelationshipGalaxy3DScene['bounds']
): RelationshipGalaxy3DCameraPose {
const span = Math.max(bounds.width, bounds.height, bounds.depth, 900)
@@ -38,8 +40,8 @@ export function buildRelationshipGalaxy3DFitCameraPose(
return {
position: {
x: 0,
y: -span * 0.5 * FIT_CAMERA_PADDING_SCALE,
z: span * 0.5 * FIT_CAMERA_PADDING_SCALE,
y: -span * 0.5 * IMMERSIVE_CAMERA_PADDING_SCALE,
z: span * 0.5 * IMMERSIVE_CAMERA_PADDING_SCALE,
},
target: { x: 0, y: 0, z: 0 },
}