Skip to content

Commit

Permalink
Merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonPacewic committed Jun 28, 2024
2 parents 7b8c524 + 3df3929 commit b825c05
Show file tree
Hide file tree
Showing 9 changed files with 1,496 additions and 1,310 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/FissionUnitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ jobs:
- name: Install Dependencies
run: |
cd fission
rm package-lock.json
npm install
npm install -g run-script-os
npm run assetpack
npm run playwright:install
- name: Unit Tests
id: unit-tests
run: |
Expand Down
13 changes: 13 additions & 0 deletions fission/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ npm i
| `prettier:fix` | Runs prettier on the project to fix any issues with formating. **DO NOT USE**, I don't like the current format it uses. |
| `format` | Runs `prettier:fix` and `lint:fix`. **Do not use** for the same reasons as `prettier:fix`. |
| `assetpack` | Downloads the assetpack and unzips/installs it in the correct location. |
| `playwright:install` | Downloads the playwright browsers. |

### Unit Testing

We use [Playwright](https://playwright.dev/) for testing consistency. The package is installed with the rest of the dependencies; however, be sure to install the playwright browsers with the following command:

```
npx playwright install
```
or
```
npm run playwright:install
```

### Autodesk Platform Services

Expand Down
2,718 changes: 1,439 additions & 1,279 deletions fission/package-lock.json

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions fission/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --open",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives",
"preview": "vite preview --base=/fission/",
Expand All @@ -14,19 +14,22 @@
"prettier:fix": "bun run prettier --write || npm run prettier --write",
"format": "(bun run prettier:fix && bun run lint:fix) || (npm run prettier:fix && npm run lint:fix)",
"build:prod": "tsc && vite build --base=/fission/",
"assetpack": "curl -o public/assetpack.zip https://synthesis.autodesk.com/Downloadables/assetpack.zip && tar -xf public/assetpack.zip -C public/"
"assetpack": "curl -o public/assetpack.zip https://synthesis.autodesk.com/Downloadables/assetpack.zip && tar -xf public/assetpack.zip -C public/",
"playwright:install": "bun x playwright install || npx playwright install"
},
"dependencies": {
"@barclah/jolt-physics": "^0.19.3",
"@barclah/jolt-physics": "^0.24.1",
"@mui/base": "^5.0.0-beta.40",
"@mui/icons-material": "^5.15.20",
"@mui/system": "^5.15.20",
"@react-three/drei": "^9.96.5",
"@react-three/fiber": "^8.15.15",
"@vitest/browser": "^1.6.0",
"@vitest/coverage-v8": "^1.6.0",
"async-mutex": "^0.5.0",
"colord": "^2.9.3",
"framer-motion": "^10.13.1",
"playwright": "^1.45.0",
"react": "^18.2.0",
"react-colorful": "^5.6.1",
"react-dom": "^18.2.0",
Expand Down Expand Up @@ -66,6 +69,6 @@
"typescript": "^5.2.2",
"vite": "^5.1.4",
"vite-plugin-singlefile": "^0.13.5",
"vitest": "^1.3.1"
"vitest": "^1.5.3"
}
}
2 changes: 1 addition & 1 deletion fission/src/aps/APS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class APS {
if (this.auth) {
this.loadUserInfo(this.auth!).then(async () => {
if (APS.userInfo) {
MainHUD_AddToast("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
console.info(`Hello, ${APS.userInfo.givenName}`)
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions fission/src/mirabuf/MirabufLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mirabuf } from "../proto/mirabuf"
import Pako from "pako"
import * as fs from "fs"
// import * as fs from "fs"

export function UnzipMira(buff: Uint8Array): Uint8Array {
if (buff[0] == 31 && buff[1] == 139) {
Expand All @@ -21,6 +21,6 @@ export async function LoadMirabufRemote(
return mirabuf.Assembly.decode(byteBuffer)
}

export function LoadMirabufLocal(fileLocation: string): mirabuf.Assembly {
return mirabuf.Assembly.decode(UnzipMira(new Uint8Array(fs.readFileSync(fileLocation))))
}
// export function LoadMirabufLocal(fileLocation: string): mirabuf.Assembly {
// return mirabuf.Assembly.decode(UnzipMira(new Uint8Array(fs.readFileSync(fileLocation))))
// }
27 changes: 14 additions & 13 deletions fission/src/test/MirabufParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ import { describe, test, expect } from "vitest"

import { mirabuf } from "../proto/mirabuf"
import MirabufParser, { RigidNodeReadOnly } from "../mirabuf/MirabufParser"
import { LoadMirabufLocal } from "../mirabuf/MirabufLoader"
import { LoadMirabufRemote } from "@/mirabuf/MirabufLoader"
// import { LoadMirabufLocal } from "../mirabuf/MirabufLoader"

describe("Mirabuf Parser Tests", () => {
test("Generate Rigid Nodes (Dozer_v9.mira)", () => {
const spikeMira = LoadMirabufLocal("./public/Downloadables/Mira/Robots/Dozer_v9.mira")
test("Generate Rigid Nodes (Dozer_v9.mira)", async () => {
const spikeMira = await LoadMirabufRemote("/api/mira/Robots/Dozer_v9.mira")

const t = new MirabufParser(spikeMira)
const t = new MirabufParser(spikeMira!)
const rn = t.rigidNodes

expect(filterNonPhysicsNodes(rn, spikeMira).length).toBe(7)
expect(filterNonPhysicsNodes(rn, spikeMira!).length).toBe(7)
})

test("Generate Rigid Nodes (FRC_Field_2018_v14.mira)", () => {
const field = LoadMirabufLocal("./public/Downloadables/Mira/Fields/FRC Field 2018_v13.mira")
test("Generate Rigid Nodes (FRC_Field_2018_v14.mira)", async () => {
const field = await LoadMirabufRemote("/api/mira/Fields/FRC Field 2018_v13.mira")

const t = new MirabufParser(field)
const t = new MirabufParser(field!)

expect(filterNonPhysicsNodes(t.rigidNodes, field).length).toBe(34)
expect(filterNonPhysicsNodes(t.rigidNodes, field!).length).toBe(34)
})

test("Generate Rigid Nodes (Team_2471_(2018)_v7.mira)", () => {
const mm = LoadMirabufLocal("./public/Downloadables/Mira/Robots/Team 2471 (2018)_v7.mira")
test("Generate Rigid Nodes (Team_2471_(2018)_v7.mira)", async () => {
const mm = await LoadMirabufRemote("/api/mira/Robots/Team 2471 (2018)_v7.mira")

const t = new MirabufParser(mm)
const t = new MirabufParser(mm!)

expect(filterNonPhysicsNodes(t.rigidNodes, mm).length).toBe(10)
expect(filterNonPhysicsNodes(t.rigidNodes, mm!).length).toBe(10)
})
})

Expand Down
15 changes: 8 additions & 7 deletions fission/src/test/PhysicsSystem.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { test, expect, describe, assert } from "vitest"
import PhysicsSystem, { LayerReserve } from "../systems/physics/PhysicsSystem"
import { LoadMirabufLocal } from "@/mirabuf/MirabufLoader"
// import { LoadMirabufLocal } from "@/mirabuf/MirabufLoader"
import MirabufParser from "@/mirabuf/MirabufParser"
import * as THREE from "three"
import Jolt from "@barclah/jolt-physics"
import { LoadMirabufRemote } from "@/mirabuf/MirabufLoader"

describe("Physics Sansity Checks", () => {
test("Convex Hull Shape (Cube)", () => {
Expand Down Expand Up @@ -76,18 +77,18 @@ describe("GodMode", () => {
})

describe("Mirabuf Physics Loading", () => {
test("Body Loading (Dozer)", () => {
const assembly = LoadMirabufLocal("./public/Downloadables/Mira/Robots/Dozer_v9.mira")
const parser = new MirabufParser(assembly)
test("Body Loading (Dozer)", async () => {
const assembly = await LoadMirabufRemote("/api/mira/Robots/Dozer_v9.mira")
const parser = new MirabufParser(assembly!)
const physSystem = new PhysicsSystem()
const mapping = physSystem.CreateBodiesFromParser(parser, new LayerReserve())

expect(mapping.size).toBe(7)
})

test("Body Loading (Team_2471_(2018)_v7.mira)", () => {
const assembly = LoadMirabufLocal("./public/Downloadables/Mira/Robots/Team 2471 (2018)_v7.mira")
const parser = new MirabufParser(assembly)
test("Body Loading (Team_2471_(2018)_v7.mira)", async () => {
const assembly = await LoadMirabufRemote("/api/mira/Robots/Team 2471 (2018)_v7.mira")
const parser = new MirabufParser(assembly!)
const physSystem = new PhysicsSystem()
const mapping = physSystem.CreateBodiesFromParser(parser, new LayerReserve())

Expand Down
10 changes: 8 additions & 2 deletions fission/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ export default defineConfig({
},
test: {
globals: true,
environment: 'jsdom'
environment: 'jsdom',
browser: {
enabled: true,
name: 'chromium',
headless: true,
provider: 'playwright'
}
},
server: {
// this ensures that the browser opens upon server start
open: true,
// open: true,
// this sets a default port to 3000
port: serverPort,
cors: false,
Expand Down

0 comments on commit b825c05

Please sign in to comment.