Skip to content

Select asset-backed elements in the 3D view - #51

Open
haphantran wants to merge 1 commit into
mainfrom
fix/3d-asset-selection
Open

haphantran wants to merge 1 commit into
mainfrom
fix/3d-asset-selection

Conversation

@haphantran

Copy link
Copy Markdown
Collaborator

Problem

In the 3D view, clicking an element whose notation binds a GLB asset did nothing. Node3D only handled a pointer hit when the hit object was the element's own mesh or a direct child of its group. A hit on an asset lands on a mesh nested inside the loaded model, several levels below the group, so the check always failed and the event was swallowed.

In the Smart Warehouse floor-plan views this affects conveyors, mobile robots, charging stations, output locations, and pathway areas. None of them could be selected, dragged, or edited through Position & Rotation. That blocks the paper scenario and reviewer guide step "in 3D, move one conveyor onto the other". Fallback shapes (racks, docks, drones, all Smart Home devices) were not affected.

Change

  • isHitWithin(object, roots) in components/diagram/3d/utils/selection.ts accepts a hit on any object at or below the element's mesh or group.
  • Node3D uses it in the click and pointer-down handlers instead of the direct-child check.

Testing

  • New unit test 3d-selection.test.ts covers a nested asset mesh, a fallback mesh and its child, and hits on other elements.
  • tsc --noEmit passes, and the changed files lint clean.
  • Full frontend suite: 422 of 428 passed locally under heavy machine load. The 6 failures were timeouts in LoginPage and ViewpointManager, and both suites pass when run alone (27/27).
  • Checked in the review archive (Docker Compose) with a headless Chrome rendering the 3D view, using the same camera and click points before and after the change:
Click target Before After
Conveyor #2 (GLB) 0/6 selected 6/6
Conveyor (GLB) 0/4 4/4
Storage Rack (fallback box) 6/6 6/6
  • With the fix, the reviewer-guide steps work end to end: copy Conveyor's X (3D) and Y (3D) onto Conveyor Fix/cicd pipeline #2, then Validate view. The panel reports "Fixed equipment must not overlap: Conveyor overlaps Conveyor Fix/cicd pipeline #2 in plan view." Both conveyors get error markers in 3D and in 2D, and a headless validate-model pipeline run on a checkpoint reports the same issue.

Clicking an element whose 3D notation binds a GLB asset did nothing. The
pointer handlers only accepted a hit on the element's own mesh or on a direct
child of its group, but a hit on an asset lands on a mesh nested inside the
loaded model. Conveyors, robots, charging stations, output locations, and
pathway areas in the Smart Warehouse views could therefore not be selected,
dragged, or edited in 3D. Accept any hit below the element's group.
Copilot AI balanced review requested due to automatic review settings October 16, 2026 03:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix preserves interaction guards, includes targeted regression tests, and has no identified blocking issues.

0 open findings

What changed in this PR

Fixes selection of asset-backed elements in the 3D view by recognizing hits on nested model meshes.

Changes:

  • Adds an ancestor-based hit-checking utility.
  • Uses it in Node3D click and pointer-down handlers.
  • Adds regression tests for nested assets, fallback shapes, and unrelated hits.
File Description
frontend/​src/​components/​diagram/​Node3D.tsx Applies descendant-aware hit checks.
frontend/​src/​components/​diagram/​3d/​utils/​selection.ts Adds the hit ancestry helper.
frontend/​src/​components/​diagram/​3d/​utils/​index.ts Exports the selection utility.
frontend/​src/​__tests__/​services/​3d-selection.test.ts Tests accepted and rejected hits.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants