Skip to content

Grid

<Grid /> creates a shader-based grid plane. It has customizable grid cell and section lines, as well as fade out.

Usage

vue
<script setup lang="ts">
import { Grid, OrbitControls } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
</script>

<template>
  <TresCanvas clear-color="#222222">
    <TresPerspectiveCamera :position="[8, 10, 10]" :fov="25" />
    <OrbitControls />
    <Grid
      :args="[10.5, 10.5]"
      cell-color="#82dbc5"
      :cell-size="0.6"
      :cell-thickness="0.5"
      section-color="#fbb03b"
      :section-size="2"
      :section-thickness="1.3"
      :infinite-grid="true"
      :fade-from="0"
      :fade-distance="12"
      :fade-strength="1"
    />
  </TresCanvas>
</template>

Props

PropDescriptionDefault
cellSizeCell size0.5
cellThicknessThickness of cell lines0.5
cellColorColor of cell lines'black'
sectionSizeSection size1
sectionThicknessThickness of section lines1
sectionColorColor of cell lines'blue'
followCameraWhether to follow camerafalse
infiniteGridWhether to display an infinite gridfalse
fadeDistanceFade distance100
fadeStrengthFade strength1
fadeFromFade from camera (1) or origin (0) or in between1
sideMaterial sideTHREE.BackSide