diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2025-07-26 13:47:20 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2025-07-26 13:47:20 +0100 |
| commit | ebcef463bb6c447e788c90fe4235f2504de186d3 (patch) | |
| tree | c7500ef92b51544195ef9fb75744ac2ce39091a8 /src/index.ts | |
| parent | 10bfc58085c6ab7e62077a1a9b6a6d922fffb025 (diff) | |
| download | js-raytracer-ebcef463bb6c447e788c90fe4235f2504de186d3.tar.xz js-raytracer-ebcef463bb6c447e788c90fe4235f2504de186d3.zip | |
Add configurable render chunk allocation modes
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 18 |
1 files changed, 16 insertions, 2 deletions
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); |