@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
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeStylusFromGamepadHook = exports.StylusFromGamepadHook = void 0;
4
- const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
4
+ const AppObject_1 = require("../../../AppObject");
5
5
  const ValueObjects_1 = require("../../../ValueObjects");
6
+ const Stylus_1 = require("../../Stylus");
6
7
  const XR_1 = require("../../XR");
7
- const ZSpaceEntity_1 = require("../Entities/ZSpaceEntity");
8
- class StylusFromGamepadHook extends AppObjectUC_1.AppObjectUC {
8
+ class StylusFromGamepadHook extends AppObject_1.AppObjectUC {
9
9
  }
10
10
  exports.StylusFromGamepadHook = StylusFromGamepadHook;
11
11
  StylusFromGamepadHook.type = "StylusFromGamepadHook";
@@ -18,7 +18,7 @@ class StylusFromGamepadUCImp extends StylusFromGamepadHook {
18
18
  super(appObject, StylusFromGamepadHook.type);
19
19
  this.lastPresses = [false, false, false];
20
20
  this.onNewXRFrame = () => {
21
- if (!this.xrEntity)
21
+ if (!this.xrEntity || !this.stylus)
22
22
  return;
23
23
  const frame = this.xrEntity.lastXRFrame;
24
24
  if (!frame)
@@ -43,23 +43,23 @@ class StylusFromGamepadUCImp extends StylusFromGamepadHook {
43
43
  if (stylusPose)
44
44
  this.processStylusPose(stylusPose);
45
45
  };
46
- const zSpaceEntity = appObject.getComponent(ZSpaceEntity_1.ZSpaceEntity.type);
47
- if (!zSpaceEntity) {
48
- throw new Error("No ZSpace Entity");
49
- }
50
- this.zSpace = zSpaceEntity;
51
- const xrEntity = zSpaceEntity.appObject.getComponent(XR_1.XREntity.type);
46
+ const xrEntity = appObject.getComponent(XR_1.XREntity.type);
52
47
  if (!xrEntity) {
53
- this.warn("Unable to get XREntity from App Object");
48
+ this.error("Added to an App Object that does not have XREntity");
54
49
  return;
55
50
  }
56
51
  this.xrEntity = xrEntity;
57
52
  this.xrEntity.addChangeObserver(this.onNewXRFrame);
58
53
  }
54
+ get stylus() {
55
+ return this.getCachedSingleton(Stylus_1.StylusEntity.type);
56
+ }
59
57
  processStylusPose(pose) {
60
58
  const matrix = ValueObjects_1.Matrix.FromFloat32Array(pose.transform.matrix);
61
59
  const flippedMatrix = ValueObjects_1.Matrix.FlipTransformMatrixHand(matrix);
62
- this.zSpace.stylus.transform.localMatrix = flippedMatrix;
60
+ if (this.stylus) {
61
+ this.stylus.transform.localMatrix = flippedMatrix;
62
+ }
63
63
  }
64
64
  processButtons(stylusSource) {
65
65
  var _a, _b, _c;
@@ -73,9 +73,10 @@ class StylusFromGamepadUCImp extends StylusFromGamepadHook {
73
73
  presses[1] = (_b = gamepad.buttons[3]) === null || _b === void 0 ? void 0 : _b.pressed;
74
74
  presses[2] = (_c = gamepad.buttons[4]) === null || _c === void 0 ? void 0 : _c.pressed;
75
75
  presses.forEach((press, i) => {
76
+ var _a;
76
77
  if (this.lastPresses[i] !== press) {
77
78
  this.lastPresses[i] = press;
78
- this.zSpace.stylus.updateButtonState(i, press);
79
+ (_a = this.stylus) === null || _a === void 0 ? void 0 : _a.updateButtonState(i, press);
79
80
  }
80
81
  });
81
82
  }
@@ -1,4 +1,3 @@
1
1
  export * from "./Entities";
2
2
  export * from "./PM";
3
3
  export * from "./UC";
4
- export * from "./Controllers";
@@ -13,4 +13,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./Entities"), exports);
14
14
  __exportStar(require("./PM"), exports);
15
15
  __exportStar(require("./UC"), exports);
16
- __exportStar(require("./Controllers"), exports);
@@ -2,75 +2,20 @@ import { EaseFn } from "../Types";
2
2
  import { Matrix, Quaternion, Vector3 } from "../ValueObjects";
3
3
  export declare type OnTransformNodeChange = () => void;
4
4
  export interface TransformNode {
5
- /**
6
- * Local position of the transform
7
- */
8
5
  localPosition: Vector3;
9
- /**
10
- * The world position of the transform
11
- */
12
6
  worldPosition: Vector3;
13
- /**
14
- * Local roation of the transform
15
- */
16
7
  localRotation: Quaternion;
17
- /**
18
- * World roation of the transform
19
- */
20
8
  worldRotation: Quaternion;
21
- /**
22
- * Local scale of the transform
23
- */
24
9
  localScale: Vector3;
25
- /**
26
- * World scale of the transform
27
- */
28
10
  worldScale: Vector3;
29
- /**
30
- * Local transformation matrix
31
- */
32
11
  localMatrix: Matrix;
33
- /**
34
- * The global transformation matrix
35
- */
36
12
  worldMatrix: Matrix;
37
- /**
38
- * The transform's parent. Optional
39
- */
40
13
  parent?: TransformNode;
41
- /**
42
- * Transforms a point from local to world space coordinates
43
- * @param point point to transform in local coordinates
44
- */
45
14
  localPointToWorld: (point: Vector3) => Vector3;
46
- /**
47
- * Transforms a point from world to local space coordinates
48
- * @param point point to transform in world coordinates
49
- */
50
15
  worldPointToLocal: (point: Vector3) => Vector3;
51
- /**
52
- * Transforms a local direction vector to world coordinates.
53
- * @param direction direction to transform in local coordinates
54
- */
55
16
  localDirectionToWorld: (direction: Vector3) => Vector3;
56
- /**
57
- * Transforms a world direction vector to local coordinates
58
- * @param direction direction to transform in world coordinates
59
- */
60
17
  worldDirectionToLocal: (direction: Vector3) => Vector3;
61
- /**
62
- * Lerps this transform node
63
- * @param duration Lerp duration in MS
64
- * @param ease Lerp ease function
65
- * @param desiredPosition: Desired position. Optional.
66
- * @param desiredRotation: Desired rotation. Optional.
67
- * @param desiredScale: Desired scale. Optional.
68
- * @param onCompletedCallback: Optional function to call when the lerp has completed
69
- */
70
18
  lerp: (duration: number, ease: EaseFn, desiredPosition?: Vector3, desiredRotation?: Quaternion, desiredScale?: Vector3, onCompletedCallback?: () => void) => void;
71
- /**
72
- * Cancels any currently running lerp
73
- */
74
19
  cancelLerp: () => void;
75
20
  addObserver: (observer: OnTransformNodeChange) => void;
76
21
  removeObserver: (observer: OnTransformNodeChange) => void;
@@ -70,7 +70,7 @@ class Color {
70
70
  */
71
71
  static X11(name) {
72
72
  for (const c of x11Colors) {
73
- if (c.name === name) {
73
+ if (c.name.toLowerCase() === name.toLowerCase()) {
74
74
  return Color.Hex(c.hex);
75
75
  }
76
76
  }
@@ -17,11 +17,14 @@ export declare class ParametricLine {
17
17
  static Left(): ParametricLine;
18
18
  static Right(): ParametricLine;
19
19
  static GetPointAtDistance(line: ParametricLine, distance: number): Vector3;
20
+ static GetDistanceToPoint(line: ParametricLine, point: Vector3): number;
20
21
  readonly x0: number;
21
22
  readonly y0: number;
22
23
  readonly z0: number;
23
24
  readonly a: number;
24
25
  readonly b: number;
25
26
  readonly c: number;
27
+ get origin(): Vector3;
28
+ get direction(): Vector3;
26
29
  constructor(parameters: LineParameters);
27
30
  }
@@ -7,9 +7,10 @@ class ParametricLine {
7
7
  this.x0 = parameters.x0;
8
8
  this.y0 = parameters.y0;
9
9
  this.z0 = parameters.z0;
10
- this.a = parameters.a;
11
- this.b = parameters.b;
12
- this.c = parameters.c;
10
+ const dir = new Vector3_1.Vector3(parameters.a, parameters.b, parameters.c).unit;
11
+ this.a = dir.x;
12
+ this.b = dir.y;
13
+ this.c = dir.z;
13
14
  }
14
15
  // See https://planetcalc.com/8253/
15
16
  static FromTwoPoint(p1, p2) {
@@ -62,5 +63,14 @@ class ParametricLine {
62
63
  const z = line.z0 + line.c * distance;
63
64
  return new Vector3_1.Vector3(x, y, z);
64
65
  }
66
+ static GetDistanceToPoint(line, point) {
67
+ return Vector3_1.Vector3.Subtract(line.origin, point).magnitude;
68
+ }
69
+ get origin() {
70
+ return new Vector3_1.Vector3(this.x0, this.y0, this.z0);
71
+ }
72
+ get direction() {
73
+ return new Vector3_1.Vector3(this.a, this.b, this.c);
74
+ }
65
75
  }
66
76
  exports.ParametricLine = ParametricLine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "4.11.3",
3
+ "version": "4.13.0",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",