Skip to content

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.

3 participants