Visit the Documentation of the upcoming Threlte 6.
  1. @threlte/core
  2. LayerableObject

@threlte/core

LayerableObject

Assignes the layers provided by a parent <Layers> component to a THREE.Object3D.

INFO

This is a trait component. Trait components are mostly used internally and make certain aspects of three.js objects accessible and reactive and interact with Threlte systems.

Import

Source

Github View Source Code

Package

NPM View Package

Basic Example

TIP

You most likely want to use a <MeshInstance> component in this scenario. The component <LayerableObject> is part of the component <Object3DInstance>, which the component <MeshInstance> is extending.

Parent.svelte
<script>
	import { Layers } from '@threlte/core'
</script>

<Layers layers={3}>
	<Child />
</Layers>
Child.svelte
<script>
	import { LayerableObject } from '@threlte/core'
	import { Mesh } from 'three'

	const mesh = new Mesh()
</script>

<!-- The mesh is assigned to layer 3 -->
<LayerableObject object={mesh} />

Properties

// required
object: Object3D