@vived/app 4.0.1 → 4.2.0

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.
Files changed (56) hide show
  1. package/lib/Components/App/UC/EditSlideTextUC.d.ts +1 -0
  2. package/lib/Components/Babylon/Mocks/MockPixelToSceneRayUC.d.ts +5 -0
  3. package/lib/Components/Babylon/Mocks/MockPixelToSceneRayUC.js +11 -0
  4. package/lib/Components/Babylon/Mocks/MockSceneRayPickUC.d.ts +5 -0
  5. package/lib/Components/Babylon/Mocks/MockSceneRayPickUC.js +11 -0
  6. package/lib/Components/Selection/Controller/MouseHoverOnAppObject.d.ts +11 -0
  7. package/lib/Components/Selection/Controller/MouseHoverOnAppObject.js +42 -0
  8. package/lib/Components/Selection/Controller/MousePressOnAppObject.d.ts +18 -0
  9. package/lib/Components/Selection/Controller/MousePressOnAppObject.js +81 -0
  10. package/lib/Components/Selection/Controller/MouseSelectAppObject.d.ts +11 -0
  11. package/lib/Components/Selection/Controller/MouseSelectAppObject.js +46 -0
  12. package/lib/Components/Selection/Controller/StylusHoverOnAppObject.d.ts +11 -0
  13. package/lib/Components/Selection/Controller/StylusHoverOnAppObject.js +42 -0
  14. package/lib/Components/Selection/Controller/StylusPressOnAppObject.d.ts +18 -0
  15. package/lib/Components/Selection/Controller/StylusPressOnAppObject.js +77 -0
  16. package/lib/Components/Selection/Controller/StylusSelectAppObject.d.ts +11 -0
  17. package/lib/Components/Selection/Controller/StylusSelectAppObject.js +44 -0
  18. package/lib/Components/Selection/Controller/TapToSelectAppObject.d.ts +16 -0
  19. package/lib/Components/Selection/Controller/TapToSelectAppObject.js +69 -0
  20. package/lib/Components/Selection/Controller/TouchPressOnAppObject.d.ts +18 -0
  21. package/lib/Components/Selection/Controller/TouchPressOnAppObject.js +78 -0
  22. package/lib/Components/Selection/Controller/index.d.ts +8 -0
  23. package/lib/Components/Selection/Controller/index.js +20 -0
  24. package/lib/Components/Selection/Entities/Selectable.d.ts +15 -0
  25. package/lib/Components/Selection/Entities/Selectable.js +48 -0
  26. package/lib/Components/Selection/Entities/Selection.d.ts +18 -0
  27. package/lib/Components/Selection/Entities/Selection.js +122 -0
  28. package/lib/Components/Selection/Entities/index.d.ts +2 -0
  29. package/lib/Components/Selection/Entities/index.js +14 -0
  30. package/lib/Components/Selection/PM/SelectableStatePM.d.ts +16 -0
  31. package/lib/Components/Selection/PM/SelectableStatePM.js +51 -0
  32. package/lib/Components/Selection/PM/SelectedObjectPM.d.ts +6 -0
  33. package/lib/Components/Selection/PM/SelectedObjectPM.js +41 -0
  34. package/lib/Components/Selection/PM/index.d.ts +2 -0
  35. package/lib/Components/Selection/PM/index.js +14 -0
  36. package/lib/Components/Selection/UC/HoverAppObjectUC.d.ts +11 -0
  37. package/lib/Components/Selection/UC/HoverAppObjectUC.js +59 -0
  38. package/lib/Components/Selection/UC/PressAppObjectUC.d.ts +11 -0
  39. package/lib/Components/Selection/UC/PressAppObjectUC.js +60 -0
  40. package/lib/Components/Selection/UC/SelectAppObjectUC.d.ts +11 -0
  41. package/lib/Components/Selection/UC/SelectAppObjectUC.js +59 -0
  42. package/lib/Components/Selection/UC/index.d.ts +3 -0
  43. package/lib/Components/Selection/UC/index.js +15 -0
  44. package/lib/Components/Selection/index.d.ts +4 -0
  45. package/lib/Components/Selection/index.js +16 -0
  46. package/lib/Components/ThemeColors/Entities/ThemeColors.d.ts +2 -0
  47. package/lib/Components/ThemeColors/Entities/ThemeColors.js +56 -0
  48. package/lib/Components/ThemeColors/PM/ThemeColorMapPM.d.ts +11 -0
  49. package/lib/Components/ThemeColors/PM/ThemeColorMapPM.js +39 -0
  50. package/lib/Components/ThemeColors/PM/index.d.ts +1 -0
  51. package/lib/Components/ThemeColors/PM/index.js +13 -0
  52. package/lib/Components/ThemeColors/index.d.ts +1 -0
  53. package/lib/Components/ThemeColors/index.js +1 -0
  54. package/lib/Components/index.d.ts +1 -0
  55. package/lib/Components/index.js +1 -0
  56. package/package.json +1 -1
