Add playSound and stopSound interaction links

This commit is contained in:
2026-04-02 19:41:37 +02:00
parent b461e31b0b
commit 7424cb7304

View File

@@ -1748,6 +1748,22 @@ export function App({ store, initialStatusMessage }: AppProps) {
targetModelInstanceId: link.action.targetModelInstanceId
});
break;
case "playSound":
nextLink = createPlaySoundInteractionLink({
id: link.id,
sourceEntityId: link.sourceEntityId,
trigger,
targetSoundEmitterId: link.action.targetSoundEmitterId
});
break;
case "stopSound":
nextLink = createStopSoundInteractionLink({
id: link.id,
sourceEntityId: link.sourceEntityId,
trigger,
targetSoundEmitterId: link.action.targetSoundEmitterId
});
break;
}
commitInteractionLinkChange(link, nextLink, `Updated ${getInteractionTriggerLabel(trigger).toLowerCase()} trigger link.`);
@@ -1838,6 +1854,51 @@ export function App({ store, initialStatusMessage }: AppProps) {
return;
}
if (actionType === "playSound" || actionType === "stopSound") {
const targetSoundEmitter =
(link.action.type === "playSound" || link.action.type === "stopSound"
? editorState.document.entities[link.action.targetSoundEmitterId]
: undefined) ?? soundEmitterOptions.find(({ entity }) => {
if (entity.audioAssetId === null) {
return false;
}
const asset = editorState.document.assets[entity.audioAssetId];
return asset?.kind === "audio";
})?.entity;
if (targetSoundEmitter === undefined || targetSoundEmitter.kind !== "soundEmitter") {
setStatusMessage("Author a Sound Emitter with an audio asset before switching this link to sound playback.");
return;
}
if (actionType === "playSound") {
commitInteractionLinkChange(
link,
createPlaySoundInteractionLink({
id: link.id,
sourceEntityId: sourceEntity.id,
trigger: link.trigger,
targetSoundEmitterId: targetSoundEmitter.id
}),
"Switched link action to play sound."
);
} else {
commitInteractionLinkChange(
link,
createStopSoundInteractionLink({
id: link.id,
sourceEntityId: sourceEntity.id,
trigger: link.trigger,
targetSoundEmitterId: targetSoundEmitter.id
}),
"Switched link action to stop sound."
);
}
return;
}
const defaultBrush = visibilityBrushOptions[0]?.brush;
if (defaultBrush === undefined) {