threedviewer 0.10.0 → 2.0.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/SimpleViewer.d.ts +17 -1
- package/dist/ThreeSceneSetup/HexGrid/HexTile.d.ts +2 -0
- package/dist/ThreeSceneSetup/SceneInitializer.d.ts +4 -1
- package/dist/ThreeSceneSetup/cleanupScene.d.ts +1 -1
- package/dist/ThreeSceneSetup/constants.d.ts +0 -3
- package/dist/ThreeSceneSetup/setupScene/AnimationManager.d.ts +8 -4
- package/dist/ThreeSceneSetup/setupScene/ControlsManager.d.ts +4 -2
- package/dist/ThreeSceneSetup/setupScene/EnvironmentMapManager.d.ts +32 -0
- package/dist/ThreeSceneSetup/setupScene/PathTracingManager.d.ts +6 -3
- package/dist/ThreeSceneSetup/setupScene/RendererManager.d.ts +5 -1
- package/dist/ThreeSceneSetup/setupScene/SceneManager.d.ts +1 -1
- package/dist/ThreeSceneSetup/updateSize.d.ts +1 -1
- package/dist/errors/ErrorCode.d.ts +13 -0
- package/dist/errors/ThreeViewerError.d.ts +11 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/events/EventEmitter.d.ts +8 -0
- package/dist/events/ViewerEvents.d.ts +42 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/simple-viewer.es.js +9185 -7989
- package/dist/simple-viewer.umd.js +130 -129
- package/dist/types/SimpleViewerOptions.d.ts +63 -0
- package/dist/types/options/CameraOptions.d.ts +8 -0
- package/dist/types/options/ControlsOptions.d.ts +19 -0
- package/dist/types/options/EnvironmentOptions.d.ts +6 -0
- package/dist/types/options/HelperOptions.d.ts +25 -0
- package/dist/types/options/LightingOptions.d.ts +37 -0
- package/dist/types/options/PathTracingOptions.d.ts +9 -0
- package/dist/types/options/RendererOptions.d.ts +11 -0
- package/dist/types/options/index.d.ts +7 -0
- package/dist/types.d.ts +9 -1
- package/dist/utils/Result.d.ts +13 -0
- package/dist/utils/deprecation.d.ts +15 -0
- package/dist/utils/optionsMapper.d.ts +11 -0
- package/dist/validation/OptionsValidator.d.ts +33 -0
- package/package.json +3 -3
package/dist/SimpleViewer.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { MapControls } from '../node_modules/three/examples/jsm/controls/MapControls';
|
|
3
|
+
import { OrbitControls } from '../node_modules/three/examples/jsm/controls/OrbitControls';
|
|
2
4
|
import { SimpleViewerProps } from './types';
|
|
3
|
-
|
|
5
|
+
import { TypedEventEmitter, ViewerEventMap } from './events';
|
|
6
|
+
import * as THREE from 'three';
|
|
7
|
+
export interface SimpleViewerHandle {
|
|
8
|
+
scene: THREE.Scene | null;
|
|
9
|
+
camera: THREE.Camera | null;
|
|
10
|
+
renderer: THREE.WebGLRenderer | null;
|
|
11
|
+
controls: OrbitControls | MapControls | null;
|
|
12
|
+
events: TypedEventEmitter<ViewerEventMap>;
|
|
13
|
+
loadModel: (url: string) => Promise<void>;
|
|
14
|
+
startRendering: () => void;
|
|
15
|
+
stopRendering: () => void;
|
|
16
|
+
captureScreenshot: () => Promise<string>;
|
|
17
|
+
dispose: () => void;
|
|
18
|
+
}
|
|
19
|
+
declare const SimpleViewer: React.ForwardRefExoticComponent<SimpleViewerProps & React.RefAttributes<SimpleViewerHandle>>;
|
|
4
20
|
export default SimpleViewer;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { MapControls } from '../../node_modules/three/examples/jsm/controls/MapControls';
|
|
2
2
|
import { OrbitControls } from '../../node_modules/three/examples/jsm/controls/OrbitControls';
|
|
3
3
|
import { SimpleViewerOptions } from '../types';
|
|
4
|
+
import { Result } from '../utils/Result';
|
|
4
5
|
import * as THREE from 'three';
|
|
5
6
|
export declare class SceneInitializer {
|
|
6
|
-
scene: THREE.Scene;
|
|
7
|
+
scene: THREE.Scene | null;
|
|
7
8
|
private object;
|
|
8
9
|
private camera;
|
|
9
10
|
private controls;
|
|
10
11
|
private options;
|
|
11
12
|
private mountRef;
|
|
12
13
|
constructor(object: THREE.Object3D | null, camera: THREE.Camera, controls: OrbitControls | MapControls, options: SimpleViewerOptions, mountRef: React.RefObject<HTMLDivElement>);
|
|
14
|
+
setup(): Result<THREE.Scene>;
|
|
13
15
|
private setupScene;
|
|
14
16
|
private setupObjectInScene;
|
|
17
|
+
dispose(): void;
|
|
15
18
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
export declare const cleanupScene: (mountRef: React.RefObject<HTMLDivElement>, renderer: THREE.WebGLRenderer, resizeHandler: () => void) => void;
|
|
3
|
+
export declare const cleanupScene: (mountRef: React.RefObject<HTMLDivElement>, renderer: THREE.WebGLRenderer | null, resizeHandler: () => void) => void;
|
|
@@ -2,6 +2,7 @@ import { OrbitControls } from '../../../node_modules/three/examples/jsm/controls
|
|
|
2
2
|
import { MapControls } from '../../../node_modules/three/examples/jsm/controls/MapControls';
|
|
3
3
|
import { SimpleViewerOptions } from '../../types';
|
|
4
4
|
import { PathTracingManager } from './PathTracingManager';
|
|
5
|
+
import { Result } from '../../utils/Result';
|
|
5
6
|
import * as THREE from 'three';
|
|
6
7
|
export declare class AnimationManager {
|
|
7
8
|
private renderer;
|
|
@@ -11,10 +12,13 @@ export declare class AnimationManager {
|
|
|
11
12
|
private options;
|
|
12
13
|
private isSceneActive;
|
|
13
14
|
private pathTracingManager;
|
|
14
|
-
|
|
15
|
+
private animationFrameId;
|
|
16
|
+
constructor(renderer: THREE.WebGLRenderer | null, scene: THREE.Scene | null, camera: THREE.Camera | null, controls: OrbitControls | MapControls | null, options: SimpleViewerOptions, pathTracingManager: PathTracingManager | null);
|
|
17
|
+
setup(): Result<void>;
|
|
15
18
|
private throttledRender;
|
|
16
19
|
private animate;
|
|
17
|
-
|
|
18
|
-
startRendering(): void
|
|
19
|
-
stopRendering(): void
|
|
20
|
+
startInitialRendering(): void;
|
|
21
|
+
startRendering(): Result<void>;
|
|
22
|
+
stopRendering(): Result<void>;
|
|
23
|
+
dispose(): void;
|
|
20
24
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { OrbitControls } from '../../../node_modules/three/examples/jsm/controls/OrbitControls';
|
|
2
2
|
import { MapControls } from '../../../node_modules/three/examples/jsm/controls/MapControls';
|
|
3
3
|
import { SimpleViewerOptions } from '../../types';
|
|
4
|
+
import { Result } from '../../utils/Result';
|
|
4
5
|
import * as THREE from 'three';
|
|
5
6
|
export declare class ControlsManager {
|
|
6
|
-
controls: OrbitControls | MapControls;
|
|
7
|
+
controls: OrbitControls | MapControls | null;
|
|
7
8
|
private camera;
|
|
8
9
|
private rendererDomElement;
|
|
9
10
|
private options;
|
|
10
11
|
constructor(camera: THREE.Camera, rendererDomElement: HTMLCanvasElement, options: SimpleViewerOptions);
|
|
11
|
-
|
|
12
|
+
setup(): Result<OrbitControls | MapControls>;
|
|
13
|
+
dispose(): void;
|
|
12
14
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PathTracingManager } from './PathTracingManager';
|
|
2
|
+
import { Result } from '../../utils/Result';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
interface EnvironmentMapManagerParams {
|
|
5
|
+
renderer: THREE.WebGLRenderer | null;
|
|
6
|
+
scene: THREE.Scene | null;
|
|
7
|
+
camera: THREE.Camera | null;
|
|
8
|
+
envMapUrl?: string;
|
|
9
|
+
usePathTracing: boolean;
|
|
10
|
+
pathTracingManager: PathTracingManager | null;
|
|
11
|
+
backgroundBlurriness?: number;
|
|
12
|
+
blurStrengthPathTracing?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class EnvironmentMapManager {
|
|
15
|
+
private renderer;
|
|
16
|
+
private scene;
|
|
17
|
+
private camera;
|
|
18
|
+
private envMapUrl?;
|
|
19
|
+
private usePathTracing;
|
|
20
|
+
private pathTracingManager;
|
|
21
|
+
private backgroundBlurriness;
|
|
22
|
+
private blurStrengthPathTracing;
|
|
23
|
+
private loadedTexture;
|
|
24
|
+
private pmremGenerator;
|
|
25
|
+
constructor(params: EnvironmentMapManagerParams);
|
|
26
|
+
setup(): Result<void>;
|
|
27
|
+
load(): Promise<Result<THREE.Texture>>;
|
|
28
|
+
private processPathTracingEnvironment;
|
|
29
|
+
updateEnvironment(): Result<void>;
|
|
30
|
+
dispose(): void;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { SimpleViewerOptions } from '../../types';
|
|
2
|
+
import { WebGLPathTracer } from '../importRaytracer';
|
|
3
|
+
import { Result } from '../../utils/Result';
|
|
2
4
|
import * as THREE from 'three';
|
|
3
5
|
export declare class PathTracingManager {
|
|
4
6
|
private renderer;
|
|
5
7
|
private scene;
|
|
6
8
|
private camera;
|
|
7
9
|
private isPathTracing;
|
|
8
|
-
ptRenderer:
|
|
10
|
+
ptRenderer: WebGLPathTracer | null;
|
|
9
11
|
private renderCount;
|
|
10
12
|
private maxSamples;
|
|
11
13
|
private _onComplete;
|
|
12
14
|
constructor(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera, options: SimpleViewerOptions, onComplete: (image: string) => void);
|
|
13
|
-
|
|
14
|
-
updatePathTracerRenderer(): void
|
|
15
|
+
setup(): Result<WebGLPathTracer>;
|
|
16
|
+
updatePathTracerRenderer(): Result<void>;
|
|
15
17
|
set onComplete(value: (image: string) => void);
|
|
16
18
|
get onComplete(): (image: string) => void;
|
|
17
19
|
startPathTracing(): void;
|
|
@@ -19,4 +21,5 @@ export declare class PathTracingManager {
|
|
|
19
21
|
private animatePathTracing;
|
|
20
22
|
saveScreenshot(): void;
|
|
21
23
|
resetForStandardRender(): void;
|
|
24
|
+
dispose(): void;
|
|
22
25
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { SimpleViewerOptions } from '../../types';
|
|
2
|
+
import { Result } from '../../utils/Result';
|
|
2
3
|
import * as THREE from 'three';
|
|
3
4
|
export declare class RendererManager {
|
|
4
|
-
renderer: THREE.WebGLRenderer;
|
|
5
|
+
renderer: THREE.WebGLRenderer | null;
|
|
5
6
|
private options;
|
|
6
7
|
constructor(options: SimpleViewerOptions);
|
|
8
|
+
setup(): Result<THREE.WebGLRenderer>;
|
|
9
|
+
private isWebGLSupported;
|
|
10
|
+
dispose(): void;
|
|
7
11
|
}
|
|
@@ -15,9 +15,9 @@ export declare class SceneManager {
|
|
|
15
15
|
private sceneInitializer;
|
|
16
16
|
readonly pathTracingManager: PathTracingManager | null;
|
|
17
17
|
private animationManager;
|
|
18
|
+
private environmentMapManager;
|
|
18
19
|
constructor(threeBase: THREEBase, object: THREE.Object3D | null, options: SimpleViewerOptions, setRenderCompleteImage: (image: string | null) => void);
|
|
19
20
|
onStartRendering(): void;
|
|
20
|
-
private loadEnvironmentMap;
|
|
21
21
|
getSceneElements(): {
|
|
22
22
|
scene: THREE.Scene;
|
|
23
23
|
camera: THREE.Camera;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
export declare const updateSize: (renderer: THREE.WebGLRenderer, camera: THREE.
|
|
3
|
+
export declare const updateSize: (renderer: THREE.WebGLRenderer, camera: THREE.Camera, mountRef: React.RefObject<HTMLDivElement>, scene: THREE.Scene) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum ErrorCode {
|
|
2
|
+
SCENE_INIT_FAILED = "SCENE_INIT_FAILED",
|
|
3
|
+
RENDERER_INIT_FAILED = "RENDERER_INIT_FAILED",
|
|
4
|
+
CAMERA_INIT_FAILED = "CAMERA_INIT_FAILED",
|
|
5
|
+
WEBGL_NOT_SUPPORTED = "WEBGL_NOT_SUPPORTED",
|
|
6
|
+
MODEL_LOAD_FAILED = "MODEL_LOAD_FAILED",
|
|
7
|
+
TEXTURE_LOAD_FAILED = "TEXTURE_LOAD_FAILED",
|
|
8
|
+
RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
|
|
9
|
+
INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
|
|
10
|
+
RENDER_ERROR = "RENDER_ERROR",
|
|
11
|
+
COMPONENT_NOT_MOUNTED = "COMPONENT_NOT_MOUNTED",
|
|
12
|
+
UNKNOWN = "UNKNOWN"
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorCode } from './ErrorCode';
|
|
2
|
+
export interface ErrorContext {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export declare class ThreeViewerError extends Error {
|
|
6
|
+
readonly code: ErrorCode;
|
|
7
|
+
readonly context?: ErrorContext | undefined;
|
|
8
|
+
readonly timestamp: Date;
|
|
9
|
+
constructor(message: string, code: ErrorCode, context?: ErrorContext | undefined);
|
|
10
|
+
static fromError(error: unknown, code: ErrorCode, context?: ErrorContext): ThreeViewerError;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class TypedEventEmitter<T extends Record<string, any>> {
|
|
2
|
+
private listeners;
|
|
3
|
+
on<K extends keyof T>(event: K, listener: (data: T[K]) => void): () => void;
|
|
4
|
+
emit<K extends keyof T>(event: K, data: T[K]): void;
|
|
5
|
+
once<K extends keyof T>(event: K, listener: (data: T[K]) => void): () => void;
|
|
6
|
+
removeAllListeners(event?: keyof T): void;
|
|
7
|
+
listenerCount(event: keyof T): number;
|
|
8
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ThreeViewerError } from '../errors';
|
|
2
|
+
import { SimpleViewerHandle } from '../SimpleViewer';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
export interface ViewerEventMap {
|
|
5
|
+
'initialized': {
|
|
6
|
+
viewer: SimpleViewerHandle;
|
|
7
|
+
};
|
|
8
|
+
'disposed': {
|
|
9
|
+
viewer: SimpleViewerHandle;
|
|
10
|
+
};
|
|
11
|
+
'model:loading': {
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
'model:loaded': {
|
|
15
|
+
model: THREE.Object3D;
|
|
16
|
+
loadTime: number;
|
|
17
|
+
};
|
|
18
|
+
'model:error': {
|
|
19
|
+
error: ThreeViewerError;
|
|
20
|
+
url: string;
|
|
21
|
+
};
|
|
22
|
+
'render:start': {
|
|
23
|
+
frame: number;
|
|
24
|
+
};
|
|
25
|
+
'render:complete': {
|
|
26
|
+
frame: number;
|
|
27
|
+
renderTime: number;
|
|
28
|
+
};
|
|
29
|
+
'screenshot:captured': {
|
|
30
|
+
dataUrl: string;
|
|
31
|
+
};
|
|
32
|
+
'controls:change': {
|
|
33
|
+
type: string;
|
|
34
|
+
camera: THREE.Camera;
|
|
35
|
+
};
|
|
36
|
+
'object:selected': {
|
|
37
|
+
object: THREE.Object3D;
|
|
38
|
+
};
|
|
39
|
+
'error': {
|
|
40
|
+
error: ThreeViewerError;
|
|
41
|
+
};
|
|
42
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { default as SimpleViewer } from './SimpleViewer';
|
|
1
|
+
export { default as SimpleViewer, type SimpleViewerHandle } from './SimpleViewer';
|
|
2
2
|
export { type SimpleViewerProps } from './types';
|
|
3
3
|
export { type SimpleViewerOptions } from './types';
|
|
4
4
|
export { default as defaultOptions } from './defaultOptions';
|
|
5
|
+
export { TypedEventEmitter } from './events';
|
|
6
|
+
export type { ViewerEventMap } from './events';
|