viral-viewer-2 6.8.2 → 6.8.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.
- package/dist/components/animation/viral-animation.d.ts +36 -0
- package/dist/components/camera/viral-camera.d.ts +17 -1
- package/dist/components/custom-objects/viral-main.model.d.ts +3 -0
- package/dist/components/custom-objects/viral-merged-edge.d.ts +32 -0
- package/dist/components/custom-objects/viral-merged-mesh.d.ts +26 -2
- package/dist/components/custom-objects/viral-merged-model.d.ts +12 -1
- package/dist/components/custom-objects/viral-spatial-merged-mesh.d.ts +7 -0
- package/dist/components/custom-objects/viral-spatial-mesh-manager.d.ts +70 -0
- package/dist/components/event-handler/viral-centralized-event-handler.d.ts +1 -0
- package/dist/components/loader/viral-revit.loader.d.ts +1 -0
- package/dist/components/renderer/viral-renderer.d.ts +46 -1
- package/dist/components/scene/viral-scene.d.ts +41 -1
- package/dist/components/worker/load-element-patch.worker.d.ts +84 -1
- package/dist/gui/pivot-point/viral-pivot-point.d.ts +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +13555 -10981
- package/dist/models/flat-buffer/model-management-camera-model.d.ts +24 -0
- package/dist/models/flat-buffer/parameter-dictionary.d.ts +20 -0
- package/dist/models/flat-buffer/point.d.ts +11 -0
- package/dist/models/flat-buffer/render-material.d.ts +26 -0
- package/dist/models/flat-buffer/revit-transform.d.ts +22 -0
- package/dist/models/flat-buffer/viralution-box.d.ts +11 -0
- package/dist/models/flat-buffer/viralution-element.d.ts +27 -0
- package/dist/models/{flatbuffers → flat-buffer}/viralution-information.d.ts +2 -2
- package/dist/models/flat-buffer/viralution-parameter.d.ts +35 -0
- package/dist/models/flat-buffer/viralution-solid.d.ts +28 -0
- package/dist/models/flat-buffer/viralution-standalone-model.d.ts +27 -0
- package/dist/models/index.d.ts +8 -3
- package/dist/serializers/index.d.ts +2 -0
- package/dist/serializers/viralution-flatbuffer.serializer.d.ts +86 -0
- package/dist/serializers/viralution-standalone.serializer.d.ts +14 -0
- package/dist/types.d.ts +5 -0
- package/dist/viral-viewer-api.d.ts +2 -0
- package/package.json +1 -1
- package/dist/models/flatbuffers/inner-dictionary.d.ts +0 -20
- package/dist/models/flatbuffers/key-value.d.ts +0 -17
|
@@ -3,10 +3,46 @@ import { ViralViewerApi } from "../../viral-viewer-api";
|
|
|
3
3
|
export declare class ViralAnimation {
|
|
4
4
|
viralViewerApi: ViralViewerApi;
|
|
5
5
|
clock: Clock;
|
|
6
|
+
private lastSpatialUpdateTime;
|
|
7
|
+
private lastCleanupTime;
|
|
8
|
+
private spatialUpdateInterval;
|
|
9
|
+
private cleanupInterval;
|
|
6
10
|
constructor(viralViewerApi: ViralViewerApi);
|
|
7
11
|
devAnimation(): void;
|
|
8
12
|
animation(): void;
|
|
9
13
|
rainAnimation(): void;
|
|
10
14
|
private isRainEnabled;
|
|
11
15
|
toggleRain(value: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* Update spatial visibility based on current camera position
|
|
18
|
+
*/
|
|
19
|
+
private updateSpatialVisibility;
|
|
20
|
+
/**
|
|
21
|
+
* Cleanup distant spatial meshes to free memory
|
|
22
|
+
*/
|
|
23
|
+
private cleanupDistantSpatialMeshes;
|
|
24
|
+
/**
|
|
25
|
+
* Get spatial mesh statistics for debugging
|
|
26
|
+
*/
|
|
27
|
+
getSpatialStats(): {
|
|
28
|
+
totalCells: number;
|
|
29
|
+
loadedCells: number;
|
|
30
|
+
visibleCells: number;
|
|
31
|
+
} | null;
|
|
32
|
+
/**
|
|
33
|
+
* Log spatial mesh statistics to console (for debugging)
|
|
34
|
+
*/
|
|
35
|
+
logSpatialStats(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Set spatial update frequency (for performance tuning)
|
|
38
|
+
*/
|
|
39
|
+
setSpatialUpdateFrequency(fps: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Set cleanup frequency (for memory management tuning)
|
|
42
|
+
*/
|
|
43
|
+
setCleanupFrequency(seconds: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Toggle debug mode for spatial meshes
|
|
46
|
+
*/
|
|
47
|
+
toggleSpatialDebug(enabled: boolean): void;
|
|
12
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import CameraControls from "camera-controls";
|
|
2
2
|
import { ViralCameraEventType, ViralViewerState } from "../../types";
|
|
3
3
|
import { ViralViewerApi } from "../../viral-viewer-api";
|
|
4
|
-
import { Vector3, Raycaster, PerspectiveCamera, Object3D, OrthographicCamera } from "three";
|
|
4
|
+
import { Vector3, Box3, Raycaster, PerspectiveCamera, Object3D, OrthographicCamera } from "three";
|
|
5
5
|
export declare class ViralCamera {
|
|
6
6
|
viralViewerApi: ViralViewerApi;
|
|
7
7
|
raycaster: Raycaster;
|
|
@@ -52,4 +52,20 @@ export declare class ViralCamera {
|
|
|
52
52
|
addEventListener(type: ViralCameraEventType, key: string, resolve: () => void): void;
|
|
53
53
|
removeEventListener(type: ViralCameraEventType, key: string): void;
|
|
54
54
|
getAllEventListener(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Calculate optimal spatial grid size based on camera far plane
|
|
57
|
+
*/
|
|
58
|
+
getOptimalSpatialGridSize(worldBounds: Box3): Vector3;
|
|
59
|
+
taa: {
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
samples: number;
|
|
62
|
+
index: number;
|
|
63
|
+
offsets: [number, number][];
|
|
64
|
+
};
|
|
65
|
+
private halton;
|
|
66
|
+
private buildJitterOffsets;
|
|
67
|
+
enableTAA(samples?: number): void;
|
|
68
|
+
disableTAA(): void;
|
|
69
|
+
applyJitter(): void;
|
|
70
|
+
clearJitter(): void;
|
|
55
71
|
}
|
|
@@ -8,6 +8,9 @@ export declare class ViralMainModel {
|
|
|
8
8
|
elements: ViralutionElement[];
|
|
9
9
|
materials: RenderMaterial[];
|
|
10
10
|
mapMaterialsToMaterialManager: Dictionary<number, number>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated don't use this anymore
|
|
13
|
+
*/
|
|
11
14
|
seperateModel: ViralSeperateModel;
|
|
12
15
|
dispose(): void;
|
|
13
16
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LineSegments2 } from "three/examples/jsm/lines/LineSegments2.js";
|
|
2
|
+
type ElemKey = {
|
|
3
|
+
modelId: string;
|
|
4
|
+
elementId: string;
|
|
5
|
+
};
|
|
6
|
+
type BufferElement = {
|
|
7
|
+
buffer: Float32Array | null;
|
|
8
|
+
elementId: string;
|
|
9
|
+
modelId: number;
|
|
10
|
+
};
|
|
11
|
+
export declare class ViralMergedEdges extends LineSegments2 {
|
|
12
|
+
globalMaterialIndex: number;
|
|
13
|
+
private _positions;
|
|
14
|
+
private _elementMap;
|
|
15
|
+
private _totalSegments;
|
|
16
|
+
constructor(color?: number, linewidth?: number);
|
|
17
|
+
/** Phải gọi khi resize để line dày đúng theo px */
|
|
18
|
+
setResolution(width: number, height: number): void;
|
|
19
|
+
/** Thêm edges cho 1 batch BufferElement[] */
|
|
20
|
+
addBufferElements(bufferElements: BufferElement[], boundaryOnly?: boolean): void;
|
|
21
|
+
/** Bật/tắt theo danh sách element: rebuild nhanh mảng positions hiển thị */
|
|
22
|
+
setVisibleElements(els: ElemKey[]): void;
|
|
23
|
+
/** Hiện tất cả edges */
|
|
24
|
+
showAll(): void;
|
|
25
|
+
/** Ẩn tất cả edges */
|
|
26
|
+
hideAll(): void;
|
|
27
|
+
/** Vẽ tất cả cạnh của từng tam giác: (0,1,2), (3,4,5), ... */
|
|
28
|
+
private _buildAllTriangleEdges;
|
|
29
|
+
/** Chỉ cạnh biên: weld đỉnh ~ gộp vertex gần nhau, đếm cạnh xuất hiện 1 lần */
|
|
30
|
+
private _buildBoundarySegments;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -29,8 +29,27 @@ export declare class ViralMergedMesh extends Mesh {
|
|
|
29
29
|
}[]): BufferElement[];
|
|
30
30
|
getElementsByModel(modelIndex: number): BufferElement[];
|
|
31
31
|
private _edgeLines;
|
|
32
|
-
|
|
32
|
+
private _edgeRanges;
|
|
33
|
+
private _edgeThreshold;
|
|
34
|
+
private _edgeMaterial;
|
|
35
|
+
enableEdgePerElement(material: LineBasicMaterial, thresholdDeg?: number): void;
|
|
33
36
|
disableEdge(): void;
|
|
37
|
+
enableEdge(): void;
|
|
38
|
+
/** call this after rebuild/batch to keep edges in sync (if enabled) */
|
|
39
|
+
refreshEdgesIfAny(): void;
|
|
40
|
+
private _buildMergedEdges;
|
|
41
|
+
/** Show edges ONLY for the given elements */
|
|
42
|
+
isolateEdge(elements?: {
|
|
43
|
+
modelId: string;
|
|
44
|
+
elementId: string;
|
|
45
|
+
}[]): void;
|
|
46
|
+
/** Hide edges for the given elements (keep all others) */
|
|
47
|
+
hideEdge(elements?: {
|
|
48
|
+
modelId: string;
|
|
49
|
+
elementId: string;
|
|
50
|
+
}[]): void;
|
|
51
|
+
/** Restore all edges */
|
|
52
|
+
edgeReset(): void;
|
|
34
53
|
private _selectedElements;
|
|
35
54
|
select(elements: {
|
|
36
55
|
modelId: string;
|
|
@@ -55,7 +74,10 @@ export declare class ViralMergedMesh extends Mesh {
|
|
|
55
74
|
isolate(elements?: {
|
|
56
75
|
modelId: string;
|
|
57
76
|
elementId: string;
|
|
58
|
-
}[]):
|
|
77
|
+
}[]): {
|
|
78
|
+
modelId: string;
|
|
79
|
+
elementId: string;
|
|
80
|
+
}[];
|
|
59
81
|
get selectedElements(): {
|
|
60
82
|
modelId: string;
|
|
61
83
|
elementId: string;
|
|
@@ -132,6 +154,8 @@ export declare class ViralMergedMesh extends Mesh {
|
|
|
132
154
|
modelId: string;
|
|
133
155
|
elementId: string;
|
|
134
156
|
}[]): Box3 | null;
|
|
157
|
+
getTotalVertexCount(): number;
|
|
158
|
+
getObjectCount(): number;
|
|
135
159
|
/**
|
|
136
160
|
* ! Disposes of the ViralMergedMesh properly, when dispose we dont need to dispose material
|
|
137
161
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Box3, LineBasicMaterial, Mesh } from "three";
|
|
2
2
|
import { ViralMergedMesh } from "./viral-merged-mesh";
|
|
3
3
|
import { BufferElement } from "../..";
|
|
4
|
+
import { ViralMergedEdges } from "./viral-merged-edge";
|
|
4
5
|
/**
|
|
5
6
|
* this class is a wrapper, it stand for a clone of bim model (optimize version to increase performance when render)
|
|
6
7
|
* it merge geometries follow material.
|
|
@@ -11,6 +12,10 @@ export declare class ViralMergedModel extends Mesh {
|
|
|
11
12
|
get bounds(): Box3;
|
|
12
13
|
isReady: boolean;
|
|
13
14
|
setReady(value: boolean): void;
|
|
15
|
+
private _mergedEdges;
|
|
16
|
+
addMergedEdge(edge: ViralMergedEdges): void;
|
|
17
|
+
getMergedEdge(globalMaterialIndex: number): ViralMergedEdges | undefined;
|
|
18
|
+
getMergedEdges(): ViralMergedEdges[];
|
|
14
19
|
private _mergedMeshes;
|
|
15
20
|
addMergedMesh(mesh: ViralMergedMesh): void;
|
|
16
21
|
getMergedMesh(globalMaterialIndex: number): ViralMergedMesh | undefined;
|
|
@@ -19,10 +24,15 @@ export declare class ViralMergedModel extends Mesh {
|
|
|
19
24
|
modelId: string;
|
|
20
25
|
elementId: string;
|
|
21
26
|
}[]): void;
|
|
27
|
+
private _isolatingElements;
|
|
22
28
|
isolate(elements?: {
|
|
23
29
|
modelId: string;
|
|
24
30
|
elementId: string;
|
|
25
31
|
}[]): void;
|
|
32
|
+
getIsolatingElements(): {
|
|
33
|
+
modelId: string;
|
|
34
|
+
elementId: string;
|
|
35
|
+
}[];
|
|
26
36
|
/**
|
|
27
37
|
* Isolate whole model
|
|
28
38
|
* @param modelIds
|
|
@@ -79,7 +89,8 @@ export declare class ViralMergedModel extends Mesh {
|
|
|
79
89
|
resetVisibility(): void;
|
|
80
90
|
resetColor(): void;
|
|
81
91
|
enableEdge(material: LineBasicMaterial): void;
|
|
82
|
-
|
|
92
|
+
showEdge(): void;
|
|
93
|
+
hideEdge(): void;
|
|
83
94
|
/**
|
|
84
95
|
* *everytime add new model in scene this model will be regenerated again, for that reason we should dispose this model
|
|
85
96
|
* *then regenerate again
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Box3, BufferGeometry, Material } from "three";
|
|
2
|
+
import { ViralMergedMesh } from "./viral-merged-mesh";
|
|
3
|
+
export declare class ViralSpatialMergedMesh extends ViralMergedMesh {
|
|
4
|
+
spatialBounds: Box3;
|
|
5
|
+
spatialId: string;
|
|
6
|
+
constructor(bounds: Box3, spatialId: string, geometry?: BufferGeometry, material?: Material);
|
|
7
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Box3, Camera, Color, Material, Mesh, Vector3 } from "three";
|
|
2
|
+
import { ViralSpatialMergedMesh } from "./viral-spatial-merged-mesh";
|
|
3
|
+
import { BufferElement } from "../..";
|
|
4
|
+
export declare class ViralSpatialMeshManager {
|
|
5
|
+
private spatialGrid;
|
|
6
|
+
private gridSize;
|
|
7
|
+
private worldBounds;
|
|
8
|
+
constructor(worldBounds: Box3, gridSize?: Vector3);
|
|
9
|
+
private getGridKey;
|
|
10
|
+
private getGridBounds;
|
|
11
|
+
getSpatialMesh(gridKey: string, materialIndex: number, material: Material): ViralSpatialMergedMesh;
|
|
12
|
+
private calculateElementCenter;
|
|
13
|
+
getVisibleMeshes(camera: Camera): ViralSpatialMergedMesh[];
|
|
14
|
+
updateVisibility(camera: Camera, parentMesh: Mesh): void;
|
|
15
|
+
/**
|
|
16
|
+
* 🔥 FIXED: Add buffer elements with material color support
|
|
17
|
+
*/
|
|
18
|
+
addBufferElements(bufferElements: BufferElement[], material: Material, globalMaterialIndex: number, materialColor?: Color): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get statistics about spatial mesh usage
|
|
21
|
+
*/
|
|
22
|
+
getStats(): {
|
|
23
|
+
totalCells: number;
|
|
24
|
+
loadedCells: number;
|
|
25
|
+
visibleCells: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Clean up distant meshes to free memory
|
|
29
|
+
*/
|
|
30
|
+
cleanupDistantMeshes(cameraPosition: Vector3, maxDistance: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get center point of a grid cell
|
|
33
|
+
*/
|
|
34
|
+
private getGridCenter;
|
|
35
|
+
/**
|
|
36
|
+
* Get world bounds for debugging
|
|
37
|
+
*/
|
|
38
|
+
getWorldBounds(): Box3;
|
|
39
|
+
/**
|
|
40
|
+
* 🔥 ADDED: Methods for element interaction (select, hide, isolate)
|
|
41
|
+
*/
|
|
42
|
+
selectElements(elements: {
|
|
43
|
+
modelId: string;
|
|
44
|
+
elementId: string;
|
|
45
|
+
}[], excepts?: {
|
|
46
|
+
elements: {
|
|
47
|
+
modelId: string;
|
|
48
|
+
elementId: string;
|
|
49
|
+
}[];
|
|
50
|
+
color: {
|
|
51
|
+
r: number;
|
|
52
|
+
g: number;
|
|
53
|
+
b: number;
|
|
54
|
+
};
|
|
55
|
+
}[]): void;
|
|
56
|
+
hideElements(elements?: {
|
|
57
|
+
modelId: string;
|
|
58
|
+
elementId: string;
|
|
59
|
+
}[]): void;
|
|
60
|
+
isolateElements(elements?: {
|
|
61
|
+
modelId: string;
|
|
62
|
+
elementId: string;
|
|
63
|
+
}[]): void;
|
|
64
|
+
resetVisibility(): void;
|
|
65
|
+
resetColor(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Dispose all spatial meshes
|
|
68
|
+
*/
|
|
69
|
+
dispose(): void;
|
|
70
|
+
}
|
|
@@ -8,6 +8,7 @@ export declare class ViralCentralizedEventHandler {
|
|
|
8
8
|
/**
|
|
9
9
|
** this for optimize purpose; when renderer become too heavy, it will hide object when camera move
|
|
10
10
|
*/
|
|
11
|
+
private sleepTimer;
|
|
11
12
|
cameraHandler(): void;
|
|
12
13
|
windowHandler(): void;
|
|
13
14
|
handleResize(entries: any): void;
|
|
@@ -19,6 +19,7 @@ export declare class ViralRevitLoader {
|
|
|
19
19
|
loadRevitGroupByMaterial(model: ViralutionFragmentModel): void;
|
|
20
20
|
getVerticePoints(indices: number[], vertices: ViralPoint[], instances?: RevitTransform[]): number[];
|
|
21
21
|
loadStandalone(trackingUrl: string, dataUrl: string, informationUrl: string, callbackOnFinish?: () => void): Promise<void>;
|
|
22
|
+
loadFlatBufferStandalone(informationUrl: string, geometriesUrl: string, callbackOnFinish?: () => void): Promise<void>;
|
|
22
23
|
getMaterials(dataUrl: string, byteRangeStart: number, byteRangeEnd: number): Promise<any>;
|
|
23
24
|
getElements(dataUrl: string, chunk: number[][], callbackOnSuccess?: (model: any, index: number) => void): Promise<void>;
|
|
24
25
|
loadByMaterial(trackingUrl: string, dataUrl: string, informationUrl: string): Promise<void>;
|
|
@@ -5,12 +5,49 @@ export declare class ViralRenderer {
|
|
|
5
5
|
viralViewerApi: ViralViewerApi;
|
|
6
6
|
renderer: WebGLRenderer;
|
|
7
7
|
postProcessingRenderer: PostProcessingRenderer;
|
|
8
|
+
private _t;
|
|
9
|
+
private _lastSpatialStatsTime;
|
|
8
10
|
constructor(viralViewerApi: ViralViewerApi);
|
|
9
11
|
updateSize(width: number, height: number): void;
|
|
10
12
|
private renderTimeout;
|
|
11
13
|
render(): void;
|
|
12
|
-
private _t;
|
|
13
14
|
private performRender;
|
|
15
|
+
accumulateTAAFrames(sampleFrames?: number): void;
|
|
16
|
+
/**
|
|
17
|
+
* Log standard WebGL render statistics
|
|
18
|
+
*/
|
|
19
|
+
private logRenderStats;
|
|
20
|
+
/**
|
|
21
|
+
* Log spatial mesh statistics if spatial merging is active
|
|
22
|
+
*/
|
|
23
|
+
private logSpatialStats;
|
|
24
|
+
/**
|
|
25
|
+
* Get detailed rendering performance info
|
|
26
|
+
*/
|
|
27
|
+
getPerformanceInfo(): {
|
|
28
|
+
rendering: {
|
|
29
|
+
calls: number;
|
|
30
|
+
triangles: number;
|
|
31
|
+
points: number;
|
|
32
|
+
lines: number;
|
|
33
|
+
};
|
|
34
|
+
memory: {
|
|
35
|
+
geometries: number;
|
|
36
|
+
textures: number;
|
|
37
|
+
};
|
|
38
|
+
spatial: {
|
|
39
|
+
totalCells: number;
|
|
40
|
+
loadedCells: number;
|
|
41
|
+
visibleCells: number;
|
|
42
|
+
cullingEfficiency: string;
|
|
43
|
+
memoryEfficiency: string;
|
|
44
|
+
} | null;
|
|
45
|
+
isSpatialActive: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Enable/disable performance logging
|
|
49
|
+
*/
|
|
50
|
+
setPerformanceLogging(enabled: boolean, interval?: number): void;
|
|
14
51
|
private jitterOffsets;
|
|
15
52
|
private jitterIndex;
|
|
16
53
|
private size;
|
|
@@ -18,4 +55,12 @@ export declare class ViralRenderer {
|
|
|
18
55
|
applyJitter(): void;
|
|
19
56
|
generateJitterOffsets(samples?: number): number[][];
|
|
20
57
|
screenshot(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Take a screenshot with spatial mesh debug overlay
|
|
60
|
+
*/
|
|
61
|
+
screenshotWithSpatialDebug(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Render only visible spatial cells (for debugging)
|
|
64
|
+
*/
|
|
65
|
+
renderVisibleCellsOnly(): void;
|
|
21
66
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Scene, DirectionalLight, Mesh, Object3D, MeshBasicMaterial, Light, CameraHelper, Box3, OrthographicCamera, PerspectiveCamera } from "three";
|
|
1
|
+
import { Scene, DirectionalLight, Mesh, Object3D, MeshBasicMaterial, Light, CameraHelper, Vector3, Box3, OrthographicCamera, PerspectiveCamera, Camera } from "three";
|
|
2
2
|
import { ViralViewerApi } from "../../viral-viewer-api";
|
|
3
3
|
import { ViralMergedModel } from "../custom-objects/viral-merged-model";
|
|
4
4
|
import { ViralMainModel } from "../custom-objects/viral-main.model";
|
|
5
5
|
import { TransformControls } from "three/examples/jsm/controls/TransformControls";
|
|
6
|
+
import { ViralSpatialMeshManager } from "../custom-objects/viral-spatial-mesh-manager";
|
|
6
7
|
export declare class ViralScene {
|
|
7
8
|
viralViewerApi: ViralViewerApi;
|
|
8
9
|
scene: Scene;
|
|
@@ -12,6 +13,9 @@ export declare class ViralScene {
|
|
|
12
13
|
isolateModel: Mesh;
|
|
13
14
|
mergedModel: ViralMergedModel;
|
|
14
15
|
outlineModel: Mesh;
|
|
16
|
+
spatialMeshManager: ViralSpatialMeshManager | null;
|
|
17
|
+
spatialMeshContainer: Mesh;
|
|
18
|
+
private useSpatialMerging;
|
|
15
19
|
hideables: Object3D[];
|
|
16
20
|
selectables: Object3D[];
|
|
17
21
|
edges: Object3D[];
|
|
@@ -21,6 +25,42 @@ export declare class ViralScene {
|
|
|
21
25
|
transformControls: TransformControls | null;
|
|
22
26
|
lightHelpers: CameraHelper[];
|
|
23
27
|
constructor(viralViewerApi: ViralViewerApi);
|
|
28
|
+
/**
|
|
29
|
+
* Initialize spatial mesh manager with world bounds
|
|
30
|
+
*/
|
|
31
|
+
initializeSpatialManager(worldBounds: Box3, gridSize?: Vector3): void;
|
|
32
|
+
/**
|
|
33
|
+
* Enable/disable spatial merging
|
|
34
|
+
*/
|
|
35
|
+
setSpatialMerging(enabled: boolean): void;
|
|
36
|
+
/**
|
|
37
|
+
* Update spatial visibility based on camera (call this in render loop)
|
|
38
|
+
*/
|
|
39
|
+
updateSpatialVisibility(camera: Camera): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get spatial mesh manager
|
|
42
|
+
*/
|
|
43
|
+
getSpatialMeshManager(): ViralSpatialMeshManager | null;
|
|
44
|
+
/**
|
|
45
|
+
* Check if spatial merging is active
|
|
46
|
+
*/
|
|
47
|
+
isSpatialMergingActive(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Add spatial mesh to the spatial container
|
|
50
|
+
*/
|
|
51
|
+
addSpatialMesh(mesh: Object3D): void;
|
|
52
|
+
/**
|
|
53
|
+
* Clean up distant spatial meshes
|
|
54
|
+
*/
|
|
55
|
+
cleanupDistantSpatialMeshes(cameraPosition: Vector3, maxDistance?: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get spatial mesh statistics
|
|
58
|
+
*/
|
|
59
|
+
getSpatialStats(): {
|
|
60
|
+
totalCells: number;
|
|
61
|
+
loadedCells: number;
|
|
62
|
+
visibleCells: number;
|
|
63
|
+
} | null;
|
|
24
64
|
addObject(object: Object3D): void;
|
|
25
65
|
addModel(object: Object3D): void;
|
|
26
66
|
addEdge(object: Object3D): void;
|
|
@@ -1,15 +1,98 @@
|
|
|
1
1
|
import { ViralViewerApi } from "../../viral-viewer-api";
|
|
2
2
|
import { RenderMaterial, ViralutionElement } from "../../types";
|
|
3
|
+
import { Box3, Camera, Vector3 } from "three";
|
|
3
4
|
import { WorkerThreadPool } from "./base/worker-pool";
|
|
5
|
+
import { ViralSpatialMeshManager } from "../custom-objects/viral-spatial-mesh-manager";
|
|
4
6
|
export declare class LoadElementPatchWorker {
|
|
5
7
|
viralViewerApi: ViralViewerApi;
|
|
6
8
|
workerPool: WorkerThreadPool;
|
|
9
|
+
private lastRenderTime;
|
|
10
|
+
private useSpatialMerging;
|
|
7
11
|
constructor(viralViewerApi: ViralViewerApi);
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Initialize model with materials
|
|
10
14
|
* @param materials
|
|
11
15
|
* @returns modelId
|
|
12
16
|
*/
|
|
13
17
|
initial(materials: RenderMaterial[]): number;
|
|
18
|
+
/**
|
|
19
|
+
* Main load method - automatically routes to spatial or traditional approach
|
|
20
|
+
*/
|
|
14
21
|
loadElement(modelId: number, elements: ViralutionElement[], callbackOnSuccess?: () => void): void;
|
|
22
|
+
/**
|
|
23
|
+
* Traditional load implementation (renamed for clarity)
|
|
24
|
+
*/
|
|
25
|
+
private loadTraditionalElement;
|
|
26
|
+
/** How many vec4 slots your per-object data needs (mat4 -> 4, id/color -> 1, none -> 0). */
|
|
27
|
+
private get perObjectUniformVec4();
|
|
28
|
+
/** Reserve some vec4 slots for built-ins (MVP, lights, fog, etc.). Tweak if you use heavy materials. */
|
|
29
|
+
private get reservedUniformVec4();
|
|
30
|
+
private computeBatchLimits;
|
|
31
|
+
/** Split elements to chunks that satisfy both vertex and object limits. */
|
|
32
|
+
private splitByLimits;
|
|
33
|
+
/**
|
|
34
|
+
* Initialize spatial mesh manager in scene only
|
|
35
|
+
*/
|
|
36
|
+
initializeSpatialManager(worldBounds: Box3): void;
|
|
37
|
+
/**
|
|
38
|
+
* Disable spatial merging and fall back to original method
|
|
39
|
+
*/
|
|
40
|
+
disableSpatialMerging(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Enable spatial merging (requires spatial manager to be initialized in scene)
|
|
43
|
+
*/
|
|
44
|
+
enableSpatialMerging(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Load elements using spatial merging
|
|
47
|
+
*/
|
|
48
|
+
private loadSpatialElement;
|
|
49
|
+
/**
|
|
50
|
+
* Create spatial meshes for elements
|
|
51
|
+
*/
|
|
52
|
+
private createSpatialMeshes;
|
|
53
|
+
/**
|
|
54
|
+
* Update camera-based visibility for spatial meshes
|
|
55
|
+
*/
|
|
56
|
+
updateSpatialVisibility(camera: Camera): void;
|
|
57
|
+
/**
|
|
58
|
+
* Create single merged mesh (traditional implementation)
|
|
59
|
+
*/
|
|
60
|
+
private createSingleMergedMesh;
|
|
61
|
+
private createSingleMergedEdge;
|
|
62
|
+
/**
|
|
63
|
+
* Create optimized material for merging
|
|
64
|
+
*/
|
|
65
|
+
private createOptimizedMaterial;
|
|
66
|
+
/**
|
|
67
|
+
* Throttled render to avoid excessive render calls
|
|
68
|
+
*/
|
|
69
|
+
private throttledRender;
|
|
70
|
+
/**
|
|
71
|
+
* Get spatial mesh manager (delegate to scene)
|
|
72
|
+
*/
|
|
73
|
+
getSpatialMeshManager(): ViralSpatialMeshManager | null;
|
|
74
|
+
/**
|
|
75
|
+
* Check if spatial merging is enabled
|
|
76
|
+
*/
|
|
77
|
+
isSpatialMergingEnabled(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Get spatial mesh statistics
|
|
80
|
+
*/
|
|
81
|
+
getSpatialStats(): {
|
|
82
|
+
totalCells: number;
|
|
83
|
+
loadedCells: number;
|
|
84
|
+
visibleCells: number;
|
|
85
|
+
} | null;
|
|
86
|
+
/**
|
|
87
|
+
* Clean up distant spatial meshes to free memory
|
|
88
|
+
*/
|
|
89
|
+
cleanupDistantMeshes(cameraPosition: Vector3, maxDistance?: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Calculate world bounds from elements (utility method)
|
|
92
|
+
*/
|
|
93
|
+
calculateWorldBounds(elements: ViralutionElement[]): Box3;
|
|
94
|
+
/**
|
|
95
|
+
* Apply RevitTransform to a point (utility method)
|
|
96
|
+
*/
|
|
97
|
+
private applyTransform;
|
|
15
98
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ViralViewerApi } from "../../viral-viewer-api";
|
|
2
|
+
export declare class ViralPivotPoint {
|
|
3
|
+
viralViewerApi: ViralViewerApi;
|
|
4
|
+
private contextMenu;
|
|
5
|
+
constructor(viralViewerApi: ViralViewerApi);
|
|
6
|
+
private injectContextMenu;
|
|
7
|
+
show(top: number, left: number): void;
|
|
8
|
+
hide(): void;
|
|
9
|
+
}
|
package/dist/index.d.ts
CHANGED