silphius/app/react-components/pixi.jsx

47 lines
921 B
React
Raw Normal View History

2024-06-10 22:42:30 -05:00
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}
2024-06-11 02:24:45 -05:00
width={RESOLUTION.x}
height={RESOLUTION.y}
2024-06-10 22:42:30 -05:00
options={{
background: 0x1099bb,
}}
>
<Ecs />
</Stage>
);
}