decentraland / decentraland/builder

Templates implementation proposal

Open
#2,630 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
156
Forks
91
Avg merge
2d 7h
Merged PRs (30d)
31

Description

This is a rough implementation proposal to support templates on the Scene Builder.

1. The scenes should be made using the Builder itself, and exported as .zip files using the regular export feature of the Builder. From this .zip file we would extract the `builder.json`. The contents of this file are what we call a `Manifest` (this is a type in the Builder codebase).

2. We could host these jsons that represent the template scenes on the frontend of the builder itself, by placing them under the `public` folder, ie: `public/templates/nice-house-template.json`

3. Finally when we want to create a scene from a template, we could create a saga that does the following:
- Fetches the json from the public folder, ie: `fetch(process.env.PUBLIC_URL + '/templates/nice-house-template.json')`
- Parses the json, and it assigns a new uuid to the `project` and `scene` properties (which are part of the manifest), same way as we do [when we import a new project].(https://github.com/decentraland/builder/blob/master/src/components/Modals/ImportModal/ImportModal.tsx#L129-L131).. Also update the `updatedAt` and `createdAt` properties [like we do here](https://github.com/decentraland/builder/blob/master/src/components/Modals/ImportModal/ImportModal.tsx#L118-L119).
- Bonus track: we would probably want to run migrations on the manifests. This will not be necessary now, but if we change the schema of the `Manifest` in the future and the json that we are hosting are outdated this would solve it. [We can copy that](https://github.com/decentraland/builder/blob/master/src/components/Modals/ImportModal/ImportModal.tsx#L112) from the import modal too.
- Lastly it just needs to call the `IMPORT_PROJECT` saga [that already exists](https://github.com/decentraland/builder/blob/master/src/modules/project/sagas.ts#L209-L217) passing the `Manifest` that we just fetched and modified. This should create a new project/scene for the user with the given template.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.