@tora-editor/tora 0.2.0 → 0.3.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.
- package/README.md +5 -6
- package/bin/tora.mjs +255 -29
- package/crates/packer/trusted/native-3d-meta.json +3 -3
- package/crates/packer/trusted/native-3d.js +180 -180
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +3 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -106
- package/docs/TORA_CREATION_API.md +63 -365
- package/docs/reference/CORE_AUTHORING.md +8 -2
- package/docs/reference/PLAYABLE_STARTERS.md +1 -1
- package/docs/reference/packs/3d.md +2 -0
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +108 -1
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +246 -68
- package/scripts/lean/editor/review-editor.js +1731 -1099
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +35 -58
- package/scripts/lean/native/api.mjs +148 -134
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +36 -5
- package/scripts/lean/native/contracts.mjs +8 -6
- package/scripts/lean/native/creative-qa.mjs +66 -12
- package/scripts/lean/native/demos.mjs +11 -20
- package/scripts/lean/native/document.mjs +14 -2
- package/scripts/lean/native/local-bundle.mjs +4 -2
- package/scripts/lean/native/mcp-server.mjs +16 -35
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/project-bundle.mjs +3 -2
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/review.mjs +203 -572
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +1 -1
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +242 -70
- package/scripts/lean/native/starters.mjs +135 -8
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +1 -1
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -143
- package/scripts/lean/native/author-fps.mjs +0 -545
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -875
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -190
- package/scripts/lean/native/check-salvage.mjs +0 -200
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/glb-loader.mjs +0 -468
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -218
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-fps-assets.mjs +0 -330
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1809
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -1121
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import {execFileSync} from 'node:child_process';
|
|
2
|
-
import {createHash} from 'node:crypto';
|
|
3
|
-
import {mkdir, mkdtemp, readFile, rm, writeFile} from 'node:fs/promises';
|
|
4
|
-
import {resolve} from 'node:path';
|
|
5
|
-
import {Buffer} from 'node:buffer';
|
|
6
|
-
import process from 'node:process';
|
|
7
|
-
import {analyzeAudio} from './audio-analysis.mjs';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Prepare verified CC0 3D (.glb), 2D (.png), and compressed MP3 audio assets for
|
|
11
|
-
* Sky Blaster 3D (Tora website FPS demo):
|
|
12
|
-
* - 3D Models: KenneyNL/Starter-Kit-FPS (CC0-1.0)
|
|
13
|
-
* - 2D Sci-Fi UI & Icons: Kenney UI Pack Sci-Fi + Game Icons + Starter-Kit-FPS muzzle burst (CC0-1.0)
|
|
14
|
-
* - Audio: Juhani Junkala (SubspaceAudio) "5 Chiptunes (Action)" + Kenney Sci-Fi Sounds (CC0-1.0)
|
|
15
|
-
* Zero asset, audio pack, or UI template reuse with any other Tora showcase demo.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const root = resolve(import.meta.dirname, '../../..');
|
|
19
|
-
const tmpPacks = '/tmp/tora-fps-revamp';
|
|
20
|
-
const outRoot = resolve(root, 'assets/tora-fps');
|
|
21
|
-
const playableBin = resolve(root, 'target/debug/playable');
|
|
22
|
-
const sha256 = bytes => 'sha256:' + createHash('sha256').update(bytes).digest('hex');
|
|
23
|
-
const RATE = 22050;
|
|
24
|
-
|
|
25
|
-
function unzipEntry(zipPath, entryPath) {
|
|
26
|
-
return execFileSync('unzip', ['-p', zipPath, entryPath], {maxBuffer: 40 * 1024 * 1024});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function decodeToPcmFloat(filePath) {
|
|
30
|
-
const raw = execFileSync(
|
|
31
|
-
'gst-launch-1.0',
|
|
32
|
-
['-q', 'filesrc', `location=${filePath}`, '!', 'decodebin', '!', 'audioconvert', '!', 'audioresample', '!', `audio/x-raw,channels=1,rate=${RATE},format=S16LE`, '!', 'fdsink', 'fd=1'],
|
|
33
|
-
{maxBuffer: 40 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe']},
|
|
34
|
-
);
|
|
35
|
-
const samples = new Float64Array(raw.length / 2);
|
|
36
|
-
for (let i = 0; i < samples.length; i++) samples[i] = raw.readInt16LE(i * 2) / 32768;
|
|
37
|
-
return samples;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function trimSilence(samples, threshold = 0.004, padSamples = Math.round(RATE * 0.012)) {
|
|
41
|
-
let first = 0, last = samples.length - 1;
|
|
42
|
-
while (first < samples.length && Math.abs(samples[first]) < threshold) first++;
|
|
43
|
-
while (last > first && Math.abs(samples[last]) < threshold) last--;
|
|
44
|
-
first = Math.max(0, first - padSamples);
|
|
45
|
-
last = Math.min(samples.length - 1, last + padSamples);
|
|
46
|
-
return samples.subarray(first, last + 1);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function masterPcm(samples, {startSec = 0, maxDurationSec, fadeInSec, fadeOutSec, fadeSec = 0.012, ceiling = 0.78, loopFadeSec = 0} = {}) {
|
|
50
|
-
const startIdx = Math.max(0, Math.floor(startSec * RATE));
|
|
51
|
-
let data = startIdx > 0 ? samples.subarray(startIdx) : samples;
|
|
52
|
-
if (maxDurationSec && data.length > Math.ceil(maxDurationSec * RATE)) {
|
|
53
|
-
data = data.subarray(0, Math.ceil(maxDurationSec * RATE));
|
|
54
|
-
}
|
|
55
|
-
let peak = 0;
|
|
56
|
-
for (let i = 0; i < data.length; i++) peak = Math.max(peak, Math.abs(data[i]));
|
|
57
|
-
const gain = peak > 0 ? Math.min(4.0, ceiling / peak) : 1;
|
|
58
|
-
const fadeIn = Math.round(RATE * (loopFadeSec || fadeInSec || fadeSec));
|
|
59
|
-
const fadeOut = Math.round(RATE * (loopFadeSec || fadeOutSec || fadeSec));
|
|
60
|
-
const pcm16 = Buffer.alloc(data.length * 2);
|
|
61
|
-
for (let i = 0; i < data.length; i++) {
|
|
62
|
-
let env = 1;
|
|
63
|
-
if (fadeIn > 0 && i < fadeIn) env *= i / fadeIn;
|
|
64
|
-
if (fadeOut > 0 && i >= data.length - fadeOut) env *= (data.length - 1 - i) / fadeOut;
|
|
65
|
-
const v = Math.max(-0.95, Math.min(0.95, data[i] * gain * env));
|
|
66
|
-
pcm16.writeInt16LE(Math.round(v * (v < 0 ? 32768 : 32767)), i * 2);
|
|
67
|
-
}
|
|
68
|
-
return pcm16;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function encodeMp3(pcm16, bitrateKbps) {
|
|
72
|
-
const wav = Buffer.alloc(44 + pcm16.length);
|
|
73
|
-
wav.write('RIFF', 0, 'ascii'); wav.writeUInt32LE(36 + pcm16.length, 4); wav.write('WAVEfmt ', 8, 'ascii');
|
|
74
|
-
wav.writeUInt32LE(16, 16); wav.writeUInt16LE(1, 20); wav.writeUInt16LE(1, 22);
|
|
75
|
-
wav.writeUInt32LE(RATE, 24); wav.writeUInt32LE(RATE * 2, 28); wav.writeUInt16LE(2, 32); wav.writeUInt16LE(16, 34);
|
|
76
|
-
wav.write('data', 36, 'ascii'); wav.writeUInt32LE(pcm16.length, 40); pcm16.copy(wav, 44);
|
|
77
|
-
return execFileSync(
|
|
78
|
-
'gst-launch-1.0',
|
|
79
|
-
['-q', 'fdsrc', 'fd=0', '!', 'wavparse', '!', 'audioconvert', '!', 'lamemp3enc', 'target=bitrate', 'cbr=true', `bitrate=${bitrateKbps}`, '!', 'fdsink', 'fd=1'],
|
|
80
|
-
{input: wav, maxBuffer: 20 * 1024 * 1024, stdio: ['pipe', 'pipe', 'pipe']},
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const temp = await mkdtemp(resolve(root, 'reports/fps-prep-'));
|
|
85
|
-
try {
|
|
86
|
-
// Preserve existing prepared Starter-Kit-FPS 3D GLBs and starter-kit-fps license receipt
|
|
87
|
-
const prevPlan = JSON.parse(await readFile(resolve(outRoot, 'plan.json'), 'utf8'));
|
|
88
|
-
const prevStarterPack = prevPlan.source.packs.find(p => p.id === 'kenney-starter-kit-fps');
|
|
89
|
-
const starterLicense = await readFile(resolve(outRoot, 'licenses/starter-kit-fps.txt'));
|
|
90
|
-
|
|
91
|
-
const receipts = JSON.parse(await readFile(resolve(tmpPacks, 'receipts.json'), 'utf8'));
|
|
92
|
-
const rcBySlug = Object.fromEntries(receipts.map(r => [r.slug, r]));
|
|
93
|
-
|
|
94
|
-
// Remove unused second weapon GLB (weapon switching cancelled — single signature twin-barrel blaster-repeater.glb!)
|
|
95
|
-
await rm(resolve(outRoot, '3d/blaster.glb'), {force: true});
|
|
96
|
-
await rm(resolve(outRoot, '2d'), {recursive: true, force: true});
|
|
97
|
-
await rm(resolve(outRoot, 'audio'), {recursive: true, force: true});
|
|
98
|
-
await rm(resolve(outRoot, 'licenses'), {recursive: true, force: true});
|
|
99
|
-
await mkdir(resolve(outRoot, '2d'), {recursive: true});
|
|
100
|
-
await mkdir(resolve(outRoot, 'audio'), {recursive: true});
|
|
101
|
-
await mkdir(resolve(outRoot, 'licenses'), {recursive: true});
|
|
102
|
-
|
|
103
|
-
// Write verified CC0 license receipts
|
|
104
|
-
await writeFile(resolve(outRoot, 'licenses/starter-kit-fps.txt'), starterLicense);
|
|
105
|
-
await writeFile(resolve(outRoot, 'licenses/ui-pack-sci-fi.txt'), unzipEntry(resolve(tmpPacks, 'ui-pack-sci-fi.zip'), 'License.txt'));
|
|
106
|
-
await writeFile(resolve(outRoot, 'licenses/sci-fi-sounds.txt'), unzipEntry(resolve(tmpPacks, 'sci-fi-sounds.zip'), 'License.txt'));
|
|
107
|
-
await writeFile(resolve(outRoot, 'licenses/game-icons.txt'), unzipEntry(resolve(tmpPacks, 'game-icons.zip'), 'license.txt'));
|
|
108
|
-
await writeFile(resolve(outRoot, 'licenses/5-chiptunes-action.txt'), await readFile(resolve(tmpPacks, 'chiptunes/INFO.txt')));
|
|
109
|
-
|
|
110
|
-
// Save updated downloads manifest
|
|
111
|
-
await writeFile(resolve(outRoot, 'source/downloads.json'), JSON.stringify([
|
|
112
|
-
{slug: 'starter-kit-fps', pageUrl: 'https://github.com/KenneyNL/Starter-Kit-FPS', license: 'CC0-1.0', author: 'Kenney', sha256: prevStarterPack.sha256},
|
|
113
|
-
rcBySlug['ui-pack-sci-fi'],
|
|
114
|
-
rcBySlug['sci-fi-sounds'],
|
|
115
|
-
rcBySlug['game-icons'],
|
|
116
|
-
rcBySlug['5-chiptunes-action'],
|
|
117
|
-
], null, 2) + '\n');
|
|
118
|
-
|
|
119
|
-
// Re-inspect the 9 kept 3D GLB models from Starter-Kit-FPS
|
|
120
|
-
const keptModels = [
|
|
121
|
-
{id: 'fps.model.blaster', file: 'blaster-repeater.glb', prevId: 'fps.model.repeater'},
|
|
122
|
-
{id: 'fps.model.enemy', file: 'enemy-flying.glb', prevId: 'fps.model.enemy'},
|
|
123
|
-
{id: 'fps.model.island', file: 'platform-large-grass.glb', prevId: 'fps.model.island'},
|
|
124
|
-
{id: 'fps.model.pad', file: 'platform.glb', prevId: 'fps.model.pad'},
|
|
125
|
-
{id: 'fps.model.wall.high', file: 'wall-high.glb', prevId: 'fps.model.wall.high'},
|
|
126
|
-
{id: 'fps.model.wall.low', file: 'wall-low.glb', prevId: 'fps.model.wall.low'},
|
|
127
|
-
{id: 'fps.model.cloud', file: 'cloud.glb', prevId: 'fps.model.cloud'},
|
|
128
|
-
{id: 'fps.model.grass', file: 'grass.glb', prevId: 'fps.model.grass'},
|
|
129
|
-
{id: 'fps.model.grass.sm', file: 'grass-small.glb', prevId: 'fps.model.grass.sm'},
|
|
130
|
-
];
|
|
131
|
-
|
|
132
|
-
const visualFiles = [];
|
|
133
|
-
for (const spec of keptModels) {
|
|
134
|
-
const relPath = `assets/tora-fps/3d/${spec.file}`;
|
|
135
|
-
const glbBytes = await readFile(resolve(root, relPath));
|
|
136
|
-
const prev = prevPlan.files.find(f => f.id === spec.id || f.id === spec.prevId);
|
|
137
|
-
const info = JSON.parse(execFileSync(playableBin, ['assets', 'inspect-3d', resolve(outRoot, '3d'), spec.file], {encoding: 'utf8'}));
|
|
138
|
-
visualFiles.push({
|
|
139
|
-
id: spec.id,
|
|
140
|
-
mime: 'model/gltf-binary',
|
|
141
|
-
file: relPath,
|
|
142
|
-
bytes: glbBytes.length,
|
|
143
|
-
sha256: sha256(glbBytes),
|
|
144
|
-
triangles: info.triangles,
|
|
145
|
-
subNodes: info.subNodes ?? info.sub_nodes ?? [],
|
|
146
|
-
sourcePack: 'kenney-starter-kit-fps',
|
|
147
|
-
sourceUrl: 'https://github.com/KenneyNL/Starter-Kit-FPS',
|
|
148
|
-
archiveSha256: prevStarterPack.sha256,
|
|
149
|
-
processing: prev.processing,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Extract & ICC-strip bespoke Kenney UI Pack Sci-Fi + Game Icons sprites
|
|
154
|
-
const uiZip = resolve(tmpPacks, 'ui-pack-sci-fi.zip');
|
|
155
|
-
const iconZip = resolve(tmpPacks, 'game-icons.zip');
|
|
156
|
-
const iconSpecs = [
|
|
157
|
-
{id: 'fps.ui.hud', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Blue/Double/button_square_header_blade_rectangle_screws.png', out: 'hud-panel.png'},
|
|
158
|
-
{id: 'fps.ui.win', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Green/Double/button_square_header_blade_rectangle_screws.png', out: 'win-panel.png'},
|
|
159
|
-
{id: 'fps.ui.timeout', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Red/Double/button_square_header_blade_rectangle_screws.png', out: 'timeout-panel.png'},
|
|
160
|
-
{id: 'fps.ui.bar.track', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Extra/Double/bar_shadow_round_outline_large.png', out: 'bar-track.png'},
|
|
161
|
-
{id: 'fps.ui.bar.fill', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Blue/Double/bar_round_gloss_large.png', out: 'bar-cyan.png'},
|
|
162
|
-
{id: 'fps.ui.badge', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Extra/Double/panel_glass_notches.png', out: 'badge-frame.png'},
|
|
163
|
-
{id: 'fps.icon.crosshair', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Blue/Double/crosshair_color_a.png', out: 'crosshair.png'},
|
|
164
|
-
{id: 'fps.icon.hit', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Red/Double/crosshair_color_b.png', out: 'hit-lock.png'},
|
|
165
|
-
{id: 'fps.icon.burst', zip: uiZip, pack: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, archiveSha: rcBySlug['ui-pack-sci-fi'].sha256, entry: 'PNG/Yellow/Double/crosshair_color_c.png', out: 'muzzle-burst.png'},
|
|
166
|
-
{id: 'fps.icon.fire', zip: iconZip, pack: 'game-icons', url: rcBySlug['game-icons'].pageUrl, archiveSha: rcBySlug['game-icons'].sha256, entry: 'PNG/White/2x/target.png', out: 'icon-fire.png'},
|
|
167
|
-
{id: 'fps.icon.medal', zip: iconZip, pack: 'game-icons', url: rcBySlug['game-icons'].pageUrl, archiveSha: rcBySlug['game-icons'].sha256, entry: 'PNG/White/2x/medal1.png', out: 'icon-medal.png'},
|
|
168
|
-
{id: 'fps.icon.warning', zip: iconZip, pack: 'game-icons', url: rcBySlug['game-icons'].pageUrl, archiveSha: rcBySlug['game-icons'].sha256, entry: 'PNG/White/2x/warning.png', out: 'icon-warning.png'},
|
|
169
|
-
];
|
|
170
|
-
|
|
171
|
-
for (const spec of iconSpecs) {
|
|
172
|
-
const raw = unzipEntry(spec.zip, spec.entry);
|
|
173
|
-
const tmpIn = resolve(temp, spec.out);
|
|
174
|
-
await writeFile(tmpIn, raw);
|
|
175
|
-
const relPath = `assets/tora-fps/2d/${spec.out}`;
|
|
176
|
-
const outAbs = resolve(root, relPath);
|
|
177
|
-
execFileSync('python3', ['-c', `
|
|
178
|
-
from PIL import Image
|
|
179
|
-
im = Image.open(${JSON.stringify(tmpIn)}).convert('RGBA')
|
|
180
|
-
im.save(${JSON.stringify(outAbs)}, optimize=True)
|
|
181
|
-
`]);
|
|
182
|
-
const clean = await readFile(outAbs);
|
|
183
|
-
visualFiles.push({
|
|
184
|
-
id: spec.id,
|
|
185
|
-
mime: 'image/png',
|
|
186
|
-
file: relPath,
|
|
187
|
-
bytes: clean.length,
|
|
188
|
-
sha256: sha256(clean),
|
|
189
|
-
sourcePack: spec.pack,
|
|
190
|
-
sourceUrl: spec.url,
|
|
191
|
-
archiveSha256: spec.archiveSha,
|
|
192
|
-
processing: {kind: 'png-strip-metadata', sourceFile: `${spec.pack}/${spec.entry}`, sourceSha256: sha256(raw)},
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const visualPlan = {
|
|
197
|
-
format: 'tora-native-3d-asset-plan-1',
|
|
198
|
-
source: {
|
|
199
|
-
id: 'kenney-starter-kit-fps',
|
|
200
|
-
author: 'Kenney',
|
|
201
|
-
sourceUrl: 'https://github.com/KenneyNL/Starter-Kit-FPS',
|
|
202
|
-
license: 'CC0-1.0',
|
|
203
|
-
licenseUrl: 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
204
|
-
styleFamily: 'kenney-starter-kit-fps-scifi',
|
|
205
|
-
attributionRequired: false,
|
|
206
|
-
packs: [
|
|
207
|
-
{id: 'kenney-starter-kit-fps', url: 'https://github.com/KenneyNL/Starter-Kit-FPS', sha256: prevStarterPack.sha256, licenseFile: 'assets/tora-fps/licenses/starter-kit-fps.txt'},
|
|
208
|
-
{id: 'ui-pack-sci-fi', url: rcBySlug['ui-pack-sci-fi'].pageUrl, sha256: rcBySlug['ui-pack-sci-fi'].sha256, licenseFile: 'assets/tora-fps/licenses/ui-pack-sci-fi.txt'},
|
|
209
|
-
{id: 'game-icons', url: rcBySlug['game-icons'].pageUrl, sha256: rcBySlug['game-icons'].sha256, licenseFile: 'assets/tora-fps/licenses/game-icons.txt'},
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
visualDirection: 'Twilight-violet cyber-sky floating arena from Kenney Starter-Kit-FPS (CC0) paired with Kenney UI Pack Sci-Fi blade-header HUD panels, cyan/red sci-fi reticles, an icon-only circular fire trigger, twin-barrel FPS blaster viewmodel, and additive plasma spark VFX.',
|
|
213
|
-
files: visualFiles,
|
|
214
|
-
};
|
|
215
|
-
await writeFile(resolve(outRoot, 'plan.json'), JSON.stringify(visualPlan, null, 2) + '\n');
|
|
216
|
-
|
|
217
|
-
// Unique Audio Pack (6 compressed MP3 cues — ZERO reuse from any other Tora demo!)
|
|
218
|
-
const scifiZip = resolve(tmpPacks, 'sci-fi-sounds.zip');
|
|
219
|
-
const sfxTemp = {};
|
|
220
|
-
for (const [k, entry] of [
|
|
221
|
-
['blaster', 'Audio/laserLarge_000.ogg'],
|
|
222
|
-
['hit', 'Audio/impactMetal_002.ogg'],
|
|
223
|
-
['kill', 'Audio/explosionCrunch_000.ogg'],
|
|
224
|
-
['loss', 'Audio/forceField_000.ogg'],
|
|
225
|
-
]) {
|
|
226
|
-
const p = resolve(temp, `${k}.ogg`);
|
|
227
|
-
const b = unzipEntry(scifiZip, entry);
|
|
228
|
-
await writeFile(p, b);
|
|
229
|
-
sfxTemp[k] = {path: p, entry, sha: sha256(b)};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const level2Path = resolve(tmpPacks, 'chiptunes/Juhani Junkala [Retro Game Music Pack] Level 2.wav');
|
|
233
|
-
const endingPath = resolve(tmpPacks, 'chiptunes/Juhani Junkala [Retro Game Music Pack] Ending.wav');
|
|
234
|
-
const level2Sha = sha256(await readFile(level2Path));
|
|
235
|
-
const endingSha = sha256(await readFile(endingPath));
|
|
236
|
-
|
|
237
|
-
const audioSpecs = [
|
|
238
|
-
{
|
|
239
|
-
id: 'fps.audio.ambient', role: 'ambient', out: 'ambient.mp3', bitrate: 32,
|
|
240
|
-
author: 'Juhani Junkala (SubspaceAudio)', sourceId: 'juhani-junkala-5-chiptunes-action', sourceUrl: 'https://opengameart.org/content/5-chiptunes-action',
|
|
241
|
-
input: {path: level2Path, rel: '5 Action Chiptunes By Juhani Junkala.zip#Juhani Junkala [Retro Game Music Pack] Level 2.wav', sha: level2Sha},
|
|
242
|
-
master: {maxDurationSec: 16, loopFadeSec: 0.035},
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: 'fps.audio.blaster', role: 'tap', out: 'blaster.mp3', bitrate: 48,
|
|
246
|
-
author: 'Kenney', sourceId: 'kenney-sci-fi-sounds', sourceUrl: 'https://kenney.nl/assets/sci-fi-sounds',
|
|
247
|
-
input: {path: sfxTemp.blaster.path, rel: `sci-fi-sounds/${sfxTemp.blaster.entry}`, sha: sfxTemp.blaster.sha},
|
|
248
|
-
trim: true,
|
|
249
|
-
master: {fadeSec: 0.004},
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
id: 'fps.audio.hit', role: 'match', out: 'hit.mp3', bitrate: 48,
|
|
253
|
-
author: 'Kenney', sourceId: 'kenney-sci-fi-sounds', sourceUrl: 'https://kenney.nl/assets/sci-fi-sounds',
|
|
254
|
-
input: {path: sfxTemp.hit.path, rel: `sci-fi-sounds/${sfxTemp.hit.entry}`, sha: sfxTemp.hit.sha},
|
|
255
|
-
trim: true,
|
|
256
|
-
master: {fadeSec: 0.004},
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
id: 'fps.audio.kill', role: 'reward', out: 'kill.mp3', bitrate: 48,
|
|
260
|
-
author: 'Kenney', sourceId: 'kenney-sci-fi-sounds', sourceUrl: 'https://kenney.nl/assets/sci-fi-sounds',
|
|
261
|
-
input: {path: sfxTemp.kill.path, rel: `sci-fi-sounds/${sfxTemp.kill.entry}`, sha: sfxTemp.kill.sha},
|
|
262
|
-
trim: true,
|
|
263
|
-
master: {fadeSec: 0.006},
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
id: 'fps.audio.win', role: 'win', out: 'win.mp3', bitrate: 48,
|
|
267
|
-
author: 'Juhani Junkala (SubspaceAudio)', sourceId: 'juhani-junkala-5-chiptunes-action', sourceUrl: 'https://opengameart.org/content/5-chiptunes-action',
|
|
268
|
-
input: {path: endingPath, rel: '5 Action Chiptunes By Juhani Junkala.zip#Juhani Junkala [Retro Game Music Pack] Ending.wav', sha: endingSha},
|
|
269
|
-
master: {maxDurationSec: 2.8, fadeInSec: 0.01, fadeOutSec: 0.25},
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
id: 'fps.audio.loss', role: 'loss', out: 'loss.mp3', bitrate: 48,
|
|
273
|
-
author: 'Kenney', sourceId: 'kenney-sci-fi-sounds', sourceUrl: 'https://kenney.nl/assets/sci-fi-sounds',
|
|
274
|
-
input: {path: sfxTemp.loss.path, rel: `sci-fi-sounds/${sfxTemp.loss.entry}`, sha: sfxTemp.loss.sha},
|
|
275
|
-
trim: true,
|
|
276
|
-
master: {fadeInSec: 0.008, fadeOutSec: 0.14},
|
|
277
|
-
},
|
|
278
|
-
];
|
|
279
|
-
|
|
280
|
-
const audioPlanFiles = [];
|
|
281
|
-
for (const spec of audioSpecs) {
|
|
282
|
-
let pcm = decodeToPcmFloat(spec.input.path);
|
|
283
|
-
if (spec.trim) pcm = trimSilence(pcm);
|
|
284
|
-
const pcm16 = masterPcm(pcm, spec.master);
|
|
285
|
-
const mp3 = encodeMp3(pcm16, spec.bitrate);
|
|
286
|
-
const relPath = `assets/tora-fps/audio/${spec.out}`;
|
|
287
|
-
await writeFile(resolve(root, relPath), mp3);
|
|
288
|
-
const analysis = analyzeAudio(new Uint8Array(mp3), 'audio/mpeg');
|
|
289
|
-
if (analysis.clipping || analysis.peakDbfs > -0.4) throw Error(`Clipping in ${spec.id}: ${analysis.peakDbfs}`);
|
|
290
|
-
if (spec.role === 'win') {
|
|
291
|
-
if (analysis.trimmedDurationSec < 1.6) throw Error(`Win fanfare too short: ${analysis.trimmedDurationSec}s`);
|
|
292
|
-
if (analysis.pitchContour === 'falling') throw Error('Win fanfare falling contour');
|
|
293
|
-
}
|
|
294
|
-
audioPlanFiles.push({
|
|
295
|
-
id: spec.id,
|
|
296
|
-
role: spec.role,
|
|
297
|
-
file: relPath,
|
|
298
|
-
mime: 'audio/mpeg',
|
|
299
|
-
bytes: mp3.length,
|
|
300
|
-
sha256: sha256(mp3),
|
|
301
|
-
durationSec: analysis.durationSec,
|
|
302
|
-
trimmedDurationSec: analysis.trimmedDurationSec,
|
|
303
|
-
pitchContour: analysis.pitchContour,
|
|
304
|
-
peakDbfs: analysis.peakDbfs,
|
|
305
|
-
rights: `${spec.author}; CC0-1.0; ${spec.sourceUrl}; attribution required: no`,
|
|
306
|
-
provenance: {
|
|
307
|
-
sourceId: spec.sourceId,
|
|
308
|
-
sourceFiles: [spec.input.rel],
|
|
309
|
-
sourceHashes: [spec.input.sha],
|
|
310
|
-
license: 'CC0-1.0',
|
|
311
|
-
tool: 'GStreamer lamemp3enc',
|
|
312
|
-
bitrateKbps: spec.bitrate,
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
await writeFile(resolve(outRoot, 'audio-plan.json'), JSON.stringify({format: 'tora-game-audio-plan-1', files: audioPlanFiles}, null, 2) + '\n');
|
|
318
|
-
|
|
319
|
-
const total3d = visualFiles.filter(f => f.mime === 'model/gltf-binary').reduce((s, f) => s + f.bytes, 0);
|
|
320
|
-
const total2d = visualFiles.filter(f => f.mime === 'image/png').reduce((s, f) => s + f.bytes, 0);
|
|
321
|
-
const totalAudio = audioPlanFiles.reduce((s, f) => s + f.bytes, 0);
|
|
322
|
-
process.stdout.write(JSON.stringify({
|
|
323
|
-
models: visualFiles.filter(f => f.mime === 'model/gltf-binary').map(f => ({id: f.id, bytes: f.bytes, tris: f.triangles})),
|
|
324
|
-
icons: visualFiles.filter(f => f.mime === 'image/png').map(f => ({id: f.id, bytes: f.bytes})),
|
|
325
|
-
audio: audioPlanFiles.map(f => ({id: f.id, bytes: f.bytes, dur: +f.trimmedDurationSec.toFixed(2), contour: f.pitchContour, peak: +f.peakDbfs.toFixed(1)})),
|
|
326
|
-
totals: {modelsBytes: total3d, iconsBytes: total2d, audioBytes: totalAudio, combinedBytes: total3d + total2d + totalAudio},
|
|
327
|
-
}, null, 2) + '\n');
|
|
328
|
-
} finally {
|
|
329
|
-
await rm(temp, {recursive: true, force: true});
|
|
330
|
-
}
|