Skip to content

Commit

Permalink
Pre-Summer Update (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored May 29, 2024
2 parents ce40abc + c00b91f commit 541df47
Show file tree
Hide file tree
Showing 135 changed files with 36,354 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/FissionESLintFormat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Fission - ES Lint Format

on:
workflow_dispatch: {}
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]

jobs:
runFormatValidationScript:
name: ESLint Format Validation
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: JavaScript Setup
uses: actions/setup-node@v2
with:
node-version: 20
- name: Install Dependencies
run: |
cd fission
npm install
- name: Linter
id: linter-validation
run: |
cd fission
npm run lint
continue-on-error: true
- name: Prettier
id: prettier-validation
run: |
cd fission
npm run prettier
continue-on-error: true
- name: Check Success
run: |
if [ ${{ steps.linter-validation.outcome }} == "success" ]; then
echo "Format Validation Passed"
else
echo "Format Validation Failed"
exit 1
fi
47 changes: 47 additions & 0 deletions .github/workflows/FissionPackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Fission - Package

on:
workflow_dispatch: {}
push:
branches: [ master, dev ]

jobs:
runUnitTests:
name: Package
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: JavaScript Setup
uses: actions/setup-node@v2
with:
node-version: 20

- name: Get date
id: date # this is used on variable path
run: |
echo "timestamp=$(date +'%Y-%m-%dT%H-%M-%S')" >> $GITHUB_OUTPUT
- name: Install Dependencies
run: |
cd fission
npm install
- name: Get package info
id: info
uses: codex-team/[email protected]
with:
path: fission/

- name: Build
id: build
run: |
cd fission
npm run build
- name: Upload Artifact
uses: actions/upload-artifact@v4
id: upload-artifact
with:
name: "${{ steps.info.outputs.name }}@${{ steps.info.outputs.version }}[${{ steps.date.outputs.timestamp }}]"
path: fission/dist/
38 changes: 38 additions & 0 deletions .github/workflows/FissionUnitTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Fission - Unit Test

on:
workflow_dispatch: {}
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]

