@dcl/ecs 7.3.30-6983622970.commit-d4f4c06 → 7.3.30-7039895622.commit-39f9862

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.
@@ -46,15 +46,21 @@ export function createRaycastSystem(engine) {
46
46
  targetEntity: options.targetEntity || 0
47
47
  }
48
48
  });
49
+ const nextTickRaycasts = [];
49
50
  function registerRaycastWithCallback(entity, raycastValue, callback) {
50
- const raycast = Raycast.getOrCreateMutable(entity);
51
- raycast.maxDistance = raycastValue.maxDistance;
52
- raycast.originOffset = raycastValue.originOffset;
53
- raycast.collisionMask = raycastValue.collisionMask;
54
- raycast.direction = raycastValue.directionRawValue;
55
- raycast.continuous = raycastValue.continuous;
56
- raycast.queryType = raycastValue.queryType;
57
- entitiesCallbackResultMap.set(entity, { callback: callback });
51
+ // Raycasts registration is delayed 1 frame to avoid same-frame raycast
52
+ // removal/adding (the client never receives the removal on those situations)
53
+ const onNextTick = () => {
54
+ const raycast = Raycast.createOrReplace(entity);
55
+ raycast.maxDistance = raycastValue.maxDistance;
56
+ raycast.originOffset = raycastValue.originOffset;
57
+ raycast.collisionMask = raycastValue.collisionMask;
58
+ raycast.direction = raycastValue.directionRawValue;
59
+ raycast.continuous = raycastValue.continuous;
60
+ raycast.queryType = raycastValue.queryType;
61
+ entitiesCallbackResultMap.set(entity, { callback: callback });
62
+ };
63
+ nextTickRaycasts.push(onNextTick);
58
64
  }
59
65
  function removeRaycast(entity) {
60
66
  Raycast.deleteFrom(entity);
@@ -63,6 +69,10 @@ export function createRaycastSystem(engine) {
63
69
  }
64
70
  // @internal
65
71
  engine.addSystem(function EventSystem() {
72
+ for (const addMissingRaycast of nextTickRaycasts) {
73
+ addMissingRaycast();
74
+ }
75
+ nextTickRaycasts.length = 0;
66
76
  for (const [entity, data] of entitiesCallbackResultMap) {
67
77
  const raycast = Raycast.getOrNull(entity);
68
78
  if (engine.getEntityState(entity) === EntityState.Removed || !raycast) {
@@ -72,15 +72,21 @@ function createRaycastSystem(engine) {
72
72
  targetEntity: options.targetEntity || 0
73
73
  }
74
74
  });
75
+ const nextTickRaycasts = [];
75
76
  function registerRaycastWithCallback(entity, raycastValue, callback) {
76
- const raycast = Raycast.getOrCreateMutable(entity);
77
- raycast.maxDistance = raycastValue.maxDistance;
78
- raycast.originOffset = raycastValue.originOffset;
79
- raycast.collisionMask = raycastValue.collisionMask;
80
- raycast.direction = raycastValue.directionRawValue;
81
- raycast.continuous = raycastValue.continuous;
82
- raycast.queryType = raycastValue.queryType;
83
- entitiesCallbackResultMap.set(entity, { callback: callback });
77
+ // Raycasts registration is delayed 1 frame to avoid same-frame raycast
78
+ // removal/adding (the client never receives the removal on those situations)
79
+ const onNextTick = () => {
80
+ const raycast = Raycast.createOrReplace(entity);
81
+ raycast.maxDistance = raycastValue.maxDistance;
82
+ raycast.originOffset = raycastValue.originOffset;
83
+ raycast.collisionMask = raycastValue.collisionMask;
84
+ raycast.direction = raycastValue.directionRawValue;
85
+ raycast.continuous = raycastValue.continuous;
86
+ raycast.queryType = raycastValue.queryType;
87
+ entitiesCallbackResultMap.set(entity, { callback: callback });
88
+ };
89
+ nextTickRaycasts.push(onNextTick);
84
90
  }
85
91
  function removeRaycast(entity) {
86
92
  Raycast.deleteFrom(entity);
@@ -89,6 +95,10 @@ function createRaycastSystem(engine) {
89
95
  }
90
96
  // @internal
91
97
  engine.addSystem(function EventSystem() {
98
+ for (const addMissingRaycast of nextTickRaycasts) {
99
+ addMissingRaycast();
100
+ }
101
+ nextTickRaycasts.length = 0;
92
102
  for (const [entity, data] of entitiesCallbackResultMap) {
93
103
  const raycast = Raycast.getOrNull(entity);
94
104
  if (engine.getEntityState(entity) === entity_1.EntityState.Removed || !raycast) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.3.30-6983622970.commit-d4f4c06",
4
+ "version": "7.3.30-7039895622.commit-39f9862",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/ecs/issues",
7
7
  "files": [
@@ -33,5 +33,5 @@
33
33
  },
34
34
  "types": "./dist/index.d.ts",
35
35
  "typings": "./dist/index.d.ts",
36
- "commit": "d4f4c066ca68ea6373531141f7aad7d4be96c682"
36
+ "commit": "39f98623c92060bfdd133d993bd03bda5f537bcf"
37
37
  }