Skip to content

Commit 2b7e703

Browse files
committed
imp: better undo handling
1 parent 8e903dc commit 2b7e703

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/core/systems/ClientBuilder.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ export class ClientBuilder extends System {
304304
}
305305
}
306306
// undo
307-
if (this.control.keyZ.pressed && (this.control.metaLeft.down || this.control.controlLeft.down)) {
307+
if (
308+
this.control.keyZ.pressed &&
309+
!this.control.shiftLeft.down &&
310+
(this.control.metaLeft.down || this.control.controlLeft.down)
311+
) {
308312
this.undo()
309313
}
310314
// translate updates
@@ -412,9 +416,11 @@ export class ClientBuilder extends System {
412416
const entity = this.world.entities.get(undo.entityId)
413417
if (!entity) return
414418
entity.data.position = undo.position
419+
entity.data.quaternion = undo.quaternion
415420
this.world.network.send('entityModified', {
416421
id: undo.entityId,
417422
position: entity.data.position,
423+
quaternion: entity.data.quaternion,
418424
})
419425
entity.build()
420426
return
@@ -499,6 +505,12 @@ export class ClientBuilder extends System {
499505
}
500506
// select new (if any)
501507
if (app) {
508+
this.addUndo({
509+
name: 'move-entity',
510+
entityId: app.data.id,
511+
position: app.data.position.slice(),
512+
quaternion: app.data.quaternion.slice(),
513+
})
502514
if (app.data.mover !== this.world.network.id) {
503515
app.data.mover = this.world.network.id
504516
app.build()

0 commit comments

Comments
 (0)