@pmndrs/viverse 0.2.13 → 0.2.14

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.
@@ -7,7 +7,7 @@ export declare class KeyboardActionBinding {
7
7
  set keys(keys: Array<string>);
8
8
  requiresPointerLock?: boolean;
9
9
  private updateState;
10
- constructor(action: WriteonlyEventAction<KeyboardEvent> | StateAction<boolean>, domElement: HTMLElement, abortSignal: AbortSignal);
10
+ constructor(action: WriteonlyEventAction<KeyboardEvent> | WriteonlyEventAction<void> | StateAction<boolean>, domElement: HTMLElement, abortSignal: AbortSignal);
11
11
  }
12
12
  export declare const DefaultMoveForwardKeys: string[];
13
13
  export declare const DefaultMoveBackwardKeys: string[];
@@ -54,6 +54,7 @@ export class KeyboardActionBinding {
54
54
  if (!this.keys.includes(e.code) || e.repeat) {
55
55
  return;
56
56
  }
57
+ //needed to support EventAction<void>
57
58
  action.emit(e);
58
59
  }, { signal: abortSignal });
59
60
  }
@@ -12,7 +12,7 @@ export declare class PointerButtonActionBinding {
12
12
  get buttons(): Array<number> | undefined;
13
13
  set buttons(buttons: Array<number> | undefined);
14
14
  requiresPointerLock?: boolean;
15
+ constructor(action: WriteonlyEventAction<PointerEvent> | WriteonlyEventAction<void> | StateAction<boolean>, domElement: HTMLElement, abortSignal: AbortSignal);
15
16
  private getPressedButtonsFromMask;
16
17
  private processPointer;
17
- constructor(action: WriteonlyEventAction<PointerEvent> | StateAction<boolean>, domElement: HTMLElement, abortSignal: AbortSignal);
18
18
  }
@@ -18,39 +18,6 @@ export class PointerButtonActionBinding {
18
18
  this.processPointer();
19
19
  }
20
20
  requiresPointerLock;
21
- getPressedButtonsFromMask(mask) {
22
- const pressed = [];
23
- if (mask & 1)
24
- pressed.push(0);
25
- if (mask & 2)
26
- pressed.push(2);
27
- if (mask & 4)
28
- pressed.push(1);
29
- if (mask & 8)
30
- pressed.push(3);
31
- if (mask & 16)
32
- pressed.push(4);
33
- return pressed;
34
- }
35
- processPointer(e) {
36
- if (e != null) {
37
- this.buttonsMask = e.buttons;
38
- }
39
- if ((this.requiresPointerLock ?? false) && document.pointerLockElement != this.domElement) {
40
- this.buttonsMask = 0;
41
- }
42
- const pressedButtons = this.getPressedButtonsFromMask(this.buttonsMask);
43
- const isActive = this.buttons == null ? pressedButtons.length > 0 : this.buttons.some((btn) => pressedButtons.includes(btn));
44
- if (this.writer != null) {
45
- this.writer.write(isActive);
46
- }
47
- if (this.eventAction != null && e != null) {
48
- if (isActive && !this.wasPressed) {
49
- this.eventAction.emit(e);
50
- }
51
- }
52
- this.wasPressed = isActive;
53
- }
54
21
  constructor(action, domElement, abortSignal) {
55
22
  this.domElement = domElement;
56
23
  if (action instanceof StateAction) {
@@ -87,4 +54,38 @@ export class PointerButtonActionBinding {
87
54
  }
88
55
  });
89
56
  }
57
+ getPressedButtonsFromMask(mask) {
58
+ const pressed = [];
59
+ if (mask & 1)
60
+ pressed.push(0);
61
+ if (mask & 2)
62
+ pressed.push(2);
63
+ if (mask & 4)
64
+ pressed.push(1);
65
+ if (mask & 8)
66
+ pressed.push(3);
67
+ if (mask & 16)
68
+ pressed.push(4);
69
+ return pressed;
70
+ }
71
+ processPointer(e) {
72
+ if (e != null) {
73
+ this.buttonsMask = e.buttons;
74
+ }
75
+ if ((this.requiresPointerLock ?? false) && document.pointerLockElement != this.domElement) {
76
+ this.buttonsMask = 0;
77
+ }
78
+ const pressedButtons = this.getPressedButtonsFromMask(this.buttonsMask);
79
+ const isActive = this.buttons == null ? pressedButtons.length > 0 : this.buttons.some((btn) => pressedButtons.includes(btn));
80
+ if (this.writer != null) {
81
+ this.writer.write(isActive);
82
+ }
83
+ if (this.eventAction != null && e != null) {
84
+ if (isActive && !this.wasPressed) {
85
+ //required to support EventAction<void>
86
+ this.eventAction.emit(e);
87
+ }
88
+ }
89
+ this.wasPressed = isActive;
90
+ }
90
91
  }
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "three": "*"
23
23
  },
24
- "version": "0.2.13",
24
+ "version": "0.2.14",
25
25
  "type": "module",
26
26
  "dependencies": {
27
27
  "@pixiv/three-vrm": "^3.4.2",