Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates: This post has converted to draft, the below issues will be fixed in standalone PRs
(Editor: Defers Commands initialization #28360)(Editor: Creates stub command during restore #28398)SetGeometryCommand
failed to UNDO/REDO (Editor: Fixed SetGeometryCommand failed to UNDO/REDO #28361)SetMaterialXXXCommand
are failed to UNDO/REDO (Editor: Fixed material-related commands #28362)The issues and solutions:
Issue 1: Commands don't respect current recovery mechanics:
A placeholder command is created in (A), however, some commands don't handle this case, i.e. commands may throw at (A), or some states may wrongly be assigned to
undefined
if they depends on constructor parameters but now missing, in this case the error will be thrown when Undo/Redo instead.To reproduce:
Cannot read properties of undefined (reading 'color')
in console.This PR fixed that by unifying all commands to have a guard in constructor in order to respect the recovery mechanics:
Issue 2:
SetGeometryCommand
failed to UNDO/REDOBecause it wrongly serializes
oldGeometry
as current object's geometry.To reproduce:
This PR fixed that by serializing it as
this.oldGeometry.toJSON()
Isseu 3: All material related commands
SetMaterialXXXCommand
are failed to UNDO/REDOIn execute() and undo(), the material is referencing to the one cached at construction time, it may not be the same material that materialChanged signal is dispatching for.
This PR fixed that by getting material via given
object, materialSlot
in execute() and undo(), instead of using cached one, s.t. it must be the same material as the one materialChanged is dispatching for:Issue 4: History entries don't honor newly changed locale
When enabled persistent history, then make some changes, then changes SETTINGS>Language, then refresh the page; The history entries will be shown in previous language, not the current language.
The cause is that command name is restored from json, not re-computed during recovery, so it won't respect current editor's language settings.
This PR doesn't fixed this issue. I'll submit another PR after this PR get merged
How to test
Make sure that 'persistent' is checked in SETTINGS>HISTORY section
Create new project (File>New Project>Empty)
Make changes, see below (editor will create commands for history)
Refresh the page (make sure states have been stored to IndexedDB before doing so, i.e. wait at least 0.5s :D)
Press Edit>Undo n times until no available Undos
(in order to test commands' undo())
Press Edit>Redo n times until no available Redos
(in order to test commands' execute())
Make changes to test
AddObjectCommand
:Make changes to test
AddScriptCommand
:Make changes to test
MoveObjectCommand
:Make changes to test
MultiCmdsCommand
:(n/a, this command currently has no consumers; should work :D)
Make changes to test
RemoveObjectCommand
:Make changes to test
RemoveScriptCommand
:Make changes to test
SetColorCommand
:Make changes to test
SetGeometryCommand
:Make changes to test
GeometryValueCommand
:Make changes to test
SetMaterialColorCommand
:Make changes to test
SetMaterialCommand
:Make changes to test
SetMaterialRangeCommand
:Make changes to test
SetMaterialValueCommand
:Make changes to test
SetMaterialVectorCommand
:Make changes to test
SetPositionCommand
:Make changes to test
SetRotationCommand
:Make changes to test
SetScaleCommand
:Make changes to test
SetSceneCommand
:(tbd; should work :D)
Make changes to test
SetScriptValueCommand
:Make changes to test
SetUuidCommand
:Make changes to test
SetValueCommand
:Thank You for Your Patience
👏