@xviewer.js/core 1.0.4-alpha.0 → 1.0.4-alpha.1
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/main.cjs +3259 -3211
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +3250 -3205
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
- package/types/Component.d.ts +12 -8
- package/types/ComponentManager.d.ts +10 -5
- package/types/ComponentScheduler.d.ts +3 -3
- package/types/Context.d.ts +6 -0
- package/types/DeviceInput.d.ts +22 -11
- package/types/PropertyManager.d.ts +3 -11
- package/types/TaskManager.d.ts +4 -4
- package/types/Viewer.d.ts +77 -63
- package/types/WebGL.d.ts +1 -1
- package/types/asset/Loader.d.ts +3 -3
- package/types/asset/ResourceManager.d.ts +4 -1
- package/types/cinestation/FreelookVirtualCamera.d.ts +2 -1
- package/types/cinestation/VirtualCamera.d.ts +2 -0
- package/types/components/BoxProjection.d.ts +15 -0
- package/types/components/DropFile.d.ts +29 -0
- package/types/components/Environment.d.ts +37 -0
- package/types/components/FreelookVirtualCamera.d.ts +110 -0
- package/types/components/PerformanceMonitor.d.ts +48 -0
- package/types/components/Reflector.d.ts +6 -5
- package/types/components/RenderTexture.d.ts +7 -0
- package/types/components/Renderer.d.ts +6 -0
- package/types/components/UI.d.ts +30 -0
- package/types/components/index.d.ts +8 -1
- package/types/enums/index.d.ts +9 -0
- package/types/index.d.ts +2 -4
- package/types/loaders/KTX2Loader.d.ts +6 -0
- package/types/loaders/SVGLoader.d.ts +8 -0
- package/types/loaders/index.d.ts +2 -0
- package/types/materials/ReflectorMaterial.d.ts +3 -1
- package/types/plugins/BoxProjection.d.ts +2 -2
- package/types/plugins/DropFile.d.ts +16 -7
- package/types/plugins/Environment.d.ts +2 -2
- package/types/plugins/Exporter.d.ts +7 -0
- package/types/plugins/PerformanceMonitor.d.ts +2 -2
- package/types/plugins/UI.d.ts +2 -2
- package/types/plugins/index.d.ts +0 -4
- package/types/types.d.ts +6 -11
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Object3D, Quaternion, Vector2, Vector3 } from "three";
|
|
2
|
+
import { Component } from "../Component";
|
|
3
|
+
export declare class FreelookVirtualCamera extends Component<Object3D & {
|
|
4
|
+
isCamera?: boolean;
|
|
5
|
+
}> {
|
|
6
|
+
static loc0: Vector2;
|
|
7
|
+
static loc1: Vector2;
|
|
8
|
+
static center: Vector2;
|
|
9
|
+
static preCenter: Vector2;
|
|
10
|
+
static panDelta: Vector2;
|
|
11
|
+
static rotateDelta: Vector2;
|
|
12
|
+
static posDelta: Vector3;
|
|
13
|
+
static lookAtOffset: Vector3;
|
|
14
|
+
static xAxis: Vector3;
|
|
15
|
+
static yAxis: Vector3;
|
|
16
|
+
static quat: Quaternion;
|
|
17
|
+
private _button;
|
|
18
|
+
private _touchID;
|
|
19
|
+
private _preLoc0;
|
|
20
|
+
private _preLoc1;
|
|
21
|
+
private _spherical;
|
|
22
|
+
private _lookAt;
|
|
23
|
+
private _offset;
|
|
24
|
+
private _fov;
|
|
25
|
+
private _near;
|
|
26
|
+
private _far;
|
|
27
|
+
private _tempSmoothing;
|
|
28
|
+
private _tempRotateSmoothing;
|
|
29
|
+
private _targetPosition;
|
|
30
|
+
private _targetTheta;
|
|
31
|
+
private _targetPhi;
|
|
32
|
+
private _targetSpringLength;
|
|
33
|
+
private _targetFov;
|
|
34
|
+
private _targetNear;
|
|
35
|
+
private _targetFar;
|
|
36
|
+
private _targetLookAt;
|
|
37
|
+
private _targetOffset;
|
|
38
|
+
private _finalLookAt;
|
|
39
|
+
name: string;
|
|
40
|
+
forbidX: boolean;
|
|
41
|
+
forbidY: boolean;
|
|
42
|
+
forbidZ: boolean;
|
|
43
|
+
forbidPanX: boolean;
|
|
44
|
+
forbidPanY: boolean;
|
|
45
|
+
forbitPanOffsetY: boolean;
|
|
46
|
+
panSpeed: number;
|
|
47
|
+
rotateSpeed: number;
|
|
48
|
+
smoothing: number;
|
|
49
|
+
rotateSmoothing: number;
|
|
50
|
+
phiMin: number;
|
|
51
|
+
phiMax: number;
|
|
52
|
+
thetaMin: number;
|
|
53
|
+
thetaMax: number;
|
|
54
|
+
distanceMin: number;
|
|
55
|
+
distanceMax: number;
|
|
56
|
+
get lookAt(): Vector3;
|
|
57
|
+
set lookAt(v: Vector3);
|
|
58
|
+
get offset(): Vector2;
|
|
59
|
+
set offset(v: Vector2);
|
|
60
|
+
get springLength(): number;
|
|
61
|
+
set springLength(v: number);
|
|
62
|
+
get theta(): number;
|
|
63
|
+
set theta(v: number);
|
|
64
|
+
get phi(): number;
|
|
65
|
+
set phi(v: number);
|
|
66
|
+
get fov(): number;
|
|
67
|
+
set fov(v: number);
|
|
68
|
+
get near(): number;
|
|
69
|
+
set near(v: number);
|
|
70
|
+
get far(): number;
|
|
71
|
+
set far(v: number);
|
|
72
|
+
private _onMultiTouch;
|
|
73
|
+
private _onSingleTouch;
|
|
74
|
+
private _onCalculatePan;
|
|
75
|
+
private _onDragging;
|
|
76
|
+
private _onDistanceScale;
|
|
77
|
+
private _lerpCamera;
|
|
78
|
+
private _syncCamera;
|
|
79
|
+
constructor();
|
|
80
|
+
onEnable(): void;
|
|
81
|
+
onDisable(): void;
|
|
82
|
+
reset(): void;
|
|
83
|
+
goto({ phi, theta, springLength, offset, lookAt, fov, near, far, smoothing, rotateSmoothing, }: {
|
|
84
|
+
phi?: number;
|
|
85
|
+
theta?: number;
|
|
86
|
+
springLength?: number;
|
|
87
|
+
lookAt?: Vector3;
|
|
88
|
+
offset?: Vector2;
|
|
89
|
+
fov?: number;
|
|
90
|
+
near?: number;
|
|
91
|
+
far?: number;
|
|
92
|
+
smoothing?: number;
|
|
93
|
+
rotateSmoothing?: number;
|
|
94
|
+
}): void;
|
|
95
|
+
update(dt: number): void;
|
|
96
|
+
private _onPointerDown;
|
|
97
|
+
private _onPointerUp;
|
|
98
|
+
private _onPointerMove;
|
|
99
|
+
private _onMouseWheel;
|
|
100
|
+
private _onTouchStart;
|
|
101
|
+
private _onTouchMove;
|
|
102
|
+
private _calculateDistanceScale;
|
|
103
|
+
private _calculateRotate;
|
|
104
|
+
private _calculatePanDelta;
|
|
105
|
+
private _calculateLookAtOffset;
|
|
106
|
+
private _setTargetLookAt;
|
|
107
|
+
private _setTargetRotation;
|
|
108
|
+
private _setTargetPosition;
|
|
109
|
+
private _setTargetSpringLength;
|
|
110
|
+
}
|
|
@@ -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,13 +1,14 @@
|
|
|
1
|
-
import { Matrix4, Vector3, WebGLRenderTarget } from "three";
|
|
1
|
+
import { Matrix4, Vector3, WebGLRenderTarget, Object3D } from "three";
|
|
2
2
|
import { Component } from "../Component";
|
|
3
3
|
export declare class Reflector extends Component {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
node: Object3D;
|
|
5
|
+
layerMask: number;
|
|
6
|
+
constructor({ resolution, clipBias, multisample, layerMask, normal, mipmap, }?: {
|
|
7
|
+
resolution?: number;
|
|
7
8
|
clipBias?: number;
|
|
8
9
|
multisample?: number;
|
|
9
10
|
normal?: Vector3;
|
|
10
|
-
|
|
11
|
+
layerMask?: number;
|
|
11
12
|
mipmap?: boolean;
|
|
12
13
|
});
|
|
13
14
|
getTextureMatrix: () => Matrix4;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderTargetOptions } from "three";
|
|
2
|
+
import { Component } from "../Component";
|
|
3
|
+
export declare class RenderTexture extends Component {
|
|
4
|
+
private _fbo;
|
|
5
|
+
get texture(): import("three").Texture;
|
|
6
|
+
constructor(width?: number, height?: number, options?: RenderTargetOptions);
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Vector2 } from "three";
|
|
2
|
+
import { Component } from "../Component";
|
|
3
|
+
export declare class UI extends Component {
|
|
4
|
+
static __loc0: Vector2;
|
|
5
|
+
static __loc1: Vector2;
|
|
6
|
+
static __panOffset: Vector2;
|
|
7
|
+
private _camera;
|
|
8
|
+
private _zoom;
|
|
9
|
+
private _targetZoom;
|
|
10
|
+
private _targetPosition;
|
|
11
|
+
private _button;
|
|
12
|
+
private _touchID;
|
|
13
|
+
private _preLoc0;
|
|
14
|
+
private _preLoc1;
|
|
15
|
+
get layerMask(): number;
|
|
16
|
+
set layerMask(v: number);
|
|
17
|
+
onLoad(): void;
|
|
18
|
+
onDestroy(): void;
|
|
19
|
+
private _onPointerDown;
|
|
20
|
+
private _onPointerUp;
|
|
21
|
+
private _onPointerMove;
|
|
22
|
+
private _onMouseWheel;
|
|
23
|
+
private _onTouchStart;
|
|
24
|
+
private _onTouchMove;
|
|
25
|
+
private _setTargetPosition;
|
|
26
|
+
private _calculatePanDelta;
|
|
27
|
+
update(dt: number): void;
|
|
28
|
+
resize(width: number, height: number): void;
|
|
29
|
+
render(dt: number): void;
|
|
30
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export { Reflector } from "./Reflector";
|
|
2
2
|
export { Animation } from "./Animation";
|
|
3
3
|
export { ContactShadows } from "./ContactShadows";
|
|
4
|
-
export { AccumulativeShadows, RandomizedLight } from "
|
|
4
|
+
export { AccumulativeShadows, RandomizedLight } from "./AccumulativeShadows";
|
|
5
5
|
export { Center } from "./Center";
|
|
6
|
+
export { Renderer } from "./Renderer";
|
|
7
|
+
export { RenderTexture } from "./RenderTexture";
|
|
8
|
+
export { FreelookVirtualCamera } from "./FreelookVirtualCamera";
|
|
9
|
+
export { Environment } from "./Environment";
|
|
10
|
+
export { BoxProjection } from "./BoxProjection";
|
|
11
|
+
export { PerformanceMonitor } from "./PerformanceMonitor";
|
|
12
|
+
export { DropFile } from "./DropFile";
|
package/types/index.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export * from "./base";
|
|
3
3
|
export * from "./loaders";
|
|
4
|
-
export * from "./cinestation";
|
|
5
4
|
export * from "./primitive";
|
|
6
5
|
export * from "./math";
|
|
7
6
|
export * from "./components";
|
|
8
7
|
export * from "./materials";
|
|
9
|
-
export * from "./plugins";
|
|
10
8
|
export * from "./Utils";
|
|
9
|
+
export * from "./enums";
|
|
11
10
|
export { Viewer } from "./Viewer";
|
|
11
|
+
export { Task } from "./Task";
|
|
12
12
|
export { Component } from "./Component";
|
|
13
|
-
export { Mount } from "./Mount";
|
|
14
13
|
export { SystemInfo } from "./SystemInfo";
|
|
15
14
|
export { ObjectInstance } from "./ObjectInstance";
|
|
16
15
|
export { property, PropertyManager } from "./PropertyManager";
|
|
17
16
|
export { dependencies, DependentMode } from "./ComponentManager";
|
|
18
17
|
export { DeviceInput } from "./DeviceInput";
|
|
19
|
-
export { Orientation } from "./enums/Orientation";
|
|
20
18
|
export { Loader, type LoadProperties } from "./asset/Loader";
|
|
21
19
|
export { ResourceManager, type AssetProperties } from "./asset/ResourceManager";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Loader, LoadProperties } from "../asset/Loader";
|
|
2
|
+
import { SVGLoader as SVGLoaderPrimitive } from "three/examples/jsm/loaders/SVGLoader.js";
|
|
3
|
+
export declare class SVGLoader extends Loader {
|
|
4
|
+
extension: string[];
|
|
5
|
+
load({ url, path, resourcePath, manager, onLoad, onProgress, onError, }: LoadProperties): void;
|
|
6
|
+
private _loader;
|
|
7
|
+
static Primitive: typeof SVGLoaderPrimitive;
|
|
8
|
+
}
|
package/types/loaders/index.d.ts
CHANGED
|
@@ -10,9 +10,11 @@ export declare class ReflectorMaterial extends ShaderMaterial {
|
|
|
10
10
|
[uniform: string]: IUniform<any>;
|
|
11
11
|
};
|
|
12
12
|
constructor({ reflector, ...parameters }: {
|
|
13
|
-
reflector: Reflector;
|
|
14
13
|
name?: string;
|
|
14
|
+
color?: Color;
|
|
15
15
|
opacity?: number;
|
|
16
|
+
reflector: Reflector;
|
|
17
|
+
reflectIntensity?: number;
|
|
16
18
|
transparent?: boolean;
|
|
17
19
|
depthWrite?: boolean;
|
|
18
20
|
roughness?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3, Vector4, WebGLProgramParametersWithUniforms } from "three";
|
|
2
|
-
import {
|
|
3
|
-
export declare class BoxProjection extends
|
|
2
|
+
import { Component } from "../Component";
|
|
3
|
+
export declare class BoxProjection extends Component {
|
|
4
4
|
private _center;
|
|
5
5
|
private _boxMin;
|
|
6
6
|
private _boxMax;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Component } from "../Component";
|
|
2
|
+
declare enum Mode {
|
|
3
|
+
BUFFER = 0,
|
|
4
|
+
BUFFER_RAW = 1,
|
|
5
|
+
URL = 2,
|
|
6
|
+
URL_RAW = 3
|
|
7
|
+
}
|
|
8
|
+
export declare class DropFile extends Component {
|
|
9
|
+
static readonly Mode: typeof Mode;
|
|
3
10
|
private _onLoad;
|
|
4
11
|
private _onError;
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
constructor({ onLoad, onError, extension, raw, }?: {
|
|
12
|
+
private _extension;
|
|
13
|
+
constructor({ onLoad, onError, extension }?: {
|
|
8
14
|
onLoad?: Function;
|
|
9
15
|
onError?: Function;
|
|
10
|
-
extension?:
|
|
11
|
-
|
|
16
|
+
extension?: {
|
|
17
|
+
[k: string]: Mode;
|
|
18
|
+
};
|
|
19
|
+
buffers?: string[];
|
|
12
20
|
});
|
|
13
21
|
onEnable(): void;
|
|
14
22
|
onDisable(): void;
|
|
@@ -18,3 +26,4 @@ export declare class DropFile extends Mount {
|
|
|
18
26
|
private _loadFiles;
|
|
19
27
|
private _loadFile;
|
|
20
28
|
}
|
|
29
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Object3D, Scene, Texture, TextureDataType, Vector3 } from "three";
|
|
2
|
-
import {
|
|
3
|
-
export declare class Environment extends
|
|
2
|
+
import { Component } from "../Component";
|
|
3
|
+
export declare class Environment extends Component {
|
|
4
4
|
static readonly Quality: {
|
|
5
5
|
LOW: number;
|
|
6
6
|
MEDIUM: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../Component";
|
|
2
2
|
type PerformanceMonitorProps = {
|
|
3
3
|
/** How much time in milliseconds to collect an average fps, 250 */
|
|
4
4
|
ms?: number;
|
|
@@ -32,7 +32,7 @@ type PerformanceMonitorSubscriber = {
|
|
|
32
32
|
/** Called after when the number of flipflops is reached, it indicates instability, use the function to set a fixed baseline */
|
|
33
33
|
onFallback?: (monitor: PerformanceMonitor) => void;
|
|
34
34
|
};
|
|
35
|
-
export declare class PerformanceMonitor extends
|
|
35
|
+
export declare class PerformanceMonitor extends Component {
|
|
36
36
|
fps: number;
|
|
37
37
|
index: number;
|
|
38
38
|
factor: number;
|
package/types/plugins/UI.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector2 } from "three";
|
|
2
|
-
import {
|
|
3
|
-
export declare class UI extends
|
|
2
|
+
import { Component } from "../Component";
|
|
3
|
+
export declare class UI extends Component {
|
|
4
4
|
static __loc0: Vector2;
|
|
5
5
|
static __loc1: Vector2;
|
|
6
6
|
static __panOffset: Vector2;
|
package/types/plugins/index.d.ts
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export type __Properties<T> = Omit<Partial<T>, __FunctionKeys<T>> & {
|
|
|
9
9
|
export type __C<T> = new (...args: any[]) => T;
|
|
10
10
|
export type __E = {
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
* The object's local scale.
|
|
13
|
+
*/
|
|
14
14
|
scale?: Vector3;
|
|
15
15
|
/**
|
|
16
16
|
* Object's local position.
|
|
@@ -23,7 +23,7 @@ export type __E = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Object's layer mask
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
layerMask?: number;
|
|
27
27
|
};
|
|
28
28
|
export type __P<T, K extends __C<T>> = __Properties<T> & __E & {
|
|
29
29
|
/**
|
|
@@ -43,18 +43,13 @@ export type __P<T, K extends __C<T>> = __Properties<T> & __E & {
|
|
|
43
43
|
*/
|
|
44
44
|
parent?: Object3D;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
debug?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Set as default camera, only valid for camera
|
|
46
|
+
* Set as default
|
|
51
47
|
*/
|
|
52
48
|
makeDefault?: boolean;
|
|
53
49
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @example ["top", "bottom", "left", "right", "near", "far", "bias", "width", "height"];
|
|
50
|
+
* Manually set the camera’s aspect ratio
|
|
56
51
|
*/
|
|
57
|
-
|
|
52
|
+
manual?: boolean;
|
|
58
53
|
};
|
|
59
54
|
export type __Comp<T, K extends __C<T>> = __Properties<T> & {
|
|
60
55
|
/**
|