@nebula-spatial/cad-loader 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.
- package/README.md +46 -0
- package/dist/core/cad-types.d.ts +26 -0
- package/dist/core/errors.d.ts +5 -0
- package/dist/core/index.d.ts +24 -0
- package/dist/core/index.js +2262 -0
- package/dist/core/parser/bin-group-reader.d.ts +9 -0
- package/dist/core/parser/bin-parser.d.ts +65 -0
- package/dist/core/parser/dxbs-sidecar.d.ts +24 -0
- package/dist/core/parser/geometry-segments.d.ts +20 -0
- package/dist/core/parser/text-roundtrip.d.ts +4 -0
- package/dist/core/parser/types.d.ts +80 -0
- package/dist/core/runtime-text-decoder.d.ts +8 -0
- package/dist/core/types.d.ts +147 -0
- package/dist/core/utils/insert-bbox.d.ts +10 -0
- package/dist/core/utils/viewport-rect.d.ts +21 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +4435 -0
- package/dist/loader/geo-loader.d.ts +56 -0
- package/dist/loader/internal/external-variant-sidecar-fetch.d.ts +13 -0
- package/dist/loader/internal/flow-control.d.ts +29 -0
- package/dist/loader/internal/frame-budget-scheduler.d.ts +21 -0
- package/dist/loader/internal/geo-compact-executor.d.ts +19 -0
- package/dist/loader/internal/geo-loader-local-adapter.d.ts +2 -0
- package/dist/loader/internal/geo-loader-pipeline.d.ts +81 -0
- package/dist/loader/internal/geo-loader-worker-adapter.d.ts +7 -0
- package/dist/loader/internal/geo-node-builder.d.ts +29 -0
- package/dist/loader/internal/geo-node-load-sink.d.ts +28 -0
- package/dist/loader/internal/geo-node.d.ts +284 -0
- package/dist/loader/internal/geo-prepare-worker-types.d.ts +87 -0
- package/dist/loader/internal/geo-prepare.d.ts +38 -0
- package/dist/loader/internal/geo-prepare.worker.d.ts +1 -0
- package/dist/loader/internal/insert-model-builder.d.ts +10 -0
- package/dist/loader/internal/insert-runtime-geometry.d.ts +15 -0
- package/dist/loader/internal/line-canonical.d.ts +37 -0
- package/dist/loader/internal/line-quality.d.ts +9 -0
- package/dist/loader/internal/prepare-credit-gate.d.ts +20 -0
- package/dist/loader/internal/transport.d.ts +2 -0
- package/dist/scene/geo-cad-line-geometry.d.ts +28 -0
- package/dist/scene/geo-cad-line-material.d.ts +18 -0
- package/dist/scene/instancing/block-geometry-registry.d.ts +35 -0
- package/dist/scene/instancing/insert-instance-table.d.ts +23 -0
- package/dist/scene/instancing/viewport-instance-presenter.d.ts +66 -0
- package/dist/selection/cad-insert-selection.d.ts +35 -0
- package/dist/session/load-session.d.ts +90 -0
- package/dist/shared/abort.d.ts +3 -0
- package/dist/shared/cad-display-color.d.ts +55 -0
- package/dist/shared/cad-load-source.d.ts +8 -0
- package/dist/shared/color-buffer.d.ts +6 -0
- package/dist/shared/constants.d.ts +11 -0
- package/dist/shared/display-color-buffer.d.ts +27 -0
- package/dist/shared/errors.d.ts +2 -0
- package/dist/shared/text-font.d.ts +12 -0
- package/dist/shared/types.d.ts +57 -0
- package/dist/shared/utils/insert-bbox.d.ts +1 -0
- package/dist/shared/utils/timing.d.ts +2 -0
- package/dist/shared/utils/viewport-rect.d.ts +1 -0
- package/dist/shared/viewer-theme.d.ts +2 -0
- package/dist/workers/geo-prepare.worker.js +2166 -0
- package/package.json +61 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ExternalBlockVariantManifestEntry, ParsedGeoPayload, TextEntity } from '../shared/types';
|
|
2
|
+
import { type CadLoadSource } from '../shared/cad-load-source';
|
|
3
|
+
import { GeoNode } from './internal/geo-node';
|
|
4
|
+
import type { ResolveTextFont } from '../shared/text-font';
|
|
5
|
+
import { type DecodedAnnotationSidecar, type ExternalVariantDependencyOptions, type ExternalVariantDependencyPlan, type ParsedHeader, type CadExternalVariantDelta as GeoNodeExternalVariantDelta } from '../core';
|
|
6
|
+
export type { ExternalVariantDependencyOptions, ExternalVariantDependencyPlan } from '../core';
|
|
7
|
+
export interface ExternalVariantFetchSource {
|
|
8
|
+
readonly baseUrl: string;
|
|
9
|
+
readonly entries: readonly ExternalBlockVariantManifestEntry[];
|
|
10
|
+
}
|
|
11
|
+
export interface LoadGeoOptions {
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
beforeTextAppend?: (texts: readonly TextEntity[]) => void | Promise<void>;
|
|
14
|
+
resolveTextFont?: ResolveTextFont;
|
|
15
|
+
hiddenInstanceIds?: readonly number[];
|
|
16
|
+
loadBlocks?: boolean;
|
|
17
|
+
loadAnnotations?: boolean;
|
|
18
|
+
maxExpandedInstanceVertices?: number;
|
|
19
|
+
preferWorker?: boolean;
|
|
20
|
+
workerUrl?: string | URL;
|
|
21
|
+
workerFactory?: () => Worker;
|
|
22
|
+
externalVariantFetchSource?: ExternalVariantFetchSource;
|
|
23
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
24
|
+
requiredExternalVariantIds?: readonly number[];
|
|
25
|
+
externalVariantGeometryFetchIds?: readonly number[];
|
|
26
|
+
}
|
|
27
|
+
export interface LoadExternalVariantDeltaOptions {
|
|
28
|
+
beforeTextAppend?: (texts: readonly TextEntity[]) => void | Promise<void>;
|
|
29
|
+
hiddenInstanceIds?: readonly number[];
|
|
30
|
+
externalVariantFetchSource?: ExternalVariantFetchSource;
|
|
31
|
+
externalVariantBuffers: ReadonlyMap<number, ArrayBuffer>;
|
|
32
|
+
requiredExternalVariantIds: readonly number[];
|
|
33
|
+
externalVariantGeometryFetchIds?: readonly number[];
|
|
34
|
+
}
|
|
35
|
+
export type LoadExternalVariantDeltaFetchSourceOptions = Omit<LoadExternalVariantDeltaOptions, 'externalVariantFetchSource' | 'externalVariantBuffers'> & {
|
|
36
|
+
externalVariantFetchSource: ExternalVariantFetchSource;
|
|
37
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
38
|
+
};
|
|
39
|
+
export declare function appendExternalVariantDeltaToGeoNode(node: GeoNode, buf: ArrayBuffer, options: LoadExternalVariantDeltaFetchSourceOptions): Promise<void>;
|
|
40
|
+
export declare function appendExternalVariantDeltaToGeoNode(node: GeoNode, buf: ArrayBuffer, options: LoadExternalVariantDeltaOptions): Promise<void>;
|
|
41
|
+
export declare function parseBuffer(buf: ArrayBuffer): ParsedGeoPayload;
|
|
42
|
+
export declare function parseBufferHeader(buf: ArrayBuffer): ParsedHeader;
|
|
43
|
+
export declare function parseBufferBounds(buf: ArrayBuffer): ParsedHeader['bounds'];
|
|
44
|
+
export declare function readBufferExternalVariantManifest(buf: ArrayBuffer): readonly ExternalBlockVariantManifestEntry[];
|
|
45
|
+
export declare function readBufferExternalVariantDependencyPlan(buf: ArrayBuffer, options?: ExternalVariantDependencyOptions): ExternalVariantDependencyPlan;
|
|
46
|
+
export declare function readBufferExternalAnnotationManifest(buf: ArrayBuffer): import("..").ExternalAnnotationsManifest | null;
|
|
47
|
+
export declare function readBufferExternalBlockAnnotations(buf: ArrayBuffer, options?: {
|
|
48
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
49
|
+
hiddenInstanceIds?: ReadonlySet<number>;
|
|
50
|
+
}): DecodedAnnotationSidecar | null;
|
|
51
|
+
export declare function loadExternalVariantDeltaFromBuffer(buf: ArrayBuffer, options: LoadExternalVariantDeltaFetchSourceOptions): GeoNodeExternalVariantDelta;
|
|
52
|
+
export declare function loadExternalVariantDeltaFromBuffer(buf: ArrayBuffer, options: LoadExternalVariantDeltaOptions): GeoNodeExternalVariantDelta;
|
|
53
|
+
export declare function assertValidSourceOrThrow(source: unknown): asserts source is import('../shared/types').GeoLoadSource;
|
|
54
|
+
declare function normalizeGeoError(err: unknown): Error;
|
|
55
|
+
export declare function loadGeo(source: CadLoadSource, options?: LoadGeoOptions): GeoNode;
|
|
56
|
+
export { normalizeGeoError };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExternalBlockVariantManifestEntry } from '../../shared/types';
|
|
2
|
+
export type FetchExternalVariantSidecarsOptions = {
|
|
3
|
+
readonly baseUrl: string;
|
|
4
|
+
readonly entries: readonly ExternalBlockVariantManifestEntry[];
|
|
5
|
+
readonly requiredVariantIds: readonly number[];
|
|
6
|
+
readonly fetchImpl?: typeof fetch;
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
readonly concurrency?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function fetchExternalVariantSidecars(options: FetchExternalVariantSidecarsOptions): Promise<{
|
|
11
|
+
readonly buffers: ReadonlyMap<number, ArrayBuffer>;
|
|
12
|
+
readonly fetchMs: number;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type QueueKind = 'geometry' | 'text';
|
|
2
|
+
export interface LoaderFlowControlOptions {
|
|
3
|
+
highWatermarkBytes: number;
|
|
4
|
+
lowWatermarkBytes: number;
|
|
5
|
+
initialGeometryCredits: number;
|
|
6
|
+
initialTextCredits: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CreditGrant {
|
|
9
|
+
geometryCredits: number;
|
|
10
|
+
textCredits: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ConsumeResult extends CreditGrant {
|
|
13
|
+
paused: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class LoaderFlowControl {
|
|
16
|
+
private readonly highWatermarkBytes;
|
|
17
|
+
private readonly lowWatermarkBytes;
|
|
18
|
+
private readonly initialGeometryCredits;
|
|
19
|
+
private readonly initialTextCredits;
|
|
20
|
+
private queuedBytes;
|
|
21
|
+
private paused;
|
|
22
|
+
private initialGranted;
|
|
23
|
+
constructor(options: LoaderFlowControlOptions);
|
|
24
|
+
takeInitialGrant(): CreditGrant;
|
|
25
|
+
onQueued(_kind: QueueKind, bytes: number): void;
|
|
26
|
+
onConsumed(kind: QueueKind, bytes: number): ConsumeResult;
|
|
27
|
+
getQueuedBytes(): number;
|
|
28
|
+
private shouldStayPaused;
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type BudgetTask = () => void | Promise<void>;
|
|
2
|
+
export interface FrameBudgetSchedulerOptions {
|
|
3
|
+
frameBudgetMs: number;
|
|
4
|
+
reserveMs: number;
|
|
5
|
+
now?: () => number;
|
|
6
|
+
}
|
|
7
|
+
export interface FrameRunResult {
|
|
8
|
+
executed: number;
|
|
9
|
+
remaining: number;
|
|
10
|
+
exhausted: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class FrameBudgetScheduler {
|
|
13
|
+
private readonly queue;
|
|
14
|
+
private readonly budgetMs;
|
|
15
|
+
private readonly now;
|
|
16
|
+
constructor(options: FrameBudgetSchedulerOptions);
|
|
17
|
+
enqueue(task: BudgetTask): void;
|
|
18
|
+
hasPending(): boolean;
|
|
19
|
+
size(): number;
|
|
20
|
+
runFrame(): Promise<FrameRunResult>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface GeoCompactOperation {
|
|
2
|
+
label: string;
|
|
3
|
+
run: () => boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface GeoCompactRunStats {
|
|
6
|
+
visited: number;
|
|
7
|
+
compacted: number;
|
|
8
|
+
yielded: number;
|
|
9
|
+
elapsedMs: number;
|
|
10
|
+
}
|
|
11
|
+
export interface GeoCompactExecutorOptions {
|
|
12
|
+
opsPerPass?: number;
|
|
13
|
+
frameBudgetMs?: number;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
onYield?: () => void | Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const DEFAULT_COMPACT_OPS_PER_PASS = 64;
|
|
18
|
+
export declare const DEFAULT_COMPACT_FRAME_BUDGET_MS = 8;
|
|
19
|
+
export declare function runGeoCompactOperations(operations: readonly GeoCompactOperation[], options?: GeoCompactExecutorOptions): Promise<GeoCompactRunStats>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TextEntity } from '../../shared/types';
|
|
2
|
+
import { type CreditGrant, type LoaderFlowControlOptions } from './flow-control';
|
|
3
|
+
import { type FrameBudgetSchedulerOptions } from './frame-budget-scheduler';
|
|
4
|
+
import type { GeometryKind, PreparedLayerChunk } from './geo-prepare';
|
|
5
|
+
import { GeoNode } from './geo-node';
|
|
6
|
+
import type { TransferableInsertInstanceBatch, TransferableVariantGeometry } from './geo-prepare-worker-types';
|
|
7
|
+
import type { ParsedHeader } from '../../core';
|
|
8
|
+
import type { ExternalVariantFetchSource } from '../geo-loader';
|
|
9
|
+
type YieldCallback = () => void | Promise<void>;
|
|
10
|
+
export type BeforeTextAppend = (texts: readonly TextEntity[]) => void | Promise<void>;
|
|
11
|
+
export type GeoLoaderPipelineEvent = {
|
|
12
|
+
type: 'header';
|
|
13
|
+
header: ParsedHeader;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'geometry';
|
|
16
|
+
kind: GeometryKind;
|
|
17
|
+
layers: readonly PreparedLayerChunk[];
|
|
18
|
+
cost: number;
|
|
19
|
+
bytes: number;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'text';
|
|
22
|
+
texts: readonly TextEntity[];
|
|
23
|
+
cost: number;
|
|
24
|
+
bytes: number;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'insertModel';
|
|
27
|
+
variants: readonly TransferableVariantGeometry[];
|
|
28
|
+
instances: TransferableInsertInstanceBatch;
|
|
29
|
+
bytes: number;
|
|
30
|
+
planMs?: number;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'done';
|
|
33
|
+
};
|
|
34
|
+
export type GeoLoaderPipelineEmit = (event: GeoLoaderPipelineEvent) => void | Promise<void>;
|
|
35
|
+
export interface GeoLoaderPipelineAdapterInput {
|
|
36
|
+
buffer: ArrayBuffer;
|
|
37
|
+
hiddenInstanceIds?: ReadonlySet<number>;
|
|
38
|
+
keepTextsForHiddenInstances?: boolean;
|
|
39
|
+
loadBlocks?: boolean;
|
|
40
|
+
suppressExpandedInsertGeometry?: boolean;
|
|
41
|
+
maxExpandedInstanceVertices?: number;
|
|
42
|
+
externalVariantFetchSource?: ExternalVariantFetchSource;
|
|
43
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
44
|
+
requiredExternalVariantIds?: ReadonlySet<number>;
|
|
45
|
+
externalVariantGeometryFetchIds?: ReadonlySet<number>;
|
|
46
|
+
externalVariantDeltaOnly?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface GeoLoaderPipelineSession {
|
|
49
|
+
completion: Promise<void>;
|
|
50
|
+
backgroundCompletion?: Promise<void>;
|
|
51
|
+
grant?: (grant: CreditGrant) => void;
|
|
52
|
+
cancel?: () => void;
|
|
53
|
+
dispose: () => void;
|
|
54
|
+
}
|
|
55
|
+
export interface GeoLoaderPipelineAdapter {
|
|
56
|
+
start(input: GeoLoaderPipelineAdapterInput, emit: GeoLoaderPipelineEmit): GeoLoaderPipelineSession;
|
|
57
|
+
}
|
|
58
|
+
export interface RunGeoLoaderPipelineOptions {
|
|
59
|
+
node: GeoNode;
|
|
60
|
+
buffer: ArrayBuffer;
|
|
61
|
+
adapter: GeoLoaderPipelineAdapter;
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
beforeTextAppend?: BeforeTextAppend;
|
|
64
|
+
beforeFinalize?: () => void | Promise<void>;
|
|
65
|
+
hiddenInstanceIds?: ReadonlySet<number>;
|
|
66
|
+
keepTextsForHiddenInstances?: boolean;
|
|
67
|
+
loadBlocks?: boolean;
|
|
68
|
+
suppressExpandedInsertGeometry?: boolean;
|
|
69
|
+
maxExpandedInstanceVertices?: number;
|
|
70
|
+
externalVariantFetchSource?: ExternalVariantFetchSource;
|
|
71
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
72
|
+
requiredExternalVariantIds?: ReadonlySet<number>;
|
|
73
|
+
externalVariantGeometryFetchIds?: ReadonlySet<number>;
|
|
74
|
+
externalVariantDeltaOnly?: boolean;
|
|
75
|
+
appendExternalVariantDelta?: boolean;
|
|
76
|
+
onYield?: YieldCallback;
|
|
77
|
+
scheduler?: Partial<FrameBudgetSchedulerOptions>;
|
|
78
|
+
flowControl?: Partial<LoaderFlowControlOptions>;
|
|
79
|
+
}
|
|
80
|
+
export declare function runGeoLoaderPipeline(options: RunGeoLoaderPipelineOptions): Promise<void>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GeoLoaderPipelineAdapter } from './geo-loader-pipeline';
|
|
2
|
+
export interface WorkerGeoLoaderAdapterOptions {
|
|
3
|
+
workerUrl?: string | URL;
|
|
4
|
+
workerFactory?: () => Worker;
|
|
5
|
+
}
|
|
6
|
+
export declare function canUsePrepareWorker(workerFactory?: () => Worker): boolean;
|
|
7
|
+
export declare function createWorkerGeoLoaderAdapter(options?: WorkerGeoLoaderAdapterOptions): GeoLoaderPipelineAdapter;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FrameBudgetSchedulerOptions } from './frame-budget-scheduler';
|
|
2
|
+
import type { LoaderFlowControlOptions } from './flow-control';
|
|
3
|
+
import { GeoNode } from './geo-node';
|
|
4
|
+
import type { TextEntity } from '../../shared/types';
|
|
5
|
+
import type { ExternalVariantFetchSource } from '../geo-loader';
|
|
6
|
+
type YieldCallback = () => void | Promise<void>;
|
|
7
|
+
type BeforeTextAppend = (texts: readonly TextEntity[]) => void | Promise<void>;
|
|
8
|
+
export interface BuildGeoNodeOptions {
|
|
9
|
+
scheduler?: Partial<FrameBudgetSchedulerOptions>;
|
|
10
|
+
flowControl?: Partial<LoaderFlowControlOptions>;
|
|
11
|
+
beforeTextAppend?: BeforeTextAppend;
|
|
12
|
+
beforeFinalize?: () => void | Promise<void>;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
hiddenInstanceIds?: ReadonlySet<number>;
|
|
15
|
+
preferWorker?: boolean;
|
|
16
|
+
workerUrl?: string | URL;
|
|
17
|
+
workerFactory?: () => Worker;
|
|
18
|
+
keepTextsForHiddenInstances?: boolean;
|
|
19
|
+
loadBlocks?: boolean;
|
|
20
|
+
maxExpandedInstanceVertices?: number;
|
|
21
|
+
externalVariantFetchSource?: ExternalVariantFetchSource;
|
|
22
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
23
|
+
requiredExternalVariantIds?: ReadonlySet<number> | readonly number[];
|
|
24
|
+
externalVariantGeometryFetchIds?: ReadonlySet<number> | readonly number[];
|
|
25
|
+
externalVariantDeltaOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function buildGeoNodeFromBuffer(node: GeoNode, buf: ArrayBuffer, onYield?: YieldCallback, options?: BuildGeoNodeOptions): Promise<void>;
|
|
28
|
+
export declare function appendExternalVariantDeltaToGeoNode(node: GeoNode, buf: ArrayBuffer, onYield?: YieldCallback, options?: BuildGeoNodeOptions): Promise<void>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TextEntity } from '../../shared/types';
|
|
2
|
+
import { GeoNode } from './geo-node';
|
|
3
|
+
import type { GeometryKind, PreparedLayerChunk } from './geo-prepare';
|
|
4
|
+
import type { TransferableInsertInstanceBatch, TransferableVariantGeometry } from './geo-prepare-worker-types';
|
|
5
|
+
import { type ParsedHeader } from '../../core';
|
|
6
|
+
type YieldCallback = () => void | Promise<void>;
|
|
7
|
+
export declare class GeoNodeLoadSink {
|
|
8
|
+
private readonly node;
|
|
9
|
+
private headerSeen;
|
|
10
|
+
private headerTexts;
|
|
11
|
+
constructor(node: GeoNode);
|
|
12
|
+
initFromHeader(header: ParsedHeader): void;
|
|
13
|
+
appendGeometry(kind: GeometryKind, layers: readonly PreparedLayerChunk[]): void;
|
|
14
|
+
appendText(texts: readonly TextEntity[]): void;
|
|
15
|
+
installInsertModel(payload: {
|
|
16
|
+
variants: readonly TransferableVariantGeometry[];
|
|
17
|
+
instances: TransferableInsertInstanceBatch;
|
|
18
|
+
planMs?: number;
|
|
19
|
+
}): void;
|
|
20
|
+
appendInsertModel(payload: {
|
|
21
|
+
variants: readonly TransferableVariantGeometry[];
|
|
22
|
+
instances: TransferableInsertInstanceBatch;
|
|
23
|
+
planMs?: number;
|
|
24
|
+
}): void;
|
|
25
|
+
finalize(onYield?: YieldCallback): Promise<void>;
|
|
26
|
+
fail(err: Error): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Group } from 'three';
|
|
2
|
+
import { type ResolveTextFont } from '../../shared/text-font';
|
|
3
|
+
import type { GeoMetaSnapshot, LayerBlockUsage, LayerSnapshot, LineRenderMode, TextEntity, ViewportRect } from '../../shared/types';
|
|
4
|
+
import { type ViewerThemeName } from '../../shared/viewer-theme';
|
|
5
|
+
import { type VariantGeometry } from '../../scene/instancing/block-geometry-registry';
|
|
6
|
+
import { type InsertInstanceRecord } from '../../scene/instancing/insert-instance-table';
|
|
7
|
+
import { type LayerVisibility } from '../../scene/instancing/viewport-instance-presenter';
|
|
8
|
+
import { type GeometryKind, type PreparedLayerChunk } from './geo-prepare';
|
|
9
|
+
import type { TransferableInsertInstanceBatch, TransferableVariantGeometry } from './geo-prepare-worker-types';
|
|
10
|
+
import type { CadExternalVariantDelta as GeoNodeExternalVariantDelta, GeoChunk, GeoGeometryChunk, ParsedHeader } from '../../core';
|
|
11
|
+
import { type AutoQualityContext, type EffectiveRenderQuality, type RenderQualityMode } from './line-quality';
|
|
12
|
+
import { type LineMemoryStatsSnapshot } from './line-canonical';
|
|
13
|
+
export type ColorPipelineStatsSnapshot = {
|
|
14
|
+
geometryCount: number;
|
|
15
|
+
sourceRgbBytes: number;
|
|
16
|
+
displayRgbBytes: number;
|
|
17
|
+
displayRgbFloat32Bytes: number;
|
|
18
|
+
displayRefreshVertexTotal: number;
|
|
19
|
+
displayRefreshRunTotal: number;
|
|
20
|
+
displayRefreshUniqueColorTotal: number;
|
|
21
|
+
displayRefreshCacheHitTotal: number;
|
|
22
|
+
displayRefreshRepeatedRunVertexTotal: number;
|
|
23
|
+
};
|
|
24
|
+
type BBox = ViewportRect;
|
|
25
|
+
type YieldCallback = () => void | Promise<void>;
|
|
26
|
+
export type GeoNodeInternalChangeKind = 'structure' | 'visual';
|
|
27
|
+
export type GeoNodeInternalChange = {
|
|
28
|
+
readonly kind: GeoNodeInternalChangeKind;
|
|
29
|
+
};
|
|
30
|
+
export declare const GEO_NODE_STRUCTURE_CHANGE: GeoNodeInternalChange;
|
|
31
|
+
export declare const GEO_NODE_VISUAL_CHANGE: GeoNodeInternalChange;
|
|
32
|
+
type FinalizeIncrementallyOptions = Record<string, never>;
|
|
33
|
+
export interface InsertInstanceMatrix2D {
|
|
34
|
+
readonly matA: number;
|
|
35
|
+
readonly matB: number;
|
|
36
|
+
readonly matC: number;
|
|
37
|
+
readonly matD: number;
|
|
38
|
+
readonly tx: number;
|
|
39
|
+
readonly ty: number;
|
|
40
|
+
}
|
|
41
|
+
export declare function setGeoNodeLoadAbortHook(node: GeoNode, hook: (() => void) | null): void;
|
|
42
|
+
export declare class GeoNode extends Group {
|
|
43
|
+
private meta;
|
|
44
|
+
private layerOrder;
|
|
45
|
+
private readonly layerStatesByIndex;
|
|
46
|
+
private bounds;
|
|
47
|
+
private readonly originalLayerColorsByIndex;
|
|
48
|
+
private readonly colorOverridesByIndex;
|
|
49
|
+
private displayThemeName;
|
|
50
|
+
private displayContrastEnhancement;
|
|
51
|
+
private readonly displayHexMemo;
|
|
52
|
+
private layerStateRevision;
|
|
53
|
+
private metaRevision;
|
|
54
|
+
private renderDebugRevision;
|
|
55
|
+
private layersSnapshotCache;
|
|
56
|
+
private metaSnapshotCache;
|
|
57
|
+
private boundsSnapshotCache;
|
|
58
|
+
private readonly layerGroupsByIndex;
|
|
59
|
+
private readonly textUserDataByAppendOrder;
|
|
60
|
+
private readonly textBatchByLayerIndex;
|
|
61
|
+
private readonly textRenderablesByLayerIndex;
|
|
62
|
+
private readonly textRenderablesByAppendOrder;
|
|
63
|
+
private readonly annotationOverlayGroupsByLayerIndex;
|
|
64
|
+
private readonly annotationTextBatchByLayerIndex;
|
|
65
|
+
private readonly annotationTextRenderablesByLayerIndex;
|
|
66
|
+
private readonly annotationTextRecordsByOwnerKey;
|
|
67
|
+
private readonly annotationTextRecordsByLayerIndex;
|
|
68
|
+
private readonly pendingTextBatchSync;
|
|
69
|
+
private textBatchSyncScheduled;
|
|
70
|
+
private insertRuntime;
|
|
71
|
+
private readonly insertRuntimeInstancesById;
|
|
72
|
+
private blockGeometryRegistry;
|
|
73
|
+
private readonly insertPresenterVariantInputs;
|
|
74
|
+
private readonly insertPresenterRecordsByKey;
|
|
75
|
+
private readonly insertPresenterRecordKeysByInstanceId;
|
|
76
|
+
private insertInstanceTable;
|
|
77
|
+
private viewportInstancePresenter;
|
|
78
|
+
private insertPresenterExternallyManaged;
|
|
79
|
+
private renderQualityMode;
|
|
80
|
+
private effectiveRenderQuality;
|
|
81
|
+
private interactionRenderQualityOverride;
|
|
82
|
+
private lineModeSwitchingEnabled;
|
|
83
|
+
private autoQualityContext;
|
|
84
|
+
private readonly lineChunkRecords;
|
|
85
|
+
private lineCanonicalMemoryStats;
|
|
86
|
+
private readonly nonLineChunkStats;
|
|
87
|
+
private readonly worldSizedPointUniforms;
|
|
88
|
+
private lineResolution;
|
|
89
|
+
private internalChangeHook;
|
|
90
|
+
private disposed;
|
|
91
|
+
private readySettled;
|
|
92
|
+
private layerBlockUsages;
|
|
93
|
+
private colorRefreshStats;
|
|
94
|
+
private contentGeneration;
|
|
95
|
+
private annotationOverlayVisible;
|
|
96
|
+
private readyPromise;
|
|
97
|
+
private resolveReady;
|
|
98
|
+
private rejectReady;
|
|
99
|
+
private readonly resolveTextFont;
|
|
100
|
+
constructor(options?: {
|
|
101
|
+
resolveTextFont?: ResolveTextFont;
|
|
102
|
+
});
|
|
103
|
+
get ready(): Promise<void>;
|
|
104
|
+
setLayerVisible(layerIndex: number, visible: boolean): void;
|
|
105
|
+
setAnnotationOverlayVisible(visible: boolean): void;
|
|
106
|
+
setDisplayTheme(themeName: ViewerThemeName, options?: {
|
|
107
|
+
enhanceContrast?: boolean;
|
|
108
|
+
}): void;
|
|
109
|
+
setLayerColor(layerIndex: number, color: number | null): void;
|
|
110
|
+
setRenderQuality(mode: RenderQualityMode): void;
|
|
111
|
+
setLineModeSwitchingEnabled(enabled: boolean): void;
|
|
112
|
+
updateAutoQualityContext(context: AutoQualityContext): void;
|
|
113
|
+
setInteractionRenderQualityOverride(mode: EffectiveRenderQuality | null): void;
|
|
114
|
+
getMeta(): Readonly<GeoMetaSnapshot>;
|
|
115
|
+
getLayers(): readonly Readonly<LayerSnapshot>[];
|
|
116
|
+
getLayerVisibility(): LayerVisibility;
|
|
117
|
+
refreshInsertPresenter(viewport: ViewportRect | null, layers: LayerVisibility, userHiddenInstanceIds: ReadonlySet<number>, userHiddenInstanceIdsRevision?: number): void;
|
|
118
|
+
getInsertPresenterVisibleVertexCount(): number;
|
|
119
|
+
invalidateInsertPresenterQueryCache(): void;
|
|
120
|
+
getLayerBlockUsages(layerIndex: number): readonly LayerBlockUsage[];
|
|
121
|
+
getBlockLayerStatsRevision(): number;
|
|
122
|
+
getRenderDebugRevision(): number;
|
|
123
|
+
getBounds(): Readonly<[number, number, number, number]>;
|
|
124
|
+
getGeometryChunkStats(): ReadonlyArray<{
|
|
125
|
+
layerIndex: number;
|
|
126
|
+
vertexCount: number;
|
|
127
|
+
bbox: BBox | null;
|
|
128
|
+
}>;
|
|
129
|
+
_collectTextUserDataForDebug(): readonly TextEntity[];
|
|
130
|
+
getTextEntries(): readonly TextEntity[];
|
|
131
|
+
getInsertInstanceBaseTransform(instanceId: number, variantId?: number): {
|
|
132
|
+
tx: number;
|
|
133
|
+
ty: number;
|
|
134
|
+
rotation: number;
|
|
135
|
+
scaleX: number;
|
|
136
|
+
scaleY: number;
|
|
137
|
+
} | null;
|
|
138
|
+
getInsertVariantGeometry(variantId: number): VariantGeometry | null;
|
|
139
|
+
getInsertInstanceMatrix(instanceId: number, variantId?: number): InsertInstanceMatrix2D | null;
|
|
140
|
+
getInsertPreviewRecordsForInstance(instanceId: number): readonly InsertInstanceRecord[];
|
|
141
|
+
getEffectiveLayerColorHex(layerIndex: number): number | null;
|
|
142
|
+
private resolveInsertRuntimeInstance;
|
|
143
|
+
updateTextEntry(textId: number, patch: Partial<{
|
|
144
|
+
content: string;
|
|
145
|
+
x: number;
|
|
146
|
+
y: number;
|
|
147
|
+
rotation: number;
|
|
148
|
+
}>): boolean;
|
|
149
|
+
updateInsertInstanceTransform(instanceId: number, transform: {
|
|
150
|
+
tx: number;
|
|
151
|
+
ty: number;
|
|
152
|
+
rotation: number;
|
|
153
|
+
scaleX: number;
|
|
154
|
+
scaleY: number;
|
|
155
|
+
}): boolean;
|
|
156
|
+
getEffectiveRenderQuality(): EffectiveRenderQuality;
|
|
157
|
+
getLineRenderMode(): LineRenderMode;
|
|
158
|
+
getLineModeSwitchingEnabled(): boolean;
|
|
159
|
+
getRenderQualityModeForDebug(): RenderQualityMode;
|
|
160
|
+
getLineMemoryStats(): Readonly<LineMemoryStatsSnapshot>;
|
|
161
|
+
getColorPipelineStats(): Readonly<ColorPipelineStatsSnapshot>;
|
|
162
|
+
getInsertRuntime(): ParsedHeader['insertRuntime'] | null;
|
|
163
|
+
getTextRenderablesByAppendOrder(): Array<{
|
|
164
|
+
visible: boolean;
|
|
165
|
+
} | null | undefined>;
|
|
166
|
+
getSupplementalTextRenderablesByInstanceId(): ReadonlyMap<number, ReadonlyArray<{
|
|
167
|
+
visible: boolean;
|
|
168
|
+
}>>;
|
|
169
|
+
private rebuildInsertRuntimeInstanceIndex;
|
|
170
|
+
dispose(): void;
|
|
171
|
+
_initFromHeader(header: ParsedHeader): void;
|
|
172
|
+
_appendChunk(chunk: GeoChunk): void;
|
|
173
|
+
_appendPreparedGeometryChunk(kind: GeometryKind, layers: readonly PreparedLayerChunk[]): void;
|
|
174
|
+
_appendTextChunks(texts: readonly TextEntity[]): void;
|
|
175
|
+
_installInsertModel(payload: {
|
|
176
|
+
variants: readonly TransferableVariantGeometry[];
|
|
177
|
+
instances: TransferableInsertInstanceBatch;
|
|
178
|
+
planMs?: number;
|
|
179
|
+
}): void;
|
|
180
|
+
_appendInsertModel(payload: {
|
|
181
|
+
variants: readonly TransferableVariantGeometry[];
|
|
182
|
+
instances: TransferableInsertInstanceBatch;
|
|
183
|
+
planMs?: number;
|
|
184
|
+
}): void;
|
|
185
|
+
private mergeInsertModelPayload;
|
|
186
|
+
private createVariantGeometryInput;
|
|
187
|
+
private rebuildViewportInsertPresenterFromAccumulatedModel;
|
|
188
|
+
private rebuildViewportInsertPresenter;
|
|
189
|
+
private computeInsertPresenterWorldBBox;
|
|
190
|
+
_debugHasInsertPresenter(): boolean;
|
|
191
|
+
_debugInsertInstanceTableSize(): number;
|
|
192
|
+
appendAnnotationOverlay(input: {
|
|
193
|
+
line: GeoGeometryChunk;
|
|
194
|
+
fill: GeoGeometryChunk;
|
|
195
|
+
dot: GeoGeometryChunk;
|
|
196
|
+
texts: readonly TextEntity[];
|
|
197
|
+
}): void;
|
|
198
|
+
appendExternalVariantDelta(delta: GeoNodeExternalVariantDelta): void;
|
|
199
|
+
appendExternalVariantDeltaHeader(header: ParsedHeader): void;
|
|
200
|
+
_finalize(): void;
|
|
201
|
+
_finalizeIncrementally(onYield?: YieldCallback, maxCompactOpsPerPass?: number, _options?: FinalizeIncrementallyOptions): Promise<void>;
|
|
202
|
+
_fail(err: Error): void;
|
|
203
|
+
_setInternalChangeHook(callback: ((change: GeoNodeInternalChange) => void) | null): void;
|
|
204
|
+
_setViewportSize(width: number, height: number): void;
|
|
205
|
+
private createPointMaterial;
|
|
206
|
+
private resolvePointWorldSize;
|
|
207
|
+
private appendTextChunk;
|
|
208
|
+
private appendAnnotationTextChunks;
|
|
209
|
+
private appendAnnotationTextChunk;
|
|
210
|
+
private getOrCreateTextBatch;
|
|
211
|
+
private getOrCreateAnnotationTextBatch;
|
|
212
|
+
private configureTextBatchForStaticBounds;
|
|
213
|
+
private markTextBatchBoundsDirty;
|
|
214
|
+
private markTextBatchBoundsClean;
|
|
215
|
+
private scheduleTextBatchSync;
|
|
216
|
+
private createRenderableChunk;
|
|
217
|
+
private createRenderableLineChunk;
|
|
218
|
+
private makeLineChunkRecord;
|
|
219
|
+
private registerLineChunkRecord;
|
|
220
|
+
private addLineCanonicalStats;
|
|
221
|
+
private subtractLineCanonicalStats;
|
|
222
|
+
private rebuildLineVariantStats;
|
|
223
|
+
private resolveLineChunkVariant;
|
|
224
|
+
private resolveInitialLineChunkVariant;
|
|
225
|
+
private resolveLineweightPx;
|
|
226
|
+
private shouldUseThinLineVariant;
|
|
227
|
+
private buildLineRenderableViews;
|
|
228
|
+
private finalizeCadLineRenderable;
|
|
229
|
+
private installSharedLineColorTargetMarkers;
|
|
230
|
+
private applyInitialLineDisplayColors;
|
|
231
|
+
private createRenderableTextChunk;
|
|
232
|
+
private commitTroikaTextTransform;
|
|
233
|
+
private getOrCreateKindGroup;
|
|
234
|
+
private appendAnnotationPreparedGeometryChunk;
|
|
235
|
+
private getOrCreateAnnotationKindGroup;
|
|
236
|
+
private getOrCreateAnnotationOverlayGroup;
|
|
237
|
+
private applyAnnotationOverlayVisibility;
|
|
238
|
+
private createInsertVisibilityHandleForAnnotationText;
|
|
239
|
+
private applyAnnotationTextRenderableVisibility;
|
|
240
|
+
private refreshAnnotationTextVisibilityForLayer;
|
|
241
|
+
private isLayerVisible;
|
|
242
|
+
private ensureLayerGroup;
|
|
243
|
+
private compactGeometryByLayer;
|
|
244
|
+
private compactGeometryByLayerIncrementally;
|
|
245
|
+
private compactLineChunksPerLayer;
|
|
246
|
+
private compactLineChunksForSingleLayer;
|
|
247
|
+
private buildLineCompactionGroups;
|
|
248
|
+
private compactNonLineChunksPerLayer;
|
|
249
|
+
private compactNonLineChunksForSingleLayer;
|
|
250
|
+
private rebuildNonLineChunkStats;
|
|
251
|
+
private findKindGroup;
|
|
252
|
+
private disposeLineChunkRecord;
|
|
253
|
+
private applyLayerColorState;
|
|
254
|
+
private refreshDisplayColors;
|
|
255
|
+
private registerGeometryDisplayColors;
|
|
256
|
+
private installGeometryDisplayColorMetadata;
|
|
257
|
+
private applyDisplayColorsToGeometry;
|
|
258
|
+
private buildDisplayColorBytes;
|
|
259
|
+
private recordDisplayColorBuildStats;
|
|
260
|
+
private resolveDisplayHexForRgb;
|
|
261
|
+
private resolveDisplayRgbForLegacyRgb;
|
|
262
|
+
private displayElementKindForObject;
|
|
263
|
+
private createInsertInstanceRecords;
|
|
264
|
+
private createInsertPresenterMaterial;
|
|
265
|
+
private clearViewportInsertPresenter;
|
|
266
|
+
private refreshDefaultInsertPresenterIfUnmanaged;
|
|
267
|
+
private resetContent;
|
|
268
|
+
private rebuildLineChunks;
|
|
269
|
+
private applyCachedLineChunkColors;
|
|
270
|
+
private applyColorToRenderable;
|
|
271
|
+
private applyLayerTextColors;
|
|
272
|
+
private invalidateTextBatchDisplayState;
|
|
273
|
+
private applyColorToTextRenderable;
|
|
274
|
+
private applyEffectiveRenderQuality;
|
|
275
|
+
private resolveCurrentEffectiveRenderQuality;
|
|
276
|
+
private notifyInternalChange;
|
|
277
|
+
private static getTextOwnerKey;
|
|
278
|
+
private static resolveTextAnchorX;
|
|
279
|
+
private static resolveTextAnchorY;
|
|
280
|
+
private startReadyCycle;
|
|
281
|
+
private resolveReadyOnce;
|
|
282
|
+
private rejectReadyOnce;
|
|
283
|
+
}
|
|
284
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { TextEntity, ViewportRect } from '../../shared/types';
|
|
2
|
+
import type { GeometryKind, PreparedLayerChunk } from './geo-prepare';
|
|
3
|
+
import type { ParsedHeader } from '../../core';
|
|
4
|
+
import type { ExternalVariantFetchSource } from '../geo-loader';
|
|
5
|
+
export type { GeometryKind, PreparedLayerChunk } from './geo-prepare';
|
|
6
|
+
export interface GeoPrepareParseRequest {
|
|
7
|
+
type: 'parse';
|
|
8
|
+
buffer: ArrayBuffer;
|
|
9
|
+
hiddenInstanceIds?: number[];
|
|
10
|
+
keepTextsForHiddenInstances?: boolean;
|
|
11
|
+
loadBlocks?: boolean;
|
|
12
|
+
suppressExpandedInsertGeometry?: boolean;
|
|
13
|
+
maxExpandedInstanceVertices?: number;
|
|
14
|
+
externalVariantFetchSource?: ExternalVariantFetchSource;
|
|
15
|
+
deferExternalVariantGeometry?: boolean;
|
|
16
|
+
externalVariantBuffers?: Array<{
|
|
17
|
+
variantId: number;
|
|
18
|
+
buffer: ArrayBuffer;
|
|
19
|
+
}>;
|
|
20
|
+
requiredExternalVariantIds?: number[];
|
|
21
|
+
externalVariantGeometryFetchIds?: number[];
|
|
22
|
+
externalVariantDeltaOnly?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface GeoPrepareGrantMessage {
|
|
25
|
+
type: 'grant';
|
|
26
|
+
geometryCredits: number;
|
|
27
|
+
textCredits: number;
|
|
28
|
+
}
|
|
29
|
+
export interface GeoPrepareCancelMessage {
|
|
30
|
+
type: 'cancel';
|
|
31
|
+
}
|
|
32
|
+
export type GeoPrepareWorkerInputMessage = GeoPrepareParseRequest | GeoPrepareGrantMessage | GeoPrepareCancelMessage;
|
|
33
|
+
export interface GeoPrepareHeaderMessage {
|
|
34
|
+
type: 'header';
|
|
35
|
+
header: ParsedHeader;
|
|
36
|
+
}
|
|
37
|
+
export interface GeoPrepareGeometryMessage {
|
|
38
|
+
type: 'geometry';
|
|
39
|
+
kind: GeometryKind;
|
|
40
|
+
layers: PreparedLayerChunk[];
|
|
41
|
+
cost: number;
|
|
42
|
+
}
|
|
43
|
+
export interface GeoPrepareTextMessage {
|
|
44
|
+
type: 'text';
|
|
45
|
+
texts: TextEntity[];
|
|
46
|
+
cost: number;
|
|
47
|
+
}
|
|
48
|
+
export interface TransferableVariantGeometryKindChunk {
|
|
49
|
+
readonly pos: Float32Array;
|
|
50
|
+
readonly col: Uint8Array;
|
|
51
|
+
readonly count: number;
|
|
52
|
+
readonly layerIndex?: number;
|
|
53
|
+
readonly lineweightPx?: number;
|
|
54
|
+
readonly bbox?: ViewportRect | null;
|
|
55
|
+
}
|
|
56
|
+
export interface TransferableVariantGeometry {
|
|
57
|
+
readonly variantId: number;
|
|
58
|
+
readonly line: readonly TransferableVariantGeometryKindChunk[];
|
|
59
|
+
readonly fill: readonly TransferableVariantGeometryKindChunk[];
|
|
60
|
+
readonly dot: readonly TransferableVariantGeometryKindChunk[];
|
|
61
|
+
}
|
|
62
|
+
export interface TransferableInsertInstanceBatch {
|
|
63
|
+
readonly meta: Uint32Array;
|
|
64
|
+
readonly mats: Float32Array;
|
|
65
|
+
readonly bboxes: Float32Array;
|
|
66
|
+
readonly count: number;
|
|
67
|
+
}
|
|
68
|
+
export interface GeoPrepareInsertModelMessage {
|
|
69
|
+
type: 'insertModel';
|
|
70
|
+
variants: readonly TransferableVariantGeometry[];
|
|
71
|
+
instances: TransferableInsertInstanceBatch;
|
|
72
|
+
cost: number;
|
|
73
|
+
bytes: number;
|
|
74
|
+
planMs: number;
|
|
75
|
+
}
|
|
76
|
+
export interface GeoPrepareDoneMessage {
|
|
77
|
+
type: 'done';
|
|
78
|
+
}
|
|
79
|
+
export interface GeoPrepareCompleteMessage {
|
|
80
|
+
type: 'complete';
|
|
81
|
+
}
|
|
82
|
+
export interface GeoPrepareErrorMessage {
|
|
83
|
+
type: 'error';
|
|
84
|
+
message: string;
|
|
85
|
+
code?: string;
|
|
86
|
+
}
|
|
87
|
+
export type GeoPrepareWorkerOutputMessage = GeoPrepareHeaderMessage | GeoPrepareGeometryMessage | GeoPrepareTextMessage | GeoPrepareInsertModelMessage | GeoPrepareDoneMessage | GeoPrepareCompleteMessage | GeoPrepareErrorMessage;
|