@ignifx/physics 0.0.0 → 0.2.0
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/LICENSE +201 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +34 -29
- package/skills/physics/SKILL.md +15 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ignifx/physics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "ignifx 3D physics on Havok through Babylon Lite: rigidbodies, colliders, triggers, character controller, queries.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ignifx",
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"homepage": "https://ignifx.com",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"author": "Astrum Forge Studios",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/astrum-forge/ignifx.git",
|
|
15
|
+
"directory": "packages/physics"
|
|
16
|
+
},
|
|
12
17
|
"files": [
|
|
13
18
|
"dist",
|
|
14
19
|
"skills"
|
|
@@ -24,37 +29,28 @@
|
|
|
24
29
|
},
|
|
25
30
|
"publishConfig": {
|
|
26
31
|
"access": "public",
|
|
27
|
-
"provenance":
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tsdown",
|
|
31
|
-
"typecheck": "tsc --build tsconfig.json tsconfig.test.json",
|
|
32
|
-
"test": "vitest run --project node --root ../.. packages/physics",
|
|
33
|
-
"api-report": "api-extractor run --verbose",
|
|
34
|
-
"docs:api": "typedoc",
|
|
35
|
-
"api-report:update": "api-extractor run --local --verbose",
|
|
36
|
-
"pack-check": "publint && attw --pack . --profile esm-only"
|
|
32
|
+
"provenance": false
|
|
37
33
|
},
|
|
38
34
|
"devDependencies": {
|
|
39
|
-
"@arethetypeswrong/cli": "
|
|
40
|
-
"@babylonjs/havok": "
|
|
41
|
-
"@babylonjs/lite": "
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@types/
|
|
45
|
-
"@types
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"typedoc": "
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
35
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
36
|
+
"@babylonjs/havok": "^1.3.14",
|
|
37
|
+
"@babylonjs/lite": "1.27.0",
|
|
38
|
+
"@microsoft/api-extractor": "^7.59.0",
|
|
39
|
+
"@types/node": "^24.13.3",
|
|
40
|
+
"@types/webxr": "^0.5.0",
|
|
41
|
+
"@webgpu/types": "^0.1.72",
|
|
42
|
+
"publint": "^0.3.24",
|
|
43
|
+
"tsdown": "^0.23.0",
|
|
44
|
+
"typedoc": "^0.28.20",
|
|
45
|
+
"typedoc-plugin-markdown": "^4.13.0",
|
|
46
|
+
"typescript-native": "npm:typescript@7.0.2",
|
|
47
|
+
"vitest": "^5.0.0",
|
|
48
|
+
"@ignifx/core": "0.2.0"
|
|
53
49
|
},
|
|
54
50
|
"peerDependencies": {
|
|
55
|
-
"@babylonjs/havok": "
|
|
56
|
-
"@babylonjs/lite": "
|
|
57
|
-
"@ignifx/core": "
|
|
51
|
+
"@babylonjs/havok": "^1.3.14",
|
|
52
|
+
"@babylonjs/lite": "1.27.0",
|
|
53
|
+
"@ignifx/core": "0.2.0"
|
|
58
54
|
},
|
|
59
55
|
"ignifx": {
|
|
60
56
|
"extension": true,
|
|
@@ -70,5 +66,14 @@
|
|
|
70
66
|
"node_modules/@babylonjs/havok/lib/esm/HavokPhysics.wasm"
|
|
71
67
|
]
|
|
72
68
|
}
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "tsdown",
|
|
72
|
+
"typecheck": "tsc --build tsconfig.json tsconfig.test.json",
|
|
73
|
+
"test": "vitest run --project node --root ../.. packages/physics",
|
|
74
|
+
"api-report": "api-extractor run --verbose",
|
|
75
|
+
"docs:api": "typedoc",
|
|
76
|
+
"api-report:update": "api-extractor run --local --verbose",
|
|
77
|
+
"pack-check": "publint && attw --pack . --profile esm-only"
|
|
73
78
|
}
|
|
74
|
-
}
|
|
79
|
+
}
|
package/skills/physics/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: physics
|
|
|
3
3
|
description: Adds 3D physics to an ignifx game with @ignifx/physics: Havok simulation on a separate headless scene, Rigidbody, box/sphere/capsule/mesh colliders, physics materials, triggers, CharacterController, raycasts and shape queries, the collision layer matrix, and render interpolation. Use when adding or editing 3D physics bodies, colliders, triggers, character movement, or physics queries in an ignifx project, or when the user mentions @ignifx/physics, Rigidbody, Havok, or collision layers.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
|
-
ignifx-version: "0.
|
|
6
|
+
ignifx-version: "0.2.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# @ignifx/physics
|
|
@@ -28,7 +28,7 @@ through, or has to be asked "what is under the crosshair".
|
|
|
28
28
|
binary out of the installed `@babylonjs/havok` package, so a headless test needs no setup.
|
|
29
29
|
- Register it like any extension; nothing happens at import time.
|
|
30
30
|
|
|
31
|
-
```ts
|
|
31
|
+
```ts run
|
|
32
32
|
import { createApp, physics } from "ignifx";
|
|
33
33
|
|
|
34
34
|
const app = await createApp({ headless: true, extensions: [physics()] });
|
|
@@ -73,7 +73,7 @@ per fixed step:
|
|
|
73
73
|
|
|
74
74
|
## First app
|
|
75
75
|
|
|
76
|
-
```ts
|
|
76
|
+
```ts run
|
|
77
77
|
import { BoxCollider, createApp, physics, Rigidbody } from "ignifx";
|
|
78
78
|
|
|
79
79
|
const app = await createApp({ headless: true, extensions: [physics()] });
|
|
@@ -90,7 +90,7 @@ crate.addComponent(Rigidbody, { mass: 2 });
|
|
|
90
90
|
for (let step = 0; step < 60; step += 1) {
|
|
91
91
|
app.step(1 / 60);
|
|
92
92
|
}
|
|
93
|
-
app.log.info("crate at y
|
|
93
|
+
app.log.info("crate at y:", crate.transform.position.y);
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
## Core APIs
|
|
@@ -147,16 +147,15 @@ Gravity is **not** applied for you — a bare controller is purely kinematic.
|
|
|
147
147
|
|
|
148
148
|
### A trigger volume
|
|
149
149
|
|
|
150
|
-
```ts
|
|
150
|
+
```ts run
|
|
151
151
|
import { BoxCollider, createApp, physics, Rigidbody, Script } from "ignifx";
|
|
152
152
|
import type { ScriptCallbacks, TriggerEvent } from "ignifx";
|
|
153
153
|
|
|
154
154
|
class Pickup extends Script implements ScriptCallbacks {
|
|
155
155
|
static typeId = "mygame/Pickup";
|
|
156
156
|
|
|
157
|
-
onTriggerEnter(trigger:
|
|
158
|
-
|
|
159
|
-
this.app.log.info("{name} entered the zone", event.other?.name ?? "something");
|
|
157
|
+
onTriggerEnter(trigger: TriggerEvent): void {
|
|
158
|
+
this.app.log.info("entered the zone:", trigger.other?.name ?? "something");
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
|
|
@@ -181,7 +180,7 @@ for (let step = 0; step < 120; step += 1) {
|
|
|
181
180
|
|
|
182
181
|
### A raycast under the crosshair
|
|
183
182
|
|
|
184
|
-
```ts
|
|
183
|
+
```ts run
|
|
185
184
|
import { BoxCollider, createApp, LayerMask, physics } from "ignifx";
|
|
186
185
|
|
|
187
186
|
const app = await createApp({ headless: true, extensions: [physics()] });
|
|
@@ -193,13 +192,13 @@ const hit = app.physics.raycast({ x: 0, y: 10, z: 0 }, { x: 0, y: -1, z: 0 }, 20
|
|
|
193
192
|
layerMask: LayerMask.everything(),
|
|
194
193
|
});
|
|
195
194
|
if (hit !== null) {
|
|
196
|
-
app.log.info("hit
|
|
195
|
+
app.log.info("hit:", hit.entity.name, "y:", hit.point.y);
|
|
197
196
|
}
|
|
198
197
|
```
|
|
199
198
|
|
|
200
199
|
### Layers that ignore each other
|
|
201
200
|
|
|
202
|
-
```ts
|
|
201
|
+
```ts run
|
|
203
202
|
// ignifx.config.ts
|
|
204
203
|
export default {
|
|
205
204
|
layers: ["Default", "Ground", "Ghost"],
|
|
@@ -229,6 +228,11 @@ collides with everything. Havok tests a pair in both directions, so one side ref
|
|
|
229
228
|
that recovers the identities.
|
|
230
229
|
- **Event objects are pooled.** `TriggerEvent` and `Collision` (and its `contacts`) are reused for
|
|
231
230
|
every event of a step: copy anything you keep past the callback.
|
|
231
|
+
- **Type the callback parameter, do not cast it.** Core declares `onTriggerEnter?(trigger: unknown)`
|
|
232
|
+
on `ScriptCallbacks` because it cannot depend on this package, but method parameters are bivariant
|
|
233
|
+
in TypeScript, so `onTriggerEnter(trigger: TriggerEvent): void` satisfies the interface as written.
|
|
234
|
+
`trigger as TriggerEvent` is redundant, and it trips `typescript/no-unsafe-type-assertion` under
|
|
235
|
+
the engine's own lint settings.
|
|
232
236
|
- **`overlap` returns a reused array**, and it is bounds-accurate rather than shape-accurate,
|
|
233
237
|
because Lite's `shapeProximity` reports neither a body identity nor more than one hit.
|
|
234
238
|
- **A body's entity must be a root entity** (`IGX-0907`), and a moving collider needs a
|