@vived/app 4.34.2 → 4.34.4

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 (32) hide show
  1. package/lib/Components/Callouts/Factories/setupCallouts.js +2 -2
  2. package/lib/Components/ChannelModel/Factories/setupChannelModels.js +2 -2
  3. package/lib/Components/Selection/UC/HoverAppObjectUC.js +12 -2
  4. package/lib/Components/Selection/UC/PressAppObjectUC.js +12 -2
  5. package/lib/Components/Selection/UC/SelectAppObjectUC.js +12 -2
  6. package/lib/Components/Stick/UCs/MoveTransformWithStickUC.d.ts +3 -0
  7. package/lib/Components/Stick/UCs/MoveTransformWithStickUC.js +110 -0
  8. package/lib/Components/Stick/UCs/index.d.ts +1 -0
  9. package/lib/Components/Stick/UCs/index.js +1 -0
  10. package/lib/Components/Transform3D/Controllers/Mouse/MousePanTransformMC.d.ts +13 -0
  11. package/lib/Components/Transform3D/Controllers/Mouse/MousePanTransformMC.js +51 -0
  12. package/lib/Components/Transform3D/Controllers/Mouse/index.d.ts +1 -1
  13. package/lib/Components/Transform3D/Controllers/Mouse/index.js +1 -1
  14. package/lib/Components/Transform3D/Controllers/Stylus/MoveTransformSC.d.ts +13 -0
  15. package/lib/Components/Transform3D/Controllers/Stylus/MoveTransformSC.js +50 -0
  16. package/lib/Components/Transform3D/Controllers/Stylus/index.d.ts +1 -0
  17. package/lib/Components/Transform3D/Controllers/Stylus/index.js +1 -0
  18. package/lib/Components/Transform3D/Controllers/Touch/TouchPanTransformTC.d.ts +12 -0
  19. package/lib/Components/Transform3D/Controllers/Touch/TouchPanTransformTC.js +53 -0
  20. package/lib/Components/Transform3D/Controllers/Touch/index.d.ts +1 -1
  21. package/lib/Components/Transform3D/Controllers/Touch/index.js +1 -1
  22. package/lib/Components/Transform3D/Mocks/MockMoveTransformUC.d.ts +12 -0
  23. package/lib/Components/Transform3D/Mocks/MockMoveTransformUC.js +16 -0
  24. package/lib/Components/Transform3D/Mocks/MockTryMoveTransformUC.d.ts +11 -0
  25. package/lib/Components/Transform3D/Mocks/MockTryMoveTransformUC.js +15 -0
  26. package/lib/Components/Transform3D/UC/MoveTransformUC.d.ts +32 -0
  27. package/lib/Components/Transform3D/UC/MoveTransformUC.js +114 -0
  28. package/lib/Components/Transform3D/UC/TryMoveTransformUC.d.ts +24 -0
  29. package/lib/Components/Transform3D/UC/TryMoveTransformUC.js +69 -0
  30. package/lib/Components/Transform3D/UC/index.d.ts +2 -1
  31. package/lib/Components/Transform3D/UC/index.js +2 -1
  32. package/package.json +1 -1
