react-javelin
v1.1.9
Published
Handy react helpers for @javelin/ecs
Downloads
4
Maintainers
Readme
react-javelin
React helpers for @javelin
ECS
These are specially usefull when composing deeply nested components with something like @react-three/fiber
Usage 👍
Use react as a declarative interface to write your game entities and components into jsx markup
Codesandbox: Physics & Falling Boxes Example
export default function App() {
return (
<Canvas shadows className="whole-canvas" style={{ position: "absolute" }}>
<WorldProvider
world={createWorld({
systems: [PhysicsSystem, RandomBoxFountainSystem],
})}
>
<Scene />
<OrbitControls enablePan={true} enableZoom={true} enableRotate={true} />
<Monitor query={queries.randomBoxes}>{({ entityId }) => <Box />}</Monitor>
</WorldProvider>
</Canvas>
);
}
Includes 🔋
Monitor
— render an array components matching a query.
WorldProvider
— create your ecs "world" instanceEntityProvider
— reference a specific entity, useful for deeply nested components
useWorld
— access the world from anywhere in the app, via theWorldProvider
useTopic
— add a Topic to the worlduseSystem
— drop in a systemuseMonitor
— provides a list of entities that matches a queryuseEntity
— returns an entity from theEntityProvider