Fix loading bug
This commit is contained in:
@@ -203,7 +203,12 @@ export const GraphBrowser: Component<{
|
|||||||
ctx.restore();
|
ctx.restore();
|
||||||
ctx.clearRect(0, 0, canvasRef.width, canvasRef.height);
|
ctx.clearRect(0, 0, canvasRef.width, canvasRef.height);
|
||||||
ctx.save();
|
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(
|
ctx.translate(
|
||||||
width() / 2 - activeRenderNode.position.x,
|
width() / 2 - activeRenderNode.position.x,
|
||||||
height() / 2 - activeRenderNode.position.y,
|
height() / 2 - activeRenderNode.position.y,
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ export const [loadScene, sceneCache] = useWithAsyncCache(
|
|||||||
const entityInstanceMap = sceneEntiyMap.get(name)!;
|
const entityInstanceMap = sceneEntiyMap.get(name)!;
|
||||||
entityInstanceMap.clear();
|
entityInstanceMap.clear();
|
||||||
|
|
||||||
Promise.all(
|
await Promise.all(
|
||||||
data.entities.map(async (entity: Entity<unknown>) => {
|
data.entities.map(async (entity: Entity<unknown>) => {
|
||||||
await import(`#/entities/${entity.name}/index.ts`);
|
await import(`#/entities/${entity.name}/index.ts`);
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -1,10 +1,11 @@
|
|||||||
export function loadImage(src: string): Promise<HTMLImageElement> {
|
export function loadImage(src: string): Promise<HTMLImageElement> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const image = new Image();
|
const image = new Image();
|
||||||
|
|
||||||
image.onload = () => resolve(image);
|
image.onload = () => resolve(image);
|
||||||
image.onerror = () => {
|
image.onerror = (error) => {
|
||||||
console.error(image.src);
|
console.error(error);
|
||||||
return resolve(image);
|
resolve(image);
|
||||||
};
|
};
|
||||||
|
|
||||||
image.src = src;
|
image.src = src;
|
||||||
|
|||||||
Reference in New Issue
Block a user