Remove colour space

This commit is contained in:
Lucas Dower 2023-09-14 00:58:18 +01:00
parent 544a2433e5
commit 4cf0a64cb1
6 changed files with 14 additions and 20 deletions

View File

@ -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(),

View File

@ -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';

View File

@ -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,

View File

@ -18,14 +18,22 @@ export class OtS_VoxelMesh {
private _voxels: Map<number, Ots_Voxel_Internal>;
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;
}

View File

@ -71,13 +71,6 @@ export class UV {
}
}
/* eslint-disable */
export enum ColourSpace {
RGB,
LAB
}
/* eslint-enable */
export type TOptional<T> = T | undefined;
export function getRandomID(): string {

View File

@ -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,