From 9e17559fc98066db79b02b7ea0c98ae3037ac906 Mon Sep 17 00:00:00 2001 From: Jakob Hock <96245357+JakobHock@users.noreply.github.com> Date: Sun, 9 Jun 2024 22:05:31 +0200 Subject: [PATCH] feat: Add cylinder component * add cylinder component + docs --- docs/component-list/components.ts | 1 + docs/guide/shapes/cylinder.md | 31 ++++++++++++++++++++ docs/public/cientos/cylinder.png | Bin 0 -> 6074 bytes src/core/shapes/Cylinder.vue | 45 ++++++++++++++++++++++++++++++ src/core/shapes/index.ts | 2 ++ 5 files changed, 79 insertions(+) create mode 100644 docs/guide/shapes/cylinder.md create mode 100644 docs/public/cientos/cylinder.png create mode 100644 src/core/shapes/Cylinder.vue diff --git a/docs/component-list/components.ts b/docs/component-list/components.ts index 0328e5d4..59f4f26c 100644 --- a/docs/component-list/components.ts +++ b/docs/component-list/components.ts @@ -68,6 +68,7 @@ export default [ { text: 'CatmullRomCurve3', link: '/guide/shapes/catmullromcurve3' }, { text: 'Circle', link: '/guide/shapes/circle' }, { text: 'Cone', link: '/guide/shapes/cone' }, + { text: 'Cylinder', link: '/guide/shapes/cylinder' }, { text: 'Dodecahedron', link: '/guide/shapes/dodecahedron' }, { text: 'Icosahedron', link: '/guide/shapes/icosahedron' }, { text: 'Line2', link: '/guide/shapes/line2' }, diff --git a/docs/guide/shapes/cylinder.md b/docs/guide/shapes/cylinder.md new file mode 100644 index 00000000..e3578d67 --- /dev/null +++ b/docs/guide/shapes/cylinder.md @@ -0,0 +1,31 @@ +# Cylinder + +![](/cientos/cylinder.png) + +The `cientos` package provides a `` 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 with a custom material transformations + + + +``` \ No newline at end of file diff --git a/docs/public/cientos/cylinder.png b/docs/public/cientos/cylinder.png new file mode 100644 index 0000000000000000000000000000000000000000..f3f2282073425701e7b63fb344e71fde0082aca7 GIT binary patch literal 6074 zcmeHLX;f3!7Ctv2p@czE15~l1BK0u~4p8POgD8TQTw*{HR3@>KqEJPYOBDy8uv!&E zWl(qwuOSdbqeYS1BBTf!tV@(48U#TKq8Lys)7wGmu-^Oe-dgY9;|Gg#&-uwZYc?UIW{(h+^#KKXI?D(-{KIx{@?@d1TZX;xp%(7uC%?c8O?jE}Nsb}l=pUqv&d3q#`L53+|3xXG&{I6sWV-mQ7A?=m*t z=7bO-w0fP0A>@4lT=n}q8+sOr!N)m~OoYyQiNF(gF8H(bXH$e+zs3QYG7X((V48tx z2BsO9X5fFr0B>|?Bzj~WdLy}`>=_Z=+aRB~&l~G(t9dj&Bk|y{ATjp&!`6mFV|QI{ zZFo2yfZog$QzTUutcQnXSE>gOe)ZrR&1IFbw+48|+T`O443cHJz2WwbE|a+SMSP?O zRjqsZ*36(B0^=m%nDF`+R(ZSfl%WlGpH)4%SH7V78g7MZ@0cQL+i=6{#Ok+QTdHV$ z3YW&We&t)%=X2?p9#Ij&B(SF^R^PTj)Z3(%7DtHvqCBPG(`l2@XThp%aS^ZK#faNNQGXTlOnLoPSAege`AMq>%N!?*_bv` z&u1f@wS}eq5QWo7_w8{yF%RN6dT!HwyIFLBE8vU#8Tw20h(pb$C{J#stJF=QDUN{s z@bfu8vSC18#71R4g@P^h1DNw6@RNS(M<3{qf+z!q-_*&2UF6#KU@R7l-Pu_z;P?(q z7zH5b-o`N=a&|2d2r_u1=fxs$XTe!Ea`q?@tdqtr0mKFoN@(uXchO|-l1rz`Oe;r0H?A>A_ea$Urv7#&oo47XNR5fDuE`D|2{gq4Sk;1R z`d}dp=nDg|y>$d*etiIn>ldL9m|U3NAHn3uvXYI$b+MIP8Ykx{>)WO>1f7v!GCqD> zHct1Jp6WF=kic%0Hp*wuz9jbjo>IDAgi=3oO0@K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@2>8W4@=HPXP7~V_H&aIjK4v!P@Tu^3=7h1dP%Qg3^QeG2vv@`OB;9&VN?vpU%N$l9pw zZ%77bH~r?!#$#Z15Mp!yyeqV~0QFyZR9ye;)cFGpCUFJi!@zyqJg_Wb3d1hAZ6OpL8ueO*SH^g03ekLp&9w`mR|xR#JI0MzC@dIs$7SS;*bx zm5E!6cY`y&loZ_nbyF2SNROOH4#sykl+4Et3;KQA{1`Zep zjy30(GkaRw2VMoorQ + import type { TresColor } from '@tresjs/core' + import type { CylinderGeometry } from 'three' + import { shallowRef, toRefs } from 'vue' + + 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 + /** + * 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(), { + args: () => [1, 1, 1, 32, 1, false, 0, Math.PI * 2], + color: '#ffffff', + }) + const { args, color } = toRefs(props) + + const cylinderRef = shallowRef() + + defineExpose({ + value: cylinderRef, + }) + + + diff --git a/src/core/shapes/index.ts b/src/core/shapes/index.ts index c9a9e359..d2dc0e4e 100644 --- a/src/core/shapes/index.ts +++ b/src/core/shapes/index.ts @@ -2,6 +2,7 @@ import Box from './Box.vue' import CatmullRomCurve3 from './CatmullRomCurve3.vue' import Circle from './Circle.vue' import Cone from './Cone.vue' +import Cylinder from './Cylinder.vue' import Dodecahedron from './Dodecahedron.vue' import Icosahedron from './Icosahedron.vue' import Line2 from './Line2.vue' @@ -20,6 +21,7 @@ export { Box, CatmullRomCurve3, Circle, + Cylinder, Cone, Dodecahedron, Icosahedron,