-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
207 additions
and
139 deletions.
There are no files selected for viewing
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,9 +1,3 @@ | ||
[submodule "mirabuf"] | ||
path = mirabuf | ||
url = https://github.com/HiceS/mirabuf | ||
[submodule "web/engine/vendor/protobuf"] | ||
path = web/engine/vendor/protobuf | ||
url = https://github.com/protocolbuffers/protobuf | ||
[submodule "web/engine/vendor/JoltPhysics"] | ||
path = web/engine/vendor/JoltPhysics | ||
url = https://github.com/jrouwe/JoltPhysics |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,7 @@ | ||
export class Jolt_Shape { | ||
|
||
} | ||
|
||
export class Jolt_ConvexShape extends Jolt_Shape { | ||
|
||
} |
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,3 +1,2 @@ | ||
export * from "./physics/PhysicsSystem"; | ||
export * from "./world/WorldSystem"; | ||
export * from "./rendering/RenderSystem"; |
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
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,51 +0,0 @@ | ||
import { Type } from "typescript"; | ||
import Queue from "../../util/data/Queue"; | ||
import { PhysicsSystem, RenderSystem } from "../Systems"; | ||
|
||
class WorldSystem { | ||
|
||
private _lastFrameTime: number; | ||
private _updateFrame?: number; | ||
|
||
private _physics: PhysicsSystem; | ||
private _renderer: RenderSystem; | ||
|
||
constructor() { | ||
this._physics = new PhysicsSystem(); | ||
this._renderer = new RenderSystem(); | ||
|
||
// Create Robot | ||
} | ||
|
||
public startLoop() { | ||
this.stopLoop(); | ||
|
||
|
||
} | ||
|
||
private update() { | ||
var _ = Date.now() - this._lastFrameTime; | ||
this._lastFrameTime = Date.now(); | ||
|
||
this._updateFrame = requestAnimationFrame(this.update); | ||
|
||
|
||
} | ||
|
||
public stopLoop() { | ||
|
||
} | ||
|
||
} | ||
export var worldSystem = new WorldSystem(); | ||
|
||
export abstract class System { | ||
|
||
private _priority: number; | ||
|
||
protected get priority() { return this._priority; } | ||
|
||
protected constructor(priority: number) { | ||
|
||
} | ||
} | ||
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,64 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { test, expect, describe, assert } from 'vitest'; | ||
import { PhysicsSystem } from '../systems/Systems'; | ||
|
||
describe('Physics System Tests', () => { | ||
test('Convex Hull Shape (Cube)', () => { | ||
const points: Float32Array = new Float32Array( | ||
[ | ||
0.5, -0.5, 0.5, | ||
-0.5, -0.5, 0.5, | ||
-0.5, -0.5, -0.5, | ||
0.5, -0.5, -0.5, | ||
0.5, 0.5, 0.5, | ||
-0.5, 0.5, 0.5, | ||
-0.5, 0.5, -0.5, | ||
0.5, 0.5, -0.5, | ||
] | ||
); | ||
|
||
const system = new PhysicsSystem(); | ||
const shapeResult = system.CreateConvexHull(points); | ||
|
||
assert(shapeResult.HasError() == false, shapeResult.GetError().c_str()); | ||
expect(shapeResult.IsValid()).toBe(true); | ||
|
||
const shape = shapeResult.Get(); | ||
|
||
expect(shape.GetVolume() - 1.0).toBeLessThan(0.001); | ||
expect(shape.GetCenterOfMass().Length()).toBe(0.0); | ||
|
||
shape.Release(); | ||
system.Destroy(); | ||
|
||
}); | ||
test('Convex Hull Shape (Tetrahedron)', () => { | ||
const points: Float32Array = new Float32Array( | ||
[ | ||
0.0, 0.0, 0.0, | ||
0.0, 1.0, 0.0, | ||
1.0, 0.0, 0.0, | ||
0.0, 0.0, 1.0 | ||
] | ||
); | ||
|
||
const system = new PhysicsSystem(); | ||
const shapeResult = system.CreateConvexHull(points); | ||
|
||
assert(shapeResult.HasError() == false, shapeResult.GetError().c_str()); | ||
expect(shapeResult.IsValid()).toBe(true); | ||
|
||
const shape = shapeResult.Get(); | ||
const bounds = shape.GetLocalBounds(); | ||
const boxSize = bounds.mMax.Sub(bounds.mMin); | ||
|
||
expect(boxSize.GetX() - 1.0).toBeLessThan(0.001); | ||
expect(boxSize.GetY() - 1.0).toBeLessThan(0.001); | ||
expect(boxSize.GetZ() - 1.0).toBeLessThan(0.001); | ||
expect(shape.GetVolume() - (1.0 / 6.0)).toBeLessThan(0.001); | ||
expect(shape.GetMassProperties().mMass - 6.0).toBeLessThan(0.001); | ||
|
||
shape.Release(); | ||
system.Destroy(); | ||
}); | ||
}); |
Oops, something went wrong.