Skip to content

feat: asset drag-into-viewport with ground-raycast drop point#35

Merged
longyi-xw merged 11 commits into
mainfrom
feat/asset-drag-into-viewport
Jun 8, 2026
Merged

feat: asset drag-into-viewport with ground-raycast drop point#35
longyi-xw merged 11 commits into
mainfrom
feat/asset-drag-into-viewport

Conversation

@longyi-xw

Copy link
Copy Markdown
Owner

What

Drag a library card into the viewport to add a node at the drop point (ground y=0 raycast x/z, keeping the item's default y). Existing double-click add-at-default is preserved.

  • Pure helpers screenToNdc + dropPositionFor (src/lib/drop-helpers.ts)
  • catalog.findLibraryItem(id, uploads)
  • adapter.raycastGroundPoint(x,y) → y=0 plane hit | null
  • ui-store.assetDragItemId + start/end actions
  • asset-drag.ts pointer controller (5px threshold → activate)
  • AssetDragGhost cursor-following DOM ghost
  • ThreeViewport window pointerup → drop → AddNodeCommand (undoable)

Why

Backlog item split from v0.2 library; user-ordered after v0.4 sub-stage B (#34). Tauri dragDropEnabled=true suppresses HTML5 ondrop → custom pointer drag.

How to test

pnpm tauri dev: ⌘/Ctrl+J → drag a geometry/light/glb card into viewport → node lands at cursor's ground point; ghost follows; release outside canvas cancels; pure double-click still adds at default; Cmd+Z undoes. Pure fns: pnpm test (drop-helpers + findLibraryItem green).

🤖 Generated with Claude Code

longyi-xw and others added 11 commits June 8, 2026 10:42
Custom pointer drag (Tauri dragDropEnabled=true suppresses HTML5 ondrop)
→ ghost follows cursor → drop on canvas raycasts y=0 ground plane →
new node at hit x/z, keeping the library item's default y. Double-click
add-at-default preserved. Pure fns screenToNdc/dropPositionFor/
findLibraryItem (lib layer so runtime adapter can reuse). Undoable via
AddNodeCommand.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@longyi-xw

Copy link
Copy Markdown
Owner Author

Automated verification on latest commit (f521640):

  • pnpm lint 0 new · pnpm typecheck 0 · pnpm test 452/452

⚠️ Visual smoke (pnpm tauri dev) not yet run — please verify the 7 points in How to test before merging (pointer + WebGL drag isn't covered by vitest).

Roadmap updated: v0.4 "资源拖拽入视口 + 落点" marked done.

@longyi-xw

Copy link
Copy Markdown
Owner Author

✅ Visual smoke (pnpm tauri dev) passed — all 7 points in How to test verified. Ready to merge.

@longyi-xw longyi-xw merged commit 72ff447 into main Jun 8, 2026
1 check passed
@longyi-xw longyi-xw deleted the feat/asset-drag-into-viewport branch June 8, 2026 13:45
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