-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add cylinder component + docs
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Cylinder <Badge type="warning" text="^4.0.0" /> | ||
|
||
![](/cientos/cylinder.png) | ||
|
||
The `cientos` package provides a `<Cylinder />` component that serves as a short-cut for a `CylinderGeometry` and a `MeshBasicMaterial` with a `Mesh` object. | ||
|
||
``` | ||
args: [ | ||
radiusTop: number, | ||
radiusBottom: number, | ||
height: number, | ||
radialSegments: number, | ||
heightSegments: number, | ||
openEnded: boolean, | ||
thetaStart: number, | ||
thetaLength: number | ||
] | ||
``` | ||
|
||
Reference: [CylinderGeometry](https://threejs.org/docs/?q=cylinder#api/en/geometries/CylinderGeometry) | ||
|
||
## Usage | ||
|
||
```vue | ||
<Cylinder :args="[1, 1, 1, 32, 1, false, 0, Math.PI * 2]" color="orange" /> | ||
// Cylinder with a custom material transformations | ||
<Cylinder ref="cylinderRef" :args="[1, 1, 1, 32, 1, false, 0, Math.PI * 2]" :position="[0, 4, 0]"> | ||
<TresMeshToonMaterial color="orange" /> | ||
</Cylinder> | ||
``` | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script setup lang="ts"> | ||
import type { TresColor } from '@tresjs/core' | ||
Check failure on line 2 in src/core/shapes/Cylinder.vue GitHub Actions / Lint (18)
|
||
import type { CylinderGeometry } from 'three' | ||
Check failure on line 3 in src/core/shapes/Cylinder.vue GitHub Actions / Lint (18)
|
||
import { shallowRef, toRefs } from 'vue' | ||
Check failure on line 4 in src/core/shapes/Cylinder.vue GitHub Actions / Lint (18)
|
||
export interface CylinderProps { | ||
/** | ||
* The radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength of the cylinder. | ||
* @default [1, 1, 1, 32, 1, false, 0, Math.PI * 2] | ||
* @type {any[]} | ||
* @memberof CylinderProps | ||
* @see https://threejs.org/docs/#api/en/geometries/CylinderGeometry | ||
*/ | ||
args?: ConstructorParameters<typeof CylinderGeometry> | ||
/** | ||
* The color of the cylinder. | ||
* @default 0xffffff | ||
* @type {TresColor} | ||
* @memberof CylinderProps | ||
* @see https://threejs.org/docs/#api/en/materials/MeshBasicMaterial | ||
*/ | ||
color?: TresColor | ||
} | ||
const props = withDefaults(defineProps<CylinderProps>(), { | ||
args: () => [1, 1, 1, 32, 1, false, 0, Math.PI * 2], | ||
color: '#ffffff', | ||
}) | ||
const { args, color } = toRefs(props) | ||
const cylinderRef = shallowRef() | ||
defineExpose({ | ||
value: cylinderRef, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<TresMesh ref="cylinderRef" v-bind="$attrs"> | ||
<TresCylinderGeometry :args="args" /> | ||
<slot> | ||
<TresMeshBasicMaterial :color="color" /> | ||
</slot> | ||
</TresMesh> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters