@xviewer.js/core 1.0.0-alpha.46 → 1.0.0-alpha.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xviewer.js/core",
3
- "version": "1.0.0-alpha.46",
3
+ "version": "1.0.0-alpha.48",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/types/Viewer.d.ts CHANGED
@@ -77,6 +77,8 @@ export declare class Viewer extends EventEmitter {
77
77
  };
78
78
  get rootRotated(): boolean;
79
79
  get input(): DeviceInput;
80
+ get targetFrameRate(): number;
81
+ set targetFrameRate(v: number);
80
82
  constructor({ root, canvas, autoStart, autoResize, shadows, camera, targetFrameRate, colorSpace, toneMapping, toneMappingExposure, maxDPR, path, resourcePath, dracoPath, orientation, loader, tasker, ...webglOpts }?: {
81
83
  root?: HTMLElement;
82
84
  canvas?: HTMLCanvasElement;
@@ -1,2 +1 @@
1
1
  export { Reflector } from "./Reflector";
2
- export { PerformanceMonitor } from "./PerformanceMonitor";
@@ -1,6 +1,6 @@
1
1
  import { WebGLRenderTarget } from "three";
2
2
  export interface MergeInfo {
3
- performance: number;
3
+ quality: number;
4
4
  envMapTarget: WebGLRenderTarget;
5
5
  envMapIntensity: number;
6
6
  blurIntensity: number;
@@ -2,10 +2,11 @@ import { OrthographicCamera, ShaderMaterial, Vector3, WebGLRenderTarget } from "
2
2
  export declare const LOD_MIN = 4;
3
3
  export declare const _flatCamera: OrthographicCamera;
4
4
  export declare const _axisDirections: Vector3[];
5
- export declare const _Performance: {
6
- HIGH: number;
7
- MEDIUM: number;
5
+ export declare const _Quality: {
8
6
  LOW: number;
7
+ MEDIUM: number;
8
+ HIGH: number;
9
+ ULTRA: number;
9
10
  };
10
11
  export declare function _setViewport(target: WebGLRenderTarget, x: number, y: number, width: number, height: number): void;
11
12
  export declare function _getCommonVertexShader(): string;
@@ -1,10 +1,11 @@
1
1
  import { Object3D, Scene, Texture, TextureDataType, Vector3 } from "three";
2
2
  import { Plugin } from "../Plugin";
3
3
  export declare class EnvironmentPlugin extends Plugin {
4
- static Performance: {
5
- HIGH: number;
6
- MEDIUM: number;
4
+ static readonly Quality: {
7
5
  LOW: number;
6
+ MEDIUM: number;
7
+ HIGH: number;
8
+ ULTRA: number;
8
9
  };
9
10
  private _scene;
10
11
  private _cubeCamera;
@@ -16,11 +17,12 @@ export declare class EnvironmentPlugin extends Plugin {
16
17
  private _elapsed;
17
18
  get debug(): boolean;
18
19
  set debug(v: boolean);
19
- performance: number;
20
+ quality: number;
20
21
  envMapIntensity: number;
21
22
  reflectExposure: number;
22
23
  reflectBlurIntensity: number;
23
24
  interval: number;
25
+ manual: boolean;
24
26
  constructor({ envMap, scene, near, far, layer, resolution, floatType, position, }?: {
25
27
  envMap?: Texture;
26
28
  scene?: Scene | Object3D;
@@ -33,5 +35,6 @@ export declare class EnvironmentPlugin extends Plugin {
33
35
  position?: Vector3;
34
36
  });
35
37
  onRender(dt: number): void;
38
+ manualFrame(): void;
36
39
  private _renderFrame;
37
40
  }
@@ -0,0 +1,48 @@
1
+ import { Plugin } from "../Plugin";
2
+ type PerformanceMonitorProps = {
3
+ /** How much time in milliseconds to collect an average fps, 250 */
4
+ ms?: number;
5
+ /** How many interations of averages to collect, 10 */
6
+ iterations?: number;
7
+ /** The percentage of iterations that are matched against the lower and upper bounds, 0.75 */
8
+ threshold?: number;
9
+ /** A function that receive the max device refreshrate to determine lower and upper bounds which create a margin where neither incline nor decline should happen, (refreshrate) => (refreshrate > 90 ? [50, 90] : [50, 60]) */
10
+ bounds?: (refreshrate: number) => [lower: number, upper: number];
11
+ /** How many times it can inline or decline before onFallback is called, Infinity */
12
+ flipflops?: number;
13
+ /** The factor increases and decreases between 0-1, this prop sets the starting value, 0.5 */
14
+ factor?: number;
15
+ /** The step that gets added or subtracted to or from the factor on each incline/decline, 0.1 */
16
+ step?: number;
17
+ /** When performance is higher than the upper bound (good!) */
18
+ onIncline?: (monitor: PerformanceMonitorPlugin) => void;
19
+ /** When performance is lower than the upper bound (bad!) */
20
+ onDecline?: (monitor: PerformanceMonitorPlugin) => void;
21
+ /** Incline and decline will change the factor, this will trigger when that happened */
22
+ onChange?: (monitor: PerformanceMonitorPlugin) => void;
23
+ /** Called after when the number of flipflops is reached, it indicates instability, use the function to set a fixed baseline */
24
+ onFallback?: (monitor: PerformanceMonitorPlugin) => void;
25
+ };
26
+ type PerformanceMonitorSubscriber = {
27
+ onIncline?: (monitor: PerformanceMonitorPlugin) => void;
28
+ /** When performance is lower than the upper bound (bad!) */
29
+ onDecline?: (monitor: PerformanceMonitorPlugin) => void;
30
+ /** Incline and decline will change the factor, this will trigger when that happened */
31
+ onChange?: (monitor: PerformanceMonitorPlugin) => void;
32
+ /** Called after when the number of flipflops is reached, it indicates instability, use the function to set a fixed baseline */
33
+ onFallback?: (monitor: PerformanceMonitorPlugin) => void;
34
+ };
35
+ export declare class PerformanceMonitorPlugin extends Plugin {
36
+ fps: number;
37
+ index: number;
38
+ factor: number;
39
+ flipped: number;
40
+ refreshrate: number;
41
+ fallback: boolean;
42
+ frames: any[];
43
+ averages: any[];
44
+ subscriptions: Map<any, any>;
45
+ subscribe(subscriber: PerformanceMonitorSubscriber): void;
46
+ constructor({ iterations, ms, threshold, step, factor: _factor, flipflops, bounds, onIncline, onDecline, onChange, onFallback, }: PerformanceMonitorProps);
47
+ }
48
+ export {};
@@ -1,3 +1,4 @@
1
1
  export { DebugPlugin } from "./DebugPlugin";
2
2
  export { EnvironmentPlugin } from "./EnvironmentPlugin";
3
3
  export { BoxProjectionPlugin } from "./BoxProjectionPlugin";
4
+ export { PerformanceMonitorPlugin } from "./PerformanceMonitorPlugin";