From e3c75e48c99ffc920a45371b95ed83c84f710664 Mon Sep 17 00:00:00 2001 From: Hirako Date: Sat, 29 Jul 2017 17:04:11 +0700 Subject: [PATCH] Brings more consistency and fix a typo etc for mesh types #297 --- types/components/meshes/Box.d.ts | 50 ++++++++++++++++------- types/components/meshes/Cone.d.ts | 8 +++- types/components/meshes/Cylinder.d.ts | 15 ++++--- types/components/meshes/Dodecahedron.d.ts | 6 ++- types/components/meshes/Extrude.d.ts | 9 +++- types/components/meshes/Group.d.ts | 3 +- types/components/meshes/Icosahedron.d.ts | 3 +- types/components/meshes/Importer.d.ts | 3 +- types/components/meshes/Lathe.d.ts | 3 +- types/components/meshes/Line.d.ts | 3 +- types/components/meshes/Octahedron.d.ts | 12 ++++-- types/components/meshes/Parametric.d.ts | 16 +++++++- types/components/meshes/Plane.d.ts | 3 +- types/components/meshes/Polyhedron.d.ts | 15 ++++++- types/components/meshes/Shape.d.ts | 4 +- types/components/meshes/Sphere.d.ts | 9 +++- types/components/meshes/Tetrahedron.d.ts | 9 +++- types/components/meshes/Text.d.ts | 9 +++- types/components/meshes/Torus.d.ts | 9 +++- types/components/meshes/Torusknot.d.ts | 10 ++++- 20 files changed, 148 insertions(+), 51 deletions(-) diff --git a/types/components/meshes/Box.d.ts b/types/components/meshes/Box.d.ts index c9b34fef7..9a6330d1c 100644 --- a/types/components/meshes/Box.d.ts +++ b/types/components/meshes/Box.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { BoxGeometry, BoxBufferGeometry, @@ -9,36 +13,52 @@ interface BoxParams extends MeshComponentParams { /** Geometry parameters */ geometry?: { - /** Width of the sides on the X axis. Default is 1. */ + /** + * Width of the sides on the X axis. + * Default is 1. + */ width?: number; - /** Height of the sides on the Y axis. Default is 1. */ + /** + * Height of the sides on the Y axis. + * Default is 1. + */ height?: number; - /** Depth of the sides on the Z axis. Default is 1. */ + /** + * Depth of the sides on the Z axis. + * Default is 1. + */ depth?: number; - /** Number of segmented faces along the width of the sides. Default is 1. */ + /** + * Number of segmented faces along the width of the sides. + * Default is 1. + */ widthSegments?: number; - /** Number of segmented faces along the height of the sides. Default is 1. */ + /** + * Number of segmented faces along the height of the sides. + * Default is 1. + */ heightSegments?: number; - /** Number of segmented faces along the depth of the sides. Default is 1. */ + /** + * Number of segmented faces along the depth of the sides. + * Default is 1. + */ depthSegments?: number; - } -} - -interface BufferedBoxParams extends BoxParams { + }; /** Sets whether to build a buffered geometry */ - buffer?: boolean -} + buffer?: boolean; +} export class Box extends MeshComponent { /** - * @constructor Creates a Box + * @description Creates a Box + * @constructor * @param params parameters */ constructor(params?: BoxParams); @@ -53,5 +73,5 @@ interface BufferedBoxParams extends BoxParams { * Builds the geometry * @param params */ - buildGeometry(params?: BufferedBoxParams): BoxGeometry | BoxBufferGeometry; + buildGeometry(params?: BoxParams): BoxGeometry | BoxBufferGeometry; } diff --git a/types/components/meshes/Cone.d.ts b/types/components/meshes/Cone.d.ts index 8dcb03cb0..3918dc81d 100644 --- a/types/components/meshes/Cone.d.ts +++ b/types/components/meshes/Cone.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { Mesh, ConeBufferGeometry, @@ -62,7 +66,7 @@ interface BufferedConeParams extends ConeParams { export class Cone extends MeshComponent { /** - * Creates a Cone + * @description Creates a Cone. * @param params */ constructor(params?: ConeParams); diff --git a/types/components/meshes/Cylinder.d.ts b/types/components/meshes/Cylinder.d.ts index bf8f5670f..29fa5fd61 100644 --- a/types/components/meshes/Cylinder.d.ts +++ b/types/components/meshes/Cylinder.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { CylinderGeometry, CylinderBufferGeometry, @@ -50,12 +54,12 @@ interface CylinderParams extends MeshComponentParams { * The thetha length * Default is Math.PI * 2. */ - thetaLength: number; + thetaLength?: number; }; /** * Whether to create buffered geometry or not. - * Default is false + * Default is false. */ buffer?: boolean; } @@ -63,10 +67,11 @@ interface CylinderParams extends MeshComponentParams { export class Cylinder extends MeshComponent { /** - * @constructor Creates a Cylinder + * @description Creates a Cylinder. + * @constructor * @param params */ - constructor(params?: SphereParams); + constructor(params?: CylinderParams); /** * Build lifecycle creates a mesh using input params. diff --git a/types/components/meshes/Dodecahedron.d.ts b/types/components/meshes/Dodecahedron.d.ts index 2933491d6..bd82d7653 100644 --- a/types/components/meshes/Dodecahedron.d.ts +++ b/types/components/meshes/Dodecahedron.d.ts @@ -4,6 +4,7 @@ import { } from '../../core/MeshComponent'; import { + BufferGeometry, DodecahedronGeometry, Geometry, Mesh @@ -15,7 +16,7 @@ import { * @interface DodecahedronBufferGeometry * @extends {Geometry} */ -interface DodecahedronBufferGeometry extends Geometry { +interface DodecahedronBufferGeometry extends BufferGeometry { constructor(radius: number, detail: number): DodecahedronBufferGeometry; parameters: { @@ -50,7 +51,8 @@ interface DodecahedronParams extends MeshComponentParams { export class Dodecahedron extends MeshComponent { /** - * @constructor Creates a Dodecahedron + * @description Creates a Dodecahedron. + * @constructor * @param params */ constructor(params?: DodecahedronParams); diff --git a/types/components/meshes/Extrude.d.ts b/types/components/meshes/Extrude.d.ts index 74b1906e8..dc921af43 100644 --- a/types/components/meshes/Extrude.d.ts +++ b/types/components/meshes/Extrude.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { BufferGeometry, CurvePath, @@ -86,7 +90,8 @@ interface ExtrudeParamsOptions { export class Extrude extends MeshComponent { /** - * @constructor Creates an extruded geometry from a path shape. + * @description Creates an extruded geometry from a path shape. + * @constructor * @param params parameters */ constructor(params?: ExtrudeParams); diff --git a/types/components/meshes/Group.d.ts b/types/components/meshes/Group.d.ts index cc11feab3..8d9595b37 100644 --- a/types/components/meshes/Group.d.ts +++ b/types/components/meshes/Group.d.ts @@ -8,7 +8,8 @@ import {Object3D} from 'three'; export class Group extends MeshComponent { /** - * @constructor Creates a Group of meshes + * @description Creates a Group of meshes + * @constructor * @param objects spread Meshes */ constructor(...objects: Array); diff --git a/types/components/meshes/Icosahedron.d.ts b/types/components/meshes/Icosahedron.d.ts index 9f9054206..793862746 100644 --- a/types/components/meshes/Icosahedron.d.ts +++ b/types/components/meshes/Icosahedron.d.ts @@ -43,7 +43,8 @@ interface IcosahedronParams extends MeshComponentParams { export class Icosahedron extends MeshComponent { /** - * @constructor Creates an Icosahedron + * @description Creates an Icosahedron. + * @constructor * @param params */ constructor(params?: IcosahedronParams); diff --git a/types/components/meshes/Importer.d.ts b/types/components/meshes/Importer.d.ts index ec08a7adc..847e6d77c 100644 --- a/types/components/meshes/Importer.d.ts +++ b/types/components/meshes/Importer.d.ts @@ -64,7 +64,8 @@ interface ImporterParams extends MeshComponentParams { export class Importer extends MeshComponent { /** - * @constructor Creates an Importer + * @description Creates an importer of meshes and any other data to your scene. + * @constructor * @param params parameters */ constructor(params?: ImporterParams); diff --git a/types/components/meshes/Lathe.d.ts b/types/components/meshes/Lathe.d.ts index ac11431de..077050055 100644 --- a/types/components/meshes/Lathe.d.ts +++ b/types/components/meshes/Lathe.d.ts @@ -28,7 +28,8 @@ interface LatheParams extends MeshComponentParams { export class Lathe extends MeshComponent { /** - * @constructor Creates a Lath + * @description Creates a Lath + * @constructor * @param params parameters */ constructor(params?: LatheParams); diff --git a/types/components/meshes/Line.d.ts b/types/components/meshes/Line.d.ts index 9c7b131e6..eaa824f0e 100644 --- a/types/components/meshes/Line.d.ts +++ b/types/components/meshes/Line.d.ts @@ -35,7 +35,8 @@ interface LineParams extends MeshComponentParams { export class Line extends MeshComponent { /** - * @constructor Creates a Line + * @description Creates a Line + * @constructor * @param params parameters */ constructor(params?: LineParams); diff --git a/types/components/meshes/Octahedron.d.ts b/types/components/meshes/Octahedron.d.ts index e38b36f3a..db37210bb 100644 --- a/types/components/meshes/Octahedron.d.ts +++ b/types/components/meshes/Octahedron.d.ts @@ -3,12 +3,17 @@ import { MeshComponentParams } from '../../core/MeshComponent'; +import {PolyhedronBufferGeometry} from './Polyhedron'; + import { Mesh, - OctahedronBufferGeometry, - OctahedronGeometry + OctahedronGeometry, } from 'three'; +export class OctahedronBufferGeometry extends PolyhedronBufferGeometry { + constructor(radius: number, detail: number); +} + interface OctahedronParams extends MeshComponentParams { /** Geometry parameters */ @@ -37,7 +42,8 @@ interface OctahedronParams extends MeshComponentParams { export class Octahedron extends MeshComponent { /** - * @constructor Creates an Octahedron + * @description Creates an Octahedron + * @constructor * @param params parameters */ constructor(params?: OctahedronParams); diff --git a/types/components/meshes/Parametric.d.ts b/types/components/meshes/Parametric.d.ts index 19a4198d7..783123b3f 100644 --- a/types/components/meshes/Parametric.d.ts +++ b/types/components/meshes/Parametric.d.ts @@ -4,11 +4,22 @@ import { } from '../../core/MeshComponent'; import { + BufferGeometry, Mesh, - ParametricBufferGeometry, ParametricGeometry, + Vector3 } from 'three'; +interface ParametricBufferGeometry extends BufferGeometry { + constructor(func: (u: number, v: number) => Vector3, slices: number, stacks: number): ParametricBufferGeometry; + + parameters: { + func: (u: number, v: number) => Vector3; + slices: number; + stacks: number; + }; +} + interface ParametricParams extends MeshComponentParams { /** Geometry parameters */ @@ -42,7 +53,8 @@ interface ParametricParams extends MeshComponentParams { export class Parametric extends MeshComponent { /** - * @constructor Creates a Parametric + * @description Creates a Parametric surface. + * @constructor * @param params parameters */ constructor(params?: ParametricParams); diff --git a/types/components/meshes/Plane.d.ts b/types/components/meshes/Plane.d.ts index 8e5daf0f7..8ab88d628 100644 --- a/types/components/meshes/Plane.d.ts +++ b/types/components/meshes/Plane.d.ts @@ -49,7 +49,8 @@ interface PlaneParams extends MeshComponentParams { export class Plane extends MeshComponent { /** - * @constructor Creates a Plane + * @description Creates a Plane. + * @constructor * @param params parameters */ constructor(params?: PlaneParams); diff --git a/types/components/meshes/Polyhedron.d.ts b/types/components/meshes/Polyhedron.d.ts index 525a2bdc2..6e4bbc8df 100644 --- a/types/components/meshes/Polyhedron.d.ts +++ b/types/components/meshes/Polyhedron.d.ts @@ -4,11 +4,22 @@ import { } from '../../core/MeshComponent'; import { + BufferGeometry, Mesh, - PolyhedronBufferGeometry, - PolyhedronGeometry + PolyhedronGeometry, } from 'three'; +export class PolyhedronBufferGeometry extends BufferGeometry { + constructor(vertices: number[], indices: number[], radius?: number, detail?: number): PolyhedronBufferGeometry; + + parameters: { + vertices: number[]; + indices: number[]; + radius: number; + detail: number; + }; +} + interface PolyhedronParams extends MeshComponentParams { /** Geometry parameters */ diff --git a/types/components/meshes/Shape.d.ts b/types/components/meshes/Shape.d.ts index 376aae8c4..8327e791c 100644 --- a/types/components/meshes/Shape.d.ts +++ b/types/components/meshes/Shape.d.ts @@ -11,8 +11,8 @@ import { } from 'three'; interface ShapeBufferGeometry extends BufferGeometry { - constructor(shape: ShapeNative, options?: any); - constructor(shapes: ShapeNative[], options?: any); + constructor(shape: ShapeNative, options?: any): ShapeBufferGeometry; + constructor(shapes: ShapeNative[], options?: any): ShapeBufferGeometry; } interface ShapeParams extends MeshComponentParams { diff --git a/types/components/meshes/Sphere.d.ts b/types/components/meshes/Sphere.d.ts index 502d14db1..ca4dff351 100644 --- a/types/components/meshes/Sphere.d.ts +++ b/types/components/meshes/Sphere.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { SphereGeometry, SphereBufferGeometry, @@ -45,7 +49,8 @@ interface SphereParams extends MeshComponentParams { export class Sphere extends MeshComponent { /** - * @constructor Creates a Sphere + * @description Creates a Sphere. + * @constructor * @param params */ constructor(params?: SphereParams); diff --git a/types/components/meshes/Tetrahedron.d.ts b/types/components/meshes/Tetrahedron.d.ts index 4f77e776e..eca7efa49 100644 --- a/types/components/meshes/Tetrahedron.d.ts +++ b/types/components/meshes/Tetrahedron.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { Mesh } from 'three'; @@ -25,7 +29,8 @@ interface TetrahedronParams extends MeshComponentParams { export class Tetrahedron extends MeshComponent { /** - * @constructor Creates Tetrahedron + * @description Creates a Tetrahedron + * @constructor * @param params */ constructor(params?: TetrahedronParams); diff --git a/types/components/meshes/Text.d.ts b/types/components/meshes/Text.d.ts index 4b0b30d89..a47c321f1 100644 --- a/types/components/meshes/Text.d.ts +++ b/types/components/meshes/Text.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { Font, Mesh, @@ -63,7 +67,8 @@ interface TextParams extends MeshComponentParams { export class Text extends MeshComponent { /** - * @constructor Creates Text + * @description Creates a Text + * @constructor * @param params */ constructor(params?: TextParams); diff --git a/types/components/meshes/Torus.d.ts b/types/components/meshes/Torus.d.ts index 7881f8748..93301b343 100644 --- a/types/components/meshes/Torus.d.ts +++ b/types/components/meshes/Torus.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { Mesh } from 'three'; @@ -43,7 +47,8 @@ interface TorusParams extends MeshComponentParams { export class Torus extends MeshComponent { /** - * @constructor Creates Torus + * @description Creates a Torus + * @constructor * @param params */ constructor(params?: TorusParams); diff --git a/types/components/meshes/Torusknot.d.ts b/types/components/meshes/Torusknot.d.ts index e334d4a0c..a199518d6 100644 --- a/types/components/meshes/Torusknot.d.ts +++ b/types/components/meshes/Torusknot.d.ts @@ -1,4 +1,8 @@ -import {MeshComponent, MeshComponentParams} from '../../core/MeshComponent'; +import { + MeshComponent, + MeshComponentParams +} from '../../core/MeshComponent'; + import { Mesh } from 'three'; @@ -49,7 +53,9 @@ interface TorusknotParams extends MeshComponentParams { export class Torusknot extends MeshComponent { /** - * @constructor Creates Torusknot + * @description Creates a torus knot, the particular shape of which is defined by a pair of coprime integers, p and q. + * If p and q are not coprime, the result will be a torus link. + * @constructor * @param params */ constructor(params?: TorusknotParams);