Prompt
coins-prompt.md94 KB
# COINS — 3D coins for any website
**For the AI agent (Claude Code, Codex, Cursor or similar).** The person has attached this file, usually together with an SVG file. They want an animated hero for their website: a long row of metal 3D coins made from their SVG that drifts sideways and reacts to the cursor. First they tune it in a settings page in their browser. Then they paste the settings back to you, and you turn them into code for their site.
The settings page is already written. It is the HTML at the very end of this file, between a line `<<<<<<<< COIN-STUDIO-HTML` and a line `>>>>>>>> COIN-STUDIO-HTML`. It is long (74 085 characters). These instructions end at line 129: don't read past that line. **Do not read the page into the chat, retype it, rewrite it or "improve" it.** Copy it out with a script.
Talk to the person in the language of their message. If they wrote nothing, use Russian, since the settings panel is in Russian. Keep messages short and free of jargon. Do one step at a time.
## Step 1. Find the files
- **This file.** Find its path on disk: the person attached it or dropped it into the chat. If you only have its text, look for `coins-prompt.md` in the working folder, then on the Desktop, then in Downloads.
- **The SVG.** It was attached alongside this file or is in the working folder. If there are several, ask which one. If there is none, ask for one. Until it arrives you can still open the page: it starts with a built-in dollar coin.
## Step 2. Check the SVG
Open the SVG as text and check it. Do not redraw or "fix" it yourself.
- The scene uses only **filled** shapes. The largest filled area becomes the coin body. Shapes in other colours on top of it become relief, like the symbol on a coin.
- A single colour gives a flat figure. Holes are fine.
- Strokes without fill, `<text>` and raster `<image>` are ignored.
If the SVG has only strokes or text, tell the person how to fix it in Figma, then export SVG again:
1. Select the layer.
2. Choose **Outline stroke** (⌥⌘O / Ctrl+Alt+O).
3. Turn text into outlines.
4. Flatten.
## Step 3. Make and open the settings page
1. Make a folder `coin-studio` in the folder you are working in (your current directory or open project). If you can't write there, use the Desktop or a temp folder.
2. Write `coin-studio/index.html` with a script:
1. Take the text between the two marker lines, without the marker lines themselves.
2. Check it: it starts with `<!doctype html>`, ends with `</html>`, and its SHA-256 (UTF-8, `\n` line endings) is `f758fe881cea83684783fbd870fd41834954519643b35b13a1521f0812b88926`. If the hash doesn't match, extract it again. Don't repair it by hand.
3. Replace the line `<!--@@SVG@@-->` with the full text of the SVG file. Change nothing else.
3. Open the page in the person's default browser. The copy button needs a real browser, not a preview:
- macOS: `open coin-studio/index.html`
- Windows: `start "" "coin-studio\index.html"`
- Linux: `xdg-open coin-studio/index.html`
If you have no shell, or the command fails (sandbox, remote machine), give the person the absolute address of the file, like `file:///Users/name/site/coin-studio/index.html` or `file:///C:/Users/name/site/coin-studio/index.html`. Tell them to paste it into the address bar of Chrome, Safari, Edge or Firefox. If the file is on a machine they can't reach, give them the file to save.
Python example (put in the real paths you found in step 1):
```python
from pathlib import Path
import hashlib
prompt = Path("/path/to/coins-prompt.md").read_text(encoding="utf-8")
html = prompt.rsplit("\n<<<<<<<< COIN-STUDIO-HTML\n", 1)[1].rsplit("\n>>>>>>>> COIN-STUDIO-HTML", 1)[0]
assert hashlib.sha256(html.encode("utf-8")).hexdigest() == "f758fe881cea83684783fbd870fd41834954519643b35b13a1521f0812b88926"
svg = Path("/path/to/shape.svg").read_text(encoding="utf-8")
html = html.replace("<!--@@SVG@@-->", svg.strip(), 1)
out = Path("coin-studio/index.html"); out.parent.mkdir(exist_ok=True); out.write_text(html, encoding="utf-8")
```
Node works the same way. The page needs internet: three.js loads from a CDN.
Then explain the page in a few lines:
- The **«Настройки анимации»** panel is on the right. Click its title to open it.
- **Вид**: colours, metal and background. **Свет**: lighting. **Форма**: size, thickness and bevel; another SVG can be loaded there or dropped onto the page. **Рельеф** shows up if the SVG has two or more colours. **Рифлёный торец**: the ribbed coin edge. **Ряд**: count, spacing, speed and position. **Механика первого экрана** and **Курсор**: how the coins react.
- The background is transparent by default (checkerboard), so the site's own background will show through. To set a colour instead, untick **«прозрачный фон»**.
- **«Сбросить»** in the panel header returns everything to the start.
- When it looks right, they press **«Скопировать настройки»** at the bottom of the panel and paste the result into this chat.
## Step 4. When the settings come back
They paste a JSON object with many keys, including `g8` and `svg`. `svg` is the shape that was on screen when they copied, and it can differ from the file they gave you. Always use the pasted one. Save the JSON as is to `coin-studio/settings.json`. Then ask, in one short message, only the questions below they haven't answered yet:
1. **Where will it go?** Tilda, Framer, Webflow, WordPress, a plain HTML site, React / Next.js, Vue / Nuxt, or something else.
2. **How?** As the full-screen background of the first screen with their content on top (the default), or as a block of a set height.
3. **What goes on top?** Their own headline and button, or they will add them later.
## Step 5. Build the code for the site
Start from `coin-studio/index.html` and change it with a script:
1. Delete everything from the line with `/*@@PANEL-START@@*/` to the line with `/*@@PANEL-END@@*/`, including both lines. That is the panel, colour picker and file upload. The site doesn't need them.
2. Delete the line `import GUI from 'lil-gui';` and the `"lil-gui"` entry in the import map. It is the last entry, so also remove the comma at the end of the line before it.
3. Replace `/*@@SETTINGS@@*/` with `window.SCENE_OVERRIDES = <the pasted JSON>;`.
- Its `svg` key overrides the SVG slot, so empty the `coin-svg` script.
- Only if the JSON has no `svg` key, keep the SVG in the slot.
4. Replace the demo page's `<style>` block (checkerboard, page background, `section` rules) with your own small one for the canvas and its wrapper. Remove the empty `<section class="hero">`. The scene still adds a class `bg-clear` to `<html>`. Without the demo CSS it does nothing.
5. Fit the canvas `#scene` to the target.
- The scene sizes itself to the canvas, so the canvas can sit anywhere. Use `position: fixed; inset: 0` for a page background, or `position: absolute; inset: 0` inside a `position: relative` block with a set height.
- Put the person's content above it with a higher `z-index`. The scene listens to the pointer on the whole window, so text and buttons on top don't block the effect.
- With `bgTransparent: true` the canvas is see-through. Otherwise it is painted with `bg`.
6. Keep everything else as it is: the scene code, three.js 0.170.0 from the CDN and the import map. The import map must come before the module script.
7. The page is one screen, so you need nothing for scrolling. The coins stay a row, and scrolling only speeds them up for a moment.
For a site builder, give a fragment with no `<html>`, `<head>` or `<body>`, in this order:
```html
<div class="coins-hero"><canvas id="scene"></canvas></div>
<style>/* wrapper and canvas sizes */</style>
<script type="importmap">{ "imports": { "three": "…", "three/addons/": "…" } }</script>
<script type="text/plain" id="coin-svg"></script>
<script>window.SCENE_OVERRIDES = { … };</script>
<script type="module">/* the scene code, unchanged */</script>
```
For a plain HTML site, it can also be a whole page.
Platform notes. Check the current limits of the platform if you can:
- **Plain HTML:** one file, or a block to paste into the page, with the import map placed before any module script.
- **Tilda:** for coins behind their own headline, use a Zero Block. Add an HTML element, paste the fragment, make it fill the block (window width, 100% height) and put it at the bottom layer. Their text and buttons are ordinary Zero Block elements above it. For a block of coins only, use an HTML block (T123) with a wrapper of a set height. Scripts may not run in the editor preview, so check on the published page. Check the current size limit of the element: the fragment is about 50–60 KB.
- **Framer:** Embed → HTML. Stretch it to the section.
- **Webflow:** a Code Embed. It has a character limit (50,000 when this was written). If the code is longer, host the standalone page as a file and embed it with an `<iframe>`.
- **WordPress:** a Custom HTML block.
- **React / Next.js / Vue:** a small component that renders the canvas and loads the scene script once on the client, using `useEffect`, `next/script` or `onMounted`. Don't port the scene to npm packages.
- **Fallback:** if a platform strips module scripts or import maps, use the standalone page in an `<iframe>`. Tell the person that the cursor effect then works only over the frame.
Then check the result:
- No markers are left.
- `SCENE_OVERRIDES` is valid.
- If you can open a browser, open the result and check that the console has no errors.
Save the code as `coin-studio/coins-<platform>.html`, for example `coins-tilda.html`, and give the person its path with short steps on where to paste it. If you can run commands, also try to put it on their clipboard (`pbcopy` / `clip` / `xclip` / `wl-copy`). Say it's copied only if the command succeeded. Don't paste tens of kilobytes into the chat unless they ask.
If something goes wrong, check these first:
- **A blank page** is usually no internet (the CDN) or a broken SVG. Look at the console.
- **The built-in dollar coin instead of their shape** means the SVG couldn't be read. Go back to step 2.