@womp/mesh-editor 0.1.8 → 0.1.10
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
CHANGED
|
@@ -23,6 +23,10 @@ await open_edit_session({
|
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
Return `false` from `on_commit` when the host cancels its import dialog. The session
|
|
27
|
+
stays open with its edits and undo history. Rejected promises display an error
|
|
28
|
+
and also keep the session open for retry.
|
|
29
|
+
|
|
26
30
|
`root_class` scopes the semantic `--womp-mesh-editor-*` theme tokens documented
|
|
27
31
|
in `docs/ui-theming.md`. Omit it to retain the default appearance.
|
|
28
32
|
|
|
@@ -10,12 +10,15 @@ export interface OpenEditSessionOptions {
|
|
|
10
10
|
symmetry_enabled?: boolean;
|
|
11
11
|
symmetry_vertical?: boolean;
|
|
12
12
|
symmetry_horizontal?: boolean;
|
|
13
|
-
|
|
13
|
+
initial_tessellation?: boolean;
|
|
14
|
+
commit_notice?: string;
|
|
15
|
+
on_commit?: (result: EditSessionCommitResult) => void | boolean | Promise<void | boolean>;
|
|
14
16
|
}
|
|
15
17
|
export type EditSessionCommitResult = {
|
|
16
18
|
action: "commit";
|
|
17
19
|
mode: "edit";
|
|
18
20
|
mesh: EditableMesh;
|
|
21
|
+
changed: boolean;
|
|
19
22
|
};
|
|
20
23
|
export type EditSessionResult = {
|
|
21
24
|
action: "cancel";
|
|
@@ -786,6 +786,13 @@ export async function open_edit_session(options) {
|
|
|
786
786
|
dirtyState.hidden = true;
|
|
787
787
|
headingRow.append(title, dirtyState);
|
|
788
788
|
heading.append(modeLabel, headingRow);
|
|
789
|
+
if (options.commit_notice) {
|
|
790
|
+
const notice = document.createElement("div");
|
|
791
|
+
notice.setAttribute("role", "note");
|
|
792
|
+
notice.style.cssText = "font-size:11px;line-height:1.4;color:var(--editor-muted);max-width:420px";
|
|
793
|
+
notice.textContent = options.commit_notice;
|
|
794
|
+
heading.appendChild(notice);
|
|
795
|
+
}
|
|
789
796
|
const headerActions = document.createElement("div");
|
|
790
797
|
headerActions.className = "womp-mesh-editor-header-actions";
|
|
791
798
|
const undoButton = button("Undo", "Undo the last mesh edit (Ctrl/Cmd+Z).");
|
|
@@ -1435,12 +1442,20 @@ export async function open_edit_session(options) {
|
|
|
1435
1442
|
set_busy(true);
|
|
1436
1443
|
set_status("Apply changes", "Preparing the edited mesh...", "running", true);
|
|
1437
1444
|
try {
|
|
1445
|
+
const mesh = await editor.prepare_commit_async();
|
|
1438
1446
|
const result = {
|
|
1439
1447
|
action: "commit",
|
|
1440
1448
|
mode: "edit",
|
|
1441
|
-
mesh
|
|
1449
|
+
mesh,
|
|
1450
|
+
changed: editor.is_dirty(),
|
|
1442
1451
|
};
|
|
1443
|
-
await options.on_commit?.(result);
|
|
1452
|
+
const accepted = await options.on_commit?.(result);
|
|
1453
|
+
if (accepted === false) {
|
|
1454
|
+
set_status("Mesh editing", "Mesh tools are ready.", "idle");
|
|
1455
|
+
set_busy(false);
|
|
1456
|
+
commitButton.focus();
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1444
1459
|
editor.accept_commit();
|
|
1445
1460
|
close(result);
|
|
1446
1461
|
}
|
|
@@ -1456,7 +1471,12 @@ export async function open_edit_session(options) {
|
|
|
1456
1471
|
window.addEventListener("blur", on_window_blur);
|
|
1457
1472
|
try {
|
|
1458
1473
|
set_status("Opening", "Preparing mesh tools...", "running", true);
|
|
1459
|
-
|
|
1474
|
+
if (options.initial_tessellation === false) {
|
|
1475
|
+
editor.open(options.editable_mesh);
|
|
1476
|
+
}
|
|
1477
|
+
else {
|
|
1478
|
+
editor.open_with_initial_tessellation(options.editable_mesh);
|
|
1479
|
+
}
|
|
1460
1480
|
configure_radius_control();
|
|
1461
1481
|
update_tool_context(activeTool);
|
|
1462
1482
|
update_brush();
|