Skip to content

feat(v0.4b): node-align snap (bbox features -> other nodes)#34

Merged
longyi-xw merged 7 commits into
mainfrom
feat/v0.4b-node-snap
Jun 7, 2026
Merged

feat(v0.4b): node-align snap (bbox features -> other nodes)#34
longyi-xw merged 7 commits into
mainfrom
feat/v0.4b-node-snap

Conversation

@longyi-xw

Copy link
Copy Markdown
Owner

What

v0.4 第二个 sub-stage:gizmo 平移拖拽 + 按住 Ctrl/Cmd 时,被拖节点 bbox 特征(中心+8角)吸附到其它节点的对应特征(屏幕 12px 内最近对对齐),命中优先、否则回退 sub-stage A 的网格吸附。

  • snapToNodes 纯函数(src/core/snap/nodes.ts,收已投影屏幕点,可单测)。
  • ThreeViewport:mouseDown 缓存其它节点 bbox 特征(投影屏幕);objectChange 节点吸附优先、grid 回退。mouseUp 提交不变(可撤销)。

Why

  • Spec: `docs/superpowers/specs/2026-06-06-v0.4b-node-snap-design.md`
  • Plan: `docs/superpowers/plans/2026-06-06-v0.4b-node-snap-plan.md`
  • 延后:Smart Guides 智能辅助线、面/边特征、socket(C)、旋转缩放吸附 → roadmap Backlog。

How to test

  • lint / typecheck / test 本地绿(snapToNodes 单测;test 434)
  • CI 绿
  • 人工 pnpm tauri dev(plan T3 步骤 2:两个 Box 角对角/中心对中心吸附 / 超出回退 grid / undo / rotate-scale 不吸附)

🤖 Generated with Claude Code

longyi-xw and others added 7 commits June 6, 2026 21:55
拖拽 + Ctrl/Cmd 时被拖节点 bbox 特征(中心+8角)吸附到其它节点对应特征(屏幕像素
阈值 12px 内最近对对齐),命中优先否则回退 A 的 grid。snapToNodes 纯函数(收已投影
屏幕点,可单测)+ ThreeViewport mouseDown 缓存目标 + objectChange 节点吸附 + 投影。
Smart Guides/面边特征/旋转缩放吸附延后。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ested)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…lback

mouseDown 缓存其它节点 bbox 特征(中心+8角,投影屏幕);objectChange 时被拖节点特征
与缓存目标比,屏幕 12px 内最近对 → obj.position.add(offset),否则回退 grid(A)。
bboxFeatures/toScreen/featureSnapPoints 模块 helper。mouseUp 提交不变(可撤销)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… align)

反馈:box 对 box 角能贴,但球放 box 顶面/侧面对齐难(拖很久)——根因 bbox 特征只有
中心+8角,缺面中心。bboxFeatures 加 6 个面中心(±X/±Y/±Z 面),让球底面中心↔box
Two visual-feedback issues from sub-stage B node-align snapping:

1. Depth-blind screen snapping — snapToNodes picked the screen-nearest
   pair, so from a parallel/side view a far box whose features project
   close on screen could win over a genuinely nearer box. Screen pixels
   now only gate "is it close enough to consider"; among in-threshold
   pairs we pick the one closest in 3D world space.

2. Rotated boxes were hard to snap to their top/face — bboxFeatures used
   Box3.setFromObject (axis-aligned world AABB), whose face centers don't
   sit on a rotated box's real faces. Now an oriented box (OBB): compute
   the bbox in the object's local space, then transform the 15 feature
   points by matrixWorld so corners/face-centers follow rotation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
OBB features + world-distance tiebreak; v0.4 stays partial (sub-stage C
Socket system pending). Next: 资源拖拽入视口.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@longyi-xw longyi-xw merged commit bcb20a2 into main Jun 7, 2026
1 check passed
@longyi-xw longyi-xw deleted the feat/v0.4b-node-snap branch June 7, 2026 15:54
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.

1 participant