@margoengine/points 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +794 -3
  4. package/dist/attributes-DNc-1pdr.js +256 -0
  5. package/dist/attributes.d.ts +48 -0
  6. package/dist/clip.d.ts +55 -0
  7. package/dist/clip.js +122 -0
  8. package/dist/cloud-B4O_G-Df.js +545 -0
  9. package/dist/cloud.d.ts +155 -0
  10. package/dist/color.d.ts +1 -0
  11. package/dist/copc.d.ts +55 -0
  12. package/dist/copc.js +130 -0
  13. package/dist/depth-video.d.ts +98 -0
  14. package/dist/depth-video.js +164 -0
  15. package/dist/e57.d.ts +163 -0
  16. package/dist/e57.js +624 -0
  17. package/dist/frame.d.ts +9 -0
  18. package/dist/index.d.ts +16 -0
  19. package/dist/index.js +1246 -0
  20. package/dist/las.d.ts +213 -0
  21. package/dist/las.js +500 -0
  22. package/dist/laz.d.ts +50 -0
  23. package/dist/laz.js +1025 -0
  24. package/dist/material.d.ts +167 -0
  25. package/dist/math.d.ts +103 -0
  26. package/dist/octree.d.ts +182 -0
  27. package/dist/octree.js +360 -0
  28. package/dist/pick.d.ts +76 -0
  29. package/dist/pick.js +192 -0
  30. package/dist/plugin.d.ts +235 -0
  31. package/dist/potree.d.ts +70 -0
  32. package/dist/potree.js +451 -0
  33. package/dist/range-BQuJAjUM.js +23 -0
  34. package/dist/range.d.ts +4 -0
  35. package/dist/screen-door-CALlYs39.js +7 -0
  36. package/dist/shaders-Deu8H36P.js +278 -0
  37. package/dist/shaders.d.ts +52 -0
  38. package/dist/shared/fog.d.ts +33 -0
  39. package/dist/shared/pass.d.ts +53 -0
  40. package/dist/shared/selection-mask.d.ts +52 -0
  41. package/dist/shared/style-expression.d.ts +18 -0
  42. package/dist/sprites.d.ts +78 -0
  43. package/dist/storage-limit.d.ts +6 -0
  44. package/dist/style.d.ts +124 -0
  45. package/dist/style.js +708 -0
  46. package/dist/surfels.d.ts +95 -0
  47. package/dist/surfels.js +538 -0
  48. package/dist/survey-DToZwkJv.js +46 -0
  49. package/dist/survey.d.ts +10 -0
  50. package/dist/tier-BcFbLPVT.js +91 -0
  51. package/dist/tier.d.ts +6 -0
  52. package/package.json +96 -6
