viral-viewer-2 6.8.7 → 6.8.9
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/camera/viral-camera.d.ts +2 -17
- package/dist/components/custom-objects/viral-batched-mesh.d.ts +35 -8
- package/dist/components/custom-objects/viral-edge-mesh.d.ts +133 -0
- package/dist/components/custom-objects/viral-instanced-mesh-v2.d.ts +142 -0
- package/dist/components/custom-objects/viral-instanced-mesh-v3.d.ts +123 -0
- package/dist/components/custom-objects/viral-merged-model.d.ts +46 -6
- package/dist/components/data-manager/viral-data-manager.d.ts +1 -0
- package/dist/components/duplication-analyzer/viral-duplication-analyzer.d.ts +74 -0
- package/dist/components/loader/viral-flatbuffer.loader.d.ts +13 -0
- package/dist/components/loader/viral.loader.d.ts +2 -0
- package/dist/components/lod-generator/viral-lod-generator.d.ts +116 -0
- package/dist/components/worker/base/worker-pool.d.ts +1 -0
- package/dist/components/worker/load-element-patch.worker.d.ts +5 -26
- package/dist/components/worker-script/load-instanced-element.script.d.ts +1 -0
- package/dist/index.mjs +17999 -24447
- package/dist/serializers/viralution-flatbuffer.serializer.d.ts +7 -1
- package/dist/serializers/viralution-standalone.serializer.d.ts +3 -1
- package/dist/types.d.ts +14 -0
- package/package.json +3 -3
|
@@ -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,
|
|
4
|
+
import { Vector3, Raycaster, PerspectiveCamera, Object3D, OrthographicCamera } from "three";
|
|
5
5
|
export declare class ViralCamera {
|
|
6
6
|
viralViewerApi: ViralViewerApi;
|
|
7
7
|
raycaster: Raycaster;
|
|
@@ -40,6 +40,7 @@ export declare class ViralCamera {
|
|
|
40
40
|
worldToClient2(point: Vector3): Vector3 | null;
|
|
41
41
|
private castRay;
|
|
42
42
|
updateMainCamera(): void;
|
|
43
|
+
adjustCameraFarFromScene(margin?: number): void;
|
|
43
44
|
private cameraWakeQueuedEvents;
|
|
44
45
|
private cameraSleepQueuedEvents;
|
|
45
46
|
private cameraUpdateQueuedEvents;
|
|
@@ -52,20 +53,4 @@ export declare class ViralCamera {
|
|
|
52
53
|
addEventListener(type: ViralCameraEventType, key: string, resolve: () => void): void;
|
|
53
54
|
removeEventListener(type: ViralCameraEventType, key: string): void;
|
|
54
55
|
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;
|
|
71
56
|
}
|
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
import { Box3, BufferGeometry, Color, Material, Mesh, Vector3 } from "three";
|
|
2
2
|
import { BufferElement } from "../..";
|
|
3
3
|
import { LineMaterial } from "three/examples/jsm/Addons";
|
|
4
|
+
import { WorkerThreadPool } from "../worker/base/worker-pool";
|
|
4
5
|
export declare class ViralBatchedMesh extends Mesh {
|
|
5
6
|
globalMaterialIndex: number;
|
|
6
|
-
|
|
7
|
+
private workerPool;
|
|
8
|
+
constructor(geometry?: BufferGeometry, material?: Material, workerPool?: WorkerThreadPool | null);
|
|
7
9
|
/**
|
|
8
10
|
* *for tracking and manage element visibility, for instance hide object
|
|
9
11
|
*/
|
|
10
12
|
_bufferElements: BufferElement[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
protected _colors: Float32Array | null;
|
|
14
|
+
protected _originalColor: Color | null;
|
|
13
15
|
/**
|
|
14
16
|
* Stores mapping of model IDs to their element data.
|
|
15
17
|
*/
|
|
16
|
-
|
|
18
|
+
protected _elementMap: Map<string, Map<string, {
|
|
19
|
+
/** Start index of the element in the buffer */
|
|
20
|
+
start: number;
|
|
21
|
+
/** Number of vertices associated with the element */
|
|
22
|
+
count: number;
|
|
23
|
+
indices: number[];
|
|
24
|
+
}[]>>;
|
|
17
25
|
addBufferElements(bufferElements: BufferElement[], materialColor: Color): void;
|
|
18
26
|
rebuildGeometry(bufferElements: BufferElement[]): void;
|
|
19
|
-
|
|
27
|
+
protected _isBatching: boolean;
|
|
20
28
|
get isBatching(): boolean;
|
|
21
29
|
batch(newBufferElements: BufferElement[]): void;
|
|
30
|
+
private _batchQueue;
|
|
31
|
+
private _isProcessingQueue;
|
|
32
|
+
batchAsync(newBufferElements: BufferElement[]): Promise<void>;
|
|
33
|
+
private _processQueue;
|
|
34
|
+
private _performSingleBatch;
|
|
35
|
+
private _applyWorkerResult;
|
|
36
|
+
/**
|
|
37
|
+
* Finalize geometry after batch operation
|
|
38
|
+
*/
|
|
39
|
+
private _finalizeGeometry;
|
|
22
40
|
/**
|
|
23
41
|
* get bufferEleemnts from given ids
|
|
24
42
|
* @param elements
|
|
@@ -51,7 +69,10 @@ export declare class ViralBatchedMesh extends Mesh {
|
|
|
51
69
|
}[]): void;
|
|
52
70
|
/** Restore all edges */
|
|
53
71
|
edgeReset(): void;
|
|
54
|
-
|
|
72
|
+
protected _selectedElements: {
|
|
73
|
+
modelId: string;
|
|
74
|
+
elementId: string;
|
|
75
|
+
}[];
|
|
55
76
|
select(elements: {
|
|
56
77
|
modelId: string;
|
|
57
78
|
elementId: string;
|
|
@@ -66,12 +87,18 @@ export declare class ViralBatchedMesh extends Mesh {
|
|
|
66
87
|
b: number;
|
|
67
88
|
};
|
|
68
89
|
}[]): void;
|
|
69
|
-
|
|
90
|
+
protected _hidingElements: {
|
|
91
|
+
modelId: string;
|
|
92
|
+
elementId: string;
|
|
93
|
+
}[];
|
|
70
94
|
hide(elements?: {
|
|
71
95
|
modelId: string;
|
|
72
96
|
elementId: string;
|
|
73
97
|
}[]): void;
|
|
74
|
-
|
|
98
|
+
protected _isolatingElements: {
|
|
99
|
+
modelId: string;
|
|
100
|
+
elementId: string;
|
|
101
|
+
}[];
|
|
75
102
|
isolate(elements?: {
|
|
76
103
|
modelId: string;
|
|
77
104
|
elementId: string;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Object3D } from "three";
|
|
2
|
+
import { LineMaterial } from "three/examples/jsm/Addons";
|
|
3
|
+
import { ViralBatchedMesh } from "./viral-batched-mesh";
|
|
4
|
+
import { ViralInstancedMeshV2 } from "./viral-instanced-mesh-v2";
|
|
5
|
+
export declare class ViralEdgeMesh extends Object3D {
|
|
6
|
+
private _edgeLines;
|
|
7
|
+
private _edgeMaterial;
|
|
8
|
+
private _edgeThreshold;
|
|
9
|
+
private _edgeRanges;
|
|
10
|
+
private _batchedMeshes;
|
|
11
|
+
private _instancedMeshes;
|
|
12
|
+
private _hiddenElements;
|
|
13
|
+
private _isolatedElements;
|
|
14
|
+
private _xrayMode;
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Initialize edge mesh with material and threshold
|
|
18
|
+
*/
|
|
19
|
+
initialize(material: LineMaterial, thresholdDeg?: number): void;
|
|
20
|
+
/**
|
|
21
|
+
* Add a batched mesh to be included in edge generation
|
|
22
|
+
*/
|
|
23
|
+
addBatchedMesh(mesh: ViralBatchedMesh): void;
|
|
24
|
+
/**
|
|
25
|
+
* Add an instanced mesh to be included in edge generation
|
|
26
|
+
*/
|
|
27
|
+
addInstancedMesh(mesh: ViralInstancedMeshV2): void;
|
|
28
|
+
/**
|
|
29
|
+
* Remove a mesh from edge generation
|
|
30
|
+
*/
|
|
31
|
+
removeMesh(mesh: ViralBatchedMesh | ViralInstancedMeshV2): void;
|
|
32
|
+
/**
|
|
33
|
+
* Build the unified edge mesh from all registered meshes
|
|
34
|
+
*/
|
|
35
|
+
buildEdges(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Extract edge data from a batched mesh
|
|
38
|
+
*/
|
|
39
|
+
private _extractBatchedMeshEdges;
|
|
40
|
+
/**
|
|
41
|
+
* Extract edge data from an instanced mesh
|
|
42
|
+
*/
|
|
43
|
+
private _extractInstancedMeshEdges;
|
|
44
|
+
/**
|
|
45
|
+
* Track edge ranges for batched mesh elements
|
|
46
|
+
*/
|
|
47
|
+
private _trackBatchedEdgeRanges;
|
|
48
|
+
/**
|
|
49
|
+
* Track edge ranges for instanced mesh elements
|
|
50
|
+
*/
|
|
51
|
+
private _trackInstancedEdgeRanges;
|
|
52
|
+
/**
|
|
53
|
+
* Rebuild edges when meshes are updated
|
|
54
|
+
*/
|
|
55
|
+
refresh(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Show edges
|
|
58
|
+
*/
|
|
59
|
+
show(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Hide edges
|
|
62
|
+
*/
|
|
63
|
+
hide(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Hide edges for specific elements
|
|
66
|
+
*/
|
|
67
|
+
hideElements(elements: {
|
|
68
|
+
modelId: string;
|
|
69
|
+
elementId: string;
|
|
70
|
+
}[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Show only specific elements (isolate) with x-ray mode option
|
|
73
|
+
*/
|
|
74
|
+
isolateElements(elements: {
|
|
75
|
+
modelId: string;
|
|
76
|
+
elementId: string;
|
|
77
|
+
}[], xrayMode?: boolean): void;
|
|
78
|
+
/**
|
|
79
|
+
* Enable/disable x-ray mode for current isolation
|
|
80
|
+
*/
|
|
81
|
+
setXrayMode(enabled: boolean): void;
|
|
82
|
+
/**
|
|
83
|
+
* Get current x-ray mode state
|
|
84
|
+
*/
|
|
85
|
+
get isXrayMode(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Reset all edge visibility
|
|
88
|
+
*/
|
|
89
|
+
resetVisibility(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Update edge visibility based on hidden/isolated elements
|
|
92
|
+
*/
|
|
93
|
+
private _updateEdgeVisibility;
|
|
94
|
+
/**
|
|
95
|
+
* Set visibility for a specific element in the visibility mask
|
|
96
|
+
*/
|
|
97
|
+
private _setElementVisibility;
|
|
98
|
+
/**
|
|
99
|
+
* Update edges when source meshes are modified
|
|
100
|
+
*/
|
|
101
|
+
onMeshUpdated(mesh: ViralBatchedMesh | ViralInstancedMeshV2): void;
|
|
102
|
+
/**
|
|
103
|
+
* Get total vertex count in the edge mesh
|
|
104
|
+
*/
|
|
105
|
+
getTotalEdgeVertexCount(): number;
|
|
106
|
+
/**
|
|
107
|
+
* Check if edges are currently visible
|
|
108
|
+
*/
|
|
109
|
+
get isVisible(): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Get the number of registered meshes
|
|
112
|
+
*/
|
|
113
|
+
getMeshCount(): {
|
|
114
|
+
batched: number;
|
|
115
|
+
instanced: number;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Clear all edge data
|
|
119
|
+
*/
|
|
120
|
+
private _clearEdges;
|
|
121
|
+
/**
|
|
122
|
+
* Dispose of the edge mesh and clean up resources
|
|
123
|
+
*/
|
|
124
|
+
dispose(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Update edge material
|
|
127
|
+
*/
|
|
128
|
+
updateMaterial(material: LineMaterial): void;
|
|
129
|
+
/**
|
|
130
|
+
* Update edge threshold and rebuild if necessary
|
|
131
|
+
*/
|
|
132
|
+
updateThreshold(thresholdDeg: number): void;
|
|
133
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Box3, BufferGeometry, Color, Material, Vector3, Matrix4, InstancedMesh, Object3D } from "three";
|
|
2
|
+
import { BufferElement } from "../..";
|
|
3
|
+
import { LineMaterial } from "three/examples/jsm/Addons";
|
|
4
|
+
export declare class ViralInstancedMeshV2 extends Object3D {
|
|
5
|
+
protected material?: Material | undefined;
|
|
6
|
+
globalMaterialIndex: number;
|
|
7
|
+
constructor(material?: Material | undefined);
|
|
8
|
+
protected _instancedMeshes: Map<string, InstancedMesh<BufferGeometry<import("three").NormalBufferAttributes>, Material | Material[], import("three").InstancedMeshEventMap>>;
|
|
9
|
+
_bufferElements: BufferElement[];
|
|
10
|
+
protected _originalColor: Color | null;
|
|
11
|
+
protected _elementMap: Map<string, Map<string, {
|
|
12
|
+
geometryKey: string;
|
|
13
|
+
instanceIndex: number;
|
|
14
|
+
instancedMesh: InstancedMesh;
|
|
15
|
+
}[]>>;
|
|
16
|
+
private _originalTransforms;
|
|
17
|
+
private _selectedElements;
|
|
18
|
+
private _hidingElements;
|
|
19
|
+
protected _isolatingElements: {
|
|
20
|
+
modelId: string;
|
|
21
|
+
elementId: string;
|
|
22
|
+
}[];
|
|
23
|
+
private _edgeLines;
|
|
24
|
+
private _edgeRanges;
|
|
25
|
+
private _edgeThreshold;
|
|
26
|
+
private _edgeMaterial;
|
|
27
|
+
private _isGeneratedLights;
|
|
28
|
+
private _pointLight;
|
|
29
|
+
addBufferElements(bufferElements: BufferElement[], materialColor: Color): void;
|
|
30
|
+
private rebuildInstances;
|
|
31
|
+
private _createInstancedMesh;
|
|
32
|
+
protected _createGeometryFromBuffer(buffer: Float32Array): BufferGeometry;
|
|
33
|
+
protected _transformArrayToMatrix4(transform: number[]): Matrix4;
|
|
34
|
+
protected _generateGeometryKey(buffer: Float32Array): string;
|
|
35
|
+
batch(newBufferElements: BufferElement[]): void;
|
|
36
|
+
select(elements: {
|
|
37
|
+
modelId: string;
|
|
38
|
+
elementId: string;
|
|
39
|
+
}[], excepts?: {
|
|
40
|
+
elements: {
|
|
41
|
+
modelId: string;
|
|
42
|
+
elementId: string;
|
|
43
|
+
}[];
|
|
44
|
+
color: {
|
|
45
|
+
r: number;
|
|
46
|
+
g: number;
|
|
47
|
+
b: number;
|
|
48
|
+
};
|
|
49
|
+
}[]): void;
|
|
50
|
+
changeColor(elements: {
|
|
51
|
+
modelId: string;
|
|
52
|
+
elementId: string;
|
|
53
|
+
}[], color: {
|
|
54
|
+
r: number;
|
|
55
|
+
g: number;
|
|
56
|
+
b: number;
|
|
57
|
+
}): void;
|
|
58
|
+
resetColor(modelId: string | null, elementId?: string, excepts?: {
|
|
59
|
+
elements: {
|
|
60
|
+
modelId: string;
|
|
61
|
+
elementId: string;
|
|
62
|
+
}[];
|
|
63
|
+
color: {
|
|
64
|
+
r: number;
|
|
65
|
+
g: number;
|
|
66
|
+
b: number;
|
|
67
|
+
};
|
|
68
|
+
}[]): void;
|
|
69
|
+
get selectedElements(): {
|
|
70
|
+
modelId: string;
|
|
71
|
+
elementId: string;
|
|
72
|
+
}[];
|
|
73
|
+
hide(elements?: {
|
|
74
|
+
modelId: string;
|
|
75
|
+
elementId: string;
|
|
76
|
+
}[]): void;
|
|
77
|
+
isolate(elements?: {
|
|
78
|
+
modelId: string;
|
|
79
|
+
elementId: string;
|
|
80
|
+
}[]): {
|
|
81
|
+
modelId: string;
|
|
82
|
+
elementId: string;
|
|
83
|
+
}[];
|
|
84
|
+
isolateModel(modelIds: string[]): void;
|
|
85
|
+
reset(): void;
|
|
86
|
+
private showAllInstances;
|
|
87
|
+
enableEdgePerElement(material: LineMaterial, thresholdDeg?: number): void;
|
|
88
|
+
disableEdge(): void;
|
|
89
|
+
enableEdge(): void;
|
|
90
|
+
refreshEdgesIfAny(): void;
|
|
91
|
+
private _buildInstancedEdges;
|
|
92
|
+
isolateEdge(elements?: {
|
|
93
|
+
modelId: string;
|
|
94
|
+
elementId: string;
|
|
95
|
+
}[]): void;
|
|
96
|
+
hideEdge(elements?: {
|
|
97
|
+
modelId: string;
|
|
98
|
+
elementId: string;
|
|
99
|
+
}[]): void;
|
|
100
|
+
edgeReset(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Enable raycasting for all instanced meshes
|
|
103
|
+
*/
|
|
104
|
+
enableRaycasting(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Custom raycast function for instanced meshes
|
|
107
|
+
*/
|
|
108
|
+
private _instancedRaycast;
|
|
109
|
+
findElementByInstancedMeshAndIndex(instancedMesh: InstancedMesh, instanceIndex: number): {
|
|
110
|
+
modelId: string;
|
|
111
|
+
elementId: string;
|
|
112
|
+
} | null;
|
|
113
|
+
/**
|
|
114
|
+
* Alternative method: Find element by face index (similar to original)
|
|
115
|
+
* Note: This is more complex for instanced meshes
|
|
116
|
+
*/
|
|
117
|
+
findElementByFaceIndex(faceIndex: number): {
|
|
118
|
+
modelId: string;
|
|
119
|
+
elementId: string;
|
|
120
|
+
} | null;
|
|
121
|
+
/**
|
|
122
|
+
* Get all instanced meshes for external raycast handling
|
|
123
|
+
*/
|
|
124
|
+
getInstancedMeshes(): InstancedMesh[];
|
|
125
|
+
getElements(elements: {
|
|
126
|
+
modelId: string;
|
|
127
|
+
elementId: string;
|
|
128
|
+
}[]): BufferElement[];
|
|
129
|
+
getElementsByModel(modelIndex: number): BufferElement[];
|
|
130
|
+
getElementBoxs(elements: {
|
|
131
|
+
modelId: string;
|
|
132
|
+
elementId: string;
|
|
133
|
+
}[]): Box3 | null;
|
|
134
|
+
getTotalVertexCount(): number;
|
|
135
|
+
getObjectCount(): number;
|
|
136
|
+
get isBatching(): boolean;
|
|
137
|
+
enableLights(): void;
|
|
138
|
+
disableLights(): void;
|
|
139
|
+
calculateCenter(buffer: Float32Array): Vector3 | null;
|
|
140
|
+
private getFarthestDistance;
|
|
141
|
+
dispose(): void;
|
|
142
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Box3, Color, Material, Vector3, InstancedMesh } from "three";
|
|
2
|
+
import { BufferElement } from "../..";
|
|
3
|
+
import { LineMaterial } from "three/examples/jsm/Addons";
|
|
4
|
+
export declare class ViralInstancedMeshV3 extends InstancedMesh {
|
|
5
|
+
globalMaterialIndex: number;
|
|
6
|
+
private _bufferElement;
|
|
7
|
+
private _originalColor;
|
|
8
|
+
private _elementMap;
|
|
9
|
+
private _selectedElements;
|
|
10
|
+
private _hidingElements;
|
|
11
|
+
private _isolatingElements;
|
|
12
|
+
private _edgeLines;
|
|
13
|
+
private _edgeThreshold;
|
|
14
|
+
private _edgeMaterial;
|
|
15
|
+
private _isGeneratedLights;
|
|
16
|
+
private _pointLight;
|
|
17
|
+
private _originalTransforms;
|
|
18
|
+
constructor(material: Material);
|
|
19
|
+
addBufferElement(bufferElement: BufferElement, materialColor: Color): void;
|
|
20
|
+
private _setupInstanceData;
|
|
21
|
+
private _createGeometryFromBuffer;
|
|
22
|
+
private _transformArrayToMatrix4;
|
|
23
|
+
private _generateGeometryKey;
|
|
24
|
+
batch(newBufferElements: BufferElement[]): void;
|
|
25
|
+
select(elements: {
|
|
26
|
+
modelId: string;
|
|
27
|
+
elementId: string;
|
|
28
|
+
}[], excepts?: {
|
|
29
|
+
elements: {
|
|
30
|
+
modelId: string;
|
|
31
|
+
elementId: string;
|
|
32
|
+
}[];
|
|
33
|
+
color: {
|
|
34
|
+
r: number;
|
|
35
|
+
g: number;
|
|
36
|
+
b: number;
|
|
37
|
+
};
|
|
38
|
+
}[]): void;
|
|
39
|
+
changeColor(elements: {
|
|
40
|
+
modelId: string;
|
|
41
|
+
elementId: string;
|
|
42
|
+
}[], color: {
|
|
43
|
+
r: number;
|
|
44
|
+
g: number;
|
|
45
|
+
b: number;
|
|
46
|
+
}): void;
|
|
47
|
+
resetColor(modelId: string | null, elementId?: string, excepts?: {
|
|
48
|
+
elements: {
|
|
49
|
+
modelId: string;
|
|
50
|
+
elementId: string;
|
|
51
|
+
}[];
|
|
52
|
+
color: {
|
|
53
|
+
r: number;
|
|
54
|
+
g: number;
|
|
55
|
+
b: number;
|
|
56
|
+
};
|
|
57
|
+
}[]): void;
|
|
58
|
+
get selectedElements(): {
|
|
59
|
+
modelId: string;
|
|
60
|
+
elementId: string;
|
|
61
|
+
}[];
|
|
62
|
+
get bufferElements(): BufferElement[];
|
|
63
|
+
hide(elements?: {
|
|
64
|
+
modelId: string;
|
|
65
|
+
elementId: string;
|
|
66
|
+
}[]): void;
|
|
67
|
+
isolate(elements?: {
|
|
68
|
+
modelId: string;
|
|
69
|
+
elementId: string;
|
|
70
|
+
}[]): {
|
|
71
|
+
modelId: string;
|
|
72
|
+
elementId: string;
|
|
73
|
+
}[];
|
|
74
|
+
isolateModel(modelIds: string[]): void;
|
|
75
|
+
reset(): void;
|
|
76
|
+
private showAllInstances;
|
|
77
|
+
enableEdgePerElement(material: LineMaterial, thresholdDeg?: number): void;
|
|
78
|
+
disableEdge(): void;
|
|
79
|
+
enableEdge(): void;
|
|
80
|
+
refreshEdgesIfAny(): void;
|
|
81
|
+
private _buildEdges;
|
|
82
|
+
isolateEdge(elements?: {
|
|
83
|
+
modelId: string;
|
|
84
|
+
elementId: string;
|
|
85
|
+
}[]): void;
|
|
86
|
+
hideEdge(elements?: {
|
|
87
|
+
modelId: string;
|
|
88
|
+
elementId: string;
|
|
89
|
+
}[]): void;
|
|
90
|
+
edgeReset(): void;
|
|
91
|
+
enableRaycasting(): void;
|
|
92
|
+
private _customRaycast;
|
|
93
|
+
findElementByInstanceIndex(instanceIndex: number): {
|
|
94
|
+
modelId: string;
|
|
95
|
+
elementId: string;
|
|
96
|
+
} | null;
|
|
97
|
+
findElementByInstancedMeshAndIndex(instancedMesh: InstancedMesh, instanceIndex: number): {
|
|
98
|
+
modelId: string;
|
|
99
|
+
elementId: string;
|
|
100
|
+
} | null;
|
|
101
|
+
findElementByFaceIndex(faceIndex: number): {
|
|
102
|
+
modelId: string;
|
|
103
|
+
elementId: string;
|
|
104
|
+
} | null;
|
|
105
|
+
getInstancedMeshes(): InstancedMesh[];
|
|
106
|
+
getElements(elements: {
|
|
107
|
+
modelId: string;
|
|
108
|
+
elementId: string;
|
|
109
|
+
}[]): BufferElement[];
|
|
110
|
+
getElementsByModel(modelIndex: number): BufferElement[];
|
|
111
|
+
getElementBoxs(elements: {
|
|
112
|
+
modelId: string;
|
|
113
|
+
elementId: string;
|
|
114
|
+
}[]): Box3 | null;
|
|
115
|
+
getTotalVertexCount(): number;
|
|
116
|
+
getObjectCount(): number;
|
|
117
|
+
get isBatching(): boolean;
|
|
118
|
+
enableLights(): void;
|
|
119
|
+
disableLights(): void;
|
|
120
|
+
calculateCenter(buffer: Float32Array): Vector3 | null;
|
|
121
|
+
private getFarthestDistance;
|
|
122
|
+
dispose(): this;
|
|
123
|
+
}
|
|
@@ -2,25 +2,38 @@ import { Box3, Mesh } from "three";
|
|
|
2
2
|
import { ViralBatchedMesh } from "./viral-batched-mesh";
|
|
3
3
|
import { BufferElement } from "../..";
|
|
4
4
|
import { LineMaterial } from "three/examples/jsm/lines/LineMaterial";
|
|
5
|
+
import { ViralInstancedMeshV2 } from "./viral-instanced-mesh-v2";
|
|
6
|
+
import { ViralEdgeMesh } from "./viral-edge-mesh";
|
|
7
|
+
import { WorkerThreadPool } from "../worker/base/worker-pool";
|
|
5
8
|
/**
|
|
6
9
|
* this class is a wrapper, it stand for a clone of bim model (optimize version to increase performance when render)
|
|
7
10
|
* it merge geometries follow material.
|
|
8
11
|
*
|
|
9
12
|
*/
|
|
10
13
|
export declare class ViralMergedModel extends Mesh {
|
|
14
|
+
protected _edgeMesh: ViralEdgeMesh;
|
|
15
|
+
workerPool: WorkerThreadPool | null;
|
|
11
16
|
constructor();
|
|
17
|
+
private _initializeWorkerPool;
|
|
12
18
|
get bounds(): Box3;
|
|
13
19
|
isReady: boolean;
|
|
14
20
|
setReady(value: boolean): void;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
protected _batchedMeshes: ViralBatchedMesh[];
|
|
22
|
+
addBatchedMesh(mesh: ViralBatchedMesh): void;
|
|
23
|
+
getBatchedMesh(globalMaterialIndex: number): ViralBatchedMesh | undefined;
|
|
24
|
+
getBatchedMeshes(): ViralBatchedMesh[];
|
|
25
|
+
protected _instancedMeshes: ViralInstancedMeshV2[];
|
|
26
|
+
addInstancedMesh(mesh: ViralInstancedMeshV2): void;
|
|
27
|
+
getInstancedMesh(globalMaterialIndex: number): ViralInstancedMeshV2 | undefined;
|
|
28
|
+
getInstancedMeshes(): ViralInstancedMeshV2[];
|
|
19
29
|
hide(elements?: {
|
|
20
30
|
modelId: string;
|
|
21
31
|
elementId: string;
|
|
22
32
|
}[]): void;
|
|
23
|
-
|
|
33
|
+
protected _isolatingElements: {
|
|
34
|
+
modelId: string;
|
|
35
|
+
elementId: string;
|
|
36
|
+
}[];
|
|
24
37
|
isolate(elements?: {
|
|
25
38
|
modelId: string;
|
|
26
39
|
elementId: string;
|
|
@@ -84,9 +97,36 @@ export declare class ViralMergedModel extends Mesh {
|
|
|
84
97
|
*/
|
|
85
98
|
resetVisibility(): void;
|
|
86
99
|
resetColor(): void;
|
|
87
|
-
enableEdge(material: LineMaterial): void;
|
|
100
|
+
enableEdge(material: LineMaterial, thresholdDeg?: number): void;
|
|
88
101
|
showEdge(): void;
|
|
89
102
|
hideEdge(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Refresh edges when meshes are updated
|
|
105
|
+
*/
|
|
106
|
+
refreshEdges(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Update edge material
|
|
109
|
+
*/
|
|
110
|
+
updateEdgeMaterial(material: LineMaterial): void;
|
|
111
|
+
/**
|
|
112
|
+
* Update edge threshold
|
|
113
|
+
*/
|
|
114
|
+
updateEdgeThreshold(thresholdDeg: number): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get edge mesh statistics
|
|
117
|
+
*/
|
|
118
|
+
getEdgeStats(): {
|
|
119
|
+
isVisible: boolean;
|
|
120
|
+
vertexCount: number;
|
|
121
|
+
meshCount: {
|
|
122
|
+
batched: number;
|
|
123
|
+
instanced: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Notify edge mesh when meshes are updated (call this after batching or rebuilding)
|
|
128
|
+
*/
|
|
129
|
+
onMeshUpdated(mesh?: ViralBatchedMesh | ViralInstancedMeshV2): void;
|
|
90
130
|
/**
|
|
91
131
|
* *everytime add new model in scene this model will be regenerated again, for that reason we should dispose this model
|
|
92
132
|
* *then regenerate again
|
|
@@ -9,6 +9,7 @@ export declare class ViralDataManager {
|
|
|
9
9
|
private _checkClashWorker;
|
|
10
10
|
constructor(viralViewerApi: ViralViewerApi);
|
|
11
11
|
normalFetch(url: string, byteRangeStart?: number, byteRangeEnd?: number): Promise<Response>;
|
|
12
|
+
gzipFetch(url: string): Promise<Response>;
|
|
12
13
|
/**
|
|
13
14
|
* worker fetch can only return json or arraybuffer value
|
|
14
15
|
* @param url
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ViralutionElement } from "../../types";
|
|
2
|
+
export interface DuplicationAnalysis {
|
|
3
|
+
strategy: "BATCHING" | "INSTANCING" | "HYBRID";
|
|
4
|
+
totalElements: number;
|
|
5
|
+
totalInstances: number;
|
|
6
|
+
totalVertices: number;
|
|
7
|
+
uniqueGeometries: number;
|
|
8
|
+
averageVerticesPerElement: number;
|
|
9
|
+
averageInstancesPerGeometry: number;
|
|
10
|
+
highDuplicationElements: Array<{
|
|
11
|
+
element: ViralutionElement;
|
|
12
|
+
vertexCount: number;
|
|
13
|
+
instanceCount: number;
|
|
14
|
+
totalVertexInstances: number;
|
|
15
|
+
efficiencyScore: number;
|
|
16
|
+
}>;
|
|
17
|
+
lowDuplicationElements: Array<{
|
|
18
|
+
element: ViralutionElement;
|
|
19
|
+
vertexCount: number;
|
|
20
|
+
instanceCount: number;
|
|
21
|
+
totalVertexInstances: number;
|
|
22
|
+
efficiencyScore: number;
|
|
23
|
+
}>;
|
|
24
|
+
estimatedDrawCalls: number;
|
|
25
|
+
estimatedMemoryReduction: number;
|
|
26
|
+
details: {
|
|
27
|
+
batchedElements: number;
|
|
28
|
+
batchedVertices: number;
|
|
29
|
+
instancedElements: number;
|
|
30
|
+
instancedVertices: number;
|
|
31
|
+
instancedDrawCalls: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
declare class ViralDuplicationAnalyzer {
|
|
35
|
+
private readonly MIN_VERTEX_INSTANCES_FOR_INSTANCING;
|
|
36
|
+
private readonly MIN_INSTANCES_FOR_INSTANCING;
|
|
37
|
+
private readonly MAX_DRAW_CALLS;
|
|
38
|
+
private readonly MIN_INSTANCED_VERTEX_RATIO;
|
|
39
|
+
private readonly HIGH_VERTEX_THRESHOLD;
|
|
40
|
+
/**
|
|
41
|
+
* Enhanced analysis considering vertex count × instance count
|
|
42
|
+
*/
|
|
43
|
+
analyze(elements: ViralutionElement[]): DuplicationAnalysis;
|
|
44
|
+
private calculateElementMetrics;
|
|
45
|
+
private categorizeByEfficiency;
|
|
46
|
+
private determineStrategy;
|
|
47
|
+
private calculateDrawCalls;
|
|
48
|
+
private calculateMemoryReduction;
|
|
49
|
+
private calculateDetails;
|
|
50
|
+
private logAnalysis;
|
|
51
|
+
/**
|
|
52
|
+
* Get elements that should be instanced vs batched with the new logic
|
|
53
|
+
*/
|
|
54
|
+
categorizeElements(elements: ViralutionElement[]): {
|
|
55
|
+
forInstancing: ViralutionElement[];
|
|
56
|
+
forBatching: ViralutionElement[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Configure thresholds for vertex-aware analysis
|
|
60
|
+
*/
|
|
61
|
+
setThresholds(config: {
|
|
62
|
+
minVertexInstancesForInstancing?: number;
|
|
63
|
+
minInstancesForInstancing?: number;
|
|
64
|
+
maxDrawCalls?: number;
|
|
65
|
+
minInstancedVertexRatio?: number;
|
|
66
|
+
highVertexThreshold?: number;
|
|
67
|
+
}): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get a detailed recommendation with vertex information
|
|
70
|
+
*/
|
|
71
|
+
getDetailedRecommendation(elements: ViralutionElement[]): string;
|
|
72
|
+
}
|
|
73
|
+
export declare const viralDuplicationAnalyzer: ViralDuplicationAnalyzer;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ViralutionElement } from "../../types";
|
|
2
|
+
import { ViralViewerApi } from "../../viral-viewer-api";
|
|
3
|
+
export declare class ViralFlatbufferLoader {
|
|
4
|
+
viralViewerApi: ViralViewerApi;
|
|
5
|
+
elements: ViralutionElement[];
|
|
6
|
+
private _loadElementPatchWorker;
|
|
7
|
+
constructor(viralViewerApi: ViralViewerApi);
|
|
8
|
+
load(trackingUrl: string, informationUrl: string, materialsUrl: string, elementsUrls: string[], callbackOnFinish?: () => void): Promise<void>;
|
|
9
|
+
private getInformations;
|
|
10
|
+
private getTracking;
|
|
11
|
+
private getMaterials;
|
|
12
|
+
private getElements;
|
|
13
|
+
}
|