Home Reference Source
import {EdgeData} from 'rabbit-hole'
public class | source

EdgeData

Stores edge data separately for each dimension.

With a grid resolution N, there are 3 * (N + 1)² * N edges in total, but the number of edges that actually contain the volume's surface is usually much lower.

Static Method Summary

Static Public Methods
public static

Calculates the amount of edges for one axis based on a given resolution.

Constructor Summary

Public Constructor
public

Constructs new edge data.

Member Summary

Public Members
public

The edges.

public

The surface intersection normals.

public

The material grid resolution.

public

The Zero Crossing interpolation values.

Method Summary

Public Methods
public

createTransferList(transferList: Array): Transferable[]

Creates a list of transferable items.

public

Adopts the given serialised data.

public

edges(cellPosition: Vector3, cellSize: Number): EdgeIterator

Returns a new edge iterator.

public

edgesX(cellPosition: Vector3, cellSize: Number): EdgeIterator

Creates a new edge iterator that only returns edges along the X-axis.

public

edgesY(cellPosition: Vector3, cellSize: Number): EdgeIterator

Creates a new edge iterator that only returns edges along the Y-axis.

public

edgesZ(cellPosition: Vector3, cellSize: Number): EdgeIterator

Creates a new edge iterator that only returns edges along the Z-axis.

public

serialize(deflate: Boolean): Object

Serialises this data.

Static Public Methods

public static calculate1DEdgeCount(n: Number): Number source

Calculates the amount of edges for one axis based on a given resolution.

Params:

NameTypeAttributeDescription
n Number

The grid resolution.

Return:

Number

The amount of edges for a single dimension.

Public Constructors

public constructor(n: Number, x: Number, y: Number, z: Number) source

Constructs new edge data.

Params:

NameTypeAttributeDescription
n Number

The material grid resolution.

x Number
  • optional
  • default: 0

The amount of edges along the X-axis. If <= 0, no memory will be allocated.

y Number
  • optional
  • default: x

The amount of edges along the Y-axis. If omitted, this will be the same as x.

z Number
  • optional
  • default: x

The amount of edges along the Z-axis. If omitted, this will be the same as x.

Public Members

public indices: Uint32Array[] source

The edges.

Edges are stored as starting grid point indices in ascending order. The ending point indices are implicitly defined through the dimension split:

Given a starting point index A, the ending point index B for the X-, Y- and Z-axis is defined as A + 1, A + N and A + N² respectively where N is the grid resolution + 1.

public normals: Float32Array[] source

The surface intersection normals.

The vectors are stored as [x, y, z] float triples and correspond to the order of the edges.

public resolution: Number source

The material grid resolution.

public zeroCrossings: Float32Array[] source

The Zero Crossing interpolation values.

Each value describes the relative surface intersection position on the respective edge. The values correspond to the order of the edges.

Public Methods

public createTransferList(transferList: Array): Transferable[] source

Creates a list of transferable items.

Params:

NameTypeAttributeDescription
transferList Array
  • optional

An optional target list. The transferable items will be added to this list.

Return:

Transferable[]

The transfer list.

public deserialize(object: Object): Deserializable source

Adopts the given serialised data.

Params:

NameTypeAttributeDescription
object Object

Serialised edge data. Can be null.

Return:

Deserializable

This object or null if the given serialised data was null.

public edges(cellPosition: Vector3, cellSize: Number): EdgeIterator source

Returns a new edge iterator.

Params:

NameTypeAttributeDescription
cellPosition Vector3

The position of the volume data cell.

cellSize Number

The size of the volume data cell.

Return:

EdgeIterator

An iterator.

public edgesX(cellPosition: Vector3, cellSize: Number): EdgeIterator source

Creates a new edge iterator that only returns edges along the X-axis.

Params:

NameTypeAttributeDescription
cellPosition Vector3

The position of the volume data cell.

cellSize Number

The size of the volume data cell.

Return:

EdgeIterator

An iterator.

public edgesY(cellPosition: Vector3, cellSize: Number): EdgeIterator source

Creates a new edge iterator that only returns edges along the Y-axis.

Params:

NameTypeAttributeDescription
cellPosition Vector3

The position of the volume data cell.

cellSize Number

The size of the volume data cell.

Return:

EdgeIterator

An iterator.

public edgesZ(cellPosition: Vector3, cellSize: Number): EdgeIterator source

Creates a new edge iterator that only returns edges along the Z-axis.

Params:

NameTypeAttributeDescription
cellPosition Vector3

The position of the volume data cell.

cellSize Number

The size of the volume data cell.

Return:

EdgeIterator

An iterator.

public serialize(deflate: Boolean): Object source

Serialises this data.

Params:

NameTypeAttributeDescription
deflate Boolean
  • optional
  • default: false

Whether the data should be compressed if possible.

Return:

Object

The serialised data.