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.
<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>