Skip to content

Commit e24326d

Browse files
committed
fix: simplify IGameOptions and streamline file loading logic
1 parent 90204ac commit e24326d

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

apps/web/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="stylesheet" href="style.css" />
66
<title>Title</title>
77
</head>
8-
<body>
8+
<body style="margin: 0">
99
<script type="module" src="index.ts"></script>
1010
<div id="nanoforge-loader">
1111
<img id="loader-logo" src="assets/logo.png" alt="logo" />

apps/web/src/loader/loader.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,16 @@ const logger = new Logger("Loader");
88
export const loadGameFiles = async (
99
manifest: IExtendedManifest,
1010
): Promise<[IGameOptions["files"], any]> => {
11-
const files = {
12-
assets: new Map<string, string>(),
13-
wasm: new Map<string, string>(),
14-
wgsl: new Map<string, string>(),
15-
};
11+
const files = new Map<string, string>();
1612
let mainModule = undefined;
1713
logger.info("Starting load game files from cache");
1814
for (const file of manifest.files) {
19-
if (file.path.endsWith(".js")) {
15+
if (file.path === "index.js") {
2016
const resModule = await loadScript(file);
2117
if (resModule) mainModule = resModule;
2218
continue;
2319
}
24-
if (file.path.endsWith(".wasm")) {
25-
files.wasm.set(file.path, file.localPath);
26-
} else if (file.path.endsWith(".wgsl")) {
27-
files.wgsl.set(file.path, file.localPath);
28-
} else {
29-
files.assets.set(file.path, file.localPath);
30-
}
20+
files.set(file.path, file.localPath);
3121
}
3222
if (!mainModule) throw new Error("Could not find main function");
3323
logger.info("Game files loaded");

apps/web/src/types/game.type.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
export interface IGameOptions {
22
canvas: HTMLCanvasElement;
3-
files: {
4-
assets: Map<string, string>;
5-
wasm: Map<string, string>;
6-
wgsl: Map<string, string>;
7-
};
3+
files: Map<string, string>;
84
}

0 commit comments

Comments
 (0)