feature request: duplicate project
I would like to duplicate a public project and then work off of it. Ok if I take a crack at this?
@anton-pascal any thoughts before I start implementing it?
Hey @kleenkanteen, thanks for the interest! Happy to share some thoughts on how this could work.
The editor package itself is client-side only — it doesn't handle project storage or CRUD directly. The scene data is a SceneGraph ({ nodes, rootNodeIds }) that the host app manages via the onSave callback and the applySceneGraphToEditor() function.
So "duplicate project" would need to happen at the host/integration level rather than inside the editor package. That said, there are a couple of things the editor could expose to make this easier:
-
Scene serialization — we already have
SceneGraphas a clean export type andapplySceneGraphToEditor()to load it. AgetSceneGraph()/ snapshot utility that deep-clones the current scene with fresh node IDs would be the main editor-side contribution. -
ID regeneration — when duplicating, all node IDs need to be regenerated while preserving parent-child relationships (buildings → levels → walls/items/zones etc). This is the tricky part since references between nodes (e.g. items attached to walls, zones referencing levels) need to be remapped correctly.
-
The actual "duplicate" button/flow — this would live in the host app, not the editor package, since it involves creating a new project record in whatever backend the host uses.
If you want to contribute to the editor package specifically, the most useful piece would be a cloneSceneGraph(sceneGraph: SceneGraph): SceneGraph utility in packages/core that:
- Deep clones all nodes
- Generates new UUIDs for every node
- Remaps all internal references (parentId, children arrays, etc.)
- Returns a clean SceneGraph ready to be saved as a new project
Would you like to take that approach? Happy to review a PR.
@anton-pascal Thanks for the guidance, I'll take a crack at it asap
@anton-pascal Are new UUIDs for every node necessary to achieve duplication? My understanding is that it's not if these 2 cases are true:
- The backend does not require all UUIDs to be globally unique
- The frontend only loads in one scene at a time
Given this, does it still make sense to create a cloneSceneGraph util?
Good question! You're right that if both of those hold, a plain deep clone would technically work without ID conflicts.
That said, I'd still recommend regenerating IDs as the default behavior for a few reasons:
-
Host app assumptions vary — we can't know what backends consumers use. Some might store node IDs globally (across projects) for analytics, cross-project references, or collaboration features. Same IDs in two projects would break those.
-
Future-proofing — even if a host app only loads one scene at a time today, features like project comparison, merge, or multi-tab editing could surface later. Unique IDs across projects keep that door open.
-
It's the safer default — generating fresh UUIDs is cheap, and it means the cloned scene is truly independent with no hidden coupling to the original.
That said, we could make it a parameter: cloneSceneGraph(scene, { regenerateIds?: boolean }) defaulting to true. That way hosts that know they don't need it can skip the remapping. But I'd still implement the full ID regeneration + reference remapping as the primary path since that's where the real utility value is.
Does that make sense? Happy to answer more questions as you dig in.
Will take a shot at it then. Btw am curious do you pass my questions through a llm first?
@anton-pascal ready for review: #178
Resolved by #178 — cloneSceneGraph() is now available as a public export from @pascal-app/core.