Refactor applyControlEffectToResolvedState in control-surface.ts
This commit is contained in:
@@ -897,19 +897,23 @@ export function applyControlEffectToResolvedState(
|
|||||||
return nextResolved;
|
return nextResolved;
|
||||||
}
|
}
|
||||||
case "setLightIntensity": {
|
case "setLightIntensity": {
|
||||||
const nextValue = createResolvedLightIntensityChannelValue({
|
const nextDescriptor = createLightIntensityControlChannelDescriptor({
|
||||||
descriptor: createLightIntensityControlChannelDescriptor({
|
target: effect.target,
|
||||||
target: effect.target,
|
defaultValue: effect.intensity
|
||||||
defaultValue: effect.intensity
|
|
||||||
}),
|
|
||||||
value: effect.intensity,
|
|
||||||
source
|
|
||||||
});
|
});
|
||||||
const descriptorKey = getControlChannelDescriptorKey(nextValue.descriptor);
|
const descriptorKey = getControlChannelDescriptorKey(nextDescriptor);
|
||||||
const existingIndex = nextResolved.channels.findIndex(
|
const existingIndex = nextResolved.channels.findIndex(
|
||||||
(candidate) =>
|
(candidate) =>
|
||||||
getControlChannelDescriptorKey(candidate.descriptor) === descriptorKey
|
getControlChannelDescriptorKey(candidate.descriptor) === descriptorKey
|
||||||
);
|
);
|
||||||
|
const nextValue = createResolvedLightIntensityChannelValue({
|
||||||
|
descriptor:
|
||||||
|
existingIndex >= 0
|
||||||
|
? nextResolved.channels[existingIndex].descriptor
|
||||||
|
: nextDescriptor,
|
||||||
|
value: effect.intensity,
|
||||||
|
source
|
||||||
|
});
|
||||||
|
|
||||||
if (existingIndex >= 0) {
|
if (existingIndex >= 0) {
|
||||||
nextResolved.channels[existingIndex] = nextValue;
|
nextResolved.channels[existingIndex] = nextValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user