@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/touch-games.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
export const touchGamesConfig = {
|
|
2
2
|
name: "touch-games",
|
|
3
|
+
needs: ["sound-core", "surface-play-area"],
|
|
3
4
|
label: "Touch games",
|
|
4
|
-
description: "Phone-first controls for
|
|
5
|
-
"
|
|
5
|
+
description: "Phone-first controls for every game played in real time, tapped or steered (a turn-based board, card or word game " +
|
|
6
|
+
"is board-games) — load it on its own for a tap game or a whack-a-mole grid, and beside three-js, voxel, physics, p5, " +
|
|
7
|
+
"worlds or ui-game for every other real-time game, 3D scene you move through, or canvas toy: the play area " +
|
|
6
8
|
"is the controller (select-none touch-none surface, Pointer Events with pointer capture), swipes that fire " +
|
|
7
9
|
"mid-move with chaining, tap vs swipe on one surface, a floating ghost stick under the thumb, hold-to-boost " +
|
|
8
|
-
"with drag steering, pull-back-and-release aiming, gesture trails and feedback,
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"platformer, arcade, one thumb, first-person, walk around, explore",
|
|
10
|
+
"with drag steering, pull-back-and-release aiming, gesture trails and feedback, sound effects on the core " +
|
|
11
|
+
"actions with a mute toggle, the world painted in the app's look, and keyboard twins for desktop. " +
|
|
12
|
+
"game, mobile game, tap game, whack-a-mole, reflex game, touch controls, swipe, joystick, runner, racer, flyer, " +
|
|
13
|
+
"shooter, snake, slingshot, platformer, arcade, flappy, one thumb",
|
|
13
14
|
cues: [
|
|
15
|
+
"whack-a-mole",
|
|
16
|
+
"whack a mole",
|
|
17
|
+
"tap game",
|
|
14
18
|
"swipe",
|
|
15
19
|
"touch controls",
|
|
16
20
|
"mobile game",
|
|
@@ -38,10 +42,6 @@ export const touchGamesConfig = {
|
|
|
38
42
|
"catapult",
|
|
39
43
|
"flappy",
|
|
40
44
|
"snake game",
|
|
41
|
-
"first-person",
|
|
42
|
-
"first person",
|
|
43
|
-
"walk around",
|
|
44
|
-
"explore",
|
|
45
45
|
],
|
|
46
46
|
};
|
|
47
47
|
//# sourceMappingURL=touch-games.js.map
|
package/llms/touch-games.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"touch-games.js","sourceRoot":"","sources":["../../jsr/llms/touch-games.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"touch-games.js","sourceRoot":"","sources":["../../jsr/llms/touch-games.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IAInB,KAAK,EAAE,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC1C,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,oHAAoH;QACpH,uHAAuH;QACvH,4GAA4G;QAC5G,4GAA4G;QAC5G,6GAA6G;QAC7G,2GAA2G;QAC3G,mGAAmG;QACnG,iHAAiH;QACjH,kEAAkE;IAKpE,IAAI,EAAE;QACJ,cAAc;QACd,cAAc;QACd,UAAU;QACV,OAAO;QACP,gBAAgB;QAChB,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,cAAc;QACd,aAAa;QACb,UAAU;QACV,QAAQ;QACR,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;QACT,YAAY;QACZ,gBAAgB;QAChB,SAAS;QACT,aAAa;QACb,aAAa;QACb,OAAO;QACP,SAAS;QACT,WAAW;QACX,SAAS;QACT,WAAW;QACX,UAAU;QACV,QAAQ;QACR,YAAY;KACb;CACF,CAAC"}
|
package/llms/touch-games.md
CHANGED
|
@@ -20,7 +20,7 @@ Three things make that true, and each has one home:
|
|
|
20
20
|
steers the game while nearby text stays put — no selection highlight, no copy callout, no
|
|
21
21
|
page scroll, no pinch zoom, no pull-to-refresh.
|
|
22
22
|
2. **One input path for every pointer.** Input runs on Pointer Events with `setPointerCapture` on one tracked `pointerId`, so mouse, pen and finger share one path.
|
|
23
|
-
A 3D world you walk through gets that path from `
|
|
23
|
+
A 3D world you walk through gets that path from the `world-controls` skill instead.
|
|
24
24
|
3. **The game says what it understood.** A short fading trail under the finger, plus an arrow,
|
|
25
25
|
ghost stick or aim line, so the player sees which gesture the game read.
|
|
26
26
|
|
|
@@ -33,7 +33,7 @@ Three things make that true, and each has one home:
|
|
|
33
33
|
| Flies or drives forward: a glider, a ship, a car | **Hold + steer** — thumb down = throttle, offset = steer | canyon flyer |
|
|
34
34
|
| Aims then commits: a launcher, golf, pool, basketball | **Pull back + release** | slingshot |
|
|
35
35
|
| Moves in steps AND has one action | **Flick + tap** on the same surface | snake with a dash |
|
|
36
|
-
| Walks or flies through a 3D world: a block world, a garden, a ruin to explore | **Walk + look** — `
|
|
36
|
+
| Walks or flies through a 3D world: a block world, a garden, a ruin to explore | **Walk + look** — the `world-controls` skill | first-person explorer |
|
|
37
37
|
|
|
38
38
|
A desktop visitor gets the same game: the mouse drives the same pointer path, and arrow keys /
|
|
39
39
|
WASD / Space call the same action functions the gestures call.
|
|
@@ -77,7 +77,7 @@ export default function App() {
|
|
|
77
77
|
pull starts.
|
|
78
78
|
- **One line of hint text** names the gestures in the HUD; that line is the whole tutorial.
|
|
79
79
|
- **HUD ink contrasts with what the canvas paints.** A neon game painted near-black needs light
|
|
80
|
-
HUD text: paint the canvas from the theme (`readLook`,
|
|
80
|
+
HUD text: paint the canvas from the theme (`readLook` from `lib/look.js`, as the worked example does) and
|
|
81
81
|
give the HUD a `Card` backing so the score reads on any frame.
|
|
82
82
|
- **Start on the first touch.** The touch that starts a run only starts it (it does not also
|
|
83
83
|
jump or dash); a tap restarts after game over, after a short grace period so a frantic swipe
|
|
@@ -162,265 +162,6 @@ the start point (~24px) cancels, and the ring says so. The thumb usually starts
|
|
|
162
162
|
third, so put the ground at about two-thirds of the screen height and leave room below it to
|
|
163
163
|
pull. Preview only part of the arc (about 0.85s of flight) so aiming stays a skill.
|
|
164
164
|
|
|
165
|
-
## Walk + look: move through a 3D world
|
|
166
|
-
|
|
167
|
-
A 3D world you walk, fly or look around in gets its controls from `useWorldControls` (from `use-vibes`), on phone and desktop alike. Hand it the root element and what each act means; the hook owns the gestures, keeps the root `touch-none`, and sizes the lens when you pass it the camera.
|
|
168
|
-
|
|
169
|
-
Left half walks: a floating stick appears under the thumb. Right half looks: drag to turn, and a finger held near the screen's edge keeps turning.
|
|
170
|
-
|
|
171
|
-
Tap acts on what is under the finger; press and hold is the second action; a quick upward flick on the look side jumps.
|
|
172
|
-
|
|
173
|
-
- **The jump is judged as the finger lifts**, and the flick's up/down look is held back, so the
|
|
174
|
-
camera stays level through every jump.
|
|
175
|
-
- **`mode: "player"`** walks, looks and flicks; **`mode: "free"`** orbits a camera that zooms
|
|
176
|
-
with a pinch or the mouse wheel (`onPinch(factor)`, under 1 zooms in). With `flying: true`, a
|
|
177
|
-
flick down (`onFlick("down")`) sinks.
|
|
178
|
-
- **The callbacks speak screen sense.** `onMove(x, y)` is the walk vector with forward at `y < 0`;
|
|
179
|
-
`onLook(dx, dy)` and `onTurn(yaw, pitch)` arrive in radians, applied the same way; `onTap`,
|
|
180
|
-
`onHold` and `onAim` carry client coordinates.
|
|
181
|
-
- **Call `tick(dt)` once per frame** from the animation loop; the edge turn, the hold timer and
|
|
182
|
-
the finger trail advance on that clock, and `keys` holds every key code down right now.
|
|
183
|
-
- **The lens follows the screen.** Pass the `THREE.PerspectiveCamera` as `camera` and the hook
|
|
184
|
-
keeps its aspect current and widens the view on a phone held upright.
|
|
185
|
-
- **HUD controls live inside the root.** A press on a button, input or link there is that
|
|
186
|
-
control's own and never a world tap; mark any other piece that keeps its own touches (a slider,
|
|
187
|
-
a chip row) with `data-world-controls-ignore`.
|
|
188
|
-
|
|
189
|
-
A 🎥 button outside the menu cycles the views; on a phone the world opens in a free-cam overview that frames the whole scene. The views are **Free cam → First person → Shoulder view**; a desktop visitor opens in first person.
|
|
190
|
-
The overview's distance is the app's: scale the orbit radius by
|
|
191
|
-
`0.36 / (tan(fov / 2) · aspect)`, clamped to 1–2.2×, each frame, so a phone held upright still
|
|
192
|
-
frames the whole scene.
|
|
193
|
-
|
|
194
|
-
The one-line hint follows the current view.
|
|
195
|
-
|
|
196
|
-
The ☰ menu holds everything else, in this order: the views by name, fullscreen, how to play,
|
|
197
|
-
who else is here and what they did lately (players and activity), then invite a friend and all
|
|
198
|
-
worlds. Every world's menu carries the first three: the views, a Fullscreen entry that fills the
|
|
199
|
-
phone with the world (`requestFullscreen()` on the root, from the tap itself), and a How to play
|
|
200
|
-
entry that keeps the gestures one tap away after the hint has moved on.
|
|
201
|
-
|
|
202
|
-
**The desktop twin is the same world.** In the player views a click-to-play overlay calls
|
|
203
|
-
`requestLock()`, so the mouse looks under pointer lock; WASD or the arrows walk and Space jumps.
|
|
204
|
-
The V key cycles the views just as the 🎥 button does, once per press, and the overlay's control legend names it (`V views`).
|
|
205
|
-
`locked` reports the lock, so the overlay comes back when the player presses Esc, and `isTouch`
|
|
206
|
-
keeps the overlay off phones. While locked, a click under the crosshair is the tap and a
|
|
207
|
-
right-click is the hold (`onTap` / `onHold` at the screen centre). Free cam needs no lock: drag
|
|
208
|
-
orbits, a click is `onTap`, a right-click is `onHold`, and the wheel zooms.
|
|
209
|
-
|
|
210
|
-
### `App.jsx`
|
|
211
|
-
```jsx
|
|
212
|
-
import React from "react";
|
|
213
|
-
import * as THREE from "three";
|
|
214
|
-
import { useWorldControls } from "use-vibes";
|
|
215
|
-
import { Button, Card, Heading, IconButton, Stack, Text } from "@vibes.diy/ui";
|
|
216
|
-
import { readLook, watchLook } from "./look.js";
|
|
217
|
-
|
|
218
|
-
const VIEWS = ["Free cam", "First person", "Shoulder view"];
|
|
219
|
-
const HINT = {
|
|
220
|
-
"Free cam": "drag to look around · pinch to zoom · 🎥 to step in",
|
|
221
|
-
"First person": "left thumb walks · right thumb looks · flick up to jump",
|
|
222
|
-
"Shoulder view": "tap a hedge to bloom it · hold to trim it back",
|
|
223
|
-
};
|
|
224
|
-
const stop = (e) => e.stopPropagation();
|
|
225
|
-
|
|
226
|
-
export default function App() {
|
|
227
|
-
const rootRef = React.useRef(null);
|
|
228
|
-
const canvasRef = React.useRef(null);
|
|
229
|
-
const [camera] = React.useState(() => new THREE.PerspectiveCamera(70, 1, 0.1, 500));
|
|
230
|
-
const [view, setView] = React.useState(() => (matchMedia("(pointer: coarse)").matches ? "Free cam" : "First person"));
|
|
231
|
-
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
232
|
-
const [howTo, setHowTo] = React.useState(false);
|
|
233
|
-
const [full, setFull] = React.useState(false);
|
|
234
|
-
const me = React.useRef({ pos: new THREE.Vector3(0, 0, 12), yaw: 0, pitch: 0, move: [0, 0], vy: 0, zoom: 34 });
|
|
235
|
-
const world = React.useRef({ hedges: [], colors: null });
|
|
236
|
-
|
|
237
|
-
const turn = (yaw, pitch) => {
|
|
238
|
-
me.current.yaw += yaw;
|
|
239
|
-
me.current.pitch = Math.max(-1.5, Math.min(1.5, me.current.pitch + pitch));
|
|
240
|
-
};
|
|
241
|
-
const look = (dx, dy) => turn(-dx, -dy); // radians, screen sense: a drag right turns right
|
|
242
|
-
const hedgeAt = (x, y) => {
|
|
243
|
-
const r = rootRef.current.getBoundingClientRect(); // taps arrive in client coordinates
|
|
244
|
-
const ray = new THREE.Raycaster();
|
|
245
|
-
ray.setFromCamera(new THREE.Vector2(((x - r.left) / r.width) * 2 - 1, 1 - ((y - r.top) / r.height) * 2), camera);
|
|
246
|
-
return ray.intersectObjects(world.current.hedges)[0]?.object;
|
|
247
|
-
};
|
|
248
|
-
const bloom = (hedge, on) => {
|
|
249
|
-
if (!hedge) return;
|
|
250
|
-
hedge.userData.bloom = on;
|
|
251
|
-
hedge.material.color.set(on ? world.current.colors.accent : world.current.colors.lead);
|
|
252
|
-
};
|
|
253
|
-
const { isTouch, locked, requestLock, tick } = useWorldControls(rootRef, {
|
|
254
|
-
mode: view === "Free cam" ? "free" : "player",
|
|
255
|
-
camera,
|
|
256
|
-
onMove: (x, y) => (me.current.move = [x, y]),
|
|
257
|
-
onLook: look,
|
|
258
|
-
onTurn: look,
|
|
259
|
-
onPinch: (factor) => (me.current.zoom = Math.max(8, Math.min(60, me.current.zoom * factor))),
|
|
260
|
-
onTap: (x, y) => bloom(hedgeAt(x, y), true),
|
|
261
|
-
onHold: (x, y) => bloom(hedgeAt(x, y), false),
|
|
262
|
-
onFlick: (dir) => dir === "up" && me.current.pos.y === 0 && (me.current.vy = 7),
|
|
263
|
-
});
|
|
264
|
-
const live = React.useRef({});
|
|
265
|
-
live.current = { tick, view };
|
|
266
|
-
|
|
267
|
-
React.useEffect(() => {
|
|
268
|
-
const root = rootRef.current;
|
|
269
|
-
const renderer = new THREE.WebGLRenderer({ canvas: canvasRef.current, antialias: true });
|
|
270
|
-
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
271
|
-
const size = new ResizeObserver(() => renderer.setSize(root.clientWidth, root.clientHeight, false));
|
|
272
|
-
size.observe(root);
|
|
273
|
-
const scene = new THREE.Scene();
|
|
274
|
-
scene.fog = new THREE.Fog(0x000000, 30, 90);
|
|
275
|
-
const light = new THREE.HemisphereLight(0xffffff, 0xffffff, 1.4);
|
|
276
|
-
scene.add(light);
|
|
277
|
-
const groundGeo = new THREE.PlaneGeometry(60, 60);
|
|
278
|
-
const ground = new THREE.Mesh(groundGeo, new THREE.MeshLambertMaterial());
|
|
279
|
-
ground.rotation.x = -Math.PI / 2;
|
|
280
|
-
scene.add(ground);
|
|
281
|
-
const hedgeGeo = new THREE.BoxGeometry(5, 2, 1);
|
|
282
|
-
for (let i = 0; i < 10; i++) {
|
|
283
|
-
const hedge = new THREE.Mesh(hedgeGeo, new THREE.MeshLambertMaterial());
|
|
284
|
-
hedge.position.set(Math.cos(i * 0.63) * 18, 1, Math.sin(i * 0.63) * 18);
|
|
285
|
-
hedge.lookAt(0, 1, 0);
|
|
286
|
-
scene.add(hedge);
|
|
287
|
-
world.current.hedges.push(hedge);
|
|
288
|
-
}
|
|
289
|
-
// The garden wears the app's look: sky, light, ground and hedges all come from its tokens, and
|
|
290
|
-
// a restyle repaints them in place while the player keeps walking.
|
|
291
|
-
const paint = (colors) => {
|
|
292
|
-
world.current.colors = colors;
|
|
293
|
-
const sky = new THREE.Color(colors.backdrop).lerp(new THREE.Color(colors.lead), 0.2);
|
|
294
|
-
scene.background = sky;
|
|
295
|
-
scene.fog.color.copy(sky);
|
|
296
|
-
light.color.set(colors.surface);
|
|
297
|
-
light.groundColor.set(colors.lead);
|
|
298
|
-
ground.material.color.set(colors.surface);
|
|
299
|
-
for (const hedge of world.current.hedges) hedge.material.color.set(hedge.userData.bloom ? colors.accent : colors.lead);
|
|
300
|
-
};
|
|
301
|
-
paint(readLook(root));
|
|
302
|
-
const unwatch = watchLook(root, paint);
|
|
303
|
-
|
|
304
|
-
let raf = 0;
|
|
305
|
-
let last = performance.now();
|
|
306
|
-
const frame = (now) => {
|
|
307
|
-
const dt = Math.min((now - last) / 1000, 1 / 30);
|
|
308
|
-
last = now;
|
|
309
|
-
live.current.tick(dt);
|
|
310
|
-
const m = me.current;
|
|
311
|
-
const fwd = new THREE.Vector3(-Math.sin(m.yaw), 0, -Math.cos(m.yaw));
|
|
312
|
-
const side = new THREE.Vector3(-fwd.z, 0, fwd.x);
|
|
313
|
-
m.pos.addScaledVector(fwd, -m.move[1] * 5 * dt).addScaledVector(side, m.move[0] * 5 * dt); // forward is y < 0
|
|
314
|
-
m.vy -= 20 * dt;
|
|
315
|
-
m.pos.y = Math.max(0, m.pos.y + m.vy * dt);
|
|
316
|
-
if (m.pos.y === 0) m.vy = 0;
|
|
317
|
-
if (live.current.view === "Free cam") {
|
|
318
|
-
// Back the overview off on a narrow screen so the whole garden stays in frame.
|
|
319
|
-
const fit = Math.min(2.2, Math.max(1, 0.36 / (Math.tan((camera.fov * Math.PI) / 360) * camera.aspect)));
|
|
320
|
-
const d = m.zoom * fit;
|
|
321
|
-
camera.position.set(m.pos.x + Math.sin(m.yaw) * d, d * 0.7, m.pos.z + Math.cos(m.yaw) * d);
|
|
322
|
-
camera.lookAt(m.pos);
|
|
323
|
-
} else {
|
|
324
|
-
camera.position.copy(m.pos).y += 1.6;
|
|
325
|
-
if (live.current.view === "Shoulder view") camera.position.addScaledVector(fwd, -4).y += 1;
|
|
326
|
-
camera.rotation.set(m.pitch, m.yaw, 0, "YXZ");
|
|
327
|
-
}
|
|
328
|
-
renderer.render(scene, camera);
|
|
329
|
-
raf = requestAnimationFrame(frame);
|
|
330
|
-
};
|
|
331
|
-
raf = requestAnimationFrame(frame);
|
|
332
|
-
|
|
333
|
-
return () => {
|
|
334
|
-
cancelAnimationFrame(raf);
|
|
335
|
-
unwatch();
|
|
336
|
-
size.disconnect();
|
|
337
|
-
world.current.hedges.forEach((hedge) => hedge.material.dispose());
|
|
338
|
-
world.current.hedges = [];
|
|
339
|
-
hedgeGeo.dispose();
|
|
340
|
-
groundGeo.dispose();
|
|
341
|
-
ground.material.dispose();
|
|
342
|
-
renderer.dispose();
|
|
343
|
-
};
|
|
344
|
-
}, [camera]);
|
|
345
|
-
|
|
346
|
-
const cycle = () => setView((v) => VIEWS[(VIEWS.indexOf(v) + 1) % VIEWS.length]);
|
|
347
|
-
React.useEffect(() => {
|
|
348
|
-
// V cycles the views on a keyboard, once per press; a text field keeps its own V.
|
|
349
|
-
const onKey = (e) => {
|
|
350
|
-
if (e.code !== "KeyV" || e.repeat || e.target.closest?.("input, textarea, [contenteditable]")) return;
|
|
351
|
-
cycle();
|
|
352
|
-
};
|
|
353
|
-
const onFull = () => setFull(document.fullscreenElement !== null);
|
|
354
|
-
addEventListener("keydown", onKey);
|
|
355
|
-
document.addEventListener("fullscreenchange", onFull);
|
|
356
|
-
return () => {
|
|
357
|
-
removeEventListener("keydown", onKey);
|
|
358
|
-
document.removeEventListener("fullscreenchange", onFull);
|
|
359
|
-
};
|
|
360
|
-
}, []);
|
|
361
|
-
const toggleFullscreen = () => {
|
|
362
|
-
if (document.fullscreenElement) document.exitFullscreen();
|
|
363
|
-
else if (document.fullscreenEnabled) rootRef.current.requestFullscreen().catch(() => {});
|
|
364
|
-
};
|
|
365
|
-
return (
|
|
366
|
-
<div ref={rootRef} className="relative h-dvh w-full overflow-hidden bg-background text-foreground select-none touch-none">
|
|
367
|
-
<canvas ref={canvasRef} className="absolute inset-0 block w-full h-full select-none touch-none" />
|
|
368
|
-
<div className="absolute top-3 left-3 pointer-events-none">
|
|
369
|
-
<Text size="sm">{HINT[view]}</Text>
|
|
370
|
-
</div>
|
|
371
|
-
<div className="absolute top-3 right-3 flex gap-2" onPointerDown={stop}>
|
|
372
|
-
<IconButton icon="🎥" label={`View: ${view}`} onClick={cycle} />
|
|
373
|
-
<IconButton icon="☰" label={menuOpen ? "Hide menu" : "Show menu"} onClick={() => setMenuOpen(!menuOpen)} />
|
|
374
|
-
</div>
|
|
375
|
-
{menuOpen && (
|
|
376
|
-
<div className="absolute top-16 right-3 w-72" onPointerDown={stop}>
|
|
377
|
-
<Card>
|
|
378
|
-
<Stack gap={2}>
|
|
379
|
-
<Heading level={2}>Hedge Garden</Heading>
|
|
380
|
-
{VIEWS.map((v) => (
|
|
381
|
-
<Button key={v} variant={v === view ? "solid" : "quiet"} onClick={() => setView(v)}>
|
|
382
|
-
{v}
|
|
383
|
-
</Button>
|
|
384
|
-
))}
|
|
385
|
-
<Button variant="quiet" onClick={toggleFullscreen}>
|
|
386
|
-
{full ? "Exit fullscreen" : "Fullscreen"}
|
|
387
|
-
</Button>
|
|
388
|
-
<Button variant="quiet" onClick={() => setHowTo(!howTo)}>
|
|
389
|
-
How to play
|
|
390
|
-
</Button>
|
|
391
|
-
{howTo && (
|
|
392
|
-
<Text size="sm" muted>
|
|
393
|
-
Left thumb walks, right thumb looks. Tap a hedge to bloom it, hold to trim it, flick up to jump. On a
|
|
394
|
-
keyboard, V changes the view.
|
|
395
|
-
</Text>
|
|
396
|
-
)}
|
|
397
|
-
</Stack>
|
|
398
|
-
</Card>
|
|
399
|
-
</div>
|
|
400
|
-
)}
|
|
401
|
-
{!isTouch && !locked && view !== "Free cam" && (
|
|
402
|
-
<div className="absolute inset-0 z-20 flex items-center justify-center bg-background/80" onPointerDown={stop}>
|
|
403
|
-
<Card>
|
|
404
|
-
<Stack gap={3}>
|
|
405
|
-
<Heading level={2}>Hedge Garden</Heading>
|
|
406
|
-
<Button size="lg" onClick={requestLock}>
|
|
407
|
-
Click to play
|
|
408
|
-
</Button>
|
|
409
|
-
<Text size="sm" muted>
|
|
410
|
-
WASD walk · mouse look · Space jump · click bloom · V views · Esc frees the mouse
|
|
411
|
-
</Text>
|
|
412
|
-
</Stack>
|
|
413
|
-
</Card>
|
|
414
|
-
</div>
|
|
415
|
-
)}
|
|
416
|
-
</div>
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
Grow it by changing what the acts mean: `voxel` makes the tap build and the hold break, a ruin
|
|
422
|
-
makes the tap open a door. The gesture numbers live in the hook; pass `tune` to adjust them.
|
|
423
|
-
|
|
424
165
|
## Teach the gesture once, then get out of the way
|
|
425
166
|
|
|
426
167
|
- **A ghost thumb on first run.** Before the first touch, a translucent thumb with a short motion
|
|
@@ -440,102 +181,50 @@ the controls without a tutorial.
|
|
|
440
181
|
layer over the game.
|
|
441
182
|
- **What fired:** a short arrow flash at the finger for a swipe, a pulse ring for a tap, an
|
|
442
183
|
outline arrow when an action is queued.
|
|
443
|
-
- **Juice on every action:** a few particles, a small screen shake on impacts,
|
|
444
|
-
`navigator.vibrate?.(10)` where the phone supports it
|
|
445
|
-
gesture (audio can only start from a user gesture).
|
|
184
|
+
- **Juice on every action:** a few particles, a small screen shake on impacts, and
|
|
185
|
+
`navigator.vibrate?.(10)` where the phone supports it.
|
|
446
186
|
|
|
447
|
-
##
|
|
187
|
+
## Sound on the core actions
|
|
448
188
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
A full-screen game is judged by its first screenshot, and that screenshot is mostly canvas. The
|
|
452
|
-
world, the overlays, the hotbar and the buttons all speak the look, so the game reads as the
|
|
453
|
-
same crafted app as everything else the person made.
|
|
454
|
-
|
|
455
|
-
**The world takes the look's colours.** Resolve the theme tokens to concrete colours once per
|
|
456
|
-
mount and paint every large area from them: the sky or backdrop from `--background` leaned toward
|
|
457
|
-
`--primary`, fog from the same colour so the horizon melts into it, the light from `--primary`
|
|
458
|
-
over `--surface`, the player and the thing to chase in `--primary` and `--accent`, guides and lane
|
|
459
|
-
lines in `--border`, and text drawn on the canvas in `--text-primary`. A game's own materials (a
|
|
460
|
-
voxel world's block table, a racer's track paint) keep their names and colours; the look owns
|
|
461
|
-
everything around them.
|
|
462
|
-
|
|
463
|
-
```js
|
|
464
|
-
// look.js — the look's tokens as colours a 2D canvas or a Three.js scene can paint with.
|
|
465
|
-
// A computed colour can come back as oklch(), color-mix() or a translucent rgba(); filling one pixel
|
|
466
|
-
// over `under` turns any of them into the opaque hex the eye sees, which THREE.Color and
|
|
467
|
-
// ctx.fillStyle both read.
|
|
468
|
-
export function cssColor(host, token, fallback, under = "#ffffff") {
|
|
469
|
-
const probe = document.createElement("span");
|
|
470
|
-
probe.style.display = "none";
|
|
471
|
-
probe.style.color = `var(${token}, ${fallback})`;
|
|
472
|
-
host.appendChild(probe);
|
|
473
|
-
const value = getComputedStyle(probe).color;
|
|
474
|
-
probe.remove();
|
|
475
|
-
const ctx = document.createElement("canvas").getContext("2d");
|
|
476
|
-
ctx.fillStyle = under;
|
|
477
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
478
|
-
ctx.fillStyle = fallback;
|
|
479
|
-
ctx.fillStyle = value; // a value the canvas cannot parse leaves the fallback in place
|
|
480
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
481
|
-
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
482
|
-
return `#${[r, g, b].map((n) => n.toString(16).padStart(2, "0")).join("")}`;
|
|
483
|
-
}
|
|
189
|
+
Every game makes sound on its core actions, unasked: a short effect on a hit, a point, a miss, a jump, a win and a loss, never on spawns, ticks or an ambient loop, with `unlockAudio()` called first in the gesture handler and a mute toggle beside the menu button.
|
|
484
190
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
return {
|
|
490
|
-
backdrop,
|
|
491
|
-
surface: cssColor(host, "--surface", "#ffffff", backdrop),
|
|
492
|
-
lead: cssColor(host, "--primary", "#5b4bff", backdrop),
|
|
493
|
-
accent: cssColor(host, "--accent", "#ff7a59", backdrop),
|
|
494
|
-
ink: cssColor(host, "--text-primary", "#1a1325", backdrop),
|
|
495
|
-
line: cssColor(host, "--border", "#d9d2c3", backdrop),
|
|
496
|
-
};
|
|
497
|
-
}
|
|
191
|
+
The sound core above holds the whole recipe: `lib/sfx.js` with the gate, the `sfx` set, one master
|
|
192
|
+
gain and `setMuted`. Register `unlockAudio` as the play area's first `pointerdown` listener (and
|
|
193
|
+
call it first in the keyboard twin and the Start button), so the very tap that unlocks audio also
|
|
194
|
+
plays its own sound. The worked example below wires it in for a canvas game.
|
|
498
195
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
export function watchLook(host, onChange) {
|
|
502
|
-
const observer = new MutationObserver(() => onChange(readLook(host)));
|
|
503
|
-
observer.observe(document.head, { childList: true, subtree: true, characterData: true });
|
|
504
|
-
return () => observer.disconnect();
|
|
505
|
-
}
|
|
506
|
-
```
|
|
196
|
+
A game of tapped cells (a whack-a-mole, a tap-the-tiles grid, a memory board) wires the same calls
|
|
197
|
+
into each cell's own handler:
|
|
507
198
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
```js
|
|
513
|
-
const look = readLook(containerRef.current);
|
|
514
|
-
const sky = new THREE.Color(look.backdrop).lerp(new THREE.Color(look.lead), 0.2);
|
|
515
|
-
scene.background = sky;
|
|
516
|
-
scene.fog = new THREE.Fog(sky, 40, 120);
|
|
517
|
-
scene.add(new THREE.HemisphereLight(look.lead, look.surface, 0.9));
|
|
518
|
-
const sun = new THREE.DirectionalLight(look.surface, 1.4);
|
|
519
|
-
```
|
|
199
|
+
```jsx
|
|
200
|
+
import { Pad } from "@vibes.diy/ui/interactive";
|
|
201
|
+
import { sfx, unlockAudio } from "./lib/sfx.js";
|
|
520
202
|
|
|
521
|
-
|
|
522
|
-
|
|
203
|
+
// Each hole is the kit's Pad: lit while its mole is up.
|
|
204
|
+
function Hole({ index, up, onWhack }) {
|
|
205
|
+
return (
|
|
206
|
+
<Pad
|
|
207
|
+
on={up}
|
|
208
|
+
label={`Hole ${index + 1}${up ? ", mole up" : ""}`}
|
|
209
|
+
onPress={() => {
|
|
210
|
+
unlockAudio(); // first, inside the tap, so this tap's own sound plays
|
|
211
|
+
if (up) {
|
|
212
|
+
sfx.hit();
|
|
213
|
+
onWhack();
|
|
214
|
+
} else sfx.miss();
|
|
215
|
+
}}
|
|
216
|
+
/>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
523
220
|
|
|
524
|
-
|
|
525
|
-
|
|
221
|
+
The round ends on `sfx.win()` or `sfx.lose()`, a mole popping up stays silent, and the mute toggle
|
|
222
|
+
sits beside the menu button as in any other game.
|
|
526
223
|
|
|
527
|
-
|
|
528
|
-
over a bright sky or a dark cave alike.
|
|
529
|
-
- Score and best are `Metric`s on a `Card`; a timer or lap count is one more `Metric`.
|
|
530
|
-
- The hotbar is a `Row` of `IconButton`s on a `Card`: the selected slot carries `tint` with the
|
|
531
|
-
active colour and `aria-pressed`, the rest stay `variant="quiet"`.
|
|
532
|
-
- Start, pause and game-over screens are a `Card` or `Dialog` with a `Heading`, one lead `Button`
|
|
533
|
-
and a quiet second action.
|
|
534
|
-
- Overlay text keeps the look's own foreground and muted tones at full opacity; a scrim behind it
|
|
535
|
-
comes from `bg-background` or `bg-surface`.
|
|
224
|
+
## The look reaches the play area
|
|
536
225
|
|
|
537
|
-
|
|
538
|
-
|
|
226
|
+
The play-area surface above carries the look onto the canvas and the HUD over it; paint the
|
|
227
|
+
world from `readLook` and draw the HUD with the kit, as it says.
|
|
539
228
|
|
|
540
229
|
## The engine around it
|
|
541
230
|
|
|
@@ -548,8 +237,9 @@ tuned in one place.
|
|
|
548
237
|
|
|
549
238
|
## Worked example: a three-lane dodge, start to finish
|
|
550
239
|
|
|
551
|
-
The whole shape in one file beside `look.js` from the
|
|
552
|
-
swipe recogniser, a keyboard twin, a finger trail, a world
|
|
240
|
+
The whole shape in one file beside `lib/look.js` from the canvas theme colours and the sound core's
|
|
241
|
+
`lib/sfx.js`: the surface, the mid-move swipe recogniser, a keyboard twin, a finger trail, a world
|
|
242
|
+
painted in the look's colours, sound on the lane change and the crash with a mute toggle, and an
|
|
553
243
|
engine that cleans up after itself. Grow it into a runner, a racer or a
|
|
554
244
|
snake by changing what `move()` does.
|
|
555
245
|
|
|
@@ -557,7 +247,8 @@ snake by changing what `move()` does.
|
|
|
557
247
|
```jsx
|
|
558
248
|
import React from "react";
|
|
559
249
|
import { Card, Heading, IconButton, Metric, Stack, Text } from "@vibes.diy/ui";
|
|
560
|
-
import { readLook, watchLook } from "./look.js";
|
|
250
|
+
import { readLook, watchLook } from "./lib/look.js";
|
|
251
|
+
import { blip, setMuted, sfx, unlockAudio } from "./lib/sfx.js";
|
|
561
252
|
|
|
562
253
|
const TUNE = {
|
|
563
254
|
swipePx: 26, // travel from the anchor before a swipe fires (raise to 30–34 if a resting thumb misfires)
|
|
@@ -635,6 +326,7 @@ export default function App() {
|
|
|
635
326
|
const [score, setScore] = React.useState(0);
|
|
636
327
|
const [over, setOver] = React.useState(false);
|
|
637
328
|
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
329
|
+
const [muted, setMutedState] = React.useState(false);
|
|
638
330
|
|
|
639
331
|
React.useEffect(() => {
|
|
640
332
|
const root = rootRef.current;
|
|
@@ -664,13 +356,16 @@ export default function App() {
|
|
|
664
356
|
if (dir === "left") s.lane = Math.max(0, s.lane - 1);
|
|
665
357
|
if (dir === "right") s.lane = Math.min(2, s.lane + 1);
|
|
666
358
|
navigator.vibrate?.(10);
|
|
359
|
+
blip({ from: 440, to: 660, ms: 70, type: "sine", vol: 0.12 }); // the core action: a lane change
|
|
667
360
|
};
|
|
668
361
|
const keys = (e) => {
|
|
362
|
+
unlockAudio(); // first, in the keyboard twin's gesture too
|
|
669
363
|
const dir = { ArrowLeft: "left", ArrowRight: "right", a: "left", d: "right" }[e.key];
|
|
670
364
|
if (dir) move(dir);
|
|
671
365
|
if (e.key === " " && s.dead) restart();
|
|
672
366
|
};
|
|
673
367
|
|
|
368
|
+
root.addEventListener("pointerdown", unlockAudio); // first listener: every tap unlocks audio before it steers
|
|
674
369
|
const detach = attachSwipe(root, {
|
|
675
370
|
onSwipe: move,
|
|
676
371
|
onTap: () => s.dead && restart(),
|
|
@@ -701,9 +396,10 @@ export default function App() {
|
|
|
701
396
|
if (s.rocks.some((r) => Math.abs(r.lane - s.x) < 0.5 && Math.abs(r.y - py) < 30)) {
|
|
702
397
|
s.dead = true;
|
|
703
398
|
navigator.vibrate?.(40);
|
|
399
|
+
sfx.lose();
|
|
704
400
|
setOver(true);
|
|
705
401
|
}
|
|
706
|
-
setScore(Math.floor(s.t * 10));
|
|
402
|
+
setScore(Math.floor(s.t * 10)); // the score ticks up silently: no sound on a tick
|
|
707
403
|
}
|
|
708
404
|
ctx.fillStyle = look.backdrop;
|
|
709
405
|
ctx.fillRect(0, 0, w, h);
|
|
@@ -731,6 +427,7 @@ export default function App() {
|
|
|
731
427
|
return () => {
|
|
732
428
|
cancelAnimationFrame(raf);
|
|
733
429
|
unwatch();
|
|
430
|
+
root.removeEventListener("pointerdown", unlockAudio);
|
|
734
431
|
detach();
|
|
735
432
|
window.removeEventListener("keydown", keys);
|
|
736
433
|
window.removeEventListener("resize", resize);
|
|
@@ -755,7 +452,15 @@ export default function App() {
|
|
|
755
452
|
</Card>
|
|
756
453
|
</div>
|
|
757
454
|
{/* One button holds everything that is not play; pointerdown stops here so a tap on it never steers. */}
|
|
758
|
-
<div className="absolute top-3 right-3" onPointerDown={(e) => e.stopPropagation()}>
|
|
455
|
+
<div className="absolute top-3 right-3 flex gap-2" onPointerDown={(e) => e.stopPropagation()}>
|
|
456
|
+
<IconButton
|
|
457
|
+
icon={muted ? "🔇" : "🔊"}
|
|
458
|
+
label={muted ? "Turn sound on" : "Mute sound"}
|
|
459
|
+
onClick={() => {
|
|
460
|
+
setMuted(!muted);
|
|
461
|
+
setMutedState(!muted);
|
|
462
|
+
}}
|
|
463
|
+
/>
|
|
759
464
|
<IconButton icon="☰" label={menuOpen ? "Hide menu" : "Show menu"} onClick={() => setMenuOpen(!menuOpen)} />
|
|
760
465
|
</div>
|
|
761
466
|
{menuOpen && (
|
package/llms/types.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export interface LlmConfig {
|
|
|
6
6
|
cues?: string[];
|
|
7
7
|
routeCues?: string[];
|
|
8
8
|
routeBlockers?: string[];
|
|
9
|
+
needs?: string[];
|
|
10
|
+
teaches?: string[];
|
|
11
|
+
menu?: false;
|
|
12
|
+
rail?: "reskin" | "custom";
|
|
13
|
+
universal?: "always" | "edits";
|
|
9
14
|
importModule?: string;
|
|
10
15
|
importName?: string;
|
|
11
16
|
importType?: "named" | "namespace" | "default";
|
package/llms/ui-chat.js
CHANGED
|
@@ -2,6 +2,7 @@ export const uiChatConfig = {
|
|
|
2
2
|
name: "ui-chat",
|
|
3
3
|
aliases: ["pouf-chat"],
|
|
4
4
|
label: "Chat block",
|
|
5
|
-
description: "Group chat with rooms, live message threads and a composer",
|
|
5
|
+
description: "Group chat with rooms, live message threads, who is in each room, and a composer",
|
|
6
|
+
needs: ["live-rooms"],
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=ui-chat.js.map
|
package/llms/ui-chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-chat.js","sourceRoot":"","sources":["../../jsr/llms/ui-chat.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"ui-chat.js","sourceRoot":"","sources":["../../jsr/llms/ui-chat.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,kFAAkF;IAE/F,KAAK,EAAE,CAAC,YAAY,CAAC;CACtB,CAAC"}
|