Added some other basic inputs to see how continuous changes of various values affect the component render

This commit is contained in:
Rezmason
2025-05-15 03:06:19 -07:00
parent 45059c4e29
commit 24e939008e
2 changed files with 56 additions and 21 deletions

View File

@@ -105,13 +105,15 @@ import makeConfig from "./utils/config";
/** @param {MatrixProps} props */
export const Matrix = memo((props) => {
const { style, className, ...rest } = props;
const { style, className, ...rawConfigProps } = props;
const elProps = { style, className };
const matrix = useRef(null);
const [rCanvas, setCanvas] = useState(null);
const [rRenderer, setRenderer] = useState(null);
const [rRain, setRain] = useState(null);
const configProps = Object.fromEntries(Object.entries(rawConfigProps).filter(([_, value]) => value != null));
const supportsWebGPU = () => {
return (
window.GPUQueue != null &&
@@ -137,7 +139,7 @@ export const Matrix = memo((props) => {
};
useEffect(() => {
const useWebGPU = supportsWebGPU() && ["webgpu"].includes(rest.renderer?.toLowerCase());
const useWebGPU = supportsWebGPU() && ["webgpu"].includes(configProps.renderer?.toLowerCase());
const isWebGPU = rRenderer?.type === "webgpu";
if (rRenderer != null && useWebGPU === isWebGPU) {
@@ -168,7 +170,7 @@ export const Matrix = memo((props) => {
return;
}
const refresh = async () => {
await rRenderer.formulate(rRain, makeConfig({ ...rest }));
await rRenderer.formulate(rRain, makeConfig(configProps));
};
refresh();
}, [props, rRain]);