@galacean/engine-xr 1.3.0-alpha.2 → 1.3.0-beta.5
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/browser.js +201 -147
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +201 -147
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +201 -147
- package/dist/module.js +201 -149
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/XRManagerExtended.d.ts +7 -64
- package/types/feature/trackable/XRTrackableFeature.d.ts +1 -2
- package/types/index.d.ts +4 -0
- package/types/loader/XRReferenceImageDecoder.d.ts +5 -0
- package/types/loader/XRReferenceImageLoader.d.ts +5 -0
- package/types/session/XRSessionManager.d.ts +11 -0
- package/types/session/XRSessionState.d.ts +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/engine-xr",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-beta.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"types/**/*"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@galacean/engine-design": "1.3.0-
|
|
27
|
-
"@galacean/engine": "1.3.0-
|
|
26
|
+
"@galacean/engine-design": "1.3.0-beta.5",
|
|
27
|
+
"@galacean/engine": "1.3.0-beta.5"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@galacean/engine": "1.3.0-
|
|
30
|
+
"@galacean/engine": "1.3.0-beta.5"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"b:types": "tsc"
|
|
@@ -1,59 +1,12 @@
|
|
|
1
|
-
import { Entity
|
|
1
|
+
import { Entity } from "@galacean/engine";
|
|
2
2
|
import { XRFeature } from "./feature/XRFeature";
|
|
3
3
|
import { XRCameraManager } from "./feature/camera/XRCameraManager";
|
|
4
4
|
import { XRInputManager } from "./input/XRInputManager";
|
|
5
5
|
import { XRSessionManager } from "./session/XRSessionManager";
|
|
6
6
|
import { XRSessionMode } from "./session/XRSessionMode";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare class XRManagerExtended extends XRManager {
|
|
11
|
-
/** Input manager for XR. */
|
|
12
|
-
inputManager: XRInputManager;
|
|
13
|
-
/** Session manager for XR. */
|
|
14
|
-
sessionManager: XRSessionManager;
|
|
15
|
-
/** Camera manager for XR. */
|
|
16
|
-
cameraManager: XRCameraManager;
|
|
17
|
-
private _origin;
|
|
18
|
-
private _features;
|
|
19
|
-
/**
|
|
20
|
-
* The current origin of XR space.
|
|
21
|
-
* @remarks The connection point between the virtual world and the real world ( XR Space )
|
|
22
|
-
*/
|
|
23
|
-
get origin(): Entity;
|
|
24
|
-
set origin(value: Entity);
|
|
25
|
-
/**
|
|
26
|
-
* Check if the specified feature is supported.
|
|
27
|
-
* @param type - The type of the feature
|
|
28
|
-
* @returns If the feature is supported
|
|
29
|
-
*/
|
|
30
|
-
isSupportedFeature<T extends XRFeature>(feature: TFeatureConstructor<T>): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Add feature based on the xr feature type.
|
|
33
|
-
* @param type - The type of the feature
|
|
34
|
-
* @param args - The constructor params of the feature
|
|
35
|
-
* @returns The feature which has been added
|
|
36
|
-
*/
|
|
37
|
-
addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>): XRFeature | null;
|
|
38
|
-
/**
|
|
39
|
-
* Get feature which match the type.
|
|
40
|
-
* @param type - The type of the feature
|
|
41
|
-
* @returns The feature which match type
|
|
42
|
-
*/
|
|
43
|
-
getFeature<T extends XRFeature>(type: TFeatureConstructor<T>): T | null;
|
|
44
|
-
getFeatures<T extends XRFeature>(type: TFeatureConstructor<T>, out?: T[]): T[];
|
|
45
|
-
/**
|
|
46
|
-
* Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
|
|
47
|
-
* @param sessionMode - The mode of the session
|
|
48
|
-
* @param autoRun - Whether to automatically run the session, when `autoRun` is set to true, xr will start working immediately after initialization. Otherwise, you need to call `sessionManager.run` later to work.
|
|
49
|
-
* @returns A promise that resolves if the XR virtual world is entered, otherwise rejects
|
|
50
|
-
*/
|
|
51
|
-
enterXR(sessionMode: XRSessionMode, autoRun?: boolean): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Exit XR immersive mode, when you call this method, it will destroy the XR virtual world.
|
|
54
|
-
* @returns A promise that resolves if the XR virtual world is destroyed, otherwise rejects
|
|
55
|
-
*/
|
|
56
|
-
exitXR(): Promise<void>;
|
|
7
|
+
export interface IXRListener {
|
|
8
|
+
fn: (...args: any[]) => any;
|
|
9
|
+
destroyed?: boolean;
|
|
57
10
|
}
|
|
58
11
|
type TFeatureConstructor<T extends XRFeature> = new (xrManager: XRManagerExtended, ...args: any[]) => T;
|
|
59
12
|
type TFeatureConstructorArguments<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature> = T extends new (xrManager: XRManagerExtended, ...args: infer P) => XRFeature ? P : never;
|
|
@@ -65,23 +18,14 @@ declare module "@galacean/engine" {
|
|
|
65
18
|
sessionManager: XRSessionManager;
|
|
66
19
|
/** Camera manager for XR. */
|
|
67
20
|
cameraManager: XRCameraManager;
|
|
21
|
+
/** Initialized features. */
|
|
22
|
+
get features(): XRFeature[];
|
|
68
23
|
/**
|
|
69
24
|
* The current origin of XR space.
|
|
70
25
|
* @remarks The connection point between the virtual world and the real world ( XR Space )
|
|
71
26
|
*/
|
|
72
27
|
get origin(): Entity;
|
|
73
28
|
set origin(value: Entity);
|
|
74
|
-
/**
|
|
75
|
-
* Get all initialized features at this moment.
|
|
76
|
-
* @param type - The type of the feature
|
|
77
|
-
*/
|
|
78
|
-
getFeatures<T extends XRFeature>(type: TFeatureConstructor<T>): T[];
|
|
79
|
-
/**
|
|
80
|
-
* Get all initialized features at this moment.
|
|
81
|
-
* @param type - The type of the feature
|
|
82
|
-
* @param out - Save all features in `out`
|
|
83
|
-
*/
|
|
84
|
-
getFeatures<T extends XRFeature>(type: TFeatureConstructor<T>, out: T[]): T[];
|
|
85
29
|
/**
|
|
86
30
|
* Check if the specified feature is supported.
|
|
87
31
|
* @param type - The type of the feature
|
|
@@ -94,14 +38,13 @@ declare module "@galacean/engine" {
|
|
|
94
38
|
* @param args - The constructor params of the feature
|
|
95
39
|
* @returns The feature which has been added
|
|
96
40
|
*/
|
|
97
|
-
addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>):
|
|
41
|
+
addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>): InstanceType<T> | null;
|
|
98
42
|
/**
|
|
99
43
|
* Get feature which match the type.
|
|
100
44
|
* @param type - The type of the feature
|
|
101
45
|
* @returns The feature which match type
|
|
102
46
|
*/
|
|
103
47
|
getFeature<T extends XRFeature>(type: TFeatureConstructor<T>): T | null;
|
|
104
|
-
getFeatures<T extends XRFeature>(type: TFeatureConstructor<T>, out?: T[]): T[];
|
|
105
48
|
/**
|
|
106
49
|
* Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
|
|
107
50
|
* @param sessionMode - The mode of the session
|
|
@@ -6,7 +6,7 @@ import { XRTracked } from "./XRTracked";
|
|
|
6
6
|
/**
|
|
7
7
|
* The base class of XR trackable manager.
|
|
8
8
|
*/
|
|
9
|
-
export declare abstract class XRTrackableFeature<T extends XRTracked, K extends XRRequestTracking<T>> extends XRFeature<IXRTrackablePlatformFeature<T, K>> {
|
|
9
|
+
export declare abstract class XRTrackableFeature<T extends XRTracked = XRTracked, K extends XRRequestTracking<T> = XRRequestTracking<T>> extends XRFeature<IXRTrackablePlatformFeature<T, K>> {
|
|
10
10
|
protected static _uuid: number;
|
|
11
11
|
protected _requestTrackings: K[];
|
|
12
12
|
protected _tracked: T[];
|
|
@@ -28,7 +28,6 @@ export declare abstract class XRTrackableFeature<T extends XRTracked, K extends
|
|
|
28
28
|
_onUpdate(): void;
|
|
29
29
|
_onSessionStop(): void;
|
|
30
30
|
_onSessionExit(): void;
|
|
31
|
-
_onDestroy(): void;
|
|
32
31
|
protected _addRequestTracking(requestTracking: K): void;
|
|
33
32
|
protected _removeRequestTracking(requestTracking: K): void;
|
|
34
33
|
protected _removeAllRequestTrackings(): void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import "./XRManagerExtended";
|
|
2
2
|
export { XRPose } from "./XRPose";
|
|
3
3
|
export { XRFeature } from "./feature/XRFeature";
|
|
4
|
+
export { XRTrackableFeature } from "./feature/trackable/XRTrackableFeature";
|
|
5
|
+
export { XRTracked } from "./feature/trackable/XRTracked";
|
|
4
6
|
export { XRCameraManager } from "./feature/camera/XRCameraManager";
|
|
5
7
|
export { TrackableType } from "./feature/hitTest/TrackableType";
|
|
6
8
|
export { XRHitResult } from "./feature/hitTest/XRHitResult";
|
|
@@ -26,3 +28,5 @@ export { XRFeatureType } from "./feature/XRFeatureType";
|
|
|
26
28
|
export { XRRequestTrackingState } from "./feature/trackable/XRRequestTrackingState";
|
|
27
29
|
export { XRInputEventType } from "./input/XRInputEventType";
|
|
28
30
|
export { XRTargetRayMode } from "./input/XRTargetRayMode";
|
|
31
|
+
export * from "./loader/XRReferenceImageDecoder";
|
|
32
|
+
export * from "./loader/XRReferenceImageLoader";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BufferReader, Engine } from "@galacean/engine";
|
|
2
|
+
import { XRReferenceImage } from "../feature/trackable/image/XRReferenceImage";
|
|
3
|
+
export declare class XRReferenceImageDecoder {
|
|
4
|
+
static decode(engine: Engine, bufferReader: BufferReader): Promise<XRReferenceImage>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AssetPromise, Loader, LoadItem, ResourceManager } from "@galacean/engine";
|
|
2
|
+
import { XRReferenceImage } from "../feature/trackable/image/XRReferenceImage";
|
|
3
|
+
export declare class XRReferenceImageLoader extends Loader<XRReferenceImage> {
|
|
4
|
+
load(item: LoadItem, resourceManager: ResourceManager): AssetPromise<XRReferenceImage>;
|
|
5
|
+
}
|
|
@@ -11,6 +11,7 @@ export declare class XRSessionManager {
|
|
|
11
11
|
private _rhi;
|
|
12
12
|
private _raf;
|
|
13
13
|
private _caf;
|
|
14
|
+
private _listeners;
|
|
14
15
|
/**
|
|
15
16
|
* The current session mode( AR or VR ).
|
|
16
17
|
*/
|
|
@@ -41,5 +42,15 @@ export declare class XRSessionManager {
|
|
|
41
42
|
* Stop the session.
|
|
42
43
|
*/
|
|
43
44
|
stop(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Add a listening function for session state changes.
|
|
47
|
+
* @param listener - The listening function
|
|
48
|
+
*/
|
|
49
|
+
addStateChangedListener(listener: (state: XRSessionState) => void): void;
|
|
50
|
+
/**
|
|
51
|
+
* Remove a listening function of session state changes.
|
|
52
|
+
* @param listener - The listening function
|
|
53
|
+
*/
|
|
54
|
+
removeStateChangedListener(listener: (state: XRSessionState) => void): void;
|
|
44
55
|
private _onSessionExit;
|
|
45
56
|
}
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
export declare enum XRSessionState {
|
|
5
5
|
/** Not initialized. */
|
|
6
6
|
None = 0,
|
|
7
|
+
/** Initializing session. */
|
|
8
|
+
Initializing = 1,
|
|
7
9
|
/** Initialized but not started. */
|
|
8
|
-
Initialized =
|
|
10
|
+
Initialized = 2,
|
|
9
11
|
/** Running. */
|
|
10
|
-
Running =
|
|
12
|
+
Running = 3,
|
|
11
13
|
/** Paused. */
|
|
12
|
-
Paused =
|
|
14
|
+
Paused = 4
|
|
13
15
|
}
|