Skip to content

perf: optimize boundary falloff — deduplicate, numeric IDs, texture reuse#33

Open
Avatarsia wants to merge 3 commits intoCNCKitchen:mainfrom
Avatarsia:perf/main-falloff-optimize
Open

perf: optimize boundary falloff — deduplicate, numeric IDs, texture reuse#33
Avatarsia wants to merge 3 commits intoCNCKitchen:mainfrom
Avatarsia:perf/main-falloff-optimize

Conversation

@Avatarsia
Copy link
Copy Markdown
Contributor

Summary

  • Extract _computeFaceMask() helper to eliminate duplicated face-mask computation between computeBoundaryFalloffAttr and computeBoundaryEdges
  • Replace string-key Maps (posKey template literals, pk/ek string concat) with a dedup pass producing numeric vertex IDs + flat TypedArrays
  • Convert falloffCache and maskTypeCache from Map to Float64Array / Uint8Array
  • Optimize write-back loop to use vtxId[] instead of recomputing posKey() per vertex
  • Share dedup results between functions via module state (_falloffVtxId, _falloffIdPosX/Y/Z)
  • Reuse _boundaryEdgeTex DataTexture instead of dispose/recreate on every slider change

Impact (100k triangle mesh): Reduces string allocations from ~1.5M to ~300k per falloff update. Eliminates 5 Map objects, replaces ~600k string-key lookups with direct array indexing. DataTexture reuse avoids WebGL texture churn during slider interaction.

Test plan

  • node --check js/main.js passes
  • Playwright: app loads without JS errors
  • Playwright: boundary-falloff slider works without errors
  • No console errors across all tests

🤖 Generated with Claude Code

Avatarsia and others added 3 commits April 7, 2026 15:51
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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