@vived/app 4.22.0 → 4.23.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 (92) hide show
  1. package/lib/Components/App/Adapters/index.d.ts +4 -0
  2. package/lib/Components/{KeyboardInput/Mocks → App/Adapters}/index.js +4 -1
  3. package/lib/Components/App/Adapters/isAuthoringAdapter.d.ts +2 -0
  4. package/lib/Components/App/Adapters/isAuthoringAdapter.js +23 -0
  5. package/lib/Components/App/Adapters/isReviewingAdapter.d.ts +2 -0
  6. package/lib/Components/App/Adapters/isReviewingAdapter.js +23 -0
  7. package/lib/Components/App/Adapters/slideNavigationAdapter.d.ts +3 -0
  8. package/lib/Components/App/Adapters/slideNavigationAdapter.js +23 -0
  9. package/lib/Components/App/Adapters/slideTextAdapter.d.ts +2 -0
  10. package/lib/Components/App/Adapters/slideTextAdapter.js +23 -0
  11. package/lib/Components/App/Entity/BaseAppState.d.ts +2 -0
  12. package/lib/Components/App/Entity/BaseAppState.js +7 -0
  13. package/lib/Components/App/Mocks/IsAuthoringMock.d.ts +8 -0
  14. package/lib/Components/App/Mocks/IsAuthoringMock.js +15 -0
  15. package/lib/Components/App/Mocks/IsReviewingMock.d.ts +8 -0
  16. package/lib/Components/App/Mocks/IsReviewingMock.js +15 -0
  17. package/lib/Components/App/Mocks/SlideNavigationMock.d.ts +8 -0
  18. package/lib/Components/App/Mocks/SlideNavigationMock.js +15 -0
  19. package/lib/Components/App/Mocks/SlideTextMock.d.ts +8 -0
  20. package/lib/Components/App/Mocks/SlideTextMock.js +15 -0
  21. package/lib/Components/App/Mocks/index.d.ts +4 -0
  22. package/lib/Components/App/Mocks/index.js +4 -0
  23. package/lib/Components/App/PM/IsAuthoringPM.d.ts +2 -6
  24. package/lib/Components/App/PM/IsAuthoringPM.js +16 -10
  25. package/lib/Components/App/PM/IsReviewingPM.d.ts +2 -6
  26. package/lib/Components/App/PM/IsReviewingPM.js +16 -10
  27. package/lib/Components/App/PM/SlideNavigationPM.d.ts +12 -0
  28. package/lib/Components/App/PM/SlideNavigationPM.js +49 -0
  29. package/lib/Components/App/PM/SlideTextPM.d.ts +2 -5
  30. package/lib/Components/App/PM/SlideTextPM.js +17 -10
  31. package/lib/Components/App/PM/index.d.ts +1 -1
  32. package/lib/Components/App/PM/index.js +1 -1
  33. package/lib/Components/App/index.d.ts +1 -0
  34. package/lib/Components/App/index.js +1 -0
  35. package/lib/Components/RequestHandler/UC/SetAppStateUC.d.ts +9 -2
  36. package/lib/Components/RequestHandler/UC/SetAppStateUC.js +35 -27
  37. package/package.json +1 -1
  38. package/lib/Components/App/PM/HasNextPreviousStatePM.d.ts +0 -15
  39. package/lib/Components/App/PM/HasNextPreviousStatePM.js +0 -44
  40. package/lib/Components/ChannelModel/Mocks/ProcessChannelModelUCMock.d.ts +0 -8
  41. package/lib/Components/ChannelModel/Mocks/ProcessChannelModelUCMock.js +0 -15
  42. package/lib/Components/ChannelModel/UC/InitializeChannelModelFromGLB.d.ts +0 -0
  43. package/lib/Components/ChannelModel/UC/InitializeChannelModelFromGLB.js +0 -1
  44. package/lib/Components/ChannelModel/UC/ProcessChannelModelUC.d.ts +0 -6
  45. package/lib/Components/ChannelModel/UC/ProcessChannelModelUC.js +0 -9
  46. package/lib/Components/ChannelModel/UC/SetupChannelModelUC.d.ts +0 -9
  47. package/lib/Components/ChannelModel/UC/SetupChannelModelUC.js +0 -11
  48. package/lib/Components/HoverLabel/Mocks/index.d.ts +0 -1
  49. package/lib/Components/HoverLabel/Mocks/index.js +0 -13
  50. package/lib/Components/HoverLabel/PM/HoverLabelPM.d.ts +0 -19
  51. package/lib/Components/HoverLabel/PM/HoverLabelPM.js +0 -65
  52. package/lib/Components/KeyboardInput/Mocks/index.d.ts +0 -1
  53. package/lib/Components/Landmarks/Mocks/index.d.ts +0 -1
  54. package/lib/Components/Landmarks/Mocks/index.js +0 -13
  55. package/lib/Components/MouseInput/Mocks/index.d.ts +0 -1
  56. package/lib/Components/MouseInput/Mocks/index.js +0 -13
  57. package/lib/Components/Question/Mocks/index.d.ts +0 -2
  58. package/lib/Components/Question/Mocks/index.js +0 -14
  59. package/lib/Components/RequestHandler/Mocks/index.d.ts +0 -1
  60. package/lib/Components/RequestHandler/Mocks/index.js +0 -13
  61. package/lib/Components/SceneRoot/Controllers/StylusMove.d.ts +0 -14
  62. package/lib/Components/SceneRoot/Controllers/StylusMove.js +0 -56
  63. package/lib/Components/SceneRoot/Controllers/StylusScale.d.ts +0 -14
  64. package/lib/Components/SceneRoot/Controllers/StylusScale.js +0 -58
  65. package/lib/Components/Selection/Controller/StylusHoverOnAppObject.d.ts +0 -11
  66. package/lib/Components/Selection/Controller/StylusHoverOnAppObject.js +0 -42
  67. package/lib/Components/Selection/Controller/StylusPressOnAppObject.d.ts +0 -18
  68. package/lib/Components/Selection/Controller/StylusPressOnAppObject.js +0 -77
  69. package/lib/Components/Selection/Controller/StylusSelectAppObject.d.ts +0 -11
  70. package/lib/Components/Selection/Controller/StylusSelectAppObject.js +0 -44
  71. package/lib/Components/TouchController/Mock/index.d.ts +0 -2
  72. package/lib/Components/TouchController/Mock/index.js +0 -14
  73. package/lib/Components/UndoRedo/Mocks/index.d.ts +0 -1
  74. package/lib/Components/UndoRedo/Mocks/index.js +0 -13
  75. package/lib/Components/XR/Mocks/index.d.ts +0 -2
  76. package/lib/Components/XR/Mocks/index.js +0 -14
  77. package/lib/Components/zSpace/Controllers/EmulateStylus.d.ts +0 -10
  78. package/lib/Components/zSpace/Controllers/EmulateStylus.js +0 -113
  79. package/lib/Components/zSpace/Controllers/ZSpaceScaleRoot.d.ts +0 -14
  80. package/lib/Components/zSpace/Controllers/ZSpaceScaleRoot.js +0 -57
  81. package/lib/Components/zSpace/Controllers/index.d.ts +0 -1
  82. package/lib/Components/zSpace/Controllers/index.js +0 -13
  83. package/lib/Components/zSpace/Entities/ZSpaceStylusEntity.d.ts +0 -29
  84. package/lib/Components/zSpace/Entities/ZSpaceStylusEntity.js +0 -115
  85. package/lib/Components/zSpace/Mocks/index.d.ts +0 -1
  86. package/lib/Components/zSpace/Mocks/index.js +0 -13
  87. package/lib/Components/zSpace/PM/StylusColorLengthPM.d.ts +0 -13
  88. package/lib/Components/zSpace/PM/StylusColorLengthPM.js +0 -77
  89. package/lib/Components/zSpace/PM/StylusIsInUsePM.d.ts +0 -6
  90. package/lib/Components/zSpace/PM/StylusIsInUsePM.js +0 -42
  91. package/lib/Types/ChannelModelData.d.ts +0 -67
  92. package/lib/Types/ChannelModelData.js +0 -21
