Spaces:
Running
Running
File size: 2,733 Bytes
18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 3aea7c6 18b0fa5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
import type IUrdfJoint from "../interfaces/IUrdfJoint";
import type IUrdfLink from "../interfaces/IUrdfLink";
import type IUrdfRobot from "../interfaces/IUrdfRobot";
// Color constants for better maintainability
export const URDF_COLORS = {
COLLISION: "#813d9c", // purple
JOINT: "#62a0ea", // blue
LINK: "#57e389", // green
JOINT_INDICATOR: "#f66151", // red
HIGHLIGHT: "#ffa348", // orange
BACKGROUND: "#241f31" // dark purple
} as const;
// Transform tool types
export type TransformTool = "translate" | "rotate" | "scale";
// Joint state tracking
export interface JointStates {
continuous: Record<string, number>;
revolute: Record<string, number>;
}
// Selection state
export interface SelectionState {
selectedLink?: IUrdfLink;
selectedJoint?: IUrdfJoint;
}
// Visibility configuration
export interface VisibilityConfig {
visual: boolean;
collision: boolean;
joints: boolean;
jointNames: boolean;
linkNames: boolean;
}
// Appearance settings
export interface AppearanceConfig {
colors: {
collision: string;
joint: string;
link: string;
jointIndicator: string;
highlight: string;
background: string;
};
opacity: {
visual: number;
collision: number;
link: number;
};
}
// Editor configuration
export interface EditorConfig {
isEditMode: boolean;
currentTool: TransformTool;
snap: {
translation: number;
scale: number;
rotation: number;
};
}
// View configuration
export interface ViewConfig {
zoom: {
current: number;
initial: number;
};
nameHeight: number;
}
// Main URDF state interface
export interface UrdfState extends SelectionState {
robot?: IUrdfRobot;
jointStates: JointStates;
visibility: VisibilityConfig;
appearance: AppearanceConfig;
editor: EditorConfig;
view: ViewConfig;
}
// Create the reactive state
export const urdfState = $state<UrdfState>({
// Selection
selectedLink: undefined,
selectedJoint: undefined,
// Robot data
robot: undefined,
jointStates: {
continuous: {},
revolute: {}
},
// Visibility settings
visibility: {
visual: true,
collision: false,
joints: true,
jointNames: true,
linkNames: true
},
// Appearance settings
appearance: {
colors: {
collision: URDF_COLORS.COLLISION,
joint: URDF_COLORS.JOINT,
link: URDF_COLORS.LINK,
jointIndicator: URDF_COLORS.JOINT_INDICATOR,
highlight: URDF_COLORS.HIGHLIGHT,
background: URDF_COLORS.BACKGROUND
},
opacity: {
visual: 1.0,
collision: 0.7,
link: 1.0
}
},
// Editor configuration
editor: {
isEditMode: false,
currentTool: "translate",
snap: {
translation: 0.001,
scale: 0.001,
rotation: 1
}
},
// View configuration
view: {
zoom: {
current: 1.3,
initial: 1.3
},
nameHeight: 0.05
}
});
|