diff --git a/src/editor/app_context.ts b/src/editor/app_context.ts index 511f10a..32531f9 100644 --- a/src/editor/app_context.ts +++ b/src/editor/app_context.ts @@ -11,7 +11,7 @@ import { MouseManager } from './mouse'; import { MeshType, Renderer } from './renderer/renderer'; import { AppConsole, TMessage } from './ui/console'; import { UI } from './ui/layout'; -import { ColourSpace, EAction } from '../runtime/util'; +import { EAction } from '../runtime/util'; import { ASSERT } from '../runtime/util/error_util'; import { download, downloadAsZip } from '../runtime/util/file_util'; import { LOG_ERROR, Logger } from '../runtime/util/log_util'; @@ -266,7 +266,6 @@ export class AppContext { blockPalette: components.blockPalette.getValue().getBlocks(), dithering: components.dithering.getValue(), ditheringMagnitude: components.ditheringMagnitude.getValue(), - colourSpace: ColourSpace.RGB, fallable: components.fallable.getValue() as FallableBehaviour, resolution: Math.pow(2, components.colourAccuracy.getValue()), calculateLighting: components.calculateLighting.getValue(), diff --git a/src/editor/worker/worker_types.ts b/src/editor/worker/worker_types.ts index 32a5ea7..198cd9a 100644 --- a/src/editor/worker/worker_types.ts +++ b/src/editor/worker/worker_types.ts @@ -1,14 +1,11 @@ -import { BlockMeshParams, FallableBehaviour } from '../../runtime/block_mesh'; +import { BlockMeshParams } from '../../runtime/block_mesh'; import { Bounds } from '../../runtime/bounds'; import { TBlockMeshBufferDescription, TMeshBufferDescription, TVoxelMeshBufferDescription } from '../buffer'; -import { RGBAUtil } from '../../runtime/colour'; import { TStructureExport } from '../../runtime/exporters/base_exporter'; import { TExporters } from '../../runtime/exporters/exporters'; import { MaterialMap } from '../../runtime/mesh'; import { TMessage } from '../ui/console'; -import { ColourSpace } from '../../runtime/util'; import { TAxis } from '../../runtime/util/type_util'; -import { TDithering } from '../../runtime/util/type_util'; import { Vector3 } from '../../runtime/vector'; import { TVoxelisers } from '../../runtime/voxelisers/voxelisers'; import { AppError } from '../util/editor_util'; diff --git a/src/runtime/block_mesh.ts b/src/runtime/block_mesh.ts index e62eb25..01fe17b 100644 --- a/src/runtime/block_mesh.ts +++ b/src/runtime/block_mesh.ts @@ -6,7 +6,7 @@ import { AppRuntimeConstants } from './constants'; import { Ditherer } from './dither'; import { BlockMeshLighting } from './lighting'; import { Palette } from './palette'; -import { ColourSpace, TOptional } from './util'; +import { TOptional } from './util'; import { ASSERT } from './util/error_util'; import { Vector3 } from './vector'; import { TDithering } from './util/type_util'; @@ -31,7 +31,6 @@ export interface BlockMeshParams { blockPalette: string[], dithering: TDithering, ditheringMagnitude: number, - colourSpace: ColourSpace, fallable: FallableBehaviour, resolution: RGBAUtil.TColourAccuracy, calculateLighting: boolean, diff --git a/src/runtime/ots_voxel_mesh.ts b/src/runtime/ots_voxel_mesh.ts index 388cc1c..bb029fd 100644 --- a/src/runtime/ots_voxel_mesh.ts +++ b/src/runtime/ots_voxel_mesh.ts @@ -18,14 +18,22 @@ export class OtS_VoxelMesh { private _voxels: Map; private _isBoundsDirty: boolean; private _bounds: Bounds; + private _replaceMode: OtS_ReplaceMode; public constructor() { this._voxels = new Map(); this._bounds = Bounds.getEmptyBounds(); this._isBoundsDirty = false; + this._replaceMode = 'average'; } - public addVoxel(x: number, y: number, z: number, colour: RGBA, replaceMode: OtS_ReplaceMode) { + public setReplaceMode(replaceMode: OtS_ReplaceMode) { + this._replaceMode = replaceMode; + } + + public addVoxel(x: number, y: number, z: number, colour: RGBA, replaceMode?: OtS_ReplaceMode) { + const useReplaceMode = replaceMode ?? this._replaceMode; + const key = Vector3.Hash(x, y, z); let voxel: (Ots_Voxel_Internal | undefined) = this._voxels.get(key); @@ -39,13 +47,13 @@ export class OtS_VoxelMesh { this._voxels.set(key, voxel); this._bounds.extendByPoint(position); } else { - if (replaceMode === 'average') { + if (useReplaceMode === 'average') { voxel.colour.r = ((voxel.colour.r * voxel.collisions) + colour.r) / (voxel.collisions + 1); voxel.colour.g = ((voxel.colour.g * voxel.collisions) + colour.g) / (voxel.collisions + 1); voxel.colour.b = ((voxel.colour.b * voxel.collisions) + colour.b) / (voxel.collisions + 1); voxel.colour.a = ((voxel.colour.a * voxel.collisions) + colour.a) / (voxel.collisions + 1); ++voxel.collisions; - } else if (replaceMode === 'replace') { + } else if (useReplaceMode === 'replace') { voxel.colour = RGBAUtil.copy(colour); voxel.collisions = 1; } diff --git a/src/runtime/util.ts b/src/runtime/util.ts index d02f265..fd121d9 100644 --- a/src/runtime/util.ts +++ b/src/runtime/util.ts @@ -71,13 +71,6 @@ export class UV { } } -/* eslint-disable */ -export enum ColourSpace { - RGB, - LAB -} -/* eslint-enable */ - export type TOptional = T | undefined; export function getRandomID(): string { diff --git a/tools/headless-config.ts b/tools/headless-config.ts index f305b5c..a2cda6c 100644 --- a/tools/headless-config.ts +++ b/tools/headless-config.ts @@ -1,5 +1,4 @@ import { PALETTE_ALL_RELEASE } from '../res/palettes/all'; -import { ColourSpace } from '../src/runtime/util'; import { Vector3 } from '../src/runtime/vector'; import { THeadlessConfig } from './headless'; @@ -20,7 +19,6 @@ export const headlessConfig: THeadlessConfig = { blockPalette: PALETTE_ALL_RELEASE, // Must be a palette name that exists in /resources/palettes dithering: 'ordered', ditheringMagnitude: 32, - colourSpace: ColourSpace.RGB, fallable: 'replace-falling', resolution: 32, calculateLighting: false,