diff --git a/dev/GraphBrowser.tsx b/dev/GraphBrowser.tsx index 690422a..d4ec297 100644 --- a/dev/GraphBrowser.tsx +++ b/dev/GraphBrowser.tsx @@ -203,7 +203,12 @@ export const GraphBrowser: Component<{ ctx.restore(); ctx.clearRect(0, 0, canvasRef.width, canvasRef.height); ctx.save(); - const activeRenderNode = nodes.find((n) => n.name === activeNode)!; + const activeRenderNode = nodes.find((n) => n.name === activeNode); + if (!activeRenderNode) { + setTimeout(animate, 100); + return; + } + ctx.translate( width() / 2 - activeRenderNode.position.x, height() / 2 - activeRenderNode.position.y, diff --git a/engine/Scene.ts b/engine/Scene.ts index bc03167..13ad680 100644 --- a/engine/Scene.ts +++ b/engine/Scene.ts @@ -49,7 +49,7 @@ export const [loadScene, sceneCache] = useWithAsyncCache( const entityInstanceMap = sceneEntiyMap.get(name)!; entityInstanceMap.clear(); - Promise.all( + await Promise.all( data.entities.map(async (entity: Entity) => { await import(`#/entities/${entity.name}/index.ts`); diff --git a/lib/loadImage.ts b/lib/loadImage.ts index 798d4ad..1ff4c0d 100644 --- a/lib/loadImage.ts +++ b/lib/loadImage.ts @@ -1,10 +1,11 @@ export function loadImage(src: string): Promise { return new Promise((resolve) => { const image = new Image(); + image.onload = () => resolve(image); - image.onerror = () => { - console.error(image.src); - return resolve(image); + image.onerror = (error) => { + console.error(error); + resolve(image); }; image.src = src;