@vived/app 4.11.3 → 4.13.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 (58) 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/RequestHandler/UC/StartZSpaceUC.js +12 -1
  4. package/lib/Components/RequestHandler/UC/StopZSpaceUC.js +20 -7
  5. package/lib/Components/SceneRoot/Controllers/ScaleSceneRootSC.d.ts +14 -0
  6. package/lib/Components/SceneRoot/Controllers/ScaleSceneRootSC.js +55 -0
  7. package/lib/Components/SceneRoot/Controllers/SceneRootMoveSC.d.ts +14 -0
  8. package/lib/Components/SceneRoot/Controllers/SceneRootMoveSC.js +53 -0
  9. package/lib/Components/SceneRoot/Controllers/index.d.ts +2 -2
  10. package/lib/Components/SceneRoot/Controllers/index.js +2 -2
  11. package/lib/Components/Selection/Controller/HoverOnAppObjectSC.d.ts +11 -0
  12. package/lib/Components/Selection/Controller/HoverOnAppObjectSC.js +41 -0
  13. package/lib/Components/Selection/Controller/PressOnAppObjectSC.d.ts +18 -0
  14. package/lib/Components/Selection/Controller/PressOnAppObjectSC.js +70 -0
  15. package/lib/Components/Selection/Controller/SelectAppObjectSC.d.ts +11 -0
  16. package/lib/Components/Selection/Controller/SelectAppObjectSC.js +39 -0
  17. package/lib/Components/Selection/Controller/index.d.ts +3 -3
  18. package/lib/Components/Selection/Controller/index.js +3 -3
  19. package/lib/Components/Stylus/Entity/StylusEntity.d.ts +21 -0
  20. package/lib/Components/Stylus/Entity/StylusEntity.js +104 -0
  21. package/lib/Components/Stylus/Entity/index.d.ts +1 -0
  22. package/lib/Components/Stylus/Entity/index.js +13 -0
  23. package/lib/Components/Stylus/Mocks/MockEmulateStylusUC.d.ts +10 -0
  24. package/lib/Components/Stylus/Mocks/MockEmulateStylusUC.js +19 -0
  25. package/lib/Components/Stylus/Mocks/index.d.ts +1 -0
  26. package/lib/Components/Stylus/Mocks/index.js +13 -0
  27. package/lib/Components/Stylus/PMs/StylusColorLengthPM.d.ts +14 -0
  28. package/lib/Components/Stylus/PMs/StylusColorLengthPM.js +81 -0
  29. package/lib/Components/Stylus/PMs/StylusIsInUsePM.d.ts +6 -0
  30. package/lib/Components/Stylus/PMs/StylusIsInUsePM.js +36 -0
  31. package/lib/Components/Stylus/PMs/index.d.ts +2 -0
  32. package/lib/Components/Stylus/PMs/index.js +14 -0
  33. package/lib/Components/Stylus/UCs/EmulateStylusUC.d.ts +9 -0
  34. package/lib/Components/Stylus/UCs/EmulateStylusUC.js +132 -0
  35. package/lib/Components/Stylus/UCs/index.d.ts +1 -0
  36. package/lib/Components/Stylus/UCs/index.js +13 -0
  37. package/lib/Components/Stylus/index.d.ts +4 -0
  38. package/lib/Components/Stylus/index.js +16 -0
  39. package/lib/Components/Transform3D/UC/StylusMoveTransformUC.js +14 -35
  40. package/lib/Components/index.d.ts +5 -4
  41. package/lib/Components/index.js +5 -4
  42. package/lib/Components/zSpace/Controllers/EmulateStylus.d.ts +2 -1
  43. package/lib/Components/zSpace/Controllers/EmulateStylus.js +13 -0
  44. package/lib/Components/zSpace/Entities/ZSpaceEntity.d.ts +0 -2
  45. package/lib/Components/zSpace/Entities/ZSpaceEntity.js +0 -3
  46. package/lib/Components/zSpace/Entities/index.d.ts +0 -1
  47. package/lib/Components/zSpace/Entities/index.js +0 -1
  48. package/lib/Components/zSpace/PM/index.d.ts +0 -2
  49. package/lib/Components/zSpace/PM/index.js +0 -2
  50. package/lib/Components/zSpace/UC/StylusFromGamepadHook.d.ts +2 -3
  51. package/lib/Components/zSpace/UC/StylusFromGamepadHook.js +14 -13
  52. package/lib/Components/zSpace/index.d.ts +0 -1
  53. package/lib/Components/zSpace/index.js +0 -1
  54. package/lib/Entities/TransformNode.d.ts +0 -55
  55. package/lib/ValueObjects/Color.js +1 -1
  56. package/lib/ValueObjects/ParametricLine.d.ts +3 -0
  57. package/lib/ValueObjects/ParametricLine.js +13 -3
  58. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeMockEmulateStylusUC = exports.MockEmulateStylusUC = void 0;
