Skip to content

Commit

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

import {
Mesh,
OctahedronBufferGeometry,
OctahedronGeometry
} from 'three';

interface OctahedronParams extends MeshComponentParams {

/** Geometry parameters */
geometry?: {

/**
* Radius of the octahedron.
* Default is 1.
*/
radius?: number;

/**
* Setting this to a value greater than zero add vertices making it no longer an octahedron.
* Default is 0.
*/
detail?: number;
}

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

export class Octahedron extends MeshComponent {

/**
* @constructor Creates an Octahedron
* @param params parameters
*/
constructor(params?: OctahedronParams);

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

/**
* Builds the geometry
* @param params
*/
buildGeometry(params?: OctahedronParams): OctahedronGeometry | OctahedronBufferGeometry;
}
1 change: 1 addition & 0 deletions types/components/meshes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {Icosahedron} from './Icosahedron';
export * from './Importer';
export * from './Lathe';
export * from './Line';
export * from './Octahedron';
export * from './Sphere';
export * from './Text';
export * from './Tetrahedron';
Expand Down
11 changes: 11 additions & 0 deletions types/whs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
Importer,
Lathe,
Line,
Octahedron,
OrthographicCamera,
PerspectiveCamera,
Sphere
Expand Down Expand Up @@ -208,6 +209,16 @@ const line = new Line({
});
line.addTo(app);

const octahedron = new Octahedron({
geometry: {
radius: 1,
detail: 0
},

buffer: true
});
octahedron.addTo(app);

// Cameras

const cubeCamera = new CubeCamera({
Expand Down

0 comments on commit 15195b6

Please sign in to comment.