@dcl/ecs 7.4.22-9129040248.commit-e3dda7a → 7.4.22-9160893926.commit-529e3f0

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.
@@ -9,6 +9,7 @@ import { createInputSystem } from './../../engine/input';
9
9
  import { createRaycastSystem } from '../../systems/raycast';
10
10
  import { createVideoEventsSystem } from '../../systems/videoEvents';
11
11
  import { createTweenSystem } from '../../systems/tween';
12
+ import { pointerEventColliderChecker } from '../../systems/pointer-event-collider-checker';
12
13
  /**
13
14
  * @public
14
15
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -51,6 +52,10 @@ export const videoEventsSystem = /* @__PURE__ */ createVideoEventsSystem(engine)
51
52
  * Register callback functions to a particular entity on video events.
52
53
  */
53
54
  export const tweenSystem = createTweenSystem(engine);
55
+ /**
56
+ * Adds pointer event collider system only in DEV env
57
+ */
58
+ pointerEventColliderChecker(engine);
54
59
  /**
55
60
  * @public
56
61
  * Runs an async function
@@ -55,7 +55,6 @@ export function createPointerEventsSystem(engine, inputSystem) {
55
55
  }
56
56
  event.delete(type);
57
57
  }
58
- // @internal
59
58
  engine.addSystem(function EventSystem() {
60
59
  for (const [entity, event] of eventsMap) {
61
60
  if (engine.getEntityState(entity) === EntityState.Removed) {
@@ -0,0 +1,8 @@
1
+ import { IEngine } from '../engine/types';
2
+ /**
3
+ * It checks all the entities that has a PointerEvent and check if it has a collider.
4
+ * *
5
+ * @public
6
+ * @params engine
7
+ */
8
+ export declare function pointerEventColliderChecker(engine: IEngine): void;
@@ -0,0 +1,45 @@
1
+ /* istanbul ignore file */
2
+ import * as components from '../components';
3
+ /**
4
+ * It checks all the entities that has a PointerEvent and check if it has a collider.
5
+ * *
6
+ * @public
7
+ * @params engine
8
+ */
9
+ export function pointerEventColliderChecker(engine) {
10
+ const PointerEvents = components.PointerEvents(engine);
11
+ const MeshCollider = components.MeshCollider(engine);
12
+ const GltfContainer = components.GltfContainer(engine);
13
+ const UiTransform = components.UiTransform(engine);
14
+ const alreadyShownlog = new Set();
15
+ let timer = 0;
16
+ function systemChecker(dt) {
17
+ timer += dt;
18
+ if (timer <= 10) {
19
+ return;
20
+ }
21
+ timer = 0;
22
+ for (const [entity] of engine.getEntitiesWith(PointerEvents)) {
23
+ if (alreadyShownlog.has(entity))
24
+ continue;
25
+ // Maybe the collider is inside the GLTFContainer. Ignore it
26
+ if (GltfContainer.has(entity))
27
+ continue;
28
+ // UI handles the pointer's in a diff way.
29
+ if (UiTransform.has(entity))
30
+ continue;
31
+ // check for Mesh Pointer Collision Layer
32
+ const mesh = MeshCollider.getOrNull(entity);
33
+ if (mesh) {
34
+ if (mesh.collisionMask === undefined || mesh.collisionMask & 1 /* components.ColliderLayer.CL_POINTER */) {
35
+ continue;
36
+ }
37
+ }
38
+ alreadyShownlog.add(entity);
39
+ console.log(`⚠️ Missing MeshCollider component on entity ${entity}. Add a MeshCollider to the entity so it can be clickeable by the player.
40
+ See https://docs.decentraland.org/creator/development-guide/sdk7/colliders/#pointer-blocking`);
41
+ }
42
+ }
43
+ engine.removeSystem(systemChecker);
44
+ engine.addSystem(systemChecker);
45
+ }
@@ -12,6 +12,7 @@ const input_1 = require("./../../engine/input");
12
12
  const raycast_1 = require("../../systems/raycast");
13
13
  const videoEvents_1 = require("../../systems/videoEvents");
