@umicat/three-sdk 1.29.0 → 1.31.0

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.
@@ -359,6 +359,25 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
359
359
  selectionBox.visible = false;
360
360
  selectionBox.renderOrder = 998;
361
361
  selectionBox.material.depthTest = false;
362
+ /**
363
+ * ADR-052 — the outline shown when a CONTEXT MENU opens on a hidden or
364
+ * locked entity.
365
+ *
366
+ * Same look as the selection box on purpose: the question it answers is the
367
+ * same one ("which thing is this menu about?"), and inventing a second
368
+ * visual language for it would only make the answer harder to read. What it
369
+ * deliberately does NOT come with is the gizmo — showing you what you are
370
+ * acting on is not the same as handing back the drag handles that lock
371
+ * exists to take away.
372
+ *
373
+ * Its own helper rather than reusing `selectionBox`, so `applySelection`
374
+ * stays the single owner of that one and the two cannot fight over
375
+ * visibility.
376
+ */
377
+ const menuTargetBox = new THREE.BoxHelper(new THREE.Object3D(), 0xffd23f);
378
+ menuTargetBox.visible = false;
379
+ menuTargetBox.renderOrder = 998;
380
+ menuTargetBox.material.depthTest = false;
362
381
  // ADR-046 — multi-select (box-select + ⌘/Ctrl-click). `multiSelected` is
363
382
  // now the ONE authoritative source of truth for "what's selected" — the
364
383
  // single-select visuals above (`gizmo.attached`/`selectionBox`) are kept
@@ -539,6 +558,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
539
558
  // the ground-marquee regression: the claim there is "the ground did NOT
540
559
  // move AND both Parts got selected", and neither half is observable from
541
560
  // the host protocol alone (a drag that moves nothing posts nothing).
561
+ globalThis.__umicatMenuTargetVisible =
562
+ () => menuTargetBox.visible;
542
563
  globalThis.__umicatSelectedIds =
543
564
  () => [...multiSelected].map((o) => entityByObject.get(o)).filter((id) => !!id);
544
565
  globalThis.__umicatEntityWorldPos =
@@ -1149,6 +1170,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1149
1170
  moved = true;
1150
1171
  };
1151
1172
  const onPointerDown = (e) => {
1173
+ // Any new press ends the previous menu's business, including its outline.
1174
+ menuTargetBox.visible = false;
1152
1175
  // Right button — camera look-drag, a separate gesture channel entirely
1153
1176
  // from everything below. Hard-returns before touching any select/drag/
1154
1177
  // gizmo state, so a right-click can never be misread as the start of a
@@ -1393,6 +1416,10 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1393
1416
  return;
1394
1417
  }
1395
1418
  if (isInert(hit.entityId)) {
1419
+ // Outline it without selecting it. The menu needs to say what it is
1420
+ // about; the gizmo would undo the lock.
1421
+ menuTargetBox.setFromObject(hit.entityRoot);
1422
+ menuTargetBox.visible = true;
1396
1423
  window.parent.postMessage({ type: 'umicat:editor:contextMenu3d', entityId: hit.entityId, inert: true, clientX: e.clientX, clientY: e.clientY }, '*');
1397
1424
  return;
1398
1425
  }
@@ -1634,6 +1661,26 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1634
1661
  // host can push a partial update, and the grid is rebuilt on any change
1635
1662
  // because its cell size IS the step (the grid is the snap grid, not a
1636
1663
  // separate decoration).
1664
+ // ADR-052 — set the selection from outside the canvas. The entity list
1665
+ // needs it: clicking a row has to select in the viewport, and until now
1666
+ // every selection originated from a pointer event in here. Ids that are
1667
+ // not in the scene are skipped rather than failing the whole call — a
1668
+ // list can race a delete, and dropping one stale id is better than
1669
+ // dropping the user's whole selection.
1670
+ if (data.type === 'umicat:editor:selectEntities3d') {
1671
+ const ids = data.entityIds;
1672
+ if (!Array.isArray(ids))
1673
+ return;
1674
+ const objs = ids
1675
+ .map((id) => (typeof id === 'string' ? objectByEntity.get(id) : undefined))
1676
+ .filter((o) => !!o);
1677
+ // Deliberately NOT filtered by `isInert`: selecting a locked entity
1678
+ // FROM THE LIST is the whole point of the list — lock makes something
1679
+ // inert to the canvas, not invisible to the editor. The gizmo it gets
1680
+ // is reachable only because the user asked for it by name.
1681
+ applySelection(objs);
1682
+ return;
1683
+ }
1637
1684
  if (data.type === 'umicat:editor:setSnap3d') {
1638
1685
  const d = data;
1639
1686
  if (typeof d.enabled === 'boolean')
@@ -1842,6 +1889,20 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
1842
1889
  disposeMeshInPlace(object);
1843
1890
  object = swapEntityObject(object, fresh, m.entityId);
1844
1891
  }
1892
+ if (m.patch?.name !== undefined) {
1893
+ // ADR-052 — display name. Kept live as well as on disk because
1894
+ // `Object3D.name` is what game code and any future debug overlay read;
1895
+ // a rename that only landed on disk would be invisible until a rebuild,
1896
+ // which is indistinguishable from a control that does not work.
1897
+ const authored = sceneData?.entities.find((e) => e.id === m.entityId);
1898
+ if (authored) {
1899
+ if (m.patch.name)
1900
+ authored.name = m.patch.name;
1901
+ else
1902
+ delete authored.name;
1903
+ }
1904
+ object.name = m.patch.name || m.entityId;
1905
+ }
1845
1906
  if (m.patch?.editorHidden !== undefined || m.patch?.editorLocked !== undefined) {
1846
1907
  const authored = sceneData?.entities.find((e) => e.id === m.entityId);
1847
1908
  if (!authored)
@@ -2591,6 +2652,8 @@ export async function runEditorDesignPlayer3D(renderer, opts = {}) {
2591
2652
  scene.add(marker);
2592
2653
  selectionBox.visible = false;
2593
2654
  scene.add(selectionBox);
2655
+ menuTargetBox.visible = false;
2656
+ scene.add(menuTargetBox);
2594
2657
  scene.add(gizmo.root);
2595
2658
  // ADR-046 Phase 3b — the shared pivot itself has no visible geometry,
2596
2659
  // but it still needs to be IN the (fresh) scene graph for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umicat/three-sdk",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "Three.js runtime for Umicat games: the scene3d design format, its loader with physics, a kinematic character controller, and the Umicat platform via @umicat/platform-sdk.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",