@dcl/playground-assets 7.0.6-4193722527.commit-97eac4a → 7.0.6-4195929129.commit-862da77

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.
package/dist/alpha.d.ts CHANGED
@@ -1762,7 +1762,7 @@ export declare type IInputSystem = {
1762
1762
  * @param entity - the entity to query, ignore for global
1763
1763
  * @returns boolean
1764
1764
  */
1765
- isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity: Entity) => boolean;
1765
+ isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity?: Entity) => boolean;
1766
1766
  /**
1767
1767
  * @public
1768
1768
  * Check if an input action is currently being pressed.
package/dist/beta.d.ts CHANGED
@@ -1758,7 +1758,7 @@ export declare type IInputSystem = {
1758
1758
  * @param entity - the entity to query, ignore for global
1759
1759
  * @returns boolean
1760
1760
  */
1761
- isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity: Entity) => boolean;
1761
+ isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity?: Entity) => boolean;
1762
1762
  /**
1763
1763
  * @public
1764
1764
  * Check if an input action is currently being pressed.
@@ -1758,7 +1758,7 @@ export declare type IInputSystem = {
1758
1758
  * @param entity - the entity to query, ignore for global
1759
1759
  * @returns boolean
1760
1760
  */
1761
- isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity: Entity) => boolean;
1761
+ isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity?: Entity) => boolean;
1762
1762
  /**
1763
1763
  * @public
1764
1764
  * Check if an input action is currently being pressed.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function (exports, communicationsController, EthereumController, EngineApi) {
1
+ (function (exports, EngineApi, communicationsController, EthereumController) {
2
2
  'use strict';
3
3
 
4
4
  function _interopNamespaceDefault(e) {
@@ -15439,7 +15439,8 @@
15439
15439
  const globalState = {
15440
15440
  previousFrameMaxTimestamp: 0,
15441
15441
  currentFrameMaxTimestamp: 0,
15442
- buttonState: new Map()
15442
+ buttonState: new Map(),
15443
+ thisFrameCommands: []
15443
15444
  };
15444
15445
  function findLastAction(pointerEventType, inputAction, entity) {
15445
15446
  const ascendingTimestampIterator = PointerEventsResult.get(entity);
@@ -15461,6 +15462,9 @@
15461
15462
  // first store the previous' frame timestamp
15462
15463
  let maxTimestamp = globalState.currentFrameMaxTimestamp;
15463
15464
  globalState.previousFrameMaxTimestamp = maxTimestamp;
15465
+ if (globalState.thisFrameCommands.length) {
15466
+ globalState.thisFrameCommands = [];
15467
+ }
15464
15468
  // then iterate over all new commands
15465
15469
  for (const [, commands] of engine.getEntitiesWith(PointerEventsResult)) {
15466
15470
  // TODO: adapt the gset component to have a cached "reversed" option by default
@@ -15470,6 +15474,9 @@
15470
15474
  if (command.timestamp > maxTimestamp) {
15471
15475
  maxTimestamp = command.timestamp;
15472
15476
  }
15477
+ if (command.timestamp > globalState.previousFrameMaxTimestamp) {
15478
+ globalState.thisFrameCommands.push(command);
15479
+ }
15473
15480
  if (command.state === 0 /* PointerEventType.PET_UP */ || command.state === 1 /* PointerEventType.PET_DOWN */) {
15474
15481
  const prevCommand = globalState.buttonState.get(command.button);
15475
15482
  if (!prevCommand || command.timestamp > prevCommand.timestamp) {
@@ -15561,8 +15568,18 @@
15561
15568
  }
15562
15569
  // returns true if the provided last action was triggered in the last frame
15563
15570
  function isTriggered(inputAction, pointerEventType, entity) {
15564
- const command = findLastAction(pointerEventType, inputAction, entity);
15565
- return (command && timestampIsCurrentFrame(command.timestamp)) || false;
15571
+ if (entity) {
15572
+ const command = findLastAction(pointerEventType, inputAction, entity);
15573
+ return (command && timestampIsCurrentFrame(command.timestamp)) || false;
15574
+ }
15575
+ else {
15576
+ for (const command of globalState.thisFrameCommands) {
15577
+ if (command.button === inputAction && command.state === pointerEventType) {
15578
+ return true;
15579
+ }
15580
+ }
15581
+ return false;
15582
+ }
15566
15583
  }
15567
15584
  // returns the global state of the input. This global state is updated from the system
15568
15585
  function isPressed(inputAction) {
@@ -42521,7 +42538,7 @@
42521
42538
  }
42522
42539
  }
42523
42540
 
42524
- let subscribeFunction = async () => ({});
42541
+ let subscribeFunction = EngineApi.subscribe;
42525
42542
  function createSubscriber(eventName) {
42526
42543
  return () => {
42527
42544
  subscribeFunction({ eventId: eventName }).catch(console.error);
@@ -42590,6 +42607,10 @@
42590
42607
  onPlayerClickedObservable.notifyObservers(data);
42591
42608
  break;
42592
42609
  }
42610
+ case 'comms': {
42611
+ onCommsMessage.notifyObservers(data);
42612
+ break;
42613
+ }
42593
42614
  }
42594
42615
  }
42595
42616
  }
@@ -42615,10 +42636,6 @@
42615
42636
  emit(message, payload) {
42616
42637
  const messageToSend = JSON.stringify({ message, payload });
42617
42638
  this.sendRaw(messageToSend);
42618
- onCommsMessage.notifyObservers({
42619
- message: messageToSend,
42620
- sender: 'self'
42621
- });
42622
42639
  }
42623
42640
  flush() {
42624
42641
  if (this.messageQueue.length === 0)
@@ -42703,7 +42720,6 @@
42703
42720
 
42704
42721
  const rendererTransport = createRendererTransport({ crdtSendToRenderer: EngineApi.crdtSendToRenderer });
42705
42722
  engine.addTransport(rendererTransport);
42706
- setSubscribeFunction(EngineApi.subscribe);
42707
42723
  async function onUpdate(deltaTime) {
42708
42724
  await engine.update(deltaTime);
42709
42725
  await pollEvents(EngineApi.sendBatch);
@@ -42852,4 +42868,4 @@
42852
42868
  exports.pollEvents = pollEvents;
42853
42869
  exports.setSubscribeFunction = setSubscribeFunction;
42854
42870
 
42855
- })(this.globalThis = this.globalThis || {}, communicationsController, EthereumController, EngineApi);
42871
+ })(this.globalThis = this.globalThis || {}, EngineApi, communicationsController, EthereumController);