@threlte/extras
<FakeGlowMaterial>
This component is a port of ektogamat’s <FakeGlowMaterial> r3f component
which displays a glowing outline around a mesh using a custom shader, instead of post-processing.
<script lang="ts">
import { Canvas } from '@threlte/core'
import Scene from './Scene.svelte'
</script>
<div>
<Canvas>
<Scene />
</Canvas>
</div>
<style>
div {
height: 100%;
}
</style>Examples
Basic Example
FakeGlowMaterial.svelte
<script lang="ts">
import { T } from '@threlte/core'
import { FakeGlowMaterial } from '@threlte/extras'
</script>
<T.Mesh>
<FakeGlowMaterial glowColor="red" />
<T.IcosahedronGeometry args={[4, 4]} />
</T.Mesh>This effect is mesh based, meaning you need to provide a mesh for this to work properly. The mesh must also be smooth enough that glsl can calculate the normals properly.
For sharp meshes like a cube, you can use a sphere to simulate the glow, instead of a copy of the cube.
FakeGlowMaterialCube.svelte
<script lang="ts">
import { T } from '@threlte/core'
import { FakeGlowMaterial } from '@threlte/extras'
</script>
<T.Mesh>
<FakeGlowMaterial glowColor="blue" />
<T.BoxGeometry args={[2, 2, 2]} />
</T.Mesh>
<T.Mesh>
<FakeGlowMaterial glowColor="blue" />
<T.IcosahedronGeometry args={[3, 4]} />
</T.Mesh>Component Signature
<FakeGlowMaterial> extends
<T
.
ShaderMaterial>
and supports all its props, slot props, bindings and events.