Skip to content

Commit b592255

Browse files
author
DavidQ
committed
feat(samples2tools): add Physics Sandbox presets and standardize sample preload status
- add Physics Sandbox roundtrip integration for samples `0303` and `1606` with canonical preset files - wire samples metadata + routing + roadmap/report updates for the new physics slice - standardize all integrated tools to show `Loaded preset from sample <id>.` - prevent Parallax sample-manifest boot refresh from overwriting preset-loaded status
1 parent 410f4e1 commit b592255

13 files changed

Lines changed: 244 additions & 11 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Samples2Tools Batch 7 Summary
2+
Generated: 2026-04-24T14:30:04.422Z
3+
Scope: phase-01 through phase-19 Phase 2 coverage check for Physics Sandbox
4+
5+
Physics Sandbox mapped samples: 2
6+
- Phase 03 Sample 0303 | Physics System | preset: /samples/phase-03/0303/sample-0303-physics-sandbox.json
7+
- Phase 16 Sample 1606 | 3D Physics Playground | preset: /samples/phase-16/1606/sample-1606-physics-sandbox.json
8+
9+
Overall: pass
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Samples2Tools Batch 7 Validation
2+
Generated: 2026-04-24T14:30:04.422Z
3+
4+
[x] Physics Sandbox has exactly 2 mapped samples (phase-01 through phase-19)
5+
[x] Mapped Physics Sandbox preset files exist on disk
6+
[x] Samples index roundtrip logic contains mapped sample ids and tool branch
7+
[x] Physics Sandbox supports samplePresetPath preload and sets loaded preset status
8+
9+
Execution evidence:
10+
- Physics Sandbox has exactly 2 mapped samples (phase-01 through phase-19): metadata sampleIds=0303,1606
11+
- Mapped Physics Sandbox preset files exist on disk: /samples/phase-03/0303/sample-0303-physics-sandbox.json; /samples/phase-16/1606/sample-1606-physics-sandbox.json
12+
- Samples index roundtrip logic contains mapped sample ids and tool branch: samples/index.render.js:shouldUsePresetRoundtrip
13+
- Physics Sandbox supports samplePresetPath preload and sets loaded preset status: tools/Physics Sandbox/main.js:tryLoadPresetFromQuery
14+
- overall: pass
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"generatedAt": "2026-04-24T14:30:04.422Z",
3+
"scope": "phase-01-phase-19",
4+
"purpose": "batch-7-physics-sandbox",
5+
"links": [
6+
{
7+
"toolId": "physics-sandbox",
8+
"sampleId": "0303",
9+
"phase": "03",
10+
"title": "Physics System",
11+
"href": "./phase-03/0303/index.html",
12+
"presetPath": "/samples/phase-03/0303/sample-0303-physics-sandbox.json"
13+
},
14+
{
15+
"toolId": "physics-sandbox",
16+
"sampleId": "1606",
17+
"phase": "16",
18+
"title": "3D Physics Playground",
19+
"href": "./phase-16/1606/index.html",
20+
"presetPath": "/samples/phase-16/1606/sample-1606-physics-sandbox.json"
21+
}
22+
]
23+
}

docs/dev/roadmaps/MASTER_ROADMAP_SAMPLES2TOOLS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
### Phase 2 - Highest Value Tools (from tools_used.txt)
9292
- [x] Parallax Scene Studio (4 candidate samples)
9393
- [x] Performance Profiler (2 candidate samples)
94-
- [ ] Physics Sandbox (2 candidate samples)
94+
- [x] Physics Sandbox (2 candidate samples)
9595
- [ ] Replay Visualizer (3 candidate samples)
9696
- [x] Vector Asset Studio (1 candidate sample)
9797
- [ ] Vector Map Editor (1 candidate sample)
@@ -154,6 +154,6 @@
154154
- [x] `docs/dev/reports/samples2tools_link_map_<n>.json`
155155

156156
## Current Snapshot (from tools_used.txt)
157-
- [x] Current tagged samples across active tools: `11` (phase-01 through phase-19)
157+
- [x] Current tagged samples across active tools: `13` (phase-01 through phase-19)
158158
- [x] Candidate coverage inventory exists for all active tools
159159
- [.] Convert candidates into curated, validated sample-to-tool links

samples/index.render.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ function shouldUsePresetRoundtrip(sample, toolId) {
6262
return (sampleId === "0512" && samplePhase === "05")
6363
|| (sampleId === "1407" && samplePhase === "14");
6464
}
65+
if (toolId === "physics-sandbox") {
66+
return (sampleId === "0303" && samplePhase === "03")
67+
|| (sampleId === "1606" && samplePhase === "16");
68+
}
6569
return false;
6670
}
6771

