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 + ) }); }