Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add <e.custom> #234

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add <e.custom> #234

wants to merge 1 commit into from

Conversation

AndrewPrifer
Copy link
Contributor

@AndrewPrifer AndrewPrifer commented Jun 28, 2022

Solution 2 for the need to create ad-hoc editable r3f components outside what's defined in the schema.

This solution adds a new "custom" property on the editable object.

This allows the "inline" creation of editable versions of r3f components:

<e.custom
  uniqueName="points"
  customComponent="points"
  editableType="mesh"
>
  <torusKnotGeometry args={[1, 0.3, 128, 64]} />
  <meshNormalMaterial />
</e.custom>

This would be equivalent to doing:

// Note: the type system currently disallows this, but the functionality is there.
const EditablePoints = e("points", "mesh")

<EditablePoints
  uniqueName="points"
>
  <torusKnotGeometry args={[1, 0.3, 128, 64]} />
  <meshNormalMaterial />
</EditablePoints>

The above two are possible, since all the editableType does is tell theatre how to interpret props on these components in theatre's prop-type system. As long as a component's props are a superset of the ones required by another component's schema definition (like in this example points is compatible with mesh, since mesh defines the transform props, which points also has), this will work.

@vercel
Copy link

vercel bot commented Jun 28, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
theatre-playground ✅ Ready (Inspect) Visit Preview Jun 28, 2022 at 2:03PM (UTC)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants