From ebcef463bb6c447e788c90fe4235f2504de186d3 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Sat, 26 Jul 2025 13:47:20 +0100 Subject: Add configurable render chunk allocation modes --- src/index.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts index c19edfc..f58cc5b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import {Plane, Sphere} from './models/Geometry'; import {Light} from './models/Light'; import {Albedo, Material} from './models/Material'; import {RaytraceDispatcher} from './RaytraceDispatcher'; -import {RaytraceContext, RaytracerOptions} from './models/RaytraceContext'; +import {ChunkAllocationMode, RaytraceContext, RaytracerOptions} from './models/RaytraceContext'; import {Vector} from './models/Vector'; import {Logger} from './Logger'; @@ -109,8 +109,8 @@ function parseOptions(): RaytracerOptions { refractions: getInputElement('refractions-toggle').checked, maxRecurseDepth: 5, maxDrawDistance: 1000, - bufferDrawCalls: getInputElement('buffer-draw').checked, directMemoryTransfer: getInputElement('direct-transfer').checked, + chunkAllocationMode: getChunkAllocationMode() }; } @@ -132,6 +132,20 @@ function parseResolution(): {width: number; height: number} { } } +function getChunkAllocationMode(): ChunkAllocationMode { + switch (getInputElement('chunk-allocation-mode').value) { + case 'SEQUENTIAL': + default: + return ChunkAllocationMode.SEQUENTIAL; + case 'RANDOM': + return ChunkAllocationMode.RANDOM + case 'CENTER_TO_EDGE': + return ChunkAllocationMode.CENTER_TO_EDGE + case 'EDGE_TO_CENTER': + return ChunkAllocationMode.EDGE_TO_CENTER + } +} + function registerEventListeners() { getRenderButton().addEventListener('click', render); -- cgit v1.2.3