4
+ const EmulateStylusUC_1 = require("../UCs/EmulateStylusUC");
5
+ class MockEmulateStylusUC extends EmulateStylusUC_1.EmulateStylusUC {
6
+ constructor(appObject) {
7
+ super(appObject, EmulateStylusUC_1.EmulateStylusUC.type);
8
+ this.startEmulating = jest.fn();
9
+ this.stopEmulating = jest.fn();
10
+ }
11
+ get isEmulating() {
12
+ throw new Error("Method not implemented.");
13
+ }
14
+ }
15
+ exports.MockEmulateStylusUC = MockEmulateStylusUC;
16
+ function makeMockEmulateStylusUC(appObjects) {
17
+ return new MockEmulateStylusUC(appObjects.getOrCreate("MockEmulateStylusUC"));
18
+ }
19
+ exports.makeMockEmulateStylusUC = makeMockEmulateStylusUC;
@@ -0,0 +1 @@
1
+ export * from "./MockEmulateStylusUC";
@@ -0,0 +1,13 @@
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("./MockEmulateStylusUC"), exports);
@@ -0,0 +1,14 @@
1
+ import { AppObject, AppObjectPM, AppObjectRepo } 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
+ static get(appObjects: AppObjectRepo): StylusColorLengthPM | undefined;
13
+ }
14
+ export declare function makeStylusColorLengthPM(appObject: AppObject): StylusColorLengthPM;
@@ -0,0 +1,81 @@
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 StylusEntity_1 = require("../Entity/StylusEntity");
8
+ class StylusColorLengthPM extends AppObject_1.AppObjectPM {
9
+ static get(appObjects) {
10
+ return AppObject_1.getSingletonComponent(StylusColorLengthPM.type, appObjects);
11
+ }
12
+ }
13
+ exports.StylusColorLengthPM = StylusColorLengthPM;
14
+ StylusColorLengthPM.type = "StylusColorLengthPM";
15
+ function makeStylusColorLengthPM(appObject) {
16
+ return new StylusColorLengthPMImp(appObject);
17
+ }
18
+ exports.makeStylusColorLengthPM = makeStylusColorLengthPM;
19
+ class StylusColorLengthPMImp extends StylusColorLengthPM {
20
+ constructor(appObject) {
21
+ super(appObject, StylusColorLengthPM.type);
22
+ this.defaultLength = 1;
23
+ this.rayColorNoPick = ValueObjects_1.Color.RGB(128, 128, 128);
24
+ this.rayColorPick = ValueObjects_1.Color.RGB(0, 255, 0);
25
+ this.onEntityChange = () => {
26
+ if (!this.stylus || !this.stylus.isInUse) {
27
+ this.setDefaultVM();
28
+ return;
29
+ }
30
+ const pickRay = this.stylus.pickRay;
31
+ const scenePickUC = Babylon_1.SceneRayPickUC.get(this.appObject.appObjectRepo);
32
+ if (!scenePickUC) {
33
+ this.setDefaultVM();
34
+ return;
35
+ }
36
+ const scenePick = scenePickUC.sceneRayPick(pickRay);
37
+ let color = this.rayColorNoPick;
38
+ let length = this.defaultLength;
39
+ if (scenePick && (scenePick === null || scenePick === void 0 ? void 0 : scenePick.hit) && scenePick.worldPickPoint) {
40
+ color = this.rayColorPick;
41
+ length = Math.abs(ValueObjects_1.Vector3.Subtract(this.stylus.transform.worldPosition, scenePick.worldPickPoint).magnitude);
42
+ }
43
+ const vm = {
44
+ color,
45
+ length
46
+ };
47
+ this.doUpdateView(vm);
48
+ };
49
+ this.dispose = () => {
50
+ var _a, _b;
51
+ super.dispose();
52
+ (_a = this.stylus) === null || _a === void 0 ? void 0 : _a.removeChangeObserver(this.onEntityChange);
53
+ (_b = this.stylus) === null || _b === void 0 ? void 0 : _b.removeOnDisposeObserver(this.dispose);
54
+ };
55
+ this.stylus = appObject.getComponent(StylusEntity_1.StylusEntity.type);
56
+ if (this.stylus) {
57
+ this.stylus.addChangeObserver(this.onEntityChange);
58
+ this.stylus.addOnDisposeObserver(() => {
59
+ this.dispose();
60
+ });
61
+ this.onEntityChange();
62
+ }
63
+ else {
64
+ this.warn("App Object does not have a Stylus Entity");
65
+ }
66
+ this.appObjects.registerSingleton(this);
67
+ }
68
+ vmsAreEqual(a, b) {
69
+ if (ValueObjects_1.Color.Equal(a.color, b.color) && a.length === b.length) {
70
+ return true;
71
+ }
72
+ return false;
73
+ }
74
+ setDefaultVM() {
75
+ const vm = {
76
+ color: this.rayColorNoPick,
77
+ length: 0
78
+ };
79
+ this.doUpdateView(vm);
80
+ }
81
+ }
@@ -0,0 +1,6 @@
1
+ import { AppObject, AppObjectPM, AppObjectRepo } from "../../../AppObject";
2
+ export declare abstract class StylusIsInUsePM extends AppObjectPM<boolean> {
3
+ static readonly type = "StylusIsInUsePM";
4
+ static get: (appObjects: AppObjectRepo) => StylusIsInUsePM | undefined;
5
+ }
6
+ export declare function makeStylusIsInUsePM(appObject: AppObject): StylusIsInUsePM;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeStylusIsInUsePM = exports.StylusIsInUsePM = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const StylusEntity_1 = require("../Entity/StylusEntity");
6
+ class StylusIsInUsePM extends AppObject_1.AppObjectPM {
7
+ }
8
+ exports.StylusIsInUsePM = StylusIsInUsePM;
9
+ StylusIsInUsePM.type = "StylusIsInUsePM";
10
+ StylusIsInUsePM.get = (appObjects) => AppObject_1.getSingletonComponent(StylusIsInUsePM.type, appObjects);
11
+ function makeStylusIsInUsePM(appObject) {
12
+ return new StylusIsInUsePMImp(appObject);
13
+ }
14
+ exports.makeStylusIsInUsePM = makeStylusIsInUsePM;
15
+ class StylusIsInUsePMImp extends StylusIsInUsePM {
16
+ constructor(appObject) {
17
+ super(appObject, StylusIsInUsePM.type);
18
+ this.onStylusChange = () => {
19
+ if (!this.stylus)
20
+ return;
21
+ this.doUpdateView(this.stylus.isInUse);
22
+ };
23
+ this.stylus = appObject.getComponent(StylusEntity_1.StylusEntity.type);
24
+ if (this.stylus) {
25
+ this.stylus.addChangeObserver(this.onStylusChange);
26
+ this.onStylusChange();
27
+ }
28
+ else {
29
+ this.warn("App Object does not have a Stylus Entity");
30
+ }
31
+ this.appObjects.registerSingleton(this);
32
+ }
33
+ vmsAreEqual(a, b) {
34
+ return a === b;
35
+ }
36
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./StylusColorLengthPM";
2
+ export * from "./StylusIsInUsePM";
@@ -0,0 +1,14 @@
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("./StylusColorLengthPM"), exports);
14
+ __exportStar(require("./StylusIsInUsePM"), exports);
@@ -0,0 +1,9 @@
1
+ import { AppObject, AppObjectRepo, AppObjectUC } from "../../../AppObject";
2
+ export declare abstract class EmulateStylusUC extends AppObjectUC {
3
+ static type: string;
4
+ abstract get isEmulating(): boolean;
5
+ abstract startEmulating(): void;
6
+ abstract stopEmulating(): void;
7
+ static get(appObjects: AppObjectRepo): EmulateStylusUC | undefined;
8
+ }
9
+ export declare function makeEmulateStylusUC(appObject: AppObject): EmulateStylusUC;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeEmulateStylusUC = exports.EmulateStylusUC = 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 TouchController_1 = require("../../TouchController");
9
+ const StylusEntity_1 = require("../Entity/StylusEntity");
10
+ class EmulateStylusUC extends AppObject_1.AppObjectUC {
11
+ static get(appObjects) {
12
+ return AppObject_1.getSingletonComponent(EmulateStylusUC.type, appObjects);
13
+ }
14
+ }
15
+ exports.EmulateStylusUC = EmulateStylusUC;
16
+ EmulateStylusUC.type = "EmulateStylusUC";
17
+ function makeEmulateStylusUC(appObject) {
18
+ return new EmulateStylusUCImp(appObject);
19
+ }
20
+ exports.makeEmulateStylusUC = makeEmulateStylusUC;
21
+ class EmulateStylusUCImp extends EmulateStylusUC {
22
+ constructor(appObject) {
23
+ super(appObject, EmulateStylusUC.type);
24
+ this._eventElement = undefined;
25
+ this.lastMousePos = ValueObjects_1.Vector2.Zero();
26
+ this._isEmulating = false;
27
+ this.screenPlane = ValueObjects_1.ParametricPlane.FromPointNormal(ValueObjects_1.Vector3.Zero(), ValueObjects_1.Vector3.Backward());
28
+ this.startEmulating = () => {
29
+ var _a;
30
+ if (!this.mouseInput)
31
+ return;
32
+ if (!this.stylus)
33
+ return;
34
+ if (this._isEmulating === true)
35
+ return;
36
+ this._eventElement = this.mouseInput.eventElement;
37
+ if (!this._eventElement) {
38
+ this.warn("No event element");
39
+ return;
40
+ }
41
+ this.mouseInput.clearInputElement();
42
+ (_a = this.touchInput) === null || _a === void 0 ? void 0 : _a.clearInputElement();
43
+ this._eventElement.addEventListener("mousedown", this.onMouseDown, false);
44
+ this._eventElement.addEventListener("mouseup", this.onMouseUp, false);
45
+ this._eventElement.addEventListener("mousemove", this.onMouseMove, false);
46
+ this._eventElement.addEventListener("keydown", this.submitKeyDown, false);
47
+ this.stylus.transform.localPosition = new ValueObjects_1.Vector3(0.05, -0.05, -0.5);
48
+ this._isEmulating = true;
49
+ };
50
+ this.stopEmulating = () => {
51
+ var _a;
52
+ if (!this.mouseInput)
53
+ return;
54
+ if (this._isEmulating === false)
55
+ return;
56
+ if (this._eventElement) {
57
+ this._eventElement.removeEventListener("mousedown", this.onMouseDown, false);
58
+ this._eventElement.removeEventListener("mouseup", this.onMouseUp, false);
59
+ this._eventElement.removeEventListener("mousemove", this.onMouseMove, false);
60
+ this._eventElement.removeEventListener("keydown", this.submitKeyDown, false);
61
+ this.mouseInput.setEventElement(this._eventElement);
62
+ (_a = this.touchInput) === null || _a === void 0 ? void 0 : _a.setEventElement(this._eventElement);
63
+ }
64
+ this._eventElement = undefined;
65
+ this._isEmulating = false;
66
+ };
67
+ this.submitKeyDown = (e) => {
68
+ const bumpAmount = 0.01;
69
+ let bump = ValueObjects_1.Vector3.Zero();
70
+ switch (e.code) {
71
+ case "KeyA":
72
+ bump = new ValueObjects_1.Vector3(-bumpAmount, 0, 0);
73
+ break;
74
+ case "KeyD":
75
+ bump = new ValueObjects_1.Vector3(bumpAmount, 0, 0);
76
+ break;
77
+ case "KeyW":
78
+ bump = new ValueObjects_1.Vector3(0, 0, bumpAmount);
79
+ break;
80
+ case "KeyS":
81
+ bump = new ValueObjects_1.Vector3(0, 0, -bumpAmount);
82
+ break;
83
+ }
84
+ if (!this.stylus)
85
+ return;
86
+ const currentPos = this.stylus.transform.localPosition;
87
+ this.stylus.transform.localPosition = ValueObjects_1.Vector3.Add(currentPos, bump);
88
+ this.pointAtMouse(this.lastMousePos);
89
+ };
90
+ this.onMouseDown = (e) => {
91
+ if (!this.stylus)
92
+ return;
93
+ this.stylus.updateButtonState(e.button, true);
94
+ };
95
+ this.onMouseUp = (e) => {
96
+ if (!this.stylus)
97
+ return;
98
+ this.stylus.updateButtonState(e.button, false);
99
+ };
100
+ this.onMouseMove = (e) => {
101
+ const px = e.offsetX;
102
+ const py = e.offsetY;
103
+ const pos = new ValueObjects_1.Vector2(px, py);
104
+ this.pointAtMouse(pos);
105
+ this.lastMousePos = pos;
106
+ };
107
+ this.pointAtMouse = (pos) => {
108
+ if (!this.stylus)
109
+ return;
110
+ const ray = Babylon_1.pixelToSceneRay(pos, this.appObjects);
111
+ const hit = this.screenPlane.intersectLine(ray);
112
+ if (!hit) {
113
+ return;
114
+ }
115
+ const direction = ValueObjects_1.Vector3.Subtract(hit, this.stylus.transform.localPosition);
116
+ this.stylus.transform.localRotation = ValueObjects_1.Quaternion.FromDirectionVector(direction);
117
+ };
118
+ this.appObjects.registerSingleton(this);
119
+ }
120
+ get mouseInput() {
121
+ return this.getCachedSingleton(MouseInput_1.MouseInputEntity.type);
122
+ }
123
+ get touchInput() {
124
+ return this.getCachedSingleton(TouchController_1.TouchInputEntity.type);
125
+ }
126
+ get stylus() {
127
+ return this.getCachedSingleton(StylusEntity_1.StylusEntity.type);
128
+ }
129
+ get isEmulating() {
130
+ return this._isEmulating;
131
+ }
132
+ }
@@ -0,0 +1 @@
1
+ export * from "./EmulateStylusUC";
@@ -0,0 +1,13 @@
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("./EmulateStylusUC"), exports);
@@ -0,0 +1,4 @@
1
+ export * from "./Entity";
2
+ export * from "./Mocks";
3
+ export * from "./PMs";
4
+ export * from "./UCs";
@@ -0,0 +1,16 @@
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("./Entity"), exports);
14
+ __exportStar(require("./Mocks"), exports);
15
+ __exportStar(require("./PMs"), exports);
16
+ __exportStar(require("./UCs"), exports);
@@ -5,8 +5,9 @@ const __1 = require("..");
5
5
  const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