@@ -4,6 +4,7 @@ import { AppObjectUC } from "../../../AppObject/AppObjectUC";
4
4
  export declare abstract class EditSlideTextUC extends AppObjectUC {
5
5
  static readonly type = "EditSlideTextUC";
6
6
  abstract editSlideText(): void;
7
+ abstract submitCallback(text: string): void;
7
8
  static get: (appObjects: AppObjectRepo) => EditSlideTextUC | undefined;
8
9
  }
9
10
  export declare function makeEditSlideTextUC(appObject: AppObject): EditSlideTextUC;
@@ -0,0 +1,5 @@
1
+ /// <reference types="jest" />
2
+ import { PixelToSceneRayUC } from "../UC/PixelToSceneRayUC";
3
+ export declare class MockPixelToSceneRayUC extends PixelToSceneRayUC {
4
+ pixelToSceneRay: jest.Mock<any, any>;
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockPixelToSceneRayUC = void 0;
4
+ const PixelToSceneRayUC_1 = require("../UC/PixelToSceneRayUC");
5
+ class MockPixelToSceneRayUC extends PixelToSceneRayUC_1.PixelToSceneRayUC {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.pixelToSceneRay = jest.fn();
9
+ }
10
+ }
11
+ exports.MockPixelToSceneRayUC = MockPixelToSceneRayUC;
@@ -0,0 +1,5 @@
1
+ /// <reference types="jest" />
2
+ import { SceneRayPickUC } from "../UC/SceneRayPickUC";
3
+ export declare class MockSceneRayPickUC extends SceneRayPickUC {
4
+ sceneRayPick: jest.Mock<any, any>;
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockSceneRayPickUC = void 0;
4
+ const SceneRayPickUC_1 = require("../UC/SceneRayPickUC");
5
+ class MockSceneRayPickUC extends SceneRayPickUC_1.SceneRayPickUC {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.sceneRayPick = jest.fn();
9
+ }
10
+ }
11
+ exports.MockSceneRayPickUC = MockSceneRayPickUC;
@@ -0,0 +1,11 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { MouseController, MouseInputEvent } from "../../MouseInput";
4
+ export declare class MouseHoverOnAppObject extends AppObjectController implements MouseController {
5
+ static readonly type = "MouseHoverOnAppObject";
6
+ private hoverUC?;
7
+ private zSpaceEntity;
8
+ allow: (e: MouseInputEvent) => boolean;
9
+ onMove: (e: MouseInputEvent) => void;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MouseHoverOnAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Babylon_1 = require("../../Babylon");
6
+ const MouseInput_1 = require("../../MouseInput");
7
+ const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
8
+ const HoverAppObjectUC_1 = require("../UC/HoverAppObjectUC");
9
+ class MouseHoverOnAppObject extends AppObjectController_1.AppObjectController {
10
+ constructor(appObject) {
11
+ super(appObject, MouseHoverOnAppObject.type);
12
+ this.zSpaceEntity = undefined;
13
+ this.allow = (e) => {
14
+ return true;
15
+ };
16
+ this.onMove = (e) => {
17
+ if (!this.hoverUC)
18
+ return;
19
+ if (this.zSpaceEntity && this.zSpaceEntity.emulate)
20
+ return;
21
+ if (!this.allow(e))
22
+ return;
23
+ const ray = Babylon_1.pixelToSceneRay(e.position, this.appObjects);
24
+ this.hoverUC.tryHoverSceneObject(ray);
25
+ };
26
+ this.zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObjects);
27
+ this.hoverUC = appObject.getComponent(HoverAppObjectUC_1.HoverAppObjectUC.type);
28
+ if (!this.hoverUC) {
29
+ console.warn("MouseHover has been added to an App Object that does not have a HoverAppObjectUC. Add an HoverAppObjectUC before adding the Controller");
30
+ return;
31
+ }
32
+ const mouseInput = MouseInput_1.MouseInputEntity.get(this.appObjects);
33
+ if (mouseInput) {
34
+ mouseInput.registerController(this);
35
+ }
36
+ else {
37
+ this.warn("Unable to find MouseInputEntity");
38
+ }
39
+ }
40
+ }
41
+ exports.MouseHoverOnAppObject = MouseHoverOnAppObject;
42
+ MouseHoverOnAppObject.type = "MouseHoverOnAppObject";
@@ -0,0 +1,18 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { MouseController, MouseInputEvent } from "../../MouseInput";
4
+ export declare class MousePressOnAppObject extends AppObjectController implements MouseController {
5
+ static readonly type = "MousePressOnAppObject";
6
+ static readonly maxTapDistancePx = 5;
7
+ private pressUC?;
8
+ private zSpaceEntity;
9
+ private startPosition;
10
+ private endPosition;
11
+ private pressedID;
12
+ private isPressed;
13
+ allow: (e: MouseInputEvent) => boolean;
14
+ onDown: (e: MouseInputEvent) => void;
15
+ onUp: (e: MouseInputEvent) => void;
16
+ onMove: (e: MouseInputEvent) => void;
17
+ constructor(appObject: AppObject);
18
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MousePressOnAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Vector2_1 = require("../../../ValueObjects/Vector2");
6
+ const Babylon_1 = require("../../Babylon");
7
+ const MouseInput_1 = require("../../MouseInput");
8
+ const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
9
+ const PressAppObjectUC_1 = require("../UC/PressAppObjectUC");
10
+ class MousePressOnAppObject extends AppObjectController_1.AppObjectController {
11
+ constructor(appObject) {
12
+ super(appObject, MousePressOnAppObject.type);
13
+ this.zSpaceEntity = undefined;
14
+ this.startPosition = Vector2_1.Vector2.Zero();
15
+ this.endPosition = Vector2_1.Vector2.Zero();
16
+ this.pressedID = null;
17
+ this.isPressed = false;
18
+ this.allow = (e) => {
19
+ return true;
20
+ };
21
+ this.onDown = (e) => {
22
+ var _a;
23
+ if (e.button !== 0) {
24
+ return;
25
+ }
26
+ if (!this.pressUC) {
27
+ return;
28
+ }
29
+ if (this.zSpaceEntity && this.zSpaceEntity.emulate)
30
+ return;
31
+ if (!this.allow(e))
32
+ return;
33
+ this.startPosition = e.position;
34
+ this.endPosition = this.startPosition;
35
+ this.isPressed = true;
36
+ const ray = Babylon_1.pixelToSceneRay(e.position, this.appObjects);
37
+ this.pressedID = (_a = this.pressUC) === null || _a === void 0 ? void 0 : _a.tryPressSceneObject(ray);
38
+ };
39
+ this.onUp = (e) => {
40
+ this.isPressed = false;
41
+ if (e.button !== 0) {
42
+ return;
43
+ }
44
+ if (!this.pressUC) {
45
+ return;
46
+ }
47
+ // Set pressedID to null
48
+ this.pressUC.pressSceneObject(this.pressedID, this.isPressed);
49
+ };
50
+ this.onMove = (e) => {
51
+ if (!this.pressUC) {
52
+ return;
53
+ }
54
+ if (this.isPressed) {
55
+ this.endPosition = e.position;
56
+ const movement = Vector2_1.Vector2.Subtract(this.startPosition, this.endPosition)
57
+ .magnitued;
58
+ if (movement > MousePressOnAppObject.maxTapDistancePx) {
59
+ // Set pressedID to null
60
+ this.pressUC.pressSceneObject(null, this.isPressed);
61
+ }
62
+ }
63
+ };
64
+ this.zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObjects);
65
+ this.pressUC = appObject.getComponent(PressAppObjectUC_1.PressAppObjectUC.type);
66
+ if (!this.pressUC) {
67
+ console.warn("MousePress has been added to an App Object that does not have a PressAppObjectUC. Add a PressAppObjectUC before adding the Controller.");
68
+ return;
69
+ }
70
+ const mouseInput = MouseInput_1.MouseInputEntity.get(this.appObjects);
71
+ if (mouseInput) {
72
+ mouseInput.registerController(this);
73
+ }
74
+ else {
75
+ this.warn("Unable to find MouseInputEntity");
76
+ }
77
+ }
78
+ }
79
+ exports.MousePressOnAppObject = MousePressOnAppObject;
80
+ MousePressOnAppObject.type = "MousePressOnAppObject";
81
+ MousePressOnAppObject.maxTapDistancePx = 5;
@@ -0,0 +1,11 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { MouseController, MouseInputEvent } from "../../MouseInput";
4
+ export declare class MouseSelectAppObject extends AppObjectController implements MouseController {
5
+ static readonly type = "MouseSelectAppObject";
6
+ private selectUC?;
7
+ private zSpaceEntity;
8
+ allow: (e: MouseInputEvent) => boolean;
9
+ onClick: (e: MouseInputEvent) => void;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MouseSelectAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Babylon_1 = require("../../Babylon");
6
+ const MouseInput_1 = require("../../MouseInput");
7
+ const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
8
+ const SelectAppObjectUC_1 = require("../UC/SelectAppObjectUC");
9
+ class MouseSelectAppObject extends AppObjectController_1.AppObjectController {
10
+ constructor(appObject) {
11
+ super(appObject, MouseSelectAppObject.type);
12
+ this.zSpaceEntity = undefined;
13
+ this.allow = (e) => {
14
+ return true;
15
+ };
16
+ this.onClick = (e) => {
17
+ if (!this.selectUC) {
18
+ return;
19
+ }
20
+ if (e.button !== 0) {
21
+ return;
22
+ }
23
+ if (this.zSpaceEntity && this.zSpaceEntity.emulate)
24
+ return;
25
+ if (!this.allow(e))
26
+ return;
27
+ const ray = Babylon_1.pixelToSceneRay(e.position, this.appObjects);
28
+ this.selectUC.trySelectSceneObject(ray);
29
+ };
30
+ this.zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObjects);
31
+ this.selectUC = appObject.getComponent(SelectAppObjectUC_1.SelectAppObjectUC.type);
32
+ if (!this.selectUC) {
33
+ console.warn("MouseSelect has been added to an App Object that does not have a SelectAppObjectUC. Add a SelectAppObjectUC before adding the Controller.");
34
+ return;
35
+ }
36
+ const mouseInput = MouseInput_1.MouseInputEntity.get(this.appObjects);
37
+ if (mouseInput) {
38
+ mouseInput.registerController(this);
39
+ }
40
+ else {
41
+ this.warn("Unable to find MouseInputEntity");
42
+ }
43
+ }
44
+ }
45
+ exports.MouseSelectAppObject = MouseSelectAppObject;
46
+ MouseSelectAppObject.type = "MouseSelectAppObject";
@@ -0,0 +1,11 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { ZSpaceStylusController } from "../../zSpace/Entities/ZSpaceStylusEntity";
4
+ export declare class StylusHoverOnAppObject extends AppObjectController implements ZSpaceStylusController {
5
+ static readonly type = "StylusHoverOnAppObject";
6
+ private stylus?;
7
+ private hoverUC?;
8
+ allow: () => boolean;
9
+ onStylusMove: () => void;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StylusHoverOnAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
6
+ const HoverAppObjectUC_1 = require("../UC/HoverAppObjectUC");
7
+ class StylusHoverOnAppObject extends AppObjectController_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, StylusHoverOnAppObject.type);
10
+ this.allow = () => {
11
+ return true;
12
+ };
13
+ this.onStylusMove = () => {
14
+ if (!this.stylus)
15
+ return;
16
+ if (!this.hoverUC)
17
+ return;
18
+ if (!this.allow())
19
+ return;
20
+ const pointerRay = this.stylus.pickRay;
21
+ this.hoverUC.tryHoverSceneObject(pointerRay);
22
+ };
23
+ const zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObjects);
24
+ if (!zSpaceEntity) {
25
+ this.warn("Unable to find ZSpaceEntity");
26
+ return;
27
+ }
28
+ this.stylus = zSpaceEntity.stylus;
29
+ this.hoverUC = appObject.getComponent(HoverAppObjectUC_1.HoverAppObjectUC.type);
30
+ if (!this.stylus) {
31
+ console.warn("StylusInputPointer Controller has been added to an app object that does not have a ZSpaceStylusEntity");
32
+ }
33
+ else if (!this.hoverUC) {
34
+ console.warn("HoverAppObjectUC has not been found on any objects in the app object repo");
35
+ }
36
+ else {
37
+ this.stylus.registerController(this);
38
+ }
39
+ }
40
+ }
41
+ exports.StylusHoverOnAppObject = StylusHoverOnAppObject;
42
+ StylusHoverOnAppObject.type = "StylusHoverOnAppObject";
@@ -0,0 +1,18 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { ZSpaceStylusButton, ZSpaceStylusController } from "../../zSpace/Entities/ZSpaceStylusEntity";
4
+ export declare class StylusPressOnAppObject extends AppObjectController implements ZSpaceStylusController {
5
+ static readonly type = "StylusPressOnAppObject";
6
+ static readonly maxTapDistancePx = 5;
7
+ private stylus?;
8
+ private pressUC?;
9
+ private startPosition;
10
+ private endPosition;
11
+ private pressedID;
12
+ private isPressed;
13
+ allow: (button: ZSpaceStylusButton) => boolean;
14
+ onButtonDown: (button: ZSpaceStylusButton) => void;
15
+ onButtonUp: (button: ZSpaceStylusButton) => void;
16
+ onStylusMove: () => void;
17
+ constructor(appObject: AppObject);
18
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StylusPressOnAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Vector3_1 = require("../../../ValueObjects/Vector3");
6
+ const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
7
+ const PressAppObjectUC_1 = require("../UC/PressAppObjectUC");
8
+ class StylusPressOnAppObject extends AppObjectController_1.AppObjectController {
9
+ constructor(appObject) {
10
+ super(appObject, StylusPressOnAppObject.type);
11
+ this.startPosition = Vector3_1.Vector3.Zero();
12
+ this.endPosition = Vector3_1.Vector3.Zero();
13
+ this.pressedID = null;
14
+ this.isPressed = false;
15
+ this.allow = (button) => {
16
+ return true;
17
+ };
18
+ this.onButtonDown = (button) => {
19
+ var _a;
20
+ if (button !== 0)
21
+ return;
22
+ if (!this.stylus)
23
+ return;
24
+ if (!this.pressUC)
25
+ return;
26
+ if (!this.allow(button))
27
+ return;
28
+ this.startPosition = this.stylus.transform.localPosition;
29
+ this.endPosition = this.startPosition;
30
+ this.isPressed = true;
31
+ this.pressedID = (_a = this.pressUC) === null || _a === void 0 ? void 0 : _a.tryPressSceneObject(this.stylus.pickRay);
32
+ };
33
+ this.onButtonUp = (button) => {
34
+ this.isPressed = false;
35
+ if (button !== 0)
36
+ return;
37
+ if (!this.pressUC)
38
+ return;
39
+ // Set pressedID to null
40
+ this.pressUC.pressSceneObject(this.pressedID, this.isPressed);
41
+ };
42
+ this.onStylusMove = () => {
43
+ var _a;
44
+ if (!this.pressUC) {
45
+ return;
46
+ }
47
+ if (this.isPressed) {
48
+ this.endPosition = (_a = this.stylus) === null || _a === void 0 ? void 0 : _a.transform.localPosition;
49
+ const movement = Vector3_1.Vector3.Subtract(this.startPosition, this.endPosition)
50
+ .magnitude;
51
+ if (movement > StylusPressOnAppObject.maxTapDistancePx) {
52
+ // Set pressedID to null
53
+ this.pressUC.pressSceneObject(null, this.isPressed);
54
+ }
55
+ }
56
+ };
57
+ const zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObjects);
58
+ if (!zSpaceEntity) {
59
+ this.warn("Unable to find ZSpaceEntity");
60
+ return;
61
+ }
62
+ this.stylus = zSpaceEntity.stylus;
63
+ this.pressUC = appObject.getComponent(PressAppObjectUC_1.PressAppObjectUC.type);
64
+ if (!this.stylus) {
65
+ console.warn("StylusInputPointer Controller has been added to an app object that does not have a ZSpaceStylusEntity");
66
+ }
67
+ else if (!this.pressUC) {
68
+ console.warn("PressAppObjectUC has not been found on any objects in the app object repo");
69
+ }
70
+ else {
71
+ this.stylus.registerController(this);
72
+ }
73
+ }
74
+ }
75
+ exports.StylusPressOnAppObject = StylusPressOnAppObject;
76
+ StylusPressOnAppObject.type = "StylusPressOnAppObject";
77
+ StylusPressOnAppObject.maxTapDistancePx = 5;
@@ -0,0 +1,11 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { ZSpaceStylusButton, ZSpaceStylusController } from "../../zSpace/Entities/ZSpaceStylusEntity";
4
+ export declare class StylusSelectAppObject extends AppObjectController implements ZSpaceStylusController {
5
+ static readonly type = "StylusSelectAppObject";
6
+ private stylus?;
7
+ private selectUC?;
8
+ allow: () => boolean;
9
+ onButtonClick: (button: ZSpaceStylusButton) => void;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StylusSelectAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
6
+ const UC_1 = require("../UC");
7
+ class StylusSelectAppObject extends AppObjectController_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, StylusSelectAppObject.type);
10
+ this.allow = () => {
11
+ return true;
12
+ };
13
+ this.onButtonClick = (button) => {
14
+ if (button !== 0)
15
+ return;
16
+ if (!this.stylus)
17
+ return;
18
+ if (!this.selectUC)
19
+ return;
20
+ if (!this.allow())
21
+ return;
22
+ const pointerRay = this.stylus.pickRay;
23
+ this.selectUC.trySelectSceneObject(pointerRay);
24
+ };
25
+ const zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObjects);
26
+ if (!zSpaceEntity) {
27
+ this.warn("Unable to find ZSpaceEntity");
28
+ return;
29
+ }
30
+ this.stylus = zSpaceEntity.stylus;
31
+ this.selectUC = appObject.getComponent(UC_1.SelectAppObjectUC.type);
32
+ if (!this.stylus) {
33
+ console.warn("StylusInputPointer Controller has been added to an app object that does not have a ZSpaceStylusEntity");
34
+ }
35
+ else if (!this.selectUC) {
36
+ console.warn("SelectAppObjectUC has not been found on any objects in the app object repo");
37
+ }
38
+ else {
39
+ this.stylus.registerController(this);
40
+ }
41
+ }
42
+ }
43
+ exports.StylusSelectAppObject = StylusSelectAppObject;
44
+ StylusSelectAppObject.type = "StylusSelectAppObject";
@@ -0,0 +1,16 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { TouchController, TouchInputEvent } from "../../TouchController";
4
+ export declare class TapToSelectAppObject extends AppObjectController implements TouchController {
5
+ static readonly type = "TapToSelectAppObject";
6
+ static readonly maxTapDistancePx = 5;
7
+ private selectUC?;
8
+ private startPosition;
9
+ private endPosition;
10
+ private doTouchEnd;
11
+ allow: (e: TouchInputEvent) => boolean;
12
+ onTouchStart: (e: TouchInputEvent) => void;
13
+ onTouchMove: (e: TouchInputEvent) => void;
14
+ onTouchEnd: () => void;
15
+ constructor(appObject: AppObject);
16
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TapToSelectAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Vector2_1 = require("../../../ValueObjects/Vector2");
6
+ const Babylon_1 = require("../../Babylon");
7
+ const TouchController_1 = require("../../TouchController");
8
+ const SelectAppObjectUC_1 = require("../UC/SelectAppObjectUC");
9
+ class TapToSelectAppObject extends AppObjectController_1.AppObjectController {
10
+ constructor(appObject) {
11
+ super(appObject, TapToSelectAppObject.type);
12
+ this.startPosition = Vector2_1.Vector2.Zero();
13
+ this.endPosition = Vector2_1.Vector2.Zero();
14
+ this.doTouchEnd = false;
15
+ this.allow = (e) => {
16
+ return true;
17
+ };
18
+ this.onTouchStart = (e) => {
19
+ this.doTouchEnd = false;
20
+ if (e.touches.length !== 1) {
21
+ return;
22
+ }
23
+ if (!this.allow(e)) {
24
+ return;
25
+ }
26
+ this.startPosition = e.touches[0].position;
27
+ this.endPosition = this.startPosition;
28
+ this.doTouchEnd = true;
29
+ };
30
+ this.onTouchMove = (e) => {
31
+ if (e.touches.length === 1) {
32
+ this.endPosition = e.touches[0].position;
33
+ }
34
+ else {
35
+ this.doTouchEnd = false;
36
+ }
37
+ };
38
+ this.onTouchEnd = () => {
39
+ var _a;
40
+ if (!this.doTouchEnd) {
41
+ return;
42
+ }
43
+ if (!this.selectUC) {
44
+ return;
45
+ }
46
+ const movement = Vector2_1.Vector2.Subtract(this.startPosition, this.endPosition)
47
+ .magnitued;
48
+ if (movement <= TapToSelectAppObject.maxTapDistancePx) {
49
+ const ray = Babylon_1.pixelToSceneRay(this.endPosition, this.appObjects);
50
+ (_a = this.selectUC) === null || _a === void 0 ? void 0 : _a.trySelectSceneObject(ray);
51
+ }
52
+ };
53
+ this.selectUC = appObject.getComponent(SelectAppObjectUC_1.SelectAppObjectUC.type);
54
+ if (!this.selectUC) {
55
+ console.warn("MouseSelect has been added to an App Object that does not have a SelectAppObjectUC. Add a SelectAppObjectUC before adding the Controller.");
56
+ return;
57
+ }
58
+ const touchInput = TouchController_1.TouchInputEntity.get(this.appObjects);
59
+ if (touchInput) {
60
+ touchInput.registerController(this);
61
+ }
62
+ else {
63
+ this.warn("Unable to find TouchInputEntity");
64
+ }
65
+ }
66
+ }
67
+ exports.TapToSelectAppObject = TapToSelectAppObject;
68
+ TapToSelectAppObject.type = "TapToSelectAppObject";
69
+ TapToSelectAppObject.maxTapDistancePx = 5;
@@ -0,0 +1,18 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { TouchController, TouchInputEvent } from "../../TouchController";
4
+ export declare class TouchPressOnAppObject extends AppObjectController implements TouchController {
5
+ static readonly type = "TouchPressOnAppObject";
6
+ static readonly maxTapDistancePx = 5;
7
+ private pressUC?;
8
+ private startPosition;
9
+ private endPosition;
10
+ private doTouchEnd;
11
+ private pressedID;
12
+ private isPressed;
13
+ allow: (e: TouchInputEvent) => boolean;
14
+ onTouchStart: (e: TouchInputEvent) => void;
15
+ onTouchMove: (e: TouchInputEvent) => void;
16
+ onTouchEnd: () => void;
17
+ constructor(appObject: AppObject);
18
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TouchPressOnAppObject = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Vector2_1 = require("../../../ValueObjects/Vector2");
6
+ const Babylon_1 = require("../../Babylon");
7
+ const TouchController_1 = require("../../TouchController");
8
+ const PressAppObjectUC_1 = require("../UC/PressAppObjectUC");
9
+ class TouchPressOnAppObject extends AppObjectController_1.AppObjectController {
10
+ constructor(appObject) {
11
+ super(appObject, TouchPressOnAppObject.type);
12
+ this.startPosition = Vector2_1.Vector2.Zero();
13
+ this.endPosition = Vector2_1.Vector2.Zero();
14
+ this.doTouchEnd = false;
15
+ this.pressedID = null;
16
+ this.isPressed = false;
17
+ this.allow = (e) => {
18
+ return true;
19
+ };
20
+ this.onTouchStart = (e) => {
21
+ var _a;
22
+ this.doTouchEnd = false;
23
+ this.isPressed = true;
24
+ if (!this.pressUC) {
25
+ return;
26
+ }
27
+ if (e.touches.length !== 1) {
28
+ return;
29
+ }
30
+ if (!this.allow(e)) {
31
+ return;
32
+ }
33
+ this.startPosition = e.touches[0].position;
34
+ this.endPosition = this.startPosition;
35
+ this.doTouchEnd = true;
36
+ const ray = Babylon_1.pixelToSceneRay(this.endPosition, this.appObjects);
37
+ this.pressedID = (_a = this.pressUC) === null || _a === void 0 ? void 0 : _a.tryPressSceneObject(ray);
38
+ };
39
+ this.onTouchMove = (e) => {
40
+ var _a, _b;
41
+ if (e.touches.length === 1) {
42
+ this.endPosition = e.touches[0].position;
43
+ const movement = Vector2_1.Vector2.Subtract(this.startPosition, this.endPosition)
44
+ .magnitued;
45
+ if (movement > TouchPressOnAppObject.maxTapDistancePx) {
46
+ (_a = this.pressUC) === null || _a === void 0 ? void 0 : _a.pressSceneObject(null, true);
47
+ }
48
+ }
49
+ else {
50
+ (_b = this.pressUC) === null || _b === void 0 ? void 0 : _b.pressSceneObject(null, true);
51
+ this.doTouchEnd = false;
52
+ }
53
+ };
54
+ this.onTouchEnd = () => {
55
+ var _a;
56
+ if (!this.doTouchEnd) {
57
+ return;
58
+ }
59
+ this.isPressed = false;
60
+ (_a = this.pressUC) === null || _a === void 0 ? void 0 : _a.pressSceneObject(this.pressedID, this.isPressed);
61
+ };
62
+ this.pressUC = appObject.getComponent(PressAppObjectUC_1.PressAppObjectUC.type);
63
+ if (!this.pressUC) {
64
+ console.warn("TouchPress has been added to an App Object that does not have a PressAppObjectUC. Add a PressAppObjectUC before adding the Controller.");
65
+ return;
66
+ }
67
+ const touchInput = TouchController_1.TouchInputEntity.get(this.appObjects);
68
+ if (touchInput) {
69
+ touchInput.registerController(this);
70
+ }
71
+ else {
72
+ this.warn("Unable to find TouchInputEntity");
73
+ }
74
+ }
75
+ }
76
+ exports.TouchPressOnAppObject = TouchPressOnAppObject;
77
+ TouchPressOnAppObject.type = "TouchPressOnAppObject";
78
+ TouchPressOnAppObject.maxTapDistancePx = 5;