Update handleCommitCreation to return boolean values
This commit is contained in:
@@ -1547,7 +1547,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCommitCreation = (creationPreview: CreationViewportToolPreview) => {
|
const handleCommitCreation = (creationPreview: CreationViewportToolPreview): boolean => {
|
||||||
try {
|
try {
|
||||||
if (creationPreview.target.kind === "box-brush") {
|
if (creationPreview.target.kind === "box-brush") {
|
||||||
const center = creationPreview.center === null ? undefined : creationPreview.center;
|
const center = creationPreview.center === null ? undefined : creationPreview.center;
|
||||||
@@ -1560,7 +1560,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
? `Created a box brush snapped to the ${DEFAULT_GRID_SIZE}m grid.`
|
? `Created a box brush snapped to the ${DEFAULT_GRID_SIZE}m grid.`
|
||||||
: `Created a box brush at snapped center ${formatVec3(center)}.`
|
: `Created a box brush at snapped center ${formatVec3(center)}.`
|
||||||
);
|
);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (creationPreview.target.kind === "model-instance") {
|
if (creationPreview.target.kind === "model-instance") {
|
||||||
@@ -1568,7 +1568,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
|
|
||||||
if (asset === undefined || asset.kind !== "model") {
|
if (asset === undefined || asset.kind !== "model") {
|
||||||
setStatusMessage("Select a model asset before placing a model instance.");
|
setStatusMessage("Select a model asset before placing a model instance.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextModelInstance = createModelInstance({
|
const nextModelInstance = createModelInstance({
|
||||||
@@ -1586,7 +1586,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation(`Placed ${asset.sourceName}.`);
|
completeCreation(`Placed ${asset.sourceName}.`);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const position = creationPreview.center ?? DEFAULT_ENTITY_POSITION;
|
const position = creationPreview.center ?? DEFAULT_ENTITY_POSITION;
|
||||||
@@ -1602,7 +1602,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation("Placed Point Light.");
|
completeCreation("Placed Point Light.");
|
||||||
return;
|
return true;
|
||||||
case "spotLight":
|
case "spotLight":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createUpsertEntityCommand({
|
createUpsertEntityCommand({
|
||||||
@@ -1613,7 +1613,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation("Placed Spot Light.");
|
completeCreation("Placed Spot Light.");
|
||||||
return;
|
return true;
|
||||||
case "playerStart":
|
case "playerStart":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createUpsertEntityCommand({
|
createUpsertEntityCommand({
|
||||||
@@ -1624,7 +1624,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation("Placed Player Start.");
|
completeCreation("Placed Player Start.");
|
||||||
return;
|
return true;
|
||||||
case "soundEmitter": {
|
case "soundEmitter": {
|
||||||
const placedAudioAssetId = creationPreview.target.audioAssetId ?? audioAssetList[0]?.id ?? null;
|
const placedAudioAssetId = creationPreview.target.audioAssetId ?? audioAssetList[0]?.id ?? null;
|
||||||
|
|
||||||
@@ -1642,7 +1642,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
? "Placed Sound Emitter."
|
? "Placed Sound Emitter."
|
||||||
: `Placed Sound Emitter using ${editorState.document.assets[placedAudioAssetId]?.sourceName ?? "the authored audio asset"}.`
|
: `Placed Sound Emitter using ${editorState.document.assets[placedAudioAssetId]?.sourceName ?? "the authored audio asset"}.`
|
||||||
);
|
);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
case "triggerVolume":
|
case "triggerVolume":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
@@ -1654,7 +1654,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation("Placed Trigger Volume.");
|
completeCreation("Placed Trigger Volume.");
|
||||||
return;
|
return true;
|
||||||
case "teleportTarget":
|
case "teleportTarget":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createUpsertEntityCommand({
|
createUpsertEntityCommand({
|
||||||
@@ -1665,7 +1665,7 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation("Placed Teleport Target.");
|
completeCreation("Placed Teleport Target.");
|
||||||
return;
|
return true;
|
||||||
case "interactable":
|
case "interactable":
|
||||||
store.executeCommand(
|
store.executeCommand(
|
||||||
createUpsertEntityCommand({
|
createUpsertEntityCommand({
|
||||||
@@ -1676,11 +1676,13 @@ export function App({ store, initialStatusMessage }: AppProps) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
completeCreation("Placed Interactable.");
|
completeCreation("Placed Interactable.");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setStatusMessage(getErrorMessage(error));
|
setStatusMessage(getErrorMessage(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const commitModelInstanceChange = (currentModelInstance: ModelInstance, nextModelInstance: ModelInstance, successMessage: string) => {
|
const commitModelInstanceChange = (currentModelInstance: ModelInstance, nextModelInstance: ModelInstance, successMessage: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user