samples/metadata/samples.index.metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,9 @@
21812181
"engine/theme/index/ThemeTokens",
21822182
"engine/tilemap/index/renderTilemap",
21832183
"engine/tilemap/index/Tilemap"
2184+
],
2185+
"toolHints": [
2186+
"physics-sandbox"
21842187
]
21852188
},
21862189
{
@@ -8054,6 +8057,9 @@
80548057
"engine/scene/index/Scene",
80558058
"engine/theme/index/Theme",
80568059
"engine/theme/index/ThemeTokens"
8060+
],
8061+
"toolHints": [
8062+
"physics-sandbox"
80578063
]
80588064
},
80598065
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"sampleId": "0303",
3+
"phase": "03",
4+
"title": "Physics System",
5+
"description": "Shared sample preset for Sample 0303 and Physics Sandbox preload.",
6+
"toolHints": [
7+
"physics-sandbox"
8+
],
9+
"payload": {
10+
"physicsBody": {
11+
"x": 0,
12+
"y": 0,
13+
"velocityX": 120,
14+
"velocityY": -20,
15+
"accelerationX": -8,
16+
"accelerationY": 18,
17+
"dragX": 10,
18+
"dragY": 4,
19+
"maxSpeedX": 160,
20+
"maxSpeedY": 160,
21+
"dt": 0.0166666667
22+
}
23+
},
24+
"runtime": {
25+
"sampleEntryPoint": "/samples/phase-03/0303/index.html"
26+
},
27+
"toolState": {
28+
"preferredToolId": "physics-sandbox"
29+
},
30+
"provenance": {
31+
"path": "/samples/phase-03/0303/sample-0303-physics-sandbox.json",
32+
"createdAt": "2026-04-24T00:00:00.000Z",
33+
"version": 1
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"sampleId": "1606",
3+
"phase": "16",
4+
"title": "3D Physics Playground",
5+
"description": "Shared sample preset for Sample 1606 and Physics Sandbox preload.",
6+
"toolHints": [
7+
"physics-sandbox"
8+
],
9+
"payload": {
10+
"physicsBody": {
11+
"x": 12,
12+
"y": 48,
13+
"velocityX": 0,
14+
"velocityY": -140,
15+
"accelerationX": 0,
16+
"accelerationY": 38,
17+
"dragX": 2,
18+
"dragY": 1,
19+
"maxSpeedX": 240,
20+
"maxSpeedY": 260,
21+
"dt": 0.0166666667
22+
}
23+
},
24+
"runtime": {
25+
"sampleEntryPoint": "/samples/phase-16/1606/index.html"
26+
},
27+
"toolState": {
28+
"preferredToolId": "physics-sandbox"
29+
},
30+
"provenance": {
31+
"path": "/samples/phase-16/1606/sample-1606-physics-sandbox.json",
32+
"createdAt": "2026-04-24T00:00:00.000Z",
33+
"version": 1
34+
}
35+
}

tools/Parallax Scene Studio/main.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ function normalizeSamplePresetPath(pathValue) {
5858
return "";
5959
}
6060

61+
function buildPresetLoadedStatus(sampleId, samplePresetPath) {
62+
const normalizedSampleId = typeof sampleId === "string" ? sampleId.trim() : "";
63+
if (normalizedSampleId) {
64+
return `Loaded preset from sample ${normalizedSampleId}.`;
65+
}
66+
const normalizedPath = typeof samplePresetPath === "string" ? samplePresetPath.trim() : "";
67+
return normalizedPath ? `Loaded preset from ${normalizedPath}.` : "Loaded preset.";
68+
}
69+
6170
function clamp(value, min, max, fallback) {
6271
const number = Number(value);
6372
if (!Number.isFinite(number)) {
@@ -451,7 +460,8 @@ class ParallaxEditorApp {
451460
this.renderAll();
452461
this.bindRuntimeStateSync();
453462
this.queueLivePreviewSync("init");
454-
this.loadSampleManifest();
463+
const hasSamplePresetQuery = new URLSearchParams(window.location.search).has("samplePresetPath");
464+
this.loadSampleManifest({ quiet: hasSamplePresetQuery });
455465
void this.tryLoadPresetFromQuery();
456466
}
457467

@@ -1167,8 +1177,7 @@ class ParallaxEditorApp {
11671177
this.skipExternalProjectStateUntil = Date.now() + 3000;
11681178
this.applyParallaxDocument(extractParallaxDocument(toolDocument));
11691179
this.queueLivePreviewSync("sample-preset");
1170-
const sourceLabel = sampleId ? `sample ${sampleId}` : samplePresetPath;
1171-
this.updateStatus(`Loaded preset from ${sourceLabel}.`);
1180+
this.updateStatus(buildPresetLoadedStatus(sampleId, samplePresetPath));
11721181
} catch (error) {
11731182
this.updateStatus(`Preset load failed: ${error instanceof Error ? error.message : "unknown error"}`);
11741183
}

tools/Performance Profiler/main.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ function normalizeSamplePresetPath(pathValue) {
4646
return "";
4747
}
4848

49+
function buildPresetLoadedStatus(sampleId, samplePresetPath) {
50+
const normalizedSampleId = typeof sampleId === "string" ? sampleId.trim() : "";
51+
if (normalizedSampleId) {
52+
return `Loaded preset from sample ${normalizedSampleId}.`;
53+
}
54+
const normalizedPath = typeof samplePresetPath === "string" ? samplePresetPath.trim() : "";
55+
return normalizedPath ? `Loaded preset from ${normalizedPath}.` : "Loaded preset.";
56+
}
57+
4958
function setStatus(message) {
5059
if (refs.statusText instanceof HTMLElement) {
5160
refs.statusText.textContent = message;
@@ -234,8 +243,7 @@ async function tryLoadPresetFromQuery() {
234243
throw new Error("Preset payload did not include profileSettings.");
235244
}
236245
performanceProfilerApi.applyProjectState(presetSettings);
237-
const sourceLabel = sampleId ? `sample ${sampleId}` : samplePresetPath;
238-
setStatus(`Loaded preset from ${sourceLabel}.`);
246+
setStatus(buildPresetLoadedStatus(sampleId, samplePresetPath));
239247
} catch (error) {
240248
setStatus(`Preset load failed: ${error instanceof Error ? error.message : "unknown error"}`);
241249
}

0 commit comments

Comments
 (0)