Improve: Performance optimizations — draw calls, VRAM, imports, DOM#95
Merged
Improve: Performance optimizations — draw calls, VRAM, imports, DOM#95
Conversation
Created disposeGroup() utility that properly disposes geometry and material GPU resources before removing children. Replaced all 17 bare while-loop group-clearing patterns throughout rt-rendering.js. Prevents VRAM exhaustion from orphaned BufferGeometry and Material objects accumulating during slider adjustments and form updates.
Convert addMatrixNodes and addRadialMatrixNodes in rt-nodes.js to use THREE.InstancedMesh instead of creating individual meshes per vertex. For a 10x10 cube matrix (~400 nodes), this reduces draw calls from 400 to 1 per node group. Primary polyhedra nodes (renderPolyhedron) kept as individual meshes to preserve instance cloning and vertex selection compatibility. Updated rt-papercut.js and rt-viewmanager.js to handle InstancedMesh by iterating stored vertexPositions from userData.
Replace per-cell geometry creation with pre-allocated merged arrays. Each matrix now creates ONE face mesh + ONE edge LineSegments instead of N² separate objects. For a 10x10 cube matrix, this reduces draw calls from ~200 to 2. Added buildMergedMatrix() helper to both planar and radial modules. Handles tetrahedron alternating orientations via flipZ flag (planar) and up/down geometry split (radial). Radial octahedron ivmScaleOnly mode retains per-cell approach due to per-cell rotation requirement. Net reduction: -502 lines of duplicated per-cell geometry code.
Convert 13 dynamic import() calls to static imports: - rt-rendering.js: 11 dynamic imports of rt-matrix-planar and rt-matrix-radial - rt-nodes.js: 2 dynamic imports of rt-polyhedra No circular dependencies — all conversions are safe.
Add SpatialVertexSet class using integer-quantized keys instead of toFixed(6) string serialization. Eliminates string allocation churn and parseFloat round-trips during node position deduplication.
- Cache all DOM elements with IDs at init time via querySelectorAll - Replace 206 document.getElementById() calls with cached el.xxx lookups - Add requestGeometryUpdate() with rAF gating for slider input events - Checkbox/radio change events remain synchronous (fire once per click)
🤖 Claude Code ReviewNo issues found. ℹ️ About this reviewThis automated review checks for:
Human review required - these are suggestions only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
disposeGroup()utility replaces 17 bare while-loop group clears in rt-rendering.jsbuildMergedMatrix()helper in rt-matrix-planar.js and rt-matrix-radial.js (net -420 lines)el.xxxlookups) and rAF-gatedrequestGeometryUpdate()for slider eventsSpatialVertexSetclass with integer-quantized keys replaces toFixed(6) string serializationTest plan