@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,38 @@
|
|
|
1
|
+
import type { ViewportRect } from '../../shared/types';
|
|
2
|
+
import { type GeoChunk, type GeoGeometryChunk } from '../../core';
|
|
3
|
+
export type GeometryKind = Extract<GeoChunk['kind'], 'line' | 'fill' | 'dot'>;
|
|
4
|
+
export interface PreparedColorRun {
|
|
5
|
+
readonly startVertex: number;
|
|
6
|
+
readonly vertexCount: number;
|
|
7
|
+
readonly color: readonly [number, number, number];
|
|
8
|
+
}
|
|
9
|
+
export interface PreparedLayerChunk {
|
|
10
|
+
layerIndex: number;
|
|
11
|
+
lineweightPx?: number;
|
|
12
|
+
pos: Float32Array;
|
|
13
|
+
positionItemSize: 2 | 3;
|
|
14
|
+
col: Uint8Array;
|
|
15
|
+
count: number;
|
|
16
|
+
bbox: ViewportRect | null;
|
|
17
|
+
colorRuns?: readonly PreparedColorRun[];
|
|
18
|
+
linePositionKind?: 'xy-zero-z';
|
|
19
|
+
}
|
|
20
|
+
export type PrepareGeometryChunkOptions = {
|
|
21
|
+
markLinePositionXy?: boolean;
|
|
22
|
+
splitLineweight?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare class PreparedGeometryAccumulatorByLayer {
|
|
25
|
+
#private;
|
|
26
|
+
get size(): number;
|
|
27
|
+
append(layers: readonly PreparedLayerChunk[]): number;
|
|
28
|
+
drain(): PreparedLayerChunk[];
|
|
29
|
+
}
|
|
30
|
+
export type PreparedGeometryAccumulators = Record<GeometryKind, PreparedGeometryAccumulatorByLayer>;
|
|
31
|
+
export declare function createPreparedGeometryAccumulatorByLayer(): PreparedGeometryAccumulatorByLayer;
|
|
32
|
+
export declare function createPreparedGeometryAccumulators(): PreparedGeometryAccumulators;
|
|
33
|
+
export declare function mergePreparedBounds(current: ViewportRect | null, next: ViewportRect | null): ViewportRect | null;
|
|
34
|
+
export declare function prepareGeometryChunkByLayer(payload: GeoGeometryChunk, options?: PrepareGeometryChunkOptions): PreparedLayerChunk[];
|
|
35
|
+
export declare function appendPreparedLayers(accumulator: PreparedGeometryAccumulatorByLayer, layers: readonly PreparedLayerChunk[]): number;
|
|
36
|
+
export declare function drainPreparedLayers(accumulator: PreparedGeometryAccumulatorByLayer): PreparedLayerChunk[];
|
|
37
|
+
export declare function estimatePreparedLayerBytes(layers: readonly PreparedLayerChunk[]): number;
|
|
38
|
+
export declare function collectPreparedLayerTransfers(layers: readonly PreparedLayerChunk[]): Transferable[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TransferableInsertInstanceBatch, TransferableVariantGeometry } from './geo-prepare-worker-types';
|
|
2
|
+
import type { ParsedHeader } from '../../core';
|
|
3
|
+
export interface InsertModel {
|
|
4
|
+
variants: TransferableVariantGeometry[];
|
|
5
|
+
instances: TransferableInsertInstanceBatch;
|
|
6
|
+
bytes: number;
|
|
7
|
+
cost: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildInsertModel(header: ParsedHeader): InsertModel | null;
|
|
10
|
+
export declare function collectInsertModelTransfers(model: InsertModel): Transferable[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViewportRect } from '../../shared/types';
|
|
2
|
+
import type { GeoGeometryChunk, GroupLayerEncoding, InsertRuntimeVariant } from '../../core';
|
|
3
|
+
export type InsertRuntimeGeometryKind = 'line' | 'fill' | 'dot';
|
|
4
|
+
export type RuntimeVariantLayerChunk = {
|
|
5
|
+
readonly layerIndex: number;
|
|
6
|
+
readonly lineweightPx?: number;
|
|
7
|
+
readonly pos: Float32Array;
|
|
8
|
+
readonly col: Uint8Array;
|
|
9
|
+
readonly count: number;
|
|
10
|
+
readonly bbox: ViewportRect | null;
|
|
11
|
+
};
|
|
12
|
+
export type RuntimeVariantChunkMaps = Record<InsertRuntimeGeometryKind, ReadonlyMap<string, RuntimeVariantLayerChunk>>;
|
|
13
|
+
export declare function decodeRuntimeGeometryChunk(raw: Uint8Array, count: number, groupLayerEncoding?: GroupLayerEncoding): GeoGeometryChunk;
|
|
14
|
+
export declare function buildRuntimeVariantChunkMaps(variant: InsertRuntimeVariant): RuntimeVariantChunkMaps;
|
|
15
|
+
export declare function mergeRuntimeLayerChunkBBoxes(chunks: RuntimeVariantChunkMaps, textsBBox: ViewportRect | null): ViewportRect | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type LineVariant = 'thin' | 'fat';
|
|
2
|
+
export type LineCanonicalPosition = {
|
|
3
|
+
kind: 'xy';
|
|
4
|
+
xy: Float32Array;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'xyz';
|
|
7
|
+
xyz: Float32Array;
|
|
8
|
+
};
|
|
9
|
+
export type LineCanonicalMemoryStats = {
|
|
10
|
+
recordCount: number;
|
|
11
|
+
vertexCount: number;
|
|
12
|
+
xyRecordCount: number;
|
|
13
|
+
xyzRecordCount: number;
|
|
14
|
+
xyVertexCount: number;
|
|
15
|
+
xyzVertexCount: number;
|
|
16
|
+
positionBytes: number;
|
|
17
|
+
colorBytes: number;
|
|
18
|
+
totalBytes: number;
|
|
19
|
+
};
|
|
20
|
+
export type LineVariantStats = {
|
|
21
|
+
activeThinCount: number;
|
|
22
|
+
activeFatCount: number;
|
|
23
|
+
cachedThinCount: number;
|
|
24
|
+
cachedFatCount: number;
|
|
25
|
+
};
|
|
26
|
+
export type LineMemoryStatsSnapshot = {
|
|
27
|
+
canonical: LineCanonicalMemoryStats;
|
|
28
|
+
variants: LineVariantStats;
|
|
29
|
+
};
|
|
30
|
+
export declare function packLineCanonicalPosition(pos3d: Float32Array, vertexCount: number): LineCanonicalPosition;
|
|
31
|
+
export declare function packLineCanonicalPositionKnownXy(pos: Float32Array, vertexCount: number, itemSize?: 2 | 3): LineCanonicalPosition;
|
|
32
|
+
export declare function copyLineCanonicalPositionTo3d(position: LineCanonicalPosition, vertexCount: number, target: Float32Array, targetVertexOffset: number): void;
|
|
33
|
+
export declare function copyLineCanonicalPositionToItemSize(position: LineCanonicalPosition, vertexCount: number, target: Float32Array, targetVertexOffset: number, targetItemSize: 2 | 3): void;
|
|
34
|
+
export declare function estimateLineCanonicalMemory(position: LineCanonicalPosition, color: Uint8Array, vertexCount: number): LineCanonicalMemoryStats;
|
|
35
|
+
export declare function emptyLineCanonicalMemoryStats(): LineCanonicalMemoryStats;
|
|
36
|
+
export declare function addLineCanonicalMemoryStats(total: LineCanonicalMemoryStats, delta: LineCanonicalMemoryStats): LineCanonicalMemoryStats;
|
|
37
|
+
export declare function subtractLineCanonicalMemoryStats(total: LineCanonicalMemoryStats, delta: LineCanonicalMemoryStats): LineCanonicalMemoryStats;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LineRenderMode } from '../../shared/types';
|
|
2
|
+
export type RenderQualityMode = 'auto' | Exclude<LineRenderMode, 'width'>;
|
|
3
|
+
export type EffectiveRenderQuality = Exclude<LineRenderMode, 'width'>;
|
|
4
|
+
export interface AutoQualityContext {
|
|
5
|
+
visibleVertexCount: number;
|
|
6
|
+
zoom: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveAutoLineQuality(current: EffectiveRenderQuality, context: AutoQualityContext): EffectiveRenderQuality;
|
|
9
|
+
export declare function resolveLineQuality(requested: RenderQualityMode, current: EffectiveRenderQuality, context: AutoQualityContext): EffectiveRenderQuality;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type CreditKind = 'geometry' | 'text';
|
|
2
|
+
export interface WorkerCreditGrant {
|
|
3
|
+
geometryCredits: number;
|
|
4
|
+
textCredits: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class PrepareCreditGate {
|
|
7
|
+
private geometryCredits;
|
|
8
|
+
private textCredits;
|
|
9
|
+
private cancelled;
|
|
10
|
+
private readonly geometryWaiters;
|
|
11
|
+
private readonly textWaiters;
|
|
12
|
+
grant(grant: WorkerCreditGrant): void;
|
|
13
|
+
cancel(): void;
|
|
14
|
+
take(kind: CreditKind): Promise<boolean>;
|
|
15
|
+
private flushWaiters;
|
|
16
|
+
private flushKind;
|
|
17
|
+
private getCredits;
|
|
18
|
+
private setCredits;
|
|
19
|
+
private getWaiters;
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Box3, BufferGeometry, InstancedBufferGeometry, LineSegments, Mesh, Sphere, Vector2 } from 'three';
|
|
2
|
+
import { GeoCadLineMaterial } from './geo-cad-line-material';
|
|
3
|
+
export type CadLineBBox = {
|
|
4
|
+
minX: number;
|
|
5
|
+
minY: number;
|
|
6
|
+
maxX: number;
|
|
7
|
+
maxY: number;
|
|
8
|
+
};
|
|
9
|
+
export type CadLineCreateArgs = {
|
|
10
|
+
position: Float32Array;
|
|
11
|
+
positionItemSize: 2 | 3;
|
|
12
|
+
color: Uint8Array;
|
|
13
|
+
vertexCount: number;
|
|
14
|
+
bbox: CadLineBBox;
|
|
15
|
+
};
|
|
16
|
+
export type FatCadLineCreateArgs = CadLineCreateArgs & {
|
|
17
|
+
linewidthPx: number;
|
|
18
|
+
resolution: Vector2;
|
|
19
|
+
};
|
|
20
|
+
export type ThinCadLine = LineSegments<BufferGeometry, GeoCadLineMaterial>;
|
|
21
|
+
export type FatCadLine = Mesh<InstancedBufferGeometry, GeoCadLineMaterial>;
|
|
22
|
+
export declare function createLineBoundsFromBbox(bbox: CadLineBBox): {
|
|
23
|
+
box: Box3;
|
|
24
|
+
sphere: Sphere;
|
|
25
|
+
};
|
|
26
|
+
export declare function createThinCadLine(args: CadLineCreateArgs): ThinCadLine;
|
|
27
|
+
export declare function createFatCadLine(args: FatCadLineCreateArgs): FatCadLine;
|
|
28
|
+
export declare function markCadLineColorBufferNeedsUpdate(geometry: BufferGeometry): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Color, RawShaderMaterial, Vector2 } from 'three';
|
|
2
|
+
export type CadLineVariant = 'thin' | 'fat';
|
|
3
|
+
export declare class GeoCadLineMaterial extends RawShaderMaterial {
|
|
4
|
+
readonly color: Color;
|
|
5
|
+
readonly resolution: Vector2;
|
|
6
|
+
constructor(args: {
|
|
7
|
+
variant: CadLineVariant;
|
|
8
|
+
linewidthPx?: number;
|
|
9
|
+
resolution?: Vector2;
|
|
10
|
+
});
|
|
11
|
+
get vertexColors(): boolean;
|
|
12
|
+
set vertexColors(value: boolean);
|
|
13
|
+
get opacity(): number;
|
|
14
|
+
set opacity(value: number);
|
|
15
|
+
get linewidthPx(): number;
|
|
16
|
+
set linewidthPx(value: number);
|
|
17
|
+
updateResolution(width: number, height: number): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
|
+
import type { ViewportRect } from '../../shared/types';
|
|
3
|
+
export type BlockGeometryKind = 'line' | 'fill' | 'dot';
|
|
4
|
+
export interface BlockGeometryChunkInput {
|
|
5
|
+
readonly pos: Float32Array;
|
|
6
|
+
readonly col: Uint8Array;
|
|
7
|
+
readonly count: number;
|
|
8
|
+
readonly layerIndex?: number;
|
|
9
|
+
readonly lineweightPx?: number;
|
|
10
|
+
readonly bbox?: ViewportRect | null;
|
|
11
|
+
}
|
|
12
|
+
export interface VariantGeometryInput {
|
|
13
|
+
readonly variantId: number;
|
|
14
|
+
readonly line: readonly BlockGeometryChunkInput[];
|
|
15
|
+
readonly fill: readonly BlockGeometryChunkInput[];
|
|
16
|
+
readonly dot: readonly BlockGeometryChunkInput[];
|
|
17
|
+
}
|
|
18
|
+
export interface KindGeometry {
|
|
19
|
+
readonly geometry: BufferGeometry;
|
|
20
|
+
readonly vertexCount: number;
|
|
21
|
+
readonly layerIndex: number;
|
|
22
|
+
readonly lineweightPx?: number;
|
|
23
|
+
readonly bbox: ViewportRect | null;
|
|
24
|
+
}
|
|
25
|
+
export interface VariantGeometry {
|
|
26
|
+
readonly variantId: number;
|
|
27
|
+
readonly byKind: Map<BlockGeometryKind, readonly KindGeometry[]>;
|
|
28
|
+
}
|
|
29
|
+
export interface BlockGeometryRegistry {
|
|
30
|
+
getVariant(variantId: number): VariantGeometry | undefined;
|
|
31
|
+
variantIds(): Iterable<number>;
|
|
32
|
+
appendVariants(inputs: readonly VariantGeometryInput[]): VariantGeometry[];
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
export declare function buildBlockGeometryRegistry(inputs: readonly VariantGeometryInput[]): BlockGeometryRegistry;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ViewportRect } from '../../shared/types';
|
|
2
|
+
export interface InsertInstanceRecord {
|
|
3
|
+
readonly recordKey?: string;
|
|
4
|
+
readonly instanceId: number;
|
|
5
|
+
readonly variantId: number;
|
|
6
|
+
readonly layerIdx: number;
|
|
7
|
+
readonly matA: number;
|
|
8
|
+
readonly matB: number;
|
|
9
|
+
readonly matC: number;
|
|
10
|
+
readonly matD: number;
|
|
11
|
+
readonly tx: number;
|
|
12
|
+
readonly ty: number;
|
|
13
|
+
readonly bbox: ViewportRect;
|
|
14
|
+
}
|
|
15
|
+
export interface InsertInstanceTable {
|
|
16
|
+
readonly records: readonly InsertInstanceRecord[];
|
|
17
|
+
appendRecords(records: readonly InsertInstanceRecord[]): void;
|
|
18
|
+
replaceRecord(record: InsertInstanceRecord): boolean;
|
|
19
|
+
queryInRect(rect: ViewportRect): InsertInstanceRecord[];
|
|
20
|
+
size(): number;
|
|
21
|
+
variantHistogram(): Map<number, number>;
|
|
22
|
+
}
|
|
23
|
+
export declare function buildInsertInstanceTable(records: readonly InsertInstanceRecord[]): InsertInstanceTable;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { InstancedBufferGeometry, LineSegments, Mesh, Object3D, Points, type Material } from 'three';
|
|
2
|
+
import type { ViewportRect } from '../../shared/types';
|
|
3
|
+
import type { BlockGeometryKind, BlockGeometryRegistry, VariantGeometry } from './block-geometry-registry';
|
|
4
|
+
import type { InsertInstanceTable } from './insert-instance-table';
|
|
5
|
+
export interface LayerVisibility {
|
|
6
|
+
readonly version: number;
|
|
7
|
+
isVisible(layerIdx: number): boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface MaterialFactory {
|
|
10
|
+
(kind: BlockGeometryKind): Material;
|
|
11
|
+
}
|
|
12
|
+
export interface ViewportInstancePresenterOptions {
|
|
13
|
+
readonly registry: BlockGeometryRegistry;
|
|
14
|
+
readonly table: InsertInstanceTable;
|
|
15
|
+
readonly materialFactory: MaterialFactory;
|
|
16
|
+
readonly initialCapacity: number;
|
|
17
|
+
readonly marginRatio: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ViewportInstancePresenterDebugSlot {
|
|
20
|
+
readonly variantId: number;
|
|
21
|
+
readonly kind: BlockGeometryKind;
|
|
22
|
+
readonly geometryLayerIndex: number;
|
|
23
|
+
readonly perVertexCount: number;
|
|
24
|
+
readonly localBBox: ViewportRect | null;
|
|
25
|
+
readonly mesh: PresenterRenderable;
|
|
26
|
+
readonly capacity: number;
|
|
27
|
+
}
|
|
28
|
+
type PresenterRenderable = (LineSegments | Mesh | Points) & {
|
|
29
|
+
geometry: InstancedBufferGeometry;
|
|
30
|
+
material: Material | Material[];
|
|
31
|
+
count: number;
|
|
32
|
+
};
|
|
33
|
+
export declare class ViewportInstancePresenter {
|
|
34
|
+
private readonly slots;
|
|
35
|
+
private readonly group;
|
|
36
|
+
private readonly marginRatio;
|
|
37
|
+
private readonly table;
|
|
38
|
+
private readonly materialFactory;
|
|
39
|
+
private readonly initialCapacity;
|
|
40
|
+
private attachedParent;
|
|
41
|
+
private lastQueryAll;
|
|
42
|
+
private lastQueryRect;
|
|
43
|
+
private lastQueryHits;
|
|
44
|
+
private lastFilteredQueryRect;
|
|
45
|
+
private lastFilteredQueryAll;
|
|
46
|
+
private lastLayerVersion;
|
|
47
|
+
private lastUserHiddenCacheKey;
|
|
48
|
+
private cacheValid;
|
|
49
|
+
private visibleVertexCount;
|
|
50
|
+
constructor(opts: ViewportInstancePresenterOptions);
|
|
51
|
+
appendVariant(variant: VariantGeometry): void;
|
|
52
|
+
attach(parent: Object3D): void;
|
|
53
|
+
detach(): void;
|
|
54
|
+
invalidateQueryCache(): void;
|
|
55
|
+
refresh(viewport: ViewportRect | null, layers: LayerVisibility, userHidden: ReadonlySet<number>, userHiddenRevision?: number): void;
|
|
56
|
+
currentVisibleVertexCount(): number;
|
|
57
|
+
private resolveQueryHits;
|
|
58
|
+
private removeVariantSlots;
|
|
59
|
+
private invalidateFilteredQueryCache;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
_debugSlots(): readonly ViewportInstancePresenterDebugSlot[];
|
|
62
|
+
private ensureCapacity;
|
|
63
|
+
private writeMatRows;
|
|
64
|
+
private slotVisibleForRecord;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { GeoNode } from '../loader/internal/geo-node';
|
|
2
|
+
import type { BlockInstanceBBox } from '../shared/types';
|
|
3
|
+
export interface CadPoint2D {
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CadInsertSelectionId {
|
|
8
|
+
readonly kind: 'insert';
|
|
9
|
+
readonly layerIndex: number;
|
|
10
|
+
readonly variantId: number;
|
|
11
|
+
readonly instanceId: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CadInsertDetails {
|
|
14
|
+
readonly id: CadInsertSelectionId;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly blockName: string;
|
|
17
|
+
readonly layerName: string;
|
|
18
|
+
readonly layerIndex: number;
|
|
19
|
+
readonly tx: number;
|
|
20
|
+
readonly ty: number;
|
|
21
|
+
readonly rotation: number | null;
|
|
22
|
+
readonly scaleX: number | null;
|
|
23
|
+
readonly scaleY: number | null;
|
|
24
|
+
readonly bbox: Readonly<BlockInstanceBBox>;
|
|
25
|
+
}
|
|
26
|
+
export interface CadInsertPickOptions {
|
|
27
|
+
readonly padding?: number;
|
|
28
|
+
readonly isInstanceVisible?: (instanceId: number) => boolean;
|
|
29
|
+
readonly viewport?: Readonly<BlockInstanceBBox> | null;
|
|
30
|
+
}
|
|
31
|
+
export declare function cadInsertSelectionEquals(a: CadInsertSelectionId, b: CadInsertSelectionId): boolean;
|
|
32
|
+
/** Resolve a world-space point to the top-most selectable CAD INSERT instance. */
|
|
33
|
+
export declare function pickCadInsertAtPoint(node: GeoNode, point: CadPoint2D, options?: CadInsertPickOptions): CadInsertSelectionId | null;
|
|
34
|
+
/** Resolve stable, read-only CAD properties for an INSERT selection. */
|
|
35
|
+
export declare function resolveCadInsertDetails(node: GeoNode, id: CadInsertSelectionId): CadInsertDetails | null;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CadDisplayChunk, CadInsertInstance, CadPackDocument, CadPackHeader, CadTextChunk, ViewportRect } from '../core';
|
|
2
|
+
import { type CadLoadSource } from '../shared/cad-load-source';
|
|
3
|
+
import type { ExternalBlockVariantManifestEntry } from '../shared/types';
|
|
4
|
+
export type { CadLoadSource } from '../shared/cad-load-source';
|
|
5
|
+
export interface CadLoadFlowControlOptions {
|
|
6
|
+
highWatermarkBytes: number;
|
|
7
|
+
lowWatermarkBytes: number;
|
|
8
|
+
initialGeometryCredits: number;
|
|
9
|
+
initialTextCredits: number;
|
|
10
|
+
}
|
|
11
|
+
export interface CadExternalVariantFetchSource {
|
|
12
|
+
readonly baseUrl: string;
|
|
13
|
+
readonly entries: readonly ExternalBlockVariantManifestEntry[];
|
|
14
|
+
}
|
|
15
|
+
export interface CadLoadSessionOptions {
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
hiddenInstanceIds?: readonly number[];
|
|
18
|
+
keepTextsForHiddenInstances?: boolean;
|
|
19
|
+
loadBlocks?: boolean;
|
|
20
|
+
maxExpandedInstanceVertices?: number;
|
|
21
|
+
preferWorker?: boolean;
|
|
22
|
+
workerUrl?: string | URL;
|
|
23
|
+
workerFactory?: () => Worker;
|
|
24
|
+
externalVariantFetchSource?: CadExternalVariantFetchSource;
|
|
25
|
+
externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
|
|
26
|
+
requiredExternalVariantIds?: readonly number[];
|
|
27
|
+
externalVariantGeometryFetchIds?: readonly number[];
|
|
28
|
+
flowControl?: Partial<CadLoadFlowControlOptions>;
|
|
29
|
+
/** Cooperative decode budget before yielding to the next browser frame. */
|
|
30
|
+
frameBudgetMs?: number;
|
|
31
|
+
/** Time reserved for the renderer/UI within `frameBudgetMs`. */
|
|
32
|
+
frameReserveMs?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface CadLoadMetaEvent {
|
|
35
|
+
readonly type: 'meta';
|
|
36
|
+
readonly meta: CadPackHeader;
|
|
37
|
+
/** Alias kept explicit for consumers that distinguish metadata from the parsed header. */
|
|
38
|
+
readonly header: CadPackHeader;
|
|
39
|
+
}
|
|
40
|
+
export interface CadLoadGeometryEvent {
|
|
41
|
+
readonly type: 'geometry';
|
|
42
|
+
readonly kind: 'line' | 'fill' | 'dot';
|
|
43
|
+
readonly chunk: CadDisplayChunk;
|
|
44
|
+
readonly layerIndex: number;
|
|
45
|
+
readonly lineweightPx?: number;
|
|
46
|
+
readonly bounds: ViewportRect | null;
|
|
47
|
+
}
|
|
48
|
+
export interface CadLoadTextEvent {
|
|
49
|
+
readonly type: 'text';
|
|
50
|
+
readonly chunk: CadTextChunk;
|
|
51
|
+
}
|
|
52
|
+
export interface CadLoadVariantGeometryChunk {
|
|
53
|
+
readonly pos: Float32Array;
|
|
54
|
+
readonly col: Uint8Array;
|
|
55
|
+
readonly count: number;
|
|
56
|
+
readonly layerIndex?: number;
|
|
57
|
+
readonly lineweightPx?: number;
|
|
58
|
+
readonly bounds?: ViewportRect | null;
|
|
59
|
+
}
|
|
60
|
+
export interface CadLoadVariantGeometry {
|
|
61
|
+
readonly variantId: number;
|
|
62
|
+
readonly line: readonly CadLoadVariantGeometryChunk[];
|
|
63
|
+
readonly fill: readonly CadLoadVariantGeometryChunk[];
|
|
64
|
+
readonly dot: readonly CadLoadVariantGeometryChunk[];
|
|
65
|
+
}
|
|
66
|
+
export interface CadLoadInsertEvent {
|
|
67
|
+
readonly type: 'insert';
|
|
68
|
+
readonly instances: readonly CadInsertInstance[];
|
|
69
|
+
readonly variants: readonly CadLoadVariantGeometry[];
|
|
70
|
+
}
|
|
71
|
+
export interface CadLoadVariantRequestEvent {
|
|
72
|
+
readonly type: 'variant-request';
|
|
73
|
+
readonly variantId: number;
|
|
74
|
+
}
|
|
75
|
+
export interface CadLoadReadyEvent {
|
|
76
|
+
readonly type: 'ready';
|
|
77
|
+
readonly document: CadPackDocument;
|
|
78
|
+
}
|
|
79
|
+
export interface CadLoadErrorEvent {
|
|
80
|
+
readonly type: 'error';
|
|
81
|
+
readonly error: Error;
|
|
82
|
+
}
|
|
83
|
+
export type CadLoadEvent = CadLoadMetaEvent | CadLoadGeometryEvent | CadLoadTextEvent | CadLoadInsertEvent | CadLoadVariantRequestEvent | CadLoadReadyEvent | CadLoadErrorEvent;
|
|
84
|
+
export interface CadLoadSession {
|
|
85
|
+
readonly events: AsyncIterable<CadLoadEvent>;
|
|
86
|
+
readonly ready: Promise<CadPackDocument>;
|
|
87
|
+
abort(reason?: unknown): void;
|
|
88
|
+
dispose(): void;
|
|
89
|
+
}
|
|
90
|
+
export declare function createLoadSession(source: CadLoadSource, options?: CadLoadSessionOptions): CadLoadSession;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function toAbortError(reason: unknown, fallbackMessage?: string): Error;
|
|
2
|
+
export declare function forwardAbortSignal(signal: AbortSignal | undefined, controller: AbortController): () => void;
|
|
3
|
+
export declare function raceWithAbort<T>(promise: Promise<T>, signal: AbortSignal, fallbackMessage?: string): Promise<T>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ViewerThemeName } from './viewer-theme';
|
|
2
|
+
export type CadRgb = [number, number, number];
|
|
3
|
+
export type CadRawColor = {
|
|
4
|
+
kind: 'aci';
|
|
5
|
+
index: number;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'truecolor';
|
|
8
|
+
rgb: CadRgb;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'bylayer';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'byblock';
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'none';
|
|
15
|
+
};
|
|
16
|
+
export type CadDisplayElementKind = 'line' | 'fill' | 'dot' | 'text' | 'hatch' | 'overlay';
|
|
17
|
+
export type CadDisplayState = 'normal' | 'hover' | 'selected' | 'hidden' | 'locked' | 'xrefFaded';
|
|
18
|
+
export interface CadDisplayColorContext {
|
|
19
|
+
theme: ViewerThemeName;
|
|
20
|
+
layerColor?: CadRawColor | null;
|
|
21
|
+
byBlockColor?: CadRawColor | null;
|
|
22
|
+
parentByBlockColor?: CadRawColor | null;
|
|
23
|
+
fallbackColor?: CadRawColor | null;
|
|
24
|
+
elementKind?: CadDisplayElementKind;
|
|
25
|
+
state?: CadDisplayState;
|
|
26
|
+
enhanceContrast?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface CadDisplayColor {
|
|
29
|
+
rgb: CadRgb;
|
|
30
|
+
opacity: number;
|
|
31
|
+
raw: CadRawColor;
|
|
32
|
+
resolvedRaw: CadRawColor;
|
|
33
|
+
adapted: boolean;
|
|
34
|
+
}
|
|
35
|
+
type ThemeDisplayPalette = {
|
|
36
|
+
background: CadRgb;
|
|
37
|
+
foreground: CadRgb;
|
|
38
|
+
defaultLine: CadRgb;
|
|
39
|
+
defaultText: CadRgb;
|
|
40
|
+
hover: CadRgb;
|
|
41
|
+
selected: CadRgb;
|
|
42
|
+
lockedOpacity: number;
|
|
43
|
+
xrefOpacity: number;
|
|
44
|
+
hatchOpacity: number;
|
|
45
|
+
};
|
|
46
|
+
export declare function getCadThemeDisplayPalette(theme: ViewerThemeName): ThemeDisplayPalette;
|
|
47
|
+
export declare function resolveCadDisplayColor(raw: CadRawColor, context: CadDisplayColorContext): CadDisplayColor;
|
|
48
|
+
export declare function adaptCadDisplayRgb(rgb: readonly [number, number, number], context: Pick<CadDisplayColorContext, 'theme' | 'elementKind' | 'enhanceContrast'>): CadRgb;
|
|
49
|
+
export declare function resolveCadRawColor(raw: CadRawColor, context: CadDisplayColorContext, depth?: number): CadRawColor;
|
|
50
|
+
export declare function isLikelyLegacyForegroundRgb(rgb: readonly [number, number, number]): boolean;
|
|
51
|
+
export declare function isLegacyDefaultForegroundRgb(rgb: readonly [number, number, number]): boolean;
|
|
52
|
+
export declare function rawColorFromLegacyRgb(rgb: readonly [number, number, number], options?: {
|
|
53
|
+
treatLegacyForegroundAsAci7?: boolean;
|
|
54
|
+
}): CadRawColor;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GeoLoadSource } from './types';
|
|
2
|
+
export type CadLoadSource = GeoLoadSource | ArrayBuffer | string | URL | Pick<File, 'arrayBuffer'>;
|
|
3
|
+
export interface NormalizedCadLoadSource {
|
|
4
|
+
readonly source: GeoLoadSource;
|
|
5
|
+
readonly sourceSignal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export declare function normalizeCadLoadSource(source: CadLoadSource, signal: AbortSignal): NormalizedCadLoadSource;
|
|
8
|
+
export declare function assertGeoLoadSource(source: unknown): asserts source is GeoLoadSource;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BufferAttribute } from 'three';
|
|
2
|
+
export type RgbColorArray = Uint8Array | Float32Array;
|
|
3
|
+
export declare function toRgbBytes(source: RgbColorArray): Uint8Array;
|
|
4
|
+
export declare function colorBytesToNormalizedFloat32(source: Uint8Array): Float32Array;
|
|
5
|
+
export declare function setNormalizedRgbColorAttribute(source: Uint8Array): BufferAttribute;
|
|
6
|
+
export declare function readColorAttributeAsBytes(attribute: BufferAttribute): Uint8Array;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const GEO_LOADER_FRAME_BUDGET_MS = 16.7;
|
|
2
|
+
export declare const GEO_LOADER_RENDER_RESERVE_MS = 6;
|
|
3
|
+
export declare const GEO_LOADER_HIGH_WATERMARK_BYTES: number;
|
|
4
|
+
export declare const GEO_LOADER_LOW_WATERMARK_BYTES: number;
|
|
5
|
+
export declare const GEO_LOADER_INITIAL_GEOMETRY_CREDITS = 2;
|
|
6
|
+
export declare const GEO_LOADER_INITIAL_TEXT_CREDITS = 1;
|
|
7
|
+
export declare const LINE_STRESS_ENTER_VERTS = 300000;
|
|
8
|
+
export declare const LINE_STRESS_EXIT_VERTS = 220000;
|
|
9
|
+
export declare const LINE_THICK_LW_PX = 2;
|
|
10
|
+
export declare const PROMOTED_INSERT_FAST_VISIBILITY_ENABLED = true;
|
|
11
|
+
export declare const PROMOTED_INSERT_MIN_REFCOUNT = 1;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type DisplayRgbResolver = (rgb: readonly [number, number, number]) => readonly [number, number, number];
|
|
2
|
+
export interface DisplayColorBuildStats {
|
|
3
|
+
readonly vertexCount: number;
|
|
4
|
+
readonly runCount: number;
|
|
5
|
+
readonly uniqueColorCount: number;
|
|
6
|
+
readonly cacheHitCount: number;
|
|
7
|
+
readonly repeatedRunVertexCount: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DisplayColorBuildResult {
|
|
10
|
+
readonly color: Uint8Array;
|
|
11
|
+
readonly stats: DisplayColorBuildStats;
|
|
12
|
+
}
|
|
13
|
+
export interface DisplayColorFloatBuildResult {
|
|
14
|
+
readonly color: Float32Array;
|
|
15
|
+
readonly stats: DisplayColorBuildStats;
|
|
16
|
+
}
|
|
17
|
+
export interface SourceColorRun {
|
|
18
|
+
readonly startVertex: number;
|
|
19
|
+
readonly vertexCount: number;
|
|
20
|
+
readonly color: readonly [number, number, number];
|
|
21
|
+
}
|
|
22
|
+
export declare function hasCompleteSourceColorRuns(vertexCount: number, runs: readonly SourceColorRun[]): boolean;
|
|
23
|
+
export declare function buildDisplayColorBytesFromRuns(sourceColor: Uint8Array, resolveRgb: DisplayRgbResolver): DisplayColorBuildResult;
|
|
24
|
+
export declare function buildDisplayColorBytesFromSourceRuns(vertexCount: number, runs: readonly SourceColorRun[], resolveRgb: DisplayRgbResolver): DisplayColorBuildResult;
|
|
25
|
+
export declare function buildDisplayColorFloatsFromSourceRuns(vertexCount: number, runs: readonly SourceColorRun[], resolveRgb: DisplayRgbResolver): DisplayColorFloatBuildResult;
|
|
26
|
+
export declare function writeDisplayColorBytesFromSourceRuns(target: Uint8Array, vertexCount: number, runs: readonly SourceColorRun[], resolveRgb: DisplayRgbResolver): DisplayColorBuildStats;
|
|
27
|
+
export declare function writeDisplayColorFloatsFromSourceRuns(target: Float32Array, vertexCount: number, runs: readonly SourceColorRun[], resolveRgb: DisplayRgbResolver): DisplayColorBuildStats;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ResolvedTextFont {
|
|
2
|
+
readonly text: string;
|
|
3
|
+
readonly fontUrl?: string;
|
|
4
|
+
readonly kind?: string;
|
|
5
|
+
readonly replacedUnsupported: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type ResolveTextFont = (text: string) => ResolvedTextFont;
|
|
8
|
+
export declare function normalizeCadTextForRendering(text: string): {
|
|
9
|
+
text: string;
|
|
10
|
+
replacedUnsupported: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function defaultResolveTextFont(text: string): ResolvedTextFont;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility facade while the renderer-neutral contracts live in
|
|
3
|
+
* `@nebula-spatial/cad-loader/core`.
|
|
4
|
+
*/
|
|
5
|
+
export type * from '../core';
|
|
6
|
+
import type { ViewportRect } from '../core';
|
|
7
|
+
/** Browser source contract owned by the loader runtime, not its core parser. */
|
|
8
|
+
export type GeoLoadSource = {
|
|
9
|
+
kind: 'buffer';
|
|
10
|
+
buffer: ArrayBuffer;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'packFile';
|
|
13
|
+
file: File;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'url';
|
|
16
|
+
url: string;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
};
|
|
19
|
+
/** Three viewer compatibility types retained in cad-loader during the package transition. */
|
|
20
|
+
export interface LayerVertexChunk {
|
|
21
|
+
posArray: Float32Array;
|
|
22
|
+
start: number;
|
|
23
|
+
count: number;
|
|
24
|
+
bbox: ViewportRect;
|
|
25
|
+
}
|
|
26
|
+
export interface LayerVertexStat {
|
|
27
|
+
chunks: LayerVertexChunk[];
|
|
28
|
+
}
|
|
29
|
+
export type LineRenderMode = 'width' | 'full' | 'stress';
|
|
30
|
+
export interface SplitBlockLayerDetail {
|
|
31
|
+
variantId: number;
|
|
32
|
+
blockName: string;
|
|
33
|
+
layerCount: number;
|
|
34
|
+
instanceCount: number;
|
|
35
|
+
layers: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface RenderDebugBreakdownEntry {
|
|
38
|
+
kind: 'line' | 'fill' | 'dot' | 'text' | 'insertPresenter' | 'other';
|
|
39
|
+
label: string;
|
|
40
|
+
renderables: number;
|
|
41
|
+
submittedVertexRefs: number;
|
|
42
|
+
}
|
|
43
|
+
export interface SceneStats {
|
|
44
|
+
fpsCurrent: number;
|
|
45
|
+
drawCalls: number;
|
|
46
|
+
renderableCount?: number;
|
|
47
|
+
viewportVertexCount: number;
|
|
48
|
+
submittedVertexRefs: number;
|
|
49
|
+
lineRenderMode: LineRenderMode;
|
|
50
|
+
visibleLayerCount: number;
|
|
51
|
+
totalLayerCount: number;
|
|
52
|
+
renderDebugBreakdown?: RenderDebugBreakdownEntry[];
|
|
53
|
+
blockVariantCount?: number;
|
|
54
|
+
blockInstanceCount?: number;
|
|
55
|
+
splitBlockLayerGroupCount?: number;
|
|
56
|
+
splitBlockLayerDetails?: SplitBlockLayerDetail[];
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../core';
|