@jgengine/core 0.18.0 → 0.18.1
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/CHANGELOG.md +114 -2
- package/dist/ai/decisionGraph.d.ts +52 -0
- package/dist/ai/decisionGraph.js +82 -0
- package/dist/ai/mobBrainGraph.d.ts +3 -0
- package/dist/ai/mobBrainGraph.js +25 -0
- package/dist/ai/tacticalQueries.d.ts +30 -0
- package/dist/ai/tacticalQueries.js +45 -0
- package/dist/anim/animGraph.d.ts +144 -0
- package/dist/anim/animGraph.js +286 -0
- package/dist/anim/ikSolver.d.ts +51 -0
- package/dist/anim/ikSolver.js +124 -0
- package/dist/anim/locomotionGraph.d.ts +26 -0
- package/dist/anim/locomotionGraph.js +33 -0
- package/dist/assets/spriteAtlas.d.ts +21 -0
- package/dist/assets/spriteAtlas.js +103 -0
- package/dist/audio/audioFalloff.d.ts +10 -0
- package/dist/economy/currency.d.ts +16 -2
- package/dist/economy/currency.js +55 -14
- package/dist/economy/wallet.d.ts +5 -4
- package/dist/economy/wallet.js +8 -4
- package/dist/editor/commandApply.js +1 -0
- package/dist/editor/commands.d.ts +4 -1
- package/dist/editor/document.d.ts +2 -1
- package/dist/editor/document.js +89 -0
- package/dist/editor/environment.d.ts +3 -0
- package/dist/editor/environment.js +16 -0
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/types.d.ts +16 -0
- package/dist/game/cameraConfig.d.ts +8 -0
- package/dist/game/chat.d.ts +22 -1
- package/dist/game/chat.js +48 -19
- package/dist/game/controlGate.d.ts +6 -0
- package/dist/game/controlGate.js +30 -1
- package/dist/game/defineGame.d.ts +10 -1
- package/dist/game/events.d.ts +8 -1
- package/dist/game/pixelPerfect.d.ts +25 -0
- package/dist/game/pixelPerfect.js +29 -0
- package/dist/game/playableGame.d.ts +97 -3
- package/dist/game/systemRuntime.js +6 -1
- package/dist/input/actionBindings.d.ts +2 -1
- package/dist/input/actionBindings.js +10 -8
- package/dist/input/actionContexts.d.ts +21 -0
- package/dist/input/actionContexts.js +56 -0
- package/dist/input/gamepadModel.d.ts +45 -0
- package/dist/input/gamepadModel.js +69 -0
- package/dist/meta/changelog.d.ts +1 -1
- package/dist/meta/changelog.js +85 -1
- package/dist/movement/characterController.d.ts +76 -0
- package/dist/movement/characterController.js +216 -0
- package/dist/movement/freeFlight.d.ts +119 -0
- package/dist/movement/freeFlight.js +294 -0
- package/dist/movement/playerMovement.d.ts +10 -2
- package/dist/movement/playerMovement.js +218 -4
- package/dist/movement/serverStep.d.ts +5 -0
- package/dist/movement/serverStep.js +6 -0
- package/dist/movement/solidObstacles.d.ts +30 -7
- package/dist/movement/solidObstacles.js +27 -4
- package/dist/multiplayer/poseSyncGate.d.ts +3 -1
- package/dist/multiplayer/poseSyncGate.js +9 -1
- package/dist/multiplayer/presenceContract.d.ts +6 -0
- package/dist/multiplayer/presenceModel.d.ts +2 -0
- package/dist/multiplayer/presenceModel.js +11 -0
- package/dist/nav/navMesh.d.ts +33 -0
- package/dist/nav/navMesh.js +164 -0
- package/dist/physics/flightDynamics.d.ts +8 -0
- package/dist/physics/kinematicVehicle.d.ts +6 -1
- package/dist/physics/physicsBackend.d.ts +191 -0
- package/dist/physics/physicsBackend.js +49 -0
- package/dist/physics/physicsBackendConformance.d.ts +27 -0
- package/dist/physics/physicsBackendConformance.js +117 -0
- package/dist/physics/physicsWorldBackend.d.ts +44 -0
- package/dist/physics/physicsWorldBackend.js +485 -0
- package/dist/physics/worldColliders.d.ts +13 -0
- package/dist/physics/worldColliders.js +96 -0
- package/dist/random/rng.d.ts +12 -1
- package/dist/random/rng.js +20 -3
- package/dist/render/environment.d.ts +23 -0
- package/dist/render/environment.js +1 -0
- package/dist/render/lookPreset.d.ts +11 -5
- package/dist/render/lookPreset.js +29 -4
- package/dist/render/postProcessing.d.ts +10 -1
- package/dist/render/sprite2d.d.ts +38 -0
- package/dist/render/sprite2d.js +40 -0
- package/dist/runtime/adapter.d.ts +20 -1
- package/dist/runtime/adapter.js +8 -1
- package/dist/runtime/commandInput.d.ts +15 -0
- package/dist/runtime/commandInput.js +13 -0
- package/dist/runtime/commandRunner.d.ts +12 -7
- package/dist/runtime/commandRunner.js +7 -5
- package/dist/runtime/gameContext.js +11 -1
- package/dist/runtime/gameContextTypes.d.ts +14 -4
- package/dist/runtime/gameRuntime.d.ts +20 -4
- package/dist/runtime/gameRuntime.js +17 -4
- package/dist/runtime/headlessRunner.d.ts +10 -0
- package/dist/runtime/headlessRunner.js +26 -8
- package/dist/runtime/hostPolicy.d.ts +3 -2
- package/dist/runtime/hostPolicy.js +8 -10
- package/dist/runtime/hostedGameRunner.js +34 -6
- package/dist/runtime/hostedWorldSession.d.ts +12 -16
- package/dist/runtime/hostedWorldSession.js +29 -6
- package/dist/runtime/hostedWorldStore.d.ts +20 -0
- package/dist/runtime/hostedWorldStore.js +1 -0
- package/dist/runtime/inputRecorder.d.ts +30 -0
- package/dist/runtime/inputRecorder.js +59 -0
- package/dist/runtime/inputSnapshot.d.ts +8 -0
- package/dist/runtime/inputSnapshot.js +1 -0
- package/dist/runtime/poseInterpolation.d.ts +36 -0
- package/dist/runtime/poseInterpolation.js +91 -0
- package/dist/runtime/prediction.d.ts +45 -0
- package/dist/runtime/prediction.js +62 -0
- package/dist/runtime/simContext.d.ts +45 -0
- package/dist/runtime/simContext.js +65 -0
- package/dist/runtime/simLoop.d.ts +52 -0
- package/dist/runtime/simLoop.js +72 -0
- package/dist/runtime/simSnapshot.d.ts +32 -0
- package/dist/runtime/simSnapshot.js +60 -0
- package/dist/runtime/snapshot.d.ts +8 -0
- package/dist/runtime/snapshotBuffer.d.ts +33 -0
- package/dist/runtime/snapshotBuffer.js +58 -0
- package/dist/runtime/transport.d.ts +32 -2
- package/dist/runtime/worldChunks.d.ts +2 -0
- package/dist/runtime/worldChunks.js +14 -0
- package/dist/runtime/worldProjection.d.ts +9 -0
- package/dist/runtime/worldProjection.js +17 -1
- package/dist/runtime/worldSnapshot.d.ts +6 -0
- package/dist/runtime/worldSnapshot.js +3 -0
- package/dist/scene/behaviorRuntime.d.ts +19 -1
- package/dist/scene/behaviorRuntime.js +55 -4
- package/dist/scene/behaviors.d.ts +8 -1
- package/dist/scene/builtinSceneKinds.js +10 -0
- package/dist/sensor/perception.d.ts +60 -0
- package/dist/sensor/perception.js +142 -0
- package/dist/settings/graphicsProfile.d.ts +19 -0
- package/dist/settings/graphicsProfile.js +36 -0
- package/dist/time/accrueSince.d.ts +10 -0
- package/dist/time/accrueSince.js +9 -0
- package/dist/time/rateWindow.d.ts +16 -0
- package/dist/time/rateWindow.js +14 -0
- package/dist/time/serverTick.d.ts +21 -3
- package/dist/time/serverTick.js +14 -13
- package/dist/vfx/particleDirector.d.ts +68 -0
- package/dist/vfx/particleDirector.js +81 -0
- package/dist/world/buildings.d.ts +12 -0
- package/dist/world/buildings.js +43 -3
- package/dist/world/cityContent.js +103 -25
- package/dist/world/cityKind.d.ts +132 -0
- package/dist/world/cityKind.js +315 -15
- package/dist/world/features.d.ts +27 -1
- package/dist/world/features.js +7 -2
- package/dist/world/placement.d.ts +7 -0
- package/dist/world/placement.js +2 -0
- package/dist/world/placementController.d.ts +1 -1
- package/dist/world/placementController.js +7 -0
- package/dist/world/raceCircuit.d.ts +168 -0
- package/dist/world/raceCircuit.js +797 -0
- package/dist/world/terrain.d.ts +5 -1
- package/dist/world/terrain.js +5 -0
- package/dist/world/territory.d.ts +97 -0
- package/dist/world/territory.js +182 -0
- package/dist/world.d.ts +5 -3
- package/dist/world.js +4 -2
- package/package.json +1 -1
- package/skills/ce-handoff/SKILL.md +1 -1
- package/skills/game-design/SKILL.md +11 -1
- package/skills/jgengine/SKILL.md +2 -0
- package/skills/jgengine/api.md +94 -19
- package/skills/jgengine/capabilities.md +28 -0
- package/skills/jgengine-gameplay/SKILL.md +10 -0
- package/skills/jgengine-gameplay/api.md +40 -18
- package/skills/jgengine-gameplay/capabilities.md +12 -0
- package/skills/jgengine-world/SKILL.md +6 -0
- package/skills/jgengine-world/api.md +312 -12
- package/skills/jgengine-world/capabilities.md +102 -0
|
@@ -12,6 +12,10 @@ export interface PlacementRules {
|
|
|
12
12
|
bounds?: Aabb;
|
|
13
13
|
obstacles?: readonly PlacementObstacle[];
|
|
14
14
|
snap?: number;
|
|
15
|
+
/** Authoritative ownership/claim validation for this footprint. */
|
|
16
|
+
territory?: (aabb: Aabb) => {
|
|
17
|
+
ok: boolean;
|
|
18
|
+
};
|
|
15
19
|
}
|
|
16
20
|
export type PlacementResult = {
|
|
17
21
|
status: "ok";
|
|
@@ -20,6 +24,9 @@ export type PlacementResult = {
|
|
|
20
24
|
} | {
|
|
21
25
|
status: "rejected";
|
|
22
26
|
reason: "out-of-bounds";
|
|
27
|
+
} | {
|
|
28
|
+
status: "rejected";
|
|
29
|
+
reason: "territory.blocked";
|
|
23
30
|
} | {
|
|
24
31
|
status: "rejected";
|
|
25
32
|
reason: "overlap";
|
package/dist/world/placement.js
CHANGED
|
@@ -16,6 +16,8 @@ export function validatePlacement(request, rules = {}) {
|
|
|
16
16
|
return { status: "rejected", reason: "overlap", obstacle, index };
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
if (rules.territory && !rules.territory(aabb).ok)
|
|
20
|
+
return { status: "rejected", reason: "territory.blocked" };
|
|
19
21
|
return { status: "ok", center, aabb };
|
|
20
22
|
}
|
|
21
23
|
export function footprintObstacle(request, id) {
|
|
@@ -32,7 +32,7 @@ export interface PlacementPreview {
|
|
|
32
32
|
footprint: Footprint;
|
|
33
33
|
aabb: Aabb;
|
|
34
34
|
valid: boolean;
|
|
35
|
-
reason?: "out-of-bounds" | "overlap" | "no-slot";
|
|
35
|
+
reason?: "out-of-bounds" | "overlap" | "no-slot" | "territory.blocked";
|
|
36
36
|
snapMode: SnapMode;
|
|
37
37
|
normal: PlacementVec3;
|
|
38
38
|
/** Id of the resolved slot, when the controller is in slot mode and a slot matched. */
|
|
@@ -59,6 +59,13 @@ export function createPlacementController(config) {
|
|
|
59
59
|
normal: hit.normal,
|
|
60
60
|
...(slot === null ? { reason: "no-slot" } : { slotId: slot.id }),
|
|
61
61
|
};
|
|
62
|
+
if (slot !== null) {
|
|
63
|
+
const result = validatePlacement({ center, footprint, quarterTurns }, { ...rules, snap: undefined });
|
|
64
|
+
if (result.status === "rejected") {
|
|
65
|
+
next.valid = false;
|
|
66
|
+
next.reason = result.reason;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
62
69
|
preview = next;
|
|
63
70
|
return next;
|
|
64
71
|
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { StreetNetwork, StreetVec2 } from "./streetGenerator.js";
|
|
2
|
+
/** How a sealed-off side street is closed: hard barriers, a cone line, or temporary fencing. */
|
|
3
|
+
export type CircuitSealKind = "barrier" | "cones" | "fence";
|
|
4
|
+
/** Fully-defaulted sliders the route search answers to. */
|
|
5
|
+
export interface CircuitRouteRules {
|
|
6
|
+
seed: string;
|
|
7
|
+
/** Target lap length in meters — the search keeps the cycle closest to this. */
|
|
8
|
+
lapLength: number;
|
|
9
|
+
/** 0 races any street; 1 keeps the lap on avenues and boulevards only. */
|
|
10
|
+
arterialBias: number;
|
|
11
|
+
/**
|
|
12
|
+
* Radius (m) the corner-rounding pass works the racing line toward. Bounded by `cornerCut` and the
|
|
13
|
+
* road width — the line never leaves the street — so the achieved figure is reported back as
|
|
14
|
+
* {@link CircuitRoute.tightestRadius} rather than enforced here.
|
|
15
|
+
*/
|
|
16
|
+
minCornerRadius: number;
|
|
17
|
+
/** Ordered checkpoint gates placed around the lap. */
|
|
18
|
+
checkpoints: number;
|
|
19
|
+
/** Laps the produced race runs. */
|
|
20
|
+
laps: number;
|
|
21
|
+
/** Half-height of a checkpoint gate volume (m) — how tall the trigger box reaches. */
|
|
22
|
+
gateHeight: number;
|
|
23
|
+
/** Starting grid slots behind the line (0 = no grid). */
|
|
24
|
+
gridSlots: number;
|
|
25
|
+
/** How the side streets leaving the lap are closed off. */
|
|
26
|
+
sealKind: CircuitSealKind;
|
|
27
|
+
/** Timing sectors the lap splits into. */
|
|
28
|
+
sectors: number;
|
|
29
|
+
/**
|
|
30
|
+
* Arc-length spacing (m) the lap is resampled to. City streets are sampled coarsely enough for a
|
|
31
|
+
* road ribbon but far too coarsely for a racing surface, corner analysis, or kerbs.
|
|
32
|
+
*/
|
|
33
|
+
sampleStep: number;
|
|
34
|
+
/**
|
|
35
|
+
* How far the racing line may be pulled off the street centerline while rounding a junction, as a
|
|
36
|
+
* fraction of the local half-width. 0 keeps the hard kink; ~0.5 uses the full lane either side.
|
|
37
|
+
*/
|
|
38
|
+
cornerCut: number;
|
|
39
|
+
}
|
|
40
|
+
/** Defaults: a ~2.4 km arterial street lap with 12 gates, 3 laps, and barriered side streets. */
|
|
41
|
+
export declare const CIRCUIT_ROUTE_DEFAULTS: CircuitRouteRules;
|
|
42
|
+
/**
|
|
43
|
+
* One street closed off where it leaves the lap — the thing that turns public roads into an
|
|
44
|
+
* instanced event. Stands just off the junction, spanning the sealed street's full width.
|
|
45
|
+
*/
|
|
46
|
+
export interface CircuitSeal {
|
|
47
|
+
/** Volume-local XZ of the barrier run's center. */
|
|
48
|
+
x: number;
|
|
49
|
+
z: number;
|
|
50
|
+
/** Yaw (radians) pointing down the sealed street, away from the lap. */
|
|
51
|
+
heading: number;
|
|
52
|
+
/** Width of the street being closed — the run spans it plus a shoulder. */
|
|
53
|
+
width: number;
|
|
54
|
+
kind: CircuitSealKind;
|
|
55
|
+
/** Graph node the seal stands at. */
|
|
56
|
+
node: number;
|
|
57
|
+
}
|
|
58
|
+
/** One analyzed corner: where the lap turns, how hard, and which way. */
|
|
59
|
+
export interface CircuitCorner {
|
|
60
|
+
/** `centerline` index at the apex (tightest point). */
|
|
61
|
+
apex: number;
|
|
62
|
+
/** Radius of curvature at the apex, meters. */
|
|
63
|
+
radius: number;
|
|
64
|
+
/** Total turn through the corner, radians. */
|
|
65
|
+
angle: number;
|
|
66
|
+
/** -1 = left-hand, 1 = right-hand. */
|
|
67
|
+
direction: -1 | 1;
|
|
68
|
+
/** `centerline` index where the corner starts. */
|
|
69
|
+
entry: number;
|
|
70
|
+
/** `centerline` index where it ends. */
|
|
71
|
+
exit: number;
|
|
72
|
+
}
|
|
73
|
+
/** One checkpoint trigger volume, shaped to hand straight to `raceTrack({ checkpoints })`. */
|
|
74
|
+
export interface CircuitGate {
|
|
75
|
+
id: string;
|
|
76
|
+
center: readonly [number, number, number];
|
|
77
|
+
half: readonly [number, number, number];
|
|
78
|
+
}
|
|
79
|
+
/** The start/finish line: where it is, which way cars face, and the painted line across the road. */
|
|
80
|
+
export interface CircuitStart {
|
|
81
|
+
x: number;
|
|
82
|
+
z: number;
|
|
83
|
+
/** Yaw cars face on the grid (direction of travel). */
|
|
84
|
+
heading: number;
|
|
85
|
+
/** The two road-edge ends of the painted line. */
|
|
86
|
+
line: readonly [StreetVec2, StreetVec2];
|
|
87
|
+
/** Arc-length position of the line along the lap, meters. */
|
|
88
|
+
distance: number;
|
|
89
|
+
/** Road width at the line. */
|
|
90
|
+
width: number;
|
|
91
|
+
}
|
|
92
|
+
/** One grid slot: a staggered spawn behind the start line. */
|
|
93
|
+
export interface CircuitGridSlot {
|
|
94
|
+
x: number;
|
|
95
|
+
z: number;
|
|
96
|
+
/** Yaw facing down the start straight. */
|
|
97
|
+
heading: number;
|
|
98
|
+
}
|
|
99
|
+
/** One kerb strip on the outside or inside of a corner, as an offset polyline to stripe. */
|
|
100
|
+
export interface CircuitKerb {
|
|
101
|
+
/** Polyline along the road edge the kerb hugs. */
|
|
102
|
+
points: StreetVec2[];
|
|
103
|
+
/** Strip width across, meters. */
|
|
104
|
+
width: number;
|
|
105
|
+
/** Which side of travel the strip sits on: -1 left, 1 right. */
|
|
106
|
+
side: -1 | 1;
|
|
107
|
+
/** Alternating stripe length along the run, meters. */
|
|
108
|
+
stripe: number;
|
|
109
|
+
/** Corner this kerb belongs to (index into {@link CircuitRoute.corners}). */
|
|
110
|
+
corner: number;
|
|
111
|
+
}
|
|
112
|
+
/** A closed race lap lifted out of a street network, with everything a race needs hung off it. */
|
|
113
|
+
export interface CircuitRoute {
|
|
114
|
+
/** Closed lap centerline in volume-local XZ. Implicitly closed: the last point joins the first. */
|
|
115
|
+
centerline: StreetVec2[];
|
|
116
|
+
/** Road width at each centerline point, inherited from the streets the lap follows. */
|
|
117
|
+
widths: number[];
|
|
118
|
+
/** Road-surface height per point, present only when the network carries elevation. */
|
|
119
|
+
heights?: number[];
|
|
120
|
+
/** Lap length, meters. */
|
|
121
|
+
length: number;
|
|
122
|
+
/** Graph edge ids the lap runs on — style exactly these streets as track surface. */
|
|
123
|
+
edges: number[];
|
|
124
|
+
/** Graph node ids the lap visits in order (no repeat of the closing node). */
|
|
125
|
+
nodes: number[];
|
|
126
|
+
/** Every street leaving the lap that is not part of it, closed off. */
|
|
127
|
+
seals: CircuitSeal[];
|
|
128
|
+
corners: CircuitCorner[];
|
|
129
|
+
/** Ordered gates, finish line last — ready for `raceTrack({ checkpoints, laps })`. */
|
|
130
|
+
checkpoints: CircuitGate[];
|
|
131
|
+
laps: number;
|
|
132
|
+
start: CircuitStart;
|
|
133
|
+
grid: CircuitGridSlot[];
|
|
134
|
+
/** Arc-length fractions (0..1) where each timing sector begins; `sectors[0]` is always 0. */
|
|
135
|
+
sectors: number[];
|
|
136
|
+
/** Share of lap length running on avenue-or-wider streets, 0..1. */
|
|
137
|
+
arterialShare: number;
|
|
138
|
+
/**
|
|
139
|
+
* Tightest radius (m) the finished racing line actually holds. `minCornerRadius` is a TARGET the
|
|
140
|
+
* rounding pass works toward, not a guarantee: rounding may not pull the line outside the street it
|
|
141
|
+
* inherited, so a 90° junction on a narrow road stays tighter than any target can ask for. Read
|
|
142
|
+
* this to report what the lap really is — widen `streetWidth` to buy a smoother one.
|
|
143
|
+
*/
|
|
144
|
+
tightestRadius: number;
|
|
145
|
+
}
|
|
146
|
+
/** Kerb strips on the outside and inside of every real corner. */
|
|
147
|
+
export interface CircuitKerbOptions {
|
|
148
|
+
/** Strip width across, meters. Defaults to 1.1. */
|
|
149
|
+
width?: number;
|
|
150
|
+
/** Alternating stripe length along the run, meters. Defaults to 2.2. */
|
|
151
|
+
stripe?: number;
|
|
152
|
+
/** Only kerb corners at or below this radius (m). Defaults to 6× the route's tightest corner. */
|
|
153
|
+
maxRadius?: number;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Red/white kerb strips hugging both road edges through each corner. Returns the polylines and
|
|
157
|
+
* stripe pitch as data; the renderer owns the mesh and the colors.
|
|
158
|
+
*/
|
|
159
|
+
export declare function circuitKerbs(route: CircuitRoute, options?: CircuitKerbOptions): CircuitKerb[];
|
|
160
|
+
/**
|
|
161
|
+
* Lift a closed, sealed-off race lap out of an existing street network. Returns `null` when the
|
|
162
|
+
* network has no drivable cycle (a pure tree of dead-end streets), so callers can fall back or warn
|
|
163
|
+
* rather than render a broken race.
|
|
164
|
+
*
|
|
165
|
+
* On a `circuit`-mode network the generated loop is used directly. On a `net` (a city) the graph is
|
|
166
|
+
* searched for the cycle closest to `lapLength` that respects `arterialBias` and `minCornerRadius`.
|
|
167
|
+
*/
|
|
168
|
+
export declare function extractCircuitRoute(network: StreetNetwork, rules?: Partial<CircuitRouteRules>): CircuitRoute | null;
|