canvasengine 2.0.0-beta.5 → 2.0.0-beta.51

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 (172) hide show
  1. package/dist/components/Button.d.ts +185 -0
  2. package/dist/components/Button.d.ts.map +1 -0
  3. package/dist/components/Canvas.d.ts +17 -0
  4. package/dist/components/Canvas.d.ts.map +1 -0
  5. package/dist/components/Container.d.ts +86 -0
  6. package/dist/components/Container.d.ts.map +1 -0
  7. package/dist/components/DOMContainer.d.ts +98 -0
  8. package/dist/components/DOMContainer.d.ts.map +1 -0
  9. package/dist/components/DOMElement.d.ts +54 -0
  10. package/dist/components/DOMElement.d.ts.map +1 -0
  11. package/dist/components/DOMSprite.d.ts +127 -0
  12. package/dist/components/DOMSprite.d.ts.map +1 -0
  13. package/dist/components/DisplayObject.d.ts +94 -0
  14. package/dist/components/DisplayObject.d.ts.map +1 -0
  15. package/dist/components/FocusContainer.d.ts +129 -0
  16. package/dist/components/FocusContainer.d.ts.map +1 -0
  17. package/dist/components/Graphic.d.ts +64 -0
  18. package/dist/components/Graphic.d.ts.map +1 -0
  19. package/dist/components/Joystick.d.ts +36 -0
  20. package/dist/components/Joystick.d.ts.map +1 -0
  21. package/dist/components/Mesh.d.ts +208 -0
  22. package/dist/components/Mesh.d.ts.map +1 -0
  23. package/dist/components/NineSliceSprite.d.ts +16 -0
  24. package/dist/components/NineSliceSprite.d.ts.map +1 -0
  25. package/dist/components/ParticleEmitter.d.ts +4 -0
  26. package/dist/components/ParticleEmitter.d.ts.map +1 -0
  27. package/dist/components/Scene.d.ts +2 -0
  28. package/dist/components/Scene.d.ts.map +1 -0
  29. package/dist/components/Sprite.d.ts +242 -0
  30. package/dist/components/Sprite.d.ts.map +1 -0
  31. package/dist/components/Text.d.ts +25 -0
  32. package/dist/components/Text.d.ts.map +1 -0
  33. package/dist/components/TilingSprite.d.ts +17 -0
  34. package/dist/components/TilingSprite.d.ts.map +1 -0
  35. package/dist/components/Video.d.ts +14 -0
  36. package/dist/components/Video.d.ts.map +1 -0
  37. package/dist/components/Viewport.d.ts +121 -0
  38. package/dist/components/Viewport.d.ts.map +1 -0
  39. package/dist/components/index.d.ts +20 -0
  40. package/dist/components/index.d.ts.map +1 -0
  41. package/dist/components/types/DisplayObject.d.ts +106 -0
  42. package/dist/components/types/DisplayObject.d.ts.map +1 -0
  43. package/dist/components/types/MouseEvent.d.ts +4 -0
  44. package/dist/components/types/MouseEvent.d.ts.map +1 -0
  45. package/dist/components/types/Spritesheet.d.ts +248 -0
  46. package/dist/components/types/Spritesheet.d.ts.map +1 -0
  47. package/dist/components/types/index.d.ts +4 -0
  48. package/dist/components/types/index.d.ts.map +1 -0
  49. package/dist/directives/Controls.d.ts +112 -0
  50. package/dist/directives/Controls.d.ts.map +1 -0
  51. package/dist/directives/ControlsBase.d.ts +199 -0
  52. package/dist/directives/ControlsBase.d.ts.map +1 -0
  53. package/dist/directives/Drag.d.ts +69 -0
  54. package/dist/directives/Drag.d.ts.map +1 -0
  55. package/dist/directives/Flash.d.ts +116 -0
  56. package/dist/directives/Flash.d.ts.map +1 -0
  57. package/dist/directives/FocusNavigation.d.ts +52 -0
  58. package/dist/directives/FocusNavigation.d.ts.map +1 -0
  59. package/dist/directives/GamepadControls.d.ts +224 -0
  60. package/dist/directives/GamepadControls.d.ts.map +1 -0
  61. package/dist/directives/JoystickControls.d.ts +171 -0
  62. package/dist/directives/JoystickControls.d.ts.map +1 -0
  63. package/dist/directives/KeyboardControls.d.ts +219 -0
  64. package/dist/directives/KeyboardControls.d.ts.map +1 -0
  65. package/dist/directives/Scheduler.d.ts +35 -0
  66. package/dist/directives/Scheduler.d.ts.map +1 -0
  67. package/dist/directives/Shake.d.ts +98 -0
  68. package/dist/directives/Shake.d.ts.map +1 -0
  69. package/dist/directives/Sound.d.ts +25 -0
  70. package/dist/directives/Sound.d.ts.map +1 -0
  71. package/dist/directives/Transition.d.ts +10 -0
  72. package/dist/directives/Transition.d.ts.map +1 -0
  73. package/dist/directives/ViewportCull.d.ts +11 -0
  74. package/dist/directives/ViewportCull.d.ts.map +1 -0
  75. package/dist/directives/ViewportFollow.d.ts +18 -0
  76. package/dist/directives/ViewportFollow.d.ts.map +1 -0
  77. package/dist/directives/index.d.ts +13 -0
  78. package/dist/directives/index.d.ts.map +1 -0
  79. package/dist/engine/FocusManager.d.ts +174 -0
  80. package/dist/engine/FocusManager.d.ts.map +1 -0
  81. package/dist/engine/animation.d.ts +72 -0
  82. package/dist/engine/animation.d.ts.map +1 -0
  83. package/dist/engine/bootstrap.d.ts +48 -0
  84. package/dist/engine/bootstrap.d.ts.map +1 -0
  85. package/dist/engine/directive.d.ts +13 -0
  86. package/dist/engine/directive.d.ts.map +1 -0
  87. package/dist/engine/reactive.d.ts +134 -0
  88. package/dist/engine/reactive.d.ts.map +1 -0
  89. package/dist/engine/signal.d.ts +71 -0
  90. package/dist/engine/signal.d.ts.map +1 -0
  91. package/dist/engine/trigger.d.ts +54 -0
  92. package/dist/engine/trigger.d.ts.map +1 -0
  93. package/dist/engine/utils.d.ts +89 -0
  94. package/dist/engine/utils.d.ts.map +1 -0
  95. package/dist/hooks/addContext.d.ts +2 -0
  96. package/dist/hooks/addContext.d.ts.map +1 -0
  97. package/dist/hooks/useFocus.d.ts +60 -0
  98. package/dist/hooks/useFocus.d.ts.map +1 -0
  99. package/dist/hooks/useProps.d.ts +42 -0
  100. package/dist/hooks/useProps.d.ts.map +1 -0
  101. package/dist/hooks/useRef.d.ts +4 -0
  102. package/dist/hooks/useRef.d.ts.map +1 -0
  103. package/dist/index-DaGekQUW.js +2218 -0
  104. package/dist/index-DaGekQUW.js.map +1 -0
  105. package/dist/index.d.ts +19 -1099
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.global.js +5 -0
  108. package/dist/index.global.js.map +1 -0
  109. package/dist/index.js +11749 -2901
  110. package/dist/index.js.map +1 -1
  111. package/dist/utils/Ease.d.ts +17 -0
  112. package/dist/utils/Ease.d.ts.map +1 -0
  113. package/dist/utils/GlobalAssetLoader.d.ts +141 -0
  114. package/dist/utils/GlobalAssetLoader.d.ts.map +1 -0
  115. package/dist/utils/RadialGradient.d.ts +57 -0
  116. package/dist/utils/RadialGradient.d.ts.map +1 -0
  117. package/dist/utils/functions.d.ts +2 -0
  118. package/dist/utils/functions.d.ts.map +1 -0
  119. package/dist/utils/tabindex.d.ts +16 -0
  120. package/dist/utils/tabindex.d.ts.map +1 -0
  121. package/package.json +13 -7
  122. package/src/components/Button.ts +399 -0
  123. package/src/components/Canvas.ts +62 -46
  124. package/src/components/Container.ts +21 -2
  125. package/src/components/DOMContainer.ts +379 -0
  126. package/src/components/DOMElement.ts +556 -0
  127. package/src/components/DOMSprite.ts +1040 -0
  128. package/src/components/DisplayObject.ts +392 -201
  129. package/src/components/FocusContainer.ts +368 -0
  130. package/src/components/Graphic.ts +227 -66
  131. package/src/components/Joystick.ts +363 -0
  132. package/src/components/Mesh.ts +222 -0
  133. package/src/components/NineSliceSprite.ts +4 -1
  134. package/src/components/ParticleEmitter.ts +12 -8
  135. package/src/components/Sprite.ts +297 -31
  136. package/src/components/Text.ts +125 -18
  137. package/src/components/Video.ts +2 -2
  138. package/src/components/Viewport.ts +118 -63
  139. package/src/components/index.ts +9 -2
  140. package/src/components/types/DisplayObject.ts +41 -4
  141. package/src/components/types/Spritesheet.ts +0 -118
  142. package/src/directives/Controls.ts +254 -0
  143. package/src/directives/ControlsBase.ts +267 -0
  144. package/src/directives/Drag.ts +357 -52
  145. package/src/directives/Flash.ts +419 -0
  146. package/src/directives/FocusNavigation.ts +113 -0
  147. package/src/directives/GamepadControls.ts +537 -0
  148. package/src/directives/JoystickControls.ts +396 -0
  149. package/src/directives/KeyboardControls.ts +85 -430
  150. package/src/directives/Scheduler.ts +12 -4
  151. package/src/directives/Shake.ts +298 -0
  152. package/src/directives/Sound.ts +94 -31
  153. package/src/directives/ViewportFollow.ts +40 -9
  154. package/src/directives/index.ts +12 -6
  155. package/src/engine/FocusManager.ts +510 -0
  156. package/src/engine/animation.ts +175 -21
  157. package/src/engine/bootstrap.ts +93 -3
  158. package/src/engine/directive.ts +4 -4
  159. package/src/engine/reactive.ts +901 -161
  160. package/src/engine/signal.ts +113 -25
  161. package/src/engine/trigger.ts +34 -7
  162. package/src/engine/utils.ts +19 -3
  163. package/src/hooks/useFocus.ts +91 -0
  164. package/src/hooks/useProps.ts +1 -1
  165. package/src/index.ts +8 -2
  166. package/src/types/pixi-cull.d.ts +7 -0
  167. package/src/utils/GlobalAssetLoader.ts +257 -0
  168. package/src/utils/functions.ts +7 -0
  169. package/src/utils/tabindex.ts +70 -0
  170. package/testing/index.ts +35 -4
  171. package/tsconfig.json +18 -0
  172. package/vite.config.ts +39 -0
