@womp/mesh-editor 0.1.9 → 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.
|
@@ -10,12 +10,15 @@ export interface OpenEditSessionOptions {
|
|
|
10
10
|
symmetry_enabled?: boolean;
|
|
11
11
|
symmetry_vertical?: boolean;
|
|
12
12
|
symmetry_horizontal?: boolean;
|
|
13
|
+
initial_tessellation?: boolean;
|
|
14
|
+
commit_notice?: string;
|
|
13
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,10 +1442,12 @@ 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
1452
|
const accepted = await options.on_commit?.(result);
|
|
1444
1453
|
if (accepted === false) {
|
|
@@ -1462,7 +1471,12 @@ export async function open_edit_session(options) {
|
|
|
1462
1471
|
window.addEventListener("blur", on_window_blur);
|
|
1463
1472
|
try {
|
|
1464
1473
|
set_status("Opening", "Preparing mesh tools...", "running", true);
|
|
1465
|
-
|
|
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
|
+
}
|
|
1466
1480
|
configure_radius_control();
|
|
1467
1481
|
update_tool_context(activeTool);
|
|
1468
1482
|
update_brush();
|