14
14
  const tween_1 = require("../../systems/tween");
15
+ const pointer_event_collider_checker_1 = require("../../systems/pointer-event-collider-checker");
15
16
  /**
16
17
  * @public
17
18
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -54,6 +55,10 @@ exports.videoEventsSystem = (0, videoEvents_1.createVideoEventsSystem)(exports.e
54
55
  * Register callback functions to a particular entity on video events.
55
56
  */
56
57
  exports.tweenSystem = (0, tween_1.createTweenSystem)(exports.engine);
58
+ /**
59
+ * Adds pointer event collider system only in DEV env
60
+ */
61
+ (0, pointer_event_collider_checker_1.pointerEventColliderChecker)(exports.engine);
57
62
  /**
58
63
  * @public
59
64
  * Runs an async function
@@ -81,7 +81,6 @@ function createPointerEventsSystem(engine, inputSystem) {
81
81
  }
82
82
  event.delete(type);
83
83
  }
84
- // @internal
85
84
  engine.addSystem(function EventSystem() {
86
85
  for (const [entity, event] of eventsMap) {
87
86
  if (engine.getEntityState(entity) === entity_1.EntityState.Removed) {
@@ -0,0 +1,8 @@
1
+ import { IEngine } from '../engine/types';
2
+ /**
3
+ * It checks all the entities that has a PointerEvent and check if it has a collider.
4
+ * *
5
+ * @public
6
+ * @params engine
7
+ */
8
+ export declare function pointerEventColliderChecker(engine: IEngine): void;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.pointerEventColliderChecker = void 0;
27
+ /* istanbul ignore file */
28
+ const components = __importStar(require("../components"));
29
+ /**
30
+ * It checks all the entities that has a PointerEvent and check if it has a collider.
31
+ * *
32
+ * @public
33
+ * @params engine
34
+ */
35
+ function pointerEventColliderChecker(engine) {
36
+ const PointerEvents = components.PointerEvents(engine);
37
+ const MeshCollider = components.MeshCollider(engine);
38
+ const GltfContainer = components.GltfContainer(engine);
39
+ const UiTransform = components.UiTransform(engine);
40
+ const alreadyShownlog = new Set();
41
+ let timer = 0;
42
+ function systemChecker(dt) {
43
+ timer += dt;
44
+ if (timer <= 10) {
45
+ return;
46
+ }
47
+ timer = 0;
48
+ for (const [entity] of engine.getEntitiesWith(PointerEvents)) {
49
+ if (alreadyShownlog.has(entity))
50
+ continue;
51
+ // Maybe the collider is inside the GLTFContainer. Ignore it
52
+ if (GltfContainer.has(entity))
53
+ continue;
54
+ // UI handles the pointer's in a diff way.
55
+ if (UiTransform.has(entity))
56
+ continue;
57
+ // check for Mesh Pointer Collision Layer
58
+ const mesh = MeshCollider.getOrNull(entity);
59
+ if (mesh) {
60
+ if (mesh.collisionMask === undefined || mesh.collisionMask & 1 /* components.ColliderLayer.CL_POINTER */) {
61
+ continue;
62
+ }
63
+ }
64
+ alreadyShownlog.add(entity);
65
+ console.log(`⚠️ Missing MeshCollider component on entity ${entity}. Add a MeshCollider to the entity so it can be clickeable by the player.
66
+ See https://docs.decentraland.org/creator/development-guide/sdk7/colliders/#pointer-blocking`);
67
+ }
68
+ }
69
+ engine.removeSystem(systemChecker);
70
+ engine.addSystem(systemChecker);
71
+ }
72
+ exports.pointerEventColliderChecker = pointerEventColliderChecker;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dcl/ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.4.22-9129040248.commit-e3dda7a",
4
+ "version": "7.4.22-9160893926.commit-529e3f0",
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": "e3dda7a1f36ae94c353ebe89012353b9e0d7c87b"
36
+ "commit": "529e3f0ff5259e0ce2c9dd13d308194cf44d1507"
37
37
  }