You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
We could and we should support prefabs with overrides.
I was thinking of the following API:
constMyPrefab=prefab("My Prefab",ReactComponentContainingEditables);constMyOtherPrefab=prefab("My Other Prefab",SomeOtherReactComponentContainingEditables);
What happens in the above code is that we create prefabs from two r3f React components. These prefabs themselves are also just React components. These are then registered with the EditableManager in the respective Canvases where they are used. From then on, they can be freely used wherever we want inside the Canvas, and a new instance will be created.
When we open the editor, there will be a separate section for prefabs, where they can be opened and edited. Instances in the normal scene editor will reflect changes made to the prefabs, and they themselves will be editable, with all their editable subelements, which will override the respective transform/property. These overrides can be reset or synced back to the prefab.
How does all this work?
When we create a prefab through the prefab() function, a React component is created. When this component is passed to EditableManager, it renders the prefab component in a portal, which lets it be part of the normal React component hierarchy, gaining access to context, while only actually showing it in the prefabs section of the editor, allowing it to be edited, without actually being part of the scene.
The text was updated successfully, but these errors were encountered:
We could and we should support prefabs with overrides.
I was thinking of the following API:
What happens in the above code is that we create prefabs from two r3f React components. These prefabs themselves are also just React components. These are then registered with the
EditableManager
in the respectiveCanvas
es where they are used. From then on, they can be freely used wherever we want inside theCanvas
, and a new instance will be created.When we open the editor, there will be a separate section for prefabs, where they can be opened and edited. Instances in the normal scene editor will reflect changes made to the prefabs, and they themselves will be editable, with all their editable subelements, which will override the respective transform/property. These overrides can be reset or synced back to the prefab.
How does all this work?
When we create a prefab through the
prefab()
function, a React component is created. When this component is passed toEditableManager
, it renders the prefab component in a portal, which lets it be part of the normal React component hierarchy, gaining access tocontext
, while only actually showing it in the prefabs section of the editor, allowing it to be edited, without actually being part of the scene.The text was updated successfully, but these errors were encountered: