39 lines
914 B
TypeScript
39 lines
914 B
TypeScript
import type { World } from "../types";
|
|
|
|
export class WorldFactory {
|
|
|
|
public static create(): World {
|
|
return {
|
|
objectTypes: [],
|
|
intialScene: {
|
|
character: {
|
|
position: [0, 0, 0],
|
|
look: [0, 0, 0],
|
|
},
|
|
objects: [],
|
|
},
|
|
state: {
|
|
playing: false,
|
|
},
|
|
gameRules: {
|
|
gravity: true,
|
|
},
|
|
editorCamera: {
|
|
position: [0, 5, 10],
|
|
look: [0, 0, 0],
|
|
},
|
|
}
|
|
}
|
|
|
|
public static load(): World | undefined {
|
|
const json = localStorage.getItem("world");
|
|
if (json) {
|
|
return JSON.parse(json) as World;
|
|
}
|
|
}
|
|
|
|
public static save(world: World): void {
|
|
localStorage.setItem("world", JSON.stringify(world));
|
|
}
|
|
}
|