Sampler ^3.7.0
Declarative abstraction around MeshSurfaceSampler & InstancedMesh. It samples points from the passed mesh and transforms an InstancedMesh's matrix to distribute instances on the points.
Usage
Experience.vue
vue
<script setup lang="ts">
import { OrbitControls, Sampler } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
</script>
<template>
<TresCanvas clear-color="#82DBC5">
<TresPerspectiveCamera :position="[0, 0.5, 5]" />
<OrbitControls />
<Sampler :count="50">
<TresMesh>
<TresTorusGeometry />
</TresMesh>
<TresInstancedMesh :args="[null!, null!, 1000]">
<TresBoxGeometry :args="[0.1, 0.1, 0.1]" />
<TresMeshNormalMaterial />
</TresInstancedMesh>
</Sampler>
<TresGridHelper :args="[10, 10]" />
</TresCanvas>
</template>
Props
Props | Description |
---|---|
mesh | Mesh Surface mesh from which to sample |
count | Number Number of samples |
instanceMesh | InstanceMesh InstanceMesh to scatter |
weight | String A vertex attribute to be used as a weight when sampling |
transform | Function A function that can be used as a custom sampling |