使用 A-Frame `state` 组件时如何重置为初始状态?

How to reset to initial state when using A-Frame `state` component?

如果我按照说明进行操作 here 并且我的游戏会随时间改变状态,我该如何重置状态?

这是我尝试的无效伪代码:

AFRAME.scenes[0].systems.state.state.game = AFRAME.scenes[0].systems.state.initialState.game;

或者可能无法从组件中获取初始设置,相反我应该在我的项目中创建一个全局常量,例如 initialStateMine,状态组件使用它来进行初始化以及另一个函数来重置状态?

是的,将初始状态保存在变量中。那么如果你想替换 Object.assign(state, initialState);