@cognite/reveal 4.37.0 → 4.39.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/dist/assets/eptBinaryDecoder.worker-DjciQFFi.js.map +1 -0
- package/dist/index.js +6313 -5940
- package/dist/index.js.map +1 -1
- package/dist/packages/api/src/public/RevealManager.d.ts +11 -1
- package/dist/packages/api/src/public/RevealOptions.d.ts +1 -0
- package/dist/packages/api/src/public/migration/Cognite3DViewer.d.ts +31 -1
- package/dist/packages/api/src/public/migration/renderOptionsHelpers.d.ts +6 -1
- package/dist/packages/api/src/public/migration/types.d.ts +11 -0
- package/dist/packages/api/src/public/types.d.ts +1 -1
- package/dist/packages/cad-geometry-loaders/src/CadManager.d.ts +3 -1
- package/dist/packages/cad-geometry-loaders/src/createCadManager.d.ts +2 -1
- package/dist/packages/cad-geometry-loaders/src/sector/SectorDownloadScheduler.d.ts +6 -0
- package/dist/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +10 -1
- package/dist/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV9SectorMap.d.ts +8 -1
- package/dist/packages/cad-model/src/CadModelFactory.d.ts +3 -1
- package/dist/packages/cad-model/src/picking/CadPickBuffer.d.ts +22 -0
- package/dist/packages/cad-model/src/picking/CadPickCache.d.ts +43 -0
- package/dist/packages/cad-model/src/picking/PickingHandler.d.ts +11 -19
- package/dist/packages/cad-model/src/picking/depthToIntersection.d.ts +12 -0
- package/dist/packages/cad-model/src/picking/types.d.ts +9 -0
- package/dist/packages/cad-model/src/wrappers/CadNode.d.ts +3 -1
- package/dist/packages/cad-styling/src/NodeAppearanceTextureBuilder.d.ts +5 -2
- package/dist/packages/data-providers/src/utilities/gzipUtils.d.ts +3 -0
- package/dist/packages/pointclouds/src/PointCloudFactory.d.ts +3 -1
- package/dist/packages/pointclouds/src/PointCloudManager.d.ts +8 -1
- package/dist/packages/pointclouds/src/PointCloudNode.d.ts +4 -2
- package/dist/packages/pointclouds/src/PointCloudPickingHandler.d.ts +19 -4
- package/dist/packages/pointclouds/src/createPointCloudManager.d.ts +2 -1
- package/dist/packages/pointclouds/src/potree-three-loader/tree/PointCloudOctreePicker.d.ts +2 -2
- package/dist/packages/rendering/index.d.ts +2 -0
- package/dist/packages/rendering/src/CadMaterialManager.d.ts +10 -3
- package/dist/packages/rendering/src/RenderPipelineProvider.d.ts +4 -1
- package/dist/packages/rendering/src/pointcloud-rendering/PointCloudMaterial.d.ts +1 -0
- package/dist/packages/rendering/src/pointcloud-rendering/PointCloudObjectAppearanceTexture.d.ts +7 -0
- package/dist/packages/rendering/src/pointcloud-rendering/constants.d.ts +43 -0
- package/dist/packages/rendering/src/render-passes/CadShadowPass.d.ts +31 -0
- package/dist/packages/rendering/src/render-passes/PostProcessingPass.d.ts +7 -1
- package/dist/packages/rendering/src/render-passes/ShadowMapPass.d.ts +56 -0
- package/dist/packages/rendering/src/render-passes/types.d.ts +3 -0
- package/dist/packages/rendering/src/render-pipeline-providers/DefaultRenderPipelineProvider.d.ts +10 -2
- package/dist/packages/rendering/src/render-pipeline-providers/types.d.ts +19 -1
- package/dist/packages/rendering/src/rendering/CustomObjectEffectMaterial.d.ts +75 -0
- package/dist/packages/rendering/src/rendering/cadLighting.d.ts +5 -0
- package/dist/packages/rendering/src/rendering/shaders.d.ts +1 -0
- package/dist/packages/rendering/src/rendering/types.d.ts +1 -0
- package/dist/packages/utilities/index.d.ts +2 -0
- package/dist/packages/utilities/src/PickCacheInvalidator.d.ts +17 -0
- package/dist/packages/utilities/src/customObject/CustomObject.d.ts +10 -0
- package/dist/packages/utilities/src/customObject/ICustomObject.d.ts +8 -0
- package/dist/packages/utilities/src/renderContextState.d.ts +4 -0
- package/package.json +10 -10
- package/dist/assets/eptBinaryDecoder.worker-C6kIzxA1.js.map +0 -1
- package/dist/packages/data-providers/src/utilities/brotliDecompressTypes.d.ts +0 -6
|
@@ -6,6 +6,7 @@ import { LoadingState } from '../../../model-base';
|
|
|
6
6
|
import { CadManager, CadModelBudget } from '../../../cad-geometry-loaders';
|
|
7
7
|
import { NodeAppearanceProvider } from '../../../cad-styling';
|
|
8
8
|
import { RenderMode, RenderPipelineExecutor, CadMaterialManager, RenderPipelineProvider, ResizeHandler, SettableRenderTarget } from '../../../rendering';
|
|
9
|
+
import { PickCacheInvalidator } from '../../../utilities';
|
|
9
10
|
import { CameraManager } from '../../../camera-manager';
|
|
10
11
|
import { DataSourceType, File3dFormat, InternalDataSourceType } from '../../../data-providers';
|
|
11
12
|
import { AddModelOptionsWithModelRevisionId } from '../../../data-providers/src/utilities/internalAddModelOptions';
|
|
@@ -25,19 +26,25 @@ export declare class RevealManager {
|
|
|
25
26
|
private readonly _renderPipeline;
|
|
26
27
|
private readonly _resizeHandler;
|
|
27
28
|
private _cameraInMotion;
|
|
29
|
+
private _lastCameraSnapshot;
|
|
30
|
+
private readonly _pickCacheInvalidator;
|
|
28
31
|
private _isDisposed;
|
|
29
32
|
private readonly _subscriptions;
|
|
30
33
|
private readonly _events;
|
|
31
34
|
private readonly _cameraManager;
|
|
32
35
|
private readonly _onCameraChange;
|
|
33
36
|
private readonly _onCameraStop;
|
|
34
|
-
constructor(cadManager: CadManager, pointCloudManager: PointCloudManager, pipelineExecutor: RenderPipelineExecutor, renderPipeline: RenderPipelineProvider & SettableRenderTarget, resizeHandler: ResizeHandler, cameraManager: CameraManager);
|
|
37
|
+
constructor(cadManager: CadManager, pointCloudManager: PointCloudManager, pipelineExecutor: RenderPipelineExecutor, renderPipeline: RenderPipelineProvider & SettableRenderTarget, resizeHandler: ResizeHandler, cameraManager: CameraManager, pickCacheInvalidator: PickCacheInvalidator);
|
|
35
38
|
dispose(): void;
|
|
36
39
|
requestRedraw(): void;
|
|
37
40
|
resetRedraw(): void;
|
|
38
41
|
setOutputRenderTarget(target: WebGLRenderTarget | null, autoSizeRenderTarget?: boolean): void;
|
|
39
42
|
get materialManager(): CadMaterialManager;
|
|
40
43
|
get needsRedraw(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Flag that is set whenever something that can change what a pick hits changes. See {@link PickCacheInvalidator}.
|
|
46
|
+
*/
|
|
47
|
+
get pickCacheInvalidator(): PickCacheInvalidator;
|
|
41
48
|
get cameraInMotion(): boolean;
|
|
42
49
|
update(camera: PerspectiveCamera): void;
|
|
43
50
|
get cadBudget(): CadModelBudget;
|
|
@@ -45,6 +52,8 @@ export declare class RevealManager {
|
|
|
45
52
|
get cadLoadedStatistics(): CadModelSectorLoadStatistics;
|
|
46
53
|
get cadRenderMode(): RenderMode;
|
|
47
54
|
set cadRenderMode(renderMode: RenderMode);
|
|
55
|
+
get shadowsEnabled(): boolean;
|
|
56
|
+
set shadowsEnabled(enabled: boolean);
|
|
48
57
|
get pointCloudBudget(): PointCloudBudget;
|
|
49
58
|
set pointCloudBudget(budget: PointCloudBudget);
|
|
50
59
|
set clippingPlanes(clippingPlanes: Plane[]);
|
|
@@ -61,4 +70,5 @@ export declare class RevealManager {
|
|
|
61
70
|
removeModel(type: 'cad', model: CadNode): void;
|
|
62
71
|
removeModel(type: 'pointcloud', model: PointCloudNode): void;
|
|
63
72
|
private initLoadingStateObserver;
|
|
73
|
+
private requestPickCacheInvalidationIfCameraChanged;
|
|
64
74
|
}
|
|
@@ -24,6 +24,8 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
|
|
|
24
24
|
private readonly _domElementResizeObserver;
|
|
25
25
|
private readonly _image360ApiHelper;
|
|
26
26
|
private readonly _unsubsribeOnLoading;
|
|
27
|
+
private _onContextLost;
|
|
28
|
+
private _onContextRestored;
|
|
27
29
|
/**
|
|
28
30
|
* Returns the rendering canvas, the DOM element where the renderer draws its output.
|
|
29
31
|
*/
|
|
@@ -83,6 +85,19 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
|
|
|
83
85
|
* budget is shared between all added CAD models and not a per-model budget.
|
|
84
86
|
*/
|
|
85
87
|
set cadBudget(budget: CadModelBudget);
|
|
88
|
+
/**
|
|
89
|
+
* Gets whether CAD shadows are currently enabled.
|
|
90
|
+
* @beta
|
|
91
|
+
*/
|
|
92
|
+
get shadowsEnabled(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Enables or disables CAD shadows at runtime, along with the world-space sun shading
|
|
95
|
+
* that matches them. Turning shadows on changes the CAD look even where no shadow is
|
|
96
|
+
* cast, including ghosted nodes. The GPU resources are allocated the first time shadows
|
|
97
|
+
* are enabled.
|
|
98
|
+
* @beta
|
|
99
|
+
*/
|
|
100
|
+
set shadowsEnabled(enabled: boolean);
|
|
86
101
|
/**
|
|
87
102
|
* Returns the point cloud budget. The budget is shared between all loaded
|
|
88
103
|
* point cloud models.
|
|
@@ -98,6 +113,12 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
|
|
|
98
113
|
*/
|
|
99
114
|
get models(): CogniteModel<DataSourceT>[];
|
|
100
115
|
constructor(options: Cognite3DViewerOptions);
|
|
116
|
+
/**
|
|
117
|
+
* Listens for render context loss/restore. On loss, prevents the default (so the
|
|
118
|
+
* browser attempts recovery) and sets `isRenderContextLost()`; on restore, clears
|
|
119
|
+
* the flag and requests a redraw.
|
|
120
|
+
*/
|
|
121
|
+
private registerContextLossHandlers;
|
|
101
122
|
/**
|
|
102
123
|
* Get resolution options that are set on the viewer. This includes
|
|
103
124
|
* settings for max resolution and limiting resolution when moving the camera.
|
|
@@ -388,6 +409,8 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
|
|
|
388
409
|
addObject3D(object: Object3D): void;
|
|
389
410
|
/**
|
|
390
411
|
* Add a CustomObject to the viewer.
|
|
412
|
+
* Meshes in the custom object can use {@link CustomObjectEffectMaterial}, which supports
|
|
413
|
+
* effects specific to custom objects.
|
|
391
414
|
* @param customObject
|
|
392
415
|
* @example
|
|
393
416
|
* ```js
|
|
@@ -398,6 +421,13 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
|
|
|
398
421
|
* const customObject = CustomObject(sphere);
|
|
399
422
|
* customObject.isPartOfBoundingBox = false;
|
|
400
423
|
* viewer.addCustomObject(customObject);
|
|
424
|
+
*
|
|
425
|
+
* // Ground plane that receives CAD shadows and texture variation
|
|
426
|
+
* const groundMaterial = new CustomObjectEffectMaterial('#ffffff', texture);
|
|
427
|
+
* groundMaterial.setReceivesShadow(true);
|
|
428
|
+
* groundMaterial.setTextureVariation('hexTiling');
|
|
429
|
+
* const plane = new Mesh(new PlaneGeometry(100, 100), groundMaterial);
|
|
430
|
+
* viewer.addCustomObject(CustomObject(plane));
|
|
401
431
|
* ```
|
|
402
432
|
* @beta
|
|
403
433
|
*/
|
|
@@ -677,7 +707,7 @@ export declare class Cognite3DViewer<DataSourceT extends DataSourceType = Classi
|
|
|
677
707
|
* @param options
|
|
678
708
|
* @param options.stopOnHitting360Icon
|
|
679
709
|
* @param options.predicate Check whether a CustomObject should be intersected.
|
|
680
|
-
* @param options.forceWindowedPick Skip point
|
|
710
|
+
* @param options.forceWindowedPick Skip point cloud and CAD full-frame pick caching for this call.
|
|
681
711
|
* @returns A promise that if there was an intersection then return the intersection object - otherwise it
|
|
682
712
|
* returns `null` if there were no intersections.
|
|
683
713
|
* @beta
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SsaoParameters, AntiAliasingMode } from '../../../../rendering';
|
|
1
|
+
import { EdlOptions, SsaoParameters, AntiAliasingMode } from '../../../../rendering';
|
|
2
2
|
import { DeviceDescriptor } from '../../../../utilities';
|
|
3
3
|
import { PropType } from '../../utilities/reflection';
|
|
4
4
|
import { Cognite3DViewerOptions } from './types';
|
|
@@ -30,4 +30,9 @@ export declare function determineSsaoRenderParameters(qualityHint: SsaoQualityHi
|
|
|
30
30
|
* @param devicePixelRatio Device pixel ratio set on the renderer.
|
|
31
31
|
*/
|
|
32
32
|
export declare function determineResolutionCap(rendererResolutionThreshold: number | undefined, device: DeviceDescriptor, devicePixelRatio: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Create EDL options from input options. The radius is clamped to the maximum supported radius.
|
|
35
|
+
* @param inputOptions
|
|
36
|
+
*/
|
|
37
|
+
export declare function createCompleteEdlOptions(inputOptions?: Partial<EdlOptions> | 'disabled'): EdlOptions;
|
|
33
38
|
export {};
|
|
@@ -147,6 +147,17 @@ export interface Cognite3DViewerOptions {
|
|
|
147
147
|
* Enables / disables visualizing the edges of geometry. Defaults to true.
|
|
148
148
|
*/
|
|
149
149
|
enableEdges?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Enables shadows cast by CAD geometry, and the world-space sun shading that goes with
|
|
152
|
+
* them. Turning shadows on changes the CAD look even where no shadow is cast, including
|
|
153
|
+
* ghosted nodes. Defaults to false. Can also be toggled at runtime through
|
|
154
|
+
* {@link Cognite3DViewer.shadowsEnabled}.
|
|
155
|
+
* Custom objects receive shadows when they use {@link CustomObjectEffectMaterial} and request
|
|
156
|
+
* it with {@link CustomObjectEffectMaterial.setReceivesShadow}. GPU resources are only allocated
|
|
157
|
+
* when first enabled.
|
|
158
|
+
* @beta
|
|
159
|
+
*/
|
|
160
|
+
enableShadows?: boolean;
|
|
150
161
|
/** Callback to download stream progress. */
|
|
151
162
|
onLoading?: OnLoadingCallback;
|
|
152
163
|
/**
|
|
@@ -7,7 +7,7 @@ import { CognitePointCloudModel } from '../../../pointclouds';
|
|
|
7
7
|
*/
|
|
8
8
|
export type CogniteModel<T extends DataSourceType = ClassicDataSourceType> = CogniteCadModel | CognitePointCloudModel<T>;
|
|
9
9
|
export { WellKnownAsprsPointClassCodes } from '../../../pointclouds';
|
|
10
|
-
export { PointShape, PointColorType, PointSizeType } from '../../../rendering';
|
|
10
|
+
export { PointShape, PointColorType, PointSizeType, CustomObjectEffectMaterial, CadShadowReceiverForCustomObjectMaterial, type TextureVariationType } from '../../../rendering';
|
|
11
11
|
/**
|
|
12
12
|
* A tuple of a 360 image and its collection.
|
|
13
13
|
*/
|
|
@@ -6,6 +6,7 @@ import { CadMaterialManager, RenderMode } from '../../rendering';
|
|
|
6
6
|
import { ModelIdentifier, File3dFormat } from '../../data-providers';
|
|
7
7
|
import { CadModelBudget } from './CadModelBudget';
|
|
8
8
|
import { CadModelFactory, CadModelSectorLoadStatistics, CadNode, GeometryFilter } from '../../cad-model';
|
|
9
|
+
import { PickCacheInvalidator } from '../../utilities';
|
|
9
10
|
export declare class CadManager {
|
|
10
11
|
private readonly _materialManager;
|
|
11
12
|
private readonly _cadModelFactory;
|
|
@@ -15,6 +16,7 @@ export declare class CadManager {
|
|
|
15
16
|
private readonly _unsubscribeLoadingState;
|
|
16
17
|
private _compatibleFileFormat;
|
|
17
18
|
private _needsRedraw;
|
|
19
|
+
private readonly _pickCacheInvalidator;
|
|
18
20
|
private readonly _loadingStateChangedTrigger;
|
|
19
21
|
private readonly _markNeedsRedrawBound;
|
|
20
22
|
private readonly _sectorBufferTime;
|
|
@@ -26,7 +28,7 @@ export declare class CadManager {
|
|
|
26
28
|
* Returns statistics about how data loaded (or data about to be loaded).
|
|
27
29
|
*/
|
|
28
30
|
get loadedStatistics(): CadModelSectorLoadStatistics;
|
|
29
|
-
constructor(materialManger: CadMaterialManager, cadModelFactory: CadModelFactory, cadModelUpdateHandler: CadModelUpdateHandler);
|
|
31
|
+
constructor(materialManger: CadMaterialManager, cadModelFactory: CadModelFactory, cadModelUpdateHandler: CadModelUpdateHandler, pickCacheInvalidator: PickCacheInvalidator);
|
|
30
32
|
dispose(): void;
|
|
31
33
|
requestRedraw(): void;
|
|
32
34
|
resetRedraw(): void;
|
|
@@ -2,6 +2,7 @@ import { CadManager } from './CadManager';
|
|
|
2
2
|
import { InternalRevealCadOptions } from './InternalRevealCadOptions';
|
|
3
3
|
import { CadMaterialManager } from '../../rendering';
|
|
4
4
|
import { ModelDataProvider, ModelMetadataProvider } from '../../data-providers';
|
|
5
|
+
import { PickCacheInvalidator } from '../../utilities';
|
|
5
6
|
export declare function createCadManager(modelMetadataProvider: ModelMetadataProvider, modelDataProvider: ModelDataProvider, materialManager: CadMaterialManager, cadOptions: InternalRevealCadOptions & {
|
|
6
7
|
continuousModelStreaming?: boolean;
|
|
7
|
-
}): CadManager;
|
|
8
|
+
}, pickCacheInvalidator: PickCacheInvalidator): CadManager;
|
|
@@ -12,12 +12,18 @@ export declare class SectorDownloadScheduler {
|
|
|
12
12
|
get numberOfQueuedDownloads(): number;
|
|
13
13
|
constructor(maxConcurrentSectorDownloads?: number);
|
|
14
14
|
queueSectorBatchForDownload(downloadData: SectorDownloadData[]): Promise<ConsumedSector>[];
|
|
15
|
+
/**
|
|
16
|
+
* Drops all downloads that are queued but not yet started, resolving them as discarded.
|
|
17
|
+
* Downloads that are already in progress are left untouched.
|
|
18
|
+
*/
|
|
19
|
+
clearQueuedDownloads(): void;
|
|
15
20
|
private createDiscardedConsumedSector;
|
|
16
21
|
private abortPendingDownload;
|
|
17
22
|
private removeDownloadFromQueue;
|
|
18
23
|
private getOrAddToQueuedDownloads;
|
|
19
24
|
private addSectorToPendingDownloads;
|
|
20
25
|
private processNextQueuedSectorDownload;
|
|
26
|
+
private downloadOrDiscard;
|
|
21
27
|
private getSectorIdentifier;
|
|
22
28
|
private createAbortSignal;
|
|
23
29
|
}
|
|
@@ -24,6 +24,15 @@ export declare class SectorLoader {
|
|
|
24
24
|
reportNewSectorsLoaded(loadedCountChange: number): void;
|
|
25
25
|
private shouldLoad;
|
|
26
26
|
private getSectorCuller;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Culls the batch against already loaded geometry and queues the remaining sectors for download.
|
|
29
|
+
* Resolves to no downloads if the load is superseded.
|
|
30
|
+
*/
|
|
31
|
+
private startBatch;
|
|
32
|
+
/**
|
|
33
|
+
* Yields the sectors of a batch as they finish downloading, and reports progress.
|
|
34
|
+
* Stops as soon as the load is superseded.
|
|
35
|
+
*/
|
|
36
|
+
private consumeBatch;
|
|
28
37
|
private startLoadingBatch;
|
|
29
38
|
}
|
package/dist/packages/cad-geometry-loaders/src/sector/culling/takensectors/TakenV9SectorMap.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { CadModelMetadata, SectorMetadata } from '../../../../../cad-parsers';
|
|
|
5
5
|
export declare class TakenV9SectorMap extends TakenSectorMapBase {
|
|
6
6
|
private readonly determineSectorCost;
|
|
7
7
|
private readonly _totalCost;
|
|
8
|
+
/** Cost of sectors force-included via {@link markSectorForced}; these bypass the budget. */
|
|
9
|
+
private readonly _forcedCost;
|
|
8
10
|
private readonly _models;
|
|
9
11
|
get totalCost(): SectorCost;
|
|
10
12
|
get modelsMetadata(): CadModelMetadata[];
|
|
@@ -13,9 +15,14 @@ export declare class TakenV9SectorMap extends TakenSectorMapBase {
|
|
|
13
15
|
markSectorDetailed(model: CadModelMetadata, sectorId: number, priority: number): void;
|
|
14
16
|
/**
|
|
15
17
|
* Marks a sector as forced-detailed with infinite priority.
|
|
16
|
-
* These sectors are always loaded regardless of budget constraints
|
|
18
|
+
* These sectors are always loaded regardless of budget constraints, and their cost
|
|
19
|
+
* does not count against the budget (see {@link isWithinBudget}).
|
|
17
20
|
*/
|
|
18
21
|
markSectorForced(model: CadModelMetadata, sectorId: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Cost of non-forced sectors is compared against the budget. Forced sectors (e.g. fully locked
|
|
24
|
+
* models) are excluded so they cannot starve other models of budget.
|
|
25
|
+
*/
|
|
19
26
|
isWithinBudget(budget: CadModelBudget): boolean;
|
|
20
27
|
collectWantedSectors(): PrioritizedWantedSector[];
|
|
21
28
|
clear(): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PickCacheInvalidator } from '../../utilities';
|
|
1
2
|
import { GeometryFilter } from './types';
|
|
2
3
|
import { CadMaterialManager } from '../../rendering';
|
|
3
4
|
import { CadModelMetadata } from '../../cad-parsers';
|
|
@@ -5,10 +6,11 @@ import { ModelDataProvider, ModelMetadataProvider, ModelIdentifier, File3dFormat
|
|
|
5
6
|
import { CadNode } from './wrappers/CadNode';
|
|
6
7
|
export declare class CadModelFactory {
|
|
7
8
|
private readonly _materialManager;
|
|
9
|
+
private readonly _pickCacheInvalidator;
|
|
8
10
|
private readonly _modelDataProvider;
|
|
9
11
|
private readonly _cadModelMetadataRepository;
|
|
10
12
|
private _gltfSectorRepository;
|
|
11
|
-
constructor(materialManager: CadMaterialManager, modelMetadataProvider: ModelMetadataProvider, modelDataProvider: ModelDataProvider);
|
|
13
|
+
constructor(materialManager: CadMaterialManager, modelMetadataProvider: ModelMetadataProvider, modelDataProvider: ModelDataProvider, pickCacheInvalidator: PickCacheInvalidator);
|
|
12
14
|
loadModelMetadata(externalModelIdentifier: ModelIdentifier, outputFormat?: File3dFormat): Promise<CadModelMetadata>;
|
|
13
15
|
createModel(metadata: CadModelMetadata, geometryFilter?: GeometryFilter): CadNode;
|
|
14
16
|
private getSectorRepository;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2026 Cognite AS
|
|
3
|
+
*/
|
|
4
|
+
export type CadPickBufferHit = {
|
|
5
|
+
modelIndex: number;
|
|
6
|
+
treeIndex: number;
|
|
7
|
+
depth: number;
|
|
8
|
+
};
|
|
9
|
+
export declare class CadPickBuffer {
|
|
10
|
+
readonly width: number;
|
|
11
|
+
readonly height: number;
|
|
12
|
+
readonly treeIndexPixels: Uint8Array;
|
|
13
|
+
readonly depthPixels: Uint8Array;
|
|
14
|
+
constructor(width: number, height: number);
|
|
15
|
+
static decodeModelIndex(pixels: Uint8Array, offset: number): number | undefined;
|
|
16
|
+
static decodeTreeIndex(pixels: Uint8Array, offset: number): number;
|
|
17
|
+
static unpackDepth(pixels: Uint8Array, offset: number): number;
|
|
18
|
+
getHit(normalizedCoords: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}): CadPickBufferHit | undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { WebGLRenderer } from 'three';
|
|
2
|
+
import { IntersectInput } from '../../../model-base';
|
|
3
|
+
import { CadMaterialManager } from '../../../rendering';
|
|
4
|
+
import { SceneHandler } from '../../../utilities';
|
|
5
|
+
import { CadNode } from '../wrappers/CadNode';
|
|
6
|
+
import { IntersectCadNodesResult } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Full-frame pick cache. Renders the tree index and depth of all visible models in one pass each
|
|
9
|
+
* and serves picks from the CPU copy until the scene is rendered again.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CadPickCache {
|
|
12
|
+
private static readonly REBUILD_HOLDOFF_MS;
|
|
13
|
+
private static readonly MAX_CACHED_MODELS;
|
|
14
|
+
private readonly _clearColor;
|
|
15
|
+
private readonly _clearAlpha;
|
|
16
|
+
private readonly _renderTarget;
|
|
17
|
+
private readonly _pipelineExecutor;
|
|
18
|
+
private readonly _depthRenderPipeline;
|
|
19
|
+
private readonly _treeIndexRenderPipeline;
|
|
20
|
+
private _cache;
|
|
21
|
+
private _invalidationCount;
|
|
22
|
+
private _lastInvalidatedAt;
|
|
23
|
+
private _isDisposed;
|
|
24
|
+
constructor(renderer: WebGLRenderer, materialManager: CadMaterialManager, sceneHandler: SceneHandler);
|
|
25
|
+
/**
|
|
26
|
+
* Marks the cache stale. Must be called whenever the camera or scene content that affects picking changes, as the
|
|
27
|
+
* cache does not compare the camera itself.
|
|
28
|
+
*/
|
|
29
|
+
invalidate(): void;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Picks from the cache, rebuilding it first when it is stale and the frame is likely to stay
|
|
33
|
+
* unchanged. Returns undefined when the per-model path should be used instead.
|
|
34
|
+
*/
|
|
35
|
+
intersect(visibleCadNodes: CadNode[], input: IntersectInput, shouldRunAsync: boolean): Promise<IntersectCadNodesResult | undefined>;
|
|
36
|
+
private isUsable;
|
|
37
|
+
/**
|
|
38
|
+
* Renders the tree index and depth of all visible models into full-frame buffers, one pass each,
|
|
39
|
+
* so every pixel holds the hit closest to the camera. Returns false if the result is stale.
|
|
40
|
+
*/
|
|
41
|
+
private build;
|
|
42
|
+
private renderAndReadFullFrame;
|
|
43
|
+
}
|
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebGLRenderer } from 'three';
|
|
2
2
|
import { IntersectInput } from '../../../model-base';
|
|
3
3
|
import { CadMaterialManager } from '../../../rendering';
|
|
4
4
|
import { SceneHandler } from '../../../utilities';
|
|
5
5
|
import { CadNode } from '../wrappers/CadNode';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
point: Vector3;
|
|
9
|
-
treeIndex: number;
|
|
10
|
-
cadNode: CadNode;
|
|
11
|
-
object: Object3D;
|
|
12
|
-
};
|
|
6
|
+
import { CadPickCache } from './CadPickCache';
|
|
7
|
+
import { IntersectCadNodesResult } from './types';
|
|
13
8
|
export declare class PickingHandler {
|
|
14
9
|
private readonly _clearColor;
|
|
15
10
|
private readonly _clearAlpha;
|
|
16
11
|
private readonly _raycaster;
|
|
17
12
|
private readonly _pickPixelColorStorage;
|
|
18
|
-
private readonly _rgbaVector;
|
|
19
|
-
/**
|
|
20
|
-
* These factors are used for undoing the `packDepthToRGBA` GLSL operation defined by ThreeJS.
|
|
21
|
-
* They are taken from https://github.com/WestLangley/three.js/blob/bc58fecba18150103b95fbde5aaa3cc7cddf95a7/src/renderers/shaders/ShaderChunk/packing.glsl.js#L19
|
|
22
|
-
*/
|
|
23
|
-
private readonly _unpackFactors;
|
|
24
13
|
private readonly _pipelineExecutor;
|
|
25
14
|
private readonly _depthRenderPipeline;
|
|
26
15
|
private readonly _treeIndexRenderPipeline;
|
|
27
16
|
private readonly _mutex;
|
|
28
|
-
|
|
17
|
+
private readonly _pickCache;
|
|
18
|
+
constructor(renderer: WebGLRenderer, materialManager: CadMaterialManager, sceneHandler: SceneHandler, pickCache?: CadPickCache);
|
|
19
|
+
/**
|
|
20
|
+
* Invalidates the cached full-frame pick buffer. Must be called whenever a new frame of the
|
|
21
|
+
* scene content that affects picking changes (sector loading, styling, clipping or model transforms).
|
|
22
|
+
*/
|
|
23
|
+
invalidatePickCache(): void;
|
|
24
|
+
dispose(): void;
|
|
29
25
|
intersectCadNodes(cadNodes: CadNode[], input: IntersectInput, shouldRunAsync?: boolean): Promise<IntersectCadNodesResult[]>;
|
|
30
26
|
private filterOutOfBoundCadNodes;
|
|
31
27
|
private intersectCadNodeDepth;
|
|
32
28
|
private intersectCadNodeTreeIndex;
|
|
33
29
|
private pickTreeIndex;
|
|
34
|
-
private perspectiveDepthToViewZ;
|
|
35
30
|
private pickDepth;
|
|
36
|
-
private getPosition;
|
|
37
31
|
private pickPixel;
|
|
38
|
-
private unpackRGBAToDepth;
|
|
39
32
|
}
|
|
40
|
-
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PerspectiveCamera, Vector3 } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a non-linear depth in [0, 1] at the given normalized device coordinates
|
|
4
|
+
* to a world space position and its distance from the camera.
|
|
5
|
+
*/
|
|
6
|
+
export declare function depthToIntersection(depth: number, camera: PerspectiveCamera, normalizedCoords: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}): {
|
|
10
|
+
distance: number;
|
|
11
|
+
point: Vector3;
|
|
12
|
+
};
|
|
@@ -3,6 +3,7 @@ import { SectorScene, CadModelMetadata, WantedSector, ConsumedSector, RootSector
|
|
|
3
3
|
import { SectorRepository } from '../../../sector-loader';
|
|
4
4
|
import { ParsedGeometry } from '../../../sector-parser';
|
|
5
5
|
import { CadMaterial } from '../../../rendering';
|
|
6
|
+
import { PickCacheInvalidator } from '../../../utilities';
|
|
6
7
|
import { Plane, Object3DEventMap, Group, Object3D, Matrix4 } from 'three';
|
|
7
8
|
import { TreeIndexToSectorsMap } from '../utilities/TreeIndexToSectorsMap';
|
|
8
9
|
export declare class CadNode extends Object3D<Object3DEventMap & {
|
|
@@ -21,12 +22,13 @@ export declare class CadNode extends Object3D<Object3DEventMap & {
|
|
|
21
22
|
private readonly _cadMaterial;
|
|
22
23
|
private _isDisposed;
|
|
23
24
|
private _needsRedraw;
|
|
25
|
+
private readonly _pickCacheInvalidator;
|
|
24
26
|
private readonly _meshManager;
|
|
25
27
|
readonly treeIndexToSectorsMap: TreeIndexToSectorsMap;
|
|
26
28
|
private readonly _lockedTreeIndices;
|
|
27
29
|
private readonly _lockedSectorIds;
|
|
28
30
|
readonly type = "CadNode";
|
|
29
|
-
constructor(model: CadModelMetadata, sectorRepository: SectorRepository);
|
|
31
|
+
constructor(model: CadModelMetadata, sectorRepository: SectorRepository, pickCacheInvalidator: PickCacheInvalidator);
|
|
30
32
|
get needsRedraw(): boolean;
|
|
31
33
|
resetRedraw(): void;
|
|
32
34
|
get cadMaterial(): CadMaterial;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DataTexture } from 'three';
|
|
2
|
-
import { IndexSet } from '../../utilities';
|
|
2
|
+
import { PickCacheInvalidator, IndexSet } from '../../utilities';
|
|
3
3
|
import { NodeAppearance } from './NodeAppearance';
|
|
4
4
|
import { NodeAppearanceProvider } from './NodeAppearanceProvider';
|
|
5
5
|
export declare class NodeAppearanceTextureBuilder {
|
|
6
6
|
private _defaultAppearance;
|
|
7
7
|
private readonly _styleProvider;
|
|
8
|
+
private readonly _pickCacheInvalidator;
|
|
8
9
|
private readonly _handleStylesChangedListener;
|
|
9
10
|
private _needsUpdate;
|
|
10
11
|
private readonly _allTreeIndices;
|
|
@@ -14,7 +15,7 @@ export declare class NodeAppearanceTextureBuilder {
|
|
|
14
15
|
private readonly _ghostedNodesTreeIndices;
|
|
15
16
|
private readonly _infrontNodesTreeIndices;
|
|
16
17
|
private readonly _visibleNodesTreeIndices;
|
|
17
|
-
constructor(treeIndexCount: number, styleProvider: NodeAppearanceProvider);
|
|
18
|
+
constructor(treeIndexCount: number, styleProvider: NodeAppearanceProvider, pickCacheInvalidator: PickCacheInvalidator);
|
|
18
19
|
getDefaultAppearance(): NodeAppearance;
|
|
19
20
|
/**
|
|
20
21
|
* Sets the default style and invalidates the builder. Note that this causes a full
|
|
@@ -44,6 +45,8 @@ export declare class NodeAppearanceTextureBuilder {
|
|
|
44
45
|
get overrideColorPerTreeIndexTexture(): DataTexture;
|
|
45
46
|
dispose(): void;
|
|
46
47
|
build(): void;
|
|
48
|
+
/** The sets that decide whether a node can be picked: hidden nodes are not visible, ghosted nodes are not drawn. */
|
|
49
|
+
private snapshotPickableSets;
|
|
47
50
|
private populateTexture;
|
|
48
51
|
private populateNodeSets;
|
|
49
52
|
private applyStyleToNodes;
|
|
@@ -4,6 +4,7 @@ import { Potree } from './potree-three-loader';
|
|
|
4
4
|
import { DMDataSourceType, DataSourceType, PointCloudStylableObjectProvider } from '../../data-providers';
|
|
5
5
|
import { IPointClassificationsProvider } from './classificationsProviders/IPointClassificationsProvider';
|
|
6
6
|
import { PointCloudMaterialManager } from '../../rendering';
|
|
7
|
+
import { PickCacheInvalidator } from '../../utilities';
|
|
7
8
|
import { ModelIdentifier } from '../../data-providers/src/ModelIdentifier';
|
|
8
9
|
export declare class PointCloudFactory {
|
|
9
10
|
private readonly _potreeInstance;
|
|
@@ -11,7 +12,8 @@ export declare class PointCloudFactory {
|
|
|
11
12
|
private readonly _pointCloudDMProvider;
|
|
12
13
|
private readonly _classificationsProvider;
|
|
13
14
|
private readonly _pointCloudMaterialManager;
|
|
14
|
-
|
|
15
|
+
private readonly _pickCacheInvalidator;
|
|
16
|
+
constructor(potreeInstance: Potree, pointCloudObjectProvider: PointCloudStylableObjectProvider, pointCloudDMProvider: PointCloudStylableObjectProvider<DMDataSourceType>, classificationsProvider: IPointClassificationsProvider, pointCloudMaterialManager: PointCloudMaterialManager, pickCacheInvalidator: PickCacheInvalidator);
|
|
15
17
|
dispose(): void;
|
|
16
18
|
createModel<T extends DataSourceType>(identifier: T['modelIdentifier'], modelIdentifier: ModelIdentifier, modelMetadata: PointCloudMetadata): Promise<PointCloudNode<T>>;
|
|
17
19
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PerspectiveCamera, Plane, Scene, WebGLRenderer, Mesh } from 'three';
|
|
2
|
+
import { PickCacheInvalidator } from '../../utilities';
|
|
2
3
|
import { LoadingState } from '../../model-base';
|
|
3
4
|
import { PointCloudFactory } from './PointCloudFactory';
|
|
4
5
|
import { PointCloudNode } from './PointCloudNode';
|
|
@@ -20,12 +21,18 @@ export declare class PointCloudManager {
|
|
|
20
21
|
private readonly _budgetSubject;
|
|
21
22
|
private readonly _renderer;
|
|
22
23
|
private _needsRedraw;
|
|
23
|
-
|
|
24
|
+
private readonly _pickCacheInvalidator;
|
|
25
|
+
constructor(metadataRepository: PointCloudMetadataRepository, materialManager: PointCloudMaterialManager, modelFactory: PointCloudFactory, potreeInstance: Potree, scene: Scene, renderer: WebGLRenderer, pickCacheInvalidator: PickCacheInvalidator);
|
|
24
26
|
requestRedraw(): void;
|
|
25
27
|
resetRedraw(): void;
|
|
26
28
|
get pointBudget(): number;
|
|
27
29
|
set pointBudget(points: number);
|
|
28
30
|
get needsRedraw(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Requests a pick cache invalidation if point buffers were loaded since the last drawn frame. Call
|
|
33
|
+
* before drawing, as drawing marks the loaded buffers as seen.
|
|
34
|
+
*/
|
|
35
|
+
requestPickCacheInvalidationOnUpdatedData(): void;
|
|
29
36
|
set clippingPlanes(planes: Plane[]);
|
|
30
37
|
getLoadingStateObserver(): Observable<LoadingState>;
|
|
31
38
|
updatePointClouds(camera: PerspectiveCamera): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CameraConfiguration } from '../../utilities';
|
|
1
|
+
import { CameraConfiguration, PickCacheInvalidator } from '../../utilities';
|
|
2
2
|
import { ClassificationInfo, PointCloudOctree, PickPoint } from './potree-three-loader';
|
|
3
3
|
import { WellKnownAsprsPointClassCodes } from './types';
|
|
4
4
|
import { PointSizeType, PointColorType, PointShape } from '../../rendering';
|
|
@@ -11,11 +11,13 @@ export declare class PointCloudNode<T extends DataSourceType = DataSourceType> e
|
|
|
11
11
|
private readonly _objectIdToAnnotationsMap;
|
|
12
12
|
private readonly _classificationHandler;
|
|
13
13
|
private _needsRedraw;
|
|
14
|
+
private _clippingPlanes;
|
|
15
|
+
private readonly _pickCacheInvalidator;
|
|
14
16
|
private static readonly pickingWindowSize;
|
|
15
17
|
private readonly _modelIdentifier;
|
|
16
18
|
private readonly _sourceTransform;
|
|
17
19
|
private readonly _customTransform;
|
|
18
|
-
constructor(modelIdentifier: symbol, sourceTransform: Matrix4, octree: PointCloudOctree, annotations: PointCloudObject<T>[], classificationInfo: ClassificationInfo, cameraConfiguration?: CameraConfiguration);
|
|
20
|
+
constructor(modelIdentifier: symbol, sourceTransform: Matrix4, octree: PointCloudOctree, annotations: PointCloudObject<T>[], classificationInfo: ClassificationInfo, pickCacheInvalidator: PickCacheInvalidator, cameraConfiguration?: CameraConfiguration);
|
|
19
21
|
get modelIdentifier(): symbol;
|
|
20
22
|
get octree(): PointCloudOctree;
|
|
21
23
|
get needsRedraw(): boolean;
|
|
@@ -3,18 +3,33 @@ import { IntersectInput } from '../../model-base';
|
|
|
3
3
|
import { PointCloudNode } from './PointCloudNode';
|
|
4
4
|
import { DataSourceType } from '../../data-providers';
|
|
5
5
|
import { IntersectPointCloudNodeResult } from './types';
|
|
6
|
+
import { EdlOptions } from '../../rendering';
|
|
6
7
|
export declare class PointCloudPickingHandler {
|
|
7
8
|
private readonly _normalized;
|
|
9
|
+
private readonly _drawingBufferSize;
|
|
8
10
|
private readonly _raycaster;
|
|
11
|
+
private readonly _renderer;
|
|
9
12
|
private readonly _picker;
|
|
13
|
+
private readonly _edlOptions;
|
|
10
14
|
private readonly _mutex;
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @param renderer Renderer used for the pick render.
|
|
17
|
+
* @param edlOptions EDL options the point clouds are rendered with, if any. EDL shades empty pixels
|
|
18
|
+
* within its radius of a point, closing small gaps on screen that the pick render (which has no EDL)
|
|
19
|
+
* still sees as empty, so the pick window is widened to cover that radius.
|
|
20
|
+
*/
|
|
21
|
+
constructor(renderer: WebGLRenderer, edlOptions?: EdlOptions);
|
|
13
22
|
dispose(): void;
|
|
14
23
|
/**
|
|
15
|
-
* Invalidates the picker's cached full-frame pick buffer.
|
|
16
|
-
*
|
|
24
|
+
* Invalidates the picker's cached full-frame pick buffer. Call it when scene content that can
|
|
25
|
+
* change what a pick hits has changed.
|
|
17
26
|
*/
|
|
18
27
|
invalidatePickCache(): void;
|
|
19
28
|
intersectPointClouds(nodes: PointCloudNode<DataSourceType>[], input: IntersectInput): Promise<IntersectPointCloudNodeResult<DataSourceType>[]>;
|
|
29
|
+
private getPickWindowSize;
|
|
20
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Pick window size in drawing buffer pixels. Odd, so the window is centered on the pick position.
|
|
33
|
+
* Wide enough to cover the EDL outline, which is drawn around points on screen but not in the pick render.
|
|
34
|
+
*/
|
|
35
|
+
export declare function computePickWindowSize(edlOptions: EdlOptions | undefined, drawingBufferHeight: number): number;
|
|
@@ -3,4 +3,5 @@ import { Scene, WebGLRenderer } from 'three';
|
|
|
3
3
|
import { DMDataSourceType, ModelMetadataProvider, PointCloudStylableObjectProvider, CachedModelDataProvider } from '../../data-providers';
|
|
4
4
|
import { IPointClassificationsProvider } from './classificationsProviders/IPointClassificationsProvider';
|
|
5
5
|
import { PointCloudMaterialManager } from '../../rendering';
|
|
6
|
-
|
|
6
|
+
import { PickCacheInvalidator } from '../../utilities';
|
|
7
|
+
export declare function createPointCloudManager(modelMetadataProvider: ModelMetadataProvider, pointCloudStylableObjectProvider: PointCloudStylableObjectProvider, classificationsProvider: IPointClassificationsProvider, pointCloudDMProvider: PointCloudStylableObjectProvider<DMDataSourceType>, pointCloudMaterialManager: PointCloudMaterialManager, cachedProvider: CachedModelDataProvider, scene: Scene, renderer: WebGLRenderer, pickCacheInvalidator: PickCacheInvalidator): PointCloudManager;
|
|
@@ -16,8 +16,8 @@ export declare class PointCloudOctreePicker {
|
|
|
16
16
|
constructor(renderer: WebGLRenderer);
|
|
17
17
|
dispose(): void;
|
|
18
18
|
/**
|
|
19
|
-
* Invalidates the cached full-frame pick buffer. Must be called whenever
|
|
20
|
-
*
|
|
19
|
+
* Invalidates the cached full-frame pick buffer. Must be called whenever the camera or scene content that
|
|
20
|
+
* affects picking changes (point cloud LOD, styling or clipping), as the cache does not compare the camera itself.
|
|
21
21
|
*/
|
|
22
22
|
invalidateCache(): void;
|
|
23
23
|
pick(camera: Camera, ray: Ray, octrees: PointCloudOctree[], params?: Partial<PickParams>): Promise<PickPoint | null>;
|