Skip to content

eulerjs API / @eulerjs/core / Voxels

Voxels ​

Defined in: packages/core/src/Voxels.ts:35

A solid approximated by equal cubes, in the frame of the geometry it was built from. Used to sample how much of a hull is under water, and to give open meshes mass properties.

Constructors ​

Constructor ​

ts
new Voxels(cellSize, cells): Voxels;

Defined in: packages/core/src/Voxels.ts:40

Parameters ​

ParameterType
cellSizenumber
cellsreadonly Vector3[]

Returns ​

Voxels

Properties ​

PropertyModifierTypeDescriptionDefined in
cellsreadonlyreadonly Vector3[]Centres of the cells inside the solid.packages/core/src/Voxels.ts:38
cellSizereadonlynumber-packages/core/src/Voxels.ts:36

Accessors ​

cellVolume ​

Get Signature ​

ts
get cellVolume(): number;

Defined in: packages/core/src/Voxels.ts:45

Returns ​

number


volume ​

Get Signature ​

ts
get volume(): number;

Defined in: packages/core/src/Voxels.ts:49

Returns ​

number

Methods ​

fromGeometry() ​

ts
static fromGeometry(geometry, options?): Voxels;

Defined in: packages/core/src/Voxels.ts:66

Fills a grid of cells over the geometry's bounding box and keeps those inside the surface.

A cell is inside when lines through it along at least two of the three axes cross the surface an odd number of times before reaching it. Voting across axes makes the result robust to holes: an open deck fools the vertical lines but not the horizontal ones. Faces count from both sides, so winding and material settings don't matter.

Parameters ​

ParameterType
geometryBufferGeometry
options?VoxelizeOptions

Returns ​

Voxels


massProperties() ​

ts
massProperties(specification): MassProperties;

Defined in: packages/core/src/Voxels.ts:54

Mass properties of the voxelized solid with uniform density, from its total mass or its density.

Parameters ​

ParameterType
specificationnumber | MassSpecification

Returns ​

MassProperties

Released under the MIT License.