Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begin splitting up the simulation schema
- Loading branch information
1 parent
515fdb8
commit bfa08c7
Showing
4 changed files
with
145 additions
and
134 deletions.
There are no files selected for viewing
137 changes: 3 additions & 134 deletions
137
src/components/ide/Simulator/simulation/schema/index.js
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 |
---|---|---|
@@ -1,136 +1,5 @@ | ||
// @flow | ||
|
||
export type Point = {| | ||
x: number, | ||
y: number, | ||
|}; | ||
|
||
export type Pose = {| | ||
x: number, | ||
y: number, | ||
angle: number, | ||
|}; | ||
|
||
type Translation = {| | ||
position: Point, | ||
|}; | ||
|
||
type Rotation = {| | ||
angle: number, | ||
|}; | ||
|
||
type RenderColor = {| | ||
fillStyle?: string, | ||
|}; | ||
|
||
type RenderVisibility = {| | ||
opacity?: number, | ||
visible?: boolean, | ||
|}; | ||
|
||
type RenderSprite = {| | ||
sprite?: { | ||
texture?: string, | ||
}, | ||
|}; | ||
|
||
type Static = {| | ||
isStatic?: boolean, | ||
|}; | ||
|
||
type Sensor = {| | ||
isSensor?: boolean, | ||
|}; | ||
|
||
type Line = {| | ||
plugin?: { | ||
hedgehog: { | ||
isLine?: boolean, | ||
}, | ||
}, | ||
|}; | ||
|
||
type Density = {| | ||
density?: number, | ||
|}; | ||
|
||
type FrictionAir = {| | ||
frictionAir?: number, | ||
|}; | ||
|
||
type Label = {| | ||
label?: string, | ||
|}; | ||
|
||
export type RobotProps = {| | ||
...Translation, | ||
...Rotation, | ||
render?: { | ||
...RenderColor, | ||
...RenderSprite, | ||
}, | ||
|}; | ||
|
||
type AllProps = {| | ||
...RobotProps, | ||
render?: { | ||
...RenderColor, | ||
...RenderVisibility, | ||
...RenderSprite, | ||
}, | ||
...Static, | ||
...Sensor, | ||
...Line, | ||
...Density, | ||
...FrictionAir, | ||
...Label, | ||
|}; | ||
|
||
export type Rectangle = { | ||
type: 'rectangle', | ||
width: number, | ||
height: number, | ||
...AllProps, | ||
}; | ||
|
||
export type Circle = { | ||
type: 'circle', | ||
radius: number, | ||
...AllProps, | ||
}; | ||
|
||
export type Svg = { | ||
type: 'svg', | ||
src: string, | ||
scale: number, | ||
granularity: number, | ||
...AllProps, | ||
}; | ||
|
||
export type TouchSensor = { | ||
type: 'touch', | ||
port: number, | ||
objects: Object[], | ||
}; | ||
|
||
export type RobotPart = TouchSensor; | ||
|
||
export type Robot = { | ||
type: 'robot', | ||
name: string, | ||
...RobotProps, | ||
parts: RobotPart[], | ||
}; | ||
|
||
export type Simulation = { | ||
center: Point, | ||
width: number, | ||
height: number, | ||
}; | ||
|
||
export type Object = Rectangle | Circle | Svg | Robot; | ||
|
||
export type SimulatorJson = { | ||
simulation: Simulation, | ||
objects: Object[], | ||
}; | ||
export * from './misc'; | ||
export * from './objects'; | ||
export * from './simulation'; |
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,11 @@ | ||
// @flow | ||
|
||
export type Point = {| | ||
x: number, | ||
y: number, | ||
|}; | ||
|
||
export type Pose = {| | ||
...Point, | ||
angle: number, | ||
|}; |
116 changes: 116 additions & 0 deletions
116
src/components/ide/Simulator/simulation/schema/objects.js
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,116 @@ | ||
// @flow | ||
|
||
import type { Point } from './misc'; | ||
|
||
type Translation = {| | ||
position: Point, | ||
|}; | ||
|
||
type Rotation = {| | ||
angle: number, | ||
|}; | ||
|
||
type RenderColor = {| | ||
fillStyle?: string, | ||
|}; | ||
|
||
type RenderVisibility = {| | ||
opacity?: number, | ||
visible?: boolean, | ||
|}; | ||
|
||
type RenderSprite = {| | ||
sprite?: { | ||
texture?: string, | ||
}, | ||
|}; | ||
|
||
type Static = {| | ||
isStatic?: boolean, | ||
|}; | ||
|
||
type Sensor = {| | ||
isSensor?: boolean, | ||
|}; | ||
|
||
type Line = {| | ||
plugin?: { | ||
hedgehog: { | ||
isLine?: boolean, | ||
}, | ||
}, | ||
|}; | ||
|
||
type Density = {| | ||
density?: number, | ||
|}; | ||
|
||
type FrictionAir = {| | ||
frictionAir?: number, | ||
|}; | ||
|
||
type Label = {| | ||
label?: string, | ||
|}; | ||
|
||
export type RobotProps = {| | ||
...Translation, | ||
...Rotation, | ||
render?: { | ||
...RenderColor, | ||
...RenderSprite, | ||
}, | ||
|}; | ||
|
||
type AllProps = {| | ||
...RobotProps, | ||
render?: { | ||
...RenderColor, | ||
...RenderVisibility, | ||
...RenderSprite, | ||
}, | ||
...Static, | ||
...Sensor, | ||
...Line, | ||
...Density, | ||
...FrictionAir, | ||
...Label, | ||
|}; | ||
|
||
export type Rectangle = { | ||
type: 'rectangle', | ||
width: number, | ||
height: number, | ||
...AllProps, | ||
}; | ||
|
||
export type Circle = { | ||
type: 'circle', | ||
radius: number, | ||
...AllProps, | ||
}; | ||
|
||
export type Svg = { | ||
type: 'svg', | ||
src: string, | ||
scale: number, | ||
granularity: number, | ||
...AllProps, | ||
}; | ||
|
||
export type TouchSensor = { | ||
type: 'touch', | ||
port: number, | ||
objects: Object[], | ||
}; | ||
|
||
export type RobotPart = TouchSensor; | ||
|
||
export type Robot = { | ||
type: 'robot', | ||
name: string, | ||
...RobotProps, | ||
parts: RobotPart[], | ||
}; | ||
|
||
export type Object = Rectangle | Circle | Svg | Robot; |
15 changes: 15 additions & 0 deletions
15
src/components/ide/Simulator/simulation/schema/simulation.js
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,15 @@ | ||
// @flow | ||
|
||
import type { Point } from './misc'; | ||
import type { Object } from './objects'; | ||
|
||
export type Simulation = { | ||
center: Point, | ||
width: number, | ||
height: number, | ||
}; | ||
|
||
export type SimulatorJson = { | ||
simulation: Simulation, | ||
objects: Object[], | ||
}; |