@threlte/extras

<HUD>

Renders a heads-up-display (HUD). Each HUD creates a new scene rendered on top of the main scene with a separate Threlte context and camera.

The HUD component creates a partially new Threlte context, specifically a new scene and camera. Everything else in useThrelte is preserved and reused.

Because creating a <HUD> is somewhat similar to creating a <Canvas>, it is recommended to use the same best practices and place all objects you want in the HUD within a new Scene component:

MyHUD.svelte
<script>
  import Scene from './Scene.svelte'
</script>

<HUD>
  <Scene />
</HUD>
Scene.svelte
<script>
  import { T } from '@threlte/core'
</script>

<T.PerspectiveCamera
  makeDefault
  position={[0, 0, 0]}
  on:create={({ ref }) => ref.lookAt(0, 0, 0)}
/>

<T.AmbientLight />

<T.Mesh>
  <T.BoxGeometry />
  <T.MeshStandardMaterial />
</T.Mesh>

Component Signature

Props

name
type
required
description

autoRender
boolean
no
Whether the HUD should automatically render its contents

stage
Stage
no
Defaults to the render stage

toneMapping
THREE.ToneMapping
no
Defaults to the parent context toneMapping