Skip to content

[Bugs] viewer, nodes: pointer moves no longer throw on a wall mid paint preview - #1116

Merged
Aymericr merged 2 commits into
mainfrom
cursor/pointer-raycast-invalid-material-b9aa
Oct 21, 2026
Merged

Aymericr merged 2 commits into
mainfrom
cursor/pointer-raycast-invalid-material-b9aa

Conversation

@Aymericr

@Aymericr Aymericr commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes MONOREPO-EDITOR-131 and MONOREPO-EDITOR-132 (Cannot read properties of undefined (reading 'side') from pointer-events.js:368 on pointer move).

Both Sentry stacks crash on the stock fallback branch of the vendored pointer manager (layer.raycaster.intersectObject(obj, true)), not the cached collector. #1091 guarded the elevator click raycast and the cached collector, but once an event falls back to three's own recursion (any untagged custom raycast in the scene), a wall whose geometry groups point past its material array still throws.

  • Source (nodes): applyWallPreview regrouped the geometry and swapped the material through two independent restores. A rebuild during the preview put the older, shorter palette back over the new geometry's groups. swapPreviewMaterial now takes the groups along with the material and swaps them as one pair. On undo it puts back only what is still the preview's, and restores the original material only over groups it can draw. The other paint previews (material-only) get the same "never restore a palette over groups it can't draw" rule.
  • Guard (viewer): the stock path now uses intersectDrawable, which mirrors three's recursive intersectObject but skips meshes hasMaterialsForGroups rejects (their children are still tested). Raycasters with their own intersectObject are still asked directly.
  • Breadcrumb: every skip (cached or stock) is reported once per mesh and material as a raycast_invalid_material breadcrumb { category, message, level: 'warning', data: { nodeType, nodeId, objectName } }. It reaches the host through the new <Viewer onBreadcrumb> prop, forwarded as <Editor onViewerBreadcrumb>. The public packages carry no Sentry SDK, so the hosted app needs to wire it, e.g. onViewerBreadcrumb={(b) => Sentry.addBreadcrumb(b)}.
  • Test: the [Bugs] viewer: room-wide paint preview no longer leaves walls unraycastable #1091 elevator regression test now drives real pointer moves through createPascalPointerEvents over the same torn wall, on both the cached and stock paths. It asserts no throw, that the hover target behind the wall still gets onPointerMove, and that exactly one breadcrumb is recorded with nodeType: 'wall' and the node id. With the old stock call put back, the stock case fails with material.side.

How to test

  1. bun test packages/viewer/src/systems/elevator packages/viewer/src/lib/pointer-events.test.ts (after bun run build): all pass.
  2. bun test packages/nodes/src/shared/swap-preview-material.test.ts: the groups and material undo as a pair, and a rebuilt geometry keeps the preview palette instead of getting the shorter original.
  3. In the editor, open the paint tool and hover a room-wide wall finish across several walls while clicking to commit. Moving the pointer no longer throws.

Screenshots / screen recording

N/A: non-visual change.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch
Open in Web Open in Cursor 

Note

Medium Risk
Changes core pointer raycasting and wall paint preview teardown; behavior is guarded and tested but affects hover/picking whenever material arrays and geometry groups disagree.

Reviewed by Cursor Bugbot for commit 3a88c84. Bugbot is set up for automated code reviews on this repo. Configure here.

…e pair

applyWallPreview regrouped the geometry and swapped the material through two
independent restores: the material went back whenever the mesh still wore the
preview, the groups only while the geometry was the same object. A rebuild
during the preview put the older, shorter palette over the new geometry's
groups, leaving a group with no material (MONOREPO-EDITOR-131/132).
swapPreviewMaterial now takes the groups with the material and restores the
original material only over groups it can draw.
…array on the stock path too

The cached collector already skipped them, but once an event fell back to
three's recursive intersectObject (any untagged custom raycast in the scene)
a torn wall threw on material.side from every pointer move
(MONOREPO-EDITOR-131/132). The stock walk now mirrors three's recursion with
the same guard. Each skip reaches the host once per mesh and material as a
raycast_invalid_material breadcrumb with the owning node's type and id,
through <Viewer onBreadcrumb> / <Editor onViewerBreadcrumb>.

The #1091 elevator regression test now drives pointer moves over the same
torn wall on both the cached and the stock path.
@Aymericr Aymericr added the bot:bugs label Oct 21, 2026 — with Cursor
@Aymericr
Aymericr marked this pull request as ready for review October 21, 2026 12:19
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T12:23:26.709185Z 3a88c84 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Aymericr
Aymericr merged commit e583ebe into main Oct 21, 2026
4 checks passed
@cursor
cursor Bot deleted the cursor/pointer-raycast-invalid-material-b9aa branch October 21, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants