From 3c59bb1fe5e2ccc9dcffe95025f4dce0895f7179 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 14 Apr 2026 01:56:53 +0200 Subject: [PATCH] Update buildRuntimeControlSurface to include scheduler state and handle duplicate actor IDs --- src/runtime-three/runtime-scene-build.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/runtime-three/runtime-scene-build.ts b/src/runtime-three/runtime-scene-build.ts index d74fcdb2..607cc47e 100644 --- a/src/runtime-three/runtime-scene-build.ts +++ b/src/runtime-three/runtime-scene-build.ts @@ -858,6 +858,7 @@ interface RuntimeSceneCollections { entities: RuntimeEntityCollection; localLights: RuntimeLocalLightCollection; npcDefinitions: RuntimeNpcDefinition[]; + scheduler: RuntimeResolvedProjectScheduleState; } function buildRuntimeControlSurface( @@ -869,6 +870,20 @@ function buildRuntimeControlSurface( const channels: RuntimeControlSurfaceDefinition["channels"] = []; const resolved = createEmptyRuntimeResolvedControlState(); const defaultSource = createDefaultResolvedControlSource(); + const seenActorIds = new Set(); + + for (const npc of collections.npcDefinitions) { + if (seenActorIds.has(npc.actorId)) { + continue; + } + + seenActorIds.add(npc.actorId); + targets.push( + createControlTargetDescriptor(createActorControlTargetRef(npc.actorId), [ + "actorPresence" + ]) + ); + } for (const pointLight of collections.localLights.pointLights) { const target = createLightControlTargetRef( @@ -1006,7 +1021,10 @@ function buildRuntimeControlSurface( return createRuntimeControlSurfaceDefinition({ targets, channels, - resolved + resolved: applyRuntimeProjectScheduleToControlState( + resolved, + collections.scheduler + ) }); }