Skip to content

Add geometry inspector panel including mesh stats#67

Open
soshiCS wants to merge 1 commit intoAdam-CAD:masterfrom
soshiCS:soroush/geometry-inspector
Open

Add geometry inspector panel including mesh stats#67
soshiCS wants to merge 1 commit intoAdam-CAD:masterfrom
soshiCS:soroush/geometry-inspector

Conversation

@soshiCS
Copy link

@soshiCS soshiCS commented Jan 25, 2026

Adds a Geometry Inspector panel in the viewer that shows live mesh stats for the current STL:

  • Bounding box size (X/Y/Z)
  • Model center
  • Vertex count
  • Triangle count
  • STL file size

Note

Introduces an on-canvas Geometry Inspector for STL outputs in the OpenSCAD viewer.

  • Computes and displays size (X/Y/Z), center, vertexCount, triangleCount, and STL byteSize after parsing with STLLoader
  • Calculates bounding box via computeBoundingBox() before recentring (geom.center()), then computeVertexNormals(); stores metrics in geometryStats
  • Renders a fixed overlay panel (top-right) with live stats; container made relative to position overlay
  • Minor: imports Vector3; defensive resets when no geometry
  • package-lock: adds peer: true metadata to numerous dependencies (React, ESLint, Tailwind, Three, Vite, etc.)

Written by Cursor Bugbot for commit 9118f5d. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Jan 25, 2026

@soshiCS is attempting to deploy a commit to the Adam Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 25, 2026

Greptile Overview

Greptile Summary

Adds a Geometry Inspector panel overlay in the 3D viewer that displays live mesh statistics for loaded STL files.

  • Imported Vector3 from three.js to calculate bounding box dimensions and center
  • Added geometryStats state to track size, center, vertex/triangle counts, and file size
  • Computed bounding box before centering geometry to preserve original center coordinates
  • Created UI overlay panel positioned in top-right corner with mesh statistics
  • Panel shows "No geometry" message when no STL is loaded

The implementation correctly captures geometry stats before transforming the mesh, preventing data loss. The only minor issue is using as type casting on line 234, which violates project style guidelines.

Confidence Score: 4/5

  • Safe to merge with one minor style improvement recommended
  • Clean implementation with correct geometry calculations and proper state management. Only issue is a single type casting violation that doesn't affect functionality.
  • No files require special attention - the type casting issue is minor

Important Files Changed

Filename Overview
package-lock.json Automated npm dependency metadata update adding peer flags - no functional changes
src/components/viewer/OpenSCADViewer.tsx Added geometry inspector panel with mesh statistics - minor type casting issue at line 234

Sequence Diagram

sequenceDiagram
    participant User
    participant OpenSCADViewer
    participant STLLoader
    participant BufferGeometry
    participant UI

    User->>OpenSCADViewer: Load STL file
    OpenSCADViewer->>STLLoader: parse(arrayBuffer)
    STLLoader-->>OpenSCADViewer: return BufferGeometry
    OpenSCADViewer->>BufferGeometry: computeBoundingBox()
    BufferGeometry-->>OpenSCADViewer: boundingBox computed
    OpenSCADViewer->>BufferGeometry: getSize(size)
    OpenSCADViewer->>BufferGeometry: getCenter(center)
    Note over OpenSCADViewer: Capture original stats<br/>(size, center)
    OpenSCADViewer->>BufferGeometry: center()
    Note over OpenSCADViewer: Transform for viewing
    OpenSCADViewer->>BufferGeometry: computeVertexNormals()
    OpenSCADViewer->>OpenSCADViewer: setGeometry(geom)
    OpenSCADViewer->>OpenSCADViewer: setGeometryStats({size, center, counts})
    OpenSCADViewer->>UI: Render 3D scene + Inspector panel
    UI-->>User: Display mesh with stats overlay
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 25, 2026

Additional Comments (1)

src/components/viewer/OpenSCADViewer.tsx
Avoid as type casting. Check already confirmed it's an OpenSCADError, so the cast is unnecessary:

            if (error && error.name === 'OpenSCADError') {
              fixError?.(error);
            }

Context Used: Rule from dashboard - Avoid using 'as' type casting in TypeScript code. Find alternative approaches for type safety instea... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/viewer/OpenSCADViewer.tsx
Line: 234:234

Comment:
Avoid `as` type casting. Check already confirmed it's an `OpenSCADError`, so the cast is unnecessary:

```suggestion
            if (error && error.name === 'OpenSCADError') {
              fixError?.(error);
            }
```

**Context Used:** Rule from `dashboard` - Avoid using 'as' type casting in TypeScript code. Find alternative approaches for type safety instea... ([source](https://app.greptile.com/review/custom-context?memory=096c10cb-12df-4744-903f-f7cad6ba6369))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

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