workspaces folders

This commit is contained in:
azykov@mail.ru
2026-06-12 11:46:14 +03:00
parent 88b36988ff
commit 36f76efdd7
102 changed files with 0 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { type RuntimeWorld, type World } from "../types";
import { depopulateRuntimeWorld, populateRuntimeWorld } from "../utils/runtime";
import { DEFAULT_VOXEL_TYPES } from "./defaultVoxelTypes";
export class WorldFactory {
public static create(): RuntimeWorld {
return populateRuntimeWorld({
objectTypes: {},
voxelTypes: DEFAULT_VOXEL_TYPES,
initialScene: {
objects: {},
},
gameRules: {
gravity: true,
},
editorCamera: {
position: [0, 5, 10],
look: [0, 0, 0],
},
});
}
public static load(): RuntimeWorld | undefined {
const json = localStorage.getItem("world");
if (json) {
return populateRuntimeWorld(JSON.parse(json) as World);
}
}
public static save(world: RuntimeWorld): void {
localStorage.setItem("world", JSON.stringify(depopulateRuntimeWorld(world)));
}
}