awesome—here’s a drop-in, copy-paste prompt you can paste into Cursor (Claude Sonnet…
- User
awesome—here’s a drop-in, copy-paste prompt you can paste into Cursor (Claude Sonnet 4.5) to build Sketch 10: Tesseract Shadow Theater in your Next.js + TS + Tailwind + three.js stack.
Prompt for Cursor / Claude
You are my senior graphics engineer. Build a production-ready interactive sketch called “Tesseract Shadow Theater” for my app Sketch Vault (Next.js, TypeScript, Tailwind). Use three.js. Deliver clean, modular code and explain only when asked.
Goal (one sentence)
Render a rotating 4D tesseract (hypercube) projected to 3D, then cast dynamic shadows onto a 2D “stage” plane, with interactive 4D rotation controls and multiple lights.
Tech + Project Constraints
-
Framework: Next.js (App Router), TypeScript, Tailwind CSS.
-
Rendering: three.js r15x (no react-three-fiber—plain three.js inside a client component).
-
Structure:
/app/sketches/tesseract/page.tsx→ page that mounts the sketch./components/sketches/TesseractShadowTheater.tsx→ client component that creates/tears down the scene./lib/math/tesseract.ts→ 4D math utilities (matrices, projection)./lib/controls/tesseractControls.ts→ state + helpers for UI controls.
-
UI: lightweight Tailwind panel with sliders/toggles; no external UI kit.
-
Build: no server dependencies. All client-side.
-
Quality: strict TS, eslint clean, small functions, comments for math.
Core Features (MVP)
- 4D Geometry
- Generate tesseract vertices (±1 in each of 4 dims) and edges.
- Apply 4D rotations via rotation matrices in planes: XY, XZ, XW, YZ, YW, ZW.
- Pipeline: 4D vertices → rotate (4×4) → project 4D→3D (perspective or orthographic—make both options) → render 3D edges with
THREE.LineSegments.
- 3D Scene + Stage
- Scene with a ground plane (“stage”) at y=0 (or configurable).
- Camera:
PerspectiveCamera, orbit controls (mouse/touch).
-
Assistant
- User
Can you analyse the structure of the other skect files and include the header and controls the smae way that they appear in the other skectes?
Assistant
- User
Can you change it so that only the controls menu is scrollable and not the whole page?
Assistant
I'll fix the scrolling so only the controls sidebar is scrollable, not the whole page. Let me check the current implementation and compare with the planets page:
[tool: read_file — Tool use: read_file • Read file: src/app/sketches/tesseract/page.tsx]
[tool: read_file — Tool use: read_file • Read file: src/app/sketches/planets/page.tsx]
I see the issue. The page uses
min-h-screenwhich allows it to grow beyond the viewport. I need to change it toh-screenwithoverflow-hiddento prevent page scrolling, while keeping the sidebar scrollable. Let me fix this:- User
This doesn't work. Now there is no scroll
Assistant
Let me check the Controls component to see why the sidebar isn't scrolling:
[tool: read_file — Tool use: read_file • Read file: src/components/sketches/Controls.tsx]
I see the issue. The Controls component has
overflow-y-autobut the parent container needs proper height constraints. Let me check the planets page to see how they handle it:[tool: read_file — Tool use: read_file • Read file: src/app/sketches/planets/page.tsx]
I see the issue. The planets page uses
min-h-screenwhich allows page scrolling. To make only the sidebar scroll, I need to add height constraints properly. Let me fix it:- User
The auto rotate isn't working. Can you fix it?
Assistant
Let me check the animation loop to see what's happening with auto rotate:
[tool: read_file — Tool use: read_file • Read file: src/app/sketches/tesseract/page.tsx]
I see the issue! The rotation is being applied to the original vertices each frame instead of accumulating. We need to track the accumulated rotation. Let me fix this: