@vived/app 4.12.0 → 4.14.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 (110) hide show
  1. package/lib/Components/HoverLabel/Controllers/StylusHoverLabel.d.ts +2 -2
  2. package/lib/Components/HoverLabel/Controllers/StylusHoverLabel.js +3 -3
  3. package/lib/Components/Question/Entities/QuestionAnswerEntity.d.ts +0 -1
  4. package/lib/Components/Question/Entities/QuestionAnswerEntity.js +2 -6
  5. package/lib/Components/RequestHandler/UC/StartZSpaceUC.js +12 -1
  6. package/lib/Components/RequestHandler/UC/StopZSpaceUC.js +20 -7
  7. package/lib/Components/SceneRoot/Controllers/ScaleSceneRootSC.d.ts +14 -0
  8. package/lib/Components/SceneRoot/Controllers/ScaleSceneRootSC.js +55 -0
  9. package/lib/Components/SceneRoot/Controllers/SceneRootMoveSC.d.ts +14 -0
  10. package/lib/Components/SceneRoot/Controllers/SceneRootMoveSC.js +53 -0
  11. package/lib/Components/SceneRoot/Controllers/index.d.ts +2 -2
  12. package/lib/Components/SceneRoot/Controllers/index.js +2 -2
  13. package/lib/Components/Selection/Controller/HoverOnAppObjectSC.d.ts +11 -0
  14. package/lib/Components/Selection/Controller/HoverOnAppObjectSC.js +41 -0
  15. package/lib/Components/Selection/Controller/PressOnAppObjectSC.d.ts +18 -0
  16. package/lib/Components/Selection/Controller/PressOnAppObjectSC.js +70 -0
  17. package/lib/Components/Selection/Controller/SelectAppObjectSC.d.ts +11 -0
  18. package/lib/Components/Selection/Controller/SelectAppObjectSC.js +39 -0
  19. package/lib/Components/Selection/Controller/index.d.ts +3 -3
  20. package/lib/Components/Selection/Controller/index.js +3 -3
  21. package/lib/Components/Stylus/Entity/StylusEntity.d.ts +21 -0
  22. package/lib/Components/Stylus/Entity/StylusEntity.js +104 -0
  23. package/lib/Components/Stylus/Entity/index.d.ts +1 -0
  24. package/lib/Components/Stylus/Entity/index.js +13 -0
  25. package/lib/Components/Stylus/Mocks/MockEmulateStylusUC.d.ts +10 -0
  26. package/lib/Components/Stylus/Mocks/MockEmulateStylusUC.js +19 -0
  27. package/lib/Components/Stylus/Mocks/index.d.ts +1 -0
  28. package/lib/Components/Stylus/Mocks/index.js +13 -0
  29. package/lib/Components/Stylus/PMs/StylusColorLengthPM.d.ts +14 -0
  30. package/lib/Components/Stylus/PMs/StylusColorLengthPM.js +81 -0
  31. package/lib/Components/Stylus/PMs/StylusIsInUsePM.d.ts +6 -0
  32. package/lib/Components/Stylus/PMs/StylusIsInUsePM.js +36 -0
  33. package/lib/Components/Stylus/PMs/index.d.ts +2 -0
  34. package/lib/Components/Stylus/PMs/index.js +14 -0
  35. package/lib/Components/Stylus/UCs/EmulateStylusUC.d.ts +9 -0
  36. package/lib/Components/Stylus/UCs/EmulateStylusUC.js +132 -0
  37. package/lib/Components/Stylus/UCs/index.d.ts +1 -0
  38. package/lib/Components/Stylus/UCs/index.js +13 -0
  39. package/lib/Components/Stylus/index.d.ts +4 -0
  40. package/lib/Components/Stylus/index.js +16 -0
  41. package/lib/Components/Transform3D/Controllers/Mouse/DragScaleTransformMC.d.ts +12 -0
  42. package/lib/Components/Transform3D/Controllers/Mouse/DragScaleTransformMC.js +49 -0
  43. package/lib/Components/Transform3D/Controllers/Mouse/PanTransformMC.d.ts +12 -0
  44. package/lib/Components/Transform3D/Controllers/Mouse/PanTransformMC.js +48 -0
  45. package/lib/Components/Transform3D/Controllers/Mouse/RollScaleTransformMC.d.ts +9 -0
  46. package/lib/Components/Transform3D/Controllers/Mouse/RollScaleTransformMC.js +37 -0
  47. package/lib/Components/Transform3D/Controllers/Mouse/index.d.ts +3 -0
  48. package/lib/Components/Transform3D/Controllers/Mouse/index.js +15 -0
  49. package/lib/Components/Transform3D/Controllers/Stylus/PanScaleTransformSC.d.ts +13 -0
  50. package/lib/Components/Transform3D/Controllers/Stylus/PanScaleTransformSC.js +54 -0
  51. package/lib/Components/Transform3D/Controllers/Stylus/PanTransformSC.d.ts +13 -0
  52. package/lib/Components/Transform3D/Controllers/Stylus/PanTransformSC.js +54 -0
  53. package/lib/Components/Transform3D/Controllers/Stylus/ScaleTransformSC.d.ts +13 -0
  54. package/lib/Components/Transform3D/Controllers/Stylus/ScaleTransformSC.js +54 -0
  55. package/lib/Components/Transform3D/Controllers/Stylus/index.d.ts +3 -0
  56. package/lib/Components/Transform3D/Controllers/Stylus/index.js +15 -0
  57. package/lib/Components/Transform3D/Controllers/Touch/DragScaleTransformTC.d.ts +13 -0
  58. package/lib/Components/Transform3D/Controllers/Touch/DragScaleTransformTC.js +60 -0
  59. package/lib/Components/Transform3D/Controllers/Touch/PanTransformTC.d.ts +12 -0
  60. package/lib/Components/Transform3D/Controllers/Touch/PanTransformTC.js +52 -0
  61. package/lib/Components/Transform3D/Controllers/Touch/PinchTransformTC.d.ts +13 -0
  62. package/lib/Components/Transform3D/Controllers/Touch/PinchTransformTC.js +55 -0
  63. package/lib/Components/Transform3D/Controllers/Touch/index.d.ts +3 -0
  64. package/lib/Components/Transform3D/Controllers/Touch/index.js +15 -0
  65. package/lib/Components/Transform3D/Controllers/index.d.ts +3 -0
  66. package/lib/Components/Transform3D/Controllers/index.js +15 -0
  67. package/lib/Components/Transform3D/Mocks/MockBumpTransformScaleAboutPixelPoint.d.ts +12 -0
  68. package/lib/Components/Transform3D/Mocks/MockBumpTransformScaleAboutPixelPoint.js +14 -0
  69. package/lib/Components/Transform3D/Mocks/MockPanTransformUC.d.ts +18 -0
  70. package/lib/Components/Transform3D/Mocks/MockPanTransformUC.js +18 -0
  71. package/lib/Components/Transform3D/Mocks/MockPinchTransformUC.d.ts +13 -0
  72. package/lib/Components/Transform3D/Mocks/MockPinchTransformUC.js +15 -0
  73. package/lib/Components/Transform3D/Mocks/MockRayPanScaleTransformUC.d.ts +17 -0
  74. package/lib/Components/Transform3D/Mocks/MockRayPanScaleTransformUC.js +15 -0
  75. package/lib/Components/Transform3D/Mocks/MockRayScaleTransform.d.ts +16 -0
  76. package/lib/Components/Transform3D/Mocks/MockRayScaleTransform.js +18 -0
  77. package/lib/Components/Transform3D/Mocks/index.d.ts +5 -0
  78. package/lib/Components/Transform3D/Mocks/index.js +17 -0
  79. package/lib/Components/Transform3D/UC/BumpTransformScaleAboutPixelPoint.d.ts +12 -0
  80. package/lib/Components/Transform3D/UC/BumpTransformScaleAboutPixelPoint.js +67 -0
  81. package/lib/Components/Transform3D/UC/PanTransformUC.d.ts +18 -0
  82. package/lib/Components/Transform3D/UC/PanTransformUC.js +94 -0
  83. package/lib/Components/Transform3D/UC/PinchTransform.d.ts +13 -0
  84. package/lib/Components/Transform3D/UC/PinchTransform.js +90 -0
  85. package/lib/Components/Transform3D/UC/RayPanScaleTransform.d.ts +17 -0
  86. package/lib/Components/Transform3D/UC/RayPanScaleTransform.js +108 -0
  87. package/lib/Components/Transform3D/UC/ScaleTransform.d.ts +16 -0
  88. package/lib/Components/Transform3D/UC/ScaleTransform.js +104 -0
  89. package/lib/Components/Transform3D/UC/StylusMoveTransformUC.js +14 -35
  90. package/lib/Components/Transform3D/UC/index.d.ts +6 -0
  91. package/lib/Components/Transform3D/UC/index.js +6 -0
  92. package/lib/Components/Transform3D/index.d.ts +2 -0
  93. package/lib/Components/Transform3D/index.js +2 -0
  94. package/lib/Components/index.d.ts +5 -4
  95. package/lib/Components/index.js +5 -4
  96. package/lib/Components/zSpace/Entities/ZSpaceEntity.d.ts +0 -2
  97. package/lib/Components/zSpace/Entities/ZSpaceEntity.js +0 -3
  98. package/lib/Components/zSpace/Entities/index.d.ts +0 -1
  99. package/lib/Components/zSpace/Entities/index.js +0 -1
  100. package/lib/Components/zSpace/PM/index.d.ts +0 -2
  101. package/lib/Components/zSpace/PM/index.js +0 -2
  102. package/lib/Components/zSpace/UC/StylusFromGamepadHook.d.ts +2 -3
  103. package/lib/Components/zSpace/UC/StylusFromGamepadHook.js +14 -13
  104. package/lib/Components/zSpace/index.d.ts +0 -1
  105. package/lib/Components/zSpace/index.js +0 -1
  106. package/lib/Entities/TransformNode.d.ts +0 -55
  107. package/lib/ValueObjects/Color.js +1 -1
  108. package/lib/ValueObjects/ParametricLine.d.ts +3 -0
  109. package/lib/ValueObjects/ParametricLine.js +13 -3
  110. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { AppObject, AppObjectController } from "../../../AppObject";
