-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2382 from stakwork/feature/layour3.0
Feature/layour3.0
- Loading branch information
Showing
11 changed files
with
192 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/components/Universe/Graph/Cubes/NodePoints/Point/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Billboard, Instance } from '@react-three/drei' | ||
|
||
type Props = { | ||
color: string | ||
} | ||
|
||
export const Point = ({ color }: Props) => ( | ||
<> | ||
<Billboard follow lockX={false} lockY={false} lockZ={false}> | ||
<Instance color={color} /> | ||
</Billboard> | ||
</> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Instances } from '@react-three/drei' | ||
import { memo, useMemo } from 'react' | ||
import { BufferGeometry, TorusGeometry } from 'three' | ||
import { useDataStore, useNodeTypes } from '~/stores/useDataStore' | ||
import { useSelectedNode } from '~/stores/useGraphStore' | ||
import { useSchemaStore } from '~/stores/useSchemaStore' | ||
import { NodeExtended } from '~/types' | ||
import { colors } from '~/utils' | ||
import { Point } from './Point' | ||
|
||
const COLORS_MAP = [ | ||
'#fff', | ||
'#9747FF', | ||
'#00887A', | ||
'#0098A6', | ||
'#0288D1', | ||
'#33691E', | ||
'#465A65', | ||
'#512DA7', | ||
'#5C6BC0', | ||
'#5D4038', | ||
'#662C00', | ||
'#689F39', | ||
'#6B1B00', | ||
'#750000', | ||
'#78909C', | ||
'#7E57C2', | ||
'#8C6E63', | ||
'#AA47BC', | ||
'#BF360C', | ||
'#C2175B', | ||
'#EC407A', | ||
'#EF6C00', | ||
'#F5511E', | ||
'#FF9696', | ||
'#FFC064', | ||
'#FFCD29', | ||
'#FFEA60', | ||
] | ||
|
||
// eslint-disable-next-line no-underscore-dangle | ||
const _NodePoints = () => { | ||
const selectedNode = useSelectedNode() | ||
const data = useDataStore((s) => s.dataInitial) | ||
const { normalizedSchemasByType } = useSchemaStore((s) => s) | ||
const nodeTypes = useNodeTypes() | ||
const ringGeometry = useMemo(() => new TorusGeometry(30, 4, 16, 100), []) | ||
|
||
return ( | ||
<> | ||
<Instances | ||
geometry={ringGeometry as BufferGeometry} | ||
limit={1000} // Optional: max amount of items (for calculating buffer size) | ||
range={1000} | ||
visible={!selectedNode} | ||
// Optional: draw-range | ||
> | ||
<meshStandardMaterial /> | ||
{data?.nodes.map((node: NodeExtended) => { | ||
const primaryColor = normalizedSchemasByType[node.node_type]?.primary_color | ||
const color = primaryColor ?? (COLORS_MAP[nodeTypes.indexOf(node.node_type)] || colors.white) | ||
|
||
return <Point key={node.ref_id} color={color} /> | ||
})} | ||
</Instances> | ||
</> | ||
) | ||
} | ||
|
||
export const NodePoints = memo(_NodePoints) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.