5.4.0

CatmullRomCurve3

Allows you to make smooth 3D lines using Catmull-Rom curves.

The cientos package provides a <CatmullRomCurve3 /> component that allows you to make smooth(ish) 3D lines.

<CatmullRomCurve3 /> wraps Three.js's CatmullRomCurve3 functionality, but applies it to Cientos' <Line2 /> under the hood, meaning you can use all the props from <Line2 />.

Usage

<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { CatmullRomCurve3 } from '@tresjs/cientos'
import { Vector3 } from 'three'
</script>

<template>
  <TresCanvas>
    <TresPerspectiveCamera :position="[3, 3, 3]" />
    <CatmullRomCurve3
      :points="[new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 0, 0)]"
      :segments="50"
      color="orange"
      :line-width="3"
    />
    <TresAmbientLight />
  </TresCanvas>
</template>

Props

PropTypeDescriptionDefault
pointsArray<Vector3 | [number, number, number]>Curve's control points
segmentsnumberNumber of segments in the resulting curve (higher = smoother)20
closedbooleanThe curve will loop back onto itself when this is true.false
curveType'centripetal' | 'chordal' | 'catmullrom'Curve type'centripetal'
tensionnumberCatmullrom's tension, when curveType is 'catmullrom'0.5
vertexColorsTresColor[]Vertex colors, if usingnull
colorTresColorColor for the line – multiplies vertex colors'white'
lineWidthnumberWidth of the line – in world units with size attenuation, pixels otherwise1
worldUnitsbooleanWhether the line width is in world units or pixelsfalse
alphaToCoveragebooleanEnables alpha to coverage. Can only be used with MSAA-enabled contexts (meaning when the renderer was created with antialias parameter set to true).false
dashedbooleanWhether the line is dashedfalse
dashSizenumberDash size1
gapSizenumberGap size in dashed line1
dashScalenumberScale of the dashes/gaps1
dashOffsetnumberDash offset0