create-aura3d 1.0.5 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aura3d",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "create-aura3d": "dist/cli.js"
@@ -82,7 +82,7 @@ export function createFighterAnimationController(
82
82
  ): AnimationController<FighterClip> {
83
83
  return new AnimationController<FighterClip>({
84
84
  id: `${id}-animation-controller`,
85
- ...(asset ? { clipRegistry: asset } : {}),
85
+ ...(asset ? { clipRegistry: animationClipRegistry(asset) } : {}),
86
86
  clips: fighterAnimationClips,
87
87
  requiredClips: REQUIRED_FIGHTER_CLIPS,
88
88
  suppressRootMotion: true,
@@ -93,6 +93,17 @@ export function createFighterAnimationController(
93
93
  });
94
94
  }
95
95
 
96
+ function animationClipRegistry(asset: AuraAssetRef<"model">) {
97
+ const metadata: Record<string, unknown> = { ...(asset.metadata ?? {}) };
98
+ return {
99
+ id: asset.id,
100
+ name: asset.id,
101
+ url: asset.url,
102
+ hash: asset.hash,
103
+ metadata
104
+ };
105
+ }
106
+
96
107
  export function createFighterNode(
97
108
  id: FighterId,
98
109
  assetKey: FighterAssetKey,
@@ -1,4 +1,4 @@
1
- import { camera, createAuraApp, effects, game, lights, scene, ui } from "@aura3d/engine";
1
+ import { camera, createGameApp, effects, game, lights, scene, ui } from "@aura3d/engine";
2
2
  import { assets } from "./aura-assets";
3
3
  import {
4
4
  animationLayer,
@@ -25,6 +25,7 @@ import "./styles.css";
25
25
  type Aura3DGameWindow = Window & {
26
26
  __AURA3D_GAME_DEBUG__?: unknown;
27
27
  __AURA3D_GAME_EVIDENCE__?: unknown;
28
+ __AURA3D_GAME_RUNTIME__?: unknown;
28
29
  __AURA3D_GAME_REPLAY__?: unknown;
29
30
  __AURA3D_GAME_SOURCE__?: unknown;
30
31
  };
@@ -112,6 +113,18 @@ const accessibilitySources = [
112
113
  })
113
114
  ];
114
115
 
116
+ const inputOptions = {
117
+ actions: {
118
+ ...fightingControls.actions,
119
+ guard: ["KeyQ", "GamepadLB"],
120
+ heavy: ["KeyK", "GamepadY"],
121
+ pause: ["Escape", "GamepadStart"]
122
+ },
123
+ axes: fightingControls.axes,
124
+ bufferMs: 150,
125
+ gamepad: true
126
+ } as const;
127
+
115
128
  const arena = scene()
116
129
  .background("#10071c")
117
130
  .addMany(fightingStage.nodes)
@@ -120,29 +133,20 @@ const arena = scene()
120
133
  .addMany([
121
134
  effects.bloom({ intensity: 0.32 }),
122
135
  lights.studio({ intensity: 1.15 }),
123
- lights.directional({ name: "rim light", color: "#80ffd4", intensity: 0.7 }).position(0, 4, 3),
124
- camera
125
- .perspective({ position: [0, 1.75, 5.8], target: [0, 0.85, 0], fov: 42 })
126
- ]);
136
+ lights.directional({ name: "rim light", color: "#80ffd4", intensity: 0.7 }).position(0, 4, 3)
137
+ ])
138
+ .camera(camera.perspective({ position: [0, 1.75, 5.8], target: [0, 0.85, 0], fov: 42 }));
127
139
 
