From 74c2f509e2152334b3e9d9f8f91f647afc1289d8 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Thu, 3 Feb 2022 19:58:55 +0100 Subject: [PATCH] Extrude and Shape geometries #112 --- src/geometries/ExtrudeGeometry.ts | 14 ++++++++++++++ src/geometries/ShapeGeometry.ts | 14 ++++++++++++++ src/geometries/index.ts | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 src/geometries/ExtrudeGeometry.ts create mode 100644 src/geometries/ShapeGeometry.ts diff --git a/src/geometries/ExtrudeGeometry.ts b/src/geometries/ExtrudeGeometry.ts new file mode 100644 index 0000000..a83bdff --- /dev/null +++ b/src/geometries/ExtrudeGeometry.ts @@ -0,0 +1,14 @@ +import { PropType } from 'vue' +import { geometryComponent } from './Geometry' +import { ExtrudeGeometry, ExtrudeGeometryOptions, Shape } from 'three' + +export const props = { + shapes: { type: [Object, Array] as PropType }, + options: { type: Object as PropType }, +} as const + +export function createGeometry(comp: any): ExtrudeGeometry { + return new ExtrudeGeometry(comp.shapes, comp.options) +} + +export default geometryComponent('ExtrudeGeometry', props, createGeometry) diff --git a/src/geometries/ShapeGeometry.ts b/src/geometries/ShapeGeometry.ts new file mode 100644 index 0000000..6f1cb88 --- /dev/null +++ b/src/geometries/ShapeGeometry.ts @@ -0,0 +1,14 @@ +import { PropType } from 'vue' +import { geometryComponent } from './Geometry' +import { Shape, ShapeGeometry } from 'three' + +export const props = { + shapes: { type: [Object, Array] as PropType }, + curveSegments: { type: Number }, +} as const + +export function createGeometry(comp: any): ShapeGeometry { + return new ShapeGeometry(comp.shapes, comp.curveSegments) +} + +export default geometryComponent('ShapeGeometry', props, createGeometry) diff --git a/src/geometries/index.ts b/src/geometries/index.ts index 290e579..dd76f8f 100644 --- a/src/geometries/index.ts +++ b/src/geometries/index.ts @@ -5,6 +5,7 @@ export { default as CircleGeometry } from './CircleGeometry' export { default as ConeGeometry } from './ConeGeometry' export { default as CylinderGeometry } from './CylinderGeometry' export { default as DodecahedronGeometry } from './DodecahedronGeometry' +export { default as ExtrudeGeometry } from './ExtrudeGeometry' export { default as IcosahedronGeometry } from './IcosahedronGeometry' export { default as LatheGeometry } from './LatheGeometry' export { default as OctahedronGeometry } from './OctahedronGeometry' @@ -12,6 +13,7 @@ export { default as PlaneGeometry } from './PlaneGeometry' export { default as PolyhedronGeometry } from './PolyhedronGeometry' export { default as RingGeometry } from './RingGeometry' export { default as SphereGeometry } from './SphereGeometry' +export { default as ShapeGeometry } from './ShapeGeometry' export { default as TetrahedronGeometry } from './TetrahedronGeometry' export { default as TorusGeometry } from './TorusGeometry' export { default as TorusKnotGeometry } from './TorusKnotGeometry'