Skip to content

Commit 85229d7

Browse files
authored
Fixes light color assignment (#197)
1 parent 28a7345 commit 85229d7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/yellow-ways-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@playcanvas/react": patch
3+
---
4+
5+
Fixes an issue setting light colors

packages/lib/src/utils/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ export function createComponentDefinition<T, InstanceType>(
314314
`Expected a hex like "#FF0000", CSS color name like "red", or an array "[1, 0, 0]").`,
315315
apply: (instance, props, key) => {
316316
if(typeof props[key] === 'string') {
317-
const color = getColorFromName(props[key] as string) || props[key] as string;
318-
(instance[key as keyof InstanceType] as Color).fromString(color);
317+
const colorString = getColorFromName(props[key] as string) || props[key] as string;
318+
(instance[key as keyof InstanceType] as Color) = new Color().fromString(colorString);
319319
} else {
320-
(instance[key as keyof InstanceType] as Color).fromArray(props[key] as number[]);
320+
(instance[key as keyof InstanceType] as Color) = (instance[key as keyof InstanceType] as Color) = new Color().fromArray(props[key] as number[]);
321321
}
322322
}
323323
};

0 commit comments

Comments
 (0)