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.
- package/dist/batched-mesh-simplifier-X1OOBfUy.mjs +1076 -0
- package/dist/components/custom-objects/viral-batched-mesh.d.ts +46 -0
- package/dist/components/custom-objects/viral-instanced-mesh-v2.d.ts +1 -1
- package/dist/components/custom-objects/viral-merged-model.d.ts +13 -0
- package/dist/components/loader/viral-revit.loader.d.ts +1 -1
- package/dist/components/renderer/viral-renderer.d.ts +1 -1
- package/dist/components/visibility-manager/viral-visibility-manager.d.ts +21 -1
- package/dist/components/worker/{load-element-patch.worker.d.ts → load-element-batch.worker.d.ts} +16 -5
- package/dist/gui/batch-debug-panel/viral-batch-debug-panel.d.ts +20 -0
- package/dist/gui/tools/tools/viral-tool-measure.d.ts +1 -1
- package/dist/index-DFLlwciS.mjs +56127 -0
- package/dist/index.mjs +35 -44071
- package/dist/types.d.ts +1 -0
- package/dist/utils/batched-mesh-simplifier.d.ts +36 -0
- package/dist/utils/geometry-simplifier.d.ts +108 -0
- package/dist/utils/threejs.d.ts +1 -1
- package/dist/viral-viewer-api.d.ts +2 -0
- package/package.json +6 -4
- package/dist/components/batcher/viral-batcher.d.ts +0 -15
- /package/dist/components/worker-script/{load-element-patch.script.d.ts → load-element-batch.script.d.ts} +0 -0
package/dist/types.d.ts
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SimplifyOptions } from "./geometry-simplifier";
|
|
2
|
+
import { BufferElement } from "../types";
|
|
3
|
+
import { ViralBatchedMesh } from "../components/custom-objects/viral-batched-mesh";
|
|
4
|
+
/**
|
|
5
|
+
* Simplify buffer elements while preserving the ability to batch them
|
|
6
|
+
* This simplifies each element's geometry individually, so element mapping remains valid
|
|
7
|
+
*/
|
|
8
|
+
export declare function simplifyBufferElements(bufferElements: BufferElement[], options: SimplifyOptions): Promise<BufferElement[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Create a simplified version of a ViralBatchedMesh by simplifying its buffer elements
|
|
11
|
+
* This preserves element mapping functionality (hide, isolate, changeColor)
|
|
12
|
+
*
|
|
13
|
+
* @param originalMesh - The original batched mesh
|
|
14
|
+
* @param options - Simplification options
|
|
15
|
+
* @returns Object containing simplified buffer elements and original color
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSimplifiedBatchedMeshData(originalMesh: any, // ViralBatchedMesh
|
|
18
|
+
options: SimplifyOptions): Promise<{
|
|
19
|
+
simplifiedElements: BufferElement[];
|
|
20
|
+
originalColor: any;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Simplify buffer elements in batches for better performance
|
|
24
|
+
* Uses parallel processing when possible
|
|
25
|
+
*/
|
|
26
|
+
export declare function simplifyBufferElementsBatch(bufferElements: BufferElement[], options: SimplifyOptions, batchSize?: number): Promise<BufferElement[]>;
|
|
27
|
+
/**
|
|
28
|
+
* FAST: Simplify entire batched mesh geometry at once
|
|
29
|
+
* This is much faster than per-element simplification but breaks element mapping
|
|
30
|
+
* Use this when you don't need hide/isolate/changeColor functionality
|
|
31
|
+
*
|
|
32
|
+
* @param batchedMesh - The batched mesh to simplify
|
|
33
|
+
* @param options - Simplification options
|
|
34
|
+
* @returns New simplified ViralBatchedMesh
|
|
35
|
+
*/
|
|
36
|
+
export declare function simplifyBatchedMeshFast(batchedMesh: ViralBatchedMesh, options: SimplifyOptions): Promise<ViralBatchedMesh>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BufferGeometry } from "three";
|
|
2
|
+
/**
|
|
3
|
+
* Options for geometry simplification
|
|
4
|
+
*/
|
|
5
|
+
export interface SimplifyOptions {
|
|
6
|
+
/** Target ratio of triangles to keep (0-1) */
|
|
7
|
+
ratio?: number;
|
|
8
|
+
/** Maximum error tolerance */
|
|
9
|
+
error?: number;
|
|
10
|
+
/** Lock border vertices during simplification */
|
|
11
|
+
lockBorder?: boolean;
|
|
12
|
+
/** Use sparse simplification */
|
|
13
|
+
sparse?: boolean;
|
|
14
|
+
/** Use absolute error metric */
|
|
15
|
+
errorAbsolute?: boolean;
|
|
16
|
+
/** Prune unnecessary vertices */
|
|
17
|
+
prune?: boolean;
|
|
18
|
+
/** Optimize memory by using smaller index types */
|
|
19
|
+
optimizeMemory?: boolean;
|
|
20
|
+
/** Log appearance error after simplification */
|
|
21
|
+
logAppearanceError?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* LOD (Level of Detail) configuration
|
|
25
|
+
*/
|
|
26
|
+
export interface LODConfig {
|
|
27
|
+
ratio: number;
|
|
28
|
+
error?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Predefined LOD ranges optimized for performance
|
|
32
|
+
*/
|
|
33
|
+
export declare const performanceRangeLOD: number[];
|
|
34
|
+
/**
|
|
35
|
+
* Predefined LOD ranges with balanced quality/performance
|
|
36
|
+
*/
|
|
37
|
+
export declare const balancedRangeLOD: number[];
|
|
38
|
+
/**
|
|
39
|
+
* Predefined LOD ranges optimized for quality
|
|
40
|
+
*/
|
|
41
|
+
export declare const qualityRangeLOD: number[];
|
|
42
|
+
/**
|
|
43
|
+
* Core simplification function using meshoptimizer
|
|
44
|
+
* @param indices - Index buffer array
|
|
45
|
+
* @param positions - Position buffer array
|
|
46
|
+
* @param options - Simplification options
|
|
47
|
+
* @returns Tuple of [simplified indices, appearance error]
|
|
48
|
+
*/
|
|
49
|
+
declare function simplify(indices: Uint8Array | Uint16Array | Uint32Array | number[], positions: Float32Array | number[], options: SimplifyOptions): Promise<[Uint8Array | Uint16Array | Uint32Array, number]>;
|
|
50
|
+
/**
|
|
51
|
+
* Simplify a BufferGeometry
|
|
52
|
+
* @param geometry - Input geometry (must be indexed)
|
|
53
|
+
* @param options - Simplification options
|
|
54
|
+
* @returns Simplified geometry clone
|
|
55
|
+
*/
|
|
56
|
+
export declare function simplifyGeometry(geometry: BufferGeometry, options: SimplifyOptions): Promise<BufferGeometry>;
|
|
57
|
+
/**
|
|
58
|
+
* Simplify multiple geometries
|
|
59
|
+
* @param geometries - Array of geometries to simplify
|
|
60
|
+
* @param options - Simplification options (can be array for per-geometry options)
|
|
61
|
+
* @returns Array of simplified geometries
|
|
62
|
+
*/
|
|
63
|
+
export declare function simplifyGeometries(geometries: BufferGeometry[], options: SimplifyOptions | SimplifyOptions[]): Promise<BufferGeometry[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Simplify geometry by error tolerance (ratio = 0)
|
|
66
|
+
* @param geometry - Input geometry
|
|
67
|
+
* @param error - Maximum error tolerance
|
|
68
|
+
* @returns Simplified geometry
|
|
69
|
+
*/
|
|
70
|
+
export declare function simplifyGeometryByError(geometry: BufferGeometry, error: number): Promise<BufferGeometry>;
|
|
71
|
+
/**
|
|
72
|
+
* Simplify multiple geometries by error tolerance
|
|
73
|
+
* @param geometries - Array of geometries
|
|
74
|
+
* @param errors - Error tolerance (can be array for per-geometry errors)
|
|
75
|
+
* @returns Array of simplified geometries
|
|
76
|
+
*/
|
|
77
|
+
export declare function simplifyGeometriesByError(geometries: BufferGeometry[], errors: number | number[]): Promise<BufferGeometry[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Create multiple LOD levels for a geometry using error-based simplification
|
|
80
|
+
* @param geometry - Input geometry
|
|
81
|
+
* @param lodCount - Number of LOD levels to generate
|
|
82
|
+
* @param errorRange - Array of error values for each LOD level (default: balancedRangeLOD)
|
|
83
|
+
* @returns Array of geometries [original, LOD1, LOD2, ...]
|
|
84
|
+
*/
|
|
85
|
+
export declare function simplifyGeometryByErrorLOD(geometry: BufferGeometry, lodCount: number, errorRange?: number[]): Promise<BufferGeometry[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Create multiple LOD levels for multiple geometries using error-based simplification
|
|
88
|
+
* @param geometries - Array of input geometries
|
|
89
|
+
* @param lodCounts - Number of LOD levels per geometry (can be array or single value)
|
|
90
|
+
* @param errorRanges - Error ranges per geometry (default: balancedRangeLOD)
|
|
91
|
+
* @returns Array of LOD arrays
|
|
92
|
+
*/
|
|
93
|
+
export declare function simplifyGeometriesByErrorLOD(geometries: BufferGeometry[], lodCounts: number | number[], errorRanges?: number[] | number[][]): Promise<BufferGeometry[][]>;
|
|
94
|
+
/**
|
|
95
|
+
* Create multiple LOD levels for a geometry using custom options
|
|
96
|
+
* @param geometry - Input geometry
|
|
97
|
+
* @param lodOptions - Array of simplification options for each LOD level
|
|
98
|
+
* @returns Array of geometries [original, LOD1, LOD2, ...]
|
|
99
|
+
*/
|
|
100
|
+
export declare function simplifyGeometryLOD(geometry: BufferGeometry, lodOptions: SimplifyOptions[]): Promise<BufferGeometry[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Create multiple LOD levels for multiple geometries using custom options
|
|
103
|
+
* @param geometries - Array of input geometries
|
|
104
|
+
* @param lodOptions - LOD options per geometry (can be array of arrays or single array)
|
|
105
|
+
* @returns Array of LOD arrays
|
|
106
|
+
*/
|
|
107
|
+
export declare function simplifyGeometriesLOD(geometries: BufferGeometry[], lodOptions: SimplifyOptions[] | SimplifyOptions[][]): Promise<BufferGeometry[][]>;
|
|
108
|
+
export { simplify };
|
package/dist/utils/threejs.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export declare class THREEUtil {
|
|
|
12
12
|
static rgbToThreejsColor(r: number, g: number, b: number): string;
|
|
13
13
|
private static componentToHex;
|
|
14
14
|
static mergeBoundingBoxes(boxes: Box3[]): Box3;
|
|
15
|
-
static createLowResMesh(mesh: Mesh, simplificationFactor?: number): Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes>, import("three").Material | import("three").Material[], import("three").Object3DEventMap>;
|
|
15
|
+
static createLowResMesh(mesh: Mesh, simplificationFactor?: number): Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, import("three").Material | import("three").Material[], import("three").Object3DEventMap>;
|
|
16
16
|
}
|
|
@@ -25,6 +25,7 @@ import { ViralAvatarManager } from "./components/avatar-manager/viral-avatar-man
|
|
|
25
25
|
import { ViralGeometryHandler } from "./components/handler/geometry.handler";
|
|
26
26
|
import { ViralSectionBox } from "./components/section-box/viral-section-box";
|
|
27
27
|
import { ViralPivotPoint } from "./gui/pivot-point/viral-pivot-point";
|
|
28
|
+
import { ViralBatchDebugPanel } from "./gui/batch-debug-panel/viral-batch-debug-panel";
|
|
28
29
|
/**
|
|
29
30
|
* Root of library
|
|
30
31
|
*/
|
|
@@ -56,5 +57,6 @@ export declare class ViralViewerApi extends EventDispatcher {
|
|
|
56
57
|
viralStats: ViralStats | null;
|
|
57
58
|
viralGeometryHandler: ViralGeometryHandler | null;
|
|
58
59
|
viralSectionBox: ViralSectionBox | null;
|
|
60
|
+
viralBatchDebugPanel: ViralBatchDebugPanel | null;
|
|
59
61
|
constructor(options?: ViewerOptions);
|
|
60
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viral-viewer-2",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^20.2.5",
|
|
24
24
|
"@types/pako": "^2.0.0",
|
|
25
|
-
"@types/three": "^0.
|
|
25
|
+
"@types/three": "^0.181.0",
|
|
26
26
|
"flatbuffers": "^25.2.10",
|
|
27
27
|
"lil-gui": "^0.20.0",
|
|
28
28
|
"typescript": "^5.0.4",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"camera-controls": "^2.9.0",
|
|
35
|
+
"meshoptimizer": "^0.25.0",
|
|
35
36
|
"n8ao": "^1.10.1",
|
|
36
37
|
"pako": "^2.1.0",
|
|
38
|
+
"postprocessing": "^6.38.0",
|
|
37
39
|
"potree-core-viral": "^0.3.0",
|
|
38
|
-
"three": "^0.
|
|
39
|
-
"three-mesh-bvh": "^0.9.
|
|
40
|
+
"three": "^0.181.2",
|
|
41
|
+
"three-mesh-bvh": "^0.9.2"
|
|
40
42
|
}
|
|
41
43
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BufferElement, ViralViewerApi } from "../..";
|
|
2
|
-
import { ViralMainModel } from "../custom-objects/viral-main.model";
|
|
3
|
-
export declare class ViralBatcher {
|
|
4
|
-
viralViewerApi: ViralViewerApi;
|
|
5
|
-
constructor(viralViewerApi: ViralViewerApi);
|
|
6
|
-
makeBatches(mainModel: ViralMainModel, modelId: number, bufferElements: BufferElement[]): void;
|
|
7
|
-
private createSingleMergedMesh;
|
|
8
|
-
private createOptimizedMaterial;
|
|
9
|
-
private get perObjectUniformVec4();
|
|
10
|
-
/** Reserve some vec4 slots for built-ins (MVP, lights, fog, etc.). Tweak if you use heavy materials. */
|
|
11
|
-
private get reservedUniformVec4();
|
|
12
|
-
private computeBatchLimits;
|
|
13
|
-
/** Split elements to chunks that satisfy both vertex and object limits. */
|
|
14
|
-
private splitByLimits;
|
|
15
|
-
}
|
|
File without changes
|