6
6
  const ValueObjects_1 = require("../../../ValueObjects");
7
7
  const Dispatcher_1 = require("../../Dispatcher");
8
+ const Stylus_1 = require("../../Stylus");
8
9
  const UndoRedo_1 = require("../../UndoRedo");
9
- const ZSpaceEntity_1 = require("../../zSpace/Entities/ZSpaceEntity");
10
+ const Entities_1 = require("../Entities");
10
11
  const MoveTransformUndoRedo_1 = require("./MoveTransformUndoRedo");
11
12
  class StylusMoveTransformUC extends AppObjectUC_1.AppObjectUC {
12
13
  static get(appObject) {
@@ -33,8 +34,8 @@ class StylusMoveTransformUCImp extends StylusMoveTransformUC {
33
34
  return;
34
35
  if (!this.stylus)
35
36
  return;
36
- this.transform.worldPosition = this.stylus.helperTransform.worldPosition;
37
- this.transform.worldRotation = this.stylus.helperTransform.worldRotation;
37
+ this.transform.worldPosition = this.helperTransform.worldPosition;
38
+ this.transform.worldRotation = this.helperTransform.worldRotation;
38
39
  this.didMove = true;
39
40
  };
40
41
  this.stop = (registerUndo = false) => {
@@ -54,43 +55,21 @@ class StylusMoveTransformUCImp extends StylusMoveTransformUC {
54
55
  this.isMoving = false;
55
56
  this.didMove = false;
56
57
  };
57
- const appObjects = appObject.appObjectRepo;
58
- this.transform = appObject.getComponent(__1.Transform3D.type);
59
- if (!this.transform) {
60
- this.warn("StylusMoveTransformUCImp has been added to an app object that does not have a Transform3D. Add one first");
61
- return;
58
+ this.transform = __1.Transform3D.addIfMissing(this.appObject);
59
+ const helperAO = this.appObjects.getOrCreate(this.appObject.id + "_helper");
60
+ this.helperTransform = Entities_1.makeTransform3D(helperAO);
61
+ if (this.stylus) {
62
+ this.helperTransform.parent = this.stylus.transform;
62
63
  }
63
64
  }
64
65
  get dispatchStateChange() {
65
- if (!this._cachedDispatchStateChange) {
66
- this._cachedDispatchStateChange = Dispatcher_1.DispatchStateChangeUC.get(this.appObject.appObjectRepo);
67
- if (!this._cachedDispatchStateChange) {
68
- this.warn("Unable to find DispatchStateChangeUC");
69
- return;
70
- }
71
- }
72
- return this._cachedDispatchStateChange;
66
+ return this.getCachedSingleton(Dispatcher_1.DispatchStateChangeUC.type);
73
67
  }
74
68
  get undoRedoEntity() {
75
- if (!this._cachedUndoRedo) {
76
- this._cachedUndoRedo = UndoRedo_1.UndoRedoEntity.get(this.appObject.appObjectRepo);
77
- if (!this._cachedUndoRedo) {
78
- this.warn("Unable to find UndoRedoEntity");
79
- return;
80
- }
81
- }
82
- return this._cachedUndoRedo;
69
+ return this.getCachedSingleton(UndoRedo_1.UndoRedoEntity.type);
83
70
  }
84
71
  get stylus() {
85
- if (!this._cachedStylus) {
86
- const zSpaceEntity = ZSpaceEntity_1.ZSpaceEntity.get(this.appObject.appObjectRepo);
87
- if (!zSpaceEntity) {
88
- this.warn("Unable to find ZSpaceEntity");
89
- return;
90
- }
91
- this._cachedStylus = zSpaceEntity.stylus;
92
- }
93
- return this._cachedStylus;
72
+ return this.getCachedSingleton(Stylus_1.StylusEntity.type);
94
73
  }
95
74
  initialize() {
96
75
  if (!this.transform)
@@ -99,8 +78,8 @@ class StylusMoveTransformUCImp extends StylusMoveTransformUC {
99
78
  return false;
100
79
  this.initialPosition = this.transform.localPosition;
101
80
  this.initialRotation = this.transform.localRotation;
102
- this.stylus.helperTransform.worldPosition = this.transform.worldPosition;
103
- this.stylus.helperTransform.worldRotation = this.transform.worldRotation;
81
+ this.helperTransform.worldPosition = this.transform.worldPosition;
82
+ this.helperTransform.worldRotation = this.transform.worldRotation;
104
83
  this.isMoving = true;
105
84
  return;
106
85
  }
@@ -6,23 +6,24 @@ export * from "./Dispatcher";
6
6
  export * from "./Enablement";
7
7
  export * from "./FramedScreen";
8
8
  export * from "./Hideable";
9
+ export * from "./HoverLabel";
9
10
  export * from "./KeyboardInput";
10
11
  export * from "./Label";
12
+ export * from "./Landmarks";
11
13
  export * from "./Mesh";
12
14
  export * from "./MouseInput";
13
15
  export * from "./OverlayColor";
14
16
  export * from "./Question";
15
17
  export * from "./RequestHandler";
16
18
  export * from "./SceneRoot";
19
+ export * from "./Selection";
17
20
  export * from "./StateMachine";
18
- export * from "./ThemeColors";
19
21
  export * from "./StoredView";
22
+ export * from "./Stylus";
23
+ export * from "./ThemeColors";
20
24
  export * from "./Tools";
21
25
  export * from "./TouchController";
22
26
  export * from "./Transform3D";
23
27
  export * from "./UndoRedo";
24
28
  export * from "./XR";
25
29
  export * from "./zSpace";
26
- export * from "./Selection";
27
- export * from "./Landmarks";
28
- export * from "./HoverLabel";
@@ -18,23 +18,24 @@ __exportStar(require("./Dispatcher"), exports);
18
18
  __exportStar(require("./Enablement"), exports);
19
19
  __exportStar(require("./FramedScreen"), exports);
20
20
  __exportStar(require("./Hideable"), exports);
21
+ __exportStar(require("./HoverLabel"), exports);
21
22
  __exportStar(require("./KeyboardInput"), exports);
22
23
  __exportStar(require("./Label"), exports);
24
+ __exportStar(require("./Landmarks"), exports);
23
25
  __exportStar(require("./Mesh"), exports);
24
26
  __exportStar(require("./MouseInput"), exports);
25
27
  __exportStar(require("./OverlayColor"), exports);
26
28
  __exportStar(require("./Question"), exports);
27
29
  __exportStar(require("./RequestHandler"), exports);
28
30
  __exportStar(require("./SceneRoot"), exports);
31
+ __exportStar(require("./Selection"), exports);
29
32
  __exportStar(require("./StateMachine"), exports);
30
- __exportStar(require("./ThemeColors"), exports);
31
33
  __exportStar(require("./StoredView"), exports);
34
+ __exportStar(require("./Stylus"), exports);
35
+ __exportStar(require("./ThemeColors"), exports);
32
36
  __exportStar(require("./Tools"), exports);
33
37
  __exportStar(require("./TouchController"), exports);
34
38
  __exportStar(require("./Transform3D"), exports);
35
39
  __exportStar(require("./UndoRedo"), exports);
36
40
  __exportStar(require("./XR"), exports);
37
41
  __exportStar(require("./zSpace"), exports);
38
- __exportStar(require("./Selection"), exports);
39
- __exportStar(require("./Landmarks"), exports);
40
- __exportStar(require("./HoverLabel"), exports);
@@ -1,9 +1,10 @@
1
1
  import { AppObject, AppObjectController } from "../../../AppObject";
2
- import { MouseController, MouseInputEvent } from "../../MouseInput";
2
+ import { MouseController, MouseInputEvent, MouseWheelEvent } from "../../MouseInput";
3
3
  export default abstract class EmulateZSpaceStylus extends AppObjectController implements MouseController {
4
4
  static readonly type = "EmulateZSpaceStylus";
5
5
  abstract onDown: (e: MouseInputEvent) => void;
6
6
  abstract onMove: (e: MouseInputEvent) => void;
7
7
  abstract onUp: (e: MouseInputEvent) => void;
8
+ abstract onWheel: (e: MouseWheelEvent) => void;
8
9
  }
9
10
  export declare function makeEmulateZSpaceStylus(appObject: AppObject): EmulateZSpaceStylus;
@@ -47,6 +47,19 @@ class EmulateZSpaceStylusImp extends EmulateZSpaceStylus {
47
47
  return;
48
48
  this.stylus.updateButtonState(e.button, false);
49
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
+ };
50
63
  this.onZpsaceEnabledChange = (enabled) => {
51
64
  this.emulationIsActive = false;
52
65
  if (!enabled)
@@ -2,7 +2,6 @@ import { AppObject } from "../../../AppObject/AppObject";
2
2
  import { AppObjectEntity } from "../../../AppObject/AppObjectEntity";
3
3
  import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
4
4
  import { ZSpaceDisplayEntity } from "./ZSpaceDisplayEntity";
5
- import { ZSpaceStylusEntity } from "./ZSpaceStylusEntity";
6
5
  import { ZSpaceViewEntity } from "./ZSpaceViewEntity";
7
6
  export declare const INSPIRE_WIDTH: number;
8
7
  export declare abstract class ZSpaceEntity extends AppObjectEntity {
@@ -15,7 +14,6 @@ export declare abstract class ZSpaceEntity extends AppObjectEntity {
15
14
  abstract set emulate(val: boolean);
16
15
  abstract get viewerScale(): number;
17
16
  abstract set viewerScale(val: number);
18
- abstract readonly stylus: ZSpaceStylusEntity;
19
17
  abstract readonly headView: ZSpaceViewEntity;
20
18
  abstract readonly leftEyeView: ZSpaceViewEntity;
21
19
  abstract readonly rightEyeView: ZSpaceViewEntity;
@@ -5,7 +5,6 @@ const AppObject_1 = require("../../../AppObject");
5
5
  const AppObjectEntity_1 = require("../../../AppObject/AppObjectEntity");
6
6
  const Entities_1 = require("../../../Entities");
7
7
  const ZSpaceDisplayEntity_1 = require("./ZSpaceDisplayEntity");
8
- const ZSpaceStylusEntity_1 = require("./ZSpaceStylusEntity");
9
8
  const ZSpaceViewEntity_1 = require("./ZSpaceViewEntity");
10
9
  exports.INSPIRE_WIDTH = 0.344;
11
10
  class ZSpaceEntity extends AppObjectEntity_1.AppObjectEntity {
@@ -34,8 +33,6 @@ class ZSpaceImp extends ZSpaceEntity {
34
33
  this.leftEyeView = ZSpaceViewEntity_1.makeZSpaceView(leftEye, ZSpaceViewEntity_1.ZSpaceViewType.LEFT);
35
34
  const rightEye = appObj.appObjectRepo.getOrCreate("zSpaceRightEyeView");
36
35
  this.rightEyeView = ZSpaceViewEntity_1.makeZSpaceView(rightEye, ZSpaceViewEntity_1.ZSpaceViewType.RIGHT);
37
- const stylusAO = appObj.appObjectRepo.getOrCreate("zSpaceStylus");
38
- this.stylus = ZSpaceStylusEntity_1.makeZSpaceStylus(stylusAO);
39
36
  const displayAO = appObj.appObjectRepo.getOrCreate("zSpaceDisplay");
40
37
  this.display = ZSpaceDisplayEntity_1.makeZSpaceDisplayEntity(displayAO);
41
38
  }
@@ -1,4 +1,3 @@
1
1
  export * from "./ZSpaceDisplayEntity";
2
2
  export * from "./ZSpaceEntity";
3
- export * from "./ZSpaceStylusEntity";
4
3
  export * from "./ZSpaceViewEntity";
@@ -12,5 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./ZSpaceDisplayEntity"), exports);
14
14
  __exportStar(require("./ZSpaceEntity"), exports);
15
- __exportStar(require("./ZSpaceStylusEntity"), exports);
16
15
  __exportStar(require("./ZSpaceViewEntity"), exports);
@@ -1,5 +1,3 @@
1
- export * from "./StylusColorLengthPM";
2
- export * from "./StylusIsInUsePM";
3
1
  export * from "./ZSpaceDisplayPM";
4
2
  export * from "./ZSpaceIsEnabledPM";
5
3
  export * from "./ZSpaceIsSupportedPM";
@@ -10,8 +10,6 @@ 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("./StylusColorLengthPM"), exports);
14
- __exportStar(require("./StylusIsInUsePM"), exports);
15
13
  __exportStar(require("./ZSpaceDisplayPM"), exports);
16
14
  __exportStar(require("./ZSpaceIsEnabledPM"), exports);
17
15
  __exportStar(require("./ZSpaceIsSupportedPM"), exports);
@@ -1,6 +1,5 @@
1
1
  /// <reference types="webxr" />
2
- import { AppObject } from "../../../AppObject/AppObject";
3
- import { AppObjectUC } from "../../../AppObject/AppObjectUC";
2
+ import { AppObject, AppObjectUC } from "../../../AppObject";
4
3
  export declare abstract class StylusFromGamepadHook extends AppObjectUC {
5
4
  static readonly type = "StylusFromGamepadHook";
6
5
  abstract onNewXRFrame(frame: XRFrame): void;
@@ -8,7 +7,7 @@ export declare abstract class StylusFromGamepadHook extends AppObjectUC {
8
7
  export declare function makeStylusFromGamepadHook(appObj: AppObject): StylusFromGamepadUCImp;
9
8
  declare class StylusFromGamepadUCImp extends StylusFromGamepadHook {
10
9
  private lastPresses;
11
- private zSpace;
10
+ private get stylus();
12
11
  private xrEntity?;
13
12
  onNewXRFrame: () => void;
14
13
  private processStylusPose;