forked from schteppe/p2.js
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sandbox): remove use of @arancini/systems
- Loading branch information
1 parent
08a99c0
commit c911c92
Showing
29 changed files
with
318 additions
and
355 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
export * from './entity' | ||
export * from './context' | ||
export * from './pointer-system' | ||
export * from './renderer-systems' | ||
export * from './tool-systems' | ||
export * from './utils' | ||
export * from './world' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
import { QueryFn } from 'arancini' | ||
import { useMemo } from 'react' | ||
import { useECS } from './context' | ||
import { Entity } from './entity' | ||
import { react, world } from './world' | ||
|
||
export const useSingletonQuery = <C extends keyof Entity>(component: C) => { | ||
const { | ||
world, | ||
react: { useQuery }, | ||
} = useECS() | ||
export const useQuery = <Q extends QueryFn<any, any>>(queryFn: Q) => { | ||
const query = useMemo(() => world.query(queryFn), [world]) | ||
|
||
const singletonComponentQuery = useMemo(() => world.query((e) => e.has(component)), [world]) | ||
|
||
const query = useQuery(singletonComponentQuery) | ||
|
||
return useMemo(() => query.first?.[component] ?? null, [query.version]) | ||
return react.useQuery(query) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { World } from 'arancini' | ||
import { createReactAPI } from 'arancini/react' | ||
import { Entity } from './entity' | ||
|
||
export const world = new World<Entity>() | ||
export const react = createReactAPI(world) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.