diff --git a/types/components/meshes/Extrude.d.ts b/types/components/meshes/Extrude.d.ts new file mode 100644 index 000000000..74b1906e8 --- /dev/null +++ b/types/components/meshes/Extrude.d.ts @@ -0,0 +1,105 @@ +import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + BufferGeometry, + CurvePath, + ExtrudeGeometry, + Mesh, + Shape, + Vector +} from 'three'; + +interface ExtrudeParams extends MeshComponentParams { + + /** Geometry parameters */ + geometry: { + shapes: Shape | Array, + options?: { + /** + * Number of points on the curves. + * Default is 12. + */ + curveSegments?: number; + + /** + * Number of points used for subdividing segments along the depth of the extruded spline. + * Default is 1. + */ + steps?: number; + + /** + * Depth to extrude the shape. Default is 100. + */ + amount?: number; + + /** + * Apply beveling to the shape. + * Default is true. + */ + bevelEnabled?: boolean; + + /** + * How deep into the original shape the bevel goes. + * Default is 6. + */ + bevelThickness?: number; + + /** + * Distance from the shape outline that the bevel extends. + * Default is bevelThickness minus 2. + */ + bevelSize?: number; + + /** + * Number of bevel layers. + * Default is 3. + */ + bevelSegments?: number; + + /** + * A 3D spline path along which the shape should be extruded (creates Frames if frames aren't defined). + */ + extrudePath?: CurvePath; + + /** + * An object containing arrays of tangents, normals, binormals for each step along the extrudePath. + */ + frames?: Object; + + /** + * An object that provides UV generator functions + */ + UVGenerator?: Object; + } + }; + + /** + * Whether to create buffered geometry or not. + * Default is false. + */ + buffer?: boolean; +} + +interface ExtrudeParamsOptions { + +} + + export class Extrude extends MeshComponent { + + /** + * @constructor Creates an extruded geometry from a path shape. + * @param params parameters + */ + constructor(params?: ExtrudeParams); + + /** + * Build lifecycle creates a mesh using input params. + * @param params + */ + build(params?: ExtrudeParams): Mesh; + + /** + * Builds the geometry + * @param params + */ + buildGeometry(params?: ExtrudeParams): ExtrudeGeometry | BufferGeometry; +} diff --git a/types/components/meshes/Group.d.ts b/types/components/meshes/Group.d.ts new file mode 100644 index 000000000..cc11feab3 --- /dev/null +++ b/types/components/meshes/Group.d.ts @@ -0,0 +1,21 @@ +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + +import {Object3D} from 'three'; + + export class Group extends MeshComponent { + + /** + * @constructor Creates a Group of meshes + * @param objects spread Meshes + */ + constructor(...objects: Array); + + /** + * Returns a new Object3D + */ + build(): Object3D; + +} diff --git a/types/components/meshes/index.d.ts b/types/components/meshes/index.d.ts index 09b9b6dcb..1f9c91692 100644 --- a/types/components/meshes/index.d.ts +++ b/types/components/meshes/index.d.ts @@ -1,6 +1,7 @@ export * from './Box'; export * from './Cone'; -export * from './Cylinder' +export * from './Cylinder'; +export * from './Group'; export * from './Dodecahedron'; export * from './Extrude'; export * from './Sphere'; diff --git a/types/core/Component.d.ts b/types/core/Component.d.ts index 2abde689c..7fe6a64e1 100644 --- a/types/core/Component.d.ts +++ b/types/core/Component.d.ts @@ -11,11 +11,11 @@ export class Component extends ModuleSystem { constructor(params?: object, defaults?: object, instructions?: object); /** - * Adds this object to the App. + * Adds this object to a Component (App ,etc) * Notes: As we work in 3D space - we have an App and objects it contains. - * The App is the parent, objects are its children. + * The App is usually the top the parent, objects are its children. */ - addTo(parent: App): Promise; + addTo(parent: App | Component): Promise; /** * Adds a child Component. diff --git a/types/core/MeshComponent.d.ts b/types/core/MeshComponent.d.ts index 5d343891f..d78302297 100644 --- a/types/core/MeshComponent.d.ts +++ b/types/core/MeshComponent.d.ts @@ -2,7 +2,8 @@ import {Component} from './Component'; import {CompositionError} from './errors'; import { Material, - Mesh + Mesh, + Object3D } from 'three'; interface MeshComponentParams { @@ -65,7 +66,7 @@ export class MeshComponent extends Component { /** * @throws a CompositionError. */ - build(): CompositionError | Mesh | Promise; + build(): CompositionError | Mesh | Promise | Object3D; /** * @returns a Promised mesh component diff --git a/types/whs-tests.ts b/types/whs-tests.ts index 7fec23a40..729dbe21b 100644 --- a/types/whs-tests.ts +++ b/types/whs-tests.ts @@ -18,6 +18,7 @@ import { Cone, CubeCamera, Extrude, + Group, OrthographicCamera, PerspectiveCamera, Sphere @@ -142,6 +143,12 @@ extrude = new Extrude({ } }); +let group = new Group(); +const object3D = group.build(); +sphere.addTo(group); + +group = new Group(extrude, cone); + // Cameras const cubeCamera = new CubeCamera({