silphius/app/react-components/pixi.jsx
2024-06-10 23:55:06 -05:00

47 lines
923 B
JavaScript

import {
Stage as PixiStage,
} from '@pixi/react';
import {RESOLUTION} from '@/constants.js';
import ClientContext from '@/context/client.js';
import Ecs from './ecs.jsx';
import styles from './pixi.module.css';
const ContextBridge = ({ children, Context, render }) => {
return (
<Context.Consumer>
{(value) =>
render(<Context.Provider value={value}>{children}</Context.Provider>)
}
</Context.Consumer>
);
};
export const Stage = ({children, ...props}) => {
return (
<ContextBridge
Context={ClientContext}
render={(children) => <PixiStage {...props}>{children}</PixiStage>}
>
{children}
</ContextBridge>
);
};
export default function Pixi() {
return (
<Stage
className={styles.stage}
width={RESOLUTION[0]}
height={RESOLUTION[1]}
options={{
background: 0x1099bb,
}}
>
<Ecs />
</Stage>
);
}