This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LinkedList } from "./base"; | |
| import { OrderedSet } from "./OrderedCollections"; | |
| export function delay(ms: number): Promise<void> { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |
| export function nextTick(): Promise<void> { | |
| return new Promise(resolve => { | |
| queueMicrotask(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Callable = (...args: any[]) => any | Promise<any>; | |
| type Streamable = (...args: any[]) => AsyncIterableIterator<any>; | |
| interface Handler { | |
| [key: string]: any; | |
| } | |
| interface Callbacks { | |
| resolve: (value: any) => void; | |
| reject: (reason?: any) => void; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SparseBitmask from "./SparseBitmask"; | |
| import { bitmaskFromWeightedRuns } from "./bitmaskHelpers"; | |
| import { OrderedMap } from "./OrderedCollections"; | |
| import { range } from "./base"; | |
| /** | |
| * [Claude generated] | |
| * | |
| * `cutAndPasteBitmask3d` copies a 3-D sub-volume (the "cut" box) out of `from` | |
| * and XOR-pastes it into `to` at an offset position. Both the cut and paste |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Calculates an ideal viewBox that centers on a target object | |
| * @param objectBBox - Bounding box of the target object | |
| * @param assetWidth - Width of the asset | |
| * @param assetHeight - Height of the asset | |
| * @param targetCoverage - target percentage of the viewport width or height the object should take up | |
| * @param viewportAspectRatio - Aspect ratio of the viewport | |
| * @param minFit - Minimum width and height of the viewport | |
| * @returns - [offsetX, offsetY, viewportWidth, viewportHeight] | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * [Claude generated] | |
| * | |
| * MultiClassBitmask is a layered compositing system for SparseBitmasks — think | |
| * Photoshop layers for bitmasks. Any number of SparseBitmask layers can be | |
| * stacked with integer priorities; at each pixel the highest-priority layer | |
| * that covers it "wins" and determines the rendered value T via a PixelShader. | |
| * The default shader returns the top mask object itself. | |
| * | |
| * --- Internal representation --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SparseBitmask, { | |
| unionRunEnds, | |
| intersectionRunEnds, | |
| subtractionRunEnds, | |
| } from "./SparseBitmask"; | |
| import { | |
| cutAndPasteBitmask3d, | |
| getBoundingBox3d, | |
| getCentroid3d, | |
| getWindowedRunLengths3d, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * [Claude generated] | |
| * | |
| * SparseBitmask is a fixed-length bitmask optimised for sparse, run-heavy data. | |
| * It supports the usual bitwise operations — | |
| * union, intersection, subtraction, symmetric diff — plus | |
| * mutation variants that fire a callback only on the bits that changed, which | |
| * is useful for driving incremental UI updates. Default iteration (`for…of`, | |
| * `forEach`, `map`) yields each bit value (0 or 1) across the full `length`, | |
| * but in practice `getIndices()` and `getIndicesCount()` are used more often |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * [Claude generated] | |
| * | |
| * This file implements two data structures — OrderedSet and OrderedMap — that | |
| * combine a min-heap with a hash map so you get O(log n) insert/delete AND | |
| * cheap O(1) membership tests, plus the ability to iterate in sorted order | |
| * without paying a full sort each time. | |
| * | |
| * --- OrderedSet --- | |
| * Internally it maintains two arrays: `heap` (unsorted, heap-ordered) and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Stack } from './common.js'; | |
| export function decodeBitmask( | |
| encoded: Uint8Array, | |
| maxIndex: number | |
| ): Iterable<number> { | |
| return { | |
| *[Symbol.iterator]() { | |
| const n = maxIndex + 1; | |
| const depth = Math.ceil(Math.log2(n)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MAX_LEVEL = 30; | |
| const STACK = new Float32Array((7 * MAX_LEVEL + 1) * 4); | |
| interface OctreeHeader { | |
| version: number; | |
| precision: number; | |
| maxLevel: number; | |
| nodeCounts: number[]; | |
| leafCount: number; | |
| dataStartOffset: number; |
NewerOlder