2
- import { ZSpaceStylusController } from "../../zSpace";
3
- export declare abstract class ZSpaceStylusHoverLabel extends AppObjectController implements ZSpaceStylusController {
2
+ import { StylusController } from "../../Stylus";
3
+ export declare abstract class ZSpaceStylusHoverLabel extends AppObjectController implements StylusController {
4
4
  static readonly type = "StylusHoverLabelController";
5
5
  abstract onStylusMove(): void;
6
6
  abstract allow: () => boolean;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeStylusHoverLabelController = exports.ZSpaceStylusHoverLabel = void 0;
4
4
  const AppObject_1 = require("../../../AppObject");
5
- const zSpace_1 = require("../../zSpace");
5
+ const Stylus_1 = require("../../Stylus");
6
6
  const UseCases_1 = require("../UseCases");
7
7
  class ZSpaceStylusHoverLabel extends AppObject_1.AppObjectController {
8
8
  }
@@ -28,10 +28,10 @@ class ZSpaceStylusHoverLabelImp extends ZSpaceStylusHoverLabel {
28
28
  }
29
29
  (_a = this.tryShowStylusHoverLabel) === null || _a === void 0 ? void 0 : _a.tryShowWorldHoverLabel(this.stylus.pickRay);
30
30
  };
31
- this.stylus = zSpace_1.ZSpaceStylusEntity.get(this.appObjects);
31
+ this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
32
32
  this.tryShowStylusHoverLabel = UseCases_1.TryShowHoverLabel.get(this.appObjects);
33
33
  if (!this.stylus) {
34
- this.error("Cannot find ZSpaceStylusEntity");
34
+ this.error("Cannot find StylusEntity");
35
35
  }
36
36
  else if (!this.tryShowStylusHoverLabel) {
37
37
  this.error("Cannot find TryShowHoverLabel");
@@ -5,7 +5,6 @@ export declare const MAX_QUESTION_LENGTH = 40;
5
5
  export declare const LONG_TEXT_VALIDATION_MESSAGE: string;
6
6
  export declare const MAX_FEEDBACK_LENGTH = 200;
7
7
  export declare const LONG_FEEDBACK_VALIDATION_MESSAGE: string;
8
- export declare const FEEDBACK_STRING_CANNOT_BE_0_CHARACTERS = "Feedback string cannot be 0 characters.";
9
8
  export declare abstract class QuestionAnswerEntity extends AppObjectEntity {
10
9
  static readonly type = "QuestionAnswerEntity";
11
10
  abstract readonly id: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeQuestionAnswerEntity = exports.QuestionAnswerEntity = exports.FEEDBACK_STRING_CANNOT_BE_0_CHARACTERS = exports.LONG_FEEDBACK_VALIDATION_MESSAGE = exports.MAX_FEEDBACK_LENGTH = exports.LONG_TEXT_VALIDATION_MESSAGE = exports.MAX_QUESTION_LENGTH = exports.EMPTY_TEXT_VALIDATION_MESSAGE = void 0;
3
+ exports.makeQuestionAnswerEntity = exports.QuestionAnswerEntity = exports.LONG_FEEDBACK_VALIDATION_MESSAGE = exports.MAX_FEEDBACK_LENGTH = exports.LONG_TEXT_VALIDATION_MESSAGE = exports.MAX_QUESTION_LENGTH = exports.EMPTY_TEXT_VALIDATION_MESSAGE = void 0;
4
4
  const AppObjectEntity_1 = require("../../../AppObject/AppObjectEntity");
5
5
  const Entities_1 = require("../../../Entities");
6
6
  exports.EMPTY_TEXT_VALIDATION_MESSAGE = "Answer text is required.";
@@ -8,7 +8,6 @@ exports.MAX_QUESTION_LENGTH = 40;
8
8
  exports.LONG_TEXT_VALIDATION_MESSAGE = `Answer text may not exceed ${exports.MAX_QUESTION_LENGTH} characters.`;
9
9
  exports.MAX_FEEDBACK_LENGTH = 200;
10
10
  exports.LONG_FEEDBACK_VALIDATION_MESSAGE = `Answer feedback may not exceed ${exports.MAX_FEEDBACK_LENGTH} characters.`;
11
- exports.FEEDBACK_STRING_CANNOT_BE_0_CHARACTERS = "Feedback string cannot be 0 characters.";
12
11
  class QuestionAnswerEntity extends AppObjectEntity_1.AppObjectEntity {
13
12
  }
14
13
  exports.QuestionAnswerEntity = QuestionAnswerEntity;
@@ -52,10 +51,7 @@ class QuestionAnswerEntityImp extends QuestionAnswerEntity {
52
51
  this.memoizedFeedback.val = val;
53
52
  }
54
53
  get feedbackValidationMessage() {
55
- if (this.feedbackText.length === 0) {
56
- return exports.FEEDBACK_STRING_CANNOT_BE_0_CHARACTERS;
57
- }
58
- else if (this.feedbackText.length > exports.MAX_FEEDBACK_LENGTH) {
54
+ if (this.feedbackText.length > exports.MAX_FEEDBACK_LENGTH) {
59
55
  return exports.LONG_FEEDBACK_VALIDATION_MESSAGE;
60
56
  }
61
57
  else {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeStartZSpaceUC = exports.StartZSpaceBaseUC = void 0;
4
4
  const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const Stylus_1 = require("../../Stylus");
5
6
  const XR_1 = require("../../XR");
6
7
  const zSpace_1 = require("../../zSpace");
7
8
  const Entities_1 = require("../Entities");
@@ -35,7 +36,17 @@ class StartZSpaceBaseUCImp extends StartZSpaceBaseUC {
35
36
  }
36
37
  zSpaceEntity.display.setForDevice(zSpace_1.ZSpaceDevice.INSPIRE);
37
38
  zSpaceEntity.emulate = emulate;
38
- if (!emulate) {
39
+ if (emulate) {
40
+ const emulateStylus = Stylus_1.EmulateStylusUC.get(appObjects);
41
+ if (emulateStylus) {
42
+ emulateStylus.startEmulating();
43
+ }
44
+ else {
45
+ appObjects.submitWarning("startZSpaceAction", "EmulateStylusUC not found");
46
+ return;
47
+ }
48
+ }
49
+ else {
39
50
  const xrSession = session;
40
51
  if (!xrSession) {
41
52
  this.warn("Unable to cast the XR session");
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeStopZSpaceUC = exports.StopZSpaceUC = void 0;
4
4
  const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
+ const Stylus_1 = require("../../Stylus");
5
6
  const XR_1 = require("../../XR");
6
7
  const zSpace_1 = require("../../zSpace");
7
8
  const Entities_1 = require("../Entities");
@@ -24,18 +25,30 @@ class StopZSpaceUCImp extends StopZSpaceUC {
24
25
  this.action = () => {
25
26
  const appObjects = this.appObject.appObjectRepo;
26
27
  const zSpaceEntity = zSpace_1.ZSpaceEntity.get(appObjects);
27
- if (!zSpaceEntity) {
28
- console.warn("No zSpace Entity Found");
28
+ if (zSpaceEntity) {
29
+ zSpaceEntity.enabled = false;
30
+ zSpaceEntity.emulate = false;
31
+ }
32
+ else {
33
+ appObjects.submitError("stopZSpaceAction", "No zSpace Entity Found");
29
34
  return;
30
35
  }
31
36
  const renderUC = zSpaceEntity.appObject.getComponent(XR_1.RenderToXR.type);
32
- if (!renderUC) {
33
- console.warn("No renderUC found");
37
+ if (renderUC) {
38
+ renderUC.stopRenderingXR();
39
+ }
40
+ else {
41
+ appObjects.submitError("stopZSpaceAction", "No renderUC found");
42
+ return;
43
+ }
44
+ const emulateStylus = Stylus_1.EmulateStylusUC.get(appObjects);
45
+ if (emulateStylus) {
46
+ emulateStylus.stopEmulating();
47
+ }
48
+ else {
49
+ appObjects.submitWarning("stopZSpaceAction", "EmulateStylusUC not found");
34
50
  return;
35
51
  }
36
- renderUC.stopRenderingXR();
37
- zSpaceEntity.enabled = false;
38
- zSpaceEntity.emulate = false;
39
52
  };
40
53
  this.handleRequest = (version) => {
41
54
  if (version === this.payloadVersion) {
@@ -0,0 +1,14 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { StylusController } from "../../Stylus";
4
+ export declare class ScaleSceneRootSC extends AppObjectController implements StylusController {
5
+ static readonly type = "ScaleSceneRootSC";
6
+ private stylus?;
7
+ private scaleSceneRootWithRay?;
8
+ private isScaling;
9
+ allow: (button: number) => boolean;
10
+ onButtonDown: (button: number) => void;
11
+ onStylusMove: () => void;
12
+ onButtonUp: () => void;
13
+ constructor(appObject: AppObject);
14
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScaleSceneRootSC = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const ScaleSceneRootWithRay_1 = require("../UC/ScaleSceneRootWithRay");
6
+ const Stylus_1 = require("../../Stylus");
7
+ class ScaleSceneRootSC extends AppObjectController_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, ScaleSceneRootSC.type);
10
+ this.isScaling = false;
11
+ this.allow = (button) => {
12
+ if (button === 1)
13
+ return true;
14
+ return false;
15
+ };
16
+ this.onButtonDown = (button) => {
17
+ var _a;
18
+ this.isScaling = false;
19
+ if (!this.stylus)
20
+ return;
21
+ if (!this.allow(button))
22
+ return;
23
+ const pointerRay = this.stylus.pickRay;
24
+ const rayStart = this.stylus.transform.localPosition;
25
+ (_a = this.scaleSceneRootWithRay) === null || _a === void 0 ? void 0 : _a.initializeScale(pointerRay, rayStart);
26
+ this.isScaling = true;
27
+ };
28
+ this.onStylusMove = () => {
29
+ var _a;
30
+ if (!this.stylus)
31
+ return;
32
+ if (!this.isScaling)
33
+ return;
34
+ const pointerRay = this.stylus.pickRay;
35
+ const rayStart = this.stylus.transform.localPosition;
36
+ (_a = this.scaleSceneRootWithRay) === null || _a === void 0 ? void 0 : _a.doScale(pointerRay, rayStart);
37
+ };
38
+ this.onButtonUp = () => {
39
+ this.isScaling = false;
40
+ };
41
+ this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
42
+ if (!this.stylus) {
43
+ this.warn("Unable to find StylusEntity");
44
+ return;
45
+ }
46
+ this.scaleSceneRootWithRay = appObject.getComponent(ScaleSceneRootWithRay_1.ScaleSceneRootWithRay.type);
47
+ if (!this.scaleSceneRootWithRay) {
48
+ this.error("StylusMoveSceneRoot has been added to an App Object that does not have a scaleSceneRootWithRay");
49
+ return;
50
+ }
51
+ this.stylus.registerController(this);
52
+ }
53
+ }
54
+ exports.ScaleSceneRootSC = ScaleSceneRootSC;
55
+ ScaleSceneRootSC.type = "ScaleSceneRootSC";
@@ -0,0 +1,14 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { StylusController } from "../../Stylus";
4
+ export declare class SceneRootMoveSC extends AppObjectController implements StylusController {
5
+ static readonly type = "SceneRootMoveSC";
6
+ private stylus?;
7
+ private stylusRootMovementUC?;
8
+ private isMoving;
9
+ allow: (button: number) => boolean;
10
+ onButtonDown: (button: number) => void;
11
+ onButtonUp: () => void;
12
+ onStylusMove: () => void;
13
+ constructor(appObject: AppObject);
14
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SceneRootMoveSC = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Stylus_1 = require("../../Stylus");
6
+ const StylusMoveTransformUC_1 = require("../../Transform3D/UC/StylusMoveTransformUC");
7
+ class SceneRootMoveSC extends AppObjectController_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, SceneRootMoveSC.type);
10
+ this.isMoving = false;
11
+ this.allow = (button) => {
12
+ if (button === 0)
13
+ return true;
14
+ return false;
15
+ };
16
+ this.onButtonDown = (button) => {
17
+ var _a;
18
+ this.isMoving = false;
19
+ if (!this.stylus)
20
+ return;
21
+ if (!this.allow(button))
22
+ return;
23
+ (_a = this.stylusRootMovementUC) === null || _a === void 0 ? void 0 : _a.initialize();
24
+ this.isMoving = true;
25
+ };
26
+ this.onButtonUp = () => {
27
+ var _a;
28
+ this.isMoving = true;
29
+ if (!this.stylus)
30
+ return;
31
+ (_a = this.stylusRootMovementUC) === null || _a === void 0 ? void 0 : _a.stop();
32
+ };
33
+ this.onStylusMove = () => {
34
+ var _a;
35
+ if (!this.stylus || !this.isMoving)
36
+ return;
37
+ (_a = this.stylusRootMovementUC) === null || _a === void 0 ? void 0 : _a.move();
38
+ };
39
+ this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
40
+ if (!this.stylus) {
41
+ this.warn("Unable to find StylusEntity");
42
+ return;
43
+ }
44
+ this.stylusRootMovementUC = appObject.getComponent(StylusMoveTransformUC_1.StylusMoveTransformUC.type);
45
+ if (!this.stylusRootMovementUC) {
46
+ this.error("StylusMoveSceneRoot has been added to an App Object that does not have a StylusMoveTransformUC");
47
+ return;
48
+ }
49
+ this.stylus.registerController(this);
50
+ }
51
+ }
52
+ exports.SceneRootMoveSC = SceneRootMoveSC;
53
+ SceneRootMoveSC.type = "SceneRootMoveSC";
@@ -5,8 +5,8 @@ export * from "./MouseOrbit";
5
5
  export * from "./MousePan";
6
6
  export * from "./MouseRoll";
7
7
  export * from "./MouseScale";
8
- export * from "./StylusMove";
9
- export * from "./StylusScale";
8
+ export * from "./SceneRootMoveSC";
9
+ export * from "./ScaleSceneRootSC";
10
10
  export * from "./TouchOrbit";
11
11
  export * from "./TouchPan";
12
12
  export * from "./TouchPinch";
@@ -17,8 +17,8 @@ __exportStar(require("./MouseOrbit"), exports);
17
17
  __exportStar(require("./MousePan"), exports);
18
18
  __exportStar(require("./MouseRoll"), exports);
19
19
  __exportStar(require("./MouseScale"), exports);
20
- __exportStar(require("./StylusMove"), exports);
21
- __exportStar(require("./StylusScale"), exports);
20
+ __exportStar(require("./SceneRootMoveSC"), exports);
21
+ __exportStar(require("./ScaleSceneRootSC"), exports);
22
22
  __exportStar(require("./TouchOrbit"), exports);
23
23
  __exportStar(require("./TouchPan"), exports);
24
24
  __exportStar(require("./TouchPinch"), exports);
@@ -0,0 +1,11 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { StylusController } from "../../Stylus";
4
+ export declare class HoverOnAppObjectSC extends AppObjectController implements StylusController {
5
+ static readonly type = "HoverOnAppObjectSC";
6
+ private stylus?;
7
+ private hoverUC?;
8
+ allow: () => boolean;
9
+ onStylusMove: () => void;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HoverOnAppObjectSC = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Stylus_1 = require("../../Stylus");
6
+ const HoverAppObjectUC_1 = require("../UC/HoverAppObjectUC");
7
+ class HoverOnAppObjectSC extends AppObjectController_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, HoverOnAppObjectSC.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
+ this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
24
+ if (!this.stylus) {
25
+ this.warn("Unable to find StylusEntity");
26
+ return;
27
+ }
28
+ this.hoverUC = appObject.getComponent(HoverAppObjectUC_1.HoverAppObjectUC.type);
29
+ if (!this.stylus) {
30
+ console.warn("StylusInputPointer Controller has been added to an app object that does not have a ZSpaceStylusEntity");
31
+ }
32
+ else if (!this.hoverUC) {
33
+ console.warn("HoverAppObjectUC has not been found on any objects in the app object repo");
34
+ }
35
+ else {
36
+ this.stylus.registerController(this);
37
+ }
38
+ }
39
+ }
40
+ exports.HoverOnAppObjectSC = HoverOnAppObjectSC;
41
+ HoverOnAppObjectSC.type = "HoverOnAppObjectSC";
@@ -0,0 +1,18 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { StylusController } from "../../Stylus";
4
+ export declare class PressOnAppObjectSC extends AppObjectController implements StylusController {
5
+ static readonly type = "PressOnAppObjectSC";
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: number) => boolean;
14
+ onButtonDown: (button: number) => void;
15
+ onButtonUp: (button: number) => void;
16
+ onStylusMove: () => void;
17
+ constructor(appObject: AppObject);
18
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PressOnAppObjectSC = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Vector3_1 = require("../../../ValueObjects/Vector3");
6
+ const Stylus_1 = require("../../Stylus");
7
+ const PressAppObjectUC_1 = require("../UC/PressAppObjectUC");
8
+ class PressOnAppObjectSC extends AppObjectController_1.AppObjectController {
9
+ constructor(appObject) {
10
+ super(appObject, PressOnAppObjectSC.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 (!this.stylus)
21
+ return;
22
+ if (!this.pressUC)
23
+ return;
24
+ if (!this.allow(button))
25
+ return;
26
+ this.startPosition = this.stylus.transform.localPosition;
27
+ this.endPosition = this.startPosition;
28
+ this.isPressed = true;
29
+ this.pressedID = (_a = this.pressUC) === null || _a === void 0 ? void 0 : _a.tryPressSceneObject(this.stylus.pickRay);
30
+ };
31
+ this.onButtonUp = (button) => {
32
+ this.isPressed = false;
33
+ if (button !== 0)
34
+ return;
35
+ if (!this.pressUC)
36
+ return;
37
+ // Set pressedID to null
38
+ this.pressUC.pressSceneObject(this.pressedID, this.isPressed);
39
+ };
40
+ this.onStylusMove = () => {
41
+ var _a;
42
+ if (!this.pressUC) {
43
+ return;
44
+ }
45
+ if (this.isPressed) {
46
+ this.endPosition = (_a = this.stylus) === null || _a === void 0 ? void 0 : _a.transform.localPosition;
47
+ const movement = Vector3_1.Vector3.Subtract(this.startPosition, this.endPosition)
48
+ .magnitude;
49
+ if (movement > PressOnAppObjectSC.maxTapDistancePx) {
50
+ // Set pressedID to null
51
+ this.pressUC.pressSceneObject(null, this.isPressed);
52
+ }
53
+ }
54
+ };
55
+ this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
56
+ if (!this.stylus) {
57
+ this.error("Unable to find StylusEntity");
58
+ return;
59
+ }
60
+ this.pressUC = appObject.getComponent(PressAppObjectUC_1.PressAppObjectUC.type);
61
+ if (!this.pressUC) {
62
+ this.error("Unable to get PressAppObjectUC from the App Object");
63
+ return;
64
+ }
65
+ this.stylus.registerController(this);
66
+ }
67
+ }
68
+ exports.PressOnAppObjectSC = PressOnAppObjectSC;
69
+ PressOnAppObjectSC.type = "PressOnAppObjectSC";
70
+ PressOnAppObjectSC.maxTapDistancePx = 5;
@@ -0,0 +1,11 @@
1
+ import { AppObject } from "../../../AppObject/AppObject";
2
+ import { AppObjectController } from "../../../AppObject/AppObjectController";
3
+ import { StylusController } from "../../Stylus";
4
+ export declare class SelectAppObjectSC extends AppObjectController implements StylusController {
5
+ static readonly type = "SelectAppObjectSC";
6
+ private stylus?;
7
+ private selectUC?;
8
+ allow: () => boolean;
9
+ onButtonClick: (button: number) => void;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectAppObjectSC = void 0;
4
+ const AppObjectController_1 = require("../../../AppObject/AppObjectController");
5
+ const Stylus_1 = require("../../Stylus");
6
+ const UC_1 = require("../UC");
7
+ class SelectAppObjectSC extends AppObjectController_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, SelectAppObjectSC.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
+ this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
26
+ if (!this.stylus) {
27
+ this.error("Unable to find StylusEntity");
28
+ return;
29
+ }
30
+ this.selectUC = appObject.getComponent(UC_1.SelectAppObjectUC.type);
31
+ if (!this.selectUC) {
32
+ this.error("Added to an App Object that does not have SelectAppObjectUC");
33
+ return;
34
+ }
35
+ this.stylus.registerController(this);
36
+ }
37
+ }
38
+ exports.SelectAppObjectSC = SelectAppObjectSC;
39
+ SelectAppObjectSC.type = "SelectAppObjectSC";
@@ -3,6 +3,6 @@ export * from "./MousePressOnAppObject";
3
3
  export * from "./MouseSelectAppObject";
4
4
  export * from "./TapToSelectAppObject";
5
5
  export * from "./TouchPressOnAppObject";
6
- export * from "./StylusHoverOnAppObject";
7
- export * from "./StylusPressOnAppObject";
8
- export * from "./StylusSelectAppObject";
6
+ export * from "./HoverOnAppObjectSC";
7
+ export * from "./PressOnAppObjectSC";
8
+ export * from "./SelectAppObjectSC";
@@ -15,6 +15,6 @@ __exportStar(require("./MousePressOnAppObject"), exports);
15
15
  __exportStar(require("./MouseSelectAppObject"), exports);
16
16
  __exportStar(require("./TapToSelectAppObject"), exports);
17
17
  __exportStar(require("./TouchPressOnAppObject"), exports);
18
- __exportStar(require("./StylusHoverOnAppObject"), exports);
19
- __exportStar(require("./StylusPressOnAppObject"), exports);
20
- __exportStar(require("./StylusSelectAppObject"), exports);
18
+ __exportStar(require("./HoverOnAppObjectSC"), exports);
19
+ __exportStar(require("./PressOnAppObjectSC"), exports);
20
+ __exportStar(require("./SelectAppObjectSC"), exports);
@@ -0,0 +1,21 @@
1
+ import { AppObject, AppObjectEntity, AppObjectRepo } from "../../../AppObject";
2
+ import { ParametricLine } from "../../../ValueObjects";
3
+ import { Transform3D } from "../../Transform3D";
4
+ export interface StylusController {
5
+ onButtonDown?: (button: number) => void;
6
+ onButtonUp?: (button: number) => void;
7
+ onButtonClick?: (button: number) => void;
8
+ onStylusMove?: (transform: Transform3D) => void;
9
+ }
10
+ export declare abstract class StylusEntity extends AppObjectEntity {
11
+ static readonly type = "StylusEntity";
12
+ static clickMovementThreshold: number;
13
+ static clickTimeThresholdMS: number;
14
+ abstract registerController: (controller: StylusController) => void;
15
+ abstract updateButtonState: (button: number, isPressed: boolean) => void;
16
+ abstract readonly transform: Transform3D;
17
+ abstract get isInUse(): boolean;
18
+ abstract get pickRay(): ParametricLine;
19
+ static get(appObjects: AppObjectRepo): StylusEntity | undefined;
20
+ }
21
+ export declare function makeStylusEntity(appObj: AppObject): StylusEntity;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeStylusEntity = exports.StylusEntity = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const Entities_1 = require("../../../Entities");
6
+ const ValueObjects_1 = require("../../../ValueObjects");
7
+ const Transform3D_1 = require("../../Transform3D");
8
+ class StylusEntity extends AppObject_1.AppObjectEntity {
9
+ static get(appObjects) {
10
+ return AppObject_1.getSingletonComponent(StylusEntity.type, appObjects);
11
+ }
12
+ }
13
+ exports.StylusEntity = StylusEntity;
14
+ StylusEntity.type = "StylusEntity";
15
+ StylusEntity.clickMovementThreshold = 0.32;
16
+ StylusEntity.clickTimeThresholdMS = 350;
17
+ function makeStylusEntity(appObj) {
18
+ return new StylusImp(appObj);
19
+ }
20
+ exports.makeStylusEntity = makeStylusEntity;
21
+ class StylusImp extends StylusEntity {
22
+ constructor(appObject) {
23
+ super(appObject, StylusEntity.type);
24
+ this.controllers = [];
25
+ this.buttonStates = [false, false, false];
26
+ this.pressPosition = ValueObjects_1.Vector3.Zero();
27
+ this.pressTime = 0;
28
+ this.registerController = (controller) => {
29
+ this.controllers.push(controller);
30
+ };
31
+ this.updateButtonState = (button, isPressed) => {
32
+ if (this.buttonStates[button] === isPressed)
33
+ return;
34
+ this.controllers.forEach((controller) => {
35
+ if (isPressed) {
36
+ if (controller.onButtonDown) {
37
+ controller.onButtonDown(button);
38
+ }
39
+ this.lassPressedButton = button;
40
+ this.pressPosition = this.transform.localPosition;
41
+ this.pressTime = Date.now();
42
+ }
43
+ else {
44
+ if (controller.onButtonUp) {
45
+ controller.onButtonUp(button);
46
+ }
47
+ if (this.isClick(button) && controller.onButtonClick) {
48
+ controller.onButtonClick(button);
49
+ }
50
+ }
51
+ });
52
+ this.buttonStates[button] = isPressed;
53
+ this.notifyOnChange();
54
+ };
55
+ this.isClick = (button) => {
56
+ const buttonIsCorrect = button === this.lassPressedButton;
57
+ const movement = ValueObjects_1.Vector3.Subtract(this.transform.localPosition, this.pressPosition).magnitude;
58
+ const movementIsSmallEnough = movement < StylusEntity.clickMovementThreshold;
59
+ const passedTime = Date.now() - this.pressTime;
60
+ const pressTimeIsShortEnough = passedTime < StylusEntity.clickTimeThresholdMS;
61
+ if (buttonIsCorrect && movementIsSmallEnough && pressTimeIsShortEnough) {
62
+ return true;
63
+ }
64
+ else {
65
+ return false;
66
+ }
67
+ };
68
+ this.onTransformUpdate = () => {
69
+ this.checkIfStylusIsInUse(this.transform.worldMatrix);
70
+ this.controllers.forEach((controller) => {
71
+ if (controller.onStylusMove) {
72
+ controller.onStylusMove(this.transform);
73
+ }
74
+ });
75
+ this.notifyOnChange();
76
+ };
77
+ this.memoizedIsInUse = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
78
+ this.transform = Transform3D_1.Transform3D.addIfMissing(appObject);
79
+ this.transform.addChangeObserver(this.onTransformUpdate);
80
+ }
81
+ get pickRay() {
82
+ return ValueObjects_1.ParametricLine.FromPointDirection(this.transform.worldPosition, this.transform.localDirectionToWorld(ValueObjects_1.Vector3.Forward()));
83
+ }
84
+ get isInUse() {
85
+ return this.memoizedIsInUse.val;
86
+ }
87
+ checkIfStylusIsInUse(worldMatrix) {
88
+ const m = worldMatrix.m;
89
+ if (m[1] === 0 &&
90
+ m[2] === 0 &&
91
+ m[3] === 0 &&
92
+ m[4] === 0 &&
93
+ m[7] === 0 &&
94
+ m[8] === 0 &&
95
+ m[11] === 0 &&
96
+ m[12] === 0 &&
97
+ m[15] === 1) {
98
+ this.memoizedIsInUse.val = false;
99
+ }
100
+ else {
101
+ this.memoizedIsInUse.val = true;
102
+ }
103
+ }
104
+ }
@@ -0,0 +1 @@
1
+ export * from "./StylusEntity";