From 7bc4ca32935abb0be68b110e054abe3618f76e2a Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Thu, 2 Apr 2026 19:19:15 +0200 Subject: [PATCH] Enhance play animation validation by checking clip existence on model asset --- src/document/scene-document-validation.ts | 66 +++++++++++++++-------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/src/document/scene-document-validation.ts b/src/document/scene-document-validation.ts index 7ee52cfa..ae8a0fe4 100644 --- a/src/document/scene-document-validation.ts +++ b/src/document/scene-document-validation.ts @@ -669,28 +669,52 @@ function validateInteractionLink(link: InteractionLink, path: string, document: } break; case "playAnimation": - // Validate that the target model instance exists in the document - if (document.modelInstances[link.action.targetModelInstanceId] === undefined) { - diagnostics.push( - createDiagnostic( - "error", - "missing-play-animation-target-instance", - `Play animation target model instance ${link.action.targetModelInstanceId} does not exist.`, - `${path}.action.targetModelInstanceId` - ) - ); + { + const targetModelInstance = document.modelInstances[link.action.targetModelInstanceId]; + + if (targetModelInstance === undefined) { + diagnostics.push( + createDiagnostic( + "error", + "missing-play-animation-target-instance", + `Play animation target model instance ${link.action.targetModelInstanceId} does not exist.`, + `${path}.action.targetModelInstanceId` + ) + ); + return; + } + + if (link.action.clipName.trim().length === 0) { + diagnostics.push( + createDiagnostic( + "error", + "invalid-play-animation-clip-name", + "Play animation clip name must be non-empty.", + `${path}.action.clipName` + ) + ); + return; + } + + const targetAsset = document.assets[targetModelInstance.assetId]; + + if (targetAsset === undefined || targetAsset.kind !== "model") { + return; + } + + if (!targetAsset.metadata.animationNames.includes(link.action.clipName)) { + diagnostics.push( + createDiagnostic( + "error", + "missing-play-animation-clip", + `Play animation clip ${link.action.clipName} does not exist on model asset ${targetAsset.id}.`, + `${path}.action.clipName` + ) + ); + } + + break; } - if (link.action.clipName.trim().length === 0) { - diagnostics.push( - createDiagnostic( - "error", - "invalid-play-animation-clip-name", - "Play animation clip name must be non-empty.", - `${path}.action.clipName` - ) - ); - } - break; case "stopAnimation": // Validate that the target model instance exists in the document if (document.modelInstances[link.action.targetModelInstanceId] === undefined) {