viral-viewer-2 6.9.1 → 6.9.3

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.
@@ -119,7 +119,42 @@ export declare class ViralBatchedMesh extends Mesh {
119
119
  * reset visibility also color
120
120
  */
121
121
  reset(): void;
122
+ optimizeVertices(): void;
122
123
  updateVisibility(bufferElements: BufferElement[]): void;
124
+ private _hiddenSet;
125
+ private _isolatedSet;
126
+ private _originalColorSize;
127
+ /**
128
+ * 🚀 ULTRA FAST: Hide elements by setting alpha to 0
129
+ * Preserves raycasting - hidden elements can still be clicked
130
+ */
131
+ hideFast(elements?: {
132
+ modelId: string;
133
+ elementId: string;
134
+ }[]): void;
135
+ /**
136
+ * 🚀 ULTRA FAST: Isolate elements by setting non-isolated alpha to 0
137
+ */
138
+ isolateFast(elements?: {
139
+ modelId: string;
140
+ elementId: string;
141
+ }[]): {
142
+ modelId: string;
143
+ elementId: string;
144
+ }[];
145
+ /**
146
+ * 🚀 INTERNAL: Update visibility by modifying alpha channel
147
+ * Sets alpha to 0.001 (nearly invisible) + alphaTest to skip rendering
148
+ */
149
+ private _updateVisibilityByAlpha;
150
+ /**
151
+ * Check if an element is currently visible
152
+ */
153
+ isElementVisible(modelId: string, elementId: string): boolean;
154
+ /**
155
+ * 🚀 ULTRA FAST: Reset visibility - restore everything to normal
156
+ */
157
+ resetFast(): void;
123
158
  findElementByFaceIndex(faceIndex: number): {
124
159
  modelId: string;
125
160
  elementId: string;
@@ -184,6 +219,51 @@ export declare class ViralBatchedMesh extends Mesh {
184
219
  }[]): Box3 | null;
185
220
  getTotalVertexCount(): number;
186
221
  getObjectCount(): number;
222
+ /**
223
+ * Create simplified LOD versions of this batched mesh
224
+ * All LOD meshes maintain full element mapping functionality (hide, isolate, changeColor)
225
+ *
226
+ * @param lodLevels - Array of simplification options for each LOD level
227
+ * @returns Promise resolving to array of meshes [original, LOD1, LOD2, ...]
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const lodMeshes = await originalMesh.createSimplifiedLODs([
232
+ * { ratio: 0.7, error: 0.01 }, // LOD1: 70% detail
233
+ * { ratio: 0.4, error: 0.02 }, // LOD2: 40% detail
234
+ * { ratio: 0.2, error: 0.05 }, // LOD3: 20% detail
235
+ * ]);
236
+ *
237
+ * // All LODs support full operations
238
+ * lodMeshes.forEach(mesh => mesh.hide(elements)); // Works on all!
239
+ * ```
240
+ */
241
+ createSimplifiedLODs(lodLevels: Array<{
242
+ ratio?: number;
243
+ error?: number;
244
+ lockBorder?: boolean;
245
+ optimizeMemory?: boolean;
246
+ }>): Promise<ViralBatchedMesh[]>;
247
+ /**
248
+ * FAST: Create simplified LOD by simplifying entire geometry at once
249
+ * ⚠️ This breaks element mapping - hide/isolate/changeColor won't work on simplified mesh
250
+ * Use this when you only need visual LOD without element operations
251
+ *
252
+ * @param options - Simplification options
253
+ * @returns Promise resolving to simplified mesh
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * const lodMesh = await originalMesh.createSimplifiedLODFast({ ratio: 0.5 });
258
+ * // 10x-100x faster than createSimplifiedLODs but no element operations
259
+ * ```
260
+ */
261
+ createSimplifiedLODFast(options: {
262
+ ratio?: number;
263
+ error?: number;
264
+ lockBorder?: boolean;
265
+ optimizeMemory?: boolean;
266
+ }): Promise<ViralBatchedMesh>;
187
267
  /**
188
268
  * ! Disposes of the ViralBatchedMesh properly, when dispose we dont need to dispose material
189
269
  */
@@ -5,7 +5,7 @@ export declare class ViralInstancedMeshV2 extends Object3D {
5
5
  protected material?: Material | undefined;
6
6
  globalMaterialIndex: number;
7
7
  constructor(material?: Material | undefined);
8
- protected _instancedMeshes: Map<string, InstancedMesh<BufferGeometry<import("three").NormalBufferAttributes>, Material | Material[], import("three").InstancedMeshEventMap>>;
8
+ protected _instancedMeshes: Map<string, InstancedMesh<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, Material | Material[], import("three").InstancedMeshEventMap>>;
9
9
  _bufferElements: BufferElement[];
10
10
  protected _originalColor: Color | null;
11
11
  protected _elementMap: Map<string, Map<string, {
@@ -70,6 +70,9 @@ export declare class ViralInstancedMeshV2 extends Object3D {
70
70
  modelId: string;
71
71
  elementId: string;
72
72
  }[];
73
+ private _hiddenSet;
74
+ private _isolatedSet;
75
+ private _originalColorSize;
73
76
  hide(elements?: {
74
77
  modelId: string;
75
78
  elementId: string;
@@ -81,6 +84,32 @@ export declare class ViralInstancedMeshV2 extends Object3D {
81
84
  modelId: string;
82
85
  elementId: string;
83
86
  }[];
87
+ /**
88
+ * 🚀 FAST: Hide instances by setting alpha to 0
89
+ * Preserves raycasting - hidden instances can still be clicked
90
+ */
91
+ hideFast(elements?: {
92
+ modelId: string;
93
+ elementId: string;
94
+ }[]): void;
95
+ /**
96
+ * 🚀 FAST: Isolate instances by setting non-isolated alpha to 0
97
+ */
98
+ isolateFast(elements?: {
99
+ modelId: string;
100
+ elementId: string;
101
+ }[]): {
102
+ modelId: string;
103
+ elementId: string;
104
+ }[];
105
+ /**
106
+ * 🚀 INTERNAL: Update instance visibility by modifying instance colors alpha
107
+ */
108
+ private _updateInstanceVisibilityByAlpha;
109
+ /**
110
+ * 🚀 FAST: Reset visibility - restore everything to normal
111
+ */
112
+ resetFast(): void;
84
113
  isolateModel(modelIds: string[]): void;
85
114
  reset(): void;
86
115
  private showAllInstances;
@@ -22,6 +22,18 @@ export declare class ViralMergedModel extends Mesh {
22
22
  addBatchedMesh(mesh: ViralBatchedMesh): void;
23
23
  getBatchedMesh(globalMaterialIndex: number): ViralBatchedMesh | undefined;
24
24
  getBatchedMeshes(): ViralBatchedMesh[];
25
+ /**
26
+ * Get diagnostic info about merged model structure
27
+ */
28
+ getDiagnostics(): {
29
+ totalChildren: number;
30
+ edgeMeshes: number;
31
+ batchedMeshesInChildren: number;
32
+ batchedMeshesInArray: number;
33
+ instancedMeshes: number;
34
+ totalVertices: number;
35
+ childrenTypes: string[];
36
+ };
25
37
  protected _instancedMeshes: ViralInstancedMeshV2[];
26
38
  addInstancedMesh(mesh: ViralInstancedMeshV2): void;
27
39
  getInstancedMesh(globalMaterialIndex: number): ViralInstancedMeshV2 | undefined;
@@ -127,6 +139,7 @@ export declare class ViralMergedModel extends Mesh {
127
139
  * Notify edge mesh when meshes are updated (call this after batching or rebuilding)
128
140
  */
129
141
  onMeshUpdated(mesh?: ViralBatchedMesh | ViralInstancedMeshV2): void;
142
+ optimizeVertices(): void;
130
143
  /**
131
144
  * *everytime add new model in scene this model will be regenerated again, for that reason we should dispose this model
132
145
  * *then regenerate again
@@ -1,13 +1,15 @@
1
- import { CheckClashResult, CompareModelsResult, DataTree, GroupByResult, ViralViewerApi } from "../..";
1
+ import { CheckClashResult, CompareModelsResult, DataTree, GroupByResult, ViralutionTrackingModel, ViralViewerApi } from "../..";
2
2
  export declare class ViralDataManager {
3
3
  viralViewerApi: ViralViewerApi;
4
4
  dataTree: DataTree[];
5
+ trackingData: Map<number, ViralutionTrackingModel>;
5
6
  private fetchDataWorker;
6
7
  private buildTreeNodeWorker;
7
8
  private _boundingBoxWorker;
8
9
  private _boundingBoxIntersectWorker;
9
10
  private _checkClashWorker;
10
11
  constructor(viralViewerApi: ViralViewerApi);
12
+ addTrackingData(modelId: number, data: ViralutionTrackingModel): void;
11
13
  normalFetch(url: string, byteRangeStart?: number, byteRangeEnd?: number): Promise<Response>;
12
14
  gzipFetch(url: string): Promise<Response>;
13
15
  /**
@@ -23,6 +23,7 @@ export declare class ViralCentralizedEventHandler {
23
23
  selectElementHandler(): void;
24
24
  enableSelectElement(value: boolean): void;
25
25
  selectElementHandler2(): void;
26
+ doubleClickElementHandler(): void;
26
27
  isShiftPressed: boolean;
27
28
  keyboardHandler(): void;
28
29
  }
@@ -1,4 +1,4 @@
1
- import { RevitTransform, ViralPoint, ViralViewerRevitProject, ViralutionElement, ViralutionFragmentModel } from "../../types";
1
+ import { RevitTransform, ViralPoint, ViralViewerRevitProject, ViralutionElement, ViralutionFragmentModel, ViralutionTrackingModel } from "../../types";
2
2
  import { ViralViewerApi } from "../../viral-viewer-api";
3
3
  export declare class ViralRevitLoader {
4
4
  viralViewerApi: ViralViewerApi;
@@ -6,7 +6,7 @@ export declare class ViralRevitLoader {
6
6
  private _loadElementStandaloneWorker;
7
7
  private _loadElementByMaterialWorker;
8
8
  private _loadElementByMaterialV2Worker;
9
- private _loadElementPatchWorker;
9
+ private _loadElementBatchWorker;
10
10
  constructor(viralViewerApi: ViralViewerApi);
11
11
  /**
12
12
  * @deprecated This function is deprecated. Use the loadRevit2 instead.
@@ -22,6 +22,12 @@ export declare class ViralRevitLoader {
22
22
  loadFlatBufferStandalone(informationUrl: string, geometriesUrl: string, callbackOnFinish?: () => void): Promise<void>;
23
23
  getMaterials(dataUrl: string, byteRangeStart: number, byteRangeEnd: number): Promise<any>;
24
24
  getElements(dataUrl: string, chunk: number[][], callbackOnSuccess?: (model: any, index: number) => void): Promise<void>;
25
+ focusCameraOnModel(trackingModel: ViralutionTrackingModel): Promise<void>;
26
+ getTranslation(translation: number[]): {
27
+ x: number;
28
+ y: number;
29
+ z: number;
30
+ } | null;
25
31
  loadByMaterial(trackingUrl: string, dataUrl: string, informationUrl: string): Promise<void>;
26
32
  /**
27
33
  * dispose all current model
@@ -4,7 +4,7 @@ import { PostProcessingRenderer } from "../post-processing/post-processing-rende
4
4
  export declare class ViralRenderer {
5
5
  viralViewerApi: ViralViewerApi;
6
6
  renderer: WebGLRenderer;
7
- postProcessingRenderer: PostProcessingRenderer;
7
+ postProcessingRenderer?: PostProcessingRenderer;
8
8
  private _t;
9
9
  private _lastSpatialStatsTime;
10
10
  constructor(viralViewerApi: ViralViewerApi);
@@ -105,7 +105,7 @@ export declare class ViralVisibilityManager {
105
105
  private _fog;
106
106
  enableFog(): void;
107
107
  disableFog(): void;
108
- rainGeometry: BufferGeometry<import("three").NormalBufferAttributes>;
108
+ rainGeometry: BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>;
109
109
  rain: Points | null;
110
110
  private _isGeneratedRain;
111
111
  enableRain(): void;
@@ -117,4 +117,28 @@ export declare class ViralVisibilityManager {
117
117
  enableSampling(numberOfSampling?: number): void;
118
118
  disableSampling(): void;
119
119
  generateLOD(): void;
120
+ private _batchColors;
121
+ private _originalBatchMaterials;
122
+ private _batchVisualizationEnabled;
123
+ /**
124
+ * Generate a random but distinct color for each material ID
125
+ */
126
+ private _generateDistinctColor;
127
+ /**
128
+ * Show batches with distinct colors based on their globalMaterialId
129
+ * Each batch with the same globalMaterialId will have the same random color
130
+ */
131
+ showBatches(): void;
132
+ /**
133
+ * Hide batches and restore original materials
134
+ */
135
+ hideBatches(): void;
136
+ /**
137
+ * Check if batch visualization is currently enabled
138
+ */
139
+ isBatchVisualizationEnabled(): boolean;
140
+ showHidePercentage: number;
141
+ showHideByPercentage(value?: number): void;
142
+ randomColor: number;
143
+ changeRandomColor(value?: number): void;
120
144
  }
@@ -3,12 +3,15 @@ import { RenderMaterial, ViralutionElement } from "../../types";
3
3
  import { Box3, Vector3 } from "three";
4
4
  import { WorkerThreadPool } from "./base/worker-pool";
5
5
  import { ViralSpatialMeshManager } from "../custom-objects/viral-spatial-mesh-manager";
6
- export declare class LoadElementPatchWorker {
6
+ export declare class LoadElementBatchWorker {
7
7
  viralViewerApi: ViralViewerApi;
8
8
  workerPool: WorkerThreadPool;
9
9
  workerPool2: WorkerThreadPool;
10
10
  private lastRenderTime;
11
11
  private useSpatialMerging;
12
+ private elementBuffer;
13
+ private readonly BATCH_THRESHOLD_VERTICES;
14
+ private readonly BATCH_THRESHOLD_OBJECTS;
12
15
  constructor(viralViewerApi: ViralViewerApi);
13
16
  /**
14
17
  * Initialize model with materials
@@ -19,16 +22,16 @@ export declare class LoadElementPatchWorker {
19
22
  /**
20
23
  * Main load method - automatically routes to spatial or traditional approach
21
24
  */
22
- loadElement(modelId: number, elements: ViralutionElement[], callbackOnSuccess?: () => void): void;
25
+ loadElement(modelId: number, elements: ViralutionElement[], callbackOnSuccess?: () => void, globalTranslation?: {
26
+ x: number;
27
+ y: number;
28
+ z: number;
29
+ } | null): void;
23
30
  private loadInstancedElement;
24
31
  /**
25
32
  * Traditional load implementation (renamed for clarity)
26
33
  */
27
34
  private loadBatchedElement;
28
- /** How many vec4 slots your per-object data needs (mat4 -> 4, id/color -> 1, none -> 0). */
29
- private get perObjectUniformVec4();
30
- /** Reserve some vec4 slots for built-ins (MVP, lights, fog, etc.). Tweak if you use heavy materials. */
31
- private get reservedUniformVec4();
32
35
  private computeBatchLimits;
33
36
  /** Split elements to chunks that satisfy both vertex and object limits. */
34
37
  private splitByLimits;
@@ -45,6 +48,18 @@ export declare class LoadElementPatchWorker {
45
48
  * Throttled render to avoid excessive render calls
46
49
  */
47
50
  private throttledRender;
51
+ /**
52
+ * 🚀 Add elements to buffer and batch when threshold is reached
53
+ */
54
+ private addToBuffer;
55
+ /**
56
+ * 🚀 Flush accumulated elements for a specific material
57
+ */
58
+ private flushBuffer;
59
+ /**
60
+ * 🚀 Flush all remaining buffers (call this when loading is complete)
61
+ */
62
+ flushAllBuffers(): void;
48
63
  /**
49
64
  * Get spatial mesh manager (delegate to scene)
50
65
  */
@@ -0,0 +1,20 @@
1
+ import { ViralViewerApi } from "../../viral-viewer-api";
2
+ export declare class ViralBatchDebugPanel {
3
+ viralViewerApi: ViralViewerApi;
4
+ private panel;
5
+ private batchListContainer;
6
+ private isVisible;
7
+ private selectedBatchMesh;
8
+ constructor(viralViewerApi: ViralViewerApi);
9
+ private inject;
10
+ private createButton;
11
+ private injectStyles;
12
+ private attachEventListeners;
13
+ show(): void;
14
+ hide(): void;
15
+ toggle(): void;
16
+ private refreshBatchList;
17
+ private isolateBatch;
18
+ private clearIsolation;
19
+ dispose(): void;
20
+ }
@@ -7,7 +7,7 @@ interface ViralMeasure {
7
7
  }
8
8
  export declare class ViralToolMeasure {
9
9
  viralTools: ViralTools;
10
- viralToolMeasureScene: Scene;
10
+ viralToolMeasureScene: Scene<import("three").Object3DEventMap>;
11
11
  isActivated: boolean;
12
12
  measures: ViralMeasure[];
13
13
  private point1;