@galacean/engine-xr 0.0.0-experimental-stateMachine.0 → 0.0.0-experimental-1.3-xr.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-xr",
3
- "version": "0.0.0-experimental-stateMachine.0",
3
+ "version": "0.0.0-experimental-1.3-xr.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -11,6 +11,9 @@
11
11
  "debug": "src/index.ts",
12
12
  "browser": "dist/browser.js",
13
13
  "types": "types/index.d.ts",
14
+ "scripts": {
15
+ "b:types": "tsc"
16
+ },
14
17
  "umd": {
15
18
  "name": "Galacean.XR",
16
19
  "globals": {
@@ -23,13 +26,10 @@
23
26
  "types/**/*"
24
27
  ],
25
28
  "devDependencies": {
26
- "@galacean/engine": "0.0.0-experimental-stateMachine.0",
27
- "@galacean/engine-design": "0.0.0-experimental-stateMachine.0"
29
+ "@galacean/engine-design": "workspace:*",
30
+ "@galacean/engine": "workspace:*"
28
31
  },
29
32
  "peerDependencies": {
30
- "@galacean/engine": "0.0.0-experimental-stateMachine.0"
31
- },
32
- "scripts": {
33
- "b:types": "tsc"
33
+ "@galacean/engine": "workspace:*"
34
34
  }
35
- }
35
+ }
@@ -14,8 +14,9 @@ export declare class XRManagerExtended extends XRManager {
14
14
  sessionManager: XRSessionManager;
15
15
  /** Camera manager for XR. */
16
16
  cameraManager: XRCameraManager;
17
+ /** All initialized features at this moment. */
18
+ readonly features: XRFeature[];
17
19
  private _origin;
18
- private _features;
19
20
  /**
20
21
  * The current origin of XR space.
21
22
  * @remarks The connection point between the virtual world and the real world ( XR Space )
@@ -34,14 +35,13 @@ export declare class XRManagerExtended extends XRManager {
34
35
  * @param args - The constructor params of the feature
35
36
  * @returns The feature which has been added
36
37
  */
37
- addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>): XRFeature | null;
38
+ addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>): InstanceType<T> | null;
38
39
  /**
39
40
  * Get feature which match the type.
40
41
  * @param type - The type of the feature
41
42
  * @returns The feature which match type
42
43
  */
43
44
  getFeature<T extends XRFeature>(type: TFeatureConstructor<T>): T | null;
44
- getFeatures<T extends XRFeature>(type: TFeatureConstructor<T>, out?: T[]): T[];
45
45
  /**
46
46
  * Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
47
47
  * @param sessionMode - The mode of the session
@@ -71,17 +71,6 @@ declare module "@galacean/engine" {
71
71
  */
72
72
  get origin(): Entity;
73
73
  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
74
  /**
86
75
  * Check if the specified feature is supported.
87
76
  * @param type - The type of the feature
@@ -94,14 +83,13 @@ declare module "@galacean/engine" {
94
83
  * @param args - The constructor params of the feature
95
84
  * @returns The feature which has been added
96
85
  */
97
- addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>): XRFeature | null;
86
+ addFeature<T extends new (xrManager: XRManagerExtended, ...args: any[]) => XRFeature>(type: T, ...args: TFeatureConstructorArguments<T>): InstanceType<T> | null;
98
87
  /**
99
88
  * Get feature which match the type.
100
89
  * @param type - The type of the feature
101
90
  * @returns The feature which match type
102
91
  */
103
92
  getFeature<T extends XRFeature>(type: TFeatureConstructor<T>): T | null;
104
- getFeatures<T extends XRFeature>(type: TFeatureConstructor<T>, out?: T[]): T[];
105
93
  /**
106
94
  * Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
107
95
  * @param sessionMode - The mode of the session
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,27 @@
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 {};
package/types/index.d.ts CHANGED
@@ -26,3 +26,6 @@ export { XRFeatureType } from "./feature/XRFeatureType";
26
26
  export { XRRequestTrackingState } from "./feature/trackable/XRRequestTrackingState";
27
27
  export { XRInputEventType } from "./input/XRInputEventType";
28
28
  export { XRTargetRayMode } from "./input/XRTargetRayMode";
29
+ export * from "./loader/XRReferenceImageDecoder";
30
+ export * from "./loader/XRReferenceImageLoader";
31
+ export * from "./loader/XRSceneExtendParser";
@@ -0,0 +1,40 @@
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 {};
@@ -0,0 +1,9 @@
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
+ }
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ import { CustomParser, Engine, IScene, Scene } from "@galacean/engine";
2
+ export declare class XRSceneCustomParser extends CustomParser {
3
+ onAfterSceneParse(engine: Engine, data: IScene, scene: Scene): void;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Engine, IScene, ParserContext, Scene } from "@galacean/engine";
2
+ export declare class XRSceneExtendParser {
3
+ static parse(engine: Engine, context: ParserContext<IScene, Scene>, data: IScene): Promise<void>;
4
+ }
@@ -0,0 +1,37 @@
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
+ }
@@ -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
+ addChangedListener(listener: (state: XRSessionState) => void): void;
50
+ /**
51
+ * Remove a listening function of session state changes.
52
+ * @param listener - The listening function
53
+ */
54
+ removeChangedListener(listener: (state: XRSessionState) => void): void;
44
55
  private _onSessionExit;
45
56
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) 2020 - present Ant Group
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.