layered three view
game object geometries layer
This commit is contained in:
@@ -12,30 +12,11 @@ export class WorldState {
|
||||
|
||||
private _buildSave(): World {
|
||||
const d = this.data;
|
||||
return {
|
||||
objectTypes: toJS(d.objectTypes),
|
||||
voxelTypes: toJS(d.voxelTypes),
|
||||
editorCamera: toJS(d.editorCamera),
|
||||
gameRules: toJS(d.gameRules),
|
||||
initialScene: {
|
||||
playerObjectId: d.initialScene.playerObjectId,
|
||||
objects: Object.fromEntries(
|
||||
Object.entries(d.initialScene.objects).map(([id, obj]) => [id, {
|
||||
id: obj.id,
|
||||
typeId: obj.typeId,
|
||||
physics: obj.physics,
|
||||
gravityScale: obj.gravityScale,
|
||||
position: toJS(obj.position),
|
||||
rotation: toJS(obj.rotation),
|
||||
scale: toJS(obj.scale),
|
||||
} satisfies ObjectInstance])
|
||||
),
|
||||
},
|
||||
};
|
||||
return toJS(d);
|
||||
}
|
||||
|
||||
private startAutoSave() {
|
||||
return autorun(() => WorldFactory.save(this._buildSave()), { delay: 500 });
|
||||
return autorun(() => this.save(), { delay: 500 });
|
||||
}
|
||||
|
||||
private withoutAutoSave(fn: () => void) {
|
||||
@@ -105,6 +86,9 @@ export class WorldState {
|
||||
position: [0, -1, 0],
|
||||
rotation: [0, 0, 0],
|
||||
scale: [1, 1, 1],
|
||||
visible: true,
|
||||
linearVelocity: [0, 0, 0],
|
||||
angularVelocity: [0, 0, 0],
|
||||
},
|
||||
...objectMap,
|
||||
},
|
||||
@@ -128,6 +112,7 @@ export class WorldState {
|
||||
}
|
||||
|
||||
public save(): void {
|
||||
console.log('Saving world...');
|
||||
WorldFactory.save(this._buildSave());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user