@bitmagic/cli 0.1.53-dev.8 → 0.1.53
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 +31 -14
- package/dist/assets/revoxelize.d.ts +34 -0
- package/dist/assets/revoxelize.js +64 -8
- package/dist/assets/revoxelize.js.map +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/commands/build.d.ts +4 -0
- package/dist/commands/build.js +7 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/generate.d.ts +20 -18
- package/dist/commands/generate.js +69 -38
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/publish.d.ts +8 -1
- package/dist/commands/publish.js +16 -6
- package/dist/commands/publish.js.map +1 -1
- package/dist/editor/asset-detail-panel.d.ts +2 -2
- package/dist/editor/asset-detail-panel.js +5 -2
- package/dist/editor/asset-detail-panel.js.map +1 -1
- package/dist/editor/server.js +5 -1
- package/dist/editor/server.js.map +1 -1
- package/dist/editor/shell-page.js +137 -5
- package/dist/editor/shell-page.js.map +1 -1
- package/dist/generate/model.d.ts +7 -5
- package/dist/generate/model.js +16 -6
- package/dist/generate/model.js.map +1 -1
- package/dist/generate/prop.d.ts +8 -6
- package/dist/generate/prop.js +48 -19
- package/dist/generate/prop.js.map +1 -1
- package/dist/publish/bundle.d.ts +35 -8
- package/dist/publish/bundle.js +41 -13
- package/dist/publish/bundle.js.map +1 -1
- package/dist/scaffold/project-files.d.ts +42 -9
- package/dist/scaffold/project-files.js +198 -16
- package/dist/scaffold/project-files.js.map +1 -1
- package/dist/scaffold/project.js +2 -1
- package/dist/scaffold/project.js.map +1 -1
- package/package.json +4 -4
|
@@ -128,8 +128,8 @@ ${BITMAGIC_CONTROLS_CSS}
|
|
|
128
128
|
/* A tab is a .bm-pill that starts invisible; the ACTIVE one is what the accent is for —
|
|
129
129
|
DESIGN.md gives Aquamarine to primary actions and active states alike. */
|
|
130
130
|
.tab { background: transparent; border-color: transparent; color: var(--bm-text-muted); }
|
|
131
|
-
.tab:hover:not(.active) { background: var(--bm-surface-card);
|
|
132
|
-
|
|
131
|
+
.tab:hover:not(.active):not(:disabled) { background: var(--bm-surface-card);
|
|
132
|
+
border-color: transparent; color: var(--bm-text); }
|
|
133
133
|
.tab.active, .tab.active:hover { background: var(--bm-aqua); border-color: var(--bm-aqua);
|
|
134
134
|
color: #000000; }
|
|
135
135
|
#status { display: flex; align-items: center; gap: 8px; font-size: 12px;
|
|
@@ -363,6 +363,24 @@ ${ASSET_DETAIL_HTML}
|
|
|
363
363
|
// When a scene save last landed. See ACTIVE_EDIT_WINDOW_MS.
|
|
364
364
|
var lastLocalEditAt = 0;
|
|
365
365
|
|
|
366
|
+
// An object voxel session (VoxelEditSession over an asset or a placed object) lives entirely in
|
|
367
|
+
// the iframe, and its unsaved edits die with it — so while one is open the shell must not reload
|
|
368
|
+
// the game or switch it out of editor mode. Bracketed by VOXEL_OBJECT_EDIT_STARTED/ENDED;
|
|
369
|
+
// 'pending' covers the gap between posting EDIT_VOXEL_ASSET and the engine's answer.
|
|
370
|
+
var voxelSessionActive = false;
|
|
371
|
+
var voxelSessionPending = false;
|
|
372
|
+
var voxelStartTimer = null;
|
|
373
|
+
// Set when a reload took an open session with it, so start() can say so once the boot is done.
|
|
374
|
+
var voxelSessionWasLost = false;
|
|
375
|
+
// How long EDIT_VOXEL_ASSET may go unanswered before the engine is presumed too old to know it.
|
|
376
|
+
// Generous: a real start fetches the .vxl from the CDN before it answers.
|
|
377
|
+
var VOXEL_START_TIMEOUT_MS = 10000;
|
|
378
|
+
|
|
379
|
+
/** Tab switching is how a session gets destroyed from out here, so it locks while one is open. */
|
|
380
|
+
function setVoxelSessionUi(active) {
|
|
381
|
+
tabButtons.forEach(function (button) { button.disabled = active; });
|
|
382
|
+
}
|
|
383
|
+
|
|
366
384
|
// localStorage is unavailable in some privacy modes, and losing a preference must not lose the
|
|
367
385
|
// page. Defaults below are the ones a first-time creator gets anyway.
|
|
368
386
|
function readPref(key, fallback) {
|
|
@@ -546,6 +564,34 @@ ${ASSET_DETAIL_HTML}
|
|
|
546
564
|
void recordVoxelSave(message);
|
|
547
565
|
break;
|
|
548
566
|
|
|
567
|
+
case 'VOXEL_OBJECT_EDIT_STARTED':
|
|
568
|
+
// An object voxel session opened — from the overlay's Edit voxels, or from the inspector's
|
|
569
|
+
// own button, which posts the same pair. Either way the session now owns the iframe.
|
|
570
|
+
if (voxelStartTimer) { clearTimeout(voxelStartTimer); voxelStartTimer = null; }
|
|
571
|
+
voxelSessionPending = false;
|
|
572
|
+
voxelSessionActive = true;
|
|
573
|
+
setVoxelSessionUi(true);
|
|
574
|
+
setStatus('saved', 'Editing voxels — Save & Exit or Cancel in the toolbar');
|
|
575
|
+
break;
|
|
576
|
+
|
|
577
|
+
case 'VOXEL_OBJECT_EDIT_ENDED':
|
|
578
|
+
// A refused START also arrives as ENDED-with-error (EditorManager.startAssetVoxelSession
|
|
579
|
+
// aborts that way, including "a voxel edit session is already open"). A genuine session end
|
|
580
|
+
// never carries 'error', so an error landing while a session is active and none is pending
|
|
581
|
+
// belongs to a refused second start — the open session must keep its lock.
|
|
582
|
+
if (message.error && voxelSessionActive && !voxelSessionPending) break;
|
|
583
|
+
if (voxelStartTimer) { clearTimeout(voxelStartTimer); voxelStartTimer = null; }
|
|
584
|
+
voxelSessionPending = false;
|
|
585
|
+
voxelSessionActive = false;
|
|
586
|
+
setVoxelSessionUi(false);
|
|
587
|
+
if (message.error) {
|
|
588
|
+
setStatus('error', 'Could not open the voxel editor: ' + message.error);
|
|
589
|
+
} else if (message.hasChanges !== true) {
|
|
590
|
+
// Saved sessions leave the status to recordVoxelSave, which owns the outcome.
|
|
591
|
+
setStatus('saved', 'Ready');
|
|
592
|
+
}
|
|
593
|
+
break;
|
|
594
|
+
|
|
549
595
|
case 'TERRAIN_SAVED_INTERNAL':
|
|
550
596
|
// The engine uploaded the sculpted terrain and is handing back its URL for world.json.
|
|
551
597
|
// Same surgical write every other editor save here uses.
|
|
@@ -715,8 +761,10 @@ ${ASSET_DETAIL_HTML}
|
|
|
715
761
|
setStatus('saved', 'Generated');
|
|
716
762
|
// The asset changed under the running engine, so the open scene is showing the old mesh.
|
|
717
763
|
// The generation wrote world.json through the sidecar, which suppresses its own writes from
|
|
718
|
-
// the watcher, so this is the only thing that will bring the new mesh in.
|
|
719
|
-
|
|
764
|
+
// the watcher, so this is the only thing that will bring the new mesh in. Unless a voxel
|
|
765
|
+
// session is open — a reload would take its unsaved edits with it.
|
|
766
|
+
if (autoReload && !voxelSessionActive && !voxelSessionPending) start();
|
|
767
|
+
else banner.classList.add('show');
|
|
720
768
|
};
|
|
721
769
|
void tick();
|
|
722
770
|
}
|
|
@@ -779,6 +827,9 @@ ${ASSET_DETAIL_HTML}
|
|
|
779
827
|
async function selectTab(tab, options) {
|
|
780
828
|
var fromEngine = options && options.fromEngine === true;
|
|
781
829
|
if (tab === activeTab && !fromEngine) return;
|
|
830
|
+
// Backstop behind the disabled tab buttons: a switch would post SET_EDITOR_MODE under the open
|
|
831
|
+
// session. The engine's own guard (canSwitchToEditorTab) only covers terrain.
|
|
832
|
+
if (voxelSessionActive && !fromEngine) return;
|
|
782
833
|
|
|
783
834
|
if (activeTab === 'editor' && tab === 'game' && loaded && !fromEngine) {
|
|
784
835
|
await flush();
|
|
@@ -848,6 +899,15 @@ ${ASSET_DETAIL_HTML}
|
|
|
848
899
|
// A fresh iframe is a fresh engine with no memory of what was glowing, so the next push must
|
|
849
900
|
// not be suppressed as a repeat of what the PREVIOUS one was told.
|
|
850
901
|
lastGlowing = '';
|
|
902
|
+
// A session cannot survive its iframe. Remember that one was OPEN — start() says so once the
|
|
903
|
+
// boot is done, the way the Creator toasts when a reload takes its voxel modal — and unlock
|
|
904
|
+
// the tabs the session had frozen. A merely pending start has no edits to mourn: the editor
|
|
905
|
+
// simply never opened, which the fresh boot's own status already conveys.
|
|
906
|
+
if (voxelSessionActive) voxelSessionWasLost = true;
|
|
907
|
+
voxelSessionActive = false;
|
|
908
|
+
voxelSessionPending = false;
|
|
909
|
+
if (voxelStartTimer) { clearTimeout(voxelStartTimer); voxelStartTimer = null; }
|
|
910
|
+
setVoxelSessionUi(false);
|
|
851
911
|
banner.classList.remove('show');
|
|
852
912
|
terrainBanner.classList.remove('show');
|
|
853
913
|
setStatus('', 'Loading…');
|
|
@@ -922,6 +982,9 @@ ${ASSET_DETAIL_HTML}
|
|
|
922
982
|
|
|
923
983
|
async function flush() {
|
|
924
984
|
if (!loaded || saving) return;
|
|
985
|
+
// Mid-session the scene set is not the creator's concern, and a poll answer flipping the status
|
|
986
|
+
// line would overwrite "Editing voxels" every half second.
|
|
987
|
+
if (voxelSessionActive) return;
|
|
925
988
|
|
|
926
989
|
var changes = await request('CHECK_SCENE_CHANGES', 'SCENE_HAS_CHANGES', 2000);
|
|
927
990
|
if (!changes) return;
|
|
@@ -1072,10 +1135,22 @@ ${ASSET_DETAIL_HTML}
|
|
|
1072
1135
|
// Logged because "why did my game just reload?" is otherwise unanswerable from the browser.
|
|
1073
1136
|
console.log('[bitmagic dev] change signalled:', reason);
|
|
1074
1137
|
if (!autoReload) { banner.classList.add('show'); return; }
|
|
1138
|
+
// An open (or opening) voxel session dies with the iframe, edits and all. Not gated on the tab:
|
|
1139
|
+
// the session owns the stage whatever the tab thinks.
|
|
1140
|
+
if (voxelSessionActive || voxelSessionPending) { banner.classList.add('show'); return; }
|
|
1075
1141
|
if (activeTab === 'editor' && (saving || Date.now() - lastLocalEditAt < ACTIVE_EDIT_MS)) {
|
|
1076
1142
|
banner.classList.add('show');
|
|
1077
1143
|
return;
|
|
1078
1144
|
}
|
|
1145
|
+
// Terrain sessions announce nothing (VOXEL_OBJECT_EDIT_* is object-only), so ask. A null
|
|
1146
|
+
// answer — timeout, or an engine from before the terrain editor — reloads as it always did.
|
|
1147
|
+
if (activeTab === 'editor' && loaded) {
|
|
1148
|
+
void request('CHECK_TERRAIN_CHANGES', 'TERRAIN_HAS_CHANGES', 2000).then(function (terrain) {
|
|
1149
|
+
if (terrain && terrain.hasChanges === true) banner.classList.add('show');
|
|
1150
|
+
else start();
|
|
1151
|
+
});
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1079
1154
|
start();
|
|
1080
1155
|
}
|
|
1081
1156
|
|
|
@@ -1624,6 +1699,8 @@ ${ASSET_DETAIL_HTML}
|
|
|
1624
1699
|
var assetPausedByOverlay = false;
|
|
1625
1700
|
var assetReturnFocus = null;
|
|
1626
1701
|
var assetLoadTimer = null;
|
|
1702
|
+
// The asset the overlay is showing, for the Edit voxels action. Null whenever it is closed.
|
|
1703
|
+
var assetDetailAsset = null;
|
|
1627
1704
|
|
|
1628
1705
|
var IMAGE_TYPES = { image: true, skybox: true };
|
|
1629
1706
|
var AUDIO_TYPES = { audio: true, sound: true, 'sound-effect': true };
|
|
@@ -1660,6 +1737,11 @@ ${ASSET_DETAIL_HTML}
|
|
|
1660
1737
|
|
|
1661
1738
|
function openAssetDetail(asset, hasPreview) {
|
|
1662
1739
|
assetReturnFocus = document.activeElement;
|
|
1740
|
+
assetDetailAsset = asset;
|
|
1741
|
+
// The one asset type the in-engine voxel editor can open. Everything else keeps the pill out
|
|
1742
|
+
// of sight rather than disabled — a disabled action begs a question this dialog cannot answer.
|
|
1743
|
+
document.getElementById('asset-edit-voxels').classList.toggle(
|
|
1744
|
+
'hidden', String(asset.type || '').toLowerCase() !== 'vxl');
|
|
1663
1745
|
document.getElementById('asset-name').textContent = asset.name || asset.id || 'unnamed';
|
|
1664
1746
|
document.getElementById('asset-sub').textContent =
|
|
1665
1747
|
(asset.hqGeneratedAt ? 'High quality · ' : asset.placeholder === true ? 'Placeholder · ' : '')
|
|
@@ -1730,6 +1812,7 @@ ${ASSET_DETAIL_HTML}
|
|
|
1730
1812
|
|
|
1731
1813
|
function closeAssetDetail() {
|
|
1732
1814
|
if (!assetOverlay.classList.contains('show')) return false;
|
|
1815
|
+
assetDetailAsset = null;
|
|
1733
1816
|
assetOverlay.classList.remove('show');
|
|
1734
1817
|
if (assetLoadTimer) clearTimeout(assetLoadTimer);
|
|
1735
1818
|
// about:blank rather than hiding it: an idle iframe would hold a WebGL context and a render
|
|
@@ -1769,6 +1852,47 @@ ${ASSET_DETAIL_HTML}
|
|
|
1769
1852
|
}
|
|
1770
1853
|
}
|
|
1771
1854
|
|
|
1855
|
+
/**
|
|
1856
|
+
* The overlay's Edit voxels action — the Creator's Assets-tab "Edit voxels…" for this lane.
|
|
1857
|
+
*
|
|
1858
|
+
* The shell only asks; the whole editor is in the engine (EDIT_VOXEL_ASSET →
|
|
1859
|
+
* EditorManager.startAssetVoxelSession, the same session the inspector's own button opens on a
|
|
1860
|
+
* placed object). Routed through the Editor tab first because that is the state the session is
|
|
1861
|
+
* built to run in — game paused, HUD hidden by SET_EDITOR_TAB 'scene' — where the Game tab's
|
|
1862
|
+
* 'prompt' mode would leave the HUD drawn over the isolated view. The session takes the camera
|
|
1863
|
+
* and hides the hierarchy panel on its own.
|
|
1864
|
+
*
|
|
1865
|
+
* Posted optimistically: a vendored engine from before the voxel editor drops unknown messages
|
|
1866
|
+
* on the floor, so the only way to learn it is too old is to stop waiting. Every current engine
|
|
1867
|
+
* answers — VOXEL_OBJECT_EDIT_STARTED, or ENDED with the reason it refused.
|
|
1868
|
+
*/
|
|
1869
|
+
async function startVoxelEditFromOverlay() {
|
|
1870
|
+
if (!assetDetailAsset || typeof assetDetailAsset.id !== 'string') return;
|
|
1871
|
+
var assetId = assetDetailAsset.id;
|
|
1872
|
+
if (!loaded) {
|
|
1873
|
+
showAssetNote('The world is still loading — try again in a moment.');
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
if (voxelSessionActive || voxelSessionPending) {
|
|
1877
|
+
showAssetNote('A voxel edit session is already open — finish it in the toolbar first.');
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
closeAssetDetail();
|
|
1881
|
+
await selectTab('editor');
|
|
1882
|
+
voxelSessionPending = true;
|
|
1883
|
+
setStatus('saving', 'Opening the voxel editor…');
|
|
1884
|
+
voxelStartTimer = setTimeout(function () {
|
|
1885
|
+
voxelStartTimer = null;
|
|
1886
|
+
if (!voxelSessionPending) return;
|
|
1887
|
+
voxelSessionPending = false;
|
|
1888
|
+
setStatus('error', 'No answer from the game — its engine may predate editing assets here. Run "bitmagic upgrade" to update it.');
|
|
1889
|
+
}, VOXEL_START_TIMEOUT_MS);
|
|
1890
|
+
post('EDIT_VOXEL_ASSET', { assetId: assetId });
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
document.getElementById('asset-edit-voxels').addEventListener('click', function () {
|
|
1894
|
+
void startVoxelEditFromOverlay();
|
|
1895
|
+
});
|
|
1772
1896
|
assetResetButton.addEventListener('click', function () {
|
|
1773
1897
|
if (assetFrame.contentWindow) {
|
|
1774
1898
|
assetFrame.contentWindow.postMessage({ type: 'RESET_VIEW' }, window.location.origin);
|
|
@@ -1968,7 +2092,15 @@ ${ASSET_DETAIL_HTML}
|
|
|
1968
2092
|
stopLoop();
|
|
1969
2093
|
var gen = ++generation;
|
|
1970
2094
|
boot(gen).then(function () {
|
|
1971
|
-
if (gen
|
|
2095
|
+
if (gen !== generation) return;
|
|
2096
|
+
runLoop();
|
|
2097
|
+
// Here rather than in boot(): a boot's own status lines are reserved for the boot, and this
|
|
2098
|
+
// one has to survive applyTab()'s "Ready" to be seen at all. A FAILED boot keeps its own
|
|
2099
|
+
// message — that failure explains the loss better than this line would.
|
|
2100
|
+
if (voxelSessionWasLost && loaded) {
|
|
2101
|
+
voxelSessionWasLost = false;
|
|
2102
|
+
setStatus('error', 'The game reloaded — voxel edits that were not saved are gone.');
|
|
2103
|
+
}
|
|
1972
2104
|
});
|
|
1973
2105
|
}
|
|
1974
2106
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-page.js","sourceRoot":"","sources":["../../src/editor/shell-page.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ome. */
|
|
20
20
|
voxelize?: VoxelizeGlb;
|
|
21
21
|
/**
|
|
22
|
-
* Ask for
|
|
23
|
-
*
|
|
22
|
+
* Ask for a mesh rather than voxels (`--mesh`). The voxel path is the default; a vendored engine
|
|
23
|
+
* too old to bake a master takes the mesh path regardless of this.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
mesh?: boolean;
|
|
26
|
+
/** Skip the paid generation and bake this voxel master instead — the voxel path's `--glb-url`. */
|
|
27
|
+
masterUrl?: string;
|
|
26
28
|
/**
|
|
27
|
-
* Grid to forge the master at (`--voxel-grid`)
|
|
28
|
-
*
|
|
29
|
+
* Grid to forge the master at (`--voxel-grid`); defaults to `DEFAULT_MASTER_GRID`. Has no
|
|
30
|
+
* meaning on the mesh path, which the command refuses rather than ignoring.
|
|
29
31
|
*/
|
|
30
32
|
voxelGrid?: number;
|
|
31
33
|
now?: () => Date;
|
package/dist/generate/model.js
CHANGED
|
@@ -8,8 +8,8 @@ import { DEFAULT_MASTER_GRID, engineSupportsVxlMaster, messageOf } from './prop.
|
|
|
8
8
|
import { isJsonObject, readWorldJson } from '../project/world-json.js';
|
|
9
9
|
/**
|
|
10
10
|
* The wire types. `prop` is the api-server generator that turns a prompt into a mesh; see the file
|
|
11
|
-
* header for why this command does not define one of its own. `prop-voxel` is
|
|
12
|
-
*
|
|
11
|
+
* header for why this command does not define one of its own. `prop-voxel` is the sibling that
|
|
12
|
+
* skips the mesh, and the default.
|
|
13
13
|
*/
|
|
14
14
|
const MESH_GENERATOR_TYPE = 'prop';
|
|
15
15
|
const VOXEL_GENERATOR_TYPE = 'prop-voxel';
|
|
@@ -39,15 +39,19 @@ export async function generateAndInstallModel(options) {
|
|
|
39
39
|
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
40
40
|
let source;
|
|
41
41
|
if (options.glbUrl !== undefined) {
|
|
42
|
-
// An explicit retry
|
|
42
|
+
// An explicit retry names its own source: the caller has one in hand and asked for it.
|
|
43
43
|
log(`Reusing the mesh at ${options.glbUrl} — skipping generation.`);
|
|
44
44
|
source = { kind: 'glb', glbUrl: options.glbUrl };
|
|
45
45
|
}
|
|
46
|
+
else if (options.masterUrl !== undefined) {
|
|
47
|
+
log(`Reusing the voxel master at ${options.masterUrl} — skipping generation.`);
|
|
48
|
+
source = { kind: 'master', masterUrl: options.masterUrl };
|
|
49
|
+
}
|
|
46
50
|
else {
|
|
47
51
|
source = await generateSource({
|
|
48
52
|
context, environment, token, prompt, fetchImpl, log,
|
|
49
53
|
...(options.creatorPrompt !== undefined ? { creatorPrompt: options.creatorPrompt } : {}),
|
|
50
|
-
|
|
54
|
+
mesh: options.mesh === true,
|
|
51
55
|
...(options.voxelGrid !== undefined ? { voxelGrid: options.voxelGrid } : {}),
|
|
52
56
|
});
|
|
53
57
|
}
|
|
@@ -100,7 +104,7 @@ export async function generateAndInstallModel(options) {
|
|
|
100
104
|
/**
|
|
101
105
|
* Step 1: buy a source to bake.
|
|
102
106
|
*
|
|
103
|
-
*
|
|
107
|
+
* The voxel master by default, falling back to the mesh on any failure — the same fork and the
|
|
104
108
|
* same two-way split as `generate prop`. A GENERATION failure falls through (and may already have
|
|
105
109
|
* been billed, since the Forger charges on acceptance); anything after that is the caller's
|
|
106
110
|
* problem to report, not a reason to buy a second source.
|
|
@@ -112,7 +116,13 @@ async function generateSource(options) {
|
|
|
112
116
|
prompt,
|
|
113
117
|
...(options.creatorPrompt !== undefined ? { creatorPrompt: options.creatorPrompt } : {}),
|
|
114
118
|
};
|
|
115
|
-
|
|
119
|
+
// Said out loud, because it is the one way onto the mesh path without asking for it — see the
|
|
120
|
+
// matching branch in prop.ts.
|
|
121
|
+
if (!options.mesh && !engineSupportsVxlMaster(context.root)) {
|
|
122
|
+
log('This project\'s vendored engine cannot bake a voxel master — using the mesh path. '
|
|
123
|
+
+ 'Run `bitmagic upgrade` to get the newer engine.');
|
|
124
|
+
}
|
|
125
|
+
else if (!options.mesh) {
|
|
116
126
|
let outcome = null;
|
|
117
127
|
try {
|
|
118
128
|
// `body` plus the grid, never `body` itself: it is reused for the mesh fallback below, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/generate/model.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EACL,sBAAsB,EAAE,aAAa,EAAE,oBAAoB,GAE5D,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,oBAAoB,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/generate/model.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EACL,sBAAsB,EAAE,aAAa,EAAE,oBAAoB,GAE5D,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAA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E,QAAQ,EAAE,SAAS,EAAE,CAAC;QACvC,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,GAAG,CAAC,qDAAqD,OAAO,CAAC,OAAO,KAAK;kBACzE,+EAA+E,CAAC,CAAC;QACvF,CAAC;QACD,GAAG,CAAC,gCAAgC,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,WAAW,EAAE,KAAK,EAAE,mBAAmB,EAAE,IAAI,EACnF,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,MAAM,IAAI,QAAQ,CAAC,GAAG,OAAO,CAAC,OAAO,2BAA2B,CAAC,CAAC;IACxF,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,QAAQ,CAAC,+EAA+E,CAAC,CAAC;IACtG,CAAC;IACD,GAAG,CAAC,mBAAmB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AACjD,CAAC"}
|
package/dist/generate/prop.d.ts
CHANGED
|
@@ -70,19 +70,21 @@ export interface GenerateAndInstallOptions {
|
|
|
70
70
|
creatorPrompt?: string;
|
|
71
71
|
/** Skip the paid generation and voxelize this mesh instead — how a failed run is retried. */
|
|
72
72
|
glbUrl?: string;
|
|
73
|
+
/** Skip the paid generation and bake this voxel master instead — the same, for the voxel path. */
|
|
74
|
+
masterUrl?: string;
|
|
73
75
|
fetchImpl?: typeof globalThis.fetch;
|
|
74
76
|
log: (message: string) => void;
|
|
75
77
|
/** See PropVoxelizeOptions.session. */
|
|
76
78
|
session?: typeof withVoxelizeSession;
|
|
77
79
|
/**
|
|
78
|
-
* Ask for
|
|
79
|
-
*
|
|
80
|
-
*
|
|
80
|
+
* Ask for a mesh rather than voxels (`--mesh`). The voxel path is the default; this is the way
|
|
81
|
+
* back to the source that has no resolution ceiling. A vendored engine too old to bake a master
|
|
82
|
+
* takes the mesh path regardless of this.
|
|
81
83
|
*/
|
|
82
|
-
|
|
84
|
+
mesh?: boolean;
|
|
83
85
|
/**
|
|
84
|
-
* Grid to forge the master at (`--voxel-grid`)
|
|
85
|
-
*
|
|
86
|
+
* Grid to forge the master at (`--voxel-grid`); defaults to {@link DEFAULT_MASTER_GRID}. Has no
|
|
87
|
+
* meaning on the mesh path, which the command refuses rather than ignoring.
|
|
86
88
|
*/
|
|
87
89
|
voxelGrid?: number;
|
|
88
90
|
}
|
package/dist/generate/prop.js
CHANGED
|
@@ -17,22 +17,32 @@
|
|
|
17
17
|
* 3. Upsert the result into `assets[]` under the SAME id, which is what upgrades every already
|
|
18
18
|
* placed instance instead of adding a second asset beside them.
|
|
19
19
|
*
|
|
20
|
-
* Step 1 has two sources
|
|
20
|
+
* Step 1 has two sources:
|
|
21
21
|
*
|
|
22
|
-
* - `prop` returns a GLB. The engine then voxelizes it and throws the mesh away — which is all
|
|
23
|
-
* a 50-100 MB textured model was ever for here.
|
|
24
22
|
* - `prop-voxel` returns an HFVX voxel master directly from TRELLIS.2's own voxel field, no mesh
|
|
25
23
|
* at any point. Measured on staging: 219 KB and ~8.5s warm, against minutes and megabytes.
|
|
24
|
+
* This is the DEFAULT, in every environment.
|
|
25
|
+
* - `prop` returns a GLB. The engine then voxelizes it and throws the mesh away — which is all
|
|
26
|
+
* a 50-100 MB textured model was ever for here. Reachable with `--mesh`, and still what a
|
|
27
|
+
* project gets when its vendored engine is too old to bake a master.
|
|
28
|
+
*
|
|
29
|
+
* The voxel path was opt-in until 2026-08-20, behind `--direct-voxels` and the `dev` environment.
|
|
30
|
+
* The reason it was opt-in was written here, and it is worth keeping because it is also the reason
|
|
31
|
+
* it no longer is: the mesh path is what every existing asset in every project was made with, so
|
|
32
|
+
* until the voxel path's output had been compared against it on real prompts, making it the
|
|
33
|
+
* default would have changed what `generate prop` produces for everyone before anyone had judged
|
|
34
|
+
* whether the change was an improvement. That comparison has now been made, and the path has been
|
|
35
|
+
* hardened by what it turned up — masters forge at grid 512 rather than 128, so the stored
|
|
36
|
+
* original is worth re-baking from; `assets revoxelize` reads its floor off the master instead of
|
|
37
|
+
* the previous bake; and a bake that gets coarsened to fit the renderer's leaf budget says so
|
|
38
|
+
* rather than silently doubling.
|
|
26
39
|
*
|
|
27
|
-
* `
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* every project was made with, so until the voxel path's output has been compared against it on
|
|
31
|
-
* real prompts, making it the default would change what `generate prop` produces for everyone on
|
|
32
|
-
* dev before anyone had judged whether the change is an improvement.
|
|
40
|
+
* `--mesh` remains, because the two sources are not interchangeable in one respect: a mesh is
|
|
41
|
+
* resolution-independent, so it is the only source a later re-voxelize can take arbitrarily
|
|
42
|
+
* finer. A master can only ever be resampled coarser than the grid it was forged at.
|
|
33
43
|
*
|
|
34
44
|
* The generated source survives a failure in steps 2-3: it is reported in the error so a retry can
|
|
35
|
-
* be pointed at it rather than paying for the generation twice.
|
|
45
|
+
* be pointed at it — `--glb-url` or `--master-url` — rather than paying for the generation twice.
|
|
36
46
|
*/
|
|
37
47
|
import * as fs from 'fs';
|
|
38
48
|
import * as path from 'path';
|
|
@@ -158,13 +168,33 @@ export async function generateAndInstallProp(options) {
|
|
|
158
168
|
});
|
|
159
169
|
return { ...reused, glbUrl: options.glbUrl };
|
|
160
170
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
// The same, for the voxel path. Both retries exist so that a bake failure after a PAID
|
|
172
|
+
// generation costs the browser step again and not the generation.
|
|
173
|
+
if (options.masterUrl !== undefined) {
|
|
174
|
+
log(`Reusing the voxel master at ${options.masterUrl} — skipping generation.`);
|
|
175
|
+
const reused = await voxelizeAndInstall({
|
|
176
|
+
context, environment, token, assetId, prompt,
|
|
177
|
+
source: { kind: 'master', masterUrl: options.masterUrl },
|
|
178
|
+
log, ...(options.session ? { session: options.session } : {}),
|
|
179
|
+
});
|
|
180
|
+
return { ...reused, masterUrl: options.masterUrl };
|
|
181
|
+
}
|
|
182
|
+
if (options.mesh !== true) {
|
|
183
|
+
// Said out loud, because it is the one way to end up on the mesh path without asking for it.
|
|
184
|
+
// Every other route here announces itself, and a creator whose docs describe a voxel asset
|
|
185
|
+
// has nothing else to connect that to what they got.
|
|
186
|
+
if (!engineSupportsVxlMaster(context.root)) {
|
|
187
|
+
log('This project\'s vendored engine cannot bake a voxel master — using the mesh path. '
|
|
188
|
+
+ 'Run `bitmagic upgrade` to get the newer engine.');
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const viaVoxels = await tryVoxelMasterPath({ ...options, fetchImpl });
|
|
192
|
+
if (viaVoxels)
|
|
193
|
+
return viaVoxels;
|
|
194
|
+
// Only a GENERATION failure falls through — a bake failure throws out of tryVoxelMasterPath,
|
|
195
|
+
// because re-generating would pay twice for a source we already have.
|
|
196
|
+
log('Falling back to the mesh path.');
|
|
197
|
+
}
|
|
168
198
|
}
|
|
169
199
|
const outcome = await requestGeneration(environment, token, MESH_GENERATOR_TYPE, { gameId: context.metadata.gameId, prompt, ...(options.creatorPrompt !== undefined ? { creatorPrompt: options.creatorPrompt } : {}) }, { fetch: fetchImpl, onProgress: log });
|
|
170
200
|
if (!outcome.success)
|
|
@@ -249,9 +279,8 @@ export async function voxelizeAndInstall(options) {
|
|
|
249
279
|
}
|
|
250
280
|
: {
|
|
251
281
|
subject: 'the voxels',
|
|
252
|
-
// No --master-url retry flag exists yet; saying so beats implying one.
|
|
253
282
|
what: `The generated voxel master is kept at ${source.masterUrl}`,
|
|
254
|
-
retry: '
|
|
283
|
+
retry: ' — retry with `--master-url` to skip the paid generation step.',
|
|
255
284
|
};
|
|
256
285
|
return runSession({
|
|
257
286
|
context, environment, token, log, subject: kept.subject, retryHint: `${kept.what}${kept.retry}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop.js","sourceRoot":"","sources":["../../src/generate/prop.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prop.js","sourceRoot":"","sources":["../../src/generate/prop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AAGxE;;;;GAIG;AACH,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC,+DAA+D;AAC/D,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAY1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACzD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAC3G,CAAC;AAyED,+FAA+F;AAC/F,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAA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K;YAClB,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACxC,CAAC;QAEF,MAAM,YAAY,GAA0B;YAC1C,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,SAAS,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO;YACnE,KAAK,EAAE,QAAQ;SAChB,CAAC;QACF,yBAAyB,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAErD,OAAO;YACL,OAAO;YACP,SAAS;YACT,GAAG,CAAC,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,aAAa,EAAE,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;SAC9C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/publish/bundle.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* The configs the scaffold vendors alongside `engine/`, one per bundle mode.
|
|
3
|
+
*
|
|
4
|
+
* The default leaves three.js, Rapier and the rest of the import map's packages to the CDN, which
|
|
5
|
+
* is what every production publish from the Creator does. The standalone one inlines them, for a
|
|
6
|
+
* game that has to run with no network at all.
|
|
7
|
+
*/
|
|
2
8
|
export declare const VITE_PUBLISH_CONFIG = "vite.publish.config.js";
|
|
9
|
+
export declare const VITE_PUBLISH_STANDALONE_CONFIG = "vite.publish-standalone.config.js";
|
|
10
|
+
/** The vendored config a build of this mode loads. */
|
|
11
|
+
export declare function publishConfigFor(singleFile: boolean): string;
|
|
3
12
|
/**
|
|
4
13
|
* What was built, and from what.
|
|
5
14
|
*
|
|
@@ -9,6 +18,15 @@ export declare const VITE_PUBLISH_CONFIG = "vite.publish.config.js";
|
|
|
9
18
|
export interface BuildManifest {
|
|
10
19
|
engineVersion: string;
|
|
11
20
|
fingerprint: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether this bundle inlines the CDN packages (`--single-file`) or leaves them external.
|
|
23
|
+
*
|
|
24
|
+
* Recorded because nothing else can tell the two apart. The mode changes no file on disk, so it
|
|
25
|
+
* does not move the fingerprint — and `publish` reuses a build on the fingerprint alone. Without
|
|
26
|
+
* this field, `bitmagic publish --single-file` straight after a default build would happily ship
|
|
27
|
+
* the external one, and the reverse.
|
|
28
|
+
*/
|
|
29
|
+
singleFile: boolean;
|
|
12
30
|
bytes: number;
|
|
13
31
|
/** Recorded for the publish audit trail. The server stores it; it cannot verify it. */
|
|
14
32
|
sha256: string;
|
|
@@ -23,15 +41,24 @@ export declare function writeBuildManifest(root: string, manifest: BuildManifest
|
|
|
23
41
|
/** The last build's manifest, or null if there is none to trust — same contract as readVerifyRecord. */
|
|
24
42
|
export declare function readBuildManifest(root: string): BuildManifest | null;
|
|
25
43
|
/**
|
|
26
|
-
* Compile and bundle the project into one
|
|
44
|
+
* Compile and bundle the project into one HTML file, and record what was built.
|
|
45
|
+
*
|
|
46
|
+
* One file either way — `bitmagic publish` PUTs a single object and api-server range-reads that
|
|
47
|
+
* same object to confirm the meta block, so there is nowhere for a second file to go. What the
|
|
48
|
+
* mode changes is what is INSIDE it: by default the engine, the game and its data are inlined
|
|
49
|
+
* while three.js, Rapier and the other CDN packages are fetched at runtime, matching what the
|
|
50
|
+
* Creator publishes; `singleFile` inlines those too, for a game that must run with no network.
|
|
27
51
|
*
|
|
28
52
|
* Exit code 1 on failure, matching the table in the spec: a build failure is the creator's own
|
|
29
53
|
* code, and the compiler's output has already been printed.
|
|
30
54
|
*
|
|
31
|
-
* The pre-flight below runs BEFORE `tsc`, not after: a project scaffolded before
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
55
|
+
* The pre-flight below runs BEFORE `tsc`, not after: a project scaffolded before the config it
|
|
56
|
+
* needs existed has none for vite to load, and without this check the creator pays a full
|
|
57
|
+
* type-check and then reads a raw vite "config not found" that names no remedy. `bitmagic upgrade`
|
|
58
|
+
* is the remedy — it vendors the file without touching game code — so the error says so. It names
|
|
59
|
+
* the config for the mode actually asked for, since a project can easily have one and not the
|
|
60
|
+
* other: the standalone config was added later than the default one.
|
|
36
61
|
*/
|
|
37
|
-
export declare function runBuild(root: string, engineVersion: string
|
|
62
|
+
export declare function runBuild(root: string, engineVersion: string, options?: {
|
|
63
|
+
singleFile?: boolean;
|
|
64
|
+
}): BuildManifest;
|