@vibes.diy/prompts 14.3.248 → 14.3.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generation-variety.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/llms/backend.js +1 -0
- package/llms/backend.js.map +1 -1
- package/llms/blockly.js +1 -0
- package/llms/blockly.js.map +1 -1
- package/llms/blockly.md +2 -3
- package/llms/board-games.js +9 -4
- package/llms/board-games.js.map +1 -1
- package/llms/board-games.md +3 -153
- package/llms/callai.js +1 -0
- package/llms/callai.js.map +1 -1
- package/llms/callai.md +1 -1
- package/llms/canvas-theme-colors.d.ts +2 -0
- package/llms/canvas-theme-colors.js +7 -0
- package/llms/canvas-theme-colors.js.map +1 -0
- package/llms/canvas-theme-colors.md +70 -0
- package/llms/image-gen.js +1 -0
- package/llms/image-gen.js.map +1 -1
- package/llms/image-gen.md +1 -1
- package/llms/index.d.ts +20 -1
- package/llms/index.js +55 -0
- package/llms/index.js.map +1 -1
- package/llms/keepsake.d.ts +2 -0
- package/llms/keepsake.js +9 -0
- package/llms/keepsake.js.map +1 -0
- package/llms/keepsake.md +74 -0
- package/llms/live-rooms.d.ts +2 -0
- package/llms/live-rooms.js +28 -0
- package/llms/live-rooms.js.map +1 -0
- package/llms/live-rooms.md +288 -0
- package/llms/media-capture.d.ts +2 -0
- package/llms/media-capture.js +27 -0
- package/llms/media-capture.js.map +1 -0
- package/llms/media-capture.md +190 -0
- package/llms/mic-capture.d.ts +2 -0
- package/llms/mic-capture.js +7 -0
- package/llms/mic-capture.js.map +1 -0
- package/llms/mic-capture.md +76 -0
- package/llms/needs.d.ts +12 -0
- package/llms/needs.js +71 -0
- package/llms/needs.js.map +1 -0
- package/llms/p5.js +1 -0
- package/llms/p5.js.map +1 -1
- package/llms/p5.md +15 -69
- package/llms/photo-input.d.ts +2 -0
- package/llms/photo-input.js +7 -0
- package/llms/photo-input.js.map +1 -0
- package/llms/photo-input.md +141 -0
- package/llms/physics.js +1 -0
- package/llms/physics.js.map +1 -1
- package/llms/physics.md +7 -16
- package/llms/reskin.js +3 -8
- package/llms/reskin.js.map +1 -1
- package/llms/reskin.md +4 -72
- package/llms/richtext.md +2 -0
- package/llms/social-post.js +1 -0
- package/llms/social-post.js.map +1 -1
- package/llms/social-post.md +22 -4
- package/llms/sound-core.d.ts +2 -0
- package/llms/sound-core.js +7 -0
- package/llms/sound-core.js.map +1 -0
- package/llms/sound-core.md +131 -0
- package/llms/strudel.js +2 -0
- package/llms/strudel.js.map +1 -1
- package/llms/strudel.md +24 -25
- package/llms/surface-board.d.ts +2 -0
- package/llms/surface-board.js +8 -0
- package/llms/surface-board.js.map +1 -0
- package/llms/surface-board.md +140 -0
- package/llms/surface-play-area.d.ts +2 -0
- package/llms/surface-play-area.js +8 -0
- package/llms/surface-play-area.js.map +1 -0
- package/llms/surface-play-area.md +51 -0
- package/llms/surface-presence.d.ts +2 -0
- package/llms/surface-presence.js +9 -0
- package/llms/surface-presence.js.map +1 -0
- package/llms/surface-presence.md +118 -0
- package/llms/three-js.js +1 -1
- package/llms/three-js.js.map +1 -1
- package/llms/three-js.md +52 -18
- package/llms/touch-games.js +11 -11
- package/llms/touch-games.js.map +1 -1
- package/llms/touch-games.md +59 -354
- package/llms/types.d.ts +5 -0
- package/llms/ui-chat.js +2 -1
- package/llms/ui-chat.js.map +1 -1
- package/llms/ui-chat.md +25 -14
- package/llms/use-vibe.js +1 -0
- package/llms/use-vibe.js.map +1 -1
- package/llms/use-viewer.js +1 -0
- package/llms/use-viewer.js.map +1 -1
- package/llms/voxel.js +1 -0
- package/llms/voxel.js.map +1 -1
- package/llms/voxel.md +33 -109
- package/llms/web-audio.js +4 -21
- package/llms/web-audio.js.map +1 -1
- package/llms/web-audio.md +19 -951
- package/llms/web-music.d.ts +2 -0
- package/llms/web-music.js +8 -0
- package/llms/web-music.js.map +1 -0
- package/llms/web-music.md +895 -0
- package/llms/world-controls.d.ts +2 -0
- package/llms/world-controls.js +14 -0
- package/llms/world-controls.js.map +1 -0
- package/llms/world-controls.md +262 -0
- package/llms/worlds.js +2 -1
- package/llms/worlds.js.map +1 -1
- package/llms/worlds.md +5 -14
- package/package.json +5 -5
- package/prompts.js +5 -19
- package/prompts.js.map +1 -1
package/llms/strudel.md
CHANGED
|
@@ -10,10 +10,12 @@ typed by a person, written by an interface, saved as a document, remixed, or
|
|
|
10
10
|
produced by `callAI` from a sentence. The engine arrives from the CDN the
|
|
11
11
|
first time someone presses play, so the app ships only its own code.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
Strudel builds on the Web Audio doc above: the press unlocks sound with its
|
|
14
|
+
`unlockAudio()`, and the engine arrives by its runtime-import rule. A synth
|
|
15
|
+
built from oscillators, a drum machine with its own clock, mic monitoring or a
|
|
16
|
+
metronome is the `web-music` skill. Strudel is the right call when the music is
|
|
17
|
+
a pattern expressed as text (or compiled into text from a grid, sliders or a
|
|
18
|
+
prompt).
|
|
17
19
|
|
|
18
20
|
The worked examples are `jchris/strudel` (an editor, saved patterns and a
|
|
19
21
|
prompt box that rewrites the groove), `jchris/strudel-groovebook` (a step
|
|
@@ -25,20 +27,15 @@ posts on good.vibes.diy.
|
|
|
25
27
|
## The engine arrives at play time
|
|
26
28
|
|
|
27
29
|
**Import the engine with its full pinned esm.sh URL inside a memoized
|
|
28
|
-
module-level loader, and call that loader from the play gesture
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
unlock is registered only once the download finishes, by which time the
|
|
38
|
-
press that started it has passed; a context made and resumed inside that
|
|
39
|
-
press is what iOS asks of sound (measured 2026-10-07: the handed-in context
|
|
40
|
-
is the one the engine plays through, `running`, events firing after a
|
|
41
|
-
1.7 s load).
|
|
30
|
+
module-level loader, and call that loader from the play gesture**:
|
|
31
|
+
`await import("https://esm.sh/@strudel/web@1.3.0")`, so first paint owes
|
|
32
|
+
nothing to a 165 KB engine plus a drum kit. **The loader takes the context
|
|
33
|
+
from `unlockAudio()` before its first `await`** and hands it to the engine
|
|
34
|
+
with `setAudioContext` ahead of `initStrudel`. The engine's own first-click
|
|
35
|
+
unlock is registered only once the download finishes, after the press that
|
|
36
|
+
started it has passed, so the handed-in context is the one that plays
|
|
37
|
+
(measured 2026-10-07: the engine plays through it, `running`, events firing
|
|
38
|
+
after a 1.7 s load).
|
|
42
39
|
|
|
43
40
|
Strudel is AGPL-licensed. The app links to the engine at its own address the
|
|
44
41
|
way a browser links to any page, so the two programs stay separate:
|
|
@@ -63,6 +60,7 @@ beside the editor, while the last good pattern plays on.
|
|
|
63
60
|
```
|
|
64
61
|
App.jsx the interface: editor or grid, play and stop, saved patterns, the credit line
|
|
65
62
|
lib/strudel.js the loader, play(), stop(), the error hook, helpers that write mini-notation, EXAMPLES
|
|
63
|
+
lib/sfx.js the sound core's module, as it writes it: the loader takes its unlockAudio()
|
|
66
64
|
access.js who may publish a pattern to the shared gallery
|
|
67
65
|
seed.json three or four finished patterns so the first visit has something to press
|
|
68
66
|
```
|
|
@@ -79,6 +77,8 @@ delivers the message a bad pattern produces.
|
|
|
79
77
|
|
|
80
78
|
### `lib/strudel.js`
|
|
81
79
|
```js
|
|
80
|
+
import { unlockAudio } from "./sfx.js";
|
|
81
|
+
|
|
82
82
|
const ENGINE_URL = "https://esm.sh/@strudel/web@1.3.0";
|
|
83
83
|
const DRUM_KIT_URL = "https://cdn.jsdelivr.net/gh/tidalcycles/Dirt-Samples@master/strudel.json";
|
|
84
84
|
const DRUM_MACHINES_URL = "https://cdn.jsdelivr.net/gh/felixroos/dough-samples@main/tidal-drum-machines.json";
|
|
@@ -90,9 +90,8 @@ const listeners = new Set();
|
|
|
90
90
|
/** One fetch of the engine and the drum kit, however many times play is pressed. */
|
|
91
91
|
export function loadStrudel() {
|
|
92
92
|
enginePromise ??= (async () => {
|
|
93
|
-
// Runs inside the press that called play(): the
|
|
94
|
-
audioContext =
|
|
95
|
-
audioContext.resume();
|
|
93
|
+
// Runs inside the press that called play(): the sound core's gate, before the first await.
|
|
94
|
+
audioContext = unlockAudio();
|
|
96
95
|
const web = await import(ENGINE_URL);
|
|
97
96
|
web.setAudioContext(audioContext);
|
|
98
97
|
const repl = await web.initStrudel({
|
|
@@ -118,8 +117,8 @@ export function onPatternError(fn) {
|
|
|
118
117
|
* the `false` keeps the engine's own sound output in place beside the callback.
|
|
119
118
|
*/
|
|
120
119
|
export async function play(code, onEvent) {
|
|
121
|
-
// Still inside the press: a context the browser suspended while the tab was away
|
|
122
|
-
|
|
120
|
+
// Still inside the press: the gate re-checks a context the browser suspended while the tab was away.
|
|
121
|
+
unlockAudio();
|
|
123
122
|
const { web, repl } = await loadStrudel();
|
|
124
123
|
const pattern = await web.evaluate(code, false);
|
|
125
124
|
if (!pattern) return null;
|
|
@@ -651,8 +650,8 @@ the kits: `samples({ kick: "https://…/kick.wav", snare: "…" })` inside
|
|
|
651
650
|
|
|
652
651
|
Play is a large button near the top; nothing sounds until it is pressed. A
|
|
653
652
|
grid's steps are `IconButton`s whose label names the row, the step and its
|
|
654
|
-
state, and a tempo slider sits beside play rather than in a settings drawer. The
|
|
655
|
-
|
|
653
|
+
state, and a tempo slider sits beside play rather than in a settings drawer. The tap calls
|
|
654
|
+
`unlockAudio()` before anything awaits.
|
|
656
655
|
|
|
657
656
|
## Shapes a Strudel vibe takes
|
|
658
657
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const surfaceBoardConfig = {
|
|
2
|
+
name: "surface-board",
|
|
3
|
+
label: "Board surface",
|
|
4
|
+
description: "How a board, tile or card game looks: the board dressed in a material from the request's world, drawn by the skin",
|
|
5
|
+
menu: false,
|
|
6
|
+
rail: "reskin",
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=surface-board.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface-board.js","sourceRoot":"","sources":["../../jsr/llms/surface-board.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,mHAAmH;IAChI,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,QAAQ;CACf,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Board surface — how a board, tile or card game looks
|
|
2
|
+
|
|
3
|
+
Loaded with the board-games skill, which holds the rules, the seeds, the turns and the access
|
|
4
|
+
shapes. This doc is the board's look: the material it is dressed in, and the skin it is drawn with.
|
|
5
|
+
|
|
6
|
+
## Dress the board in the game's world
|
|
7
|
+
|
|
8
|
+
A board in plain rounded rectangles plays fine and looks like a spreadsheet. Before drawing, pick **one physical thing from the request's world** that a player would recognise on a real table, and let it decide four parts of the board: the frame, the column header, what a mark looks like, and how a win shows. Everything but the material's own colour stays in the theme's token classes, so the dressing restyles with the palette.
|
|
9
|
+
|
|
10
|
+
**Choose the material from the request, in this order:**
|
|
11
|
+
|
|
12
|
+
1. **The request's own subject.** A rollerblade club's bingo marks squares with skate wheels; a baby-shower bingo uses pacifiers or footprints; a road trip uses licence plates; a bird walk uses binocular rings; a wine night uses glass rings.
|
|
13
|
+
2. **The game's classic table.** Bingo is a paper card with a dauber; checkers are poker chips on felt; chess is an inlaid wood board; word tiles are wooden letter tiles; sudoku is pencil on graph paper; mancala is seeds in carved pits; memory is a deck of card backs; a trivia board is a TV game-show wall.
|
|
14
|
+
3. **The look the app already has.** When neither gives a strong picture, the board takes the shapes of the room's own components (its radius, its ledge shadow, its type).
|
|
15
|
+
|
|
16
|
+
**Then dress the four parts:**
|
|
17
|
+
|
|
18
|
+
- **Frame.** The material's edge: a ruled paper card with an ink border (`stroke-foreground`), a felt table (`fill-muted`), an inlaid border, a game-show wall with gaps between panels.
|
|
19
|
+
- **Header.** A bingo card's five column letters can spell a word from the theme instead of B-I-N-G-O: SKATE for a skate club, BIRDS for a bird walk, ROADS for a road trip. A header with exactly as many letters as columns reads as part of the card.
|
|
20
|
+
- **Mark.** The thing a real player puts down: a dauber blot, a wheel, a sticker, a chip, a pencil cross. The words underneath stay readable, so a mark is translucent (`opacity-60`) or the text flips to `fill-primary-foreground` on a solid mark. A mark animates once when it lands (a scale or a quarter turn, 150–500 ms) and stays put under `motion-reduce:transition-none`.
|
|
21
|
+
- **Win.** The table's own celebration: a stroke drawn through the line, the winning marks changing colour together, a game-show panel flip. The win line is `stroke-accent` drawn over the marks.
|
|
22
|
+
|
|
23
|
+
**Two dressed bingo cards** (the board-games skill's `BingoBoard`, with a different cell and frame):
|
|
24
|
+
|
|
25
|
+
- **Dauber on paper.** Cells are square `<rect>`s with no gaps and `stroke-foreground` rules; a dark header band carries the theme word. A mark is a slightly lumpy blot — a `<path>` circle with uneven radii, rotated a little per cell from the seed — in `fill-primary opacity-60`, drawn above the cell and below the text.
|
|
26
|
+
- **Skate wheels** (or any round token: chips, caps, coins). Each cell is a `<circle>` in `fill-muted`; a marked cell fills `fill-foreground` with `fill-background` text and gains a dashed tread ring (`stroke-primary`, `strokeDasharray="6 5"`) that turns half a turn as it lands. The free centre is the hub, in `fill-accent`.
|
|
27
|
+
|
|
28
|
+
```jsx
|
|
29
|
+
// A dauber blot and a wheel, each one cell of a 100-unit grid centred on (cx, cy).
|
|
30
|
+
function Blot({ cx, cy, turn }) {
|
|
31
|
+
return <path d={`M ${cx - 36} ${cy} q 2 -38 38 -37 q 37 3 35 39 q -3 34 -38 35 q -37 -2 -35 -37 z`} transform={`rotate(${turn} ${cx} ${cy})`} className="fill-primary opacity-60 transition-transform duration-200 motion-reduce:transition-none" />;
|
|
32
|
+
}
|
|
33
|
+
function Wheel({ cx, cy, on }) {
|
|
34
|
+
// Drawn round (0, 0) inside a translated group, so a CSS rotate turns the ring about its own centre.
|
|
35
|
+
return (
|
|
36
|
+
<g transform={`translate(${cx} ${cy})`}>
|
|
37
|
+
<circle r="44" className={on ? "fill-foreground" : "fill-muted"} />
|
|
38
|
+
{/* Always mounted, so marking changes the rotation and the transition has a "from". */}
|
|
39
|
+
<circle r="44" fill="none" strokeWidth="5" strokeDasharray="6 5" className={`stroke-primary transition duration-500 motion-reduce:transition-none ${on ? "rotate-180 opacity-100" : "rotate-0 opacity-0"}`} />
|
|
40
|
+
</g>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**The same move on other boards:** checkers as poker chips (two concentric `<circle>`s with a dashed edge stripe); a word-guess as wooden tiles (a `<rect>` with a lighter top edge, letters in the display face); sudoku as graph paper (thin `stroke-border` rules, thick box rules, entries in a handwritten-looking face and givens in the body face); memory as a deck (a card back with a pattern drawn from the deck's seed, flipped with a `scaleX` transition); mancala as carved pits (an ellipse with an inner shadow ring and seeds as small circles scattered from the seed).
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Board surface — the board is the app
|
|
49
|
+
|
|
50
|
+
On a board game the board is the thing people came for, so the look's components only frame it: the title, a `Stat` or `Badge` for the score and the turn, `Button`s for New game / Undo / Share, a `Dialog` for the win. Taste goes into the board itself — its material, tiles, pieces, texture and motion — and a board drawn from `Card`s, `RowCard`s or one `IconButton` per square reads as an admin screen, whatever the palette.
|
|
51
|
+
|
|
52
|
+
On an app built from the UI's components (the default look or any look on its surface) the board takes the `reskin` technique, even when the person never asked for a look:
|
|
53
|
+
|
|
54
|
+
- **One wrapper.** The app renders inside a root `<div data-reskin>` with `<style>{SKIN}</style>` as its first child, `SKIN` one module-level CSS string. A later "make it look like a 1970s wooden set" then lands in the same place.
|
|
55
|
+
- **Colour from the look's tokens.** The board's CSS reads `var(--surface)`, `var(--ink)`, `var(--purple)`, `var(--up)`, `var(--down)` and `var(--r-card)`, so the Look tab and a reskin restyle the board with the chrome. The material is the exception: a material the person named, or the game's classic table (walnut and maple inlay, green felt, slate), is that material's own colour, set once as a token on the wrapper (`--felt: #2f6b4f;`, `--wood-light: #e2c296; --wood-dark: #8b5a34;`) and read from there. A look token never stands in for a named material, so an inlaid wood board is wood on every look.
|
|
56
|
+
- **Plain elements for tiles and pieces.** The board is SVG or a CSS grid of `div`s with the app's own class names (`.board`, `.sq`, `.sq--dark`, `.piece`), each cell a `<g role="button">` or `div role="button" tabIndex={0}` as the board-games skill draws them. They take classes freely; the look's components never do.
|
|
57
|
+
- **Texture and motion on the board, capture-safe.** Grain or felt is a gradient on `.board`; a piece slides with a `transform` transition and lands once; the first frame is already a full board.
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
import React, { useState } from "react";
|
|
61
|
+
import { Badge, Button, Heading, Row, Stack } from "@vibes.diy/ui";
|
|
62
|
+
|
|
63
|
+
const SKIN = `
|
|
64
|
+
[data-reskin], body:has([data-reskin]) { --felt: #2f6b4f; }
|
|
65
|
+
[data-reskin] .board { display: grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr); width: min(100%, 28rem); aspect-ratio: 1;
|
|
66
|
+
padding: 10px; border-radius: var(--r-card); background: var(--ink); touch-action: manipulation; user-select: none; }
|
|
67
|
+
[data-reskin] .sq { display: grid; place-items: center; background: var(--surface); }
|
|
68
|
+
[data-reskin] .sq--dark { background: repeating-linear-gradient(135deg, var(--felt) 0 3px, color-mix(in srgb, var(--felt) 88%, var(--ink)) 3px 6px); }
|
|
69
|
+
[data-reskin] .piece { width: 76%; aspect-ratio: 1; border-radius: 50%; border: 3px dashed color-mix(in srgb, var(--surface) 60%, transparent);
|
|
70
|
+
box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 45%, transparent); transition: transform 180ms ease; }
|
|
71
|
+
[data-reskin] .piece--red { background: var(--down); }
|
|
72
|
+
[data-reskin] .piece--black { background: var(--ink); border-color: var(--text-secondary); }
|
|
73
|
+
[data-reskin] .sq[aria-pressed="true"] .piece { transform: translateY(-4px) scale(1.06); }
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
const START = Array.from({ length: 64 }, (_, i) => {
|
|
77
|
+
const dark = (Math.floor(i / 8) + i) % 2 === 1;
|
|
78
|
+
return !dark ? null : i < 24 ? "black" : i >= 40 ? "red" : null;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export default function App() {
|
|
82
|
+
const [cells, setCells] = useState(START);
|
|
83
|
+
const [held, setHeld] = useState(-1);
|
|
84
|
+
const [turn, setTurn] = useState("red");
|
|
85
|
+
|
|
86
|
+
// Any empty square takes the held piece here; a real game asks legalMoves(state) first (below).
|
|
87
|
+
function tap(i) {
|
|
88
|
+
if (cells[i] === turn) return setHeld(i);
|
|
89
|
+
if (held < 0 || cells[i] !== null) return;
|
|
90
|
+
setCells(cells.map((c, j) => (j === i ? turn : j === held ? null : c)));
|
|
91
|
+
setHeld(-1);
|
|
92
|
+
setTurn(turn === "red" ? "black" : "red");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function newGame() {
|
|
96
|
+
setCells(START);
|
|
97
|
+
setHeld(-1);
|
|
98
|
+
setTurn("red");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div data-reskin>
|
|
103
|
+
<style>{SKIN}</style>
|
|
104
|
+
<Stack gap={4}>
|
|
105
|
+
<Row gap={2} align="center">
|
|
106
|
+
<Heading level={1}>Checkers</Heading>
|
|
107
|
+
<Badge tone={turn === "red" ? "down" : "idle"}>{turn} to move</Badge>
|
|
108
|
+
</Row>
|
|
109
|
+
<div className="board" role="group" aria-label="Checkers board">
|
|
110
|
+
{cells.map((c, i) => (
|
|
111
|
+
<div
|
|
112
|
+
key={i}
|
|
113
|
+
role="button"
|
|
114
|
+
tabIndex={0}
|
|
115
|
+
aria-label={`Square ${i + 1}${c ? `, ${c}` : ""}`}
|
|
116
|
+
aria-pressed={held === i}
|
|
117
|
+
className={(Math.floor(i / 8) + i) % 2 === 1 ? "sq sq--dark" : "sq"}
|
|
118
|
+
onClick={() => tap(i)}
|
|
119
|
+
onKeyDown={(e) => {
|
|
120
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
tap(i);
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
{c && <span className={`piece piece--${c}`} />}
|
|
126
|
+
</div>
|
|
127
|
+
))}
|
|
128
|
+
</div>
|
|
129
|
+
<Row gap={2}>
|
|
130
|
+
<Button variant="quiet" onClick={newGame}>
|
|
131
|
+
New game
|
|
132
|
+
</Button>
|
|
133
|
+
</Row>
|
|
134
|
+
</Stack>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The rule functions, seeds and access shapes are the board-games skill's; this is only where the board's look lives. The same move covers a puzzle grid, a card table (a `.table` in felt, `.card` faces as plain elements) and the HUD around a canvas or voxel world, where the canvas is the board and the components are the frame.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const surfacePlayAreaConfig = {
|
|
2
|
+
name: "surface-play-area",
|
|
3
|
+
needs: ["canvas-theme-colors"],
|
|
4
|
+
label: "Play area surface",
|
|
5
|
+
description: "A full-screen game wears the app's look: sky, fog, light, player and lane lines painted from the theme tokens, a day/night cycle between look colours, and the HUD as kit components on the look's surfaces.",
|
|
6
|
+
menu: false,
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=surface-play-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface-play-area.js","sourceRoot":"","sources":["../../jsr/llms/surface-play-area.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,qBAAqB,GAAc;IAC9C,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE,CAAC,qBAAqB,CAAC;IAC9B,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EACT,8MAA8M;IAChN,IAAI,EAAE,KAAK;CACZ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Surface: the play area — the look reaches a full-screen game
|
|
2
|
+
|
|
3
|
+
The look reaches the play area: the canvas paints with the app's own tokens, and the HUD over it is the kit's components on the look's surfaces.
|
|
4
|
+
|
|
5
|
+
A full-screen game is judged by its first screenshot, and that screenshot is mostly canvas. The
|
|
6
|
+
world, the overlays, the hotbar and the buttons all speak the look, so the game reads as the
|
|
7
|
+
same crafted app as everything else the person made.
|
|
8
|
+
|
|
9
|
+
**The world takes the look's colours.** Resolve the theme tokens to concrete colours once per
|
|
10
|
+
mount and paint every large area from them: the sky or backdrop from `--background` leaned toward
|
|
11
|
+
`--primary`, fog from the same colour so the horizon melts into it, the light from `--primary`
|
|
12
|
+
over `--surface`, the player and the thing to chase in `--primary` and `--accent`, guides and lane
|
|
13
|
+
lines in `--border`, and text drawn on the canvas in `--text-primary`. A game's own materials (a
|
|
14
|
+
voxel world's block table, a racer's track paint) keep their names and colours; the look owns
|
|
15
|
+
everything around them.
|
|
16
|
+
|
|
17
|
+
The colours come from `lib/look.js` (the canvas theme colours above): `readLook(host)` gives
|
|
18
|
+
`backdrop`, `surface`, `lead`, `accent`, `ink` and `line` as opaque hex, and `watchLook` repaints
|
|
19
|
+
on a restyle.
|
|
20
|
+
|
|
21
|
+
Read the look inside the effect that builds the scene, and call `watchLook` in the same effect
|
|
22
|
+
with its cleanup, so a restyle recolours the world in place (keep the sky, light and materials
|
|
23
|
+
in one `paint(look)` it runs at mount and on every change):
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const look = readLook(containerRef.current);
|
|
27
|
+
const sky = new THREE.Color(look.backdrop).lerp(new THREE.Color(look.lead), 0.2);
|
|
28
|
+
scene.background = sky;
|
|
29
|
+
scene.fog = new THREE.Fog(sky, 40, 120);
|
|
30
|
+
scene.add(new THREE.HemisphereLight(look.lead, look.surface, 0.9));
|
|
31
|
+
const sun = new THREE.DirectionalLight(look.surface, 1.4);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
A day/night cycle blends between two look colours (`backdrop` toward `lead` by day, toward `ink`
|
|
35
|
+
by night), so every hour of the day still belongs to the app.
|
|
36
|
+
|
|
37
|
+
**The HUD is the kit, on the look's surfaces.** Everything drawn over the world is a component
|
|
38
|
+
from `@vibes.diy/ui`, so it brings the look's type, radius, border and weight with it:
|
|
39
|
+
|
|
40
|
+
- The title sits in a `Heading` on a `Card` (or a `Row` on `bg-surface`) at full ink, so it reads
|
|
41
|
+
over a bright sky or a dark cave alike.
|
|
42
|
+
- Score and best are `Metric`s on a `Card`; a timer or lap count is one more `Metric`.
|
|
43
|
+
- The hotbar is a `Row` of `IconButton`s on a `Card`: the selected slot carries `tint` with the
|
|
44
|
+
active colour and `aria-pressed`, the rest stay `variant="quiet"`.
|
|
45
|
+
- Start, pause and game-over screens are a `Card` or `Dialog` with a `Heading`, one lead `Button`
|
|
46
|
+
and a quiet second action.
|
|
47
|
+
- Overlay text keeps the look's own foreground and muted tones at full opacity; a scrim behind it
|
|
48
|
+
comes from `bg-background` or `bg-surface`.
|
|
49
|
+
|
|
50
|
+
Read the first screenshot before you finish: the sky, the ground, the HUD and the title should
|
|
51
|
+
look like they came from the app's palette and type, the way its list pages do.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const surfacePresenceConfig = {
|
|
2
|
+
name: "surface-presence",
|
|
3
|
+
label: "Presence surface",
|
|
4
|
+
description: "How a live room shows its people: overlapping avatar faces at the top right, a live 'N here' count, " +
|
|
5
|
+
"an Invite button that copies the room's link, and other people's cursors and selected cells in their own theme colour.",
|
|
6
|
+
menu: false,
|
|
7
|
+
rail: "reskin",
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=surface-presence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface-presence.js","sourceRoot":"","sources":["../../jsr/llms/surface-presence.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,qBAAqB,GAAc;IAC9C,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,kBAAkB;IACzB,WAAW,EACT,sGAAsG;QACtG,wHAAwH;IAC1H,IAAI,EAAE,KAAK;IAEX,IAAI,EAAE,QAAQ;CACf,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Presence surface — who is here, where they are, and the way in
|
|
2
|
+
|
|
3
|
+
People who share a live space expect the same four signs they know from Figma,
|
|
4
|
+
Google Docs and Discord, in the same places:
|
|
5
|
+
|
|
6
|
+
1. **Faces in the top corner.** A row of overlapping round avatars at the
|
|
7
|
+
right end of the room's header, newest last, at most four, then a `+N`.
|
|
8
|
+
Tapping a face opens that person's profile.
|
|
9
|
+
2. **A live count.** "3 here" beside the faces with a small live dot, and "Just
|
|
10
|
+
you" when nobody else has arrived, so an empty room reads as waiting rather
|
|
11
|
+
than broken.
|
|
12
|
+
3. **The invite next to them.** One quiet "Invite" button at the end of the
|
|
13
|
+
row copies the room's link; its label turns to "Link copied" for two seconds.
|
|
14
|
+
4. **Where each person is.** On a shared board or canvas, each other person's
|
|
15
|
+
pointer or selected cell is drawn in their own colour with their handle, the
|
|
16
|
+
way a Docs cursor carries a name flag. Your own pointer is never drawn.
|
|
17
|
+
|
|
18
|
+
## The bar
|
|
19
|
+
|
|
20
|
+
The faces are the platform's `ViewerTag`, which resolves each avatar from the
|
|
21
|
+
handle and paints from the look's palette variables on every look. The count
|
|
22
|
+
and the invite are the kit's `Badge`, `Dot` and `Button`, so the bar follows
|
|
23
|
+
the app's room, its reskin and its type with nothing of its own to restyle.
|
|
24
|
+
|
|
25
|
+
### `lib/here.jsx`
|
|
26
|
+
```jsx
|
|
27
|
+
import React from "react";
|
|
28
|
+
import { ViewerTag } from "use-vibes";
|
|
29
|
+
import { Badge, Button, Dot, Row, Text } from "@vibes.diy/ui";
|
|
30
|
+
|
|
31
|
+
/** Everyone in `people` ({ handle, isMe }); `onInvite` copies the room's link. */
|
|
32
|
+
export function HereBar({ people, onInvite, onOpenProfile }) {
|
|
33
|
+
const [copied, setCopied] = React.useState(false);
|
|
34
|
+
const others = people.filter((p) => !p.isMe);
|
|
35
|
+
const shown = people.slice(0, 4);
|
|
36
|
+
const more = people.length - shown.length;
|
|
37
|
+
async function invite() {
|
|
38
|
+
await onInvite();
|
|
39
|
+
setCopied(true);
|
|
40
|
+
setTimeout(() => setCopied(false), 2000);
|
|
41
|
+
}
|
|
42
|
+
return (
|
|
43
|
+
<Row justify="end" align="center" gap="2">
|
|
44
|
+
<Row align="center">
|
|
45
|
+
{shown.map((p, i) => (
|
|
46
|
+
<ViewerTag
|
|
47
|
+
key={p.handle}
|
|
48
|
+
userHandle={p.handle}
|
|
49
|
+
size={28}
|
|
50
|
+
avatarOnly
|
|
51
|
+
className={i > 0 ? "-ml-2" : undefined}
|
|
52
|
+
onClick={onOpenProfile ? () => onOpenProfile(p.handle) : undefined}
|
|
53
|
+
/>
|
|
54
|
+
))}
|
|
55
|
+
</Row>
|
|
56
|
+
{more > 0 && <Badge tone="idle">+{more}</Badge>}
|
|
57
|
+
<Row align="center" gap="1">
|
|
58
|
+
<Dot tone={others.length > 0 ? "up" : "idle"} />
|
|
59
|
+
<Text size="sm" muted>{others.length > 0 ? `${people.length} here` : "Just you"}</Text>
|
|
60
|
+
</Row>
|
|
61
|
+
{onInvite && (
|
|
62
|
+
<Button size="sm" variant="quiet" onClick={invite}>{copied ? "Link copied" : "Invite"}</Button>
|
|
63
|
+
)}
|
|
64
|
+
</Row>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- **Place it once, at the top right of the room** (the header row of a board,
|
|
70
|
+
the thread header of a chat, a corner of the HUD over a 3D world). On a phone
|
|
71
|
+
the row stays one line: faces first, the count shortens to the number.
|
|
72
|
+
- **A person's colour is chosen once from their handle** and used for their
|
|
73
|
+
cursor, their selection ring and any name flag, so the same person reads the
|
|
74
|
+
same everywhere in the room. Pick from the theme's own fills, never a hex:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
const PERSON_FILLS = ["fill-primary", "fill-accent", "fill-success", "fill-warning"];
|
|
78
|
+
const PERSON_STROKES = ["stroke-primary", "stroke-accent", "stroke-success", "stroke-warning"];
|
|
79
|
+
const hue = (handle) => [...handle].reduce((h, c) => (h * 31 + c.charCodeAt(0)) >>> 0, 0) % PERSON_FILLS.length;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Cursors and selections
|
|
83
|
+
|
|
84
|
+
A cursor rides the person's presence state as board coordinates
|
|
85
|
+
(`{ x, y }` in the board's own `viewBox` units, or `{ cell: "r2c3" }`), never
|
|
86
|
+
screen pixels, so it lands on the same spot on every screen size. Draw the
|
|
87
|
+
other people over the board in the same SVG, after the board so it sits on
|
|
88
|
+
top, with `pointer-events-none` so it never steals a tap:
|
|
89
|
+
|
|
90
|
+
```jsx
|
|
91
|
+
<g className="pointer-events-none">
|
|
92
|
+
{people.filter((p) => !p.isMe && p.state).map((p) =>
|
|
93
|
+
p.state.cell ? (
|
|
94
|
+
<rect key={p.handle} {...cellBox(p.state.cell)} rx="2" className={`fill-none ${PERSON_STROKES[hue(p.handle)]}`} strokeWidth="1.5" />
|
|
95
|
+
) : (
|
|
96
|
+
<g key={p.handle} transform={`translate(${p.state.x} ${p.state.y})`}>
|
|
97
|
+
<path d="M0 0 L0 9 L2.5 6.5 L5 11 L6.5 10 L4 5.5 L7.5 5.5 Z" className={`${PERSON_FILLS[hue(p.handle)]} stroke-background`} strokeWidth="0.6" />
|
|
98
|
+
<text x="8" y="12" fontSize="4" className={PERSON_FILLS[hue(p.handle)]}>{p.handle}</text>
|
|
99
|
+
</g>
|
|
100
|
+
)
|
|
101
|
+
)}
|
|
102
|
+
</g>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- Update the pointer from `onPointerMove` into the presence state ref (the
|
|
106
|
+
board's `getScreenCTM().inverse()` turns a pointer into `viewBox` units); the
|
|
107
|
+
heartbeat sends it. Clear it to `null` on `onPointerLeave`.
|
|
108
|
+
- A person whose state goes quiet fades after a few seconds rather than staying
|
|
109
|
+
pinned where they last pointed; the bar keeps their face until they leave.
|
|
110
|
+
- A 3D world draws other people as figures in the scene from the same state;
|
|
111
|
+
the bar still sits over the HUD.
|
|
112
|
+
|
|
113
|
+
## On a look without the kit
|
|
114
|
+
|
|
115
|
+
An app in the person's own style draws the same three parts with its own
|
|
116
|
+
elements: the `ViewerTag` row unchanged, the count as a small label with a dot
|
|
117
|
+
in the theme's success colour, and the invite as the app's quiet button. The
|
|
118
|
+
places and the words stay the same.
|
package/llms/three-js.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const threeJsConfig = {
|
|
2
2
|
name: "three-js",
|
|
3
3
|
label: "Three.js",
|
|
4
|
-
description: "Three.js 3D graphics library for WebGL rendering: mesh geometry, materials, lighting, animation, cameras, textures, GLSL shaders, GLTF/OBJ/FBX model loading, physics, particle systems, post-processing, visual effects, 3js. Anything played or steered also loads touch-games for phone controls",
|
|
4
|
+
description: "Three.js 3D graphics library for WebGL rendering: mesh geometry, materials, lighting, animation, cameras, textures, GLSL shaders, GLTF/OBJ/FBX model loading, physics, particle systems, post-processing, visual effects, 3js. Anything played or steered also loads touch-games for phone controls; a place the person walks through as a player (a garden, house, museum or cave, first-person) also loads world-controls, and a model turned, spun or orbited on its own (a product viewer, a globe) stays three-js",
|
|
5
5
|
cues: ["3d", "three.js", "threejs", "3js", "webgl", "shader", "shaders", "mesh", "gltf", "3d model", "3d scene"],
|
|
6
6
|
importModule: "three",
|
|
7
7
|
importName: "THREE",
|
package/llms/three-js.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three-js.js","sourceRoot":"","sources":["../../jsr/llms/three-js.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"three-js.js","sourceRoot":"","sources":["../../jsr/llms/three-js.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,WAAW,EACT,wfAAwf;IAC1f,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC;IAChH,YAAY,EAAE,OAAO;IACrB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,WAAW;CACxB,CAAC"}
|
package/llms/three-js.md
CHANGED
|
@@ -95,7 +95,7 @@ title, settings, scores, sharing and every other panel live behind **one** menu
|
|
|
95
95
|
top-right corner (`IconButton`, never the bottom-right, which the platform owns) that toggles an
|
|
96
96
|
overlay — see the Sky Glider example below. The game stays in view the moment the overlay closes.
|
|
97
97
|
|
|
98
|
-
The lens follows the screen:
|
|
98
|
+
The lens follows the screen: set the camera's aspect from the canvas on every resize, and widen the view on a phone held upright (a walked world gets both from `world-controls`).
|
|
99
99
|
An overview camera that orbits the scene keeps its own distance: scale the radius by
|
|
100
100
|
`0.36 / (tan(fov / 2) · aspect)`, clamped to 1–2.2×, so the whole scene stays in frame upright.
|
|
101
101
|
|
|
@@ -125,7 +125,7 @@ those touches to the scene with `select-none touch-none` on the mount `<div>` /
|
|
|
125
125
|
on the container that holds the HUD and labels. `OrbitControls` already speaks pointer events and
|
|
126
126
|
receives the drag once its element is `touch-none`.
|
|
127
127
|
|
|
128
|
-
- A world you move through — walked, explored, flown around — calls `useWorldControls` from `use-vibes`, taught in the `
|
|
128
|
+
- A world you move through — walked, explored, flown around — calls `useWorldControls` from `use-vibes`, taught in the `world-controls` skill: left thumb walks, right thumb looks, tap acts, and a click-to-play overlay carries the desktop.
|
|
129
129
|
- A flyer or a car that charges forward calls for hold + steer from the `touch-games` skill: thumb down is the throttle and its offset steers.
|
|
130
130
|
|
|
131
131
|
## Core Setup
|
|
@@ -1257,7 +1257,6 @@ Structure your component in this order:
|
|
|
1257
1257
|
import React, { useState, useEffect, useRef, useCallback } from "react";
|
|
1258
1258
|
import { useFireproof } from "use-fireproof";
|
|
1259
1259
|
import * as THREE from "three";
|
|
1260
|
-
import { useWorldControls } from "use-vibes";
|
|
1261
1260
|
import { Card, Heading, IconButton, Stack, Text } from "@vibes.diy/ui";
|
|
1262
1261
|
|
|
1263
1262
|
export default function SkyGlider() {
|
|
@@ -1278,6 +1277,7 @@ export default function SkyGlider() {
|
|
|
1278
1277
|
score: 0,
|
|
1279
1278
|
gameRunning: false,
|
|
1280
1279
|
stick: { x: 0, y: 0 },
|
|
1280
|
+
held: new Set(),
|
|
1281
1281
|
velocity: { x: 0, y: 0, z: 0 },
|
|
1282
1282
|
heading: 0,
|
|
1283
1283
|
forwardSpeed: 0,
|
|
@@ -1288,17 +1288,47 @@ export default function SkyGlider() {
|
|
|
1288
1288
|
const [currentScore, setCurrentScore] = useState(0);
|
|
1289
1289
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
1290
1290
|
|
|
1291
|
-
//
|
|
1292
|
-
//
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1291
|
+
// Hold + steer, the flyer's scheme (the touch-games skill has it in full): thumb down thrusts,
|
|
1292
|
+
// and its offset from where it landed banks and pitches. One pointer path for finger, pen and
|
|
1293
|
+
// mouse; on a keyboard WASD or the arrows steer and Space thrusts.
|
|
1294
|
+
useEffect(() => {
|
|
1295
|
+
const root = rootRef.current;
|
|
1296
|
+
const { stick, held } = gameStateRef.current;
|
|
1297
|
+
let thumb = null;
|
|
1298
|
+
const down = (e) => {
|
|
1299
|
+
if (e.target.closest("button")) return; // the HUD's own buttons keep their presses
|
|
1300
|
+
root.setPointerCapture(e.pointerId);
|
|
1301
|
+
thumb = { id: e.pointerId, x: e.clientX, y: e.clientY };
|
|
1302
|
+
held.add("Space");
|
|
1303
|
+
};
|
|
1304
|
+
const move = (e) => {
|
|
1305
|
+
if (thumb?.id !== e.pointerId) return;
|
|
1306
|
+
const reach = (d) => Math.max(-1, Math.min(1, d / 60)); // 60px of offset is full deflection
|
|
1307
|
+
Object.assign(stick, { x: reach(e.clientX - thumb.x), y: reach(e.clientY - thumb.y) });
|
|
1308
|
+
};
|
|
1309
|
+
const up = (e) => {
|
|
1310
|
+
if (thumb?.id !== e.pointerId) return;
|
|
1311
|
+
thumb = null;
|
|
1312
|
+
held.delete("Space");
|
|
1313
|
+
Object.assign(stick, { x: 0, y: 0 });
|
|
1314
|
+
};
|
|
1315
|
+
const keyDown = (e) => !e.repeat && held.add(e.code);
|
|
1316
|
+
const keyUp = (e) => held.delete(e.code);
|
|
1317
|
+
root.addEventListener("pointerdown", down);
|
|
1318
|
+
root.addEventListener("pointermove", move);
|
|
1319
|
+
root.addEventListener("pointerup", up);
|
|
1320
|
+
root.addEventListener("pointercancel", up);
|
|
1321
|
+
window.addEventListener("keydown", keyDown);
|
|
1322
|
+
window.addEventListener("keyup", keyUp);
|
|
1323
|
+
return () => {
|
|
1324
|
+
root.removeEventListener("pointerdown", down);
|
|
1325
|
+
root.removeEventListener("pointermove", move);
|
|
1326
|
+
root.removeEventListener("pointerup", up);
|
|
1327
|
+
root.removeEventListener("pointercancel", up);
|
|
1328
|
+
window.removeEventListener("keydown", keyDown);
|
|
1329
|
+
window.removeEventListener("keyup", keyUp);
|
|
1330
|
+
};
|
|
1331
|
+
}, []);
|
|
1302
1332
|
const { docs: scoreData } = useLiveQuery("type", { key: "score" }) || {
|
|
1303
1333
|
docs: [],
|
|
1304
1334
|
};
|
|
@@ -1552,6 +1582,8 @@ export default function SkyGlider() {
|
|
|
1552
1582
|
const state = gameStateRef.current;
|
|
1553
1583
|
if (!state.renderer) return;
|
|
1554
1584
|
state.renderer.setSize(window.innerWidth, window.innerHeight);
|
|
1585
|
+
state.camera.aspect = window.innerWidth / window.innerHeight;
|
|
1586
|
+
state.camera.updateProjectionMatrix();
|
|
1555
1587
|
}, []);
|
|
1556
1588
|
|
|
1557
1589
|
const updateGame = useCallback((dt) => {
|
|
@@ -1559,11 +1591,13 @@ export default function SkyGlider() {
|
|
|
1559
1591
|
if (!state.gameRunning || !state.glider) return;
|
|
1560
1592
|
|
|
1561
1593
|
const { stick, held, glider } = state;
|
|
1562
|
-
|
|
1594
|
+
const key = (a, b) => (held.has(a) || held.has(b) ? 1 : 0);
|
|
1595
|
+
const steerX = key("KeyD", "ArrowRight") - key("KeyA", "ArrowLeft") || stick.x;
|
|
1596
|
+
const steerY = key("KeyS", "ArrowDown") - key("KeyW", "ArrowUp") || stick.y;
|
|
1563
1597
|
|
|
1564
|
-
// Controls: the
|
|
1565
|
-
state.heading -=
|
|
1566
|
-
state.pitch -=
|
|
1598
|
+
// Controls: the thumb's offset (or WASD) banks and pitches; a held thumb or Space thrusts
|
|
1599
|
+
state.heading -= steerX * 0.03;
|
|
1600
|
+
state.pitch -= steerY * 0.01; // forward on the stick (y < 0) climbs
|
|
1567
1601
|
if (held.has("Space")) state.forwardSpeed = Math.min(0.3, state.forwardSpeed + 0.005);
|
|
1568
1602
|
|
|
1569
1603
|
// Physics
|