@@ -19,8 +19,8 @@ function setupCallouts(appObjects) {
19
19
  // Controllers
20
20
  new Controller_1.MouseAddCalloutMC(calloutsAO);
21
21
  new Controller_1.TouchAddCalloutTC(calloutsAO);
22
- new Transform3D_1.TryMousePanTransformMC(calloutsAO);
23
- new Transform3D_1.TryTouchPanTransformTC(calloutsAO);
22
+ new Transform3D_1.MousePanTransformMC(calloutsAO);
23
+ new Transform3D_1.TouchPanTransformTC(calloutsAO);
24
24
  // Setup Tool
25
25
  const toolRepo = Tools_1.ToolRepository.get(appObjects);
26
26
  if (!toolRepo) {
@@ -18,8 +18,8 @@ function setupChannelModels(appObjects) {
18
18
  PMs_1.makeActiveModelPM(appObj);
19
19
  PMs_1.makeActiveModelObjectListPM(appObj);
20
20
  // Controllers
21
- new Transform3D_1.TryMousePanTransformMC(appObj);
22
- new Transform3D_1.TryTouchPanTransformTC(appObj);
21
+ new Transform3D_1.MousePanTransformMC(appObj);
22
+ new Transform3D_1.TouchPanTransformTC(appObj);
23
23
  repo.channelModelFactory = channelModelFactory_1.makeChannelModelFactory(appObjects);
24
24
  }
25
25
  exports.setupChannelModels = setupChannelModels;
@@ -4,6 +4,7 @@ exports.makeHoverAppObject = exports.HoverAppObjectUC = void 0;
4
4
  const AppObject_1 = require("../../../AppObject");
5
5
  const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
6
6
  const Babylon_1 = require("../../Babylon");
7
+ const BaseApp_1 = require("../../BaseApp");
7
8
  const Selectable_1 = require("../Entities/Selectable");
8
9
  const Selection_1 = require("../Entities/Selection");
9
10
  class HoverAppObjectUC extends AppObjectUC_1.AppObjectUC {
@@ -21,10 +22,16 @@ class HoverAppObjectUCImp extends HoverAppObjectUC {
21
22
  constructor(appObject) {
22
23
  super(appObject, HoverAppObjectUC.type);
23
24
  this.allowHover = () => {
24
- return true;
25
+ if (!this.baseApp) {
26
+ return false;
27
+ }
28
+ return this.baseApp.isAuthoring;
25
29
  };
26
30
  this.allowTryHover = () => {
27
- return true;
31
+ if (!this.baseApp) {
32
+ return false;
33
+ }
34
+ return this.baseApp.isAuthoring;
28
35
  };
29
36
  this.tryHoverAppObject = (ray) => {
30
37
  if (!this.selection)
@@ -60,4 +67,7 @@ class HoverAppObjectUCImp extends HoverAppObjectUC {
60
67
  get selection() {
61
68
  return this.getCachedSingleton(Selection_1.Selection.type);
62
69
  }
70
+ get baseApp() {
71
+ return this.getCachedSingleton(BaseApp_1.BaseAppState.type);
72
+ }
63
73
  }
@@ -4,6 +4,7 @@ exports.makePressAppObject = exports.PressAppObjectUC = void 0;
4
4
  const AppObject_1 = require("../../../AppObject");
5
5
  const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
6
6
  const Babylon_1 = require("../../Babylon");
7
+ const BaseApp_1 = require("../../BaseApp");
7
8
  const Selectable_1 = require("../Entities/Selectable");
8
9
  const Selection_1 = require("../Entities/Selection");
9
10
  class PressAppObjectUC extends AppObjectUC_1.AppObjectUC {
@@ -21,10 +22,16 @@ class PressAppObjectUCImp extends PressAppObjectUC {
21
22
  constructor(appObject) {
22
23
  super(appObject, PressAppObjectUC.type);
23
24
  this.allowPress = () => {
24
- return true;
25
+ if (!this.baseApp) {
26
+ return false;
27
+ }
28
+ return this.baseApp.isAuthoring;
25
29
  };
26
30
  this.allowTryPress = () => {
27
- return true;
31
+ if (!this.baseApp) {
32
+ return false;
33
+ }
34
+ return this.baseApp.isAuthoring;
28
35
  };
29
36
  this.tryPressAppObject = (ray) => {
30
37
  if (!this.selection)
@@ -61,4 +68,7 @@ class PressAppObjectUCImp extends PressAppObjectUC {
61
68
  get selection() {
62
69
  return this.getCachedSingleton(Selection_1.Selection.type);
63
70
  }
71
+ get baseApp() {
72
+ return this.getCachedSingleton(BaseApp_1.BaseAppState.type);
73
+ }
64
74
  }
@@ -4,6 +4,7 @@ exports.makeSelectAppObject = exports.SelectAppObjectUC = void 0;
4
4
  const AppObject_1 = require("../../../AppObject");
5
5
  const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
6
6
  const Babylon_1 = require("../../Babylon");
7
+ const BaseApp_1 = require("../../BaseApp");
7
8
  const Selectable_1 = require("../Entities/Selectable");
8
9
  const Selection_1 = require("../Entities/Selection");
9
10
  class SelectAppObjectUC extends AppObjectUC_1.AppObjectUC {
@@ -21,10 +22,16 @@ class SelectAppObjectUCImp extends SelectAppObjectUC {
21
22
  constructor(appObject) {
22
23
  super(appObject, SelectAppObjectUC.type);
23
24
  this.allowSelect = () => {
24
- return true;
25
+ if (!this.baseApp) {
26
+ return false;
27
+ }
28
+ return this.baseApp.isAuthoring;
25
29
  };
26
30
  this.allowTrySelect = () => {
27
- return true;
31
+ if (!this.baseApp) {
32
+ return false;
33
+ }
34
+ return this.baseApp.isAuthoring;
28
35
  };
29
36
  this.trySelectAppObject = (ray) => {
30
37
  if (!this.selection)
@@ -60,4 +67,7 @@ class SelectAppObjectUCImp extends SelectAppObjectUC {
60
67
  get selection() {
61
68
  return this.getCachedSingleton(Selection_1.Selection.type);
62
69
  }
70
+ get baseApp() {
71
+ return this.getCachedSingleton(BaseApp_1.BaseAppState.type);
72
+ }
63
73
  }
@@ -0,0 +1,3 @@
1
+ import { AppObject } from "../../../AppObject";
2
+ import { MoveTransformUC } from "../../Transform3D";
3
+ export declare function makeMoveTransformWithStickUC(appObject: AppObject): MoveTransformUC;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeMoveTransformWithStickUC = void 0;
4
+ const ValueObjects_1 = require("../../../ValueObjects");
5
+ const Transform3D_1 = require("../../Transform3D");
6
+ const Stickable_1 = require("../Entities/Stickable");
7
+ const TryPickStickTarget_1 = require("./TryPickStickTarget");
8
+ function makeMoveTransformWithStickUC(appObject) {
9
+ return new MoveTransformWithStickUC(appObject);
10
+ }
11
+ exports.makeMoveTransformWithStickUC = makeMoveTransformWithStickUC;
12
+ class MoveTransformWithStickUC extends Transform3D_1.MoveTransformUCImp {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.isFirstPeel = true;
16
+ this.initialScale = ValueObjects_1.Vector3.Zero();
17
+ }
18
+ get stickable() {
19
+ return this.getCachedLocalComponent(Stickable_1.StickableEntity.type);
20
+ }
21
+ get pickTargetsUC() {
22
+ return this.getCachedLocalComponent(TryPickStickTarget_1.TryPickStickTargetUC.type);
23
+ }
24
+ initialize(helper) {
25
+ if (!this.transform)
26
+ return;
27
+ super.initialize(helper);
28
+ this.initialScale = this.transform.localScale;
29
+ this.isFirstPeel = true;
30
+ }
31
+ update(helper, ray) {
32
+ super.update(helper, ray);
33
+ if (!this.pickTargetsUC || !this.stickable) {
34
+ return;
35
+ }
36
+ const isHitStickTarget = this.pickTargetsUC.tryPick(ray);
37
+ if (isHitStickTarget) {
38
+ if (this.isFirstPeel) {
39
+ this.stickable.showStickTarget = false;
40
+ this.stickable.highlightTarget = false;
41
+ }
42
+ else {
43
+ this.stickable.showStickTarget = true;
44
+ this.stickable.highlightTarget = true;
45
+ }
46
+ }
47
+ else {
48
+ this.stickable.showStickTarget = true;
49
+ this.stickable.highlightTarget = false;
50
+ this.isFirstPeel = false;
51
+ }
52
+ }
53
+ finish() {
54
+ super.finish();
55
+ if (!this.stickable) {
56
+ return;
57
+ }
58
+ const doStick = this.stickable.highlightTarget;
59
+ this.stickable.showStickTarget = false;
60
+ this.stickable.highlightTarget = false;
61
+ if (doStick) {
62
+ this.finishWithStick();
63
+ }
64
+ else {
65
+ this.submitDispatchAndUndo();
66
+ }
67
+ }
68
+ finishWithStick() {
69
+ var _a;
70
+ const dispatch = this.dispatchStateChange;
71
+ const transform = this.transform;
72
+ if (!transform || !dispatch || !this.stickable)
73
+ return;
74
+ const startPos = this.initialPos;
75
+ const finalPos = this.stickable.stickPosition;
76
+ const startRot = this.initialRotation;
77
+ const finalRot = this.stickable.stickRotation;
78
+ const startScale = this.initialScale;
79
+ const finalScale = new ValueObjects_1.Vector3(this.stickable.stickScale, this.stickable.stickScale, this.stickable.stickScale);
80
+ if (this.dispatchStateChangeOnComplete) {
81
+ this.stickable.doStick(dispatch);
82
+ }
83
+ else {
84
+ this.stickable.doStick();
85
+ }
86
+ if (this.submitUndoOnComplete) {
87
+ (_a = this.undoRedo) === null || _a === void 0 ? void 0 : _a.submitAction({
88
+ undoAction: () => {
89
+ transform.localPosition = startPos;
90
+ transform.localRotation = startRot;
91
+ transform.localScale = startScale;
92
+ dispatch();
93
+ },
94
+ redoAction: () => {
95
+ transform.localPosition = finalPos;
96
+ transform.localRotation = finalRot;
97
+ transform.localScale = finalScale;
98
+ dispatch();
99
+ },
100
+ });
101
+ }
102
+ }
103
+ cancel() {
104
+ super.cancel();
105
+ if (this.stickable) {
106
+ this.stickable.showStickTarget = false;
107
+ this.stickable.highlightTarget = false;
108
+ }
109
+ }
110
+ }
@@ -1,3 +1,4 @@
1
+ export * from "./MoveTransformWithStickUC";
1
2
  export * from "./PanTransformWithStickUC";
2
3
  export * from "./StickUC";
3
4
  export * from "./TryPickStickTarget";
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./MoveTransformWithStickUC"), exports);
13
14
  __exportStar(require("./PanTransformWithStickUC"), exports);
14
15
  __exportStar(require("./StickUC"), exports);
15
16
  __exportStar(require("./TryPickStickTarget"), exports);
@@ -0,0 +1,13 @@
1
+ import { AppObject, AppObjectController } from "../../../../AppObject";
2
+ import { MouseController, MouseInputEvent } from "../../../MouseInput";
3
+ export declare class MousePanTransformMC extends AppObjectController implements MouseController {
4
+ static readonly type = "MousePanTransformMC";
5
+ allow: (e: MouseInputEvent) => boolean;
6
+ private get mouseInput();
7
+ private get tryScreenDragUC();
8
+ private isDragging;
9
+ onDown: (e: MouseInputEvent) => void;
10
+ onMove: (e: MouseInputEvent) => void;
11
+ onUp: () => void;
12
+ constructor(appObject: AppObject);
13
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MousePanTransformMC = void 0;
4
+ const AppObject_1 = require("../../../../AppObject");
5
+ const MouseInput_1 = require("../../../MouseInput");
6
+ const TryPanTransformUC_1 = require("../../UC/TryPanTransformUC");
7
+ class MousePanTransformMC extends AppObject_1.AppObjectController {
8
+ constructor(appObject) {
9
+ var _a;
10
+ super(appObject, MousePanTransformMC.type);
11
+ this.allow = (e) => {
12
+ if (e.button !== 0)
13
+ return false;
14
+ return true;
15
+ };
16
+ this.isDragging = false;
17
+ this.onDown = (e) => {
18
+ var _a, _b, _c;
19
+ if (this.isDragging) {
20
+ (_a = this.tryScreenDragUC) === null || _a === void 0 ? void 0 : _a.cancel();
21
+ this.isDragging = false;
22
+ }
23
+ if (!this.allow(e)) {
24
+ return;
25
+ }
26
+ this.isDragging = (_c = (_b = this.tryScreenDragUC) === null || _b === void 0 ? void 0 : _b.tryWithPixel(e.position)) !== null && _c !== void 0 ? _c : false;
27
+ };
28
+ this.onMove = (e) => {
29
+ var _a;
30
+ if (!this.isDragging)
31
+ return;
32
+ (_a = this.tryScreenDragUC) === null || _a === void 0 ? void 0 : _a.moveWithPixel(e.position);
33
+ };
34
+ this.onUp = () => {
35
+ var _a;
36
+ if (!this.isDragging)
37
+ return;
38
+ (_a = this.tryScreenDragUC) === null || _a === void 0 ? void 0 : _a.stop();
39
+ this.isDragging = false;
40
+ };
41
+ (_a = this.mouseInput) === null || _a === void 0 ? void 0 : _a.registerController(this);
42
+ }
43
+ get mouseInput() {
44
+ return this.getCachedSingleton(MouseInput_1.MouseInputEntity.type);
45
+ }
46
+ get tryScreenDragUC() {
47
+ return this.getCachedLocalComponent(TryPanTransformUC_1.TryPanTransformUC.type);
48
+ }
49
+ }
50
+ exports.MousePanTransformMC = MousePanTransformMC;
51
+ MousePanTransformMC.type = "MousePanTransformMC";
@@ -1,4 +1,4 @@
1
1
  export * from "./DragScaleTransformMC";
2
2
  export * from "./PanTransformMC";
3
3
  export * from "./RollScaleTransformMC";
4
- export * from "./TryMousePanTransformMC";
4
+ export * from "./MousePanTransformMC";
@@ -13,4 +13,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./DragScaleTransformMC"), exports);
14
14
  __exportStar(require("./PanTransformMC"), exports);
15
15
  __exportStar(require("./RollScaleTransformMC"), exports);
16
- __exportStar(require("./TryMousePanTransformMC"), exports);
16
+ __exportStar(require("./MousePanTransformMC"), exports);
@@ -0,0 +1,13 @@
1
+ import { AppObject, AppObjectController } from "../../../../AppObject";
2
+ import { StylusController } from "../../../Stylus";
3
+ export declare class MoveTransformSC extends AppObjectController implements StylusController {
4
+ static readonly type = "MoveTransformSC";
5
+ private get stylus();
6
+ private get tryMoveUC();
7
+ private doUpdate;
8
+ allow: (button: number) => boolean;
9
+ onButtonDown: (button: number) => void;
10
+ onStylusMove: () => void;
11
+ onButtonUp: () => void;
12
+ constructor(appObject: AppObject);
13
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MoveTransformSC = void 0;
4
+ const AppObject_1 = require("../../../../AppObject");
5
+ const Stylus_1 = require("../../../Stylus");
6
+ const UC_1 = require("../../UC");
7
+ class MoveTransformSC extends AppObject_1.AppObjectController {
8
+ constructor(appObject) {
9
+ var _a;
10
+ super(appObject, MoveTransformSC.type);
11
+ this.doUpdate = false;
12
+ this.allow = (button) => {
13
+ if (button === 0)
14
+ return true;
15
+ return false;
16
+ };
17
+ this.onButtonDown = (button) => {
18
+ this.doUpdate = false;
19
+ if (!this.stylus || !this.tryMoveUC)
20
+ return;
21
+ if (!this.allow(button))
22
+ return;
23
+ this.doUpdate = this.tryMoveUC.tryWithRay(this.stylus.pickRay);
24
+ };
25
+ this.onStylusMove = () => {
26
+ if (!this.stylus || !this.tryMoveUC)
27
+ return;
28
+ if (!this.doUpdate)
29
+ return;
30
+ this.tryMoveUC.moveWithRay(this.stylus.pickRay);
31
+ };
32
+ this.onButtonUp = () => {
33
+ if (!this.doUpdate)
34
+ return;
35
+ this.doUpdate = false;
36
+ if (!this.tryMoveUC)
37
+ return;
38
+ this.tryMoveUC.stop();
39
+ };
40
+ (_a = this.stylus) === null || _a === void 0 ? void 0 : _a.registerController(this);
41
+ }
42
+ get stylus() {
43
+ return this.getCachedSingleton(Stylus_1.StylusEntity.type);
44
+ }
45
+ get tryMoveUC() {
46
+ return this.getCachedLocalComponent(UC_1.TryMoveTransformUC.type);
47
+ }
48
+ }
49
+ exports.MoveTransformSC = MoveTransformSC;
50
+ MoveTransformSC.type = "MoveTransformSC";
@@ -1,3 +1,4 @@
1
+ export * from "./MoveTransformSC";
1
2
  export * from "./PanScaleTransformSC";
2
3
  export * from "./PanTransformSC";
3
4
  export * from "./ScaleTransformSC";
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./MoveTransformSC"), exports);
13
14
  __exportStar(require("./PanScaleTransformSC"), exports);
14
15
  __exportStar(require("./PanTransformSC"), exports);
15
16
  __exportStar(require("./ScaleTransformSC"), exports);
@@ -0,0 +1,12 @@
1
+ import { AppObject, AppObjectController } from "../../../../AppObject";
2
+ import { TouchController, TouchInputEvent } from "../../../TouchController";
3
+ export declare class TouchPanTransformTC extends AppObjectController implements TouchController {
4
+ static readonly type = "TouchPanTransformTC";
5
+ allow: (e: TouchInputEvent) => boolean;
6
+ private get tryScreenDragUC();
7
+ private isDragging;
8
+ onTouchStart: (e: TouchInputEvent) => void;
9
+ onTouchMove: (e: TouchInputEvent) => void;
10
+ onTouchEnd: () => void;
11
+ constructor(appObject: AppObject);
12
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TouchPanTransformTC = void 0;
4
+ const AppObject_1 = require("../../../../AppObject");
5
+ const TouchController_1 = require("../../../TouchController");
6
+ const TryPanTransformUC_1 = require("../../UC/TryPanTransformUC");
7
+ class TouchPanTransformTC extends AppObject_1.AppObjectController {
8
+ constructor(appObject) {
9
+ super(appObject, TouchPanTransformTC.type);
10
+ this.allow = (e) => {
11
+ if (e.touches.length !== 1)
12
+ return false;
13
+ return true;
14
+ };
15
+ this.isDragging = false;
16
+ this.onTouchStart = (e) => {
17
+ var _a;
18
+ if (this.isDragging) {
19
+ (_a = this.tryScreenDragUC) === null || _a === void 0 ? void 0 : _a.cancel();
20
+ this.isDragging = false;
21
+ }
22
+ if (!this.tryScreenDragUC)
23
+ return;
24
+ if (!this.allow(e))
25
+ return;
26
+ const position = e.touches[0].position;
27
+ this.isDragging = this.tryScreenDragUC.tryWithPixel(position);
28
+ };
29
+ this.onTouchMove = (e) => {
30
+ if (!this.tryScreenDragUC)
31
+ return;
32
+ if (!this.isDragging)
33
+ return;
34
+ const position = e.touches[0].position;
35
+ this.tryScreenDragUC.moveWithPixel(position);
36
+ };
37
+ this.onTouchEnd = () => {
38
+ if (!this.tryScreenDragUC)
39
+ return;
40
+ if (!this.isDragging)
41
+ return;
42
+ this.tryScreenDragUC.stop();
43
+ this.isDragging = false;
44
+ };
45
+ const touchInput = TouchController_1.TouchInputEntity.get(this.appObjects);
46
+ touchInput === null || touchInput === void 0 ? void 0 : touchInput.registerController(this);
47
+ }
48
+ get tryScreenDragUC() {
49
+ return this.getCachedLocalComponent(TryPanTransformUC_1.TryPanTransformUC.type);
50
+ }
51
+ }
52
+ exports.TouchPanTransformTC = TouchPanTransformTC;
53
+ TouchPanTransformTC.type = "TouchPanTransformTC";
@@ -1,4 +1,4 @@
1
1
  export * from "./DragScaleTransformTC";
2
2
  export * from "./PanTransformTC";
3
3
  export * from "./PinchTransformTC";
4
- export * from "./TryTouchPanTransformTC";
4
+ export * from "./TouchPanTransformTC";
@@ -13,4 +13,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./DragScaleTransformTC"), exports);
14
14
  __exportStar(require("./PanTransformTC"), exports);
15
15
  __exportStar(require("./PinchTransformTC"), exports);
16
- __exportStar(require("./TryTouchPanTransformTC"), exports);
16
+ __exportStar(require("./TouchPanTransformTC"), exports);
@@ -0,0 +1,12 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject } from "../../../AppObject";
3
+ import { MoveTransformUC } from "../UC";
4
+ export declare class MockMoveTransformUC extends MoveTransformUC {
5
+ dispatchStateChangeOnComplete: boolean;
6
+ submitUndoOnComplete: boolean;
7
+ initialize: jest.Mock<any, any>;
8
+ update: jest.Mock<any, any>;
9
+ finish: jest.Mock<any, any>;
10
+ cancel: jest.Mock<any, any>;
11
+ constructor(appObject: AppObject);
12
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockMoveTransformUC = void 0;
4
+ const UC_1 = require("../UC");
5
+ class MockMoveTransformUC extends UC_1.MoveTransformUC {
6
+ constructor(appObject) {
7
+ super(appObject, UC_1.MoveTransformUC.type);
8
+ this.dispatchStateChangeOnComplete = true;
9
+ this.submitUndoOnComplete = true;
10
+ this.initialize = jest.fn();
11
+ this.update = jest.fn();
12
+ this.finish = jest.fn();
13
+ this.cancel = jest.fn();
14
+ }
15
+ }
16
+ exports.MockMoveTransformUC = MockMoveTransformUC;
@@ -0,0 +1,11 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject } from "../../../AppObject";
3
+ import { TryMoveTransformUC } from "../UC/TryMoveTransformUC";
4
+ export declare class MockTryMoveTransformUC extends TryMoveTransformUC {
5
+ allow: jest.Mock<any, any>;
6
+ tryWithRay: jest.Mock<any, any>;
7
+ moveWithRay: jest.Mock<any, any>;
8
+ stop: jest.Mock<any, any>;
9
+ cancel: jest.Mock<any, any>;
10
+ constructor(appObject: AppObject);
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockTryMoveTransformUC = void 0;
4
+ const TryMoveTransformUC_1 = require("../UC/TryMoveTransformUC");
5
+ class MockTryMoveTransformUC extends TryMoveTransformUC_1.TryMoveTransformUC {
6
+ constructor(appObject) {
7
+ super(appObject, TryMoveTransformUC_1.TryMoveTransformUC.type);
8
+ this.allow = jest.fn();
9
+ this.tryWithRay = jest.fn();
10
+ this.moveWithRay = jest.fn();
11
+ this.stop = jest.fn();
12
+ this.cancel = jest.fn();
13
+ }
14
+ }
15
+ exports.MockTryMoveTransformUC = MockTryMoveTransformUC;
@@ -0,0 +1,32 @@
1
+ import { AppObject, AppObjectRepo, AppObjectUC } from "../../../AppObject";
2
+ import { ParametricLine, Quaternion, Vector3 } from "../../../ValueObjects";
3
+ import { UndoRedoEntity } from "../../UndoRedo";
4
+ import { Transform3D } from "../Entities/Transform3D";
5
+ export declare abstract class MoveTransformUC extends AppObjectUC {
6
+ static readonly type = "MoveTransformUC";
7
+ abstract dispatchStateChangeOnComplete: boolean;
8
+ abstract submitUndoOnComplete: boolean;
9
+ abstract initialize(helper: Transform3D): void;
10
+ abstract update(helper: Transform3D, ray: ParametricLine): void;
11
+ abstract finish(): void;
12
+ abstract cancel(): void;
13
+ static get(id: string, appObjects: AppObjectRepo): MoveTransformUC | undefined;
14
+ }
15
+ export declare function makeMoveTransform(appObject: AppObject): MoveTransformUC;
16
+ export declare class MoveTransformUCImp extends MoveTransformUC {
17
+ dispatchStateChangeOnComplete: boolean;
18
+ submitUndoOnComplete: boolean;
19
+ protected get transform(): Transform3D | undefined;
20
+ protected get undoRedo(): UndoRedoEntity | undefined;
21
+ protected get dispatchStateChange(): (() => void) | undefined;
22
+ protected initialPos: Vector3;
23
+ protected initialRotation: Quaternion;
24
+ protected isDragging: boolean;
25
+ protected didDrag: boolean;
26
+ initialize(helper: Transform3D): void;
27
+ update(helper: Transform3D, ray: ParametricLine): void;
28
+ finish(): void;
29
+ cancel(): void;
30
+ protected submitDispatchAndUndo(): void;
31
+ constructor(appObject: AppObject);
32
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MoveTransformUCImp = exports.makeMoveTransform = exports.MoveTransformUC = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const ValueObjects_1 = require("../../../ValueObjects");
6
+ const Dispatcher_1 = require("../../Dispatcher");
7
+ const UndoRedo_1 = require("../../UndoRedo");
8
+ const Transform3D_1 = require("../Entities/Transform3D");
9
+ class MoveTransformUC extends AppObject_1.AppObjectUC {
10
+ static get(id, appObjects) {
11
+ var _a;
12
+ return (_a = appObjects
13
+ .get(id)) === null || _a === void 0 ? void 0 : _a.getComponent(MoveTransformUC.type);
14
+ }
15
+ }
16
+ exports.MoveTransformUC = MoveTransformUC;
17
+ MoveTransformUC.type = "MoveTransformUC";
18
+ function makeMoveTransform(appObject) {
19
+ return new MoveTransformUCImp(appObject);
20
+ }
21
+ exports.makeMoveTransform = makeMoveTransform;
22
+ class MoveTransformUCImp extends MoveTransformUC {
23
+ constructor(appObject) {
24
+ super(appObject, MoveTransformUC.type);
25
+ this.dispatchStateChangeOnComplete = true;
26
+ this.submitUndoOnComplete = true;
27
+ this.initialPos = ValueObjects_1.Vector3.Zero();
28
+ this.initialRotation = ValueObjects_1.Quaternion.Identity();
29
+ this.isDragging = false;
30
+ this.didDrag = false;
31
+ }
32
+ get transform() {
33
+ return this.getCachedLocalComponent(Transform3D_1.Transform3D.type);
34
+ }
35
+ get undoRedo() {
36
+ return this.getCachedSingleton(UndoRedo_1.UndoRedoEntity.type);
37
+ }
38
+ get dispatchStateChange() {
39
+ var _a;
40
+ return (_a = this.getCachedSingleton(Dispatcher_1.DispatchStateChangeUC.type)) === null || _a === void 0 ? void 0 : _a.doDispatch;
41
+ }
42
+ initialize(helper) {
43
+ this.isDragging = false;
44
+ this.didDrag = false;
45
+ if (!this.transform) {
46
+ return;
47
+ }
48
+ helper.worldPosition = this.transform.worldPosition;
49
+ helper.worldRotation = this.transform.worldRotation;
50
+ this.initialPos = this.transform.localPosition;
51
+ this.initialRotation = this.transform.localRotation;
52
+ this.isDragging = true;
53
+ }
54
+ ;
55
+ update(helper, ray) {
56
+ if (!this.isDragging)
57
+ return;
58
+ if (!this.transform)
59
+ return;
60
+ this.transform.worldRotation = helper.worldRotation;
61
+ this.transform.worldPosition = helper.worldPosition;
62
+ this.didDrag = true;
63
+ }
64
+ ;
65
+ finish() {
66
+ if (!this.transform)
67
+ return;
68
+ this.isDragging = false;
69
+ if (!this.didDrag)
70
+ return;
71
+ this.submitDispatchAndUndo();
72
+ this.didDrag = false;
73
+ }
74
+ ;
75
+ cancel() {
76
+ if (!this.transform)
77
+ return;
78
+ if (!this.isDragging)
79
+ return;
80
+ this.isDragging = false;
81
+ this.didDrag = false;
82
+ }
83
+ ;
84
+ submitDispatchAndUndo() {
85
+ var _a;
86
+ const dispatch = this.dispatchStateChange;
87
+ const transform = this.transform;
88
+ if (!transform || !dispatch)
89
+ return;
90
+ if (ValueObjects_1.Vector3.Equal(this.initialPos, transform.localPosition) &&
91
+ ValueObjects_1.Quaternion.Equal(this.initialRotation, transform.localRotation))
92
+ return;
93
+ if (this.dispatchStateChangeOnComplete) {
94
+ dispatch();
95
+ }
96
+ if (this.submitUndoOnComplete) {
97
+ const redoPos = transform.localPosition;
98
+ const redoRot = transform.localRotation;
99
+ (_a = this.undoRedo) === null || _a === void 0 ? void 0 : _a.submitAction({
100
+ undoAction: () => {
101
+ transform.localPosition = this.initialPos;
102
+ transform.localRotation = this.initialRotation;
103
+ dispatch();
104
+ },
105
+ redoAction: () => {
106
+ transform.localPosition = redoPos;
107
+ transform.localRotation = redoRot;
108
+ dispatch();
109
+ },
110
+ });
111
+ }
112
+ }
113
+ }
114
+ exports.MoveTransformUCImp = MoveTransformUCImp;
@@ -0,0 +1,24 @@
1
+ import { AppObject, AppObjectUC } from "../../../AppObject";
2
+ import { ParametricLine } from "../../../ValueObjects";
3
+ import { SceneRayPickUC } from "../../Babylon";
4
+ import { MoveTransformUC } from "./MoveTransformUC";
5
+ export declare abstract class TryMoveTransformUC extends AppObjectUC {
6
+ static readonly type = "TryMoveTransformUC";
7
+ abstract allow(): boolean;
8
+ abstract tryWithRay(ray: ParametricLine): boolean;
9
+ abstract moveWithRay(ray: ParametricLine): void;
10
+ abstract stop(): void;
11
+ abstract cancel(): void;
12
+ }
13
+ export declare function makeTryMoveTransformUC(appObject: AppObject): TryMoveTransformUC;
14
+ export declare class TryMoveTransformUCImp extends TryMoveTransformUC {
15
+ protected moveUC?: MoveTransformUC;
16
+ protected get rayPickUC(): SceneRayPickUC | undefined;
17
+ private helperTransform;
18
+ allow: () => boolean;
19
+ tryWithRay: (pickRay: ParametricLine) => boolean;
20
+ moveWithRay: (pickRay: ParametricLine) => void;
21
+ stop: () => void;
22
+ cancel: () => void;
23
+ constructor(appObject: AppObject);
24
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TryMoveTransformUCImp = exports.makeTryMoveTransformUC = exports.TryMoveTransformUC = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const Babylon_1 = require("../../Babylon");
6
+ const Stylus_1 = require("../../Stylus");
7
+ const Entities_1 = require("../Entities");
8
+ const MoveTransformUC_1 = require("./MoveTransformUC");
9
+ class TryMoveTransformUC extends AppObject_1.AppObjectUC {
10
+ }
11
+ exports.TryMoveTransformUC = TryMoveTransformUC;
12
+ TryMoveTransformUC.type = "TryMoveTransformUC";
13
+ function makeTryMoveTransformUC(appObject) {
14
+ return new TryMoveTransformUCImp(appObject);
15
+ }
16
+ exports.makeTryMoveTransformUC = makeTryMoveTransformUC;
17
+ class TryMoveTransformUCImp extends TryMoveTransformUC {
18
+ constructor(appObject) {
19
+ super(appObject, TryMoveTransformUC.type);
20
+ this.allow = () => {
21
+ return true;
22
+ };
23
+ this.tryWithRay = (pickRay) => {
24
+ var _a, _b;
25
+ this.moveUC = undefined;
26
+ if (!this.allow())
27
+ return false;
28
+ const appObjectID = (_b = (_a = this.rayPickUC) === null || _a === void 0 ? void 0 : _a.sceneRayPick(pickRay)) === null || _b === void 0 ? void 0 : _b.appObjectID;
29
+ if (!appObjectID)
30
+ return false;
31
+ this.moveUC = MoveTransformUC_1.MoveTransformUC.get(appObjectID, this.appObjects);
32
+ if (this.moveUC === undefined) {
33
+ return false;
34
+ }
35
+ this.moveUC.initialize(this.helperTransform);
36
+ return true;
37
+ };
38
+ this.moveWithRay = (pickRay) => {
39
+ if (!this.moveUC)
40
+ return;
41
+ this.moveUC.update(this.helperTransform, pickRay);
42
+ };
43
+ this.stop = () => {
44
+ if (!this.moveUC)
45
+ return;
46
+ this.moveUC.finish();
47
+ this.moveUC = undefined;
48
+ };
49
+ this.cancel = () => {
50
+ if (!this.moveUC)
51
+ return;
52
+ this.moveUC.cancel();
53
+ this.moveUC = undefined;
54
+ };
55
+ const helperAO = this.appObjects.getOrCreate(this.appObject.id + "_helper");
56
+ this.helperTransform = Entities_1.Transform3D.addIfMissing(helperAO);
57
+ const stylus = Stylus_1.StylusEntity.get(this.appObjects);
58
+ if (!stylus) {
59
+ this.error("Unable to find stylus");
60
+ }
61
+ else {
62
+ this.helperTransform.parent = stylus.transform;
63
+ }
64
+ }
65
+ get rayPickUC() {
66
+ return this.getCachedSingleton(Babylon_1.SceneRayPickUC.type);
67
+ }
68
+ }
69
+ exports.TryMoveTransformUCImp = TryMoveTransformUCImp;
@@ -1,9 +1,10 @@
1
1
  export * from "./BumpTransformScaleAboutPixelPoint";
2
- export * from "./DragTransformUC";
2
+ export * from "./MoveTransformUC";
3
3
  export * from "./MoveTransformUndoRedo";
4
4
  export * from "./PanTransformUC";
5
5
  export * from "./PinchTransform";
6
6
  export * from "./RayPanScaleTransform";
7
7
  export * from "./ScaleTransform";
8
8
  export * from "./StylusMoveTransformUC";
9
+ export * from "./TryMoveTransformUC";
9
10
  export * from "./TryPanTransformUC";
@@ -11,11 +11,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./BumpTransformScaleAboutPixelPoint"), exports);
14
- __exportStar(require("./DragTransformUC"), exports);
14
+ __exportStar(require("./MoveTransformUC"), exports);
15
15
  __exportStar(require("./MoveTransformUndoRedo"), exports);
16
16
  __exportStar(require("./PanTransformUC"), exports);
17
17
  __exportStar(require("./PinchTransform"), exports);
18
18
  __exportStar(require("./RayPanScaleTransform"), exports);
19
19
  __exportStar(require("./ScaleTransform"), exports);
20
20
  __exportStar(require("./StylusMoveTransformUC"), exports);
21
+ __exportStar(require("./TryMoveTransformUC"), exports);
21
22
  __exportStar(require("./TryPanTransformUC"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "4.34.2",
3
+ "version": "4.34.4",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",