@galacean/engine-xr 1.3.0-alpha.3 → 1.3.0-beta.6
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/session/XRSessionManager.d.ts +11 -0
- package/types/session/XRSessionState.d.ts +5 -3
- package/types/component/TrackedComponent.d.ts +0 -10
- package/types/component/XRHitTestObjectManager.d.ts +0 -0
- package/types/component/XRTrackedComponent.d.ts +0 -16
- package/types/component/XRTrackedObjectManager.d.ts +0 -27
- package/types/loader/IXRScene.d.ts +0 -40
- package/types/loader/XRCustomParser.d.ts +0 -9
- package/types/loader/XRSceneCustomParser.d.ts +0 -4
- package/types/loader/XRSceneExtendParser.d.ts +0 -4
- package/types/loader/XRSceneSchema.d.ts +0 -37
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.6",
|
|
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
|
|
27
|
-
"@galacean/engine": "1.3.0-
|
|
26
|
+
"@galacean/engine": "1.3.0-beta.6",
|
|
27
|
+
"@galacean/engine-design": "1.3.0-beta.6"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@galacean/engine": "1.3.0-
|
|
30
|
+
"@galacean/engine": "1.3.0-beta.6"
|
|
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";
|
|
@@ -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
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Script } from "@galacean/engine";
|
|
2
|
-
import { XRTracked } from "../feature/trackable/XRTracked";
|
|
3
|
-
export declare class TrackedComponent<T extends XRTracked> extends Script {
|
|
4
|
-
private _data;
|
|
5
|
-
private _destroyedOnRemoval;
|
|
6
|
-
get destroyedOnRemoval(): boolean;
|
|
7
|
-
set destroyedOnRemoval(value: boolean);
|
|
8
|
-
get data(): T;
|
|
9
|
-
set data(value: T);
|
|
10
|
-
}
|
|
File without changes
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Script } from "@galacean/engine";
|
|
2
|
-
import { XRTracked } from "../feature/trackable/XRTracked";
|
|
3
|
-
export declare class XRTrackedComponent<T extends XRTracked> extends Script {
|
|
4
|
-
private _data;
|
|
5
|
-
private _destroyedOnRemoval;
|
|
6
|
-
/**
|
|
7
|
-
* Tracking data of the TrackedObject.
|
|
8
|
-
*/
|
|
9
|
-
get data(): T;
|
|
10
|
-
set data(value: T);
|
|
11
|
-
/**
|
|
12
|
-
* Whether to destroy when tracking is removed, default is true.
|
|
13
|
-
*/
|
|
14
|
-
get destroyedOnRemoval(): boolean;
|
|
15
|
-
set destroyedOnRemoval(value: boolean);
|
|
16
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Entity, Script, XRManager } from "@galacean/engine";
|
|
2
|
-
import { XRFeature } from "../feature/XRFeature";
|
|
3
|
-
import { XRTrackableFeature } from "../feature/trackable/XRTrackableFeature";
|
|
4
|
-
import { XRTracked } from "../feature/trackable/XRTracked";
|
|
5
|
-
import { XRTrackedComponent } from "./XRTrackedComponent";
|
|
6
|
-
/**
|
|
7
|
-
* 被追踪到的所有对象
|
|
8
|
-
*/
|
|
9
|
-
export declare class XRTrackedObjectManager<T extends XRTracked> extends Script {
|
|
10
|
-
private _prefab;
|
|
11
|
-
private _trackIdToIndex;
|
|
12
|
-
private _feature;
|
|
13
|
-
private _trackedComponents;
|
|
14
|
-
get prefab(): Entity;
|
|
15
|
-
set prefab(value: Entity);
|
|
16
|
-
getTrackedComponentByTrackId(trackId: number): XRTrackedComponent<T>;
|
|
17
|
-
constructor(entity: Entity, feature: TFeatureConstructor<XRTrackableFeature>);
|
|
18
|
-
onEnable(): void;
|
|
19
|
-
onDisable(): void;
|
|
20
|
-
private _onXRSessionInit;
|
|
21
|
-
private _onXRSessionExit;
|
|
22
|
-
private _onChanged;
|
|
23
|
-
private _createOrUpdateTrackedComponents;
|
|
24
|
-
private _createTrackedComponents;
|
|
25
|
-
}
|
|
26
|
-
type TFeatureConstructor<T extends XRFeature> = new (xrManager: XRManager, ...args: any[]) => T;
|
|
27
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IReferable, IScene, ISceneConfig, IVector3, IVector4 } from "@galacean/engine";
|
|
2
|
-
import { XRFeatureType } from "../feature/XRFeatureType";
|
|
3
|
-
import { XRPlaneMode } from "../feature/trackable/plane/XRPlaneMode";
|
|
4
|
-
interface IXRSceneConfig extends ISceneConfig {
|
|
5
|
-
xr?: {
|
|
6
|
-
sessionMode: number;
|
|
7
|
-
origin: string;
|
|
8
|
-
camera: string;
|
|
9
|
-
leftCamera: string;
|
|
10
|
-
rightCamera: string;
|
|
11
|
-
features: IXRFeatureSchema[];
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface IXRScene extends Omit<IScene, "scene"> {
|
|
15
|
-
scene: IXRSceneConfig;
|
|
16
|
-
}
|
|
17
|
-
export interface IXRFeatureSchema {
|
|
18
|
-
type: XRFeatureType;
|
|
19
|
-
enable: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface IAnchorTrackingSchema extends IXRFeatureSchema {
|
|
22
|
-
anchors: IAnchor[];
|
|
23
|
-
prefab: null | IReferable;
|
|
24
|
-
}
|
|
25
|
-
export interface IImageTrackingSchema extends IXRFeatureSchema {
|
|
26
|
-
images: IReferable[];
|
|
27
|
-
prefab: null | IReferable;
|
|
28
|
-
}
|
|
29
|
-
export interface IHitTestSchema extends IXRFeatureSchema {
|
|
30
|
-
prefab: null | IReferable;
|
|
31
|
-
}
|
|
32
|
-
export interface IPlaneTrackingSchema extends IXRFeatureSchema {
|
|
33
|
-
detectionMode: XRPlaneMode;
|
|
34
|
-
prefab: null | IReferable;
|
|
35
|
-
}
|
|
36
|
-
export interface IAnchor {
|
|
37
|
-
position: IVector3;
|
|
38
|
-
rotation: IVector4;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Engine, IScene, ParserContext, Scene } from "@galacean/engine";
|
|
2
|
-
export declare class XRExtendParser {
|
|
3
|
-
parse(engine: Engine, context: ParserContext<IScene, Scene>, data: IScene): Promise<void>;
|
|
4
|
-
private _addImageTracking;
|
|
5
|
-
private _addPlaneTracking;
|
|
6
|
-
private _addAnchorTracking;
|
|
7
|
-
private _addHitTest;
|
|
8
|
-
private _setCamera;
|
|
9
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { IReferable, IVector3, IVector4 } from "@galacean/engine";
|
|
2
|
-
import { XRFeatureType } from "../feature/XRFeatureType";
|
|
3
|
-
import { XRPlaneMode } from "../feature/trackable/plane/XRPlaneMode";
|
|
4
|
-
declare module "@galacean/engine" {
|
|
5
|
-
interface ISceneConfig {
|
|
6
|
-
xr: {
|
|
7
|
-
sessionMode: number;
|
|
8
|
-
origin: string;
|
|
9
|
-
camera: string;
|
|
10
|
-
leftCamera: string;
|
|
11
|
-
rightCamera: string;
|
|
12
|
-
features: IXRFeatureSchema[];
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export interface IXRFeatureSchema {
|
|
17
|
-
type: XRFeatureType;
|
|
18
|
-
enable: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface IAnchorTrackingSchema extends IXRFeatureSchema {
|
|
21
|
-
anchors: IAnchor[];
|
|
22
|
-
prefab: null | IReferable;
|
|
23
|
-
}
|
|
24
|
-
export interface IImageTrackingSchema extends IXRFeatureSchema {
|
|
25
|
-
images: IReferable[];
|
|
26
|
-
prefab: null | IReferable;
|
|
27
|
-
}
|
|
28
|
-
export interface IHitTestSchema extends IXRFeatureSchema {
|
|
29
|
-
}
|
|
30
|
-
export interface IPlaneTrackingSchema extends IXRFeatureSchema {
|
|
31
|
-
detectionMode: XRPlaneMode;
|
|
32
|
-
prefab: null | IReferable;
|
|
33
|
-
}
|
|
34
|
-
export interface IAnchor {
|
|
35
|
-
position: IVector3;
|
|
36
|
-
rotation: IVector4;
|
|
37
|
-
}
|