Skip to content

Commit

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

import {
LatheBufferGeometry,
LatheGeometry,
Mesh,
Vector2
} from 'three';

interface LatheParams extends MeshComponentParams {

/** Geometry parameters */
geometry?: {

/**
* Array of Vector2s. The x-coordinate of each point must be greater than zero.
*/
points: Array<Vector2>;
}

/** Sets whether to build a buffered geometry */
buffer?: boolean;
}

export class Lathe extends MeshComponent {

/**
* @constructor Creates a Lath
* @param params parameters
*/
constructor(params?: LatheParams);

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

/**
* Builds the geometry
* @param params
*/
buildGeometry(params?: LatheParams): LatheGeometry | LatheBufferGeometry;
}
1 change: 1 addition & 0 deletions types/components/meshes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {Dodecahedron} from './Dodecahedron';
export * from './Extrude';
export {Icosahedron} from './Icosahedron';
export * from './Importer';
export * from './Lathe';
export * from './Sphere';
export * from './Text';
export * from './Tetrahedron';
Expand Down
14 changes: 11 additions & 3 deletions types/whs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Material,
Mesh,
MeshStandardMaterial,
GLTF2Loader,
JSONLoader,
Shape,
Vector2
} from 'three';
Expand All @@ -25,6 +25,7 @@ import {
Group,
Icosahedron,
Importer,
Lathe,
OrthographicCamera,
PerspectiveCamera,
Sphere
Expand Down Expand Up @@ -164,9 +165,9 @@ const icosahedron = new Icosahedron({
icosahedron.addTo(app);

new Importer({
loader: new GLTF2Loader(),
loader: new JSONLoader(),

url: 'some/path/model.gltf',
url: 'some/path/model.json',

onLoad: () => {
console.log('on load');
Expand All @@ -187,6 +188,13 @@ new Importer({
useCustomMaterial: false
}).addTo(app);

const lathe = new Lathe({
geometry: {
points: [new Vector2(1, 1)]
}
});
lathe.addTo(app);

// Cameras

const cubeCamera = new CubeCamera({
Expand Down

0 comments on commit 4f49f11

Please sign in to comment.