viral-viewer-2 6.9.0 → 6.9.2

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,6 +119,7 @@ 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;
123
124
  findElementByFaceIndex(faceIndex: number): {
124
125
  modelId: string;
@@ -184,6 +185,51 @@ export declare class ViralBatchedMesh extends Mesh {
184
185
  }[]): Box3 | null;
185
186
  getTotalVertexCount(): number;
186
187
  getObjectCount(): number;
188
+ /**
189
+ * Create simplified LOD versions of this batched mesh
190
+ * All LOD meshes maintain full element mapping functionality (hide, isolate, changeColor)
191
+ *
192
+ * @param lodLevels - Array of simplification options for each LOD level
193
+ * @returns Promise resolving to array of meshes [original, LOD1, LOD2, ...]
194
+ *
195
+ * @example
196
+ * ```typescript
197
+ * const lodMeshes = await originalMesh.createSimplifiedLODs([
198
+ * { ratio: 0.7, error: 0.01 }, // LOD1: 70% detail
199
+ * { ratio: 0.4, error: 0.02 }, // LOD2: 40% detail
200
+ * { ratio: 0.2, error: 0.05 }, // LOD3: 20% detail
201
+ * ]);
202
+ *
203
+ * // All LODs support full operations
204
+ * lodMeshes.forEach(mesh => mesh.hide(elements)); // Works on all!
205
+ * ```
206
+ */
207
+ createSimplifiedLODs(lodLevels: Array<{
208
+ ratio?: number;
209
+ error?: number;
210
+ lockBorder?: boolean;
211
+ optimizeMemory?: boolean;
212
+ }>): Promise<ViralBatchedMesh[]>;
213
+ /**
214
+ * FAST: Create simplified LOD by simplifying entire geometry at once
215
+ * ⚠️ This breaks element mapping - hide/isolate/changeColor won't work on simplified mesh
216
+ * Use this when you only need visual LOD without element operations
217
+ *
218
+ * @param options - Simplification options
219
+ * @returns Promise resolving to simplified mesh
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const lodMesh = await originalMesh.createSimplifiedLODFast({ ratio: 0.5 });
224
+ * // 10x-100x faster than createSimplifiedLODs but no element operations
225
+ * ```
226
+ */
227
+ createSimplifiedLODFast(options: {
228
+ ratio?: number;
229
+ error?: number;
230
+ lockBorder?: boolean;
231
+ optimizeMemory?: boolean;
232
+ }): Promise<ViralBatchedMesh>;
187
233
  /**
188
234
  * ! Disposes of the ViralBatchedMesh properly, when dispose we dont need to dispose material
189
235
  */
@@ -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, {
@@ -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
@@ -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.
@@ -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,24 @@ 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;
120
140
  }
@@ -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
@@ -25,10 +28,6 @@ export declare class LoadElementPatchWorker {
25
28
  * Traditional load implementation (renamed for clarity)
26
29
  */
27
30
  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
31
  private computeBatchLimits;
33
32
  /** Split elements to chunks that satisfy both vertex and object limits. */
34
33
  private splitByLimits;
@@ -45,6 +44,18 @@ export declare class LoadElementPatchWorker {
45
44
  * Throttled render to avoid excessive render calls
46
45
  */
47
46
  private throttledRender;
47
+ /**
48
+ * 🚀 Add elements to buffer and batch when threshold is reached
49
+ */
50
+ private addToBuffer;
51
+ /**
52
+ * 🚀 Flush accumulated elements for a specific material
53
+ */
54
+ private flushBuffer;
55
+ /**
56
+ * 🚀 Flush all remaining buffers (call this when loading is complete)
57
+ */
58
+ flushAllBuffers(): void;
48
59
  /**
49
60
  * Get spatial mesh manager (delegate to scene)
50
61
  */
@@ -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;