diff --git a/src/voxelisers/base-voxeliser.ts b/src/voxelisers/base-voxeliser.ts index 64e3db5..70fc84a 100644 --- a/src/voxelisers/base-voxeliser.ts +++ b/src/voxelisers/base-voxeliser.ts @@ -4,9 +4,21 @@ import { Vector3 } from '../vector'; import { Mesh } from '../mesh'; import { VoxelMesh, VoxelMeshParams} from '../voxel_mesh'; import { TextureFiltering } from '../texture'; +import { StatusHandler } from '../status'; export abstract class IVoxeliser { - public abstract voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh; + public voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { + const voxelMesh = this._voxelise(mesh, voxelMeshParams); + + StatusHandler.Get.add('info', `Voxel mesh has ${voxelMesh.getVoxelCount().toLocaleString()} voxels`); + + const dim = voxelMesh.getBounds().getDimensions().addScalar(1); + StatusHandler.Get.add('info', `Dimensions are ${dim.x.toLocaleString()}x${dim.y.toLocaleString()}x${dim.z.toLocaleString()} voxels`); + + return voxelMesh; + } + + protected abstract _voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh; protected _getVoxelColour(mesh: Mesh, triangle: UVTriangle, materialName: string, location: Vector3, filtering: TextureFiltering): RGB { const area01 = new Triangle(triangle.v0, triangle.v1, location).getArea(); diff --git a/src/voxelisers/bvh-ray-voxeliser.ts b/src/voxelisers/bvh-ray-voxeliser.ts index beb2c0d..a4ab1a7 100644 --- a/src/voxelisers/bvh-ray-voxeliser.ts +++ b/src/voxelisers/bvh-ray-voxeliser.ts @@ -12,7 +12,7 @@ const bvhtree = require('bvh-tree'); * on each of the principle angles and testing for intersections */ export class BVHRayVoxeliser extends IVoxeliser { - public override voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { + protected override _voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { const voxelMesh = new VoxelMesh(mesh, voxelMeshParams); const scale = (voxelMeshParams.desiredHeight - 1) / Mesh.desiredHeight; const offset = (voxelMeshParams.desiredHeight % 2 === 0) ? new Vector3(0.0, 0.5, 0.0) : new Vector3(0.0, 0.0, 0.0); diff --git a/src/voxelisers/normal-corrected-ray-voxeliser.ts b/src/voxelisers/normal-corrected-ray-voxeliser.ts index c37cffd..765670e 100644 --- a/src/voxelisers/normal-corrected-ray-voxeliser.ts +++ b/src/voxelisers/normal-corrected-ray-voxeliser.ts @@ -20,7 +20,7 @@ export class NormalCorrectedRayVoxeliser extends IVoxeliser { private _size!: Vector3; private _offset!: Vector3; - public override voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { + protected override _voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { this._mesh = mesh; this._voxelMesh = new VoxelMesh(mesh, voxelMeshParams); this._voxelMeshParams = voxelMeshParams; diff --git a/src/voxelisers/ray-voxeliser.ts b/src/voxelisers/ray-voxeliser.ts index b42629c..f981b95 100644 --- a/src/voxelisers/ray-voxeliser.ts +++ b/src/voxelisers/ray-voxeliser.ts @@ -19,7 +19,7 @@ export class RayVoxeliser extends IVoxeliser { private _scale!: number; private _offset!: Vector3; - public override voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { + protected override _voxelise(mesh: Mesh, voxelMeshParams: VoxelMeshParams): VoxelMesh { this._mesh = mesh; this._voxelMesh = new VoxelMesh(mesh, voxelMeshParams); this._voxelMeshParams = voxelMeshParams;