Skip to content

NgtsPrismGeometry

NgtsPrismGeometry abstracts THREE.ExtrudeGeometry to create a prism geometry from a 2D shape.

Usage

import { NgtsPrismGeometry } from 'angular-three-soba/abstractions';
<ngt-mesh>
<ngts-prism-geometry [vertices]="[[0, 0], [1, 0], [0.5, 1]]" [options]="{ height: 2 }" />
<ngt-mesh-standard-material color="purple" />
</ngt-mesh>

Triangle Prism

Create a simple triangular prism:

<ngt-mesh>
<ngts-prism-geometry
[vertices]="[[0, 0], [2, 0], [1, 1.732]]"
[options]="{ height: 3 }"
/>
<ngt-mesh-standard-material color="coral" />
</ngt-mesh>

Rectangular Prism

Create a rectangular prism:

<ngt-mesh>
<ngts-prism-geometry
[vertices]="[[0, 0], [2, 0], [2, 1], [0, 1]]"
[options]="{ height: 1.5 }"
/>
<ngt-mesh-standard-material color="teal" />
</ngt-mesh>

With Bevel

Add bevel to the prism edges:

<ngt-mesh>
<ngts-prism-geometry
[vertices]="[[0, 0], [1, 0], [1, 1], [0, 1]]"
[options]="{ height: 1, bevelEnabled: true, bevelThickness: 0.1, bevelSize: 0.1, bevelSegments: 3 }"
/>
<ngt-mesh-standard-material color="gold" />
</ngt-mesh>

Custom Polygon

Create a prism from any polygon shape:

<ngt-mesh>
<!-- Hexagon base -->
<ngts-prism-geometry
[vertices]="[
[1, 0],
[0.5, 0.866],
[-0.5, 0.866],
[-1, 0],
[-0.5, -0.866],
[0.5, -0.866]
]"
[options]="{ height: 0.5 }"
/>
<ngt-mesh-standard-material color="skyblue" />
</ngt-mesh>

Inputs

name type description required
vertices Array<[number, number]> Array of 2D vertices defining the base shape. yes
attach NgtAttachable Defines how the geometry attaches to its parent. Default: 'geometry' no

Options

options input accepts any properties from THREE.ExtrudeGeometry in addition to the following:

Properties

name type description
height number Height of the prism extrusion. Default: 1
bevelEnabled boolean Enable bevel. Default: false
steps number Number of points used for subdividing segments along the depth of the extruded spline.
bevelThickness number How deep into the original shape the bevel goes.
bevelSize number Distance from the shape outline that the bevel extends.
bevelOffset number Distance from the shape outline that the bevel starts.
bevelSegments number Number of bevel layers.
curveSegments number Number of points on the curves.