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

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.44",
3
+ "version": "1.0.0-alpha.46",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/types/Viewer.d.ts CHANGED
@@ -20,8 +20,17 @@ export declare class Viewer extends EventEmitter {
20
20
  static createFullscreenTriangle(): BufferGeometry<import("three").NormalBufferAttributes>;
21
21
  static findChild<T extends Object3D>(node: T, path: string): T;
22
22
  static getChildByName<T extends Object3D>(node: T, name: string): T;
23
- static getObject<T extends Object3D>(node: T, filter: (value: T) => any): any;
24
- static getObjects<T extends Object3D>(node: T, filter: (value: T) => any): any[];
23
+ static getObject<T extends Object3D>(node: T, filter: (value: T) => any, group?: boolean): any;
24
+ static __emtpyObject: {};
25
+ static _getObjectValue<T extends Object & {
26
+ name: string;
27
+ }>(object: any, name?: string, group?: boolean): T | T[];
28
+ static getMaterial<T extends Material>(node: Object3D): T[];
29
+ static getMaterial<T extends Material>(node: Object3D, name: string): T;
30
+ static getTexture<T extends Texture>(node: Object3D): T[];
31
+ static getTexture<T extends Texture>(node: Object3D, name: string): T;
32
+ static getMesh<T extends Mesh>(node: Object3D): T[];
33
+ static getMesh<T extends Mesh>(node: Object3D, name: string): T;
25
34
  static fullscreenMesh: Mesh;
26
35
  static fullscreenCamera: OrthographicCamera;
27
36
  private _root;
@@ -135,8 +144,8 @@ export declare class Viewer extends EventEmitter {
135
144
  addNode<T, K extends __C<T>>(object: T | K & __C<T>, props?: __P<T, K>): T;
136
145
  removeNode(node: Object3D): void;
137
146
  activeNode(node: Object3D, active: boolean): Object3D<import("three").Object3DEventMap>;
138
- createRenderTarget(width: number, height: number, nearest?: boolean, floatType?: boolean | TextureDataType, msaa?: number, mipmap?: boolean): WebGLRenderTarget<Texture>;
139
- createCubeRenderTarget(size: number, nearest?: boolean, floatType?: boolean | TextureDataType, msaa?: number, mipmap?: boolean): WebGLCubeRenderTarget;
147
+ createRenderTarget(width: number, height: number, nearest?: boolean, floatType?: boolean | TextureDataType, msaa?: number, mipmap?: boolean, depth?: boolean): WebGLRenderTarget<Texture>;
148
+ createCubeRenderTarget(size: number, nearest?: boolean, floatType?: boolean | TextureDataType, msaa?: number, mipmap?: boolean, depth?: boolean): WebGLCubeRenderTarget;
140
149
  createDataTexture(data: BufferSource, width: number, height: number, floatType?: boolean, nearest?: boolean): DataTexture;
141
150
  /**
142
151
  * 传送门,得到一个全新的场景
@@ -11,7 +11,7 @@ export interface LoadProperties {
11
11
  export declare abstract class aLoader {
12
12
  manager: ResourceManager;
13
13
  static _texKeys: string[];
14
- static _setMeshData(node: Object3D): Object3D<import("three").Object3DEventMap>;
14
+ static _setUserData(node: Object3D): Object3D<import("three").Object3DEventMap>;
15
15
  constructor(manager: ResourceManager);
16
16
  abstract extension: string[];
17
17
  abstract load(props: LoadProperties): void;
@@ -66,7 +66,7 @@ export declare class FreelookVirtualCamera extends VirtualCamera {
66
66
  private _calculatePanDelta;
67
67
  private _calculateTargetLookAt;
68
68
  private _calculateTargetSpringArm;
69
- gotoPOI({ duration, easing, springLength, theta, phi, lookAt, fov, smoothing, rotateSmoothing, }: {
69
+ gotoPOI({ duration, easing, springLength, theta, phi, lookAt, fov, smoothing, rotateSmoothing }: {
70
70
  duration?: number;
71
71
  easing?: EasingFunction;
72
72
  springLength?: number;
@@ -0,0 +1,48 @@
1
+ import { Component } from "../Component";
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: PerformanceMonitor) => void;
19
+ /** When performance is lower than the upper bound (bad!) */
20
+ onDecline?: (monitor: PerformanceMonitor) => void;
21
+ /** Incline and decline will change the factor, this will trigger when that happened */
22
+ onChange?: (monitor: PerformanceMonitor) => 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: PerformanceMonitor) => void;
25
+ };
26
+ type PerformanceMonitorSubscriber = {
27
+ onIncline?: (monitor: PerformanceMonitor) => void;
28
+ /** When performance is lower than the upper bound (bad!) */
29
+ onDecline?: (monitor: PerformanceMonitor) => void;
30
+ /** Incline and decline will change the factor, this will trigger when that happened */
31
+ onChange?: (monitor: PerformanceMonitor) => 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: PerformanceMonitor) => void;
34
+ };
35
+ export declare class PerformanceMonitor extends Component {
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 +1,2 @@
1
1
  export { Reflector } from "./Reflector";
2
+ export { PerformanceMonitor } from "./PerformanceMonitor";
@@ -13,12 +13,14 @@ export declare class EnvironmentPlugin extends Plugin {
13
13
  private _mergeInfo;
14
14
  private _debug;
15
15
  private _debugNode;
16
+ private _elapsed;
16
17
  get debug(): boolean;
17
18
  set debug(v: boolean);
18
19
  performance: number;
19
20
  envMapIntensity: number;
20
21
  reflectExposure: number;
21
22
  reflectBlurIntensity: number;
23
+ interval: number;
22
24
  constructor({ envMap, scene, near, far, layer, resolution, floatType, position, }?: {
23
25
  envMap?: Texture;
24
26
  scene?: Scene | Object3D;
@@ -30,5 +32,6 @@ export declare class EnvironmentPlugin extends Plugin {
30
32
  floatType?: boolean | TextureDataType;
31
33
  position?: Vector3;
32
34
  });
33
- onRender(): void;
35
+ onRender(dt: number): void;
36
+ private _renderFrame;
34
37
  }