viral-viewer-2 7.2.3 → 7.2.4
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/components/custom-objects/viral-batched-mesh.d.ts +0 -12
- package/dist/components/custom-objects/viral-bim-world.d.ts +6 -0
- package/dist/components/custom-objects/viral-instanced-mesh-v2.d.ts +1 -20
- package/dist/components/post-processing/post-processing-renderer.d.ts +0 -41
- package/dist/components/post-processing/selection-outline-pass.d.ts +2 -0
- package/dist/components/visibility-manager/viral-visibility-manager.d.ts +8 -34
- package/dist/components/worker/merge-positions.worker.d.ts +19 -0
- package/dist/components/worker-script/merge-positions.script.d.ts +1 -0
- package/dist/index.mjs +856 -1071
- package/package.json +49 -49
- package/dist/components/post-processing/alpha-selection-outline-pass.d.ts +0 -49
- package/dist/components/post-processing/stencil-selection-outline-pass.d.ts +0 -54
|
@@ -2,11 +2,6 @@ import { Box3, BufferGeometry, type Color, type Material, Mesh, Vector3 } from "
|
|
|
2
2
|
import { type LineMaterial } from "three/examples/jsm/Addons";
|
|
3
3
|
import { type BufferElement } from "../..";
|
|
4
4
|
import type { WorkerThreadPool } from "../worker/base/worker-pool";
|
|
5
|
-
/**
|
|
6
|
-
* Special alpha value to mark selected vertices for fast outline detection.
|
|
7
|
-
* The AlphaSelectionOutlinePass detects this value with ZERO extra render passes.
|
|
8
|
-
*/
|
|
9
|
-
export declare const SELECTION_ALPHA = 0.99;
|
|
10
5
|
export declare class ViralBatchedMesh extends Mesh {
|
|
11
6
|
globalMaterialIndex: number;
|
|
12
7
|
private workerPool;
|
|
@@ -115,13 +110,6 @@ export declare class ViralBatchedMesh extends Mesh {
|
|
|
115
110
|
elementId: string;
|
|
116
111
|
}[];
|
|
117
112
|
unselect(): void;
|
|
118
|
-
/**
|
|
119
|
-
* Set alpha value for elements (used for selection marking)
|
|
120
|
-
* This is VERY fast - only updates alpha channel, no geometry copying
|
|
121
|
-
*
|
|
122
|
-
* When setting alpha to 1.0 (removing selection), respects hidden/isolated state
|
|
123
|
-
*/
|
|
124
|
-
private _setSelectionAlpha;
|
|
125
113
|
/**
|
|
126
114
|
* Hide elements by setting their alpha to 0 (GPU-accelerated)
|
|
127
115
|
* Hidden elements are discarded in fragment shader - no rendering cost
|
|
@@ -11,6 +11,7 @@ import { ViralInstancedMeshV2 } from "./viral-instanced-mesh-v2";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class ViralBIMWorld extends Mesh {
|
|
13
13
|
workerPool: WorkerThreadPool | null;
|
|
14
|
+
private _mergePositionsWorker;
|
|
14
15
|
bimModels: ViralBIMModel[];
|
|
15
16
|
constructor();
|
|
16
17
|
private _initializeWorkerPool;
|
|
@@ -98,6 +99,11 @@ export declare class ViralBIMWorld extends Mesh {
|
|
|
98
99
|
* @returns Float32Array of positions or null if no selection
|
|
99
100
|
*/
|
|
100
101
|
getSelectedElementsPositions(): Float32Array | null;
|
|
102
|
+
/**
|
|
103
|
+
* Async version — offloads vertex merging to a Web Worker so the main thread stays unblocked.
|
|
104
|
+
* Automatically cancels any in-flight request when called again.
|
|
105
|
+
*/
|
|
106
|
+
getSelectedElementsPositionsAsync(): Promise<Float32Array | null>;
|
|
101
107
|
/**
|
|
102
108
|
* Changes the color of multiple elements in the merged mesh.
|
|
103
109
|
* Works with RGBA color buffer (preserves existing alpha values)
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Box3, BufferGeometry, Color, InstancedMesh, type Material, Matrix4, Object3D, Vector3 } from "three";
|
|
2
2
|
import { type LineMaterial } from "three/examples/jsm/Addons";
|
|
3
3
|
import { type BufferElement } from "../..";
|
|
4
|
-
/**
|
|
5
|
-
* Special alpha value to mark selected instances for fast outline detection.
|
|
6
|
-
* Note: Instanced meshes use a separate instanceSelected attribute instead of alpha.
|
|
7
|
-
*/
|
|
8
|
-
export declare const SELECTION_ALPHA = 0.99;
|
|
9
4
|
export declare class ViralInstancedMeshV2 extends Object3D {
|
|
10
5
|
protected material?: Material | undefined;
|
|
11
6
|
globalMaterialIndex: number;
|
|
@@ -56,12 +51,6 @@ export declare class ViralInstancedMeshV2 extends Object3D {
|
|
|
56
51
|
};
|
|
57
52
|
}[]): void;
|
|
58
53
|
unselect(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Set instance selection state for fast outline detection
|
|
61
|
-
* @param elements - Elements to set selection for
|
|
62
|
-
* @param selected - 1.0 = selected, 0.0 = not selected
|
|
63
|
-
*/
|
|
64
|
-
private _setInstanceSelection;
|
|
65
54
|
/**
|
|
66
55
|
* Changes the color of multiple elements.
|
|
67
56
|
* @param elements - An array of elements, each containing `modelId` and `elementId`.
|
|
@@ -174,10 +163,7 @@ export declare class ViralInstancedMeshV2 extends Object3D {
|
|
|
174
163
|
*/
|
|
175
164
|
isElementVisible(modelId: string, elementId: string): boolean;
|
|
176
165
|
/**
|
|
177
|
-
* Inject per-instance opacity
|
|
178
|
-
* Enables:
|
|
179
|
-
* - Per-instance opacity (ghosting, hiding)
|
|
180
|
-
* - Selection alpha marker (for fast outline detection via AlphaSelectionOutlinePass)
|
|
166
|
+
* Inject per-instance opacity shader into material
|
|
181
167
|
* Must be called after material is set and before rendering
|
|
182
168
|
*/
|
|
183
169
|
injectOpacityShader(): void;
|
|
@@ -185,11 +171,6 @@ export declare class ViralInstancedMeshV2 extends Object3D {
|
|
|
185
171
|
* Ensure all instanced meshes have opacity attribute
|
|
186
172
|
*/
|
|
187
173
|
private _ensureOpacityAttributes;
|
|
188
|
-
/**
|
|
189
|
-
* Ensure all instanced meshes have selection attribute
|
|
190
|
-
* Used for fast outline detection via AlphaSelectionOutlinePass
|
|
191
|
-
*/
|
|
192
|
-
private _ensureSelectionAttributes;
|
|
193
174
|
/**
|
|
194
175
|
* Update opacity for specific instances
|
|
195
176
|
*/
|
|
@@ -6,7 +6,6 @@ import { ShaderPass } from "three/examples/jsm/postprocessing/ShaderPass";
|
|
|
6
6
|
import { SMAAPass } from "three/examples/jsm/postprocessing/SMAAPass";
|
|
7
7
|
import { type ViralViewerApi } from "../..";
|
|
8
8
|
import { DevicePerformanceChecker } from "../../utils/device";
|
|
9
|
-
import { AlphaSelectionOutlinePass } from "./alpha-selection-outline-pass";
|
|
10
9
|
import { type ScreenSpaceEdgesOptions, ScreenSpaceEdgesPass } from "./screen-space-edges-pass";
|
|
11
10
|
import { type SelectionOutlineOptions, SelectionOutlinePass } from "./selection-outline-pass";
|
|
12
11
|
export declare class PostProcessingRenderer {
|
|
@@ -27,7 +26,6 @@ export declare class PostProcessingRenderer {
|
|
|
27
26
|
outlinePass: OutlinePass | null;
|
|
28
27
|
screenSpaceEdgesPass: ScreenSpaceEdgesPass | null;
|
|
29
28
|
selectionOutlinePass: SelectionOutlinePass | null;
|
|
30
|
-
alphaSelectionOutlinePass: AlphaSelectionOutlinePass | null;
|
|
31
29
|
n8aoPass: any;
|
|
32
30
|
perfChecker: DevicePerformanceChecker;
|
|
33
31
|
constructor(renderer: WebGLRenderer, viralViewerApi: ViralViewerApi);
|
|
@@ -160,43 +158,4 @@ export declare class PostProcessingRenderer {
|
|
|
160
158
|
* Set selection outline thickness in pixels
|
|
161
159
|
*/
|
|
162
160
|
setSelectionOutlineThickness(thickness: number): void;
|
|
163
|
-
/**
|
|
164
|
-
* Initialize alpha-based selection outline pass
|
|
165
|
-
* ZERO extra render passes - detects selection via alpha channel in main render
|
|
166
|
-
* Cost: 1 fullscreen pass only (no geometry re-render)
|
|
167
|
-
*
|
|
168
|
-
* This is MUCH faster than SelectionOutlinePass for large selections
|
|
169
|
-
* Works with both batched meshes (per-vertex alpha) and instanced meshes (per-instance alpha)
|
|
170
|
-
*/
|
|
171
|
-
initAlphaSelectionOutlinePass(): void;
|
|
172
|
-
/**
|
|
173
|
-
* Enable alpha selection outline rendering
|
|
174
|
-
*/
|
|
175
|
-
enableAlphaSelectionOutline(): void;
|
|
176
|
-
/**
|
|
177
|
-
* Disable alpha selection outline rendering
|
|
178
|
-
*/
|
|
179
|
-
disableAlphaSelectionOutline(): void;
|
|
180
|
-
/**
|
|
181
|
-
* Bypass alpha selection outline (instant, zero cost)
|
|
182
|
-
*/
|
|
183
|
-
bypassAlphaSelectionOutline(): void;
|
|
184
|
-
/**
|
|
185
|
-
* Resume alpha selection outline after bypassing
|
|
186
|
-
*/
|
|
187
|
-
resumeAlphaSelectionOutline(): void;
|
|
188
|
-
/**
|
|
189
|
-
* Set alpha selection outline color
|
|
190
|
-
*/
|
|
191
|
-
setAlphaSelectionOutlineColor(color: Color | number | string): void;
|
|
192
|
-
/**
|
|
193
|
-
* Set alpha selection outline thickness in pixels
|
|
194
|
-
*/
|
|
195
|
-
setAlphaSelectionOutlineThickness(thickness: number): void;
|
|
196
|
-
/**
|
|
197
|
-
* Update alpha selection outline state
|
|
198
|
-
* Call this when selection changes
|
|
199
|
-
* @param hasSelection - Whether there's any selection active
|
|
200
|
-
*/
|
|
201
|
-
updateAlphaSelectionOutline(hasSelection: boolean): void;
|
|
202
161
|
}
|
|
@@ -5,6 +5,8 @@ export declare class ViralVisibilityManager {
|
|
|
5
5
|
private viralViewerApi;
|
|
6
6
|
/** Whether selection outline is enabled (default: true) */
|
|
7
7
|
private _selectionOutlineEnabled;
|
|
8
|
+
/** Whether an outline update is already scheduled for the next frame */
|
|
9
|
+
private _outlineUpdateScheduled;
|
|
8
10
|
constructor(viralViewerApi: ViralViewerApi);
|
|
9
11
|
/**
|
|
10
12
|
* show all elements and reset back to normal visualization
|
|
@@ -167,6 +169,12 @@ export declare class ViralVisibilityManager {
|
|
|
167
169
|
* Uses merged geometry for efficient rendering
|
|
168
170
|
*/
|
|
169
171
|
updateSelectionOutline(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Schedule outline update for the next animation frame.
|
|
174
|
+
* Batches multiple rapid selection changes into a single update.
|
|
175
|
+
* Uses Web Worker to avoid blocking the main thread.
|
|
176
|
+
*/
|
|
177
|
+
private scheduleOutlineUpdate;
|
|
170
178
|
/**
|
|
171
179
|
* Enable selection outline effect
|
|
172
180
|
*/
|
|
@@ -184,40 +192,6 @@ export declare class ViralVisibilityManager {
|
|
|
184
192
|
* Get whether selection outline mode is enabled
|
|
185
193
|
*/
|
|
186
194
|
get selectionOutlineEnabled(): boolean;
|
|
187
|
-
/** Whether alpha selection outline is enabled (default: false, as it requires opt-in) */
|
|
188
|
-
private _alphaSelectionOutlineEnabled;
|
|
189
|
-
/**
|
|
190
|
-
* Update alpha selection outline state
|
|
191
|
-
* This is MUCH faster than updateSelectionOutline() - no geometry copying needed
|
|
192
|
-
*/
|
|
193
|
-
updateAlphaSelectionOutline(): void;
|
|
194
|
-
/**
|
|
195
|
-
* Enable alpha selection outline effect
|
|
196
|
-
* This is the FAST outline mode - constant cost regardless of selection size
|
|
197
|
-
*/
|
|
198
|
-
enableAlphaSelectionOutline(): void;
|
|
199
|
-
/**
|
|
200
|
-
* Disable alpha selection outline effect
|
|
201
|
-
*/
|
|
202
|
-
disableAlphaSelectionOutline(): void;
|
|
203
|
-
/**
|
|
204
|
-
* Set whether alpha selection outline mode is enabled
|
|
205
|
-
* This is the recommended mode for large selections (1000+ elements)
|
|
206
|
-
* @param enabled - true to enable, false to disable
|
|
207
|
-
*/
|
|
208
|
-
setAlphaSelectionOutlineMode(enabled: boolean): void;
|
|
209
|
-
/**
|
|
210
|
-
* Get whether alpha selection outline mode is enabled
|
|
211
|
-
*/
|
|
212
|
-
get alphaSelectionOutlineEnabled(): boolean;
|
|
213
|
-
/**
|
|
214
|
-
* Bypass alpha selection outline (fast, for camera movement)
|
|
215
|
-
*/
|
|
216
|
-
bypassAlphaSelectionOutline(): void;
|
|
217
|
-
/**
|
|
218
|
-
* Resume alpha selection outline after bypass
|
|
219
|
-
*/
|
|
220
|
-
resumeAlphaSelectionOutline(): void;
|
|
221
195
|
enableNight(): void;
|
|
222
196
|
disableNight(): void;
|
|
223
197
|
enableSectionBox(): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class MergePositionsWorker {
|
|
2
|
+
private _worker;
|
|
3
|
+
private _resolve;
|
|
4
|
+
private _requestId;
|
|
5
|
+
constructor();
|
|
6
|
+
/**
|
|
7
|
+
* Merge selected element positions in a background thread.
|
|
8
|
+
* Cancels any in-flight request automatically.
|
|
9
|
+
*/
|
|
10
|
+
merge(bufferElements: {
|
|
11
|
+
buffer: Float32Array | null;
|
|
12
|
+
modelId: number;
|
|
13
|
+
instances: {
|
|
14
|
+
elementId: string;
|
|
15
|
+
transform: number[];
|
|
16
|
+
}[];
|
|
17
|
+
}[], selectedKeys: string[]): Promise<Float32Array | null>;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const workerCode: any;
|