@jgengine/shell 0.8.0 → 0.10.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +11 -0
  3. package/dist/GamePlayerShell.d.ts +10 -22
  4. package/dist/GamePlayerShell.js +709 -264
  5. package/dist/GameUiPreview.js +2 -1
  6. package/dist/audio/AudioComponents.js +25 -8
  7. package/dist/audio/audioEngine.d.ts +9 -0
  8. package/dist/audio/audioEngine.js +37 -0
  9. package/dist/audio/musicDirector.d.ts +31 -0
  10. package/dist/audio/musicDirector.js +125 -0
  11. package/dist/audio/musicVoices.d.ts +10 -0
  12. package/dist/audio/musicVoices.js +338 -0
  13. package/dist/audio/synthEngine.d.ts +9 -0
  14. package/dist/audio/synthEngine.js +57 -0
  15. package/dist/behaviour.d.ts +5 -24
  16. package/dist/behaviour.js +14 -50
  17. package/dist/behaviourAttach.d.ts +9 -0
  18. package/dist/behaviourAttach.js +32 -0
  19. package/dist/behaviourDriver.d.ts +7 -0
  20. package/dist/behaviourDriver.js +21 -0
  21. package/dist/camera/GameCameraRig.js +1 -1
  22. package/dist/camera/GameFirstPersonCamera.d.ts +3 -0
  23. package/dist/camera/GameFirstPersonCamera.js +35 -4
  24. package/dist/camera/GameInspectionCamera.js +12 -1
  25. package/dist/camera/GameOrbitCamera.js +44 -1
  26. package/dist/camera/PlayerFov.d.ts +18 -0
  27. package/dist/camera/PlayerFov.js +48 -0
  28. package/dist/camera/cameraBlendMath.d.ts +13 -0
  29. package/dist/camera/cameraBlendMath.js +36 -0
  30. package/dist/camera/cameraRigs.d.ts +3 -0
  31. package/dist/camera/cameraRigs.js +36 -33
  32. package/dist/camera/fovPreference.d.ts +25 -0
  33. package/dist/camera/fovPreference.js +73 -0
  34. package/dist/camera/index.d.ts +3 -0
  35. package/dist/camera/index.js +3 -0
  36. package/dist/camera/orbitCameraMath.d.ts +18 -0
  37. package/dist/camera/orbitCameraMath.js +6 -1
  38. package/dist/camera/rigMath.d.ts +10 -0
  39. package/dist/camera/rigMath.js +36 -1
  40. package/dist/camera/shakeChannel.d.ts +3 -17
  41. package/dist/camera/shakeChannel.js +2 -21
  42. package/dist/camera/shakeChannelMath.d.ts +8 -0
  43. package/dist/camera/shakeChannelMath.js +21 -0
  44. package/dist/cartridge.d.ts +145 -0
  45. package/dist/cartridge.js +246 -0
  46. package/dist/commandSink.d.ts +20 -0
  47. package/dist/commandSink.js +27 -0
  48. package/dist/defineGame.js +4 -1
  49. package/dist/devtools/CollisionDebugWorld.d.ts +5 -0
  50. package/dist/devtools/CollisionDebugWorld.js +181 -0
  51. package/dist/devtools/DevtoolsOverlay.d.ts +65 -1
  52. package/dist/devtools/DevtoolsOverlay.js +383 -41
  53. package/dist/devtools/collisionDebug.d.ts +57 -0
  54. package/dist/devtools/collisionDebug.js +127 -0
  55. package/dist/devtools/collisionDebugMath.d.ts +103 -0
  56. package/dist/devtools/collisionDebugMath.js +129 -0
  57. package/dist/environment/Daylight.d.ts +20 -8
  58. package/dist/environment/Daylight.js +63 -15
  59. package/dist/environment/EnvironmentScene.js +91 -35
  60. package/dist/environment/RoadRibbons.d.ts +7 -0
  61. package/dist/environment/RoadRibbons.js +57 -0
  62. package/dist/environment/groundPadMath.d.ts +2 -2
  63. package/dist/environment/groundPadMath.js +1 -1
  64. package/dist/environment/index.d.ts +2 -1
  65. package/dist/environment/index.js +1 -0
  66. package/dist/environment/skyLightingPolicy.d.ts +10 -0
  67. package/dist/environment/skyLightingPolicy.js +6 -0
  68. package/dist/input/mouseLook.d.ts +27 -0
  69. package/dist/input/mouseLook.js +35 -0
  70. package/dist/inputSink.d.ts +18 -0
  71. package/dist/inputSink.js +35 -0
  72. package/dist/materialOverride.d.ts +4 -6
  73. package/dist/materialOverride.js +12 -16
  74. package/dist/multiplayer.js +7 -3
  75. package/dist/pointer/PointerProbe.js +6 -2
  76. package/dist/pointer/pointerService.d.ts +3 -0
  77. package/dist/pointer/pointerService.js +6 -0
  78. package/dist/postfx/PostProcessing.d.ts +10 -0
  79. package/dist/postfx/PostProcessing.js +82 -0
  80. package/dist/postfx/gradeShader.d.ts +4 -0
  81. package/dist/postfx/gradeShader.js +64 -0
  82. package/dist/render/modelRender.d.ts +10 -1
  83. package/dist/render/modelRender.js +32 -5
  84. package/dist/render/resolveModel.d.ts +14 -0
  85. package/dist/render/resolveModel.js +24 -0
  86. package/dist/settings/QuickControls.d.ts +4 -0
  87. package/dist/settings/QuickControls.js +42 -0
  88. package/dist/settings/SettingsChrome.d.ts +1 -0
  89. package/dist/settings/SettingsChrome.js +10 -0
  90. package/dist/settings/SettingsMenu.d.ts +6 -0
  91. package/dist/settings/SettingsMenu.js +148 -0
  92. package/dist/settings/SettingsRuntime.d.ts +11 -0
  93. package/dist/settings/SettingsRuntime.js +19 -0
  94. package/dist/settings/appliedSettings.d.ts +14 -0
  95. package/dist/settings/appliedSettings.js +27 -0
  96. package/dist/settings/settingsController.d.ts +20 -0
  97. package/dist/settings/settingsController.js +165 -0
  98. package/dist/structures/GeneratedBuilding.d.ts +10 -0
  99. package/dist/structures/GeneratedBuilding.js +96 -8
  100. package/dist/structures/index.d.ts +1 -1
  101. package/dist/structures/index.js +1 -1
  102. package/dist/terrain/CarvedTerrain.d.ts +5 -1
  103. package/dist/terrain/CarvedTerrain.js +6 -5
  104. package/dist/terrain/GrassField.d.ts +3 -1
  105. package/dist/terrain/GrassField.js +4 -2
  106. package/dist/terrain/grassBudget.d.ts +3 -0
  107. package/dist/terrain/grassBudget.js +6 -0
  108. package/dist/terrain/grassGeometry.js +1 -1
  109. package/dist/terrain/terrainDetailMaterial.d.ts +14 -0
  110. package/dist/terrain/terrainDetailMaterial.js +90 -0
  111. package/dist/terrain/terrainMath.d.ts +8 -0
  112. package/dist/terrain/terrainMath.js +9 -0
  113. package/dist/touch/OrientationHint.d.ts +3 -0
  114. package/dist/touch/OrientationHint.js +13 -0
  115. package/dist/touch/TouchControlsOverlay.d.ts +17 -1
  116. package/dist/touch/TouchControlsOverlay.js +125 -9
  117. package/dist/visibility/CullingProvider.d.ts +21 -0
  118. package/dist/visibility/CullingProvider.js +134 -0
  119. package/dist/vision/FrustumSensorHud.d.ts +1 -6
  120. package/dist/vision/FrustumSensorHud.js +25 -27
  121. package/dist/vision/frustumSampleEqual.d.ts +2 -0
  122. package/dist/vision/frustumSampleEqual.js +10 -0
  123. package/dist/water/Ocean.js +1 -1
  124. package/dist/water/OceanConfig.d.ts +13 -0
  125. package/dist/water/OceanConfig.js +25 -17
  126. package/dist/water/index.d.ts +1 -1
  127. package/dist/water/index.js +1 -1
  128. package/dist/weather/FireSpreadLayer.js +7 -2
  129. package/dist/weather/RainField.d.ts +3 -1
  130. package/dist/weather/RainField.js +4 -4
  131. package/dist/weather/SnowField.d.ts +3 -1
  132. package/dist/weather/SnowField.js +4 -4
  133. package/dist/weather/fireSpreadPose.d.ts +2 -0
  134. package/dist/weather/fireSpreadPose.js +4 -0
  135. package/dist/weather/weatherMath.d.ts +5 -1
  136. package/dist/weather/weatherMath.js +7 -2
  137. package/dist/world/DataObjects.d.ts +1 -1
  138. package/dist/world/DataObjects.js +3 -1
  139. package/dist/world/SpriteBatch.d.ts +44 -0
  140. package/dist/world/SpriteBatch.js +112 -0
  141. package/dist/world/WorldHud.d.ts +6 -1
  142. package/dist/world/WorldHud.js +95 -48
  143. package/dist/world/entityPose.d.ts +14 -0
  144. package/dist/world/entityPose.js +10 -0
  145. package/dist/world/telegraphPulse.d.ts +1 -0
  146. package/dist/world/telegraphPulse.js +4 -0
  147. package/dist/world/worldBarSamples.d.ts +30 -0
  148. package/dist/world/worldBarSamples.js +57 -0
  149. package/dist/worldSync.d.ts +10 -0
  150. package/dist/worldSync.js +19 -0
  151. package/llms.txt +1522 -1143
  152. package/package.json +4 -4
