layered three view

game object geometries layer
This commit is contained in:
azykov@mail.ru
2026-06-19 20:54:27 +03:00
parent 076cded364
commit 579fe36e6c
31 changed files with 521 additions and 219 deletions
+6 -21
View File
@@ -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());
}