From dad03e3be5b0a7c1159e0207cce11540ca830359 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Mon, 3 Jan 2022 17:21:18 +0100 Subject: feat(filter): add option to filter by subdirectory (#190) --- components/Tweaks/Physics/PhysicsPanel.tsx | 143 +++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 components/Tweaks/Physics/PhysicsPanel.tsx (limited to 'components/Tweaks/Physics/PhysicsPanel.tsx') diff --git a/components/Tweaks/Physics/PhysicsPanel.tsx b/components/Tweaks/Physics/PhysicsPanel.tsx new file mode 100644 index 0000000..82dd6b7 --- /dev/null +++ b/components/Tweaks/Physics/PhysicsPanel.tsx @@ -0,0 +1,143 @@ +import { + Text, + Accordion, + AccordionButton, + AccordionIcon, + AccordionItem, + AccordionPanel, + Box, + Flex, + StackDivider, + Switch, + VStack, +} from '@chakra-ui/react' +import React, { useCallback } from 'react' +import { initialPhysics } from '../../config' +import { EnableSection } from '../EnableSection' +import { SliderWithInfo } from '../SliderWithInfo' + +export interface PhysicsPanelProps { + physics: typeof initialPhysics + setPhysics: any +} + +export const PhysicsPanel = (props: PhysicsPanelProps) => { + const { physics, setPhysics } = props + const setPhysicsCallback = useCallback((val: number, phys: string, scale: number) => { + setPhysics((curr: typeof initialPhysics) => { + return { ...curr, [phys]: val / scale } + }) + }, []) + return ( + + } + align="stretch" + paddingLeft={7} + color="gray.800" + > + setPhysics({ ...physics, gravityOn: !physics.gravityOn })} + > + + Also in local + { + setPhysics((curr: typeof initialPhysics) => { + return { ...curr, gravityLocal: !curr.gravityLocal } + }) + }} + isChecked={physics.gravityLocal} + > + + setPhysicsCallback(v, 'gravity', 10)} + /> + + setPhysicsCallback(v, 'charge', -1 / 100)} + label="Repulsive Force" + /> + setPhysicsCallback(v, 'linkStrength', 5)} + label="Link Force" + /> + setPhysicsCallback(v, 'alphaDecay', 50)} + /> + + + + + + Advanced + + + + } + align="stretch" + paddingLeft={3} + color="gray.800" + > + setPhysics({ ...physics, collision: !physics.collision })} + > + setPhysicsCallback(v, 'collisionStrength', 1 / 5)} + label="Collision Radius" + infoText="Easy with this one, high values can lead to a real jiggly mess" + /> + + setPhysicsCallback(v, 'linkIts', 1)} + min={0} + max={6} + step={1} + infoText="How many links down the line the physics of a single node affects (Slow)" + /> + setPhysicsCallback(v, 'velocityDecay', 10)} + /> + setPhysics({ ...physics, centering: !physics.centering })} + infoText="Keeps the nodes in the center of the viewport. If disabled you can drag the nodes anywhere you want." + > + setPhysicsCallback(v, 'centeringStrength', 1)} + /> + + + + + + + + ) +} -- cgit v1.2.3