theatre-js / theatre

Motion design editor for the web
https://www.theatrejs.com
Apache License 2.0
10.86k stars 338 forks source link

How to clear the state of a project (originally: make all static programatically) #382

Closed vimlesh1975 closed 1 year ago

vimlesh1975 commented 1 year ago

Is there any method to do it?

gmile commented 1 year ago

@vimlesh1975 could you elaborate what is your use case to give more context?

clementroche commented 1 year ago

I think @vimlesh1975 is asking for a prop static option so you couldn't create a timeline from it, which might be handy. If you set all props as static, Theatre could be seen as a GUI more than an animation tool. I think this can ease the collaboration between developer and animator, so as a developer you could indicate that this props should not be animated.

vimlesh1975 commented 1 year ago

After finishing one project, I want to start new project but objects are same. So I need to reset all animations at one go. https://jsfiddle.net/vimlesh1975/webh6gsx/2/

AriaMinaei commented 1 year ago

@vimlesh1975 hmm, if a project is finished, I'd assume the new project would need a different ID. Would changing the project id help? getProject(newId) I mean.

clementroche commented 1 year ago

delete your state.json and do a localeStorage.clear()

vimlesh1975 commented 1 year ago

@vimlesh1975 hmm, if a project is finished, I'd assume the new project would need a different ID. Would changing the project id help? getProject(newId) I mean.

Yes changing the project id clears everything. So can I do it programatically?

vimlesh1975 commented 1 year ago

Basically I need like const onMousedblclick = (obj, event) => { studio.transaction(({ unset }) => { unset(obj.props); unset(obj.animations); //not available }); };

vimlesh1975 commented 1 year ago

delete your state.json and do a localeStorage.clear() following did the job. Thank you. localStorage.clear(); location.reload();

AriaMinaei commented 1 year ago

Thanks @clementroche! @vimlesh1975 I'll mark this one as solved, but feel free to re-open if the localStorage clearing method isn't enough.