Skip to content

Latest commit

 

History

History
50 lines (43 loc) · 1.32 KB

layers.mdx

File metadata and controls

50 lines (43 loc) · 1.32 KB
order category name sourcePath type
5.3
@threlte/extras
layers
packages/extras/src/lib/layers
plugin

layers is a plugin that provides inheritance for the property layers on <T> components. Typically when assigning a value to layers on a <T> component, it will only be applied to that component. This plugin allows you to assign a value to layers on a parent component and have it be inherited by all child components.

This plugin injects and relies on a context. It's affecting all `` components that are descendants of the component that uses it. Check out the [guide on structuring your app](/docs/learn/basics/app-structure) to learn more about contexts.

Usage

<script>
  import { layers } from '@threlte/extras'
  layers()
</script>

<!--
The camera needs to be on the same layer
as an object for the object to be visible
-->
<T.PerspectiveCamera layers={[4, 5]} />

<!--
Everything inside this group that isn't
assigned another layer is on layer 4 and
is therefore visible to the camera
-->
<T.Group layers={4}>
  <T.Mesh>
    <T.BoxGeometry />
    <T.MeshStandardMaterial />
  </T.Mesh>

  <!-- This Mesh is on all layers -->
  <T.Mesh layers={'all'}>
    <T.BoxGeometry />
    <T.MeshStandardMaterial />
  </T.Mesh>
</T.Group>