Initial commit
This commit is contained in:
94
types.ts
Normal file
94
types.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
export enum ObjectType {
|
||||
AXIS_LINEAR = 'AXIS_LINEAR',
|
||||
AXIS_ROTARY = 'AXIS_ROTARY',
|
||||
CYLINDER = 'CYLINDER',
|
||||
SWITCH = 'SWITCH',
|
||||
LED = 'LED',
|
||||
}
|
||||
|
||||
export interface Vec3 {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
}
|
||||
|
||||
export interface BaseObject {
|
||||
id: string;
|
||||
name: string;
|
||||
type: ObjectType;
|
||||
position: Vec3;
|
||||
rotation: Vec3; // Euler angles in radians
|
||||
}
|
||||
|
||||
export interface AxisPositionTrigger {
|
||||
id: string;
|
||||
position: number;
|
||||
condition: '>' | '<';
|
||||
targetInputPort: number; // Sets this Input bit when condition met
|
||||
}
|
||||
|
||||
export interface AxisObject extends BaseObject {
|
||||
type: ObjectType.AXIS_LINEAR | ObjectType.AXIS_ROTARY;
|
||||
min: number;
|
||||
max: number;
|
||||
currentValue: number;
|
||||
targetValue: number;
|
||||
speed: number;
|
||||
isOscillating: boolean;
|
||||
triggers: AxisPositionTrigger[]; // Axis drives Inputs
|
||||
}
|
||||
|
||||
export interface CylinderObject extends BaseObject {
|
||||
type: ObjectType.CYLINDER;
|
||||
stroke: number;
|
||||
extended: boolean;
|
||||
currentPosition: number;
|
||||
speed: number;
|
||||
outputPort: number; // Reads this Output bit to extend
|
||||
}
|
||||
|
||||
export interface SwitchObject extends BaseObject {
|
||||
type: ObjectType.SWITCH;
|
||||
isOn: boolean;
|
||||
isMomentary: boolean;
|
||||
inputPort: number; // Sets this Input bit when pressed
|
||||
}
|
||||
|
||||
export interface LedObject extends BaseObject {
|
||||
type: ObjectType.LED;
|
||||
isOn: boolean;
|
||||
color: string;
|
||||
outputPort: number; // Reads this Output bit to turn on
|
||||
}
|
||||
|
||||
export type SimObject = AxisObject | CylinderObject | SwitchObject | LedObject;
|
||||
|
||||
// Logic Types
|
||||
export enum LogicCondition {
|
||||
IS_ON = 'IS_ON',
|
||||
IS_OFF = 'IS_OFF',
|
||||
}
|
||||
|
||||
export enum LogicAction {
|
||||
SET_ON = 'ON',
|
||||
SET_OFF = 'OFF',
|
||||
TOGGLE = 'TOGGLE',
|
||||
}
|
||||
|
||||
export interface IOLogicRule {
|
||||
id: string;
|
||||
inputPort: number;
|
||||
condition: LogicCondition;
|
||||
outputPort: number;
|
||||
action: LogicAction;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
// Full Project Export Type
|
||||
export interface ProjectData {
|
||||
version: string;
|
||||
objects: SimObject[];
|
||||
logicRules: IOLogicRule[];
|
||||
inputNames: string[];
|
||||
outputNames: string[];
|
||||
}
|
||||
Reference in New Issue
Block a user