jobs:
runUnitTests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: JavaScript Setup
uses: actions/setup-node@v2
with:
node-version: 20
- name: Install Dependencies
run: |
cd fission
npm install
- name: Unit Tests
id: unit-tests
run: |
cd fission
npm run test
continue-on-error: true
- name: Check Success
run: |
if [ ${{ steps.unit-tests.outcome }} == "success" ]; then
echo "Format Validation Passed"
else
echo "Format Validation Failed"
exit 1
fi
8 changes: 8 additions & 0 deletions engine/Assets/Scripts/CEF.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions engine/Assets/Scripts/Importer/MirabufDefinitionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public static void MakePartDefinition(GameObject container, PartDefinition defin
AssemblyData assemblyData, ColliderGenType colliderGenType, bool useIndex, int partIndex) {
PhysicMaterial physMat = new PhysicMaterial { dynamicFriction = 0.6f, staticFriction = 0.6f };
foreach (var body in definition.Bodies) {
if (body.TriangleMesh == null)
continue;

var bodyObject = new GameObject(useIndex ? $"{body.Info.Name}_{partIndex}" : body.Info.Name);
var filter = bodyObject.AddComponent<MeshFilter>();
var renderer = bodyObject.AddComponent<MeshRenderer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ def _MapAllComponents(
else:
partDefinition.dynamic = True

for body in component.bRepBodies:
def processBody(body: adsk.fusion.BRepBody | adsk.fusion.MeshBody):
if progressDialog.wasCancelled():
raise RuntimeError("User canceled export")
if body.isLightBulbOn:
part_body = partDefinition.bodies.add()
fill_info(part_body, body)
part_body.part = comp_ref
_ParseBRep(body, options, part_body.triangle_mesh)

if isinstance(body, adsk.fusion.BRepBody):
_ParseBRep(body, options, part_body.triangle_mesh)
else:
_ParseMesh(body, options, part_body.triangle_mesh)

appearance_key = "{}_{}".format(body.appearance.name, body.appearance.id)
# this should be appearance
Expand All @@ -59,6 +63,12 @@ def _MapAllComponents(
else:
part_body.appearance_override = "default"

for body in component.bRepBodies:
processBody(body)

for body in component.meshBodies:
processBody(body)


@TimeThis
def _ParseComponentRoot(
Expand Down Expand Up @@ -199,6 +209,29 @@ def _ParseBRep(
)


def _ParseMesh(
meshBody: adsk.fusion.MeshBody,
options: ParseOptions,
trimesh: assembly_pb2.TriangleMesh,
) -> any:
try:
mesh = meshBody.displayMesh

fill_info(trimesh, meshBody)
trimesh.has_volume = True

plainmesh_out = trimesh.mesh

plainmesh_out.verts.extend(mesh.nodeCoordinatesAsFloat)
plainmesh_out.normals.extend(mesh.normalVectorsAsFloat)
plainmesh_out.indices.extend(mesh.nodeIndices)
plainmesh_out.uv.extend(mesh.textureCoordinatesAsFloat)
except:
logging.getLogger("{INTERNAL_ID}.Parser.BrepBody").error(
"Failed:\n{}".format(traceback.format_exc())
)


def _MapRigidGroups(
rootComponent: adsk.fusion.Component, joints: joint_pb2.Joints
) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ def export(self) -> bool:
path = pathlib.Path(self.parseOptions.fileLocation).parent
path.mkdir(parents=True, exist_ok=True)

### Print out assembly as JSON
# miraJson = MessageToJson(assembly_out)
# miraJsonFile = open(f'', 'wb')
# miraJsonFile.write(str.encode(miraJson))
# miraJsonFile.close()

if self.parseOptions.compress:
self.logger.debug("Compressing file")
with gzip.open(self.parseOptions.fileLocation, "wb", 9) as f:
Expand Down
27 changes: 27 additions & 0 deletions fission/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs', 'src/proto/mirabuf.*', 'src/samples/*'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'@typescript-eslint/no-unused-vars': [
'warn', // or "error"
{
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_'
}
]
},

}
24 changes: 24 additions & 0 deletions fission/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
65 changes: 65 additions & 0 deletions fission/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Fission: Synthesis' web-based robot simulator

## Gettings Started
### Requirements
1. NPM (v10.2.4 recommended)
2. NodeJS (v20.10.0 recommended)
3. TypeScript (v4.8.4 recommended) *Unknown if this is actually required*

### Building
To build, install all dependencies:
```bash
npm i
```
### NPM Scripts

| Script | Description |
| ------ | ----------- |
| `dev` | Starts the development server used for testing. Supports hotloading (though finicky with WASM module loading). |
| `test` | Runs the unit tests via vitest. |
| `build` | Builds the project into it's packaged form. Uses root base path. |
| `build:prod` | Builds the project into it's packaged form. Uses the `/fission/` base path. |
| `preview` | Runs the built project for preview locally before deploying. |
| `lint` | Runs eslint on the project. |
| `lint:fix` | Attempts to fix issues found with eslint. |
| `prettier` | Runs prettier on the project as a check. |
| `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`. |

## Core Systems
These core systems make up the bulk of the vital technologies to make Synthesis work. The idea is that these systems will serve as a
jumping off point for anything requiring real-time simulation.

### World
The world serves as a hub for all of the core systems. It is a static class that handles system update execution order and lifetime.

### Scene Renderer
The Scene Renderer is our interface with rendering within the Canvas. This is primarily done via ThreeJS, however can be extended later on.

### Physics System
This Physics System is our interface with Jolt, ensuring objects are properly handled and provides utility functions that are more custom fit to our purposes.

[Jolt Physics Architecture](https://jrouwe.github.io/JoltPhysics/)

### Input System

### UI System

## Additional Systems
These systems will extend off of the core systems to build out features in Synthesis.

### Simulation System
The Simulation System articulates dynamic elements of the scene via the Physics System. At it's core there are 3 main components:

#### Driver
Drivers are mostly write-only. They take in values to know how to articulate the physics objects and contraints.

#### Stimulus
Stimulu are mostly read-only. They read values from given physics objects and constraints.

#### Brain
Brains are the controllers of the mechanisms. They use a combination of Drivers and Stimuli to control a given mechanism.

For basic user control of the mechanisms, we'll have a Synthesis Brain. By the end of Summer 2024, I hope to have an additional brain, the WPIBrain for facilitating WPILib code control over the mechanisms inside of Synthesis.

### Mode System
Binary file added fission/bun.lockb
Binary file not shown.
15 changes: 15 additions & 0 deletions fission/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/synthesis-logo.svg" />
<link rel='stylesheet' href='https://static-dc.autodesk.net/etc/designs/v201808022224/templates-general/structure/fonts/artifakt/clientlibs/artifakt.css'/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fission | Synthesis</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit 541df47

Please sign in to comment.