128
- const app = createAuraApp("#app", {
140
+ const gameApp = createGameApp("#app", {
129
141
  diagnostics: { overlay: true, performancePanel: true },
142
+ input: inputOptions,
143
+ loop: { fixedDt: 1 / 60 },
130
144
  scene: arena
131
145
  });
132
146
 
133
- const inputOptions = {
134
- actions: {
135
- ...fightingControls.actions,
136
- guard: ["KeyQ", "GamepadLB"],
137
- heavy: ["KeyK", "GamepadY"],
138
- pause: ["Escape", "GamepadStart"]
139
- },
140
- axes: fightingControls.axes,
141
- bufferMs: 150,
142
- gamepad: true
143
- } as const;
144
-
145
- const input = app.input(inputOptions);
147
+ const app = gameApp.app;
148
+ const input = gameApp.input;
149
+ if (!input) throw new Error("create-aura3d fighting-game template failed to create runtime-owned input.");
146
150
  const replayInput = game.input({ ...inputOptions, autoListen: false, gamepad: false });
147
151
  const openingReplay = game.inputReplay(
148
152
  [
@@ -196,6 +200,11 @@ gameWindow.__AURA3D_GAME_SOURCE__ = {
196
200
  template: "fighting-game",
197
201
  package: "create-aura3d",
198
202
  publicEngineApi: true,
203
+ lifecycle: {
204
+ kind: gameApp.kind,
205
+ usesCreateGameApp: true,
206
+ runtimeEvidenceGlobal: "__AURA3D_GAME_RUNTIME__"
207
+ },
199
208
  typedAssetPattern: "src/aura-assets.ts",
200
209
  typedAssetKeys: REQUIRED_FIGHTER_ASSETS,
201
210
  missingAssets: missingFighterAssets,
@@ -223,7 +232,7 @@ ui.onClick(replayButton, () => {
223
232
 
224
233
  ui.onClick(pauseButton, () => setPaused(!paused));
225
234
 
226
- app.onFrame(({ dt }) => {
235
+ gameApp.onFrame(({ dt }) => {
227
236
  const activeInput = replayActive ? replayInput : input;
228
237
  if (replayActive) {
229
238
  replayDriver.step(dt);
@@ -360,6 +369,7 @@ app.onFrame(({ dt }) => {
360
369
  totalHitCount,
361
370
  liveInputEvents: input.recorded()
362
371
  };
372
+ gameWindow.__AURA3D_GAME_RUNTIME__ = gameApp.evidence;
363
373
  gameWindow.__AURA3D_GAME_DEBUG__ = game.debug.overlay({
364
374
  runtime: app.runtime,
365
375
  input: activeInput,
@@ -397,8 +407,8 @@ function setPaused(next: boolean): void {
397
407
  paused = next;
398
408
  ui.setPressed(pauseButton, paused);
399
409
  ui.setText(pauseButton, paused ? "Resume" : "Pause");
400
- if (paused) app.pause();
401
- else app.resume();
410
+ if (paused) gameApp.pause();
411
+ else gameApp.resume();
402
412
  }
403
413
 
404
414
  function syncFighterAnimation(controller: ReturnType<typeof createFighterAnimationController>, clip: FighterClip, dt: number): void {
@@ -4,11 +4,23 @@ test("input replay produces runtime evidence and a hit declaration", async ({ pa
4
4
  await page.goto("/");
5
5
  await page.click("#hud-replay-button");
6
6
  await page.waitForFunction(() => Boolean((window as any).__AURA3D_GAME_EVIDENCE__?.systems?.inputPlan));
7
+ await page.waitForFunction(() => Boolean((window as any).__AURA3D_GAME_RUNTIME__?.kind === "aura-game-app-runtime-evidence"));
7
8
  await page.waitForFunction(() => ((window as any).__AURA3D_GAME_REPLAY__?.hitCount ?? 0) > 0);
8
9
  const evidence = await page.evaluate(() => (window as any).__AURA3D_GAME_EVIDENCE__);
10
+ const runtime = await page.evaluate(() => (window as any).__AURA3D_GAME_RUNTIME__);
9
11
  const replay = await page.evaluate(() => (window as any).__AURA3D_GAME_REPLAY__);
10
12
  const source = await page.evaluate(() => (window as any).__AURA3D_GAME_SOURCE__);
11
13
 
14
+ expect(runtime).toMatchObject({
15
+ status: "running",
16
+ running: true,
17
+ started: true,
18
+ startCount: 1,
19
+ inputControllers: 1,
20
+ activeInputControllers: 1
21
+ });
22
+ expect(runtime.frame).toBeGreaterThan(0);
23
+ expect(runtime.loop.frame).toBeGreaterThan(0);
12
24
  expect(evidence.systems.mutableNodes).toBeTruthy();
13
25
  expect(evidence.systems.inputPlan).toBeTruthy();
14
26
  expect(evidence.systems.physicsPlan).toBeTruthy();
@@ -7,5 +7,10 @@ test("fighting-game route loads", async ({ page }) => {
7
7
  await page.waitForFunction(() => Boolean((window as any).__AURA3D_GAME_SOURCE__?.readiness));
8
8
  const source = await page.evaluate(() => (window as any).__AURA3D_GAME_SOURCE__);
9
9
  expect(source.readiness.route).toBe("/");
10
+ expect(source.lifecycle).toMatchObject({
11
+ kind: "aura-game-app-runtime",
12
+ usesCreateGameApp: true,
13
+ runtimeEvidenceGlobal: "__AURA3D_GAME_RUNTIME__"
14
+ });
10
15
  expect(source.readiness.buildDeclarations.routeHealthSpec).toBe("tests/route-health.spec.ts");
11
16
  });