Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#1066 - Show the current selected direction on the tracker mounting radial menu #1077

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import classNames from 'classnames';
import { MouseEventHandler } from 'react';
import ReactModal from 'react-modal';
import { useElemSize, useLayout } from '@/hooks/layout';
import { Button } from '@/components/commons/Button';
import { Typography } from '@/components/commons/Typography';
import { useLocalization } from '@fluent/react';
import { FootIcon } from '@/components/commons/icon/FootIcon';
import { rotationToQuatMap } from '@/maths/quaternion';
import { rotationToQuatMap, similarQuaternions } from '@/maths/quaternion';
import { Quaternion } from 'three';
import { SlimeUpIcon } from '@/components/commons/icon/SlimeUpIcon';
import { BodyPart } from 'solarxr-protocol';
Expand Down Expand Up @@ -113,14 +112,18 @@ export function MountingBodyPartIcon({
}

function PieSliceOfFeet({
onClick,
direction,
onDirectionSelected,
currRotation,
id,
d,
noText = false,
trackerTransform,
trackerWidth = 10,
}: {
onClick?: MouseEventHandler<SVGGElement>;
direction: Quaternion;
onDirectionSelected: (direction: Quaternion) => void;
currRotation?: Quaternion;
id: string;
d: string;
noText?: boolean;
Expand All @@ -131,7 +134,7 @@ function PieSliceOfFeet({

return (
<g
onClick={onClick}
onClick={() => onDirectionSelected(direction)}
className={classNames('group fill-background-10 stroke-background-10')}
>
<path
Expand All @@ -150,7 +153,12 @@ function PieSliceOfFeet({
</text>
<g
transform={trackerTransform}
className="fill-none stroke-none group-hover:fill-accent-background-20"
className={classNames(
'stroke-none group-hover:fill-accent-background-20',
currRotation && similarQuaternions(currRotation, direction)
? 'fill-background-90'
: 'fill-none'
)}
>
<SlimeUpIcon width={trackerWidth}></SlimeUpIcon>
</g>
Expand All @@ -163,11 +171,13 @@ export function MountingSelectionMenu({
onClose,
onDirectionSelected,
bodyPart,
currRotation,
}: {
isOpen: boolean;
onClose: () => void;
onDirectionSelected: (direction: Quaternion) => void;
bodyPart?: BodyPart;
currRotation?: Quaternion;
}) {
const { l10n } = useLocalization();
const { ref: refTrackers, layoutHeight: trackersHeight } =
Expand Down Expand Up @@ -209,63 +219,71 @@ export function MountingSelectionMenu({
<g strokeWidth="4" className="stroke-background-90">
<PieSliceOfFeet
d="M0 0-89 44A99 99 0 0 1-89-44Z"
onClick={() => onDirectionSelected(rotationToQuatMap.LEFT)}
direction={rotationToQuatMap.LEFT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-left"
trackerTransform="translate(75, 0) scale(-1, 1)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-89-44A99 99 0 0 1-44-89Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.FRONT_LEFT)
}
direction={rotationToQuatMap.FRONT_LEFT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation_left_front"
noText={true}
trackerTransform="translate(-2, 175) rotate(-135)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
onClick={() => onDirectionSelected(rotationToQuatMap.FRONT)}
d="M0 0-44-89A99 99 0 0 1 44-89Z"
direction={rotationToQuatMap.FRONT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-front"
trackerTransform="translate(0, 75) rotate(-90)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 44-89A99 99 0 0 1 89-44Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.FRONT_RIGHT)
}
direction={rotationToQuatMap.FRONT_RIGHT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-front_right"
noText={true}
trackerTransform="translate(73, 0) rotate(-45)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 89-44A99 99 0 0 1 89 44Z"
onClick={() => onDirectionSelected(rotationToQuatMap.RIGHT)}
direction={rotationToQuatMap.RIGHT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-right"
trackerTransform="translate(175,0)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 89 44A99 99 0 0 1 44 89Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.BACK_RIGHT)
}
direction={rotationToQuatMap.BACK_RIGHT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-back_right"
noText={true}
trackerTransform="translate(252, 75) rotate(45)"
trackerWidth={7}
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0 44 89A99 99 0 0 1-44 89Z"
onClick={() => onDirectionSelected(rotationToQuatMap.BACK)}
direction={rotationToQuatMap.BACK}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-back"
trackerTransform="translate(250, 175) rotate(90)"
></PieSliceOfFeet>
<PieSliceOfFeet
d="M0 0-44 89A99 99 0 0 1-89 44Z"
onClick={() =>
onDirectionSelected(rotationToQuatMap.BACK_LEFT)
}
direction={rotationToQuatMap.BACK_LEFT}
onDirectionSelected={onDirectionSelected}
currRotation={currRotation}
id="tracker-rotation-back_left"
noText={true}
trackerTransform="translate(177, 250) rotate(135)"
Expand Down
1 change: 1 addition & 0 deletions gui/src/components/tracker/TrackerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function TrackerSettingsPage() {
></SingleTrackerBodyAssignmentMenu>
<MountingSelectionMenu
bodyPart={tracker?.tracker.info?.bodyPart}
currRotation={currRotation}
isOpen={selectRotation}
onClose={() => setSelectRotation(false)}
onDirectionSelected={onDirectionSelected}
Expand Down