@jgengine/shell 0.10.0 → 0.12.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 (286) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/LICENSE +203 -661
  3. package/README.md +1 -1
  4. package/dist/CombatPresentation.d.ts +5 -0
  5. package/dist/CombatPresentation.js +8 -0
  6. package/dist/GameHost.d.ts +25 -1
  7. package/dist/GameHost.js +60 -4
  8. package/dist/GamePhaseStamp.d.ts +1 -0
  9. package/dist/GamePhaseStamp.js +9 -0
  10. package/dist/GamePlayer.d.ts +5 -0
  11. package/dist/GamePlayer.js +5 -0
  12. package/dist/GamePlayerShell.d.ts +5 -12
  13. package/dist/GamePlayerShell.js +67 -1332
  14. package/dist/GameUiPreview.js +3 -2
  15. package/dist/Shell3dPresentation.d.ts +63 -0
  16. package/dist/Shell3dPresentation.js +302 -0
  17. package/dist/ShellChrome.d.ts +51 -0
  18. package/dist/ShellChrome.js +51 -0
  19. package/dist/ShellHudPresentation.d.ts +41 -0
  20. package/dist/ShellHudPresentation.js +22 -0
  21. package/dist/audio/audioEngine.d.ts +4 -0
  22. package/dist/audio/audioEngine.js +128 -21
  23. package/dist/audio/audioWire.d.ts +40 -0
  24. package/dist/audio/audioWire.js +62 -0
  25. package/dist/audio/loopParams.d.ts +20 -0
  26. package/dist/audio/loopParams.js +28 -0
  27. package/dist/behaviour.d.ts +2 -1
  28. package/dist/behaviour.js +2 -1
  29. package/dist/behaviourAttach.d.ts +1 -0
  30. package/dist/behaviourAttach.js +1 -0
  31. package/dist/behaviourDriver.d.ts +1 -0
  32. package/dist/behaviourDriver.js +1 -0
  33. package/dist/boundActionDispatch.d.ts +13 -0
  34. package/dist/boundActionDispatch.js +37 -0
  35. package/dist/camera/GameCameraRig.d.ts +5 -2
  36. package/dist/camera/GameCameraRig.js +8 -3
  37. package/dist/camera/GameFirstPersonCamera.d.ts +9 -2
  38. package/dist/camera/GameFirstPersonCamera.js +8 -3
  39. package/dist/camera/GameInspectionCamera.d.ts +1 -1
  40. package/dist/camera/GameInspectionCamera.js +2 -2
  41. package/dist/camera/GameOrbitCamera.js +24 -9
  42. package/dist/camera/cameraBlendMath.d.ts +3 -0
  43. package/dist/camera/cameraBlendMath.js +3 -0
  44. package/dist/camera/cameraRigs.d.ts +3 -1
  45. package/dist/camera/cameraRigs.js +21 -3
  46. package/dist/camera/fovPreference.d.ts +6 -1
  47. package/dist/camera/fovPreference.js +6 -1
  48. package/dist/camera/index.d.ts +4 -7
  49. package/dist/camera/index.js +4 -7
  50. package/dist/camera/inspectionCameraMath.d.ts +7 -2
  51. package/dist/camera/inspectionCameraMath.js +7 -2
  52. package/dist/camera/orbitCameraMath.d.ts +36 -6
  53. package/dist/camera/orbitCameraMath.js +56 -6
  54. package/dist/camera/rigMath.d.ts +114 -24
  55. package/dist/camera/rigMath.js +129 -24
  56. package/dist/camera/rigResolve.d.ts +4 -2
  57. package/dist/camera/rigResolve.js +4 -2
  58. package/dist/camera/shakeChannel.d.ts +6 -2
  59. package/dist/camera/shakeChannel.js +6 -2
  60. package/dist/camera/shakeChannelMath.d.ts +1 -0
  61. package/dist/camera/shakeChannelMath.js +1 -0
  62. package/dist/commandSink.d.ts +8 -3
  63. package/dist/commandSink.js +8 -3
  64. package/dist/defineGame.d.ts +15 -1
  65. package/dist/defineGame.js +50 -9
  66. package/dist/devtools/ColPanel.d.ts +1 -0
  67. package/dist/devtools/ColPanel.js +14 -0
  68. package/dist/devtools/DevtoolsOverlay.d.ts +11 -7
  69. package/dist/devtools/DevtoolsOverlay.js +47 -462
  70. package/dist/devtools/KeysPanel.d.ts +4 -0
  71. package/dist/devtools/KeysPanel.js +31 -0
  72. package/dist/devtools/LogsPanel.d.ts +1 -0
  73. package/dist/devtools/LogsPanel.js +12 -0
  74. package/dist/devtools/NetPanel.d.ts +4 -0
  75. package/dist/devtools/NetPanel.js +10 -0
  76. package/dist/devtools/PerfPanel.d.ts +4 -0
  77. package/dist/devtools/PerfPanel.js +53 -0
  78. package/dist/devtools/TunePanel.d.ts +3 -0
  79. package/dist/devtools/TunePanel.js +309 -0
  80. package/dist/devtools/agentBridge.d.ts +41 -0
  81. package/dist/devtools/agentBridge.js +266 -0
  82. package/dist/devtools/collisionDebug.d.ts +6 -0
  83. package/dist/devtools/collisionDebug.js +6 -0
  84. package/dist/devtools/collisionDebugMath.d.ts +8 -2
  85. package/dist/devtools/collisionDebugMath.js +24 -5
  86. package/dist/devtools/devtoolsOverrides.d.ts +6 -0
  87. package/dist/devtools/devtoolsOverrides.js +48 -0
  88. package/dist/devtools/panelAtoms.d.ts +9 -0
  89. package/dist/devtools/panelAtoms.js +10 -0
  90. package/dist/devtools/perfDiagnose.d.ts +2 -0
  91. package/dist/devtools/perfDiagnose.js +43 -0
  92. package/dist/diagnostics/RuntimeDiagnostics.d.ts +36 -0
  93. package/dist/diagnostics/RuntimeDiagnostics.js +80 -0
  94. package/dist/drivers/FrameDriver.d.ts +37 -0
  95. package/dist/drivers/FrameDriver.js +232 -0
  96. package/dist/drivers/HudOnlyDriver.d.ts +16 -0
  97. package/dist/drivers/HudOnlyDriver.js +60 -0
  98. package/dist/environment/Daylight.d.ts +23 -7
  99. package/dist/environment/Daylight.js +106 -13
  100. package/dist/environment/EnvironmentScene.js +44 -9
  101. package/dist/environment/VolumetricClouds.d.ts +17 -0
  102. package/dist/environment/VolumetricClouds.js +202 -0
  103. package/dist/environment/daylightCycle.d.ts +3 -1
  104. package/dist/environment/daylightCycle.js +3 -1
  105. package/dist/environment/groundPadMath.d.ts +3 -0
  106. package/dist/environment/groundPadMath.js +3 -0
  107. package/dist/environment/index.d.ts +1 -0
  108. package/dist/environment/index.js +1 -0
  109. package/dist/environment/skyLightingPolicy.d.ts +2 -0
  110. package/dist/environment/skyLightingPolicy.js +2 -0
  111. package/dist/environment/terrainGroundColor.d.ts +9 -0
  112. package/dist/environment/terrainGroundColor.js +22 -0
  113. package/dist/gameKit.d.ts +27 -0
  114. package/dist/gameKit.js +29 -0
  115. package/dist/hotbarActions.d.ts +26 -0
  116. package/dist/hotbarActions.js +27 -0
  117. package/dist/inputSink.d.ts +16 -4
  118. package/dist/inputSink.js +57 -7
  119. package/dist/map/MapMarkerBeacons.d.ts +3 -2
  120. package/dist/materialOverride.d.ts +10 -0
  121. package/dist/materialOverride.js +15 -3
  122. package/dist/multiplayer.js +8 -2
  123. package/dist/postfx/PostProcessing.d.ts +9 -1
  124. package/dist/postfx/PostProcessing.js +56 -11
  125. package/dist/postfx/gradeShader.js +9 -1
  126. package/dist/presentationResolve.d.ts +35 -0
  127. package/dist/presentationResolve.js +51 -0
  128. package/dist/registry.d.ts +4 -2
  129. package/dist/render/EnvironmentLighting.d.ts +10 -0
  130. package/dist/render/EnvironmentLighting.js +34 -0
  131. package/dist/render/SceneLighting.d.ts +7 -0
  132. package/dist/render/SceneLighting.js +18 -0
  133. package/dist/render/SceneModels.d.ts +14 -0
  134. package/dist/render/SceneModels.js +337 -0
  135. package/dist/render/assetBase.d.ts +17 -0
  136. package/dist/render/assetBase.js +35 -0
  137. package/dist/render/defaultSurface.d.ts +29 -0
  138. package/dist/render/defaultSurface.js +101 -0
  139. package/dist/render/modelLoad.d.ts +24 -0
  140. package/dist/render/modelLoad.js +76 -0
  141. package/dist/render/modelRender.d.ts +11 -0
  142. package/dist/render/modelRender.js +15 -0
  143. package/dist/render/resolveModel.d.ts +54 -3
  144. package/dist/render/resolveModel.js +116 -4
  145. package/dist/render/useEntityRenderCues.d.ts +13 -0
  146. package/dist/render/useEntityRenderCues.js +62 -0
  147. package/dist/scatter/InstancedScatter.d.ts +24 -0
  148. package/dist/scatter/InstancedScatter.js +135 -0
  149. package/dist/scatter/scatterModels.d.ts +25 -0
  150. package/dist/scatter/scatterModels.js +61 -0
  151. package/dist/scatter/scatterProxies.d.ts +6 -0
  152. package/dist/scatter/scatterProxies.js +118 -0
  153. package/dist/scatter.d.ts +1 -0
  154. package/dist/scatter.js +1 -0
  155. package/dist/scene/AuthoredScene.d.ts +84 -0
  156. package/dist/scene/AuthoredScene.js +178 -0
  157. package/dist/scene/CityRenderer.d.ts +2 -0
  158. package/dist/scene/CityRenderer.js +1031 -0
  159. package/dist/scene/GeneratedAssetRenderer.d.ts +14 -0
  160. package/dist/scene/GeneratedAssetRenderer.js +59 -0
  161. package/dist/scene/GrassFieldRenderer.d.ts +2 -0
  162. package/dist/scene/GrassFieldRenderer.js +73 -0
  163. package/dist/scene/PoleLineRenderer.d.ts +2 -0
  164. package/dist/scene/PoleLineRenderer.js +287 -0
  165. package/dist/scene/SoilPatchRenderer.d.ts +2 -0
  166. package/dist/scene/SoilPatchRenderer.js +84 -0
  167. package/dist/scene/StudioStage.d.ts +37 -0
  168. package/dist/scene/StudioStage.js +42 -0
  169. package/dist/scene/WaterRenderer.d.ts +2 -0
  170. package/dist/scene/WaterRenderer.js +61 -0
  171. package/dist/scene/builtinSceneKindRenderers.d.ts +2 -0
  172. package/dist/scene/builtinSceneKindRenderers.js +26 -0
  173. package/dist/scene/cityWindowMaterial.d.ts +16 -0
  174. package/dist/scene/cityWindowMaterial.js +81 -0
  175. package/dist/scene/sceneKindRenderers.d.ts +30 -0
  176. package/dist/scene/sceneKindRenderers.js +17 -0
  177. package/dist/scene.d.ts +1 -0
  178. package/dist/scene.js +1 -0
  179. package/dist/settings/appliedSettings.d.ts +7 -1
  180. package/dist/settings/appliedSettings.js +13 -2
  181. package/dist/settings/settingsController.d.ts +2 -0
  182. package/dist/settings/settingsController.js +22 -1
  183. package/dist/shellConstants.d.ts +4 -0
  184. package/dist/shellConstants.js +4 -0
  185. package/dist/shellMovement.d.ts +8 -0
  186. package/dist/shellMovement.js +11 -0
  187. package/dist/shellPointer.d.ts +20 -0
  188. package/dist/shellPointer.js +28 -0
  189. package/dist/structures/PlacementGhost.d.ts +4 -0
  190. package/dist/structures/PlacementGhost.js +4 -0
  191. package/dist/structures/TransformGizmo.d.ts +53 -0
  192. package/dist/structures/TransformGizmo.js +59 -0
  193. package/dist/structures/index.d.ts +1 -0
  194. package/dist/structures/index.js +1 -0
  195. package/dist/terrain/GrassField.d.ts +11 -3
  196. package/dist/terrain/GrassField.js +16 -6
  197. package/dist/terrain/TerraformBrushCursor.js +3 -0
  198. package/dist/terrain/grassBudget.d.ts +11 -2
  199. package/dist/terrain/grassBudget.js +20 -4
  200. package/dist/terrain/grassGeometry.d.ts +35 -0
  201. package/dist/terrain/grassGeometry.js +85 -20
  202. package/dist/terrain/grassMaterial.d.ts +20 -0
  203. package/dist/terrain/grassMaterial.js +68 -13
  204. package/dist/terrain/heightfieldGeometry.d.ts +34 -0
  205. package/dist/terrain/heightfieldGeometry.js +109 -0
  206. package/dist/terrain/index.d.ts +1 -0
  207. package/dist/terrain/index.js +1 -0
  208. package/dist/terrain/random.d.ts +3 -0
  209. package/dist/terrain/random.js +3 -0
  210. package/dist/terrain/soilPatchMaterial.d.ts +23 -0
  211. package/dist/terrain/soilPatchMaterial.js +147 -0
  212. package/dist/terrain/terrainDetailMaterial.d.ts +19 -2
  213. package/dist/terrain/terrainDetailMaterial.js +87 -7
  214. package/dist/terrain/terrainMath.d.ts +8 -1
  215. package/dist/terrain/terrainMath.js +8 -1
  216. package/dist/touch/TouchControlsOverlay.d.ts +9 -5
  217. package/dist/touch/TouchControlsOverlay.js +201 -22
  218. package/dist/useShellMultiplayerSync.d.ts +9 -0
  219. package/dist/useShellMultiplayerSync.js +98 -0
  220. package/dist/visibility/CullingProvider.js +1 -1
  221. package/dist/water/Ocean.d.ts +7 -1
  222. package/dist/water/Ocean.js +16 -3
  223. package/dist/water/OceanConfig.d.ts +11 -0
  224. package/dist/water/OceanConfig.js +8 -0
  225. package/dist/water/OceanMaterial.d.ts +12 -0
  226. package/dist/water/OceanMaterial.js +9 -0
  227. package/dist/water/OceanShader.d.ts +2 -2
  228. package/dist/water/OceanShader.js +78 -10
  229. package/dist/weather/fireSpreadPose.d.ts +1 -0
  230. package/dist/weather/fireSpreadPose.js +1 -0
  231. package/dist/weather/weatherGeometry.d.ts +1 -0
  232. package/dist/weather/weatherGeometry.js +1 -0
  233. package/dist/weather/weatherMath.d.ts +3 -0
  234. package/dist/weather/weatherMath.js +3 -0
  235. package/dist/weather/weatherUniforms.d.ts +3 -0
  236. package/dist/weather/weatherUniforms.js +3 -0
  237. package/dist/world/PlaceScene.d.ts +11 -0
  238. package/dist/world/PlaceScene.js +27 -0
  239. package/dist/world/RetainedVfx.d.ts +10 -0
  240. package/dist/world/RetainedVfx.js +136 -0
  241. package/dist/world/WorldHud.d.ts +49 -2
  242. package/dist/world/WorldHud.js +87 -2
  243. package/dist/world/WorldScene.d.ts +21 -0
  244. package/dist/world/WorldScene.js +186 -0
  245. package/dist/world/WorldVfx.d.ts +9 -0
  246. package/dist/world/WorldVfx.js +184 -0
  247. package/dist/world/entityPose.d.ts +2 -0
  248. package/dist/world/entityPose.js +2 -0
  249. package/dist/world/floatTextStyle.d.ts +1 -0
  250. package/dist/world/floatTextStyle.js +1 -0
  251. package/dist/world/telegraphPulse.d.ts +1 -0
  252. package/dist/world/telegraphPulse.js +1 -0
  253. package/dist/world/worldBarSamples.d.ts +25 -0
  254. package/dist/world/worldBarSamples.js +38 -0
  255. package/dist/worldSky.d.ts +11 -0
  256. package/dist/worldSky.js +21 -0
  257. package/dist/worldSync.d.ts +2 -1
  258. package/dist/worldSync.js +2 -1
  259. package/package.json +6 -6
  260. package/skills/game-design/SKILL.md +28 -0
  261. package/skills/game-design/agents/openai.yaml +4 -0
  262. package/skills/game-design/references/application-playbook.md +170 -0
  263. package/skills/game-design/references/field-guide.md +288 -0
  264. package/skills/jgengine/SKILL.md +54 -0
  265. package/skills/jgengine/api.md +527 -0
  266. package/skills/jgengine/capabilities.md +131 -0
  267. package/skills/jgengine/recipes/minimal-game.md +88 -0
  268. package/skills/jgengine-ui/SKILL.md +41 -0
  269. package/skills/jgengine-ui/api.md +2007 -0
  270. package/skills/jgengine-ui/capabilities.md +211 -0
  271. package/skills/jgengine-ui/recipes/portable-minimap.md +150 -0
  272. package/skills/jgengine-ui/reference.md +513 -0
  273. package/skills/jgengine-ui/references/visual-scorecard.md +73 -0
  274. package/skills/jgengine-world/SKILL.md +51 -0
  275. package/skills/jgengine-world/api.md +3056 -0
  276. package/skills/jgengine-world/capabilities.md +476 -0
  277. package/skills/jgengine-world/recipes/commanding-entities.md +128 -0
  278. package/skills/jgengine-world/reference.md +261 -0
  279. package/skills/level-design/SKILL.md +54 -0
  280. package/skills/level-design/agents/openai.yaml +4 -0
  281. package/skills/level-design/references/application-playbook.md +192 -0
  282. package/skills/level-design/references/field-guide.md +337 -0
  283. package/skills/level-design/references/live-editor-loop.md +179 -0
  284. package/dist/cartridge.d.ts +0 -145
  285. package/dist/cartridge.js +0 -246
  286. package/llms.txt +0 -2761
