three-edge-projection

June 16, 2026 ยท View on GitHub

Constants

OUTPUT_MESH

OUTPUT_MESH: number

OUTPUT_LINE_SEGMENTS

OUTPUT_LINE_SEGMENTS: number

OUTPUT_BOTH

OUTPUT_BOTH: number

EdgeSet

Set of projected edges produced by ProjectionGenerator.

.getLineGeometry

getLineGeometry( meshes = null: Array<Mesh> | null ): BufferGeometry

Returns a new BufferGeometry representing the edges.

Pass a list of meshes in to extract edges from a specific subset of meshes in the given order. Returns all edges if null.

.getRangeForMesh

getRangeForMesh( mesh: Mesh ): Object | null

Returns the range of vertices associated with the given mesh in the geometry returned from getLineGeometry. The start value is only relevant if lines are generated with the default order and set of meshes.

Can be used to add extra vertex attributes in a geometry associated with a specific subrange of the geometry.

MeshVisibilityCuller

Utility for determining visible geometry from a top down orthographic perspective. This can be run before performing projection generation to reduce the complexity of the operation at the cost of potentially missing small details.

Constructor for the visibility culler that takes the renderer to use for culling.

.pixelsPerMeter

pixelsPerMeter: number

The size of a pixel on a single dimension. If this results in a texture larger than what the graphics context can provide then the rendering is tiled.

.constructor

constructor(
	renderer: WebGLRenderer,
	{
		pixelsPerMeter = 0.1: number,
	}
)

.cull

async cull( object: Object3D | Array<Object3D> ): Promise<Array<Object3D>>

Returns the set of meshes that are visible within the given object.

PlanarIntersectionGenerator

Utility for generating the line segments produced by a planar intersection with geometry.

.plane

plane: Plane

Plane that defaults to y up plane at the origin.

.generate

generate( geometry: MeshBVH | BufferGeometry ): BufferGeometry

Generates a geometry of the resulting line segments from the planar intersection.

ProjectionGenerator

Utility for generating 2D projections of 3D geometry.

.iterationTime

iterationTime: number

How long to spend trimming edges before yielding.

.angleThreshold

angleThreshold: number

The threshold angle in degrees at which edges are generated.

.includeIntersectionEdges

includeIntersectionEdges: boolean

Whether to generate edges representing the intersections between triangles.

.generateAsync

async generateAsync(
	geometry: Object3D | BufferGeometry | Array<Object3D>,
	{
		onProgress?: (
			percent: number,
			message: string
		) => void,
		signal?: AbortSignal,
	}
): ProjectionResult

Generate the geometry with a promise-style API.

.generate

generate(
	scene: Object3D | BufferGeometry | Array<Object3D>,
	{
		onProgress?: (
			percent: number,
			message: string
		) => void,
	}
): ProjectionResult

Generate the edge geometry result using a generator function.

ProjectionResult

Result object returned by ProjectionGenerator containing visible and hidden edge sets.

.visibleEdges

visibleEdges: EdgeSet

.hiddenEdges

hiddenEdges: EdgeSet

SilhouetteGenerator

Used for generating a projected silhouette of a geometry using the clipper2-js project. Performing these operations can be extremely slow with more complex geometry and not always yield a stable result.

.iterationTime

iterationTime: number

How long to spend trimming edges before yielding.

.doubleSided

doubleSided: boolean

If false then only the triangles facing upwards are included in the silhouette.

.sortTriangles

sortTriangles: boolean

Whether to sort triangles and project them large-to-small. In some cases this can cause the performance to drop since the union operation is best performed with smooth, simple edge shapes.

.output

output: number

Whether to output mesh geometry, line segments geometry, or both in an array ( [ mesh, line segments ] ).

.generateAsync

async generateAsync(
	geometry: BufferGeometry,
	{
		onProgress?: (
			percent: number
		) => void,
		signal?: AbortSignal,
	}
): BufferGeometry | Array<BufferGeometry>

Generate the silhouette geometry with a promise-style API.

.generate

generate(
	geometry: BufferGeometry,
	{
		onProgress?: (
			percent: number
		) => void,
	}
): BufferGeometry | Array<BufferGeometry>

Generate the geometry using a generator function.

WebGPU API

MeshVisibilityCuller

Utility for determining visible geometry from a top down orthographic perspective. This can be run before performing projection generation to reduce the complexity of the operation at the cost of potentially missing small details.

Takes the WebGPURenderer instance used to render.

.pixelsPerMeter

pixelsPerMeter: number

The size of a pixel on a single dimension. If this results in a texture larger than what the graphics context can provide then the rendering is tiled.

.constructor

constructor(
	renderer: WebGPURenderer,
	{
		pixelsPerMeter = 0.1: number,
	}
)

.cull

async cull( object: Object3D | Array<Object3D> ): Promise<Array<Object3D>>

Returns the set of meshes that are visible within the given object.

ProjectionGenerator

Takes the WebGPURenderer instance used to run compute kernels.

.angleThreshold

angleThreshold: number = 50

The threshold angle in degrees at which edges are generated.

.batchSize

batchSize: number = 100000

The number of edges to process in one compute kernel pass. Larger values can process faster but may cause internal buffers to overflow, resulting in extra kernel executions, taking more time.

.includeIntersectionEdges

includeIntersectionEdges: boolean = true

Whether to generate edges representing the intersections between triangles.

.iterationTime

iterationTime: number = 300

How long to spend generating edges.

.parallelJobs

parallelJobs: number = 3

How many compute jobs to perform in parallel.

.constructor

constructor( renderer: WebGPURenderer )

.generate

async generate(
	scene: Object3D | BufferGeometry | Array<Object3D>,
	{
		onProgress?: (
			percent: number,
			message: string
		) => void,
		signal?: AbortSignal,
	}
): Promise<ProjectionResult>

Asynchronously generate the edge geometry result.