Skip to content

editorGlobalsPlateRenderSurface

Class: PlateRenderSurface

Describes a surface as used by the PlateRenderSurfaceExtruder and PlateRenderSurfaceTriangulator. This will later be used to make a BufferGeometry out of it that is then rendered. Also used in some cases where we need to calculate plate volume (e.g. in PlateCSG) as the volume computations are base don the PlateRenderSurfaceExtruder.

This is mainly a data interface except for the {@see fromPolygon} method, thus we allow direct member access.

Mainly used by constructing from a plate polygon.

In the past we used indexed vertices to prevent vertex duplication, but three.js does not (yet) allow attaching multiple vertex normals when using indexed buffer geometries, leading to some rendering artifacts, so we duplicate the points as a workaround.

Hierarchy

  • PlateRenderSurface

Index

Properties

Methods

Properties

Optional faceIndices

faceIndices? : IArrayFace[]

Defined in src/util/PlateRenderSurface.ts:153

Triangles (array of @points indices) of the surface - will be filled when triangulating


holeStartIndices

holeStartIndices: number[] = []

Defined in src/util/PlateRenderSurface.ts:147

Defines at which indices in vertices holes start.


Optional pseudoUvs

pseudoUvs? : Float32Array

Defined in src/util/PlateRenderSurface.ts:150

Vertex Data: Pseudo UV coordinate (2 elements per vertex)


vertices

vertices: PlateRenderSurfaceVertex[] = []

Defined in src/util/PlateRenderSurface.ts:144

Contains the concatenated vertices of all the outlines and holes of the surface.

Methods

Private _computeFaceNormal

_computeFaceNormal(face: IArrayFace, targetArray: Float32Array): Float32Array‹›

Defined in src/util/PlateRenderSurface.ts:268

Computes the normal of the triangle defined by the points p1, p2 and p3 and stores the result in targetArray.

Parameters:

Name Type Description
face IArrayFace the vertex indices of the face
targetArray Float32Array the array to store the result in

Returns: Float32Array‹›


attachNormals

attachNormals(): void

Defined in src/util/PlateRenderSurface.ts:214

Attach normals to all vertices based on the average of all adjacent faces. Some points may not have adjacent surfaces, as they are f.e. collinear and not needed in the triangulation. To calculate a normal for these points, we interpolate between the normals of the previous and next vertex afterwards.

Returns: void


attachPseudoUvs

attachPseudoUvs(vertexPositionToPseudoUv: function): void

Defined in src/util/PlateRenderSurface.ts:198

Attach pseudoUvs to the surface

Parameters:

vertexPositionToPseudoUv: function

a function taking - an ArrayPoint2 of the vertex position of the surface - a target array to write the resulting pseudo uv coordinates to - an index where to write the position to. Entries should be written to array[index] and array[index + 1]

▸ (ArrayPoint3: any, Float32Array: any, number: any): void

Parameters:

Name Type
ArrayPoint3 any
Float32Array any
number any

Returns: void


clone

clone(reverseTrianglesAndNormals: boolean): PlateRenderSurface‹›

Defined in src/util/PlateRenderSurface.ts:160

Clones the surface, used in PlateRenderSurfaceExtruder to create extruded surfaces.

Parameters:

Name Type Default Description
reverseTrianglesAndNormals boolean false if set, reverses each triangle and inverts the normal of each vertex this is useful to create a matching opposing surface for the renderer.

Returns: PlateRenderSurface‹›


offsetVerticesAlongNormals

offsetVerticesAlongNormals(distance: number): void

Defined in src/util/PlateRenderSurface.ts:254

Offset the vertices of this surface along their normals Assumes that vertex normals are set and normalized.

Parameters:

Name Type Description
distance number -

Returns: void


reverseFaceTriangles

reverseFaceTriangles(): void

Defined in src/util/PlateRenderSurface.ts:182

Returns: void


Static createCombinedFaceIndexArray

createCombinedFaceIndexArray(surfaces: PlateRenderSurface[]): Uint16Array

Defined in src/util/PlateRenderSurface.ts:82

Create a Uint16Array (itemSize 1) that contains all vertex indices for the faces in the surface list. Assumes that the vertex positions of all the faces are simply concatenated in the list we are indexing.

Parameters:

Name Type
surfaces PlateRenderSurface[]

Returns: Uint16Array


Static createCombinedNormalArray

createCombinedNormalArray(surfaces: PlateRenderSurface[]): Float32Array

Defined in src/util/PlateRenderSurface.ts:61

Create a Float32Array (itemSize 3) that contains all normals of all vertices in the surface list.

Parameters:

Name Type
surfaces PlateRenderSurface[]

Returns: Float32Array


Static createCombinedPositionArray

createCombinedPositionArray(surfaces: PlateRenderSurface[]): Float32Array

Defined in src/util/PlateRenderSurface.ts:41

Create a Float32Array (itemSize 3) that contains all positions of all vertices in the surface list.

Parameters:

Name Type
surfaces PlateRenderSurface[]

Returns: Float32Array


Static createCombinedPseudoUvArray

createCombinedPseudoUvArray(surfaces: PlateRenderSurface[]): Float32Array

Defined in src/util/PlateRenderSurface.ts:103

Create a Float32Array (itemSize 2) that contains all pseudo uv coordinates of all vertices in the surface list.

Parameters:

Name Type
surfaces PlateRenderSurface[]

Returns: Float32Array


Static fromPolygon

fromPolygon(polygonOutline: ArrayPoint2[], holes: ArrayPoint2[][]): PlateRenderSurface

Defined in src/util/PlateRenderSurface.ts:19

Parameters:

Name Type Default
polygonOutline ArrayPoint2[] -
holes ArrayPoint2[][] []

Returns: PlateRenderSurface


Static getCombinedFaceIndexCount

getCombinedFaceIndexCount(surfaces: PlateRenderSurface[]): number

Defined in src/util/PlateRenderSurface.ts:130

Get the count of all the faces in the surfaces given.

Parameters:

Name Type
surfaces PlateRenderSurface[]

Returns: number


Static getCombinedVertexCount

getCombinedVertexCount(surfaces: PlateRenderSurface[]): number

Defined in src/util/PlateRenderSurface.ts:119

Get the count of all the vertices in the surfaces given.

Parameters:

Name Type
surfaces PlateRenderSurface[]

Returns: number