@@ -5,4 +5,5 @@ export interface CameraShakeChannel {
5
5
  sample(config?: Parameters<typeof shakeOffset>[1]): ShakeOffset;
6
6
  trauma(): number;
7
7
  }
8
+ /** @internal */
8
9
  export declare function createCameraShakeChannel(defaultDecayPerSecond?: number): CameraShakeChannel;
@@ -1,4 +1,5 @@
1
1
  import { addTrauma, createTrauma, shakeOffset, stepTrauma } from "./rigMath.js";
2
+ /** @internal */
2
3
  export function createCameraShakeChannel(defaultDecayPerSecond = 1.6) {
3
4
  const state = createTrauma();
4
5
  let decay = defaultDecayPerSecond;
@@ -4,15 +4,20 @@ import type { LiveGameBackend } from "@jgengine/core/runtime/transport";
4
4
  export interface CommandSink {
5
5
  run(name: string, input: unknown): void;
6
6
  }
7
- /** Runs commands on the local `ctx` — the default, client-authoritative path. */
7
+ /** Runs commands on the local `ctx` — the default, client-authoritative path.
8
+ * @internal
9
+ */
8
10
  export declare function localCommandSink(ctx: GameContext): CommandSink;
9
- /** Sends commands to the authoritative host over the transport; the result replicates back through world sync. */
11
+ /** Sends commands to the authoritative host over the transport; the result replicates back through world sync.
12
+ * @internal
13
+ */
10
14
  export declare function remoteCommandSink(backend: Pick<LiveGameBackend, "transport">, serverId: string): CommandSink;
11
15
  /**
12
16
  * The sink a server-authoritative shell should dispatch gameplay commands through: remote when the game opts into
13
17
  * `authority: "server"` and a server is joined, local otherwise. Client-only UI commands (targeting, hotbar
14
18
  * scroll) keep calling `ctx.game.commands.run` directly — only authoritative gameplay verbs route to the host.
15
- */
19
+ * @internal
20
+ */
16
21
  export declare function resolveCommandSink(ctx: GameContext, opts: {
17
22
  serverAuthoritative: boolean;
18
23
  backend: Pick<LiveGameBackend, "transport"> | null;
@@ -1,4 +1,6 @@
1
- /** Runs commands on the local `ctx` — the default, client-authoritative path. */
1
+ /** Runs commands on the local `ctx` — the default, client-authoritative path.
2
+ * @internal
3
+ */
2
4
  export function localCommandSink(ctx) {
3
5
  return {
4
6
  run(name, input) {
@@ -6,7 +8,9 @@ export function localCommandSink(ctx) {
6
8
  },
7
9
  };
8
10
  }
9
- /** Sends commands to the authoritative host over the transport; the result replicates back through world sync. */
11
+ /** Sends commands to the authoritative host over the transport; the result replicates back through world sync.
12
+ * @internal
13
+ */
10
14
  export function remoteCommandSink(backend, serverId) {
11
15
  return {
12
16
  run(name, input) {
@@ -18,7 +22,8 @@ export function remoteCommandSink(backend, serverId) {
18
22
  * The sink a server-authoritative shell should dispatch gameplay commands through: remote when the game opts into
19
23
  * `authority: "server"` and a server is joined, local otherwise. Client-only UI commands (targeting, hotbar
20
24
  * scroll) keep calling `ctx.game.commands.run` directly — only authoritative gameplay verbs route to the host.
21
- */
25
+ * @internal
26
+ */
22
27
  export function resolveCommandSink(ctx, opts) {
23
28
  if (opts.serverAuthoritative && opts.backend !== null && opts.serverId !== null) {
24
29
  return remoteCommandSink(opts.backend, opts.serverId);
@@ -1,7 +1,8 @@
1
- import type { ComponentType } from "react";
1
+ import { type ComponentType } from "react";
2
2
  import { type GameDefinitionConfig, type GameLoop } from "@jgengine/core/game/defineGame";
3
3
  import type { GameContext, GameContextContent } from "@jgengine/core/runtime/gameContext";
4
4
  import type { ModelAssetRef } from "@jgengine/core/scene/assetCatalog";
5
+ import type { ModelConfig } from "@jgengine/core/game/playableGame";
5
6
  import type { PlayableGame } from "./registry.js";
6
7
  type EngineFields<TAssetRef extends ModelAssetRef> = Omit<GameDefinitionConfig<TAssetRef>, "loop" | "ui" | "multiplayer"> & {
7
8
  multiplayer?: GameDefinitionConfig<TAssetRef>["multiplayer"];
@@ -10,7 +11,20 @@ type PresentationFields = Omit<PlayableGame, "game" | "content" | "loop" | "Game
10
11
  content?: GameContextContent;
11
12
  loop?: Partial<GameLoop<GameContext>>;
12
13
  GameUI?: ComponentType;
14
+ /** Tunes how the auto-mounted `AuthoredScene` places the document's catalog-id markers into the object store. Default `true`; pass `false` when the game spawns its placed content as entities itself (`placeAuthoredObjects`) to avoid a double render. */
15
+ scenePlacement?: boolean | {
16
+ verticalOffset?: number;
17
+ };
18
+ /** GLB models for the auto-mounted scene's scatter palette items, keyed by palette item id; string ids resolve through the game's asset catalog. Unmatched items keep the built-in proxy meshes. */
19
+ sceneScatterModels?: Record<string, string | ModelConfig>;
13
20
  };
14
21
  export type GameConfig<TAssetRef extends ModelAssetRef = ModelAssetRef> = EngineFields<TAssetRef> & PresentationFields;
22
+ /**
23
+ * The one public authoring entry point: compose engine fields (systems, world, physics, input) and
24
+ * presentation fields (camera, HUD, audio, authored scene) into a `PlayableGame` ready for `GameHost`.
25
+ * Defaults to solo/offline multiplayer; `editorLayers` auto-mounts the authored scene document.
26
+ *
27
+ * @capability define-game single public game-authoring path — compose systems, world, presentation, and authored scene in one definition
28
+ */
15
29
  export declare function defineGame<TAssetRef extends ModelAssetRef = ModelAssetRef>(config: GameConfig<TAssetRef>): PlayableGame;
16
30
  export {};
@@ -1,31 +1,67 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { defineGame as defineEngineGame, } from "@jgengine/core/game/defineGame";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { defineGameDefinition as defineEngineGame, } from "@jgengine/core/game/defineGame";
4
+ import { syncLifecyclePhase } from "@jgengine/core/game/gamePhase";
3
5
  import { offline } from "@jgengine/core/runtime/adapter";
4
6
  import { EnvironmentScene } from "./environment.js";
7
+ import { terrainGroundColorSampler } from "./environment/terrainGroundColor.js";
8
+ import { AuthoredScene } from "./scene/AuthoredScene.js";
5
9
  const noop = () => { };
6
10
  function worldBackdrop(feature) {
7
11
  return function WorldBackdrop() {
8
12
  return _jsx(EnvironmentScene, { feature: feature });
9
13
  };
10
14
  }
15
+ function authoredSceneOverlay(document, placement, scatterModels, assets, world, Vfx) {
16
+ const terrain = world !== undefined && world.kind === "environment" ? world.terrain : undefined;
17
+ return function AuthoredSceneOverlay(props) {
18
+ const groundColorAt = useMemo(() => terrainGroundColorSampler(terrain, props.ctx.world.ground), [props.ctx.world.ground]);
19
+ return (_jsxs(_Fragment, { children: [_jsx(AuthoredScene, { document: document, field: props.ctx.world.ground, placeObjects: placement, ...(scatterModels === undefined ? {} : { scatterModels, assets }), ...(groundColorAt === undefined ? {} : { groundColorAt }) }), Vfx === undefined ? null : _jsx(Vfx, { ...props })] }));
20
+ };
21
+ }
11
22
  const emptyUi = () => null;
23
+ /**
24
+ * The one public authoring entry point: compose engine fields (systems, world, physics, input) and
25
+ * presentation fields (camera, HUD, audio, authored scene) into a `PlayableGame` ready for `GameHost`.
26
+ * Defaults to solo/offline multiplayer; `editorLayers` auto-mounts the authored scene document.
27
+ *
28
+ * @capability define-game single public game-authoring path — compose systems, world, presentation, and authored scene in one definition
29
+ */
12
30
  export function defineGame(config) {
13
- const { content, loop, GameUI, environment, camera, multiplayer, WorldOverlay, renderEntity, renderObject, entitySprites, entityModels, objectModels, hotbarSelection, prompts, pointer, touch, orientation, worldHealthBars, audio, entitySounds, objectSounds, worldItem, collision, movement, lighting, backdrop, postProcessing, shadows, presentation, objectStyles, devtools, ...engineFields } = config;
14
- const game = defineEngineGame({ ...engineFields, multiplayer: multiplayer ?? offline() });
31
+ const { content, loop, GameUI, environment, camera, multiplayer, editorLayers, editorCatalogs, scenePlacement, sceneScatterModels, WorldOverlay, viewmodel, renderEntity, renderObject, entitySprites, entityModels, objectModels, hotbarSelection, prompts, pointer, touch, orientation, worldHealthBars, nameplates, presentationEffects, audio, entitySounds, objectSounds, worldItem, collision, movement, lighting, backdrop, postProcessing, shadows, presentation, objectStyles, devtools, capture, platforms, hudFit, ...engineFields } = config;
32
+ const game = defineEngineGame({
33
+ ...engineFields,
34
+ multiplayer: multiplayer ?? offline(),
35
+ loop,
36
+ });
37
+ function withPhaseSync(inner) {
38
+ return (ctx, ...args) => {
39
+ inner?.(ctx, ...args);
40
+ syncLifecyclePhase(ctx, game.lifecycle);
41
+ };
42
+ }
43
+ const composed = game.loop;
15
44
  return {
16
45
  game,
17
46
  content: content ?? {},
18
47
  loop: {
19
- onInit: loop?.onInit ?? noop,
20
- onNewPlayer: loop?.onNewPlayer ?? noop,
21
- onTick: loop?.onTick ?? noop,
22
- onPlayerLeave: loop?.onPlayerLeave ?? noop,
48
+ onInit: withPhaseSync(composed?.onInit),
49
+ onNewPlayer: withPhaseSync(composed?.onNewPlayer),
50
+ onTick: withPhaseSync(composed?.onTick),
51
+ onPlayerLeave: composed?.onPlayerLeave ?? noop,
52
+ onReset: composed?.onReset?.bind(composed) ?? noop,
53
+ onDispose: composed?.onDispose?.bind(composed) ?? noop,
23
54
  },
24
55
  GameUI: GameUI ?? emptyUi,
25
56
  environment: environment ??
26
57
  (game.world?.kind === "environment" ? worldBackdrop(game.world) : undefined),
27
58
  camera: camera ?? { perspective: "third" },
28
- WorldOverlay,
59
+ editorLayers,
60
+ editorCatalogs,
61
+ WorldOverlay: editorLayers === undefined
62
+ ? WorldOverlay
63
+ : authoredSceneOverlay(editorLayers, scenePlacement ?? true, sceneScatterModels, game.assets, game.world, WorldOverlay),
64
+ viewmodel,
29
65
  renderEntity,
30
66
  renderObject,
31
67
  entitySprites,
@@ -37,6 +73,8 @@ export function defineGame(config) {
37
73
  touch,
38
74
  orientation,
39
75
  worldHealthBars,
76
+ nameplates,
77
+ presentationEffects,
40
78
  audio,
41
79
  entitySounds,
42
80
  objectSounds,
@@ -50,5 +88,8 @@ export function defineGame(config) {
50
88
  presentation,
51
89
  objectStyles,
52
90
  devtools,
91
+ capture,
92
+ platforms,
93
+ hudFit,
53
94
  };
54
95
  }
@@ -0,0 +1 @@
1
+ export declare function ColPanel(): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSyncExternalStore } from "react";
3
+ import { COLLISION_DEBUG_LAYERS, collisionDebug } from "./collisionDebug.js";
4
+ const LAYER_LABELS = {
5
+ hitboxes: "Damage hitboxes",
6
+ bodies: "Physical bodies",
7
+ projectiles: "Projectile paths",
8
+ muzzles: "Muzzle / shot origins",
9
+ aimLaser: "Aim laser (authoritative)",
10
+ };
11
+ export function ColPanel() {
12
+ const state = useSyncExternalStore(collisionDebug.subscribe, () => collisionDebug.getState(), () => collisionDebug.getState());
13
+ return (_jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "text-[10px] text-neutral-500", children: "F2+D world collision debugger \u00B7 layers stay on when panel closes \u00B7 zero cost when all off" }), _jsxs("div", { className: "flex gap-1", children: [_jsx("button", { type: "button", className: "rounded-md bg-white/[0.04] px-2 py-0.5 text-neutral-300 ring-1 ring-inset ring-white/[0.08] transition-colors hover:bg-white/10", onClick: () => collisionDebug.setAllLayers(true), children: "All on" }), _jsx("button", { type: "button", className: "rounded-md bg-white/[0.04] px-2 py-0.5 text-neutral-300 ring-1 ring-inset ring-white/[0.08] transition-colors hover:bg-white/10", onClick: () => collisionDebug.setAllLayers(false), children: "All off" })] }), _jsx("div", { className: "space-y-1", children: COLLISION_DEBUG_LAYERS.map((layer) => (_jsxs("label", { className: "flex cursor-pointer items-center gap-2 text-neutral-200", children: [_jsx("input", { type: "checkbox", checked: state.layers[layer], onChange: (event) => collisionDebug.setLayer(layer, event.target.checked) }), _jsx("span", { children: LAYER_LABELS[layer] })] }, layer))) }), _jsx("div", { className: "border-t border-neutral-800 pt-1.5 font-mono text-[9px] text-neutral-500", children: "hitbox pink \u00B7 body cyan \u00B7 muzzle red \u00B7 laser lime \u00B7 X damage \u00B7 \u25CB solid \u00B7 \u00B7 miss" })] }));
14
+ }
@@ -1,11 +1,13 @@
1
- import { type DevtoolsOverrides, type DevtoolsSnapshot } from "@jgengine/core/devtools/devtools";
1
+ import { type DevtoolsSnapshot } from "@jgengine/core/devtools/devtools";
2
2
  import type { GameContext } from "@jgengine/core/runtime/gameContext";
3
3
  import type { ShellMultiplayer } from "../multiplayer.js";
4
4
  import type { PlayableGame } from "../registry.js";
5
- export declare function persistDevtoolsOverrides(gameName: string): DevtoolsOverrides;
6
- export declare function applyStoredDevtoolsOverrides(gameName: string): void;
5
+ export { applyStoredDevtoolsOverrides, persistDevtoolsOverrides } from "./devtoolsOverrides.js";
6
+ /** @internal */
7
7
  export declare function withDevtoolsLatency(multiplayer: ShellMultiplayer): ShellMultiplayer;
8
+ /** @internal */
8
9
  export declare function DevtoolsRendererProbe(): null;
10
+ /** @internal */
9
11
  export declare function buildLeanReport(playable: PlayableGame): {
10
12
  game: string;
11
13
  at: number;
@@ -28,8 +30,8 @@ export declare function buildLeanReport(playable: PlayableGame): {
28
30
  pctOfSim: number;
29
31
  }[];
30
32
  } | null;
31
- render: import("@jgengine/core/devtools/devtools").RenderSample | null;
32
- latency: import("@jgengine/core/devtools/devtools").LatencyStats | null;
33
+ render: import("@jgengine/core/devtools/types").RenderSample | null;
34
+ latency: import("@jgengine/core/devtools/types").LatencyStats | null;
33
35
  longFrameSummary: {
34
36
  count: number;
35
37
  culprits: {
@@ -52,10 +54,10 @@ export declare function buildLeanReport(playable: PlayableGame): {
52
54
  ms: number;
53
55
  }[];
54
56
  probes: Record<string, unknown>;
55
- render: import("@jgengine/core/devtools/devtools").RenderSample | null;
57
+ render: import("@jgengine/core/devtools/types").RenderSample | null;
56
58
  }[];
57
59
  probes: Record<string, unknown>;
58
- logs: import("@jgengine/core/devtools/devtools").DevtoolsLogEntry[] | undefined;
60
+ logs: import("@jgengine/core/devtools/types").DevtoolsLogEntry[] | undefined;
59
61
  controls: {
60
62
  name: string;
61
63
  value: unknown;
@@ -67,9 +69,11 @@ export declare function buildLeanReport(playable: PlayableGame): {
67
69
  }[] | undefined;
68
70
  discoveredCount: number;
69
71
  };
72
+ /** @internal */
70
73
  export declare function buildFullReport(playable: PlayableGame): DevtoolsSnapshot & {
71
74
  game: string;
72
75
  };
76
+ /** @internal */
73
77
  export declare function DevtoolsOverlay({ open, ctx, playable, multiplayer, }: {
74
78
  open: boolean;
75
79
  ctx: GameContext;