-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { CatmullRomCurve3, OrbitControls } from '@tresjs/cientos' | ||
</script> | ||
|
||
<template> | ||
<TresCanvas v-bind="{clearColor:'#4f4f4f'}"> | ||
Check failure on line 7 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
Check failure on line 7 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
|
||
<CatmullRomCurve3 | ||
:points="[[-1.5,0,0],[-0.5,1,0],[0.5,0,0],[1.5,1,0]]" | ||
Check failure on line 9 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
Check failure on line 9 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
Check failure on line 9 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
Check failure on line 9 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
Check failure on line 9 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
Check failure on line 9 in docs/.vitepress/theme/components/CatmullRomCurve3Demo.vue GitHub Actions / Lint (16)
|
||
:segments="40" | ||
:line-width="10" | ||
color="#fbb03b" | ||
/> | ||
<TresGridHelper /> | ||
<OrbitControls /> | ||
</TresCanvas> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { OrbitControls, Line2 } from '@tresjs/cientos' | ||
</script> | ||
|
||
<template> | ||
<TresCanvas v-bind="{clearColor:'#4f4f4f'}"> | ||
<Line2 | ||
:points="[[-0.5, 0,0], [0.5, 0, 0] ,[0, 0.8660,0], [-0.5,0,0] ]" | ||
:line-width="10" | ||
color="#82dbc5" | ||
/> | ||
<TresGridHelper /> | ||
<OrbitControls /> | ||
</TresCanvas> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# CatmullRomCurve3 | ||
|
||
<DocsDemo> | ||
<CatmullRomCurve3Demo /> | ||
</DocsDemo> | ||
|
||
The `cientos` package provides a `<CatmullRomCurve3 />` component that allows you to make smooth(ish) 3D lines. | ||
|
||
`<CatmullRomCurve3 />` wraps [Three.js's `CatmullRomCurve3`](https://threejs.org/docs/index.html?q=catmu#api/en/extras/curves/CatmullRomCurve3) functionality, but applies it to Cientos' `<Line2 />` under the hood, meaning you can use [all the props from `<Line2 />`.](line2#props) | ||
|
||
|
||
## Usage | ||
|
||
```vue{3,8-13} | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { CatmullRomCurve3, OrbitControls } from '@tresjs/cientos' | ||
</script> | ||
<template> | ||
<TresCanvas v-bind="{clearColor:'#4f4f4f'}"> | ||
<CatmullRomCurve3 | ||
:points="[[-1.5,0,0],[-0.5,1,0],[0.5,0,0],[1.5,1,0]]" | ||
:segments="40" | ||
:line-width="10" | ||
color="#fbb03b" | ||
/> | ||
<TresGridHelper /> | ||
<OrbitControls /> | ||
</TresCanvas> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
`<CatmullRomCurve3 />` accepts [all of `<Line2 />`'s props and uses the same defaults](line2#props). In addition, it accepts the props below. | ||
|
||
| Prop | Type | Description | Default | | ||
| ------------ | --------- | ----------------------------------------------------------------------------- | -------------- | | ||
| segments | `number` | Number of points to insert between each pair of points in props.points | 20 | | ||
| closed | `boolean` | The curve will loop back onto itself when this is true. | false | | ||
| curveType | `'centripetal' \| 'chordal' \| 'catmullrom'` | Curve type | 'centripetal' | | ||
| tension | `number` | Catmullrom's tension, when curveType is 'catmullrom' | 0.5 | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Line2 | ||
|
||
<DocsDemo> | ||
<Line2Demo /> | ||
</DocsDemo> | ||
|
||
The `cientos` package provides a `<Line2 />` component that wraps [Three.js's `Line2`](https://github.com/mrdoob/three.js/blob/e2bcdfff6427c2f106cb819b18d88d1e13aa508a/examples/jsm/lines/Line2.js). | ||
|
||
## Usage | ||
|
||
```vue{3,8-12} | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import { Line2, OrbitControls } from '@tresjs/cientos' | ||
</script> | ||
<template> | ||
<TresCanvas v-bind="{clearColor:'#888'}"> | ||
<Line2 | ||
:points="[[-0.5,0,0], [0.5,0,0] ,[0,0.8660,0], [-0.5,0,0]]" | ||
:line-width="10" | ||
color="#82dbc5" | ||
/> | ||
<TresGridHelper /> | ||
<OrbitControls /> | ||
</TresCanvas> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
| Prop | Type | Description | Default | | ||
| --------------- | -------------------------|--------------------------------------------------------------------------- | -------------- | | ||
| points | [See below](#points) | Points representing the line | | | ||
| vertexColors | `TresColor[]` | Vertex colors, if using | null | | ||
| color | `TresColor` | Color for the line – multiplies vertex colors | 'white' | | ||
| lineWidth | `number` | Width of the line – in world units with size attenuation, pixels otherwise | 1 | | ||
| worldUnits | `boolean` | Whether the line width is in world units or pixels | false | | ||
| alphaToCoverage | `boolean` | Enables alpha to coverage. Can only be used with MSAA-enabled contexts (meaning when the renderer was created with antialias parameter set to true). | false | | ||
| dashed | `boolean` | Whether the line is dashed | false | | ||
| dashSize | `number` | Dash size | 1 | | ||
| gapSize | `number` | Gap size in dashed line | 1 | | ||
| dashScale | `number` | Scale of the dashes/gaps | 1 | | ||
| dashOffset | `number` | Dash offset | 0 | | ||
|
||
### Points | ||
|
||
The points prop can be any of these types: | ||
|
||
| Type | Interpretation | | ||
| ---------------------------- | -------------------------------------------------------------------------------- | | ||
| `Vector3[]` | Each Vector3 maps to a point's x, y, z. | | ||
| <nobr>`[number, number, number][]`</nobr> | Each entry maps to [x, y, z]. | | ||
| `Vector2[]` | Each Vector2 maps to a point's x and y. z = 0. | | ||
| `[number, number][]` | Each entry maps to [x, y, 0]. | | ||
| `number[]` | An array of [x, y, z, x, y, z, x ...] coordinates. Length should be a multiple of 3. Proper length is not checked. | |