Skip to content

Commit

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

import {
Mesh,
PlaneBufferGeometry,
PlaneGeometry
} from 'three';

interface PlaneParams extends MeshComponentParams {

/** Geometry parameters */
geometry?: {

/**
* Width along the X axis.
* Default is 10.
*/
width?: number;

/**
* Width along the Y axis.
* Default is 10.
*/
height?: number;

/**
* Number of width segments.
* Default is 1.
*/
wSegments?: number;

/**
* Number of height segments.
* Default is 1.
*/
hSegments?: number;
};

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

export class Plane extends MeshComponent {

/**
* @constructor Creates a Plane
* @param params parameters
*/
constructor(params?: PlaneParams);

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

/**
* Builds the geometry
* @param params
*/
buildGeometry(params?: PlaneParams): PlaneGeometry | PlaneBufferGeometry;
}
1 change: 1 addition & 0 deletions types/components/meshes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './Lathe';
export * from './Line';
export * from './Octahedron';
export * from './Parametric';
export * from './Plane';
export * from './Sphere';
export * from './Text';
export * from './Tetrahedron';
Expand Down
17 changes: 15 additions & 2 deletions types/whs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Line,
Octahedron,
Parametric,
Plane,
OrthographicCamera,
PerspectiveCamera,
Sphere
Expand Down Expand Up @@ -220,7 +221,7 @@ const octahedron = new Octahedron({
});
octahedron.addTo(app);

const createParametric = (u, v) => {
const createParametric = (u: number, v: number) => {
return new Vector3(u * 30, Math.random() * 5, v * 30);
};

Expand All @@ -235,6 +236,18 @@ const parametric = new Parametric({
});
parametric.addTo(app);

const plane = new Plane({
geometry: {
height: 3,
width: 10,
hSegments: 2,
wSegments: 3
},

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

// Cameras

const cubeCamera = new CubeCamera({
Expand All @@ -258,7 +271,7 @@ const perspectiveCamera = new PerspectiveCamera({
build: false,
far: 100
});
perspectiveCamera.wrap
perspectiveCamera.wrap();
const perspectiveCameraNative = orthographicCamera.build();


Expand Down

0 comments on commit eaacfe2

Please sign in to comment.