@@ -1,77 +0,0 @@
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;
@@ -1,11 +0,0 @@
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
- }
@@ -1,44 +0,0 @@
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";
@@ -1,2 +0,0 @@
1
- export * from "./MockTouchInput";
2
- export * from "./mockTouchInputEvent";
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./MockTouchInput"), exports);
14
- __exportStar(require("./mockTouchInputEvent"), exports);
@@ -1 +0,0 @@
1
- export * from "./MockUndoRedo";
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./MockUndoRedo"), exports);
@@ -1,2 +0,0 @@
1
- export * from "./MockRenderToXR";
2
- export * from "./MockXRSession";
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./MockRenderToXR"), exports);
14
- __exportStar(require("./MockXRSession"), exports);
@@ -1,10 +0,0 @@
1
- import { AppObject, AppObjectController } from "../../../AppObject";
2
- import { MouseController, MouseInputEvent, MouseWheelEvent } from "../../MouseInput";
3
- export default abstract class EmulateZSpaceStylus extends AppObjectController implements MouseController {
4
- static readonly type = "EmulateZSpaceStylus";
5
- abstract onDown: (e: MouseInputEvent) => void;
6
- abstract onMove: (e: MouseInputEvent) => void;
7
- abstract onUp: (e: MouseInputEvent) => void;
8
- abstract onWheel: (e: MouseWheelEvent) => void;
9
- }
10
- export declare function makeEmulateZSpaceStylus(appObject: AppObject): EmulateZSpaceStylus;
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeEmulateZSpaceStylus = void 0;
4
- const AppObject_1 = require("../../../AppObject");
5
- const ValueObjects_1 = require("../../../ValueObjects");
6
- const Babylon_1 = require("../../Babylon");
7
- const MouseInput_1 = require("../../MouseInput");
8
- const Entities_1 = require("../Entities/");
9
- const PM_1 = require("../PM");
10
- class EmulateZSpaceStylus extends AppObject_1.AppObjectController {
11
- }
12
- exports.default = EmulateZSpaceStylus;
13
- EmulateZSpaceStylus.type = "EmulateZSpaceStylus";
14
- function makeEmulateZSpaceStylus(appObject) {
15
- return new EmulateZSpaceStylusImp(appObject);
16
- }
17
- exports.makeEmulateZSpaceStylus = makeEmulateZSpaceStylus;
18
- class EmulateZSpaceStylusImp extends EmulateZSpaceStylus {
19
- constructor(appObject) {
20
- super(appObject, EmulateZSpaceStylus.type);
21
- this.emulationIsActive = false;
22
- this.screenPlane = ValueObjects_1.ParametricPlane.FromPointNormal(ValueObjects_1.Vector3.Zero(), ValueObjects_1.Vector3.Backward());
23
- this.onDown = (e) => {
24
- if (!this.emulationIsActive)
25
- return;
26
- if (!this.stylus)
27
- return;
28
- this.stylus.updateButtonState(e.button, true);
29
- };
30
- this.onMove = (e) => {
31
- if (!this.emulationIsActive)
32
- return;
33
- if (!this.stylusTransform)
34
- return;
35
- const ray = this.pixelToSceneRay(e.position);
36
- const hit = this.screenPlane.intersectLine(ray);
37
- if (!hit) {
38
- return;
39
- }
40
- const direction = ValueObjects_1.Vector3.Subtract(hit, this.stylusTransform.localPosition);
41
- this.stylusTransform.localRotation = ValueObjects_1.Quaternion.FromDirectionVector(direction);
42
- };
43
- this.onUp = (e) => {
44
- if (!this.emulationIsActive)
45
- return;
46
- if (!this.stylus)
47
- return;
48
- this.stylus.updateButtonState(e.button, false);
49
- };
50
- this.onWheel = (e) => {
51
- if (!this.emulationIsActive)
52
- return;
53
- if (!this.stylus)
54
- return;
55
- if (!this.stylusTransform)
56
- return;
57
- const bumpAmount = 0.01;
58
- const bump = e.event.deltaY > 0 ? -bumpAmount : bumpAmount;
59
- const newPos = this.stylusTransform.localPointToWorld(new ValueObjects_1.Vector3(0, 0, bump));
60
- this.stylusTransform.worldPosition = newPos;
61
- console.log(newPos);
62
- };
63
- this.onZpsaceEnabledChange = (enabled) => {
64
- this.emulationIsActive = false;
65
- if (!enabled)
66
- return;
67
- if (!this.zSpaceEntity)
68
- return;
69
- if (!this.zSpaceEntity.emulate)
70
- return;
71
- this.emulationIsActive = true;
72
- if (this.stylusTransform) {
73
- this.stylusTransform.localPosition = new ValueObjects_1.Vector3(0.05, -0.05, -0.5);
74
- }
75
- };
76
- this.zSpaceEntity = Entities_1.ZSpaceEntity.get(this.appObjects);
77
- if (!this.zSpaceEntity) {
78
- this.warn("Unable to find ZSpaceEntity");
79
- return;
80
- }
81
- const pm = this.zSpaceEntity.appObject.getComponent(PM_1.ZSpaceIsEnabledPM.type);
82
- if (!pm) {
83
- this.warn("Unable to find ZSpaceIsEnabledPM");
84
- return;
85
- }
86
- this.stylus = appObject.getComponent(Entities_1.ZSpaceStylusEntity.type);
87
- if (!this.stylus) {
88
- this.warn("Controller has been added to an app object that does not have a ZSpaceStylusEntity");
89
- return;
90
- }
91
- this.stylusTransform = this.stylus.transform;
92
- const mouseInput = MouseInput_1.MouseInputEntity.get(appObject.appObjectRepo);
93
- if (mouseInput) {
94
- mouseInput.registerController(this);
95
- }
96
- else {
97
- this.warn("Unable to find MouseInputEntity");
98
- return;
99
- }
100
- mouseInput.registerController(this);
101
- pm.addView(this.onZpsaceEnabledChange);
102
- }
103
- pixelToSceneRay(pixelPos) {
104
- if (!this.pixelToSceneRayUC) {
105
- this.pixelToSceneRayUC = Babylon_1.PixelToSceneRayUC.get(this.appObjects);
106
- if (!this.pixelToSceneRayUC) {
107
- this.warn("Unable to find PixelToSceneRayUC");
108
- return ValueObjects_1.ParametricLine.Forward();
109
- }
110
- }
111
- return this.pixelToSceneRayUC.pixelToSceneRay(pixelPos);
112
- }
113
- }
@@ -1,14 +0,0 @@
1
- import { AppObject } from "../../../AppObject/AppObject";
2
- import { AppObjectController } from "../../../AppObject/AppObjectController";
3
- import { ZSpaceStylusButton, ZSpaceStylusController } from "../Entities/ZSpaceStylusEntity";
4
- export declare class ZSpaceScaleRoot extends AppObjectController implements ZSpaceStylusController {
5
- static readonly type = "ZSpaceScaleRoot";
6
- private stylus?;
7
- private scaleSceneRootWithRay?;
8
- private isScaling;
9
- allow: (button: ZSpaceStylusButton) => boolean;
10
- onButtonDown: (button: ZSpaceStylusButton) => void;
11
- onStylusMove: () => void;
12
- onButtonUp: () => void;
13
- constructor(appObject: AppObject);
14
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZSpaceScaleRoot = void 0;
4
- const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
- const SceneRoot_1 = require("../../SceneRoot");
6
- const ScaleSceneRootWithRay_1 = require("../../SceneRoot/UC/ScaleSceneRootWithRay");
7
- const ZSpaceStylusEntity_1 = require("../Entities/ZSpaceStylusEntity");
8
- class ZSpaceScaleRoot extends AppObjectController_1.AppObjectController {
9
- constructor(appObject) {
10
- super(appObject, ZSpaceScaleRoot.type);
11
- this.isScaling = false;
12
- this.allow = (button) => {
13
- if (button === ZSpaceStylusEntity_1.ZSpaceStylusButton.BACK_RIGHT)
14
- return true;
15
- return false;
16
- };
17
- this.onButtonDown = (button) => {
18
- var _a;
19
- this.isScaling = false;
20
- if (!this.stylus)
21
- return;
22
- if (!this.allow(button))
23
- return;
24
- const pointerRay = this.stylus.pickRay;
25
- const rayStart = this.stylus.transform.localPosition;
26
- (_a = this.scaleSceneRootWithRay) === null || _a === void 0 ? void 0 : _a.initializeScale(pointerRay, rayStart);
27
- this.isScaling = true;
28
- };
29
- this.onStylusMove = () => {
30
- var _a;
31
- if (!this.stylus)
32
- return;
33
- if (!this.isScaling)
34
- return;
35
- const pointerRay = this.stylus.pickRay;
36
- const rayStart = this.stylus.transform.localPosition;
37
- (_a = this.scaleSceneRootWithRay) === null || _a === void 0 ? void 0 : _a.doScale(pointerRay, rayStart);
38
- };
39
- this.onButtonUp = () => {
40
- this.isScaling = false;
41
- };
42
- this.stylus = appObject.getComponent(ZSpaceStylusEntity_1.ZSpaceStylusEntity.type);
43
- const sceneRoot = SceneRoot_1.SceneRootEntity.get(appObject.appObjectRepo);
44
- this.scaleSceneRootWithRay = sceneRoot === null || sceneRoot === void 0 ? void 0 : sceneRoot.appObject.getComponent(ScaleSceneRootWithRay_1.ScaleSceneRootWithRay.type);
45
- if (!this.stylus) {
46
- this.warn("StylusInputPointer Controller has been added to an app object that does not have a ZSpaceStylusEntity");
47
- }
48
- else if (!this.scaleSceneRootWithRay) {
49
- this.warn("StylusRootScaleSceneRootWithRay was not found on the Scene Root App Object");
50
- }
51
- else {
52
- this.stylus.registerController(this);
53
- }
54
- }
55
- }
56
- exports.ZSpaceScaleRoot = ZSpaceScaleRoot;
57
- ZSpaceScaleRoot.type = "ZSpaceScaleRoot";
@@ -1 +0,0 @@
1
- export * from "./EmulateStylus";
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./EmulateStylus"), exports);
@@ -1,29 +0,0 @@
1
- import { AppObjectRepo } from "../../../AppObject";
2
- import { AppObject } from "../../../AppObject/AppObject";
3
- import { AppObjectEntity } from "../../../AppObject/AppObjectEntity";
4
- import { ParametricLine } from "../../../ValueObjects";
5
- import { Transform3D } from "../../Transform3D";
6
- export declare enum ZSpaceStylusButton {
7
- PRIMARY = 0,
8
- BACK_RIGHT = 1,
9
- BACK_LEFT = 2
10
- }
11
- export interface ZSpaceStylusController {
12
- onButtonDown?: (button: ZSpaceStylusButton) => void;
13
- onButtonUp?: (button: ZSpaceStylusButton) => void;
14
- onButtonClick?: (button: ZSpaceStylusButton) => void;
15
- onStylusMove?: (transform: Transform3D) => void;
16
- }
17
- export declare abstract class ZSpaceStylusEntity extends AppObjectEntity {
18
- static readonly type = "ZSpaceStylusEntity";
19
- static clickMovementThreshold: number;
20
- static clickTimeThresholdMS: number;
21
- abstract registerController: (controller: ZSpaceStylusController) => void;
22
- abstract updateButtonState: (button: ZSpaceStylusButton, isPressed: boolean) => void;
23
- abstract readonly transform: Transform3D;
24
- abstract readonly helperTransform: Transform3D;
25
- abstract get pickRay(): ParametricLine;
26
- abstract get isInUse(): boolean;
27
- static get(appObjects: AppObjectRepo): ZSpaceStylusEntity | undefined;
28
- }
29
- export declare function makeZSpaceStylus(appObj: AppObject): ZSpaceStylusEntity;
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeZSpaceStylus = exports.ZSpaceStylusEntity = exports.ZSpaceStylusButton = void 0;
4
- const AppObject_1 = require("../../../AppObject");
5
- const AppObjectEntity_1 = require("../../../AppObject/AppObjectEntity");
6
- const Entities_1 = require("../../../Entities");
7
- const ValueObjects_1 = require("../../../ValueObjects");
8
- const Transform3D_1 = require("../../Transform3D");
9
- var ZSpaceStylusButton;
10
- (function (ZSpaceStylusButton) {
11
- ZSpaceStylusButton[ZSpaceStylusButton["PRIMARY"] = 0] = "PRIMARY";
12
- ZSpaceStylusButton[ZSpaceStylusButton["BACK_RIGHT"] = 1] = "BACK_RIGHT";
13
- ZSpaceStylusButton[ZSpaceStylusButton["BACK_LEFT"] = 2] = "BACK_LEFT";
14
- })(ZSpaceStylusButton = exports.ZSpaceStylusButton || (exports.ZSpaceStylusButton = {}));
15
- class ZSpaceStylusEntity extends AppObjectEntity_1.AppObjectEntity {
16
- static get(appObjects) {
17
- return AppObject_1.getSingletonComponent(ZSpaceStylusEntity.type, appObjects);
18
- }
19
- }
20
- exports.ZSpaceStylusEntity = ZSpaceStylusEntity;
21
- ZSpaceStylusEntity.type = "ZSpaceStylusEntity";
22
- ZSpaceStylusEntity.clickMovementThreshold = 0.32;
23
- ZSpaceStylusEntity.clickTimeThresholdMS = 350;
24
- function makeZSpaceStylus(appObj) {
25
- const transform = Transform3D_1.Transform3D.addIfMissing(appObj);
26
- return new StylusImp(appObj, transform);
27
- }
28
- exports.makeZSpaceStylus = makeZSpaceStylus;
29
- class StylusImp extends ZSpaceStylusEntity {
30
- constructor(appObject, transform) {
31
- super(appObject, ZSpaceStylusEntity.type);
32
- this.controllers = [];
33
- this.buttonStates = [false, false, false];
34
- this.pressPosition = ValueObjects_1.Vector3.Zero();
35
- this.pressTime = 0;
36
- this.registerController = (controller) => {
37
- this.controllers.push(controller);
38
- };
39
- this.updateButtonState = (button, isPressed) => {
40
- if (this.buttonStates[button] === isPressed)
41
- return;
42
- this.controllers.forEach((controller) => {
43
- if (isPressed) {
44
- if (controller.onButtonDown) {
45
- controller.onButtonDown(button);
46
- }
47
- this.lassPressedButton = button;
48
- this.pressPosition = this.transform.localPosition;
49
- this.pressTime = Date.now();
50
- }
51
- else {
52
- if (controller.onButtonUp) {
53
- controller.onButtonUp(button);
54
- }
55
- if (this.isClick(button) && controller.onButtonClick) {
56
- controller.onButtonClick(button);
57
- }
58
- }
59
- });
60
- this.buttonStates[button] = isPressed;
61
- this.notifyOnChange();
62
- };
63
- this.isClick = (button) => {
64
- const buttonIsCorrect = button === this.lassPressedButton;
65
- const movement = ValueObjects_1.Vector3.Subtract(this.transform.localPosition, this.pressPosition).magnitude;
66
- const movementIsSmallEnough = movement < ZSpaceStylusEntity.clickMovementThreshold;
67
- const passedTime = Date.now() - this.pressTime;
68
- const pressTimeIsShortEnough = passedTime < ZSpaceStylusEntity.clickTimeThresholdMS;
69
- if (buttonIsCorrect && movementIsSmallEnough && pressTimeIsShortEnough) {
70
- return true;
71
- }
72
- else {
73
- return false;
74
- }
75
- };
76
- this.onTransformUpdate = () => {
77
- this.checkIfStylusIsInUse(this.transform.worldMatrix);
78
- this.controllers.forEach((controller) => {
79
- if (controller.onStylusMove) {
80
- controller.onStylusMove(this.transform);
81
- }
82
- });
83
- this.notifyOnChange();
84
- };
85
- this.memoizedIsInUse = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
86
- this.transform = transform;
87
- this.transform.addChangeObserver(this.onTransformUpdate);
88
- const helperTransformAO = appObject.appObjectRepo.getOrCreate("StylusHelper");
89
- this.helperTransform = Transform3D_1.Transform3D.addIfMissing(helperTransformAO);
90
- this.helperTransform.parent = this.transform;
91
- }
92
- get pickRay() {
93
- return ValueObjects_1.ParametricLine.FromPointDirection(this.transform.worldPosition, this.transform.localDirectionToWorld(ValueObjects_1.Vector3.Forward()));
94
- }
95
- get isInUse() {
96
- return this.memoizedIsInUse.val;
97
- }
98
- checkIfStylusIsInUse(worldMatrix) {
99
- const m = worldMatrix.m;
100
- if (m[1] === 0 &&
101
- m[2] === 0 &&
102
- m[3] === 0 &&
103
- m[4] === 0 &&
104
- m[7] === 0 &&
105
- m[8] === 0 &&
106
- m[11] === 0 &&
107
- m[12] === 0 &&
108
- m[15] === 1) {
109
- this.memoizedIsInUse.val = false;
110
- }
111
- else {
112
- this.memoizedIsInUse.val = true;
113
- }
114
- }
115
- }
@@ -1 +0,0 @@
1
- export * from "./MockCheckZSpaceDisplaySizeUC";
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./MockCheckZSpaceDisplaySizeUC"), exports);
@@ -1,13 +0,0 @@
1
- import { AppObject, AppObjectPM } from "../../../AppObject";
2
- import { Color } from "../../../ValueObjects";
3
- export interface StylusColorLengthVM {
4
- color: Color;
5
- length: number;
6
- }
7
- export declare abstract class StylusColorLengthPM extends AppObjectPM<StylusColorLengthVM> {
8
- static readonly type = "StylusColorLengthPM";
9
- abstract rayColorNoPick: Color;
10
- abstract rayColorPick: Color;
11
- abstract defaultLength: number;
12
- }
13
- export declare function makeStylusColorLengthPM(appObject: AppObject): StylusColorLengthPM;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeStylusColorLengthPM = exports.StylusColorLengthPM = void 0;
4
- const AppObject_1 = require("../../../AppObject");
5
- const ValueObjects_1 = require("../../../ValueObjects");
6
- const Babylon_1 = require("../../Babylon");
7
- const ZSpaceStylusEntity_1 = require("../Entities/ZSpaceStylusEntity");
8
- class StylusColorLengthPM extends AppObject_1.AppObjectPM {
9
- }
10
- exports.StylusColorLengthPM = StylusColorLengthPM;
11
- StylusColorLengthPM.type = "StylusColorLengthPM";
12
- function makeStylusColorLengthPM(appObject) {
13
- return new StylusColorLengthPMImp(appObject);
14
- }
15
- exports.makeStylusColorLengthPM = makeStylusColorLengthPM;
16
- class StylusColorLengthPMImp extends StylusColorLengthPM {
17
- constructor(appObject) {
18
- super(appObject, StylusColorLengthPM.type);
19
- this.defaultLength = 1;
20
- this.rayColorNoPick = ValueObjects_1.Color.RGB(128, 128, 128);
21
- this.rayColorPick = ValueObjects_1.Color.RGB(0, 255, 0);
22
- this.onEntityChange = () => {
23
- if (!this.stylus || !this.stylus.isInUse) {
24
- this.setDefaultVM();
25
- return;
26
- }
27
- const pickRay = this.stylus.pickRay;
28
- const scenePickUC = Babylon_1.SceneRayPickUC.get(this.appObject.appObjectRepo);
29
- if (!scenePickUC) {
30
- this.setDefaultVM();
31
- return;
32
- }
33
- const scenePick = scenePickUC.sceneRayPick(pickRay);
34
- let color = this.rayColorNoPick;
35
- let length = this.defaultLength;
36
- if (scenePick && (scenePick === null || scenePick === void 0 ? void 0 : scenePick.hit) && scenePick.worldPickPoint) {
37
- color = this.rayColorPick;
38
- length = Math.abs(ValueObjects_1.Vector3.Subtract(this.stylus.transform.worldPosition, scenePick.worldPickPoint).magnitude);
39
- }
40
- const vm = {
41
- color,
42
- length,
43
- };
44
- this.doUpdateView(vm);
45
- };
46
- this.dispose = () => {
47
- var _a, _b;
48
- super.dispose();
49
- (_a = this.stylus) === null || _a === void 0 ? void 0 : _a.removeChangeObserver(this.onEntityChange);
50
- (_b = this.stylus) === null || _b === void 0 ? void 0 : _b.removeOnDisposeObserver(this.dispose);
51
- };
52
- this.stylus = appObject.getComponent(ZSpaceStylusEntity_1.ZSpaceStylusEntity.type);
53
- if (this.stylus) {
54
- this.stylus.addChangeObserver(this.onEntityChange);
55
- this.stylus.addOnDisposeObserver(() => {
56
- this.dispose();
57
- });
58
- this.onEntityChange();
59
- }
60
- else {
61
- this.warn("App Object does not have a Stylus Entity");
62
- }
63
- }
64
- vmsAreEqual(a, b) {
65
- if (ValueObjects_1.Color.Equal(a.color, b.color) && a.length === b.length) {
66
- return true;
67
- }
68
- return false;
69
- }
70
- setDefaultVM() {
71
- const vm = {
72
- color: this.rayColorNoPick,
73
- length: 0,
74
- };
75
- this.doUpdateView(vm);
76
- }
77
- }