Skip to content

Commit

Permalink
Adds types for Ring - #297
Browse files Browse the repository at this point in the history
  • Loading branch information
hirako2000 committed Jul 29, 2017
1 parent e6f6fcf commit 42ae787
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 3 deletions.
88 changes: 88 additions & 0 deletions types/components/meshes/Ring.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {
MeshComponent,
MeshComponentParams
} from '../../core/MeshComponent';

import {
Mesh,
RingGeometry,
RingBufferGeometry
} from 'three';

interface RingParams extends MeshComponentParams {

/** Geometry parameters */
geometry?: {

/**
* Increase radius as it doesn't work right when innerRadius is set to 0.
* Default is 0.
*/
innerRadius?: number;

/**
*
* Default is 50.
*/
outerRadius?: number;

/**
* Number of segments.
* A higher number means the ring will be more round. Minimum is 3.
* Default is 8.
*/
thetaSegments?: number;

/**
* Minimum is 1
* Default is 8.
*/
phiSegments?: number;

/**
* Starting angle
* Default is 0.
*/
thetaStart?: number;

/**
* Central angle
* Default is Math.PI * 2.
*/
thetaLength?: number;
};

/**
* Sets whether to build a buffered geometry
* Default is false.
*/
buffer?: boolean;
}

/**
* generating a two-dimensional ring geometry.
*
* @export
* @class Ring
* @extends {MeshComponent}
*/
export class Ring extends MeshComponent {

/**
* @constructor Creates a Ring
* @param params parameters
*/
constructor(params?: RingParams);

/**
* Build lifecycle creates a mesh using input params.
* @param params
*/
build(params?: RingParams): Mesh;

/**
* Builds the geometry
* @param params
*/
buildGeometry(params?: RingParams): RingGeometry | RingBufferGeometry;
}
1 change: 1 addition & 0 deletions types/components/meshes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from './Octahedron';
export * from './Parametric';
export * from './Plane';
export * from './Polyhedron';
export * from './Ring';
export * from './Sphere';
export * from './Text';
export * from './Tetrahedron';
Expand Down
22 changes: 19 additions & 3 deletions types/whs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
import {
Box,
Cone,
CubeCamera,
Extrude,
Group,
Icosahedron,
Expand All @@ -33,10 +32,15 @@ import {
Parametric,
Plane,
Polyhedron,
Sphere,
Ring
} from './components/meshes';

import {
CubeCamera,
OrthographicCamera,
PerspectiveCamera,
Sphere
} from './components';
} from './components/cameras';

import {
AmbientLight,
Expand Down Expand Up @@ -273,6 +277,18 @@ const polyhedron = new Polyhedron({
});
polyhedron.addTo(app);

const ring = new Ring({
geometry: {
innerRadius: 1,
outerRadius: 50,
phiSegments: 5,
thetaLength: Math.PI /3,
thetaSegments: 10,
thetaStart: 0
}
});
ring.addTo(app);

// Cameras

const cubeCamera = new CubeCamera({
Expand Down

0 comments on commit 42ae787

Please sign in to comment.