Skip to content

Commit

Permalink
Add bundled assets for 2D evergreen field & KitBot
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Aug 26, 2023
1 parent 4a7aa4d commit b046d25
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 7 deletions.
13 changes: 13 additions & 0 deletions bundledAssets/Field2d_Evergreen/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Evergreen",
"topLeft": [
267,
132
],
"bottomRight": [
4733,
2356
],
"widthInches": 648,
"heightInches": 324
}
Binary file added bundledAssets/Field2d_Evergreen/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 106 additions & 0 deletions bundledAssets/Robot_KitBot/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"name": "KitBot",
"sourceUrl": "https://cad.onshape.com/documents/eeba08a27f462f02e601684e/w/0f61d86476db9c2997f2f9e2/e/d3543ebb4bf93b5d352a38fe",
"rotations": [
{
"axis": "z",
"degrees": 90
}
],
"position": [
0.12,
3.15,
0
],
"cameras": [
{
"name": "Front Camera",
"rotations": [
{
"axis": "y",
"degrees": 20
}
],
"position": [
0.2,
0,
0.8
],
"resolution": [
960,
720
],
"fov": 100
},
{
"name": "Back Camera",
"rotations": [
{
"axis": "y",
"degrees": 20
},
{
"axis": "z",
"degrees": 180
}
],
"position": [
-0.2,
0,
0.8
],
"resolution": [
960,
720
],
"fov": 100
},
{
"name": "Left Camera",
"rotations": [
{
"axis": "y",
"degrees": 20
},
{
"axis": "z",
"degrees": 90
}
],
"position": [
0,
0.2,
0.8
],
"resolution": [
960,
720
],
"fov": 90
},
{
"name": "Right Camera",
"rotations": [
{
"axis": "y",
"degrees": 20
},
{
"axis": "z",
"degrees": -90
}
],
"position": [
0,
-0.2,
0.8
],
"resolution": [
960,
720
],
"fov": 90
}
],
"components": []
}
Binary file added bundledAssets/Robot_KitBot/model.glb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"bundles/*",
"icons/**/*",
"!icons/**/*.iconset",
"bundledAssets/**/*",
"docs/**/*",
"!**/.*"
],
Expand Down
3 changes: 3 additions & 0 deletions src/hub/tabControllers/JoysticksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default class JoysticksController extends TimelineVizController {
(cell) => cell.lastElementChild as HTMLInputElement
);

// Add initial set of options
this.resetLayoutOptions();

// Enforce range
this.CONFIG_IDS.forEach((input) => {
input.addEventListener("change", () => {
Expand Down
1 change: 1 addition & 0 deletions src/main/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const STATE_FILENAME = path.join(
app.getPath("userData"),
"state-" + (app.isPackaged ? app.getVersion().replaceAll(".", "_") : "dev") + ".json"
);
export const BUNDLED_ASSETS = path.join(__dirname, "..", "bundledAssets");
export const AUTO_ASSETS = path.join(app.getPath("userData"), "autoAssets");
export const USER_ASSETS = path.join(app.getPath("userData"), "userAssets");
export const LEGACY_ASSETS = path.join(app.getPath("userData"), "frcData");
Expand Down
27 changes: 20 additions & 7 deletions src/main/assetsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ConfigJoystick_Joystick
} from "../shared/AdvantageScopeAssets";
import { checkArrayType } from "../shared/util";
import { AUTO_ASSETS, LEGACY_ASSETS, USER_ASSETS, WINDOW_ICON } from "./Constants";
import { AUTO_ASSETS, BUNDLED_ASSETS, LEGACY_ASSETS, USER_ASSETS, WINDOW_ICON } from "./Constants";

const USER_ASSETS_README =
'This folder contains extra assets for the odometry, 3D field, and joystick views. For more details, see the "Custom Fields/Robots/Joysticks" page in the AdvantageScope documentation (available through the documentation tab in the app or the URL below).\n\nhttps://github.com/Mechanical-Advantage/AdvantageScope/blob/main/docs/CUSTOM-CONFIG.md';
Expand Down Expand Up @@ -113,8 +113,8 @@ export function loadAssets(): AdvantageScopeAssets {
joysticks: []
};

// Load user assets first so they take priority
[USER_ASSETS, AUTO_ASSETS].forEach((parentFolder) => {
// Highest priority is first
[USER_ASSETS, AUTO_ASSETS, BUNDLED_ASSETS].forEach((parentFolder) => {
fs.readdirSync(parentFolder, { withFileTypes: true })
.sort((a, b) => (a.name < b.name ? 1 : a.name > b.name ? -1 : 0)) // Inverse order so newer versions take priority
.forEach((object) => {
Expand Down Expand Up @@ -475,10 +475,23 @@ export function loadAssets(): AdvantageScopeAssets {
assets = uniqueAssets;

// Sort assets
assets.field2ds.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));
assets.field3ds.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));
assets.robots.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
assets.joysticks.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));
{
// Evergeen field in asset files, sort to end of list
assets.field2ds.sort((a, b) => {
if (a.name == "Evergreen") return 1;
if (b.name == "Evergreen") return -1;
return a.name > b.name ? -1 : b.name > a.name ? 1 : 0;
});

// Built-in fields added in code to end of list
assets.field3ds.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));

// All robots in asset files, no special sorting required
assets.robots.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));

// Built-in joysticks added in code to beginning of list
assets.joysticks.sort((a, b) => (a.name > b.name ? -1 : b.name > a.name ? 1 : 0));
}

return assets;
}

0 comments on commit b046d25

Please sign in to comment.