@@ -0,0 +1,30 @@
1
+ import type { SceneEntity } from "@jgengine/core/scene/entityStore";
2
+ import type { CatalogEntityRole } from "@jgengine/core/runtime/gameContext";
3
+ import type { GameContext } from "@jgengine/core/runtime/gameContext";
4
+ export interface WorldBarSample {
5
+ x: number;
6
+ y: number;
7
+ percent: number;
8
+ }
9
+ export interface Projectable {
10
+ set(x: number, y: number, z: number): this;
11
+ project(camera: {
12
+ matrixWorldInverse: unknown;
13
+ projectionMatrix: unknown;
14
+ }): this;
15
+ x: number;
16
+ y: number;
17
+ z: number;
18
+ }
19
+ export declare function collectWorldBarSamples(ctx: GameContext, statId: string, height: number, roles: readonly CatalogEntityRole[] | undefined, resolveRole: ((entity: SceneEntity) => CatalogEntityRole | undefined) | undefined, camera: {
20
+ matrixWorldInverse: unknown;
21
+ projectionMatrix: unknown;
22
+ }, viewport: {
23
+ width: number;
24
+ height: number;
25
+ }, into: WorldBarSample[], project: Projectable, maxDistance?: number): number;
26
+ export declare function paintWorldBarSamples(canvas: {
27
+ width: number;
28
+ height: number;
29
+ getContext(kind: "2d"): CanvasRenderingContext2D | null;
30
+ }, samples: readonly WorldBarSample[], dpr: number, barWidthPx?: number, barHeightPx?: number): void;
@@ -0,0 +1,57 @@
1
+ import { worldHealthBarAllowsRole } from "@jgengine/core/game/playableGame";
2
+ export function collectWorldBarSamples(ctx, statId, height, roles, resolveRole, camera, viewport, into, project, maxDistance = 60) {
3
+ into.length = 0;
4
+ const playerId = ctx.player.userId;
5
+ const player = ctx.scene.entity.get(playerId);
6
+ for (const entity of ctx.scene.entity.list()) {
7
+ if (entity.id === playerId)
8
+ continue;
9
+ if (!worldHealthBarAllowsRole(roles, resolveRole?.(entity)))
10
+ continue;
11
+ if (player !== null &&
12
+ Math.hypot(entity.position[0] - player.position[0], entity.position[2] - player.position[2]) >
13
+ maxDistance) {
14
+ continue;
15
+ }
16
+ const stat = ctx.scene.entity.stats.get(entity.id, statId);
17
+ if (stat === null)
18
+ continue;
19
+ const range = stat.max - stat.min;
20
+ const percent = range <= 0 ? 0 : Math.max(0, Math.min(1, (stat.current - stat.min) / range));
21
+ project.set(entity.position[0], entity.position[1] + height, entity.position[2]);
22
+ project.project(camera);
23
+ if (project.z < -1 || project.z > 1)
24
+ continue;
25
+ const x = (project.x * 0.5 + 0.5) * viewport.width;
26
+ const y = (-project.y * 0.5 + 0.5) * viewport.height;
27
+ into.push({ x, y, percent });
28
+ }
29
+ return into.length;
30
+ }
31
+ export function paintWorldBarSamples(canvas, samples, dpr, barWidthPx = 112, barHeightPx = 10) {
32
+ const g = canvas.getContext("2d");
33
+ if (g === null)
34
+ return;
35
+ g.setTransform(1, 0, 0, 1, 0, 0);
36
+ g.clearRect(0, 0, canvas.width, canvas.height);
37
+ g.setTransform(dpr, 0, 0, dpr, 0, 0);
38
+ const halfW = barWidthPx / 2;
39
+ const halfH = barHeightPx / 2;
40
+ for (const sample of samples) {
41
+ const left = sample.x - halfW;
42
+ const top = sample.y - halfH;
43
+ g.fillStyle = "rgba(0,0,0,0.7)";
44
+ g.strokeStyle = "rgba(0,0,0,0.7)";
45
+ g.lineWidth = 1;
46
+ g.fillRect(left, top, barWidthPx, barHeightPx);
47
+ g.strokeRect(left + 0.5, top + 0.5, barWidthPx - 1, barHeightPx - 1);
48
+ const fill = Math.max(0, Math.min(barWidthPx, sample.percent * barWidthPx));
49
+ if (fill > 0) {
50
+ const gradient = g.createLinearGradient(left, top, left + barWidthPx, top);
51
+ gradient.addColorStop(0, "#e11d48");
52
+ gradient.addColorStop(1, "#f87171");
53
+ g.fillStyle = gradient;
54
+ g.fillRect(left, top, fill, barHeightPx);
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,10 @@
1
+ import type { GameContext } from "@jgengine/core/runtime/gameContext";
2
+ import type { GameRuntimeFeeds } from "@jgengine/core/runtime/transport";
3
+ /**
4
+ * Client half of host-authoritative play: subscribe to the server-state channel and mirror each authoritative
5
+ * `WorldSnapshot` (carried in `serverState`) into the local `ctx`, so the game renders the host's world instead
6
+ * of a locally-simulated one. Pure and transport-agnostic — the backend's `feeds.subscribeServer` is the only
7
+ * dependency; returns the unsubscribe. The shell attaches this (and gates its local sim) when the game's adapter
8
+ * opts into `authority: "server"`.
9
+ */
10
+ export declare function attachWorldSync(feeds: Pick<GameRuntimeFeeds, "subscribeServer">, serverId: string, ctx: Pick<GameContext, "hydrate">): () => void;
@@ -0,0 +1,19 @@
1
+ import { createWorldMirror } from "@jgengine/core/runtime/worldMirror";
2
+ /**
3
+ * Client half of host-authoritative play: subscribe to the server-state channel and mirror each authoritative
4
+ * `WorldSnapshot` (carried in `serverState`) into the local `ctx`, so the game renders the host's world instead
5
+ * of a locally-simulated one. Pure and transport-agnostic — the backend's `feeds.subscribeServer` is the only
6
+ * dependency; returns the unsubscribe. The shell attaches this (and gates its local sim) when the game's adapter
7
+ * opts into `authority: "server"`.
8
+ */
9
+ export function attachWorldSync(feeds, serverId, ctx) {
10
+ const mirror = createWorldMirror(ctx);
11
+ return feeds.subscribeServer(serverId, (view) => {
12
+ if (view === null)
13
+ return;
14
+ const snapshot = view.serverState;
15
+ if (snapshot === null || snapshot === undefined)
16
+ return;
17
+ mirror.applyBaseline(view.revision, snapshot);
18
+ });
19
+ }