@gg-web-engine/rapier2d 0.0.58 → 0.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export type Rapier2dPhysicsTypeDocRepo = {
|
|
|
8
8
|
rigidBody: Rapier2dRigidBodyComponent;
|
|
9
9
|
trigger: Rapier2dTriggerComponent;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type Rapier2dTypeDoc = Gg2dWorldTypeDocPPatch<Rapier2dPhysicsTypeDocRepo>;
|
|
12
|
+
export type Rapier2dSceneTypeDoc = Gg2dWorldSceneTypeDocPPatch<Rapier2dPhysicsTypeDocRepo, Rapier2dWorldComponent>;
|
|
13
|
+
export type Rapier2dGgWorld = Gg2dWorld<Rapier2dTypeDoc, Rapier2dSceneTypeDoc>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gg-web-engine/rapier2d",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"description": "An attempt to create open source game engine for browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,20 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/AndyGura/gg-web-engine#readme",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@dimforge/rapier2d-compat": "0.
|
|
31
|
-
"@gg-web-engine/core": "0.0.
|
|
32
|
-
"@types/jest": "^
|
|
33
|
-
"
|
|
34
|
-
"jest
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
30
|
+
"@dimforge/rapier2d-compat": "0.20.0",
|
|
31
|
+
"@gg-web-engine/core": "0.0.60",
|
|
32
|
+
"@types/jest": "^30.0.0",
|
|
33
|
+
"@types/node": "^26.4.0",
|
|
34
|
+
"jest": "^30.5.0",
|
|
35
|
+
"jest-environment-jsdom": "^30.5.0",
|
|
36
|
+
"prettier": "^3.9.6",
|
|
37
|
+
"rxjs": "7.8.2",
|
|
38
|
+
"ts-jest": "^29.4.12",
|
|
39
|
+
"typescript": "~6.0.3"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@dimforge/rapier2d-compat": "0.
|
|
42
|
-
"@gg-web-engine/core": "0.0.
|
|
43
|
-
"rxjs": "7.8.
|
|
42
|
+
"@dimforge/rapier2d-compat": "0.20.0",
|
|
43
|
+
"@gg-web-engine/core": "0.0.60",
|
|
44
|
+
"rxjs": "7.8.2"
|
|
44
45
|
},
|
|
45
46
|
"jest": {
|
|
46
47
|
"rootDir": ".",
|
|
@@ -51,6 +52,9 @@
|
|
|
51
52
|
"moduleNameMapper": {
|
|
52
53
|
"@gg-web-engine/core": "<rootDir>/../core/src/index.ts"
|
|
53
54
|
},
|
|
55
|
+
"setupFiles": [
|
|
56
|
+
"<rootDir>/test/jest.polyfills.ts"
|
|
57
|
+
],
|
|
54
58
|
"preset": "ts-jest/presets/default",
|
|
55
59
|
"collectCoverageFrom": [
|
|
56
60
|
"**/*.ts",
|
|
@@ -41,6 +41,15 @@ describe(`Rapier2dTriggerComponent`, () => {
|
|
|
41
41
|
expect(enterRegistered).toBe(false);
|
|
42
42
|
expect(exitRegistered).toBe(false);
|
|
43
43
|
|
|
44
|
+
world.simulate(500);
|
|
45
|
+
trigger.checkOverlaps();
|
|
46
|
+
// rapier2d-compat 0.20 runs narrow-phase (and therefore collision-event generation) against
|
|
47
|
+
// the body positions as of the *start* of a step, i.e. the result of the previous step's
|
|
48
|
+
// integration - so a transition only shows up in the event queue one `simulate()` call after
|
|
49
|
+
// the geometry actually starts overlapping. One extra step is needed here to observe it.
|
|
50
|
+
expect(enterRegistered).toBe(false);
|
|
51
|
+
expect(exitRegistered).toBe(false);
|
|
52
|
+
|
|
44
53
|
world.simulate(500);
|
|
45
54
|
trigger.checkOverlaps();
|
|
46
55
|
expect(enterRegistered).toBe(true);
|
|
@@ -65,6 +74,12 @@ describe(`Rapier2dTriggerComponent`, () => {
|
|
|
65
74
|
expect(exitRegistered).toBe(false);
|
|
66
75
|
world.simulate(1000);
|
|
67
76
|
trigger.checkOverlaps();
|
|
77
|
+
// see the comment in the previous test: this step's drain only reports the *enter* event
|
|
78
|
+
// (computed from the position after the first step); the exit doesn't show up until the
|
|
79
|
+
// narrow-phase catches up with the position produced by this step's integration.
|
|
80
|
+
expect(exitRegistered).toBe(false);
|
|
81
|
+
world.simulate(1000);
|
|
82
|
+
trigger.checkOverlaps();
|
|
68
83
|
expect(exitRegistered).toBe(true);
|
|
69
84
|
});
|
|
70
85
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// jest-environment-jsdom (as of jest 30 / jsdom 26) no longer exposes TextEncoder/TextDecoder as
|
|
2
|
+
// globals inside the jsdom window, but @dimforge/rapier2d-compat's wasm-bindgen-generated glue
|
|
3
|
+
// (rapier_wasm2d.js) references `TextDecoder` at module load time to decode strings coming back
|
|
4
|
+
// from the WASM module. Without this polyfill, simply importing anything from
|
|
5
|
+
// `@gg-web-engine/rapier2d` inside a jsdom test environment throws
|
|
6
|
+
// `ReferenceError: TextDecoder is not defined` before any test body runs.
|
|
7
|
+
import { TextDecoder, TextEncoder } from 'util';
|
|
8
|
+
|
|
9
|
+
if (typeof (global as any).TextEncoder === 'undefined') {
|
|
10
|
+
(global as any).TextEncoder = TextEncoder;
|
|
11
|
+
}
|
|
12
|
+
if (typeof (global as any).TextDecoder === 'undefined') {
|
|
13
|
+
(global as any).TextDecoder = TextDecoder;
|
|
14
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"baseUrl": "./src/",
|
|
5
5
|
"outDir": "./dist/",
|
|
6
|
+
"rootDir": "./src/",
|
|
7
|
+
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
|
|
8
|
+
"types": ["jest", "node"]
|
|
6
9
|
},
|
|
7
10
|
"include": ["src/*.ts", "src/**/*.ts"],
|
|
11
|
+
"references": [{ "path": "../core" }]
|
|
8
12
|
}
|