@@ -1,6 +1,4 @@
1
- import { Directive, registerDirective } from "../engine/directive";
2
- import { Element } from "../engine/reactive";
3
- import { fps2ms } from "../engine/utils";
1
+ import { ControlsBase, ControlOptions, Controls, BoundKey } from "./ControlsBase";
4
2
 
5
3
  export enum Input {
6
4
  Break = 'break',
@@ -144,19 +142,8 @@ export enum Input {
144
142
  Altgr = 'altgr'
145
143
  }
146
144
 
147
- export interface ControlOptions {
148
- repeat?: boolean;
149
- bind: string | string[];
150
- keyUp?: Function;
151
- keyDown?: Function;
152
- delay?: number | {
153
- duration: number;
154
- otherControls?: (string)[];
155
- };
156
- }
157
- export interface Controls {
158
- [controlName: string]: ControlOptions;
159
- }
145
+ // Re-export for backward compatibility
146
+ export type { ControlOptions, Controls, BoundKey };
160
147
 
161
148
  // keyboard handling
162
149
  const keyCodeTable = {
@@ -335,59 +322,68 @@ const inverse = (obj) => {
335
322
 
336
323
  const inverseKeyCodeTable = inverse(keyCodeTable)
337
324
 
338
- type BoundKey = { actionName: string, options: ControlOptions, parameters?: any }
339
-
340
- export class KeyboardControls extends Directive {
325
+ /**
326
+ * Keyboard input controls implementation
327
+ *
328
+ * Handles keyboard input events and maps them to control actions.
329
+ * Supports composite directions (diagonal movement) and key repeat functionality.
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * const keyboardControls = new KeyboardControls();
334
+ * keyboardControls.setInputs({
335
+ * up: {
336
+ * repeat: true,
337
+ * bind: Input.Up,
338
+ * keyDown() {
339
+ * console.log('Up pressed');
340
+ * }
341
+ * }
342
+ * });
343
+ * keyboardControls.start();
344
+ * ```
345
+ */
346
+ export class KeyboardControls extends ControlsBase {
341
347
  private keyState: {
342
348
  [keyName: string]: {
343
349
  isDown: boolean,
344
350
  count: number
345
351
  } | null
346
352
  } = {}
347
- private boundKeys: {
348
- [keyName: string]: BoundKey
349
- } = {}
350
- private stop: boolean = false
351
353
  private lastKeyPressed: number | null = null
352
- private _controlsOptions: Controls = {}
353
- private interval: any
354
- // TODO: This should be dynamic
355
- private serverFps: number = 60
354
+ private lastActionTimes: Record<string, number> = {}
356
355
  private directionState: {
357
356
  up: boolean,
358
357
  down: boolean,
359
358
  left: boolean,
360
359
  right: boolean
361
360
  } = {
362
- up: false,
363
- down: false,
364
- left: false,
365
- right: false
366
- };
367
-
368
- onInit(element: Element) {
369
- this.setupListeners();
370
- this.setInputs(element.props.controls.value)
371
- // The processing is outside the rendering loop because if the FPS are lower (or higher) then the sending to the server would be slower or faster. Here it is constant
372
- this.interval = setInterval(() => {
373
- this.preStep()
374
- }, fps2ms(this.serverFps ?? 60))
375
- }
376
-
377
- onMount(element: Element) {}
361
+ up: false,
362
+ down: false,
363
+ left: false,
364
+ right: false
365
+ };
378
366
 
379
- onUpdate(props) {
380
- this.setInputs(props)
367
+ /**
368
+ * Setup keyboard event listeners
369
+ */
370
+ protected setupListeners(): void {
371
+ document.addEventListener('keydown', (e) => { this.onKeyChange(e, true); });
372
+ document.addEventListener('keyup', (e) => { this.onKeyChange(e, false); });
381
373
  }
382
374
 
383
- onDestroy() {
384
- clearInterval(this.interval)
375
+ /**
376
+ * Cleanup keyboard event listeners
377
+ */
378
+ protected cleanup(): void {
385
379
  document.removeEventListener('keydown', (e) => { this.onKeyChange(e, true); });
386
380
  document.removeEventListener('keyup', (e) => { this.onKeyChange(e, false); });
387
381
  }
388
382
 
389
- /** @internal */
390
- preStep() {
383
+ /**
384
+ * Process keyboard inputs each step
385
+ */
386
+ protected preStep() {
391
387
  if (this.stop) return;
392
388
 
393
389
  const direction = this.getDirection();
@@ -396,7 +392,7 @@ export class KeyboardControls extends Directive {
396
392
  const directionControl = this.boundKeys[direction];
397
393
  if (directionControl) {
398
394
  const { keyDown } = directionControl.options;
399
- if (keyDown ) {
395
+ if (keyDown) {
400
396
  this.applyInput(direction);
401
397
  }
402
398
  }
@@ -409,40 +405,43 @@ export class KeyboardControls extends Directive {
409
405
  }
410
406
  }
411
407
 
412
- private applyInput(keyName: string) {
408
+ /**
409
+ * Apply input for a keyboard key
410
+ * Overrides base implementation to handle key state and repeat logic
411
+ */
412
+ protected applyInput(keyName: string) {
413
413
  const keyState = this.keyState[keyName];
414
- if (!keyState) return;
414
+ if (!keyState) {
415
+ return;
416
+ }
415
417
  const { isDown, count } = keyState;
416
418
  if (isDown) {
417
- const { repeat, keyDown } = this.boundKeys[keyName].options;
419
+ const boundKey = this.boundKeys[keyName];
420
+ if (!boundKey) {
421
+ return;
422
+ }
423
+ const { repeat, keyDown, throttle } = boundKey.options;
418
424
  if ((repeat || count == 0)) {
419
- let parameters = this.boundKeys[keyName].parameters;
425
+ if (typeof throttle === "number") {
426
+ const now = Date.now();
427
+ const lastTime = this.lastActionTimes[boundKey.actionName] ?? 0;
428
+ if (now - lastTime < throttle) {
429
+ return;
430
+ }
431
+ this.lastActionTimes[boundKey.actionName] = now;
432
+ }
433
+ let parameters = boundKey.parameters;
420
434
  if (typeof parameters === "function") {
421
435
  parameters = parameters();
422
436
  }
423
437
  if (keyDown) {
424
- keyDown(this.boundKeys[keyName]);
438
+ keyDown(boundKey);
425
439
  }
426
440
  this.keyState[keyName]!.count++;
427
441
  }
428
442
  }
429
443
  }
430
444
 
431
- private setupListeners() {
432
- document.addEventListener('keydown', (e) => { this.onKeyChange(e, true); });
433
- document.addEventListener('keyup', (e) => { this.onKeyChange(e, false); });
434
- }
435
-
436
- private bindKey(keys: Input | Input[], actionName: string, options: ControlOptions, parameters?: object) {
437
- if (!Array.isArray(keys)) keys = [keys] as Input[]
438
- const keyOptions = Object.assign({
439
- repeat: false
440
- }, options);
441
- (keys as Input[]).forEach(keyName => {
442
- this.boundKeys[keyName] = { actionName, options: keyOptions, parameters }
443
- })
444
- }
445
-
446
445
  private applyKeyDown(name: string) {
447
446
  const code = inverseKeyCodeTable[name]
448
447
  const e: any = new Event('keydown')
@@ -532,65 +531,23 @@ export class KeyboardControls extends Directive {
532
531
  }
533
532
 
534
533
  /**
535
- * From the name of the entry, we retrieve the control information
536
- *
537
- * ```ts
538
- * import { Input, inject, KeyboardControls } from '@rpgjs/client'
539
- *
540
- * const controls = inject(KeyboardControls)
541
- * controls.getControl(Input.Enter)
542
-
543
- * if (control) {
544
- * console.log(control.actionName) // action
545
- * }
546
- * ```
547
- * @title Get Control
548
- * @method getControl(inputName)
549
- * @param {string} inputName
550
- * @returns { { actionName: string, options: any } | undefined }
551
- * @memberof KeyboardControls
552
- */
553
- getControl(inputName: string): BoundKey | undefined {
554
- return this.boundKeys[inputName]
555
- }
556
-
557
- /**
558
- * Returns all controls
559
- *
560
- * @method getControls()
561
- * @since 4.2.0
562
- * @returns { { [key: string]: BoundKey } }
563
- * @memberof KeyboardControls
564
- */
565
- getControls(): { [key: string]: BoundKey } {
566
- return this.boundKeys
567
- }
568
-
569
- /**
570
- * Triggers an input according to the name of the control
571
- *
572
- * ```ts
573
- * import { Control, inject, KeyboardControls } from '@rpgjs/client'
534
+ * Apply a control action programmatically
535
+ * Triggers keyboard events to simulate key presses
574
536
  *
575
- * const controls = inject(KeyboardControls)
576
- * controls.applyControl(Control.Action)
577
- * ```
537
+ * @param controlName - Name of the control
538
+ * @param isDown - Whether the key is pressed (true) or released (false)
539
+ * @returns Promise that resolves when the action is complete
540
+ * @example
541
+ * ```ts
542
+ * // Press a key
543
+ * await keyboardControls.applyControl('action', true);
578
544
  *
579
- * You can put a second parameter or indicate on whether the key is pressed or released
545
+ * // Release a key
546
+ * await keyboardControls.applyControl('action', false);
580
547
  *
581
- * ```ts
582
- * import { Control, inject, KeyboardControls } from '@rpgjs/client'
583
- *
584
- * const controls = inject(KeyboardControls)
585
- * controls.applyControl(Control.Up, true) // keydown
586
- * controls.applyControl(Control.Up, false) // keyup
548
+ * // Press and release (default)
549
+ * await keyboardControls.applyControl('action');
587
550
  * ```
588
- * @title Apply Control
589
- * @method applyControl(controlName,isDown)
590
- * @param {string} controlName
591
- * @param {boolean} [isDown]
592
- * @returns {Promise<void>}
593
- * @memberof KeyboardControls
594
551
  */
595
552
  async applyControl(controlName: string | number, isDown?: boolean | undefined): Promise<void> {
596
553
  const control = this._controlsOptions[controlName]
@@ -609,314 +566,12 @@ export class KeyboardControls extends Directive {
609
566
  }
610
567
 
611
568
  /**
612
- * Stop listening to the inputs. Pressing a key won't do anything
613
- *
614
- * @title Stop Inputs
615
- * @method stopInputs()
616
- * @returns {void}
617
- * @memberof KeyboardControls
618
- */
619
- stopInputs() {
620
- this.stop = true
621
- }
622
-
623
- /**
624
- * Listen to the inputs again
625
- *
626
- * @title Listen Inputs
627
- * @method listenInputs()
628
- * @returns {void}
629
- * @memberof KeyboardControls
569
+ * Resume listening to inputs after stopInputs() was called
570
+ * Also resets keyboard state
630
571
  */
631
572
  listenInputs() {
632
- this.stop = false
573
+ super.listenInputs();
633
574
  this.keyState = {}
634
575
  }
635
576
 
636
- /**
637
- * Assign custom inputs to the scene
638
- *
639
- * The object is the following:
640
- *
641
- * * the key of the object is the name of the control. Either it is existing controls (Up, Dow, Left, Right, Action, Back) or customized controls
642
- * * The value is an object representing control information:
643
- * * repeat {boolean} The key can be held down to repeat the action. (false by default)
644
- * * bind {string | string[]} To which key is linked the control
645
- * * method {Function} Function to be triggered. If you do not set this property, the name of the control is sent directly to the server.
646
- * * delay {object|number} (since v3.2.0) Indicates how long (in milliseconds) the player can press the key again to perform the action
647
- * * delay.duration
648
- * * delay.otherControls {string | string[]} Indicates the other controls that will also have the delay at the same time
649
- *
650
- * ```ts
651
- * import { Control, Input, inject, KeyboardControls } from '@rpgjs/client'
652
- *
653
- * const controls = inject(KeyboardControls)
654
- * controls.setInputs({
655
- [Control.Up]: {
656
- repeat: true,
657
- bind: Input.Up
658
- },
659
- [Control.Down]: {
660
- repeat: true,
661
- bind: Input.Down
662
- },
663
- [Control.Right]: {
664
- repeat: true,
665
- bind: Input.Right
666
- },
667
- [Control.Left]: {
668
- repeat: true,
669
- bind: Input.Left
670
- },
671
- [Control.Action]: {
672
- bind: [Input.Space, Input.Enter]
673
- },
674
- [Control.Back]: {
675
- bind: Input.Escape
676
- },
677
-
678
- // The myscustom1 control is sent to the server when the A key is pressed.
679
- mycustom1: {
680
- bind: Input.A
681
- },
682
-
683
- // the myAction method is executed when the B key is pressed
684
- mycustom2: {
685
- bind: Input.B,
686
- method({ actionName }) {
687
- console.log('cool', actionName)
688
- }
689
- },
690
-
691
- // The player can redo the action after 400ms
692
- mycustom3: {
693
- bind: Input.C,
694
- delay: 400 // ms
695
- },
696
-
697
- // The player can redo the action (mycustom4) and the directions after 400ms
698
- mycustom4: {
699
- bind: Input.C,
700
- delay: {
701
- duration: 400,
702
- otherControls: [Control.Up, Control.Down, Control.Left, Control.Right]
703
- }
704
- }
705
- })
706
- *
707
- * ```
708
- * @enum {string} Control
709
- *
710
- * Control.Up | up
711
- * Control.Down | down
712
- * Control.Left | left
713
- * Control.Right | right
714
- * Control.Action | action
715
- * Control.Back | back
716
- *
717
- * @enum {string} Mouse Event
718
- *
719
- * click | Click
720
- * dblclick | Double Click
721
- * mousedown | Mouse Down
722
- * mouseup | Mouse Up
723
- * mouseover | Mouse Over
724
- * mousemove | Mouse Move
725
- * mouseout | Mouse Out
726
- * contextmenu | Context Menu
727
- *
728
- *
729
- * @enum {string} Input
730
- *
731
- * break | Pause
732
- * backspace | Backspace / Delete
733
- * tab | Tab
734
- * clear | Clear
735
- * enter | Enter
736
- * shift | Shift
737
- * ctrl | Control
738
- * alt | Alt
739
- * pause/break | Pause / Break
740
- * caps lock | Caps Lock
741
- * escape | Escape
742
- * conversion | Conversion
743
- * non-conversion | Non-conversion
744
- * space | Space
745
- * page up | Page Up
746
- * page down | Page Down
747
- * end | End
748
- * home | Home
749
- * left | Left Arrow
750
- * up | Up Arrow
751
- * right | Right Arrow
752
- * down | Down Arrow
753
- * select | Select
754
- * print | Print
755
- * execute | Execute
756
- * Print Screen | Print Screen
757
- * insert | Insert
758
- * delete | Delete
759
- * n0 | 0
760
- * n1 | 1
761
- * n2 | 2
762
- * n3 | 3
763
- * n4 | 4
764
- * n5 | 5
765
- * n6 | 6
766
- * n7 | 7
767
- * n8 | 8
768
- * n9 | 9
769
- * : | Colon
770
- * semicolon (firefox), equals | Semicolon (Firefox), Equals
771
- * < | Less Than
772
- * equals (firefox) | Equals (Firefox)
773
- * ß | Eszett
774
- * @ | At
775
- * a | A
776
- * b | B
777
- * c | C
778
- * d | D
779
- * e | E
780
- * f | F
781
- * g | G
782
- * h | H
783
- * i | I
784
- * j | J
785
- * k | K
786
- * l | L
787
- * m | M
788
- * n | N
789
- * o | O
790
- * p | P
791
- * q | Q
792
- * r | R
793
- * s | S
794
- * t | T
795
- * u | U
796
- * v | V
797
- * w | W
798
- * x | X
799
- * y | Y
800
- * z | Z
801
- * Windows Key / Left ⌘ / Chromebook Search key | Windows Key / Left Command ⌘ / Chromebook Search Key
802
- * right window key | Right Windows Key
803
- * Windows Menu / Right ⌘ | Windows Menu / Right Command ⌘
804
- * numpad 0 | Numpad 0
805
- * numpad 1 | Numpad 1
806
- * numpad 2 | Numpad 2
807
- * numpad 3 | Numpad 3
808
- * numpad 4 | Numpad 4
809
- * numpad 5 | Numpad 5
810
- * numpad 6 | Numpad 6
811
- * numpad 7 | Numpad 7
812
- * numpad 8 | Numpad 8
813
- * numpad 9 | Numpad 9
814
- * multiply | Multiply
815
- * add | Add
816
- * numpad period (firefox) | Numpad Period (Firefox)
817
- * subtract | Subtract
818
- * decimal point | Decimal Point
819
- * divide | Divide
820
- * f1 | F1
821
- * f2 | F2
822
- * f3 | F3
823
- * f4 | F4
824
- * f5 | F5
825
- * f6 | F6
826
- * f7 | F7
827
- * f8 | F8
828
- * f9 | F9
829
- * f10 | F10
830
- * f11 | F11
831
- * f12 | F12
832
- * f13 | F13
833
- * f14 | F14
834
- * f15 | F15
835
- * f16 | F16
836
- * f17 | F17
837
- * f18 | F18
838
- * f19 | F19
839
- * f20 | F20
840
- * f21 | F21
841
- * f22 | F22
842
- * f23 | F23
843
- * f24 | F24
844
- * num lock | Num Lock
845
- * scroll lock | Scroll Lock
846
- * ^ | Caret
847
- * ! | Exclamation Point
848
- * # | Hash
849
- * $ | Dollar Sign
850
- * ù | Grave Accent U
851
- * page backward | Page Backward
852
- * page forward | Page Forward
853
- * closing paren (AZERTY) | Closing Parenthesis (AZERTY)
854
- * * | Asterisk
855
- * ~ + * key | Tilde + Asterisk Key
856
- * minus (firefox), mute/unmute | Minus (Firefox), Mute/Unmute
857
- * decrease volume level | Decrease Volume Level
858
- * increase volume level | Increase Volume Level
859
- * next | Next
860
- * previous | Previous
861
- * stop | Stop
862
- * play/pause | Play/Pause
863
- * e-mail | Email
864
- * mute/unmute (firefox) | Mute/Unmute (Firefox)
865
- * decrease volume level (firefox) | Decrease Volume Level (Firefox)
866
- * increase volume level (firefox) | Increase Volume Level (Firefox)
867
- * semi-colon / ñ | Semicolon / ñ
868
- * equal sign | Equal Sign
869
- * comma | Comma
870
- * dash | Dash
871
- * period | Period
872
- * forward slash / ç | Forward Slash / ç
873
- * grave accent / ñ / æ | Grave Accent / ñ / æ
874
- * ?, / or ° | ?, / or °
875
- * numpad period (chrome) | Numpad Period (Chrome)
876
- * open bracket | Open Bracket
877
- * back slash | Backslash
878
- * close bracket / å | Close Bracket / å
879
- * single quote / ø | Single Quote / ø
880
- * \` | Backtick
881
- * left or right ⌘ key (firefox) | Left or Right Command Key (Firefox)
882
- * altgr | AltGr
883
- * < /git > | < /git >
884
- * GNOME Compose Key | GNOME Compose Key
885
- * ç | ç
886
- * XF86Forward | XF86Forward
887
- * XF86Back | XF86Back
888
- * alphanumeric | Alphanumeric
889
- * hiragana/katakana | Hiragana/Katakana
890
- * half-width/full-width | Half-Width/Full-Width
891
- * kanji | Kanji
892
- * toggle touchpad | Toggle Touchpad
893
- *
894
- * @title Set Inputs
895
- * @method setInputs(inputs)
896
- * @param {object} inputs
897
- * @memberof KeyboardControls
898
- */
899
- setInputs(inputs: Controls) {
900
- if (!inputs) return
901
- this.boundKeys = {}
902
- let inputsTransformed: any = {}
903
- for (let control in inputs) {
904
- const option = inputs[control]
905
- const { bind } = option
906
- let inputsKey: any = bind
907
- if (!Array.isArray(inputsKey)) {
908
- inputsKey = [bind]
909
- }
910
- for (let input of inputsKey) {
911
- this.bindKey(input, control, option)
912
- }
913
- }
914
- this._controlsOptions = inputs
915
- }
916
-
917
- get options(): Controls {
918
- return this._controlsOptions
919
- }
920
577
  }
921
-
922
- registerDirective('controls', KeyboardControls)
@@ -30,9 +30,17 @@ export class Scheduler extends Directive {
30
30
  onUpdate(props: any) { }
31
31
 
32
32
  nextTick(timestamp: number) {
33
- this.lastTimestamp = this.lastTimestamp || this.timestamp // first
34
- this.deltaTime = Utils.preciseNow() - this.timestamp
35
- this.timestamp = timestamp
33
+ const now = (typeof timestamp === "number" && timestamp > 0)
34
+ ? timestamp
35
+ : Utils.preciseNow()
36
+ if (this.lastTimestamp === 0) {
37
+ this.lastTimestamp = now
38
+ this.deltaTime = 0
39
+ } else {
40
+ this.deltaTime = now - this.lastTimestamp
41
+ this.lastTimestamp = now
42
+ }
43
+ this.timestamp = now
36
44
  this.tick.set({
37
45
  timestamp: this.timestamp,
38
46
  deltaTime: this.deltaTime,
@@ -98,4 +106,4 @@ export class Scheduler extends Directive {
98
106
  }
99
107
  }
100
108
 
101
- registerDirective('tick', Scheduler)
109
+ registerDirective('tick', Scheduler)