not sure its better or not
This commit is contained in:
+4
-3
@@ -20,16 +20,17 @@ export const entityAnimateMap = new Map<string, Animate<Indirect>>();
|
||||
export const entityProcessMap = new Map<string, Process<Indirect>>();
|
||||
|
||||
export function useEntity<T extends object>(
|
||||
name: string,
|
||||
data: T,
|
||||
meta: { url: string },
|
||||
state: T,
|
||||
): {
|
||||
animate: (fn: Animate<T>) => void;
|
||||
process: (fn: Process<T>) => void;
|
||||
} {
|
||||
const name = meta.url.match(/entities\/(.+)\/entity\.ts$/)![1];
|
||||
entityMap.set(name, {
|
||||
name,
|
||||
position: createVector(),
|
||||
...data,
|
||||
...state,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ export const sceneGraph: Graph<string> = new Map();
|
||||
|
||||
export const [loadScene, sceneCache] = useWithAsyncCache(
|
||||
async (name: string) => {
|
||||
await import(`#/scenes/${name}/index.ts`);
|
||||
await import(`#/scenes/${name}/scene.ts`);
|
||||
|
||||
const data = sceneDataMap.get(name)!;
|
||||
const entityInstanceMap = sceneEntiyMap.get(name)!;
|
||||
@@ -56,7 +56,7 @@ export const [loadScene, sceneCache] = useWithAsyncCache(
|
||||
|
||||
await Promise.all(
|
||||
data.entities.map(async (entity: Entity<unknown>) => {
|
||||
await import(`#/entities/${entity.name}/index.ts`);
|
||||
await import(`#/entities/${entity.name}/entity.ts`);
|
||||
|
||||
if (!entityInstanceMap.has(entity.name)) {
|
||||
entityInstanceMap.set(entity.name, {
|
||||
|
||||
Reference in New Issue
Block a user