threedviewer 2.3.0 → 2.4.0
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/core/ViewerCore.d.ts +5 -18
- package/dist/core/managers/ModelManager.d.ts +53 -0
- package/dist/core/managers/ResourceManager.d.ts +40 -0
- package/dist/core/managers/ScreenshotManager.d.ts +38 -0
- package/dist/core/managers/StateManager.d.ts +78 -0
- package/dist/core/managers/index.d.ts +4 -0
- package/dist/simple-viewer.es.js +2704 -2454
- package/dist/simple-viewer.umd.js +80 -80
- package/dist/types/options/HelperOptions.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IRenderer, IRendererOptions, IScene, IModelLoader, ICamera, IControls, IObject3D, Result } from './interfaces';
|
|
2
|
-
import { ViewerState } from './entities/ViewerState';
|
|
3
2
|
import { TypedEventEmitter } from '../events/EventEmitter';
|
|
4
3
|
import { ViewerEventMap } from './events/ViewerEvents';
|
|
5
4
|
import { SimpleViewerOptions } from '../types/SimpleViewerOptions';
|
|
@@ -7,6 +6,7 @@ import { IPathTracingService } from './services/IPathTracingService';
|
|
|
7
6
|
import { IEnvironmentService } from './services/IEnvironmentService';
|
|
8
7
|
import { ISceneSetupService } from './services/ISceneSetupService';
|
|
9
8
|
import { IFloorAlignmentService } from './services/IFloorAlignmentService';
|
|
9
|
+
import { ViewerState } from './entities/ViewerState';
|
|
10
10
|
export interface ViewerDependencies {
|
|
11
11
|
renderer: IRenderer;
|
|
12
12
|
scene: IScene;
|
|
@@ -25,31 +25,26 @@ export interface ViewerDependencies {
|
|
|
25
25
|
* Independent of UI framework and rendering engine
|
|
26
26
|
*/
|
|
27
27
|
export declare class ViewerCore {
|
|
28
|
-
private state;
|
|
29
28
|
private readonly events;
|
|
30
29
|
private readonly renderLoopManager;
|
|
31
30
|
private lastFrameTime;
|
|
32
31
|
private frameCount;
|
|
33
|
-
private stateChangeCallback?;
|
|
34
32
|
private pathTracingStartTime?;
|
|
35
|
-
private screenshotElement;
|
|
36
|
-
private isShowingScreenshot;
|
|
37
|
-
private screenshotResizeHandler?;
|
|
38
|
-
private serializedSceneState?;
|
|
39
|
-
private lastModelUrl?;
|
|
40
33
|
private pathTracingCompleteHandled;
|
|
41
34
|
private disposed;
|
|
35
|
+
private readonly stateManager;
|
|
36
|
+
private readonly screenshotManager;
|
|
37
|
+
private readonly modelManager;
|
|
38
|
+
private readonly resourceManager;
|
|
42
39
|
private readonly renderer;
|
|
43
40
|
private readonly scene;
|
|
44
41
|
private readonly camera;
|
|
45
42
|
private readonly controls;
|
|
46
|
-
private readonly modelLoader;
|
|
47
43
|
private readonly options;
|
|
48
44
|
private readonly rendererOptions?;
|
|
49
45
|
private readonly sceneSetupService?;
|
|
50
46
|
private environmentService?;
|
|
51
47
|
private pathTracingService?;
|
|
52
|
-
private readonly floorAlignmentService?;
|
|
53
48
|
constructor(dependencies: ViewerDependencies);
|
|
54
49
|
/**
|
|
55
50
|
* Initialize the viewer
|
|
@@ -99,14 +94,6 @@ export declare class ViewerCore {
|
|
|
99
94
|
* Restore the 3D scene from screenshot
|
|
100
95
|
*/
|
|
101
96
|
private restoreFromScreenshot;
|
|
102
|
-
/**
|
|
103
|
-
* Dispose scene resources while keeping the screenshot
|
|
104
|
-
*/
|
|
105
|
-
private disposeSceneResources;
|
|
106
|
-
/**
|
|
107
|
-
* Recursively dispose of an object and its children
|
|
108
|
-
*/
|
|
109
|
-
private disposeObject;
|
|
110
97
|
/**
|
|
111
98
|
* Dispose of all resources
|
|
112
99
|
*/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IModelLoader, IObject3D, IScene, ICamera, IControls, Result } from '../interfaces';
|
|
2
|
+
import { IFloorAlignmentService } from '../services/IFloorAlignmentService';
|
|
3
|
+
import { ISceneSetupService } from '../services/ISceneSetupService';
|
|
4
|
+
import { TypedEventEmitter } from '../../events/EventEmitter';
|
|
5
|
+
import { ViewerEventMap } from '../events/ViewerEvents';
|
|
6
|
+
export interface ModelManagerDependencies {
|
|
7
|
+
modelLoader: IModelLoader;
|
|
8
|
+
scene: IScene;
|
|
9
|
+
camera: ICamera;
|
|
10
|
+
controls: IControls;
|
|
11
|
+
floorAlignmentService?: IFloorAlignmentService;
|
|
12
|
+
sceneSetupService?: ISceneSetupService;
|
|
13
|
+
autoFitToObject?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Manages model loading, disposal, and scene setup
|
|
17
|
+
*/
|
|
18
|
+
export declare class ModelManager {
|
|
19
|
+
private currentModel;
|
|
20
|
+
private lastModelUrl?;
|
|
21
|
+
private readonly modelLoader;
|
|
22
|
+
private readonly scene;
|
|
23
|
+
private readonly camera;
|
|
24
|
+
private readonly controls;
|
|
25
|
+
private readonly floorAlignmentService?;
|
|
26
|
+
private readonly sceneSetupService?;
|
|
27
|
+
private readonly autoFitToObject;
|
|
28
|
+
constructor(dependencies: ModelManagerDependencies);
|
|
29
|
+
/**
|
|
30
|
+
* Get current model
|
|
31
|
+
*/
|
|
32
|
+
getCurrentModel(): IObject3D | null;
|
|
33
|
+
/**
|
|
34
|
+
* Get last loaded model URL
|
|
35
|
+
*/
|
|
36
|
+
getLastModelUrl(): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Load a 3D model
|
|
39
|
+
*/
|
|
40
|
+
loadModel(source: string | IObject3D, events: TypedEventEmitter<ViewerEventMap>): Promise<Result<IObject3D>>;
|
|
41
|
+
/**
|
|
42
|
+
* Dispose current model
|
|
43
|
+
*/
|
|
44
|
+
disposeCurrentModel(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Recursively dispose of an object and its children
|
|
47
|
+
*/
|
|
48
|
+
private disposeObject;
|
|
49
|
+
/**
|
|
50
|
+
* Dispose all resources
|
|
51
|
+
*/
|
|
52
|
+
dispose(): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IScene } from '../interfaces';
|
|
2
|
+
import { IPathTracingService } from '../services/IPathTracingService';
|
|
3
|
+
import { IEnvironmentService } from '../services/IEnvironmentService';
|
|
4
|
+
export interface ResourceManagerDependencies {
|
|
5
|
+
scene: IScene;
|
|
6
|
+
pathTracingService?: IPathTracingService;
|
|
7
|
+
environmentService?: IEnvironmentService;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Manages resource disposal and cleanup
|
|
11
|
+
*/
|
|
12
|
+
export declare class ResourceManager {
|
|
13
|
+
private readonly scene;
|
|
14
|
+
private pathTracingService?;
|
|
15
|
+
private environmentService?;
|
|
16
|
+
constructor(dependencies: ResourceManagerDependencies);
|
|
17
|
+
/**
|
|
18
|
+
* Update services (needed after screenshot restoration)
|
|
19
|
+
*/
|
|
20
|
+
updateServices(services: {
|
|
21
|
+
pathTracingService?: IPathTracingService;
|
|
22
|
+
environmentService?: IEnvironmentService;
|
|
23
|
+
}): void;
|
|
24
|
+
/**
|
|
25
|
+
* Dispose scene resources (for screenshot mode)
|
|
26
|
+
*/
|
|
27
|
+
disposeSceneResources(preservePathTracing?: boolean): void;
|
|
28
|
+
/**
|
|
29
|
+
* Dispose all services
|
|
30
|
+
*/
|
|
31
|
+
disposeServices(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Complete disposal of all resources
|
|
34
|
+
*/
|
|
35
|
+
dispose(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Trigger garbage collection hint
|
|
38
|
+
*/
|
|
39
|
+
private triggerGarbageCollection;
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IRenderer, ICamera, IControls } from '../interfaces';
|
|
2
|
+
import { SerializedSceneState } from '../utils/SceneSerializer';
|
|
3
|
+
export interface ScreenshotManagerDependencies {
|
|
4
|
+
renderer: IRenderer;
|
|
5
|
+
onRestore?: () => Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manages screenshot capture and restoration functionality
|
|
9
|
+
*/
|
|
10
|
+
export declare class ScreenshotManager {
|
|
11
|
+
private screenshotElement;
|
|
12
|
+
private isShowingScreenshot;
|
|
13
|
+
private screenshotResizeHandler?;
|
|
14
|
+
private serializedSceneState?;
|
|
15
|
+
private readonly renderer;
|
|
16
|
+
private readonly onRestore?;
|
|
17
|
+
constructor(dependencies: ScreenshotManagerDependencies);
|
|
18
|
+
/**
|
|
19
|
+
* Check if currently showing a screenshot
|
|
20
|
+
*/
|
|
21
|
+
isActive(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Capture current frame and replace canvas with screenshot
|
|
24
|
+
*/
|
|
25
|
+
captureAndReplace(camera: ICamera, controls: IControls, lastModelUrl?: string, onResourcesDisposed?: () => void): void;
|
|
26
|
+
/**
|
|
27
|
+
* Restore the 3D scene from screenshot
|
|
28
|
+
*/
|
|
29
|
+
restore(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Get serialized scene state for restoration
|
|
32
|
+
*/
|
|
33
|
+
getSerializedState(): SerializedSceneState | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Clean up resources
|
|
36
|
+
*/
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ViewerState } from '../entities/ViewerState';
|
|
2
|
+
import { ThreeViewerError } from '../../errors';
|
|
3
|
+
import { IObject3D } from '../interfaces';
|
|
4
|
+
export interface StateChangeCallback {
|
|
5
|
+
(state: ViewerState): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manages viewer state transitions and notifications
|
|
9
|
+
*/
|
|
10
|
+
export declare class StateManager {
|
|
11
|
+
private state;
|
|
12
|
+
private readonly stateChangeCallbacks;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Get current state
|
|
16
|
+
*/
|
|
17
|
+
getState(): ViewerState;
|
|
18
|
+
/**
|
|
19
|
+
* Set initialized state
|
|
20
|
+
*/
|
|
21
|
+
setInitialized(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Start loading state
|
|
24
|
+
*/
|
|
25
|
+
startLoading(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set loaded state with model
|
|
28
|
+
*/
|
|
29
|
+
setLoaded(model: IObject3D): void;
|
|
30
|
+
/**
|
|
31
|
+
* Set error state
|
|
32
|
+
*/
|
|
33
|
+
setError(error: ThreeViewerError): void;
|
|
34
|
+
/**
|
|
35
|
+
* Start rendering state
|
|
36
|
+
*/
|
|
37
|
+
startRendering(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Update render info
|
|
40
|
+
*/
|
|
41
|
+
updateRenderInfo(info: {
|
|
42
|
+
frameCount: number;
|
|
43
|
+
fps: number;
|
|
44
|
+
lastRenderTime: number;
|
|
45
|
+
}): void;
|
|
46
|
+
/**
|
|
47
|
+
* Set disposed state
|
|
48
|
+
*/
|
|
49
|
+
setDisposed(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Check if can load model in current state
|
|
52
|
+
*/
|
|
53
|
+
canLoad(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if viewer is initialized
|
|
56
|
+
*/
|
|
57
|
+
isInitialized(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get current status
|
|
60
|
+
*/
|
|
61
|
+
getStatus(): 'idle' | 'loading' | 'loaded' | 'rendering' | 'error' | 'disposed';
|
|
62
|
+
/**
|
|
63
|
+
* Get current model
|
|
64
|
+
*/
|
|
65
|
+
getCurrentModel(): IObject3D | null;
|
|
66
|
+
/**
|
|
67
|
+
* Subscribe to state changes
|
|
68
|
+
*/
|
|
69
|
+
onStateChange(callback: StateChangeCallback): () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Clear all callbacks
|
|
72
|
+
*/
|
|
73
|
+
clearCallbacks(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Update state and notify listeners
|
|
76
|
+
*/
|
|
77
|
+
private updateState;
|
|
78
|
+
}
|