order | category | sourcePath | name | type | componentSignature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2.2 |
@threlte/extras |
packages/extras/src/lib/components/HTML/HTML.svelte |
<HTML> |
component |
|
This component is a port of drei's <Html>
component. It allows you to tie HTML content to any object of your scene. It will be projected to the objects whereabouts automatically.
<script lang="ts">
import { HTML } from '@threlte/extras'
</script>
<HTML>
<h1>Hello World</h1>
</HTML>
transform
applies matrix3d transformations.
<script lang="ts">
import { HTML } from '@threlte/extras'
</script>
<HTML transform>
<h1>Hello World</h1>
</HTML>
<Html>
can be occluded behind geometry using the occlude occlude
property.
<script lang="ts">
import { HTML } from '@threlte/extras'
</script>
<HTML
transform
occlude
>
<h1>Hello World</h1>
</HTML>
Use the property occlude
and bind to the event visibilitychange
to implement a custom hide/show behaviour.
<script lang="ts">
import { HTML } from '@threlte/extras'
const onVisibilityChange = (isVisible: boolean) => {
console.log(isVisible)
}
</script>
<HTML
transform
occlude
on:visibilitychange={onVisibilityChange}
>
<h1>Hello World</h1>
</HTML>
Use the property sprite
in transform
mode to render the contents of <HTML>
as a sprite.
<script lang="ts">
import { HTML } from '@threlte/extras'
</script>
<HTML
transform
sprite
>
<h1>Hello World</h1>
</HTML>
Add a -50%/-50% css transform with center
when not in transform
mode.
<script lang="ts">
import { HTML } from '@threlte/extras'
</script>
<HTML center>
<h1>Hello World</h1>
</HTML>
Use the property portal
to mount the contents of the <HTML>
component on another HTMLElement
.
By default the contents are mounted as a sibling to the rendering <canvas>
.
<script lang="ts">
import { HTML } from '@threlte/extras'
</script>
<HTML portal={document.body}>
<h1>Hello World</h1>
</HTML>