@dcl-regenesislabs/opendcl 0.2.1-26238928766.commit-28648d7 → 0.2.1-26502482653.commit-5089b10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl-regenesislabs/opendcl",
3
- "version": "0.2.1-26238928766.commit-28648d7",
3
+ "version": "0.2.1-26502482653.commit-5089b10",
4
4
  "description": "AI coding assistant for Decentraland SDK7 scene development",
5
5
  "type": "module",
6
6
  "bin": {
@@ -71,5 +71,5 @@
71
71
  "prompts/",
72
72
  "context/"
73
73
  ],
74
- "commit": "28648d736e3cd0f11630168013ee7ca6075abb45"
74
+ "commit": "5089b101116c01ab32e68795fd6c020d0d509efe"
75
75
  }
@@ -9,7 +9,9 @@ import {
9
9
  Material,
10
10
  GltfContainer,
11
11
  Name,
12
- pointerEventsSystem,
12
+ PointerEvents,
13
+ PointerEventType,
14
+ inputSystem,
13
15
  InputAction,
14
16
  ColliderLayer,
15
17
  } from '@dcl/sdk/ecs'
@@ -31,6 +33,22 @@ export const SKIP_ENTITIES = new Set<Entity>()
31
33
  /** Entity names to skip (case-insensitive). Add names here to prevent selection. */
32
34
  const SKIP_NAMES = new Set(['ground', 'floor'])
33
35
 
