@threlte/extras
useTexture
useTexture
is a convenience hook wrapping useLoader
that returns an AsyncWritable
store populated
with a THREE.Texture
.
<script>
import { T } from '@threlte/core'
import { useTexture } from '@threlte/extras'
const map = useTexture('texture.png')
$: console.log($map) // eventually THREE.Texture
</script>
{#await map then value}
<T.Mesh>
<T.SphereGeometry />
<T.MeshBasicMaterial map={value} />
</T.Mesh>
{/await}