@margoengine/points 0.0.0-stage → 1.0.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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +876 -2
- package/dist/attributes-DNc-1pdr.js +256 -0
- package/dist/attributes.d.ts +48 -0
- package/dist/clip.d.ts +55 -0
- package/dist/clip.js +122 -0
- package/dist/cloud-B4O_G-Df.js +545 -0
- package/dist/cloud.d.ts +155 -0
- package/dist/color.d.ts +1 -0
- package/dist/copc-write.d.ts +95 -0
- package/dist/copc-write.js +318 -0
- package/dist/copc.d.ts +55 -0
- package/dist/copc.js +127 -0
- package/dist/depth-video.d.ts +98 -0
- package/dist/depth-video.js +164 -0
- package/dist/e57.d.ts +163 -0
- package/dist/e57.js +624 -0
- package/dist/frame.d.ts +14 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1246 -0
- package/dist/las.d.ts +213 -0
- package/dist/las.js +500 -0
- package/dist/laz-encode-CHXgHra_.js +446 -0
- package/dist/laz-encode.d.ts +14 -0
- package/dist/laz-model-DCphHLqH.js +385 -0
- package/dist/laz-model.d.ts +47 -0
- package/dist/laz-write.d.ts +46 -0
- package/dist/laz-write.js +75 -0
- package/dist/laz.d.ts +50 -0
- package/dist/laz.js +645 -0
- package/dist/material.d.ts +167 -0
- package/dist/math.d.ts +103 -0
- package/dist/octree.d.ts +182 -0
- package/dist/octree.js +360 -0
- package/dist/pick.d.ts +76 -0
- package/dist/pick.js +192 -0
- package/dist/plugin.d.ts +235 -0
- package/dist/potree-las-RC8sjbYU.js +1 -0
- package/dist/potree-las.d.ts +1 -0
- package/dist/potree.d.ts +70 -0
- package/dist/potree.js +451 -0
- package/dist/range-BQuJAjUM.js +23 -0
- package/dist/range.d.ts +4 -0
- package/dist/screen-door-CALlYs39.js +7 -0
- package/dist/shaders-DCnbvb0-.js +282 -0
- package/dist/shaders.d.ts +52 -0
- package/dist/shared/fog.d.ts +33 -0
- package/dist/shared/pass.d.ts +53 -0
- package/dist/shared/selection-mask.d.ts +52 -0
- package/dist/shared/style-expression.d.ts +18 -0
- package/dist/sprites.d.ts +78 -0
- package/dist/storage-limit.d.ts +6 -0
- package/dist/style.d.ts +124 -0
- package/dist/style.js +709 -0
- package/dist/surfels.d.ts +95 -0
- package/dist/surfels.js +538 -0
- package/dist/survey-DToZwkJv.js +46 -0
- package/dist/survey.d.ts +10 -0
- package/dist/tier-BcFbLPVT.js +91 -0
- package/dist/tier.d.ts +6 -0
- package/package.json +102 -4
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { Engine, EnginePlugin, FrameGraph, PassContext } from '@margoengine/core/extension';
|
|
3
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
4
|
+
import { PointCloud } from './cloud.js';
|
|
5
|
+
import { SpriteBatch } from './sprites.js';
|
|
6
|
+
import { type FogLike } from './shared/fog.js';
|
|
7
|
+
import { type SurfaceTransparency } from './shared/pass.js';
|
|
8
|
+
type GpuContext = Extract<PassContext, {
|
|
9
|
+
backend: 'webgpu';
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Options for the `PointsPlugin`. An empty name or non-finite order throws a TypeError; a negative
|
|
13
|
+
* pointBudget or edlStrength, or a non-positive edlRadius, a RangeError.
|
|
14
|
+
*/
|
|
15
|
+
export interface PointsPluginOptions {
|
|
16
|
+
/** Plugin name, unique per engine. Default 'points'. */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Frame graph order. Default 10: after the scene (0), before fat lines (20) and post-processing (30). */
|
|
19
|
+
order?: number;
|
|
20
|
+
/** Most points drawn per frame across all clouds. Visible blocks share it by screen area. Default 1,000,000. */
|
|
21
|
+
pointBudget?: number;
|
|
22
|
+
/** Eye-dome lighting strength. Default 1. */
|
|
23
|
+
edlStrength?: number;
|
|
24
|
+
/** Eye-dome lighting neighbor radius in pixels. Default 1.4. */
|
|
25
|
+
edlRadius?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Options for `PointsPlugin.pick`. */
|
|
28
|
+
export interface PointsPickOptions {
|
|
29
|
+
/** Search radius in CSS pixels; negative throws a RangeError. Default 6. */
|
|
30
|
+
radius?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Id of the engine view to pick through (`RenderView.id`, default its index as a string). Default the canvas view
|
|
33
|
+
* under the point, as `engine.pick` chooses, or the full-canvas frame.
|
|
34
|
+
*/
|
|
35
|
+
view?: string;
|
|
36
|
+
}
|
|
37
|
+
/** The point found by `PointsPlugin.pick`. */
|
|
38
|
+
export interface PointsPickResult {
|
|
39
|
+
/** The cloud the point belongs to. */
|
|
40
|
+
cloud: PointCloud;
|
|
41
|
+
/** Index into the cloud's arrays. */
|
|
42
|
+
index: number;
|
|
43
|
+
/** World position of the point. */
|
|
44
|
+
position: [number, number, number];
|
|
45
|
+
/** Distance from the pick position in CSS pixels. */
|
|
46
|
+
distance: number;
|
|
47
|
+
/** View depth (clip w) of the point; with an orthographic camera, its distance from the near plane. */
|
|
48
|
+
depth: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Engine plugin that draws `PointCloud`s and `SpriteBatch`es over the scene color and depth (WebGPU).
|
|
52
|
+
* On the WebGL2 backend it warns once and draws nothing.
|
|
53
|
+
*/
|
|
54
|
+
export declare class PointsPlugin implements EnginePlugin {
|
|
55
|
+
/** @internal Live per-cloud inventory, empty before first draw and after release. */
|
|
56
|
+
memoryFor(cloud: PointCloud): {
|
|
57
|
+
cpu: readonly ArrayLike<number>[];
|
|
58
|
+
gpu: readonly GPUBuffer[];
|
|
59
|
+
};
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly order: number;
|
|
62
|
+
pointBudget: number;
|
|
63
|
+
edlStrength: number;
|
|
64
|
+
edlRadius: number;
|
|
65
|
+
/** Counters of the latest frame. */
|
|
66
|
+
readonly stats: {
|
|
67
|
+
clouds: number;
|
|
68
|
+
blocks: number;
|
|
69
|
+
blocksVisible: number;
|
|
70
|
+
pointsVisible: number;
|
|
71
|
+
pointsDrawn: number;
|
|
72
|
+
sprites: number;
|
|
73
|
+
drawCalls: number;
|
|
74
|
+
uploads: number;
|
|
75
|
+
uploadBytes: number;
|
|
76
|
+
};
|
|
77
|
+
private readonly clouds;
|
|
78
|
+
private readonly batches;
|
|
79
|
+
private readonly cloudGpu;
|
|
80
|
+
private readonly batchGpu;
|
|
81
|
+
private readonly owned;
|
|
82
|
+
/** One slot per caller texture or function (shared/borrowed.js), so a lost texture is reported once. */
|
|
83
|
+
private readonly borrowed;
|
|
84
|
+
private readonly borrowedViews;
|
|
85
|
+
private readonly pipelines;
|
|
86
|
+
private edlLayout;
|
|
87
|
+
private readonly mipCache;
|
|
88
|
+
/** Told when clouds come and go (`@margoengine/points/pick`). */
|
|
89
|
+
private readonly watchers;
|
|
90
|
+
private engine?;
|
|
91
|
+
private device?;
|
|
92
|
+
private gpu?;
|
|
93
|
+
private edl?;
|
|
94
|
+
/**
|
|
95
|
+
* @internal Target pixels per CSS pixel for the frame being drawn, applied to pixel sizes (`size` in 'pixels' units,
|
|
96
|
+
* `minPixelSize`, `maxPixelSize`, pixel sprites). Unset, the drawn target's width over the canvas's CSS width. An
|
|
97
|
+
* owner that maps differently (sciviz, whose tiled exports draw no canvas pixels) returns its own.
|
|
98
|
+
*/
|
|
99
|
+
pixelScale: ((context: GpuContext) => number) | undefined;
|
|
100
|
+
private readonly frameData;
|
|
101
|
+
private readonly frameBits;
|
|
102
|
+
private readonly frameWritten;
|
|
103
|
+
private frameValid;
|
|
104
|
+
private fogSource;
|
|
105
|
+
private fogGpu?;
|
|
106
|
+
private fogUsed;
|
|
107
|
+
private readonly fogData;
|
|
108
|
+
private readonly edlData;
|
|
109
|
+
private orthographic;
|
|
110
|
+
private readonly view;
|
|
111
|
+
/** Each view's camera and rectangle as last drawn (the plain full-canvas frame is one too). */
|
|
112
|
+
private readonly pickViews;
|
|
113
|
+
private pickView?;
|
|
114
|
+
private readonly box;
|
|
115
|
+
private readonly pickMvp;
|
|
116
|
+
private readonly pickRanges;
|
|
117
|
+
private readonly pickWindow;
|
|
118
|
+
private readonly entryBlock;
|
|
119
|
+
private readonly entryCount;
|
|
120
|
+
private readonly entryWeight;
|
|
121
|
+
private readonly entryDistance;
|
|
122
|
+
private blockAllotment;
|
|
123
|
+
private readonly blockOrder;
|
|
124
|
+
private readonly cloudDraws;
|
|
125
|
+
private readonly cloudDrawScratch;
|
|
126
|
+
private readonly spriteDraws;
|
|
127
|
+
/** This view's own cloud and sprite draws come first in their lists, up to Count; the hook's follow, up to End. */
|
|
128
|
+
private cloudCount;
|
|
129
|
+
private cloudEnd;
|
|
130
|
+
private spriteCount;
|
|
131
|
+
private spriteEnd;
|
|
132
|
+
private readonly transparency;
|
|
133
|
+
private readonly hookLayouts;
|
|
134
|
+
private readonly spriteDrawScratch;
|
|
135
|
+
private readonly pointColor;
|
|
136
|
+
private readonly pointColors;
|
|
137
|
+
private readonly edlColor;
|
|
138
|
+
private readonly sceneDepth;
|
|
139
|
+
/** Same as `engine.use(new PointsPlugin(...))`; returns the PointsPlugin. */
|
|
140
|
+
static attach(engine: EngineKernel, options?: PointsPluginOptions): PointsPlugin;
|
|
141
|
+
constructor(options?: PointsPluginOptions);
|
|
142
|
+
/** Clouds and sprite batches drawn by this plugin. */
|
|
143
|
+
get pointClouds(): ReadonlySet<PointCloud>;
|
|
144
|
+
get spriteBatches(): ReadonlySet<SpriteBatch>;
|
|
145
|
+
/** The fog clouds and sprites are drawn in (see `setFog`), or null. */
|
|
146
|
+
get fog(): FogLike | null;
|
|
147
|
+
/**
|
|
148
|
+
* Fogs every cloud and sprite batch whose material has `fog` true (the default): `fog` is `@margoengine/environment`'s
|
|
149
|
+
* `Fog` or any object with its fields, read every frame, with Fog's maths (linear near/far, exp2 density, height
|
|
150
|
+
* falloff). A point takes the fog at its centre, a sprite at each pixel. 'normal' blending fades toward the fog colour;
|
|
151
|
+
* 'additive' fades toward adding nothing, so fog hides a glow instead of painting it in the fog colour. `null` (the
|
|
152
|
+
* default) draws exactly as without fog. The first fogged frame compiles the fogged shaders; changing the fog or its
|
|
153
|
+
* `enabled` flag never does.
|
|
154
|
+
* @throws TypeError when `fog` is neither an object nor null; RangeError or TypeError for an invalid field.
|
|
155
|
+
*/
|
|
156
|
+
setFog(fog: FogLike | null): this;
|
|
157
|
+
/** Adds a cloud or a sprite batch and returns it. */
|
|
158
|
+
add<T extends PointCloud | SpriteBatch>(item: T): T;
|
|
159
|
+
/** Removes a cloud or batch and frees its GPU buffers. */
|
|
160
|
+
remove(item: unknown): void;
|
|
161
|
+
clear(): void;
|
|
162
|
+
setup(engine: Engine): void;
|
|
163
|
+
registerPasses(graph: FrameGraph): void;
|
|
164
|
+
onDeviceRestored(engine: Engine): void;
|
|
165
|
+
/** Drops the pick record of each view not drawn in the last frame (once per frame, not on picks). */
|
|
166
|
+
onPreUpdate(delta: number): void;
|
|
167
|
+
/** Releases every GPU resource. Clouds and batches stay registered, so the plugin can be used again. */
|
|
168
|
+
dispose(): void;
|
|
169
|
+
[Symbol.dispose]: () => void;
|
|
170
|
+
/**
|
|
171
|
+
* CPU picking: the drawn point nearest to CSS pixel (x, y) of the canvas within `radius`, using the latest
|
|
172
|
+
* frame's camera, transforms and level of detail of the view picked through. Points a `'filter'` selection mask hides
|
|
173
|
+
* do not pick. Meshes do not occlude picks and clipping planes do not apply; `PointPicking` in
|
|
174
|
+
* `@margoengine/points/pick` picks on the GPU with both.
|
|
175
|
+
*/
|
|
176
|
+
pick(x: number, y: number, options?: PointsPickOptions): PointsPickResult | null;
|
|
177
|
+
private texture;
|
|
178
|
+
private releaseUnusedTexture;
|
|
179
|
+
private ensureCloud;
|
|
180
|
+
private flushCloud;
|
|
181
|
+
/** Uploads the whole mask (header and bits, count/8 bytes) once after it changed. */
|
|
182
|
+
private flushMask;
|
|
183
|
+
private releaseCloud;
|
|
184
|
+
private ensureBatch;
|
|
185
|
+
private releaseBatch;
|
|
186
|
+
private releaseGpu;
|
|
187
|
+
private blend;
|
|
188
|
+
/** Whether `material` draws with the fogged shaders this frame. */
|
|
189
|
+
private fogged;
|
|
190
|
+
/** The fog uniform, its group 2 and the fogged pipeline layouts, made on the first fogged frame. */
|
|
191
|
+
private fogResources;
|
|
192
|
+
/** The fogged point or sprite module for this blending, compiled once. */
|
|
193
|
+
private fogModule;
|
|
194
|
+
/** `edl` adds the eye-dome depth target to the colour; `'alone'` draws that target only, testing against the depth. */
|
|
195
|
+
private pointPipeline;
|
|
196
|
+
private spritePipeline;
|
|
197
|
+
/** Whether `material` leaves this plugin's own draws for the transparency hook. */
|
|
198
|
+
private takes;
|
|
199
|
+
/** The bind group layout of a hook's group 3. */
|
|
200
|
+
private hookLayout;
|
|
201
|
+
/** A point or sprite pipeline into the hook's pass. Fog's group 2 is in every layout, bound or used or not. */
|
|
202
|
+
private surfacePipeline;
|
|
203
|
+
/**
|
|
204
|
+
* Leaves the transparent clouds and sprites to an order-independent pass, which calls `drawTransparent`: those that
|
|
205
|
+
* test depth and do not write it, additive ones only if the hook takes them. Use `addEffect` from
|
|
206
|
+
* `@margoengine/oit/vfx`. Returns a remover; `released` runs if this plugin is disposed first.
|
|
207
|
+
*/
|
|
208
|
+
setTransparency(hook: SurfaceTransparency, released?: () => void): () => void;
|
|
209
|
+
/** Draws this frame's transparent clouds and sprites into `hook`'s pass, depth tested and not written. */
|
|
210
|
+
drawTransparent(context: Extract<PassContext, {
|
|
211
|
+
backend: 'webgpu';
|
|
212
|
+
}>, hook: SurfaceTransparency): void;
|
|
213
|
+
/**
|
|
214
|
+
* The lighting pipelines of a target: one, or at the compatibility level, which has no `sample_index`, one per
|
|
215
|
+
* sample of a multisampled target, its mask writing that sample alone.
|
|
216
|
+
*/
|
|
217
|
+
/**
|
|
218
|
+
* Whether the eye-dome depth goes out as its float's four bytes in rgba8unorm (exact): at the compatibility level,
|
|
219
|
+
* which multisamples no r32float, and on the WebGL2 layer below its full tier, which rounds r32float targets.
|
|
220
|
+
*/
|
|
221
|
+
private packedEdl;
|
|
222
|
+
private edlPipelines;
|
|
223
|
+
/** The layout of every multisampled lighting pipeline, shared so that one bind group serves each sample's. */
|
|
224
|
+
private edlSampledLayout;
|
|
225
|
+
private edlPipeline;
|
|
226
|
+
private edlTarget;
|
|
227
|
+
private writeFrame;
|
|
228
|
+
private writeCloudUniform;
|
|
229
|
+
private cloudGroup;
|
|
230
|
+
private batchGroup;
|
|
231
|
+
/** Uploads, culls and shares the point budget for this view, and leaves out what the transparency hook draws. */
|
|
232
|
+
private readonly prepare;
|
|
233
|
+
private readonly execute;
|
|
234
|
+
}
|
|
235
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseLAS } from "./las.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseLAS } from './las.js';
|
package/dist/potree.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { LazDecoder, parseLAS } from './las.js';
|
|
2
|
+
import type { OctreeNode, OctreeNodeData, OctreeSource } from './octree.js';
|
|
3
|
+
/** Options of `PotreeSource.open`. */
|
|
4
|
+
export interface PotreeOptions {
|
|
5
|
+
/** Used for every request. Default `globalThis.fetch`. */
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
/** Cancels the metadata and hierarchy reads. */
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
/** The reader of 1.x folders of LAS or LAZ nodes. Default: `parseLAS` of `@margoengine/points/las`, loaded when one is met. */
|
|
10
|
+
parseLAS?: typeof parseLAS;
|
|
11
|
+
/** A LAZ decoder for 1.x folders of LAZ nodes. Default: what `parseLAS` loads by itself. */
|
|
12
|
+
laz?: LazDecoder;
|
|
13
|
+
/**
|
|
14
|
+
* How Brotli nodes of 2.0 folders decode. Default: `decodeBrotli` of `@margoengine/decoders/brotli`, loaded when one
|
|
15
|
+
* is met.
|
|
16
|
+
*/
|
|
17
|
+
brotli?: (bytes: Uint8Array) => Uint8Array;
|
|
18
|
+
/**
|
|
19
|
+
* Which attributes beyond position and colour `load` gives back in `attributes`, by the names of {@link attributeKey}.
|
|
20
|
+
* Default `['intensity', 'classification']`; `'all'` reads every one the folder has.
|
|
21
|
+
*/
|
|
22
|
+
attributes?: readonly string[] | 'all';
|
|
23
|
+
/**
|
|
24
|
+
* What a node is coloured by: `'rgb'`, the file's colours; `'classification'`, `classificationColors`; `'intensity'`,
|
|
25
|
+
* `rampColors` over the range the folder states. Default `'rgb'`.
|
|
26
|
+
*/
|
|
27
|
+
colorBy?: 'rgb' | 'classification' | 'intensity';
|
|
28
|
+
/**
|
|
29
|
+
* `'lazy'` reads the first hierarchy page at open and each further page when `load` reaches its node; `'eager'` reads
|
|
30
|
+
* every page at open, for code that walks the whole tree. Default `'lazy'`.
|
|
31
|
+
*/
|
|
32
|
+
hierarchy?: 'lazy' | 'eager';
|
|
33
|
+
}
|
|
34
|
+
/** A node's attributes, as `PotreeSource.load` gives them: one value per point, or `numElements` in a row. */
|
|
35
|
+
export type PotreeAttribute = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
36
|
+
/** What `PotreeSource.load` gives: a node's points, and the attributes asked for. */
|
|
37
|
+
export interface PotreeNodeData extends OctreeNodeData {
|
|
38
|
+
attributes?: Record<string, PotreeAttribute>;
|
|
39
|
+
}
|
|
40
|
+
/** The name an attribute goes by in `attributes`: lower case, words joined by `_`, so 2.0's `gps-time` is 1.x's `GPS_TIME`. */
|
|
41
|
+
export declare const attributeKey: (name: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* An `OctreeSource` over a Potree octree folder on any web server: `PotreeSource.open(url)`, then
|
|
44
|
+
* `OctreeCloud.attach(engine, points, source)`. Reads Potree 2.0 (encodings `DEFAULT` and `BROTLI`) and Potree 1.4 to 1.8
|
|
45
|
+
* (binary, LAS or LAZ nodes). The first hierarchy page is read at open, the rest and a node's points when it is shown.
|
|
46
|
+
* Positions and bounds are relative to `origin`, the centre of the cloud's box, so place the cloud there.
|
|
47
|
+
*/
|
|
48
|
+
export declare class PotreeSource implements OctreeSource {
|
|
49
|
+
readonly root: OctreeNode;
|
|
50
|
+
/** World position of local [0, 0, 0]: the centre of the box. */
|
|
51
|
+
readonly origin: readonly [number, number, number];
|
|
52
|
+
/** The format version the folder states. */
|
|
53
|
+
readonly version: string;
|
|
54
|
+
/** Points the folder states it holds. */
|
|
55
|
+
readonly points: number;
|
|
56
|
+
private readonly fetchNode;
|
|
57
|
+
private constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Reads the metadata and the first hierarchy page. `url` is the folder, or its `metadata.json` or `cloud.js`; a folder
|
|
60
|
+
* is taken as 2.0 when it has a `metadata.json`.
|
|
61
|
+
* @throws MargoError `'failed'` when the server answers an error; MargoError `'unsupported'` for a version or encoding
|
|
62
|
+
* not read here; TypeError for metadata that is not Potree's; RangeError for a corrupt hierarchy; the `signal`'s reason
|
|
63
|
+
* when it aborts.
|
|
64
|
+
*/
|
|
65
|
+
static open(url: string | URL, options?: PotreeOptions): Promise<PotreeSource>;
|
|
66
|
+
/** Reads the hierarchy page under a node, if one is still unread; `node.children` then holds its children. */
|
|
67
|
+
expand(node: OctreeNode, signal?: AbortSignal): Promise<void>;
|
|
68
|
+
/** Reads the node's hierarchy page if it has one, then fetches and decodes its points. An empty node gives no points. */
|
|
69
|
+
load(node: OctreeNode, signal: AbortSignal): Promise<PotreeNodeData>;
|
|
70
|
+
}
|