36
+ type PointerEventsValue = ReturnType<typeof PointerEvents.get>
37
+ const originalPointerEvents = new Map<Entity, PointerEventsValue | null>()
38
+
39
+ function addEditorHover(entity: Entity, name: string) {
40
+ const existing = PointerEvents.getMutableOrNull(entity)
41
+ const entry = {
42
+ eventType: PointerEventType.PET_DOWN,
43
+ eventInfo: { button: InputAction.IA_POINTER, hoverText: `Select ${name}`, maxDistance: 100 },
44
+ }
45
+ if (existing) {
46
+ existing.pointerEvents.push(entry)
47
+ } else {
48
+ PointerEvents.create(entity, { pointerEvents: [entry] })
49
+ }
50
+ }
51
+
34
52
  function getEntityName(entity: Entity): string {
35
53
  if (Name.has(entity)) {
36
54
  return Name.get(entity).value
@@ -142,16 +160,9 @@ export function registerEntity(entity: Entity) {
142
160
 
143
161
  selectableInfoMap.set(entity, info)
144
162
 
145
- pointerEventsSystem.onPointerDown(
146
- {
147
- entity,
148
- opts: { button: InputAction.IA_POINTER, hoverText: `Select ${name}`, maxDistance: 100 },
149
- },
150
- () => {
151
- if (!state.editorActive || state.isDragging || gizmoClickConsumed) return
152
- selectEntity(entity)
153
- }
154
- )
163
+ const snapshot = PointerEvents.getOrNull(entity)
164
+ originalPointerEvents.set(entity, snapshot ? structuredClone(snapshot) : null)
165
+ addEditorHover(entity, name)
155
166
  }
156
167
 
157
168
  export function discoverySystem() {
@@ -165,22 +176,35 @@ export function discoverySystem() {
165
176
  }
166
177
  }
167
178
 
168
- /** Remove pointer events from all discovered entities (hides hover text). */
169
- export function removeAllPointerEvents() {
179
+ /** Polls pointer-down input per selectable entity. Runs only while editor is
180
+ * active so scene click handlers behave normally otherwise. */
181
+ export function editorClickSystem() {
182
+ if (!state.editorActive || state.isDragging || gizmoClickConsumed) return
170
183
  for (const [entity] of selectableInfoMap) {
171
- pointerEventsSystem.removeOnPointerDown(entity)
184
+ if (inputSystem.isTriggered(InputAction.IA_POINTER, PointerEventType.PET_DOWN, entity)) {
185
+ selectEntity(entity)
186
+ return
187
+ }
188
+ }
189
+ }
190
+
191
+ /** Restore each discovered entity's PointerEvents to the snapshot taken at
192
+ * registration time. Called on editor-off so the scene's own click handlers
193
+ * see their unmodified component again. */
194
+ export function removeAllPointerEvents() {
195
+ for (const [entity, original] of originalPointerEvents) {
196
+ if (original === null) {
197
+ PointerEvents.deleteFrom(entity)
198
+ } else {
199
+ PointerEvents.createOrReplace(entity, original)
200
+ }
172
201
  }
173
202
  }
174
203
 
175
- /** Re-add pointer events on all discovered entities. */
204
+ /** Re-add the editor's hover affordance to each registered entity, leaving
205
+ * any user-added entries intact. Inverse of removeAllPointerEvents. */
176
206
  export function restoreAllPointerEvents() {
177
207
  for (const [entity, info] of selectableInfoMap) {
178
- pointerEventsSystem.onPointerDown(
179
- { entity, opts: { button: InputAction.IA_POINTER, hoverText: `Select ${info.name}`, maxDistance: 100 } },
180
- () => {
181
- if (!state.editorActive || state.isDragging || gizmoClickConsumed) return
182
- selectEntity(entity)
183
- }
184
- )
208
+ addEditorHover(entity, info.name)
185
209
  }
186
210
  }
@@ -25,7 +25,7 @@ import { Vector3 } from '@dcl/sdk/math'
25
25
  import { state, editorEntities, gizmoClickConsumed, setToggleHandler } from './state'
26
26
  import { setupEditorUi } from './ui'
27
27
  import { createEditorCamera, createLockCamera, deactivateEditorCamera, editorCameraSystem } from './camera'
28
- import { SKIP_ENTITIES, discoverySystem, removeAllPointerEvents, restoreAllPointerEvents } from './discovery'
28
+ import { SKIP_ENTITIES, discoverySystem, editorClickSystem, removeAllPointerEvents, restoreAllPointerEvents } from './discovery'
29
29
  import { deselectEntity } from './selection'
30
30
  import { startDrag, startPlaneDrag, dragSystem } from './drag'
31
31
  import { gizmoFollowSystem, setStartDragHandler, setStartPlaneDragHandler } from './gizmo'
@@ -110,6 +110,7 @@ function setupClientEditor() {
110
110
 
111
111
  engine.addSystem(editorCameraSystem, 102)
112
112
  engine.addSystem(discoverySystem, 100)
113
+ engine.addSystem(editorClickSystem, 99)
113
114
  engine.addSystem(dragSystem)
114
115
  engine.addSystem(gizmoFollowSystem)
115
116
  engine.addSystem(modeToggleSystem)
@@ -1,4 +1,4 @@
1
- import { Entity, Transform, VisibilityComponent } from '@dcl/sdk/ecs'
1
+ import { Entity, Transform, VisibilityComponent, engine } from '@dcl/sdk/ecs'
2
2
  import { Color4, Quaternion } from '@dcl/sdk/math'
3
3
  import { isWeb } from '@dcl/sdk/platform'
4
4
  import ReactEcs, { ReactEcsRenderer, UiEntity, Label } from '@dcl/sdk/react-ecs'
@@ -7,7 +7,7 @@ import { toggleEditorCamera, focusSelectedEntity } from './camera'
7
7
  import { createGizmo } from './gizmo'
8
8
  import { undoCount, redoCount, undo, redo } from './history'
9
9
  import { selectEntity, deselectEntity } from './selection'
10
- import { state, selectableInfoMap, toggleEditorActive } from './state'
10
+ import { state, selectableInfoMap, toggleEditorActive, editorEntities } from './state'
11
11
 
12
12
  // ── Platform detection ──────────────────────────────────
13
13
 
@@ -693,5 +693,7 @@ function EditorUI() {
693
693
  }
694
694
 
695
695
  export function setupEditorUi() {
696
- ReactEcsRenderer.setUiRenderer(EditorUI, { virtualWidth: 1280, virtualHeight: 720 })
696
+ const uiEntity = engine.addEntity()
697
+ editorEntities.add(uiEntity)
698
+ ReactEcsRenderer.addUiRenderer(uiEntity, EditorUI, { virtualWidth: 1280, virtualHeight: 720 })
697
699
  }