diff --git a/types/components/meshes/Plane.d.ts b/types/components/meshes/Plane.d.ts new file mode 100644 index 000000000..8e5daf0f7 --- /dev/null +++ b/types/components/meshes/Plane.d.ts @@ -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; +} diff --git a/types/components/meshes/index.d.ts b/types/components/meshes/index.d.ts index 1138457fd..a792f16f6 100644 --- a/types/components/meshes/index.d.ts +++ b/types/components/meshes/index.d.ts @@ -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'; diff --git a/types/whs-tests.ts b/types/whs-tests.ts index f3fb0f2fa..fc4be0822 100644 --- a/types/whs-tests.ts +++ b/types/whs-tests.ts @@ -31,6 +31,7 @@ import { Line, Octahedron, Parametric, + Plane, OrthographicCamera, PerspectiveCamera, Sphere @@ -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); }; @@ -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({ @@ -258,7 +271,7 @@ const perspectiveCamera = new PerspectiveCamera({ build: false, far: 100 }); -perspectiveCamera.wrap +perspectiveCamera.wrap(); const perspectiveCameraNative = orthographicCamera.build();