Skip to content

Commit

Permalink
feat: selection v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rassl committed Dec 24, 2024
1 parent 2e01809 commit f3a7336
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 199 deletions.
7 changes: 4 additions & 3 deletions src/components/Universe/Controls/CameraAnimations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export const useCameraAnimations = (

useAutoNavigate(cameraControlsRef)

const isUserDragging = useControlStore((s) => s.isUserDragging)

const { graphRadius, disableCameraRotation } = useGraphStore((s) => s)
const { graphRadius } = useGraphStore((s) => s)

useEffect(() => {
if (!enabled) {
Expand Down Expand Up @@ -58,6 +56,9 @@ export const useCameraAnimations = (
useFrame((_, delta) => {
if (cameraControlsRef.current) {
// do camera rotation
const { disableCameraRotation } = useGraphStore.getState()
const { isUserDragging } = useControlStore.getState()

if (!disableCameraRotation && !isUserDragging) {
cameraControlsRef.current.azimuthAngle += autoRotateSpeed * delta * MathUtils.DEG2RAD
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
import { memo } from 'react'
import { useGraphStore } from '~/stores/useGraphStore'
import { Link } from '~/types'
import { LinkPosition } from '../../..'
import { Connection } from './Connection'

type Props = {
linksPosition: Map<string, LinkPosition>
links: Link[]
}

export const Connections = memo(({ linksPosition }: Props) => {
const { selectionGraphData } = useGraphStore((s) => s)
export const Connections = memo(({ linksPosition, links }: Props) => (
<group name="simulation-3d-group__connections">
{links?.map((l: Link) => {
const position = linksPosition.get(l.ref_id) || {
sx: 0,
sy: 0,
sz: 0,
tx: 0,
ty: 0,
tz: 0,
}

return (
<group name="simulation-3d-group__connections">
{selectionGraphData?.links.map((l: Link) => {
const position = linksPosition.get(l.ref_id) || {
sx: 0,
sy: 0,
sz: 0,
tx: 0,
ty: 0,
tz: 0,
}

return (
<Connection
key={l.ref_id}
label={l.edge_type}
sourceX={position.sx}
sourceY={position.sy}
sourceZ={position.sz}
targetX={position.tx}
targetY={position.ty}
targetZ={position.tz}
/>
)
})}
</group>
)
})
return (
<Connection
key={l.ref_id}
label={l.edge_type}
sourceX={position.sx}
sourceY={position.sy}
sourceZ={position.sz}
targetX={position.tx}
targetY={position.ty}
targetZ={position.tz}
/>
)
})}
</group>
))

Connections.displayName = 'Connections'
Loading

0 comments on commit f3a7336

Please sign in to comment.