UNPKG

@spearwolf/twopoint5d

Version:

a library to create 2.5d realtime graphics and pixelart with three.js

31 lines 1.02 kB
import { DataChunk2D } from './DataChunk2D.js'; import { base64toUint32Arr } from './base64toUint32Arr.js'; export class DataIdsChunk2D extends DataChunk2D { #uint32Data; constructor(data) { super(data); this.data = data; this.#uint32Data = data.uint32Arr; } prepareData() { const { compression, data } = this.data; if (compression) { console.error('[Data2DChunk] compression feature is not yet implemented', { compression, data }); throw new Error('compression is not yet implemented'); } return base64toUint32Arr(data); } get uint32Arr() { if (this.#uint32Data == null) { this.#uint32Data = this.prepareData(); } return this.#uint32Data; } readDataIdAtLocal(x, y) { return this.uint32Arr[y * this.data.width + x]; } readDataIdAt(x, y) { return this.readDataIdAtLocal(x - this.left, y - this.top); } } //# sourceMappingURL=DataIdsChunk2D.js.map