Skip to content

app-16292: shared ECS traits and helpers for entity pose plugins#735

Merged
Devin T. Currie (DTCurrie) merged 9 commits into
mainfrom
app-16292/1-ecs-utils
Jun 2, 2026
Merged

app-16292: shared ECS traits and helpers for entity pose plugins#735
Devin T. Currie (DTCurrie) merged 9 commits into
mainfrom
app-16292/1-ecs-utils

Conversation

@DTCurrie

@DTCurrie Devin T. Currie (DTCurrie) commented Jun 1, 2026

Copy link
Copy Markdown
Member

Adds shared ECS traits and helpers (writeMatrix, CustomDetails), a 'gizmo' interaction mode, and a firstHitOnly raycaster option. Foundation for the Gizmos plugin in #738. No consumers in this PR.

Note

Use this PR preview to view all of the changes from this stack: https://viamrobotics.github.io/visualization/pr-preview/pr-739/snapshot

Stack

  1. This PR: Shared ECS traits and helpers
  2. Details refactor (app-16292: refactor Details panel into focused subcomponents #736)
  3. Component tweaks (app-16292: small component tweaks to support per-entity pose mutators #737)
  4. Gizmos plugin (app-16292: add Gizmos plugin #738)
  5. Gizmos plugin docs (app-16292: add docs page for the Gizmos plugin #739)

Frontend

  • src/lib/ecs/traits.ts: adds writeMatrix(entity, patch) that mutates an entity's Matrix trait via the existing createPose / matrixToPose / poseToMatrix round-trip and then dirties the trait.
  • src/lib/ecs/traits.ts: adds the CustomDetails marker trait so the refactored Details panel can suppress its default frame and pose blocks for entities that render their own. May be removed after frame editing becomes a plugin.
  • src/lib/hooks/useMouseRaycaster.svelte.ts: accepts a firstHitOnly option that is forwarded to three-mesh-bvh, for tools that only care about the closest hit.
  • src/lib/hooks/useSettings.svelte.ts: extends the Settings.interactionMode union with 'gizmo'.

Testing

Added src/lib/ecs/__tests__/writeMatrix.spec.ts covering each Pose field individually and the no-op path when the entity has no Matrix trait. Ran pnpm check and pnpm test.

@changeset-bot

changeset-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d076b3f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@viamrobotics/motion-tools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-02 22:07 UTC

Foundation for the upcoming Gizmos plugin. No callers yet; these
symbols are consumed by follow-up PRs in the stack.

* writeMatrix(entity, patch): patch a Pose onto an entity's Matrix
  trait via createPose/matrixToPose/poseToMatrix, then dirty the
  trait. Used by the refactored Details panel and the Gizmos plugin.
* CustomDetails trait: marker so the Details panel suppresses its
  default frame/pose UI for entities that render their own.
* useMouseRaycaster firstHitOnly option (forwarded to three-mesh-bvh).
* 'gizmo' value added to Settings.interactionMode.
* Re-exports of DEFAULT_LINE_WIDTH and ARROW_LENGTH for downstream
  consumers.
@DTCurrie

This comment was marked as outdated.

@claude

This comment was marked as outdated.

Comment thread src/lib/ecs/traits.ts Outdated
Comment thread src/lib/ecs/traits.ts Outdated
Comment thread src/lib/ecs/__tests__/writeMatrix.spec.ts
Comment thread src/lib/hooks/useMouseRaycaster.svelte.ts Outdated
@DTCurrie

This comment was marked as outdated.

@claude

This comment was marked as outdated.

github-actions Bot and others added 2 commits June 1, 2026 21:27
- Move writeMatrix below updateGeometryTrait for consistent file layout
- Add JSDoc to writeMatrix documenting round-trip semantics and no-op behavior
- Filter undefined values from patch before Object.assign to prevent NaN in matrix
- Add comment clarifying firstHitOnly affects both hover and click handlers
- Strengthen orientation test with oX/oY/oZ assertions

Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
Comment thread src/lib/ecs/traits.ts
Comment on lines +78 to +84
/**
* Suppresses the default frame-style world/local pose and parent-frame blocks
* in the details panel. Entities that render their own pose UI via the
* `details-extensions` portal target (e.g. gizmo plugin entities) opt in by
* adding this trait.
*/
export const CustomDetails = trait(() => true)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This can probably be removed when frame editing is made a plugin

Comment thread src/lib/hooks/useMouseRaycaster.svelte.ts Outdated
@DTCurrie

This comment was marked as outdated.

@claude

This comment was marked as outdated.

Comment thread src/lib/ecs/traits.ts
Comment thread src/lib/ecs/__tests__/writeMatrix.spec.ts
Comment thread src/lib/hooks/useMouseRaycaster.svelte.ts Outdated
@DTCurrie

This comment was marked as outdated.

@claude

This comment was marked as outdated.

…stHitOnly effect split

- Add early-exit guard in writeMatrix when filtered patch is empty to avoid
  spurious entity.changed(Matrix) notifications
- Add tests for undefined field filtering and empty/all-undefined patch paths
- Split firstHitOnly assignment into its own $effect so toggling it doesn't
  tear down and re-attach event listeners

Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
@DTCurrie

This comment was marked as outdated.

@claude

This comment was marked as outdated.

Comment thread src/lib/ecs/traits.ts Outdated
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Comment thread src/lib/hooks/useMouseRaycaster.svelte.ts Outdated
@DTCurrie Devin T. Currie (DTCurrie) merged commit 652e924 into main Jun 2, 2026
7 checks passed
@DTCurrie Devin T. Currie (DTCurrie) deleted the app-16292/1-ecs-utils branch June 2, 2026 22:07
@claude claude Bot mentioned this pull request Jun 2, 2026
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