Skip to content

Commit

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

import {
BufferGeometry,
Geometry,
LineCurve3,
Mesh
} from 'three';

interface LineParams extends MeshComponentParams {

/** Geometry parameters */
geometry: {

/**
* A LineCurve3 representing the curve to trace as a line
* @type {LineCurve3}
*/
curve: LineCurve3;

/**
* Points is the number of pieces to divide the curve into.
* Default is 50.
*/
points?: number;
}

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

export class Line extends MeshComponent {

/**
* @constructor Creates a Line
* @param params parameters
*/
constructor(params?: LineParams);

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

/**
* Builds the geometry
* @param params
*/
buildGeometry(params?: LineParams): Geometry | BufferGeometry;
}
1 change: 1 addition & 0 deletions types/components/meshes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './Extrude';
export {Icosahedron} from './Icosahedron';
export * from './Importer';
export * from './Lathe';
export * from './Line';
export * from './Sphere';
export * from './Text';
export * from './Tetrahedron';
Expand Down
15 changes: 14 additions & 1 deletion types/whs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
Mesh,
MeshStandardMaterial,
JSONLoader,
LineCurve3,
Shape,
Vector2
Vector2,
Vector3
} from 'three';

import {
Expand All @@ -26,6 +28,7 @@ import {
Icosahedron,
Importer,
Lathe,
Line,
OrthographicCamera,
PerspectiveCamera,
Sphere
Expand Down Expand Up @@ -195,6 +198,16 @@ const lathe = new Lathe({
});
lathe.addTo(app);

const line = new Line({
geometry: {
curve: new LineCurve3(new Vector3(0, 0, 0), new Vector3(10, 0, 0)),
points: 5
},

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

// Cameras

const cubeCamera = new CubeCamera({
Expand Down

0 comments on commit a20fee9

Please sign in to comment.