@@ -0,0 +1,167 @@
1
+ import { type ColorInput } from './color.js';
2
+ /**
3
+ * Anything the plugin can sample: a GPUTexture you own (created on the engine's device), a function that makes one for
4
+ * a device (called once per device, so it comes back after a device restore), or an image source it uploads itself
5
+ * with `copyExternalImageToTexture` (ImageBitmap, canvas, OffscreenCanvas, image, video, ImageData). A plain GPUTexture
6
+ * held at a device restore is reported once through `engine.onError` and the material draws untextured until `map` is
7
+ * given a new one (docs/conventions.md, "Borrowed GPU objects").
8
+ */
9
+ export type PointsTextureSource = GPUTexture | ((device: GPUDevice) => GPUTexture) | ImageBitmap | HTMLCanvasElement | OffscreenCanvas | HTMLImageElement | HTMLVideoElement | ImageData;
10
+ /** Blend mode: 'normal' is alpha over, 'additive' adds color to the target. */
11
+ export type PointsBlending = 'normal' | 'additive';
12
+ /**
13
+ * Options shared by `PointsMaterialOptions` and `SpriteMaterialOptions`. Validated on set and every frame:
14
+ * opacity or alphaTest outside 0..1, an unknown filter or blending, or a negative color throw a RangeError;
15
+ * non-boolean flags a TypeError.
16
+ */
17
+ export interface BaseMaterialOptions {
18
+ /** Base color. '#rrggbb', '#rgb' or 0xrrggbb are sRGB; an [r, g, b] array is linear RGB. Default white. */
19
+ color?: ColorInput;
20
+ /** Multiplies alpha. Default 1. */
21
+ opacity?: number;
22
+ /** Texture multiplied into the color. Image sources are uploaded as sRGB (`rgba8unorm-srgb`). Default null. */
23
+ map?: PointsTextureSource | null;
24
+ /** Texture filtering. Default 'linear'. */
25
+ mapFilter?: 'linear' | 'nearest';
26
+ /**
27
+ * Generates mips of an uploaded image source so a map stays smooth when drawn small. Default true for points, false
28
+ * for sprites, as mips bleed between the cells of an atlas. A `GPUTexture` keeps the mips it has.
29
+ */
30
+ mipmaps?: boolean;
31
+ /** Fragments whose alpha (before edge antialiasing) is below this are discarded. Default 0. */
32
+ alphaTest?: number;
33
+ /** Blend without writing depth. Default false for points, true for sprites. */
34
+ transparent?: boolean;
35
+ /** 'normal' (alpha over) or 'additive'. Default 'normal'. */
36
+ blending?: PointsBlending;
37
+ /** Test against the scene depth with reversed-Z `greater-equal`. Default true. */
38
+ depthTest?: boolean;
39
+ /** Write depth. Default `!transparent`. */
40
+ depthWrite?: boolean;
41
+ /** Fogged by the plugin's fog (`PointsPlugin.setFog`); false keeps this material clear. Default true. */
42
+ fog?: boolean;
43
+ /**
44
+ * Up to 6 world-space planes `[a, b, c, d]`: fragments at points with `a x + b y + c z + d < 0` are cut away (the
45
+ * `@margoengine/materials` convention). Live; default none.
46
+ */
47
+ clippingPlanes?: readonly (readonly number[])[];
48
+ /** false (default): cut away what is behind any plane. true: only what is behind every plane (their intersection). */
49
+ clipIntersection?: boolean;
50
+ }
51
+ declare abstract class BaseMaterial {
52
+ /** Linear RGB. */
53
+ readonly color: Float32Array<ArrayBuffer>;
54
+ opacity: number;
55
+ mapFilter: 'linear' | 'nearest';
56
+ mipmaps: boolean;
57
+ alphaTest: number;
58
+ transparent: boolean;
59
+ blending: PointsBlending;
60
+ depthTest: boolean;
61
+ /** null means `!transparent`. */
62
+ depthWrite: boolean | null;
63
+ fog: boolean;
64
+ /** Bumped when `map` changes or `needsUpdate()` is called; the plugin re-uploads image sources. */
65
+ mapVersion: number;
66
+ private source;
67
+ /** Clipping planes, four normalised numbers each (at most 24). */
68
+ private clipping;
69
+ private clipAll;
70
+ protected constructor(transparent: boolean, mipmaps: boolean);
71
+ get map(): PointsTextureSource | null;
72
+ set map(value: PointsTextureSource | null);
73
+ /**
74
+ * Up to 6 world-space planes `[a, b, c, d]`; fragments at points with `a x + b y + c z + d < 0` are discarded. Points
75
+ * test each fragment's world position on the point's camera-facing disc (on the sphere for `shading: 'sphere'`);
76
+ * world-sized sprites each fragment's position on the quad, pixel-sized sprites their centre. Reading gives
77
+ * normalised copies; assign a new list to change them (live, next frame). Throws TypeError for a malformed plane,
78
+ * RangeError for more than 6.
79
+ */
80
+ get clippingPlanes(): number[][];
81
+ set clippingPlanes(planes: readonly (readonly number[])[]);
82
+ /** false (default): `clippingPlanes` cut away what is behind any plane; true: only what is behind every plane. */
83
+ get clipIntersection(): boolean;
84
+ set clipIntersection(value: boolean);
85
+ /** Re-uploads an image source whose pixels changed (for example a canvas you drew into). */
86
+ needsUpdate(): void;
87
+ setColor(color: ColorInput): this;
88
+ /** Depth writes after resolving the `null` default. */
89
+ get writesDepth(): boolean;
90
+ protected apply(options: BaseMaterialOptions): void;
91
+ validate(): void;
92
+ }
93
+ /** Point footprint: 'square', or 'round' (an antialiased disc). */
94
+ export type PointShape = 'square' | 'round';
95
+ /** 'flat' fills the footprint with one color; 'sphere' shades a lit sphere impostor with curved depth. */
96
+ export type PointShading = 'flat' | 'sphere';
97
+ /**
98
+ * Options for `PointsMaterial`. Besides the base checks, a negative or non-finite size, min above max pixel
99
+ * size, or an unknown sizeUnits, shape or shading throw a RangeError.
100
+ */
101
+ export interface PointsMaterialOptions extends BaseMaterialOptions {
102
+ /** Optional screen-door coverage [lower,upper], both in [0,1]. Default full coverage. */
103
+ ditherFade?: readonly [number, number];
104
+ /** Point diameter: pixels, or world units when `sizeUnits` is 'world'. Per-point sizes multiply it. Default 4. */
105
+ size?: number;
106
+ /** 'pixels' keeps a constant screen size; 'world' attenuates with distance. Default 'pixels'. */
107
+ sizeUnits?: 'pixels' | 'world';
108
+ /** Alias: true is `sizeUnits: 'world'`, false is 'pixels'. */
109
+ sizeAttenuation?: boolean;
110
+ /** Clamp of the final diameter in pixels. Defaults 1 and 256. */
111
+ minPixelSize?: number;
112
+ /** Upper clamp of the final diameter in pixels; must be at least `minPixelSize`. Default 256. */
113
+ maxPixelSize?: number;
114
+ /** 'square', or 'round' (an antialiased disc). Default 'square'. A `map` is sampled across either shape. */
115
+ shape?: PointShape;
116
+ /** Use per-point colors when the cloud has them. Default true. */
117
+ vertexColors?: boolean;
118
+ /** 'sphere' shades each point as a lit sphere impostor and writes its curved depth (implies a round shape). Default 'flat'. */
119
+ shading?: PointShading;
120
+ /** Eye-dome lighting: darkens depth discontinuities between points in a screen-space pass. Default false. */
121
+ edl?: boolean;
122
+ /**
123
+ * Largest multiple of `size` (and of both pixel clamps) a point grows to when the plugin's `pointBudget` draws fewer
124
+ * points than the cloud has in view, so a thinned cloud still covers its surface. The multiple is the square root of
125
+ * visible over drawn points, at most this value. 0 or 1 keeps the size (default 0); finite, 0 or more.
126
+ */
127
+ adaptiveSize?: number;
128
+ }
129
+ /** Point cloud material. Read every frame; change fields freely. */
130
+ export declare class PointsMaterial extends BaseMaterial {
131
+ /** Live optional screen-door coverage interval, [0,1] when unset. */
132
+ ditherFade?: readonly [number, number];
133
+ size: number;
134
+ sizeUnits: 'pixels' | 'world';
135
+ minPixelSize: number;
136
+ maxPixelSize: number;
137
+ shape: PointShape;
138
+ vertexColors: boolean;
139
+ shading: PointShading;
140
+ edl: boolean;
141
+ adaptiveSize: number;
142
+ constructor(options?: PointsMaterialOptions);
143
+ get sizeAttenuation(): boolean;
144
+ set sizeAttenuation(value: boolean);
145
+ set(options: PointsMaterialOptions): this;
146
+ validate(): void;
147
+ }
148
+ /** Options for `SpriteMaterial`. A non-finite rotation or unknown sizeUnits throws a RangeError. */
149
+ export interface SpriteMaterialOptions extends BaseMaterialOptions {
150
+ /** Added to every sprite's own rotation, radians counterclockwise. Default 0. */
151
+ rotation?: number;
152
+ /** 'world' sizes attenuate with distance; 'pixels' keeps a constant screen size. Default 'world'. */
153
+ sizeUnits?: 'world' | 'pixels';
154
+ /** Alias: false is `sizeUnits: 'pixels'`. */
155
+ sizeAttenuation?: boolean;
156
+ }
157
+ /** Sprite material. Transparent by default. */
158
+ export declare class SpriteMaterial extends BaseMaterial {
159
+ rotation: number;
160
+ sizeUnits: 'world' | 'pixels';
161
+ constructor(options?: SpriteMaterialOptions);
162
+ get sizeAttenuation(): boolean;
163
+ set sizeAttenuation(value: boolean);
164
+ set(options: SpriteMaterialOptions): this;
165
+ validate(): void;
166
+ }
167
+ export {};
package/dist/math.d.ts ADDED
@@ -0,0 +1,103 @@
1
+ /** Marks a point that belongs to no block (non-finite position at build time). */
2
+ export declare const NO_BLOCK = 4294967295;
3
+ /** Blocks of a chunked point cloud. Block `b` draws slots `starts[b] .. starts[b] + counts[b]` of `order`. */
4
+ export interface PointBlocks {
5
+ /** Slot to point index. Within each block the slots are shuffled, so any prefix is a uniform random sample. */
6
+ readonly order: Uint32Array;
7
+ /** First slot of each block. */
8
+ readonly starts: Uint32Array;
9
+ /** Points in each block. */
10
+ readonly counts: Uint32Array;
11
+ /** Local-space axis-aligned bounds, six floats per block: min xyz, max xyz. */
12
+ readonly bounds: Float32Array;
13
+ /** Block of each point, or `NO_BLOCK`. */
14
+ readonly blockOf: Uint32Array;
15
+ /** Number of blocks. */
16
+ readonly length: number;
17
+ /** Points that are in a block (finite positions). */
18
+ readonly finite: number;
19
+ }
20
+ /** Small, fast, seedable PRNG (mulberry32, `@margoengine/math/mathutils` createRandom). Returns floats in [0, 1). */
21
+ export declare const random: (seed: number) => () => number;
22
+ /**
23
+ * Splits points into spatially compact blocks of at most `blockSize` points (median split along the longest
24
+ * axis, like a kd-tree), then shuffles each block with a seeded PRNG so that drawing the first `n` slots of a
25
+ * block gives an even random subsample (Potree-style progressive level of detail).
26
+ */
27
+ export declare function buildBlocks(positions: ArrayLike<number>, count: number, blockSize?: number, seed?: number): PointBlocks;
28
+ /**
29
+ * Grows the bounds of the blocks that hold points `start .. start + count` so they contain the new positions.
30
+ * Bounds only grow; call `buildBlocks` again (PointCloud.rebuild) to tighten them. Returns how many blocks grew.
31
+ */
32
+ export declare function expandBlockBounds(blocks: PointBlocks, positions: ArrayLike<number>, start: number, count: number): number;
33
+ /**
34
+ * Transforms local block bounds by a column-major model matrix into a world-space center and half extent
35
+ * (the box that encloses the transformed box). Writes six floats to `out`: center xyz, extent xyz.
36
+ */
37
+ export declare function worldBox(bounds: ArrayLike<number>, block: number, model: ArrayLike<number>, out: Float64Array | number[]): void;
38
+ /** True when a world box (center, half extent) is at least partly inside all six planes (`n.p + d >= 0` inside). */
39
+ export declare function boxInFrustum(box: ArrayLike<number>, planes: ArrayLike<number>, margin?: number): boolean;
40
+ /**
41
+ * Frustum-culls every non-empty block against `planes` (the 24 floats of `camera.planes`, world space) after
42
+ * transforming its bounds by `model`. Writes visible block ids to `out` and returns how many there are.
43
+ */
44
+ export declare function cullBlocks(blocks: Pick<PointBlocks, 'bounds' | 'counts' | 'length'>, model: ArrayLike<number>, planes: ArrayLike<number>, out: Uint32Array, margin?: number): number;
45
+ /**
46
+ * Approximate screen area in pixels of a world box seen from `eye`: the projected disc of its bounding sphere,
47
+ * capped at the viewport. `projScale` is pixels per world unit at distance 1 (`0.5 * height / tan(fov / 2)`).
48
+ */
49
+ export declare function screenArea(box: ArrayLike<number>, eye: ArrayLike<number>, projScale: number, width: number, height: number, orthographic?: boolean): number;
50
+ /**
51
+ * Shares a point budget between blocks. Each block gets at most its own count; the rest is split in proportion
52
+ * to `weights` (screen area), and whatever a small block cannot use flows to the others (water filling).
53
+ * When the counts fit in the budget every block is drawn in full. Writes per-block allotments to `out` and
54
+ * returns their sum, which equals `min(budget, sum of counts)`.
55
+ */
56
+ export declare function allocateBudget(counts: ArrayLike<number>, weights: ArrayLike<number>, length: number, budget: number, out: Uint32Array | number[]): number;
57
+ /**
58
+ * Projects a local point through a column-major model-view-projection matrix to device pixels (origin top left,
59
+ * y down), using math/mat4 projectPoint. Writes x, y and perspective clip w (orthographic normalized depth)
60
+ * to `out`; returns false without changing `out` when the point is behind the camera or outside the
61
+ * near/far range (reversed-Z clip z in 0..w).
62
+ */
63
+ export declare function projectToPixels(mvp: ArrayLike<number>, x: number, y: number, z: number, width: number, height: number, out: Float64Array | number[]): boolean;
64
+ /** Candidate slots for picking: `count` slots starting at `start` in `order` (or point indices directly when `order` is null). */
65
+ export interface PickRange {
66
+ start: number;
67
+ count: number;
68
+ }
69
+ /** The nearest point found by `pickPoint`, in device pixels. */
70
+ export interface PointsPickHit {
71
+ /** Point index in the cloud's arrays. */
72
+ index: number;
73
+ /** Distance from the pick position in device pixels. */
74
+ distance: number;
75
+ /** Clip w (view depth) of the point. */
76
+ depth: number;
77
+ /** Device-pixel position of the point. */
78
+ screen: [number, number];
79
+ }
80
+ /**
81
+ * Nearest point to the device-pixel position (x, y) among the given slot ranges, within `radius` pixels.
82
+ * Points within half a pixel of the best distance are tie-broken by depth, so the front point wins. Points for which
83
+ * `hidden(index)` is true (not drawn, such as those a filter mask hides) are skipped.
84
+ */
85
+ export declare function pickPoint(positions: ArrayLike<number>, order: ArrayLike<number> | null, ranges: readonly PickRange[], mvp: ArrayLike<number>, width: number, height: number, x: number, y: number, radius: number, hidden?: (index: number) => boolean): PointsPickHit | null;
86
+ /** Screen rectangle [x0, y0, x1, y1] in device pixels of a world box, or null if any corner is behind the camera. */
87
+ export declare function boxScreenRect(box: ArrayLike<number>, viewProj: ArrayLike<number>, width: number, height: number): [number, number, number, number] | null;
88
+ /**
89
+ * Writes `count` colours as four float32 each into `out` from point `offset`, 3 or 4 components a point in `source`.
90
+ * Bytes are 0..255; numbers keep their value, so HDR colours stay above 1.
91
+ * @throws RangeError for too few values, a range past the end, or a negative or non-finite colour.
92
+ */
93
+ export declare function packFloatColors(source: ArrayLike<number>, components: number, count: number, out: Float32Array, offset?: number): Float32Array;
94
+ /**
95
+ * Packs per-point colors into RGBA8 words (r in the low byte), the layout WGSL `unpack4x8unorm` reads.
96
+ * `source` holds `components` (3 or 4) values per point: floats in 0..1, or 0..255 bytes for Uint8 arrays.
97
+ * Missing alpha becomes 255.
98
+ */
99
+ export declare function packColors(source: ArrayLike<number>, components: number, count: number, out: Uint32Array, offset?: number): Uint32Array;
100
+ /** Merges `[start, end)` ranges in place (sorted, overlapping or touching ranges joined) and returns them. */
101
+ export declare function mergeRanges(ranges: Array<[number, number]>): Array<[number, number]>;
102
+ /** Atlas rectangle `[u0, v0, u1, v1]` (origin top left) of cell `index` in a grid of `columns` x `rows`, read row by row. */
103
+ export declare function atlasRect(index: number, columns: number, rows: number, padding?: number): [number, number, number, number];
@@ -0,0 +1,182 @@
1
+ /// <reference lib="esnext.disposable" preserve="true" />
2
+ import type { EngineKernel, EnginePlugin, Mesh } from '@margoengine/core';
3
+ import { PointCloud, type PointCloudOptions } from './cloud.js';
4
+ import { PointsMaterial, type PointsMaterialOptions } from './material.js';
5
+ /** One node: a cube, how many points it holds and its eight child slots. */
6
+ export interface OctreeNode {
7
+ /** 'r' for the root, then one octant digit (0 to 7) per level: x is bit 0, y bit 1, z bit 2. */
8
+ readonly id: string;
9
+ readonly level: number;
10
+ /** minX, minY, minZ, maxX, maxY, maxZ. */
11
+ readonly bounds: Float64Array;
12
+ /** Grid cell size of this node's sample (points are at least about this far apart). */
13
+ readonly spacing: number;
14
+ readonly count: number;
15
+ readonly parent: OctreeNode | null;
16
+ readonly children: readonly (OctreeNode | null)[];
17
+ }
18
+ /** A node's points, as `PointCloud` takes them. */
19
+ export interface OctreeNodeData {
20
+ positions: Float32Array;
21
+ colors?: Uint8Array | Float32Array | null;
22
+ colorComponents?: 3 | 4;
23
+ /** Point-major scalar or vector attributes, preserved in source point order. */
24
+ attributes?: Readonly<Record<string, PointAttribute>>;
25
+ /** Stable source rows, when supplied by an in-memory source. Otherwise use node id and point index. */
26
+ rowIds?: ArrayLike<string | number>;
27
+ }
28
+ /** Numeric columns supported by octree sources. */
29
+ export type PointAttribute = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
30
+ /** Where nodes come from: their hierarchy up front, their points on demand. */
31
+ export interface OctreeSource {
32
+ readonly root: OctreeNode;
33
+ /** Loads one node's points; honour `signal`. */
34
+ load(node: OctreeNode, signal: AbortSignal): OctreeNodeData | Promise<OctreeNodeData>;
35
+ }
36
+ /** Options of `buildOctree`. */
37
+ export interface OctreeOptions {
38
+ /** A node with this many points or fewer is a leaf. Default 20,000. */
39
+ maxPointsPerNode?: number;
40
+ /** Sample grid cells per axis of each node. Default 128. */
41
+ grid?: number;
42
+ /** Deepest level, a whole number from 0 to 64. Default 16. */
43
+ maxDepth?: number;
44
+ /** Shuffle seed (the sample of a node is the first point per grid cell in shuffled order). Default 1. */
45
+ seed?: number;
46
+ }
47
+ /** An octree built in memory; it is its own `OctreeSource`. */
48
+ export declare class MemoryOctree implements OctreeSource {
49
+ private readonly positions;
50
+ private readonly colors?;
51
+ private readonly colorComponents;
52
+ private readonly attributes;
53
+ private readonly rowIds?;
54
+ readonly root: OctreeNode;
55
+ /** Point indices of each node into the source arrays. */
56
+ readonly indices: ReadonlyMap<OctreeNode, Uint32Array>;
57
+ constructor(root: OctreeNode, indices: Map<OctreeNode, Uint32Array>, positions: ArrayLike<number>, colors?: ArrayLike<number> | null | undefined, colorComponents?: 3 | 4, attributes?: Readonly<Record<string, PointAttribute>>, rowIds?: ArrayLike<string | number> | undefined);
58
+ /** Every node, parents first. */
59
+ nodes(): IterableIterator<OctreeNode>;
60
+ load(node: OctreeNode): OctreeNodeData;
61
+ }
62
+ /**
63
+ * Builds a nested-sample octree over a cloud (positions xyz, optional colours with 3 or 4 components). Each node keeps
64
+ * the first point per grid cell of its cube (in a seeded shuffle, so the sample is even and random), and passes the
65
+ * rest to its octants. Every point lands in exactly one node.
66
+ */
67
+ export declare function buildOctree(cloud: {
68
+ positions: ArrayLike<number>;
69
+ colors?: ArrayLike<number> | null;
70
+ colorComponents?: 3 | 4;
71
+ attributes?: Readonly<Record<string, PointAttribute>>;
72
+ rowIds?: ArrayLike<string | number>;
73
+ }, options?: OctreeOptions): MemoryOctree;
74
+ /** The camera in world coordinates, for `OctreeCloud.select`. */
75
+ export interface OctreeView {
76
+ readonly position: ArrayLike<number>;
77
+ /** 24 numbers, 6 planes (a x + b y + c z + d >= 0 inside); omit to keep every node. */
78
+ readonly planes?: ArrayLike<number>;
79
+ readonly screenHeight: number;
80
+ /** Vertical field of view, degrees. Default 60. */
81
+ readonly fov?: number;
82
+ }
83
+ /** Options of `OctreeCloud`. */
84
+ export interface OctreeCloudOptions {
85
+ /** Most points drawn per frame. Default 2,000,000. */
86
+ pointBudget?: number;
87
+ /** Refine a node while its bounding sphere spans more than this many pixels. Default 150. */
88
+ minNodePixels?: number;
89
+ /** Points kept loaded (drawn or not); least recently used nodes past it are freed. Default 3 x pointBudget. */
90
+ maxLoadedPoints?: number;
91
+ /** Positive safe integer number of nodes loading at once. Default 4. */
92
+ maxConcurrentLoads?: number;
93
+ /** Material shared by every node's cloud. */
94
+ material?: PointsMaterial | PointsMaterialOptions;
95
+ /**
96
+ * Grows each point to fill the gaps of the nodes drawn around it, so a subsampled part of a scan looks solid. The
97
+ * material then measures in world units with `size` 1 and takes its size from each point; the size it had stays the
98
+ * smallest a point draws, and `maxPixelSize` the largest. Under a transform `size` follows its longest axis, and a
99
+ * world size counts in the cloud's own units. Default false.
100
+ */
101
+ adaptiveSize?: boolean | OctreeAdaptiveSize;
102
+ /** Other `PointCloud` options for every node (colour space, block size). */
103
+ cloud?: Omit<PointCloudOptions, 'positions' | 'colors' | 'colorComponents' | 'material'>;
104
+ }
105
+ /** Options of `OctreeCloudOptions.adaptiveSize`. */
106
+ export interface OctreeAdaptiveSize {
107
+ /** Point diameter as a multiple of the spacing around it; 1 only just touches on a perfect grid. Default 1.5. */
108
+ scale?: number;
109
+ }
110
+ /** The part of `PointsPlugin` an `OctreeCloud` uses. */
111
+ export interface OctreePointsHost {
112
+ add<T extends PointCloud>(cloud: T): T;
113
+ remove(cloud: unknown): void;
114
+ }
115
+ /** Draws an octree under a point budget; attach it to the engine (it updates every frame) or call `select` yourself. */
116
+ export declare class OctreeCloud implements EnginePlugin {
117
+ private readonly points;
118
+ readonly name: string;
119
+ readonly source: OctreeSource;
120
+ /** The material every node draws with. */
121
+ readonly material: PointsMaterial;
122
+ /** Column-major model matrix of the whole octree, used when it is not attached to a mesh. Write to it freely. */
123
+ readonly matrix: Float32Array<ArrayBuffer>;
124
+ pointBudget: number;
125
+ minNodePixels: number;
126
+ maxLoadedPoints: number;
127
+ /** Nodes drawn in the last selection, largest on screen first. */
128
+ visible: OctreeNode[];
129
+ /** Points drawn in the last selection, and points loaded. */
130
+ stats: {
131
+ drawn: number;
132
+ loaded: number;
133
+ loading: number;
134
+ failed: number;
135
+ };
136
+ disposed: boolean;
137
+ private engine?;
138
+ private mesh;
139
+ private readonly localPlanes;
140
+ private frame;
141
+ private readonly loaded;
142
+ private readonly failed;
143
+ private readonly maxConcurrent;
144
+ private readonly sizeScale;
145
+ /** Smallest world diameter of a point under `adaptiveSize`. */
146
+ private readonly sizeFloor;
147
+ private sizesPending;
148
+ private readonly cloudOptions;
149
+ private errorListener?;
150
+ /** Same as `engine.use(new OctreeCloud(points, source, options))`. */
151
+ static attach(engine: EngineKernel, points: OctreePointsHost, source: OctreeSource, options?: OctreeCloudOptions): OctreeCloud;
152
+ constructor(points: OctreePointsHost, source: OctreeSource, options?: OctreeCloudOptions);
153
+ setup(engine: EngineKernel): void;
154
+ /** The mesh whose world matrix the octree follows, or null. */
155
+ get attachedMesh(): Mesh | null;
156
+ /**
157
+ * Follows a core mesh's world matrix and its visibility, so a scan can be placed, rotated and animated in the scene;
158
+ * pass null to use `matrix` again. A hidden mesh hides the octree and stops its loading.
159
+ */
160
+ attach(mesh: Mesh | null): this;
161
+ /** Called with the node and error when a node fails to load (it is then skipped until `retry()`). */
162
+ onError(listener: (node: OctreeNode, error: unknown) => void): void;
163
+ /** Forgets failed nodes so they load again. */
164
+ retry(): void;
165
+ onPreUpdate(): void;
166
+ /** Chooses, shows and loads the nodes for a view; returns the nodes drawn. */
167
+ select(view: OctreeView): OctreeNode[];
168
+ /** World planes in the cloud's own coordinates: a plane times the matrix tests the local point it maps to. */
169
+ private planesInCloud;
170
+ /** Diameter in the cloud's own units of a point in a place of this many points per square unit. */
171
+ private pointSize;
172
+ /** Rewrites the point sizes of drawn nodes whose drawn children changed, largest on screen first. */
173
+ private fitSizes;
174
+ /** Sizes each point of a drawn node by the density where it lies: this node's chain, then drawn nodes below it. */
175
+ private sizeNode;
176
+ private request;
177
+ private load;
178
+ private evict;
179
+ /** Frees every node's cloud and stops loading. */
180
+ dispose(): void;
181
+ [Symbol.dispose](): void;
182
+ }