dewctl 0.9.3 → 0.11.0
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/README.md +18 -0
- package/examples/.agents/skills/look/SKILL.md +119 -90
- package/examples/AGENTS.md +113 -62
- package/examples/starter/src/main.js +12 -6
- package/package.json +1 -1
- package/src/client.js +15 -8
- package/src/main.js +38 -17
- package/src/project.js +2 -2
- package/src/session.js +10 -8
package/README.md
CHANGED
|
@@ -88,6 +88,24 @@ dewctl eval 'game.player.position'
|
|
|
88
88
|
dewctl resume
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
## Named dev versions
|
|
92
|
+
|
|
93
|
+
A game runs up to eight dev versions beside its first, each at a link of its
|
|
94
|
+
own, so several agents working on different parts of a game can each show
|
|
95
|
+
their own. `dewctl dev --new terrain` starts the dev version `terrain`, and is
|
|
96
|
+
refused while one of that name runs, so pick another name; `dewctl status`
|
|
97
|
+
lists the ones running. After that, `--name terrain` reaches it from `dev`,
|
|
98
|
+
`stop`, `publish`, `status`, `logs`, `seat`, `sessions`, `eval`, `pause`,
|
|
99
|
+
`resume`, `step`, `speed` and `repl`. A name is 1 to 10 lowercase letters,
|
|
100
|
+
digits or dashes, and every dev version shares the game's dev saves.
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
dewctl dev --new terrain # starts it; refused if terrain runs
|
|
104
|
+
dewctl dev --name terrain --watch # uploads to it on every save
|
|
105
|
+
dewctl seat --name terrain --out .dewdrop-seat.json
|
|
106
|
+
dewctl stop --name terrain # frees the name
|
|
107
|
+
```
|
|
108
|
+
|
|
91
109
|
## License
|
|
92
110
|
|
|
93
111
|
MIT
|
|
@@ -5,10 +5,10 @@ description: Agree the game's look with the user in a short interview that adapt
|
|
|
5
5
|
|
|
6
6
|
# Agree the look
|
|
7
7
|
|
|
8
|
-
Dewdrop draws each frame from what
|
|
9
|
-
the style prompt and the sky. A look is a set of decisions about those, made once and
|
|
10
|
-
switched on at the end. This skill gets the decisions from the user in a few questions and
|
|
11
|
-
`LOOK.md`, so every change after it builds the same game.
|
|
8
|
+
Dewdrop lights the scene and draws each frame from what it holds: the lights and the colors, the shapes, the words
|
|
9
|
+
that describe each thing, the style prompt and the sky. A look is a set of decisions about those, made once and
|
|
10
|
+
kept to, not a filter switched on at the end. This skill gets the decisions from the user in a few questions and
|
|
11
|
+
writes them to `LOOK.md`, so every change after it builds the same game.
|
|
12
12
|
|
|
13
13
|
## When
|
|
14
14
|
|
|
@@ -17,8 +17,9 @@ switched on at the end. This skill gets the decisions from the user in a few que
|
|
|
17
17
|
`LOOK.md` and don't ask.
|
|
18
18
|
- When a decision comes up that `LOOK.md` doesn't settle, decide it from the look's recipe and its own words, add
|
|
19
19
|
it to `LOOK.md`, and say so in one line. Ask only when it would change the look itself.
|
|
20
|
-
- A game whose `
|
|
21
|
-
from the code and README.md, show it, and ask only what's missing.
|
|
20
|
+
- A starter game whose prompt (`src/look.js`) already starts with `style:` and has no `LOOK.md` has its look.
|
|
21
|
+
Write `LOOK.md` from the code and README.md, show it, and ask only what's missing. The Blank game's sample
|
|
22
|
+
prompt, a turquoise cube in a studio, decides nothing: while it is unchanged, run the interview.
|
|
22
23
|
|
|
23
24
|
## Before you ask
|
|
24
25
|
|
|
@@ -26,23 +27,23 @@ Read what is already decided, so you never ask for it:
|
|
|
26
27
|
|
|
27
28
|
- README.md in a starter game: how the game works and why its look works.
|
|
28
29
|
- The prompt (`src/look.js` in a starter, `renderer.prompt` in `src/main.js` in Blank), `scene.background`,
|
|
29
|
-
`renderer.backgroundDescription`,
|
|
30
|
+
`renderer.backgroundDescription`, the lights, `renderer.exposure`, and the meshes' materials.
|
|
30
31
|
- The user's own words so far. A film, a toy, a mood or "like my last game" is already an answer.
|
|
31
32
|
|
|
32
33
|
## How to ask
|
|
33
34
|
|
|
34
35
|
- One message holds one to three questions, each with an example answer, so the user can say "yes", "the second
|
|
35
36
|
one" or "like that, but at night". Never a form.
|
|
36
|
-
- A question must change what you'd build. If no answer would change a color, a word, a shape, the
|
|
37
|
-
sky or the camera, don't ask it.
|
|
37
|
+
- A question must change what you'd build. If no answer would change a light, a color, a word, a shape, the
|
|
38
|
+
prompt, the sky or the camera, don't ask it.
|
|
38
39
|
- Propose rather than quiz. Draft `LOOK.md` as soon as you have a recipe to start from, show it, and ask what's
|
|
39
40
|
wrong with it. A draft gets corrected; a blank gets a shrug.
|
|
40
|
-
- Take an answer in any form, and translate it into Dewdrop's terms out loud: "so: colored paper, a summer
|
|
41
|
-
|
|
41
|
+
- Take an answer in any form, and translate it into Dewdrop's terms out loud: "so: colored paper, a low summer sun
|
|
42
|
+
from the left, soft greens with one red roof, seen from behind and a little above". Let the user correct the
|
|
42
43
|
translation.
|
|
43
|
-
- Depth follows the game. A one-room puzzle needs the medium, the palette and the camera; an open world
|
|
44
|
-
needs the sky, what the distance looks like, and what moves while the player stands still. Leave the rest at
|
|
45
|
-
recipe's defaults, and say so.
|
|
44
|
+
- Depth follows the game. A one-room puzzle needs the medium, the light, the palette and the camera; an open world
|
|
45
|
+
also needs the sky, what the distance looks like, and what moves while the player stands still. Leave the rest at
|
|
46
|
+
the recipe's defaults, and say so.
|
|
46
47
|
- Stop when the sections the game needs are filled, or when the user says "you decide". Then decide, and say what
|
|
47
48
|
you decided in one line.
|
|
48
49
|
|
|
@@ -56,8 +57,9 @@ the draft (step 2).
|
|
|
56
57
|
|
|
57
58
|
- **A medium.** Take the matching recipe below and confirm it in one line.
|
|
58
59
|
- **A film, a game or an illustrator.** Say what you would take from it: the medium, the palette, the light, the
|
|
59
|
-
era, the mood. Say what doesn't carry over: its characters, its textures, its exact frames
|
|
60
|
-
you'd take matters most, and start
|
|
60
|
+
era, the mood. Say what doesn't carry over: its characters, its textures, its exact frames, and its name, since
|
|
61
|
+
the prompt describes a look and never names who made it. Ask which of what you'd take matters most, and start
|
|
62
|
+
from the nearest recipe.
|
|
61
63
|
- **A feeling or a setting** ("cozy", "a lighthouse in a storm", "eerie"). Offer three recipes that carry it, one
|
|
62
64
|
line each, and ask the user to pick one or mix two.
|
|
63
65
|
- **Realistic, "like a photo".** Horror, Winter and Underwater are realistic recipes; offer the nearest, and ask
|
|
@@ -66,7 +68,7 @@ the draft (step 2).
|
|
|
66
68
|
- **"I don't know", or "make it look nice".** Offer three or four recipes nearest to what the game is about, one
|
|
67
69
|
line each, and let the user choose. Never list all sixteen.
|
|
68
70
|
|
|
69
|
-
The recipes, each with a prompt,
|
|
71
|
+
The recipes, each with a prompt, lights, materials, words and shapes on the
|
|
70
72
|
[style recipes](https://alpha.dewdrop.world/docs/recipes) page:
|
|
71
73
|
|
|
72
74
|
- **Clay:** matte plasticine with thumbprints, chunky rounded shapes, saturated colors, a tabletop set.
|
|
@@ -86,8 +88,9 @@ The recipes, each with a prompt, colors, words and shapes on the
|
|
|
86
88
|
- **Golden hour:** gouache countryside under a low warm sun, gold highlights, cool blue-green shade.
|
|
87
89
|
- **Underwater:** murky teal water, god rays from the surface, caustic light on the sea floor.
|
|
88
90
|
|
|
89
|
-
A look needn't be one of them: the
|
|
90
|
-
|
|
91
|
+
A look needn't be one of them: the style phrase takes any medium in words, and
|
|
92
|
+
[looks to start from](https://alpha.dewdrop.world/docs/prompting#looks-to-start-from) lists many more that Dewdrop
|
|
93
|
+
draws well. A recipe is the fastest way to one that works.
|
|
91
94
|
|
|
92
95
|
### 2. Draft
|
|
93
96
|
|
|
@@ -99,31 +102,41 @@ ask them only where the draft is wrong or empty, and only for the sections the g
|
|
|
99
102
|
|
|
100
103
|
For each: what to ask, why it changes the build, and what to take when the user doesn't mind.
|
|
101
104
|
|
|
102
|
-
- **Setting and time.** Place, era, season, weather, time of day, and whether the time changes while playing.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
- **Setting and time.** Place, era, season, weather, time of day, and whether the time changes while playing. The
|
|
106
|
+
time of day is the lights: where the sun is, its color and how bright it is next to the sky. A changing time
|
|
107
|
+
moves the sun and changes the sky's color, and the prompt's light words with it; a new prompt shows as a cut, so
|
|
108
|
+
change it at a moment the player won't mind. Default: the recipe's.
|
|
109
|
+
- **Light.** Where the light comes from: the sun and the sky, lamps, candles, neon, a moon, glowing windows. A
|
|
110
|
+
sun is a `DirectionalLight`, the sky a `HemisphereLight`, a lamp a `PointLight` or `SpotLight`, and a candle,
|
|
111
|
+
a lit window, a neon tube or a lantern's shade a mesh that glows, which lights what's near it. Every light casts
|
|
112
|
+
shadows by itself; ask whether they're soft (a hazy sun, `userData.angle` about 0.03) or hard and long (a low,
|
|
113
|
+
small sun). Default: the recipe's ([lights and materials](https://alpha.dewdrop.world/docs/lighting)).
|
|
106
114
|
- **How dark.** For a night or an indoor look: "can the player see the whole room, or only what the light
|
|
107
|
-
reaches?"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
- **
|
|
112
|
-
|
|
115
|
+
reaches?" Night is dim lights over everyday colors, with a fixed exposure so it stays dark; only what the light
|
|
116
|
+
reaches means `localShadows` at 1 and lights placed where the player should look
|
|
117
|
+
([a fixed exposure](https://alpha.dewdrop.world/docs/lighting#a-fixed-exposure)). Default: Dewdrop's own
|
|
118
|
+
exposure for day, a fixed one for night.
|
|
119
|
+
- **Palette.** Three or four colors by their roles: the ground, the sky, the main built thing, the player or hero.
|
|
120
|
+
Ask in color names and choose the hex yourself. They are the things' everyday colors: the light makes them warm
|
|
121
|
+
or cold, bright or dim. Default: the recipe's colors.
|
|
122
|
+
- **Surfaces.** Matte or glossy, metal or not, and whether things wear a texture, such as planks, tiles or a pattern
|
|
123
|
+
on cloth. They become each material's `roughness`, `metalness` and `map`; a texture's colors and larger patterns
|
|
124
|
+
show, and its finest detail is drawn again in the style. Default: matte, no textures.
|
|
125
|
+
- **Mood.** Two or three words ("cozy, handmade, slow"). They decide the light and the scene sentence's one word for
|
|
126
|
+
the whole scene ("foggy", "abandoned"), and only when the scene shows them.
|
|
113
127
|
- **Shapes.** Chunky and rounded, sharp and faceted, cubes on a grid, or true proportions; big heads, or real
|
|
114
128
|
ones; a few big shapes, or many small. Dewdrop keeps the shapes you build, and small detail far from the camera
|
|
115
129
|
loses its shape, so this decides how much you model and how big. Default: the recipe's shapes.
|
|
116
130
|
- **Camera.** First or third person; how far behind and how high; following tightly or loosely; a fixed angle or
|
|
117
|
-
free. It decides what is in frame, and so what must be built well,
|
|
118
|
-
|
|
119
|
-
character is large in frame.
|
|
120
|
-
- **
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
smear, so ambient life is large and far, or left out. Default: a still world, with the player's own motion.
|
|
131
|
+
free. It decides what is in frame, and so what must be built well, what comes near the camera, where a mesh
|
|
132
|
+
grows into a blob, and the scene sentence's view ("eye-level view", "viewed from a high angle"). Default: third
|
|
133
|
+
person, a few meters behind and a little above, close enough that the character is large in frame.
|
|
134
|
+
- **Words.** Short descriptions (1 to 4 words, "plaster house") or rich ones (4 to 12 words, with the color,
|
|
135
|
+
material and state), one form for the whole game. Rich gives more control. Default: rich, as the recipes write
|
|
136
|
+
them.
|
|
137
|
+
- **Motion.** What moves while the player stands still: water, trees, flags, birds, fish, flickering flames. Small
|
|
138
|
+
moving things lose their shape, so ambient life is large and far, or left out. Default: a still world, with the
|
|
139
|
+
player's own motion.
|
|
127
140
|
- **The page.** Whether the game shows words over the frame (a title, a HUD, prompts) and in what manner: none,
|
|
128
141
|
as little as possible, or in the look's own hand (ink lettering, a paper label, pixel type). The page shows
|
|
129
142
|
over the game ([your page](https://alpha.dewdrop.world/docs/limits#your-page)); its colors come from the
|
|
@@ -133,35 +146,38 @@ For each: what to ask, why it changes the build, and what to take when the user
|
|
|
133
146
|
|
|
134
147
|
### 4. The medium's own questions
|
|
135
148
|
|
|
136
|
-
Two or three per medium, each changing shapes or colors. Skip what the user already said.
|
|
149
|
+
Two or three per medium, each changing shapes, light or colors. Skip what the user already said.
|
|
137
150
|
|
|
138
151
|
- **Clay:** a tabletop set with a backdrop behind it, or an open world? Thumbprints and lumps, or smooth? Round
|
|
139
152
|
dents about a twentieth of an object's smallest dimension deep read as thumbprints better than words do.
|
|
140
153
|
- **Knitted wool:** which things are knitted and which are felt? How plump: a stuffed toy, or neat? Big surfaces
|
|
141
154
|
get rows of ribs, which read as knitting.
|
|
142
|
-
- **Paper:** colored paper, or white card? How many folds show?
|
|
155
|
+
- **Paper:** colored paper, or white card? How many folds show? A key light low enough shades each fold.
|
|
143
156
|
- **Voxel:** how many cubes tall is the player? That sets the grid everything sits on, one exact color per prop
|
|
144
157
|
and nothing tilted.
|
|
145
|
-
- **Cartoon / anime:** outlines, or none?
|
|
158
|
+
- **Cartoon / anime:** outlines, or none? A bright summer afternoon, or sunset? The shadows read as the cel
|
|
159
|
+
shading's dark tone, so the sun's direction decides which faces are dark.
|
|
146
160
|
- **Ink sketch, watercolor, picture book, colored pencil:** white paper, or cream? How much bare paper shows?
|
|
147
|
-
Color, or none?
|
|
148
|
-
- **Stained glass:** a dark window frame around the view, or none? Thick lead, or thin? The
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
- **Noir:** black and white, or a tint? One light
|
|
153
|
-
- **Horror:** a carried
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
Color, or none? Fewer things far away keep the page open, and bright, even light keeps the paper pale.
|
|
162
|
+
- **Stained glass:** a dark window frame around the view, or none? Thick lead, or thin? The panes glow: each
|
|
163
|
+
pane's color is its `emissive` too, and other light stays low.
|
|
164
|
+
- **Neon cyberpunk:** rain, or dry? Which two neon colors? How much of the frame stays dark? Every tube and sign
|
|
165
|
+
is a glowing mesh that lights the wet ground below it.
|
|
166
|
+
- **Noir:** black and white, or a tint? One hard light per scene, so the shadows agree?
|
|
167
|
+
- **Horror:** a carried candle, fixed candles, or moonlight through the windows? How far can the player see?
|
|
168
|
+
A carried candle is a glowing flame that moves with the player and lights what's around it. Flames about
|
|
169
|
+
5 × 11 cm; smaller ones read as unlit.
|
|
170
|
+
- **Winter:** overcast, or sunny? Snowfall in the prompt's words, or none?
|
|
156
171
|
- **Golden hour:** where is the sun, and so which faces are gold and which blue-green? Does it set while playing?
|
|
172
|
+
The view toward the sun reads most golden.
|
|
157
173
|
- **Underwater:** how murky, and how far can the player see? Does the light come from the surface, or from
|
|
158
174
|
something glowing below?
|
|
159
175
|
|
|
160
176
|
### 5. Write it down
|
|
161
177
|
|
|
162
|
-
Keep `LOOK.md` at the project's root in this shape, and put the prompt
|
|
163
|
-
|
|
164
|
-
other. Show the final once more before you build.
|
|
178
|
+
Keep `LOOK.md` at the project's root in this shape, and put the prompt, the sky, the lights and the exposure into
|
|
179
|
+
the code (`src/look.js` in a starter, `src/main.js` in Blank). Keep both in step: a change to one is a change to
|
|
180
|
+
the other. Show the final once more before you build.
|
|
165
181
|
|
|
166
182
|
```markdown
|
|
167
183
|
# The look
|
|
@@ -170,31 +186,39 @@ One sentence: the game, its medium, its time of day and its mood.
|
|
|
170
186
|
|
|
171
187
|
## Style prompt
|
|
172
188
|
|
|
173
|
-
`style:
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
`style: Plasticine claymation diorama with soft studio lighting. A handmade tabletop village set, eye-level view.`
|
|
190
|
+
(Exactly `style: <medium with light>. <scene sentence>`, 15 to 35 words: the style phrase names the medium and
|
|
191
|
+
ends with its light; the scene sentence holds the scene broadly, its conditions and the camera's view, and names
|
|
192
|
+
nothing that has a description of its own.)
|
|
176
193
|
|
|
177
194
|
## Sky
|
|
178
195
|
|
|
179
|
-
`scene.background`: `#8fd0f5`. `renderer.backgroundDescription`: "
|
|
196
|
+
`scene.background`: `#8fd0f5`. `renderer.backgroundDescription`: "plain pale blue studio backdrop".
|
|
197
|
+
|
|
198
|
+
## Light
|
|
199
|
+
|
|
200
|
+
| Light | three.js | Color | Intensity | Where |
|
|
201
|
+
| --- | --- | --- | --- | --- |
|
|
202
|
+
| key | `DirectionalLight`, `userData.angle` 0.05 | `#fff1dc` | 3 | high, from the left |
|
|
203
|
+
| sky | `HemisphereLight` | `#cfe8ff` / `#7a6a50` | 1 | |
|
|
204
|
+
| ... | | | | |
|
|
205
|
+
|
|
206
|
+
Exposure: Dewdrop's own (`renderer.exposure = null`), or the fixed settings and why.
|
|
180
207
|
|
|
181
208
|
## Palette
|
|
182
209
|
|
|
183
|
-
| Role | Color |
|
|
184
|
-
| --- | --- | --- |
|
|
185
|
-
| ground | `#86c23c` | "lumpy green plasticine grass" |
|
|
186
|
-
| ... | | |
|
|
210
|
+
| Role | Color | Material | Description |
|
|
211
|
+
| --- | --- | --- | --- |
|
|
212
|
+
| ground | `#86c23c` | roughness 0.8 | "lumpy green plasticine grass" |
|
|
213
|
+
| ... | | | |
|
|
187
214
|
|
|
188
215
|
## Words
|
|
189
216
|
|
|
190
|
-
|
|
191
|
-
A color word matches the mesh's color
|
|
192
|
-
color.
|
|
217
|
+
Short or rich, and the material words every description carries in a world made of one ("plasticine", "clay").
|
|
218
|
+
A color word matches the mesh's color. Every surface in view is described, the ground and the sky included.
|
|
193
219
|
|
|
194
220
|
## Shapes
|
|
195
221
|
|
|
196
|
-
## Light and shadow
|
|
197
|
-
|
|
198
222
|
## Camera
|
|
199
223
|
|
|
200
224
|
## Motion
|
|
@@ -210,34 +234,39 @@ A line per check: the date, what was looked at, and what changed because of it.
|
|
|
210
234
|
|
|
211
235
|
### 6. Check it on Dewdrop
|
|
212
236
|
|
|
213
|
-
After the upload that carries the colors, the words and the prompt, look first yourself: open the dev
|
|
214
|
-
your browser tool ([for coding agents](https://alpha.dewdrop.world/docs/coding-agents)), take
|
|
215
|
-
first second, and check each against `LOOK.md`. A screenshot
|
|
216
|
-
half-size preview, so then ask the user to judge the look in
|
|
217
|
-
"Is the grass a bright plasticine green? Does the lamp
|
|
218
|
-
|
|
237
|
+
After the upload that carries the lights, the colors, the words and the prompt, look first yourself: open the dev
|
|
238
|
+
version in your browser tool ([for coding agents](https://alpha.dewdrop.world/docs/coding-agents)), take
|
|
239
|
+
screenshots after the first second, once the exposure has settled, and check each against `LOOK.md`. A screenshot
|
|
240
|
+
is a still frame, and without hardware acceleration a half-size preview, so then ask the user to judge the look in
|
|
241
|
+
motion, with three specific questions from `LOOK.md`: "Is the grass a bright plasticine green? Does the lamp light
|
|
242
|
+
the path? Is the sky a plain pale backdrop?" Put what you saw and the answers under "Checked on Dewdrop", and
|
|
243
|
+
change the code and `LOOK.md` together, one thing at a time.
|
|
219
244
|
|
|
220
245
|
## Dewdrop's terms
|
|
221
246
|
|
|
222
|
-
What a wish turns into. The [renderer](https://alpha.dewdrop.world/docs/renderer) page has each control in full
|
|
247
|
+
What a wish turns into. The [renderer](https://alpha.dewdrop.world/docs/renderer) page has each control in full,
|
|
248
|
+
and [lights and materials](https://alpha.dewdrop.world/docs/lighting) each light and material setting.
|
|
223
249
|
|
|
224
250
|
| The user says | You change |
|
|
225
251
|
| --- | --- |
|
|
226
|
-
| softer, dreamier |
|
|
227
|
-
| darker, moodier |
|
|
228
|
-
| a carried candle or torch |
|
|
229
|
-
| a lit side and a dark side, long shadows |
|
|
230
|
-
|
|
|
231
|
-
|
|
|
232
|
-
|
|
|
233
|
-
|
|
|
234
|
-
| wood grain, fabric, rust, any texture | the material
|
|
235
|
-
| glow, neon, fire, a lit window | a
|
|
236
|
-
|
|
|
237
|
-
|
|
|
238
|
-
|
|
|
252
|
+
| softer, dreamier | a hazier sun (`userData.angle` 0.02 to 0.05) and a brighter sky light; paler colors; "soft, diffused" light in the style phrase; fewer small meshes far away |
|
|
253
|
+
| darker, moodier | dimmer lights and a fixed exposure, the colors kept; the light words in the style phrase ("dim candlelight", "hard low-key lighting") |
|
|
254
|
+
| a carried candle or torch | a glowing flame mesh moving with the player, which lights what's around it |
|
|
255
|
+
| a lit side and a dark side, long shadows | a low `DirectionalLight` sun with a weaker sky light; a smaller `userData.angle` for harder edges |
|
|
256
|
+
| warmer, colder | the lights' colors: a warm sun and a cool sky, or the other way round |
|
|
257
|
+
| more detail, more realistic | more meshes and truer shapes, the biggest where the camera goes; textures on the large surfaces |
|
|
258
|
+
| fog, mist, rain, god rays | words in the prompt's scene sentence |
|
|
259
|
+
| smoke, steam, dust | words in the prompt. Sparks and embers are small transparent glowing meshes |
|
|
260
|
+
| wood grain, fabric, rust, any texture | a texture of it as the material's `map`, and the material in the words |
|
|
261
|
+
| glow, neon, fire, a lit window | a mesh with an `emissive` color and `emissiveIntensity`, which lights what's near it |
|
|
262
|
+
| a lantern, a frosted globe | the shade or the lantern's windows glow: a light inside a closed shade is hidden by it, but still shines through an open bottom or cut-out holes |
|
|
263
|
+
| shiny, polished, metal | low `roughness`; `metalness` 1 with the metal's own color for metal |
|
|
264
|
+
| glass, water, ice | a transparent material with `userData.modelLayer = 'surface'`, described as the surface |
|
|
265
|
+
| wet ground, reflections | the ground at low `roughness`, which shows the lights in it, and "wet" in its words |
|
|
266
|
+
| leaves, grass, a fence, lace | cards with a cut-out texture and an `alphaTest` |
|
|
267
|
+
| shadows | every light casts them; a softer edge from a larger `userData.angle` on the sun |
|
|
268
|
+
| a sign you can read | the letters built as meshes or in the sign's texture; a sign only described shows no word |
|
|
239
269
|
| big clouds | white spheres stacked into towers about 1 km or more away, described as a cloud |
|
|
240
|
-
|
|
|
241
|
-
| cinematic, like a film | the prompt's words, and the camera closer to what matters |
|
|
270
|
+
| cinematic, like a film | a photographic medium and dramatic light in the style phrase, and the camera closer to what matters |
|
|
242
271
|
| cute, toy-like | big heads and rounded shapes, saturated colors |
|
|
243
|
-
| sharper, crisper |
|
|
272
|
+
| sharper, crisper | the flat medium named plainly in the style phrase, flat facets, fewer colors |
|
package/examples/AGENTS.md
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# Working on this game
|
|
2
2
|
|
|
3
|
-
This is a three.js game for Dewdrop. Dewdrop draws each frame from
|
|
4
|
-
The docs are at https://alpha.dewdrop.world/docs, and each rule below links the page with the details.
|
|
3
|
+
This is a three.js game for Dewdrop. Dewdrop lights the scene and draws each frame from it, in the style the game
|
|
4
|
+
describes. The docs are at https://alpha.dewdrop.world/docs, and each rule below links the page with the details.
|
|
5
5
|
|
|
6
6
|
## 1. Agree the look with the user first
|
|
7
7
|
|
|
8
8
|
Before you build or restyle anything, agree the look with the user by following the
|
|
9
9
|
[look skill](.agents/skills/look/SKILL.md): a short interview that adapts to the answers, from a medium or a
|
|
10
|
-
reference the user names to the palette, the
|
|
11
|
-
`LOOK.md` is the look: every color, description and shape follows it, and the skill runs again only when the
|
|
12
|
-
asks for a different look.
|
|
10
|
+
reference the user names to the palette, the light, the camera and what moves, written to `LOOK.md`. From then on
|
|
11
|
+
`LOOK.md` is the look: every light, color, description and shape follows it, and the skill runs again only when the
|
|
12
|
+
user asks for a different look.
|
|
13
13
|
|
|
14
14
|
So you never stall:
|
|
15
15
|
- If `LOOK.md` exists, the look is chosen. Follow it, and add what it doesn't settle without asking.
|
|
16
|
-
- If `
|
|
17
|
-
`LOOK.md` from the code and README.md, and ask only what's missing.
|
|
16
|
+
- If a starter game's prompt (`src/look.js`) starts with `style:` and there is no `LOOK.md`, the look is chosen
|
|
17
|
+
too. Write `LOOK.md` from the code and README.md, and ask only what's missing. The Blank game's prompt, a
|
|
18
|
+
turquoise cube in a studio, is only a sample: while it is unchanged, the look is still open.
|
|
18
19
|
- If nobody can answer, pick the nearest [style recipe](https://alpha.dewdrop.world/docs/recipes), say which in
|
|
19
20
|
your first message, and write it to `LOOK.md`.
|
|
20
21
|
|
|
@@ -23,60 +24,106 @@ keep it in step with `LOOK.md`. Don't change the style on your own.
|
|
|
23
24
|
|
|
24
25
|
## 2. How Dewdrop makes a frame
|
|
25
26
|
|
|
26
|
-
Dewdrop
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
Dewdrop lights the three.js scene, then draws every frame in the game's style
|
|
28
|
+
([renderer](https://alpha.dewdrop.world/docs/renderer#what-dewdrop-reads)). It reads:
|
|
29
|
+
- **Shapes:** every mesh's geometry, posed by its skeleton and morph targets.
|
|
30
|
+
- **Materials:** each material's `color`, its textures, `roughness`, `metalness` and `emissive` glow
|
|
31
|
+
([lights and materials](https://alpha.dewdrop.world/docs/lighting#materials)).
|
|
32
|
+
- **Lights:** three.js's directional, point, spot, ambient and hemisphere lights, with soft shadows and light
|
|
33
|
+
bouncing between surfaces ([lights](https://alpha.dewdrop.world/docs/lighting#lights)).
|
|
34
|
+
- **Exposure:** it adapts to the light by itself, and `renderer.exposure` can set it
|
|
35
|
+
([exposure and tone](https://alpha.dewdrop.world/docs/lighting#exposure-and-tone)).
|
|
36
|
+
- **Words:** `renderer.prompt`, the style of the whole game, each mesh's `userData.description`, and
|
|
37
|
+
`renderer.backgroundDescription`, the sky, with a matching `scene.background` color
|
|
38
|
+
([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)).
|
|
39
|
+
|
|
40
|
+
`scene.fog`, lines (`Line`, `LineSegments`, `LineLoop`), render targets and post-processing don't show. A
|
|
41
|
+
`ShaderMaterial`'s shaders don't run, and `RectAreaLight` and `scene.environment` light nothing. Sprites, points and
|
|
42
|
+
transparent materials draw as glows. The prompt is at most 4 KiB, the background description and each description
|
|
43
|
+
at most 1 KiB. A scene draws at most 65,536 objects (each mesh counts once, and so does each instance), and holds
|
|
44
|
+
up to 4,096 lights and 4,096 textures ([what works](https://alpha.dewdrop.world/docs/limits#the-look)).
|
|
35
45
|
The view is 16:9, or 9:16 on a phone held upright once the game calls `session.allowPortrait()`
|
|
36
46
|
([phones held upright](https://alpha.dewdrop.world/docs/sessions#phones-held-upright)).
|
|
37
47
|
|
|
38
48
|
## 3. The rules that matter most
|
|
39
49
|
|
|
40
|
-
The controls, strongest first:
|
|
41
|
-
A new look usually means changing the
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- **
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- **
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
The controls, strongest first: light and color, shapes, descriptions, then the style prompt. Words can't overrule
|
|
51
|
+
light and color: "at night" over a sunlit scene still gives a sunlit scene. A new look usually means changing the
|
|
52
|
+
first three together, then the prompt ([the controls](https://alpha.dewdrop.world/docs/renderer#the-controls)).
|
|
53
|
+
|
|
54
|
+
Light and color ([lights and materials](https://alpha.dewdrop.world/docs/lighting)):
|
|
55
|
+
- **Light the scene as for three.js's own renderer:** a sun (`DirectionalLight`) and a sky (`HemisphereLight`)
|
|
56
|
+
for daylight, lamps (`PointLight`, `SpotLight`) and glowing meshes at night. Every light casts shadows, with no
|
|
57
|
+
`castShadow` needed, and light bounces. A scene with no light shows every surface evenly at its own color; once
|
|
58
|
+
the game adds a light or a glowing mesh, only its lights and glowing meshes light it, so give it a sky as well
|
|
59
|
+
as a sun.
|
|
60
|
+
- **Brightness is relative.** The exposure adapts, so what matters is each light next to the others. A sun's
|
|
61
|
+
`userData.angle` softens its shadows: 0.02 to 0.05 gives a hazy sun.
|
|
62
|
+
- **Night is dim light, not dark colors.** Keep the materials' everyday colors, turn the lights down, and fix the
|
|
63
|
+
exposure so the night stays dark: `renderer.exposure = { ev: 2, strength: 0 }`, its `ev` chosen on Dewdrop
|
|
64
|
+
([a fixed exposure](https://alpha.dewdrop.world/docs/lighting#a-fixed-exposure)).
|
|
65
|
+
- **A glowing thing is a mesh that glows:** a lamp, a candle flame, a lit window or neon is a material's
|
|
66
|
+
`emissive` times its `emissiveIntensity`, and it lights what's around it, so a candle can light a dark room by
|
|
67
|
+
itself. Only an opaque mesh with a lit material (`MeshStandardMaterial` and the like) lights its surroundings;
|
|
68
|
+
a transparent one, sprites and points glow but light nothing. A light inside a closed shade, such as a paper
|
|
69
|
+
lantern, is hidden by it: make the shade or the lantern's windows glow instead
|
|
70
|
+
([glowing things](https://alpha.dewdrop.world/docs/lighting#glowing-things)).
|
|
71
|
+
- **Give every mesh a material with a color.** `MeshStandardMaterial` takes highlights by its `roughness` (0
|
|
72
|
+
polished to 1 matte) and `metalness`; `MeshBasicMaterial` is unlit. A geometry needs normals to be lit.
|
|
73
|
+
- **Textures show** (`map`, `emissiveMap`, `alphaMap`, `normalMap`) from PNG, JPEG or WebP, glTF models and
|
|
74
|
+
`DataTexture`s: their colors and larger patterns carry into the picture, and their finest detail is drawn again
|
|
75
|
+
in the style. A canvas or video texture doesn't show
|
|
76
|
+
([textures](https://alpha.dewdrop.world/docs/lighting#textures)).
|
|
77
|
+
- **Foliage, fences and lace are cut-outs:** cards with a texture and an `alphaTest`, `opacity` 1 and `transparent`
|
|
78
|
+
off ([cut-outs](https://alpha.dewdrop.world/docs/lighting#cut-outs-and-foliage)). A transparent material is a
|
|
79
|
+
glow over the scene; for water, glass and ice set `userData.modelLayer = 'surface'`
|
|
80
|
+
([transparency](https://alpha.dewdrop.world/docs/lighting#transparency)).
|
|
81
|
+
- **A drawn look on white paper needs near-white colors** and bright, even light.
|
|
82
|
+
- To find which mesh became a blob, give the suspects a loud color such as magenta for a moment, and check again.
|
|
83
|
+
|
|
84
|
+
Shapes ([shapes](https://alpha.dewdrop.world/docs/renderer#shapes)):
|
|
58
85
|
- **Dewdrop keeps your shapes.** A style made of shapes needs them: cubes for voxel, folded flat faces for paper,
|
|
59
86
|
rounded lumpy forms for clay. A realistic look needs realistic shapes. A face needs eye and nose meshes. Build the
|
|
60
|
-
letters you want read
|
|
61
|
-
- **A light is a mesh.** Three.js lights don't show on Dewdrop. Give a lamp or candle a bright mesh described as
|
|
62
|
-
glowing. Night is every surface at about a fifth of its daylight color, with the lights in view. Warmth comes from
|
|
63
|
-
color; say the same light in every description, and a light's own words light the frame, as a hand "holding a lit
|
|
64
|
-
candle" does. A shadow is a thin dark mesh on the ground
|
|
65
|
-
([light and shadow](https://alpha.dewdrop.world/docs/renderer#light-and-shadow)).
|
|
66
|
-
- **The sky is the background.** Describe it in `renderer.backgroundDescription`, not the prompt, with a matching
|
|
67
|
-
`scene.background` color. A gradient and the sun come from the words; a sun disc mesh shows as a flat coin. Big
|
|
68
|
-
clouds are stacked white spheres about 1 km or more away. Flat bands or panels in the sky become a wall
|
|
69
|
-
([background](https://alpha.dewdrop.world/docs/renderer#style-prompt-and-background)).
|
|
70
|
-
- Mist, rain and god rays come from the words. `scene.fog` doesn't show; to fade distance, or for pools of light
|
|
71
|
-
and sunlight, bake them into colors ([baked light](https://alpha.dewdrop.world/docs/baked-light)).
|
|
87
|
+
letters you want read, as meshes or in a texture.
|
|
72
88
|
- **Keep the camera clear.** A mesh very close to the camera becomes a big smooth blob. Keep scenery and moving
|
|
73
|
-
parts a few meters from anywhere the camera goes. In first person, hold items 0.6
|
|
74
|
-
its children ([camera](https://alpha.dewdrop.world/docs/camera)).
|
|
75
|
-
- **Small moving things
|
|
76
|
-
or more, 8 m or more from the camera
|
|
77
|
-
Turn flat things to face the camera
|
|
89
|
+
parts a few meters from anywhere the camera goes, and characters 2.5 m or more. In first person, hold items 0.6
|
|
90
|
+
to 0.7 m from the camera, as its children ([camera](https://alpha.dewdrop.world/docs/camera)).
|
|
91
|
+
- **Small moving things lose their shape.** Make what matters large in frame. Fish, flocks and sparks: muted,
|
|
92
|
+
about 0.6 m long or more, 8 m or more from the camera
|
|
78
93
|
([what to watch for](https://alpha.dewdrop.world/docs/renderer#what-to-watch-for)).
|
|
79
|
-
-
|
|
94
|
+
- **Atmosphere is words.** Haze, mist, rain and god rays go in the prompt's scene sentence.
|
|
95
|
+
|
|
96
|
+
Words ([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)):
|
|
97
|
+
- **The prompt has exactly this form:** `style: <style phrase>. <scene sentence>`, 15 to 35 words in all.
|
|
98
|
+
`'style: Needle-felted wool diorama with soft studio lighting. A cozy farmyard in the morning, viewed from a high angle.'`
|
|
99
|
+
- **The style phrase is a medium with its light,** about 8 to 14 words: name the medium concretely ("impasto oil
|
|
100
|
+
painting on canvas", not "oil style"), a flat medium plainly ("flat vector illustration"), and end with the light,
|
|
101
|
+
in agreement with the scene's lights. Describe the look, never an artist or a studio
|
|
102
|
+
([the style phrase](https://alpha.dewdrop.world/docs/prompting#the-style-phrase)).
|
|
103
|
+
- **The scene sentence** (at most 25 words) holds only the scene broadly, its conditions (time of day, weather, where
|
|
104
|
+
the light comes from, the camera's angle and framing) and at most one thing true of the whole scene. It names
|
|
105
|
+
nothing that has its own description, and no praise such as "highly detailed"
|
|
106
|
+
([the scene sentence](https://alpha.dewdrop.world/docs/prompting#the-scene-sentence)).
|
|
107
|
+
- **A description is one plain string naming one thing**, with no leading "a" or "the", in one form for the whole
|
|
108
|
+
game: short (1 to 4 words, `plaster house`) or rich (4 to 12 words, `cracked cream plaster house with green
|
|
109
|
+
shutters`). Keep style words out, unless the world is made of a material (`knitted wool pumpkin`), and keep color
|
|
110
|
+
words in step with the mesh's color. Describe what the camera sees: `back of brown owl head` behind a character
|
|
111
|
+
([descriptions](https://alpha.dewdrop.world/docs/prompting#descriptions)).
|
|
112
|
+
- **Describe everything in view, or nothing.** A frame with a few things described comes out worse than one with
|
|
113
|
+
none: describe the ground, the walls and the sky too. Every mesh of one thing gets the same string, so put it on
|
|
114
|
+
the group; different things get different strings; three or more small things of a kind share a plural; specks
|
|
115
|
+
get `null`. Only the 32 largest described things in view are read
|
|
116
|
+
([what gets a description](https://alpha.dewdrop.world/docs/prompting#what-gets-a-description)).
|
|
117
|
+
- A group's description reaches every mesh under it that has none of its own; `null` gives none, and a mesh's
|
|
118
|
+
`name` is never used. `userData.instanceDescriptions` describes an instanced mesh's instances one by one
|
|
119
|
+
([scene graph](https://alpha.dewdrop.world/docs/descriptions)).
|
|
120
|
+
- **A character close to the camera can describe its parts:** `helmet of the knight in dented steel armor`, the
|
|
121
|
+
part's name, `of the` and the character's own description
|
|
122
|
+
([characters and their parts](https://alpha.dewdrop.world/docs/prompting#characters-and-their-parts)).
|
|
123
|
+
- **The sky is the background.** Describe it in `renderer.backgroundDescription`, with a matching `scene.background`
|
|
124
|
+
color. Big clouds are stacked white spheres about 1 km or more away.
|
|
125
|
+
- **A change of look is a cut**, 0.15 to 0.3 s later, with no blend. Change the prompt, lights, colors and
|
|
126
|
+
descriptions in the same frame ([a change of look](https://alpha.dewdrop.world/docs/renderer#a-change-of-look-is-a-cut)).
|
|
80
127
|
|
|
81
128
|
The code ([limits](https://alpha.dewdrop.world/docs/limits)):
|
|
82
129
|
- The frame rate on Dewdrop is often far lower than a browser's own three.js, and varies. Move by the real time
|
|
@@ -99,9 +146,9 @@ Follow the [development flow](https://alpha.dewdrop.world/docs/development-flow)
|
|
|
99
146
|
in its dev version; there is no local preview.
|
|
100
147
|
1. **Shapes:** build the scene and the game from simple shapes, and play it until it works.
|
|
101
148
|
Check that the player and the roads show. Seed any random layout.
|
|
102
|
-
2. **
|
|
103
|
-
3. **Descriptions:** say what each thing
|
|
104
|
-
4. **Style prompt:** set the prompt for the whole game, and the
|
|
149
|
+
2. **Materials and light:** give every mesh a material with a color, and light the scene.
|
|
150
|
+
3. **Descriptions:** say what each thing in view is, the ground and the sky included.
|
|
151
|
+
4. **Style prompt:** set the prompt for the whole game: its medium, its light and the scene.
|
|
105
152
|
|
|
106
153
|
After each step, upload with `npm run dev`: it builds the game, uploads it and prints the link to play it on
|
|
107
154
|
Dewdrop; in a script it returns once the game is ready to play. Upload when there is something to check, not after
|
|
@@ -109,9 +156,9 @@ every edit. If the user runs `npx dewctl dev --watch`, every save uploads by its
|
|
|
109
156
|
build into the same folder.
|
|
110
157
|
|
|
111
158
|
Check each upload yourself first (section 5): read the game's state, step it, and take screenshots. Then ask the
|
|
112
|
-
user specific questions about it in motion ("Does the lantern
|
|
113
|
-
like?"): the user judges the look in motion, not from a still frame. Change one thing at a time, so you
|
|
114
|
-
each change did.
|
|
159
|
+
user specific questions about it in motion ("Does the lantern light the path as you walk past?", "What does the
|
|
160
|
+
sky look like?"): the user judges the look in motion, not from a still frame. Change one thing at a time, so you
|
|
161
|
+
know what each change did.
|
|
115
162
|
|
|
116
163
|
## 5. Check it yourself
|
|
117
164
|
|
|
@@ -119,16 +166,16 @@ You can play the dev version in a browser tool and work it from the terminal
|
|
|
119
166
|
([for coding agents](https://alpha.dewdrop.world/docs/coding-agents)).
|
|
120
167
|
|
|
121
168
|
1. In the dev version only, put the state worth checking on `globalThis`: code you run reaches nothing else.
|
|
122
|
-
`if (session.dev) globalThis.game = {player, level}`, with `session` from `dewdrop-sdk`.
|
|
169
|
+
`if (session.dev) globalThis.game = {scene, player, level}`, with `session` from `dewdrop-sdk`.
|
|
123
170
|
2. Right after uploading, `npx dewctl seat --out .dewdrop-seat.json` gets a pass. It works once, within 10
|
|
124
171
|
minutes. Keep the file out of git and out of the build folder.
|
|
125
172
|
3. In a browser tool (headless is fine), set the pass's cookie, its `name` and `value`, for its `url`. Open the
|
|
126
173
|
`url`, wait for `window.dewdrop`, then `await dewdrop.ready()`. Keep that page in front, and give each player a
|
|
127
174
|
browser of its own. Each upload reloads the page: wait for `ready()` again
|
|
128
175
|
([headless browsers](https://alpha.dewdrop.world/docs/headless)).
|
|
129
|
-
4. Take screenshots after the first second,
|
|
130
|
-
gets a half-size preview at up to 5 frames a second: fine for layout and state, so let
|
|
131
|
-
in motion.
|
|
176
|
+
4. Take screenshots after the first second, once the exposure and the light have settled. Without hardware
|
|
177
|
+
acceleration the browser gets a half-size preview at up to 5 frames a second: fine for layout and state, so let
|
|
178
|
+
the user judge the look in motion.
|
|
132
179
|
|
|
133
180
|
From the terminal ([commands](https://alpha.dewdrop.world/docs/terminal)):
|
|
134
181
|
- `npx dewctl sessions` lists your seats, newest first. `npx dewctl eval '<code>'` runs code in the newest and
|
|
@@ -140,6 +187,10 @@ From the terminal ([commands](https://alpha.dewdrop.world/docs/terminal)):
|
|
|
140
187
|
- To hold a key for 30 frames, evaluate
|
|
141
188
|
`document.dispatchEvent(new KeyboardEvent('keydown', {code: 'ArrowRight', key: 'ArrowRight', bubbles: true}))`,
|
|
142
189
|
`step 30`, then dispatch its `keyup` the same way.
|
|
190
|
+
- To check the words, with `scene` on `globalThis.game`, list each description with the number of meshes and
|
|
191
|
+
instances that carry it, and those with none (a `null` description counts as neither):
|
|
192
|
+
`npx dewctl eval '(()=>{const out=Object.create(null),none=[];(function walk(o,d){if(!o.visible)return;if(o.userData.description!==undefined)d=o.userData.description;if(o.isMesh){const a=o.userData.instanceDescriptions,n=o.isInstancedMesh?o.count:o.isBatchedMesh?o.maxInstanceCount:1;for(let i=0;i<n;i++){if(o.isBatchedMesh)try{if(!o.getVisibleAt(i))continue}catch{continue}const e=a&&a[i]!==undefined?a[i]:d;if(e)out[e]=(out[e]??0)+1;else if(e===undefined)none.push(o.name||o.type)}}o.children.forEach(c=>walk(c,d))})(game.scene);return{described:out,undescribed:none}})()'`.
|
|
193
|
+
Every big thing in view should be described, in one form, and each thing by one string.
|
|
143
194
|
- `npx dewctl logs` prints every seat's and the backend's console and how each session ended, with stacks in your
|
|
144
195
|
source. Read it while the game plays, or keep `--follow` running
|
|
145
196
|
([console](https://alpha.dewdrop.world/docs/console)).
|
|
@@ -2,17 +2,23 @@
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
|
|
4
4
|
const scene=new THREE.Scene();
|
|
5
|
-
scene.background=new THREE.Color('#142232');
|
|
6
5
|
const camera=new THREE.PerspectiveCamera(55,innerWidth/innerHeight,0.1,100);
|
|
7
6
|
camera.position.set(0,0,5);
|
|
8
7
|
const renderer=new THREE.WebGLRenderer();
|
|
9
|
-
// On Dewdrop,
|
|
10
|
-
renderer.prompt='
|
|
8
|
+
// On Dewdrop, the style of your whole game: a medium with its light, then the scene…
|
|
9
|
+
renderer.prompt='style: Clean stylized 3D game render with soft studio lighting. A minimal studio scene, eye-level view, centered framing.';
|
|
10
|
+
// …the sky, in color and in words…
|
|
11
|
+
scene.background=new THREE.Color('#142232');
|
|
12
|
+
renderer.backgroundDescription='plain dark blue studio backdrop';
|
|
11
13
|
renderer.setSize(innerWidth,innerHeight);
|
|
12
14
|
document.body.appendChild(renderer.domElement);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
// …the light: a key light and a soft sky…
|
|
16
|
+
const key=new THREE.DirectionalLight('#fff4e6',3);
|
|
17
|
+
key.position.set(3,5,4);
|
|
18
|
+
scene.add(key,new THREE.HemisphereLight('#cfe2ff','#1c2838',0.8));
|
|
19
|
+
// …and what each thing is.
|
|
20
|
+
const cube=new THREE.Mesh(new THREE.BoxGeometry(1.5,1.5,1.5),new THREE.MeshStandardMaterial({color:'#4edbb1',roughness:0.35}));
|
|
21
|
+
cube.userData.description='turquoise cube';
|
|
16
22
|
scene.add(cube);
|
|
17
23
|
const heading=document.createElement('h1');
|
|
18
24
|
heading.textContent='Hello from your Dewdrop game';
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -41,8 +41,13 @@ export class Client {
|
|
|
41
41
|
// `partBytes` is for the tests, which cut at a few bytes; a push's requests and a file's parts are PART_BYTES.
|
|
42
42
|
// `pollMs` is the least a wait on Dewdrop takes a round: a request Dewdrop holds is answered when there is news,
|
|
43
43
|
// within WAIT_S, and an answer without news that comes at once is asked again after that long.
|
|
44
|
-
// `confirmed` holds the hashes of the files Dewdrop has been seen to have, for this run.
|
|
45
|
-
|
|
44
|
+
// `confirmed` holds the hashes of the files Dewdrop has been seen to have, for this run. `devName` names the dev
|
|
45
|
+
// version every request of the game's dev version reaches, '' the game's first; with `fresh`, each game's first upload
|
|
46
|
+
// starts it, refused while it runs, so two developers or agents never share a name unknowingly, and later ones update
|
|
47
|
+
// it: `started` holds the games it was started in, a watcher moving to another game starting it there afresh.
|
|
48
|
+
constructor(origin,credentials,{fetcher=fetch,pollMs=1000,timeoutMs=180000,storeMs=15*60*1000,partBytes=PART_BYTES,devName='',fresh=false}={}){this.origin=origin;this.credentials=credentials;this.fetcher=fetcher;this.pollMs=pollMs;this.timeoutMs=timeoutMs;this.storeMs=storeMs;this.partBytes=partBytes;this.holds=true;this.confirmed=new Set();this.devName=devName;this.fresh=fresh;this.started=new Set();}
|
|
49
|
+
// `path` of the game or its dev version, reaching the dev version `devName` names.
|
|
50
|
+
#named(path){return this.devName?`${path}${path.includes('?')?'&':'?'}name=${this.devName}`:path;}
|
|
46
51
|
// A request signed in with `token`. When Dewdrop can't be reached the failure is marked transient, which a watcher
|
|
47
52
|
// or a sign-in waits out; a refused token asks for a new sign-in, whatever Dewdrop's words.
|
|
48
53
|
async request(path,{method='GET',body,token,signal,type,prefer}={}) {
|
|
@@ -74,7 +79,7 @@ export class Client {
|
|
|
74
79
|
return current;
|
|
75
80
|
}
|
|
76
81
|
async api(path,options={}){return this.request(path,{...options,token:this.session().token});}
|
|
77
|
-
game(game,signal){return this.api(`/v1/games/${game}
|
|
82
|
+
game(game,signal){return this.api(this.#named(`/v1/games/${game}`),{signal});}
|
|
78
83
|
releases(game){return this.api(`/v1/games/${game}/releases`);}
|
|
79
84
|
deleteRelease(game,release){return this.api(`/v1/games/${game}/releases/${release}`,{method:'DELETE'});}
|
|
80
85
|
deleteGame(game){return this.api(`/v1/games/${game}`,{method:'DELETE'});}
|
|
@@ -170,7 +175,9 @@ export class Client {
|
|
|
170
175
|
// Points a version at a release, then follows the game until that version is ready, fails, or somebody points it
|
|
171
176
|
// elsewhere. The PUT answers with the game, so it is the first look, handed to `started` before the wait.
|
|
172
177
|
async point(game,version,release,signal,started) {
|
|
173
|
-
|
|
178
|
+
const fresh=version==='dev'&&release!==null&&this.fresh&&!this.started.has(game);
|
|
179
|
+
let state=await this.api(version==='dev'?this.#named(`/v1/games/${game}/dev`):`/v1/games/${game}/live`,{method:'PUT',body:fresh?{release,new:true}:{release},signal});
|
|
180
|
+
if(fresh)this.started.add(game);
|
|
174
181
|
started?.(state);
|
|
175
182
|
if(release===null&&version==='live')return state;
|
|
176
183
|
const doing=release===null?'Stopping the dev version':version==='dev'?'Starting the dev version':'Publishing',deadline=Date.now()+this.timeoutMs;
|
|
@@ -191,7 +198,7 @@ export class Client {
|
|
|
191
198
|
// refuse that wait, the game is read as it stands instead, then and from then on.
|
|
192
199
|
async held(game,version,signal) {
|
|
193
200
|
if(!this.holds)return this.game(game,signal);
|
|
194
|
-
try{return await this.api(`/v1/games/${game}/${
|
|
201
|
+
try{return await this.api(version==='dev'?this.#named(`/v1/games/${game}/dev`):`/v1/games/${game}/live`,{signal,prefer:`wait=${WAIT_S}`});}
|
|
195
202
|
catch(error){
|
|
196
203
|
if(error.status!==405&&error.status!==404)throw error;
|
|
197
204
|
this.holds=false;
|
|
@@ -213,13 +220,13 @@ export class Client {
|
|
|
213
220
|
// A seat pass for the dev version: one use, within minutes, by whatever the developer's own tools are.
|
|
214
221
|
seat(game,signal){return this.#dev(game,'seat',{method:'POST',body:{},signal});}
|
|
215
222
|
async #dev(game,path,options) {
|
|
216
|
-
try { return await this.api(`/v1/games/${game}/dev/${path}
|
|
223
|
+
try { return await this.api(this.#named(`/v1/games/${game}/dev/${path}`),options); }
|
|
217
224
|
catch(error) {
|
|
218
225
|
const said={
|
|
219
226
|
403:`Only ${game}'s owner and the developers it's shared with can use its dev version.`,
|
|
220
227
|
404:`${game} isn't on Dewdrop yet. Run ${RUN} dev to create it.`,
|
|
221
228
|
429:path==='seat'?'You\'ve reached your account\'s limit on seat passes and the seats they open. Try again later.':'Dewdrop is asked for the console too often. Try again in a moment.',
|
|
222
|
-
503
|
|
229
|
+
503:this.devName?`${game} has no dev version named ${this.devName} running. Run ${RUN} dev --new ${this.devName} to start it.`:`${game} has no dev version running. Run ${RUN} dev to start it.`,
|
|
223
230
|
}[error.status];
|
|
224
231
|
if(said===undefined||error.status===401)throw error;
|
|
225
232
|
throw new ApiError(error.status,said,error.body);
|
|
@@ -235,7 +242,7 @@ export class Client {
|
|
|
235
242
|
// A control of the developer's own seats. Dewdrop's own words say what was wrong — which seat or room, what to run —
|
|
236
243
|
// but for a route Dewdrop doesn't take, and a refusal to someone not on the game.
|
|
237
244
|
async #control(game,path,options) {
|
|
238
|
-
try { return await this.api(`/v1/games/${game}/dev/${path}
|
|
245
|
+
try { return await this.api(this.#named(`/v1/games/${game}/dev/${path}`),options); }
|
|
239
246
|
catch(error) {
|
|
240
247
|
if(error.status===405||(error.status===404&&error.message==='Route not found'))throw new ApiError(error.status,'Dewdrop can\'t control dev sessions from the CLI right now. Try again later.',error.body);
|
|
241
248
|
if(error.status===403)throw new ApiError(403,`Only ${game}'s owner and the developers it's shared with can use its dev version.`,error.body);
|
package/src/main.js
CHANGED
|
@@ -24,12 +24,15 @@ const HELP=`${RUN} — make three.js games on Dewdrop
|
|
|
24
24
|
after the folder unless --game names it
|
|
25
25
|
login Sign in: prints a link to open in your browser and approve
|
|
26
26
|
logout Sign this computer out
|
|
27
|
-
dev [--watch] [--release ID]
|
|
27
|
+
dev [--watch] [--release ID] [--new NAME | --name NAME]
|
|
28
|
+
Build, upload and play the dev version; --watch repeats this on every
|
|
28
29
|
save, --release plays a kept upload without building. Without --release,
|
|
29
30
|
dev then prints the dev version's console as logs --follow does, at a
|
|
30
31
|
terminal and with --watch, until Ctrl-C; in a script it returns once the
|
|
31
32
|
upload is ready to play. The build's source maps (.map files) are never
|
|
32
|
-
uploaded: they stay on this computer
|
|
33
|
+
uploaded: they stay on this computer. --new NAME starts a dev version of
|
|
34
|
+
its own beside the first, refused while one of that name runs; --name
|
|
35
|
+
NAME uploads to it once it runs
|
|
33
36
|
logs [GAME] [--follow] Print the dev version's recent console: the game's page and backend lines,
|
|
34
37
|
and how each seat's session ended. Positions in the built code are shown
|
|
35
38
|
in your source, by the last build's source maps. --follow keeps printing
|
|
@@ -59,17 +62,18 @@ const HELP=`${RUN} — make three.js games on Dewdrop
|
|
|
59
62
|
to 1/2, 1/3, 1/4 and so on, no slower than 1/300
|
|
60
63
|
repl [GAME] [--seat S] [--backend] Evaluate each line you type in your seat. .pause, .resume, .step N,
|
|
61
64
|
.speed K, .seat S, .backend, .page, .help and .exit do what they say
|
|
62
|
-
stop
|
|
65
|
+
stop [--name NAME] Stop the dev version and disconnect its players
|
|
63
66
|
publish [--release ID] Publish the dev version, or an earlier upload, for players; uploads
|
|
64
67
|
the thumbnail dewdrop.json names when it has changed
|
|
65
68
|
unpublish Take the game down for players
|
|
66
69
|
share EMAIL Let another developer play and update the dev version
|
|
67
70
|
unshare EMAIL Take that back
|
|
68
|
-
status Show the dev and published versions
|
|
71
|
+
status Show the dev and published versions, every named dev version running,
|
|
72
|
+
and where to play them
|
|
69
73
|
releases List every upload Dewdrop keeps, which is all of them until deleted;
|
|
70
74
|
any id, or its first 8 characters, feeds --release and delete
|
|
71
75
|
delete ID Delete an upload nothing runs, freeing its space (owner only)
|
|
72
|
-
delete-game NAME Delete this game, its name typed again to confirm:
|
|
76
|
+
delete-game NAME Delete this game, its name typed again to confirm: every version stops
|
|
73
77
|
now, and it is removed with its uploads and its players' saves. This
|
|
74
78
|
can't be undone (owner only)
|
|
75
79
|
--version Show this CLI's version
|
|
@@ -78,6 +82,12 @@ const HELP=`${RUN} — make three.js games on Dewdrop
|
|
|
78
82
|
eval, pause, resume, step, speed and repl also take the name of a game you develop. Those that reach your
|
|
79
83
|
seats reach only your own, in the dev version, and none starts one: open one in a browser first.
|
|
80
84
|
|
|
85
|
+
Named dev versions: a game runs up to eight beside its first, each at a link of its own, so that several
|
|
86
|
+
agents each show their own work. A name is 1 to 10 lowercase letters, digits or dashes. dev --new NAME
|
|
87
|
+
starts one, and is refused while one of that name runs: pick another, as status lists them. After that,
|
|
88
|
+
--name NAME on dev, stop, publish, status, logs, seat, sessions, eval, pause, resume, step, speed and repl
|
|
89
|
+
reaches it in place of the first. Every dev version shares the game's dev saves.
|
|
90
|
+
|
|
81
91
|
A coding agent driving the game, for example (${DEWDROP}/docs/coding-agents):
|
|
82
92
|
${RUN} dev && ${RUN} seat --out .dewdrop-seat.json # upload, and get a pass for its browser tool
|
|
83
93
|
# the browser tool sets the pass's cookie for its url, opens the url and awaits dewdrop.ready()
|
|
@@ -88,8 +98,10 @@ const HELP=`${RUN} — make three.js games on Dewdrop
|
|
|
88
98
|
// Each command's flags; share and unshare also take one address, delete one release, delete-game the game's name,
|
|
89
99
|
// logs, seat and the seat commands (SEATED) a game's name, eval its code, step its frames and speed its factor. Anything
|
|
90
100
|
// else on the line is refused.
|
|
91
|
-
const COMMANDS={init:['--game','--template'],login:[],logout:[],dev:['--watch','--release'],stop:[],publish:['--release'],unpublish:[],share:[],unshare:[],status:[],releases:[],delete:[],'delete-game':[],logs:['--follow'],seat:['--out'],sessions:['--json'],eval:['--seat','--backend','--json'],pause:['--seat','--json'],resume:['--seat','--json'],step:['--seat','--json'],speed:['--seat','--json'],repl:['--seat','--backend']};
|
|
92
|
-
const VALUED=['--game','--template','--release','--out','--seat'];
|
|
101
|
+
const COMMANDS={init:['--game','--template'],login:[],logout:[],dev:['--watch','--release','--new','--name'],stop:['--name'],publish:['--release','--name'],unpublish:[],share:[],unshare:[],status:['--name'],releases:[],delete:[],'delete-game':[],logs:['--follow','--name'],seat:['--out','--name'],sessions:['--json','--name'],eval:['--seat','--backend','--json','--name'],pause:['--seat','--json','--name'],resume:['--seat','--json','--name'],step:['--seat','--json','--name'],speed:['--seat','--json','--name'],repl:['--seat','--backend','--name']};
|
|
102
|
+
const VALUED=['--game','--template','--release','--out','--seat','--new','--name'];
|
|
103
|
+
// A dev version's name beside the game's first, as Dewdrop takes one.
|
|
104
|
+
const DEV_NAME=/^[a-z0-9][a-z0-9-]{0,9}$/;
|
|
93
105
|
// The commands that reach the developer's own seats, and the one value each takes after the game's name.
|
|
94
106
|
const SEATED={sessions:null,eval:'code',pause:null,resume:null,step:'frames',speed:'k',repl:null};
|
|
95
107
|
function options(command,args) {
|
|
@@ -107,7 +119,7 @@ function options(command,args) {
|
|
|
107
119
|
else out[key.slice(2)]=args[++i];
|
|
108
120
|
} else if(['share','unshare'].includes(command)&&!key.startsWith('-')&&out.email===undefined)out.email=key;
|
|
109
121
|
else if(command==='delete'&&!key.startsWith('-')&&out.release===undefined)out.release=key;
|
|
110
|
-
else if(command==='delete-game'&&!key.startsWith('-')&&out.
|
|
122
|
+
else if(command==='delete-game'&&!key.startsWith('-')&&out.confirm===undefined)out.confirm=key;
|
|
111
123
|
else if(['logs','seat'].includes(command)&&!key.startsWith('-')&&out.game===undefined)out.game=key;
|
|
112
124
|
// A seat command's words: its game's name, then its value — a lone word is the value for a command that takes one.
|
|
113
125
|
else if(Object.hasOwn(SEATED,command)&&(!key.startsWith('-')||key==='-')&&(out.words??=[]).length<(SEATED[command]?2:1))out.words.push(key);
|
|
@@ -115,6 +127,9 @@ function options(command,args) {
|
|
|
115
127
|
}
|
|
116
128
|
if(out.release!==undefined&&!/^[a-f0-9]{8,64}$/.test(out.release))throw new Error(`${command==='delete'?'delete':'--release'} takes a release id, or its first 8 or more characters, from ${RUN} releases.`);
|
|
117
129
|
if(out.watch&&out.release)throw new Error('Choose --watch or --release, not both.');
|
|
130
|
+
if(out.new!==undefined&&out.name!==undefined)throw new Error('Choose --new to start a dev version or --name to reach one running, not both.');
|
|
131
|
+
const devName=out.new??out.name;
|
|
132
|
+
if(devName!==undefined&&!DEV_NAME.test(devName))throw new Error(`${devName} isn't a dev version's name: a name is 1–10 lowercase letters, digits or dashes, starting with a letter or digit.`);
|
|
118
133
|
if(Object.hasOwn(SEATED,command)) {
|
|
119
134
|
const words=out.words??[],value=SEATED[command];
|
|
120
135
|
delete out.words;
|
|
@@ -181,7 +196,7 @@ async function main() {
|
|
|
181
196
|
try { project=readProject(process.cwd()); }
|
|
182
197
|
catch(error) { if(flags.game===undefined)throw error; }
|
|
183
198
|
const origin=dewdropOrigin();
|
|
184
|
-
const credentials=new Credentials(origin),client=new Client(origin,credentials);
|
|
199
|
+
const credentials=new Credentials(origin),client=new Client(origin,credentials,{devName:flags.new??flags.name??'',fresh:flags.new!==undefined});
|
|
185
200
|
// The commands that wait on Dewdrop stop waiting at Ctrl-C; the rest end the ordinary way. Every signal is taken,
|
|
186
201
|
// not the first alone: under `npm run dev`, npm passes the terminal's Ctrl-C on to the CLI, which has had it already,
|
|
187
202
|
// and a second signal must not end the CLI before it has said what it stopped.
|
|
@@ -236,7 +251,7 @@ async function main() {
|
|
|
236
251
|
}
|
|
237
252
|
if(command==='sessions') {
|
|
238
253
|
const answer=await client.sessions(game,signal);
|
|
239
|
-
console.log(flags.json?json(answer):seatTable(answer.sessions,game));
|
|
254
|
+
console.log(flags.json?json(answer):seatTable(answer.sessions,game,flags.name));
|
|
240
255
|
return;
|
|
241
256
|
}
|
|
242
257
|
if(command==='eval') {
|
|
@@ -266,8 +281,9 @@ async function main() {
|
|
|
266
281
|
let state;
|
|
267
282
|
try { state=await client.game(game); }
|
|
268
283
|
catch(error) { if(error.status===404)throw new Error(`${game} isn't on Dewdrop yet. Run ${RUN} dev to create it.`); throw error; }
|
|
269
|
-
const url=devPlayUrl(state);
|
|
270
|
-
|
|
284
|
+
const url=devPlayUrl(state),named=(state.named??[]).filter(each=>each.name!==flags.name);
|
|
285
|
+
const others=named.length?`\n Named: ${named.map(each=>`${each.name} ${describe(each,'stopped')} — ${each.url}/dev`).join('\n ')}`:'';
|
|
286
|
+
console.log(printable(`${game}\n ${flags.name?`Dev ${flags.name}:`.padEnd(13):'Dev version: '} ${describe(state.dev,'stopped')}${state.dev.release?` — ${url}`:''}${others}\n Published: ${describe(state.live,'not published')}${state.live.release?` — ${state.urls.play}`:''}\n Thumbnail: ${state.urls.thumbnail??'none'}`));
|
|
271
287
|
return;
|
|
272
288
|
}
|
|
273
289
|
if(command==='releases'){
|
|
@@ -275,7 +291,7 @@ async function main() {
|
|
|
275
291
|
if(!releases.length){console.log(`No uploads of ${game} yet. Run ${RUN} dev to make one.`);return;}
|
|
276
292
|
// What each release is to the game: the versions running it, else whether it was published before, is an older
|
|
277
293
|
// dev build, or is the latest upload.
|
|
278
|
-
const status=release=>[release.sha256===state.dev.release&&'dev',release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':release.devBuild?'dev build':'latest upload');
|
|
294
|
+
const status=release=>[release.sha256===state.dev.release&&'dev',...(state.named??[]).filter(each=>each.release===release.sha256).map(each=>`dev ${each.name}`),release.sha256===state.live.release&&'published'].filter(Boolean).join(', ')||(release.published?'published before':release.devBuild?'dev build':'latest upload');
|
|
279
295
|
console.log(printable(columns([['RELEASE','UPLOADED (UTC)','SIZE','STATUS','BY'],...releases.map(release=>[release.sha256.slice(0,12),new Date(release.created).toISOString().slice(0,16).replace('T',' '),size(release.bytes),status(release),release.email])])));
|
|
280
296
|
return;
|
|
281
297
|
}
|
|
@@ -286,9 +302,9 @@ async function main() {
|
|
|
286
302
|
console.log(printable(`Deleted ${release.slice(0,12)} from ${game}.`));return;
|
|
287
303
|
}
|
|
288
304
|
if(command==='delete-game'){
|
|
289
|
-
if(flags.
|
|
305
|
+
if(flags.confirm!==game)throw new Error(`delete-game takes the game's name to confirm. Run ${RUN} delete-game ${game} to delete ${game}.`);
|
|
290
306
|
await client.deleteGame(game);
|
|
291
|
-
console.log(`Deleted ${game}.
|
|
307
|
+
console.log(`Deleted ${game}. Every version is stopped, players can no longer open it, and it is removed with its uploads and its players' saves.`);return;
|
|
292
308
|
}
|
|
293
309
|
if(['share','unshare'].includes(command)) {
|
|
294
310
|
if(!flags.email)throw new Error(`${command} needs the developer's email address.`);
|
|
@@ -298,12 +314,13 @@ async function main() {
|
|
|
298
314
|
}
|
|
299
315
|
if(command==='stop'){
|
|
300
316
|
await client.stop(game,signal);
|
|
301
|
-
console.log(
|
|
317
|
+
console.log(flags.name?`Stopped ${game}'s dev version ${flags.name}. Run ${RUN} dev --new ${flags.name} to start it again.`:`Stopped ${game}'s dev version. Run ${RUN} dev to start it again.`);return;
|
|
302
318
|
}
|
|
303
319
|
if(command==='unpublish'){await client.publish(game,null,signal);console.log(`Unpublished ${game}. Players can no longer open it.`);return;}
|
|
304
320
|
if(command==='publish') {
|
|
305
321
|
const current=await client.game(game,signal);
|
|
306
322
|
const release=flags.release?await releaseId(client,game,flags.release):current.dev.release;
|
|
323
|
+
if(!release&&flags.name)throw new Error(`${game} has no dev version named ${flags.name} running. Run ${RUN} dev --new ${flags.name} first, or publish a kept upload with --release (see ${RUN} releases).`);
|
|
307
324
|
if(!release)throw new Error(`${game} has no dev version to publish. Run ${RUN} dev first, or publish a kept upload with --release (see ${RUN} releases).`);
|
|
308
325
|
// The thumbnail goes first, so an image Dewdrop refuses stops the publish before anything changes for players.
|
|
309
326
|
if(project.thumbnail&&await syncThumbnail(project,client,current,signal))console.log(`Uploaded the thumbnail, ${project.thumbnail}.`);
|
|
@@ -321,7 +338,11 @@ async function main() {
|
|
|
321
338
|
else {
|
|
322
339
|
// Claimed before the build, so a name someone else has or an ended sign-in is known at once.
|
|
323
340
|
await client.claim(game,signal);
|
|
324
|
-
if((await deploy(project,client,{signal,maps})).changed)
|
|
341
|
+
if((await deploy(project,client,{signal,maps})).changed){
|
|
342
|
+
// Run again as this run was: the version it names was neither started nor updated.
|
|
343
|
+
const again=flags.new?` --new ${flags.new}`:flags.name?` --name ${flags.name}`:'';
|
|
344
|
+
throw new Error(`Files changed during the build, so nothing was uploaded. Run ${RUN} dev${again} again, or ${RUN} dev${again} --watch to rebuild on every save.`);
|
|
345
|
+
}
|
|
325
346
|
// At a terminal the console follows, for the developer to watch; a script or an agent gets the upload alone, and
|
|
326
347
|
// reads the console with logs.
|
|
327
348
|
if(process.stdout.isTTY) {
|
package/src/project.js
CHANGED
|
@@ -180,11 +180,11 @@ export async function build(project, signal) {
|
|
|
180
180
|
const STARTER_FILES=['package.json','src','index.html','vite.config.js'];
|
|
181
181
|
// The SDK a new game depends on — the range moves with the SDK's minor, since a caret on 0.x stays within one —
|
|
182
182
|
// and this CLI, at its own version.
|
|
183
|
-
const SDK_RANGE='^0.
|
|
183
|
+
const SDK_RANGE='^0.10.0';
|
|
184
184
|
const CLI_RANGE=`^${JSON.parse(readFileSync(new URL('../package.json',import.meta.url),'utf8')).version}`;
|
|
185
185
|
// The games a new one can start from: Blank, which ships with this CLI, and the starter games in the public
|
|
186
186
|
// starter-templates repository, a folder each, at the commit this release pins.
|
|
187
|
-
const STARTERS={repo:'DewdropLabs/starter-templates',commit:'
|
|
187
|
+
const STARTERS={repo:'DewdropLabs/starter-templates',commit:'fcffe9dcc6dae96c59d6d6699883dbd88eaa89ad'};
|
|
188
188
|
const TEMPLATES={
|
|
189
189
|
blank:['Blank','a cube and a style prompt, the smallest game'],
|
|
190
190
|
'golden-glide':['Golden Glide','flight over golden-hour countryside, in gouache'],
|
package/src/session.js
CHANGED
|
@@ -7,21 +7,23 @@ import {readFileSync} from 'node:fs';
|
|
|
7
7
|
import {RUN} from './command.js';
|
|
8
8
|
import {printable,json} from './logs.js';
|
|
9
9
|
|
|
10
|
+
// A command as the developer runs it for dev version `devName`, '' the game's first.
|
|
11
|
+
const named=(command,devName)=>`${RUN} ${command}${devName?` --name ${devName}`:''}`;
|
|
10
12
|
// No seat of the developer's playing, in their words: how to get one.
|
|
11
|
-
const noSeat=game=>`No dev seat of yours is playing ${game}: open one in a browser (${
|
|
13
|
+
const noSeat=(game,devName)=>`No dev seat of yours is playing ${game}: open one in a browser (${named('seat',devName)}) first.`;
|
|
12
14
|
// The seat named `seat`, or the developer's newest when it names none, as `{seat, room}`.
|
|
13
15
|
export async function findSeat(client,game,seat,signal) {
|
|
14
16
|
const {sessions}=await client.sessions(game,signal);
|
|
15
|
-
if(!sessions.length)throw new Error(noSeat(game));
|
|
17
|
+
if(!sessions.length)throw new Error(noSeat(game,client.devName));
|
|
16
18
|
if(seat===undefined)return sessions[0];
|
|
17
19
|
const found=sessions.find(each=>each.seat===seat);
|
|
18
|
-
if(!found)throw new Error(`No dev seat of yours named ${seat} is playing ${game}. Run ${
|
|
20
|
+
if(!found)throw new Error(`No dev seat of yours named ${seat} is playing ${game}. Run ${named('sessions',client.devName)} to list yours.`);
|
|
19
21
|
return found;
|
|
20
22
|
}
|
|
21
23
|
// The seats as `sessions` prints them: a column each for the seat and its room, the newest — the one the other commands
|
|
22
24
|
// use when no --seat is given — first.
|
|
23
|
-
export function seatTable(sessions,game) {
|
|
24
|
-
if(!sessions.length)return noSeat(game);
|
|
25
|
+
export function seatTable(sessions,game,devName='') {
|
|
26
|
+
if(!sessions.length)return noSeat(game,devName);
|
|
25
27
|
const width=Math.max(4,...sessions.map(each=>each.seat.length));
|
|
26
28
|
return printable([`${'SEAT'.padEnd(width)} ROOM`,...sessions.map((each,i)=>`${each.seat.padEnd(width)} ${each.room}${i===0?' (default)':''}`)].join('\n'));
|
|
27
29
|
}
|
|
@@ -77,12 +79,12 @@ export function factor(value) {
|
|
|
77
79
|
if(!/^(0|1)?(\.[0-9]+)?$/.test(value??'')||!(k>0&&k<=1)||Math.ceil(1/k)>300)throw new Error('speed takes a factor above 0 and at most 1, no slower than 1/300, such as 0.25.');
|
|
78
80
|
return k;
|
|
79
81
|
}
|
|
80
|
-
const
|
|
82
|
+
const help=devName=>`Each line is evaluated in the seat (or, after .backend, in its room's backend) and its value printed.
|
|
81
83
|
.pause Pause the seat's room
|
|
82
84
|
.resume Resume it
|
|
83
85
|
.step N Run the room N frames (1 to 600), then pause it
|
|
84
86
|
.speed K Run the room at K times its speed (above 0, at most 1, no slower than 1/300)
|
|
85
|
-
.seat S Evaluate in your seat S from now on (${
|
|
87
|
+
.seat S Evaluate in your seat S from now on (${named('sessions',devName)} lists them)
|
|
86
88
|
.backend Evaluate in the room's backend from now on
|
|
87
89
|
.page Evaluate in the seat's page again
|
|
88
90
|
.help Show this
|
|
@@ -119,7 +121,7 @@ export async function repl(client,game,{seat,backend=false,maps,input=process.st
|
|
|
119
121
|
},
|
|
120
122
|
'.backend':()=>{backend=true;say(`Evaluating in ${current}'s room's backend.`);},
|
|
121
123
|
'.page':()=>{backend=false;say(`Evaluating in ${current}'s page.`);},
|
|
122
|
-
'.help':()=>say(
|
|
124
|
+
'.help':()=>say(help(client.devName)),
|
|
123
125
|
};
|
|
124
126
|
for await(const line of lines) {
|
|
125
127
|
const text=line.trim();
|