dewctl 0.9.2 → 0.10.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.
@@ -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 the scene holds: the colors, the words that describe each thing, the shapes,
9
- the style prompt and the sky. A look is a set of decisions about those, made once and kept to, not a filter
10
- switched on at the end. This skill gets the decisions from the user in a few questions and writes them to
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 `renderer.prompt` already starts with `style:` and has no `LOOK.md` has its look. Write `LOOK.md`
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`, and the colors the meshes have.
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 prompt, 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
- afternoon, soft greens with one red roof, seen from behind and a little above". Let the user correct the
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 also
44
- needs the sky, what the distance looks like, and what moves while the player stands still. Leave the rest at the
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. Ask which of what
60
- you'd take matters most, and start from the nearest recipe.
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, colors, words and shapes on the
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 prompt takes any style in words. A recipe is the fastest way to one that
90
- works.
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. A
103
- changing time means a second color for every mesh and a second sky. Default: the recipe's.
104
- - **Palette.** Three or four colors by their roles: the ground, the sky, the main built thing, the player or hero.
105
- Ask in color names and choose the hex yourself. Default: the recipe's colors.
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 or a neon tube a mesh that glows, which lights what's near it. Every light casts shadows by
112
+ itself; ask whether they're soft (a hazy sun, `userData.angle` about 0.03) or hard and long (a low, small sun).
113
+ 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?" Dewdrop lifts dark colors: night is every surface at about a fifth of its daylight color, and black is
108
- under about `#12` in each channel, with the darkness said in words. Only what the light reaches means floors
109
- and walls in small tiles whose colors follow the light
110
- ([pools of light](https://alpha.dewdrop.world/docs/baked-light#pools-of-light)), the most work of any answer.
111
- - **Mood.** Two or three words ("cozy, handmade, slow"). They become the prompt's adjectives and the
112
- descriptions' words.
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, and what comes near the camera, where a
118
- mesh grows into a blob. Default: third person, a few meters behind and a little above, close enough that the
119
- character is large in frame.
120
- - **Light and shadow.** Where the light comes from: the sun, lamps, candles, neon, a moon, nothing. The sun comes
121
- from the sky's words; a lamp, a candle, a window or a moon is a bright mesh described as glowing, something to
122
- build; warmth on a surface is its color. Soft shadows cost nothing: Dewdrop draws one under each character by
123
- itself. Hard, long shadows are thin dark strips, or a lit side and a dark side on every object
124
- ([sunlight](https://alpha.dewdrop.world/docs/baked-light#sunlight)). Default: the recipe's.
125
- - **Motion.** What moves while the player stands still: water, trees, flags, birds, fish. Small moving things
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? Cut edges white, or the paper's color?
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? Two-tone shading, or flat? The recipe's summer afternoon, or sunset?
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? Outlines, or none? Fewer things far away keep the page open.
148
- - **Stained glass:** a dark window frame around the view, or none? Thick lead, or thin? The recipe is jewel
149
- colors over dark lead. A few big panes read as a window; fine detail reads as
150
- hatching.
151
- - **Neon cyberpunk:** rain, or dry? Which two neon colors? How much of the frame stays dark? Every glow is a mesh.
152
- - **Noir:** black and white, or a tint? One light source per scene, so the shadows agree?
153
- - **Horror:** a carried light, fixed candles, or moonlight through the windows? How far can the player see?
154
- Flames about 5 × 11 cm; smaller ones read as unlit.
155
- - **Winter:** overcast, or sunny? Snowfall in the sky's words, or none: falling flakes can't be built.
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 with a `PointLight` that moves with the player. Flames about 5 × 11 cm;
169
+ smaller ones read as unlit.
170
+ - **Winter:** overcast, or sunny? Snowfall in the prompt's words, or none: falling flakes can't be built.
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 and the sky into the code (`src/look.js`
163
- in a starter, `renderer.prompt` in `src/main.js` in Blank). Keep both in step: a change to one is a change to the
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: clay stop motion.` Matte plasticine with thumbprints, chunky rounded shapes, saturated colors, a tabletop
174
- set. (The whole prompt as it goes into `renderer.prompt`: under 4 KiB, the style and then the frame as the camera
175
- sees it, in the meshes' colors and words. A starter's prompt stands as it is.)
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`: "a plain pale blue studio backdrop".
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 | Words |
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
- The material words every description carries ("plasticine", "clay"), one description for each kind of thing.
191
- A color word matches the mesh's color; lightness words ("pale", "dark") stay out, since either overrides the
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,38 @@ 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 version in
214
- your browser tool ([for coding agents](https://alpha.dewdrop.world/docs/coding-agents)), take screenshots after the
215
- first second, and check each against `LOOK.md`. A screenshot is a still frame, and without hardware acceleration a
216
- half-size preview, so then ask the user to judge the look in motion, with three specific questions from `LOOK.md`:
217
- "Is the grass a bright plasticine green? Does the lamp glow? Is the sky a plain pale backdrop?" Put what you saw
218
- and the answers under "Checked on Dewdrop", and change the code and `LOOK.md` together, one thing at a time.
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 | paler colors, nearer the sky's; distant things faded toward it; fewer small meshes far away |
227
- | darker, moodier | every color to about a fifth; the lights as bright meshes; "in deep shadow" in the words |
228
- | a carried candle or torch | floors and walls in tiles about 1 m across, each lit by its distance from the light every frame ([pools of light](https://alpha.dewdrop.world/docs/baked-light#pools-of-light)) |
229
- | a lit side and a dark side, long shadows | each object's faces split by the way they point, the sunward ones lighter ([sunlight](https://alpha.dewdrop.world/docs/baked-light#sunlight)) |
230
- | more detail, more realistic | more meshes and truer shapes, the biggest where the camera goes |
231
- | fog, mist, rain, god rays | words in the prompt and the sky; colors faded with distance |
232
- | smoke, steam | words alone; no mesh works for them |
233
- | dust kicked up | a few big soft puffs |
234
- | wood grain, fabric, rust, any texture | the material in the words; a texture file shows nothing |
235
- | glow, neon, fire, a lit window | a bright saturated mesh described as glowing; a three.js light shows nothing |
236
- | glass, a window | a mid blue-grey with the sky in its words; an unlit window is an opening with something behind it |
237
- | shadows | thin dark strips on the ground; soft ones under characters come by themselves; large ones read as raised pads |
238
- | a sign you can read | the letters built as meshes; a sign only described shows no word |
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 with a `PointLight` at it, moving with the player |
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; no mesh works for a plume. 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
+ | shiny, polished, metal | low `roughness`; `metalness` 1 with the metal's own color for metal |
263
+ | glass, water, ice | a transparent material with `userData.modelLayer = 'surface'`, described as the surface |
264
+ | wet ground, reflections | the ground at low `roughness`, which shows the lights in it, and "wet" in its words |
265
+ | leaves, grass, a fence, lace | cards with a cut-out texture and an `alphaTest` |
266
+ | shadows | every light casts them; a softer edge from a larger `userData.angle` on the sun |
267
+ | a sign you can read | the letters built as meshes or in the sign's texture; a sign only described shows no word |
239
268
  | big clouds | white spheres stacked into towers about 1 km or more away, described as a cloud |
240
- | wet ground, reflections | the ground's words; a plane meant as a reflection comes out as a slab |
241
- | cinematic, like a film | the prompt's words, and the camera closer to what matters |
269
+ | cinematic, like a film | a photographic medium and dramatic light in the style phrase, and the camera closer to what matters |
242
270
  | cute, toy-like | big heads and rounded shapes, saturated colors |
243
- | sharper, crisper | outlines in the prompt, flat facets, fewer colors |
271
+ | sharper, crisper | the flat medium named plainly in the style phrase, flat facets, fewer colors |
@@ -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 the scene, in the style the game describes.
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 camera, the light and what moves, written to `LOOK.md`. From then on
11
- `LOOK.md` is the look: every color, description and shape follows it, and the skill runs again only when the user
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 `renderer.prompt` already starts with `style:` and there is no `LOOK.md`, the look is chosen too. Write
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,103 @@ 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 renders the game from what is in the three.js scene ([renderer](https://alpha.dewdrop.world/docs/renderer)):
27
- - `renderer.prompt`: the style of the whole game. It starts with `style:` and the style, then describes the scene:
28
- `'style: claymation. A handmade plasticine miniature on a dark blue studio backdrop.'`
29
- - `scene.background`, a `THREE.Color`, and `renderer.backgroundDescription`, the sky in words.
30
- - Each mesh's shape, its base color (its material's `color`) and its `userData.description`.
31
-
32
- Textures, vertex colors, emissive colors, lights, shadows, fog, custom shaders, points, lines and sprites don't
33
- show on Dewdrop. The prompt is at most 4 KiB, the background description and each description at most 1 KiB. A
34
- scene draws at most 65,536 objects: each mesh counts once, and so does each instance.
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: colors, descriptions, shapes, light and shadow, then the prompt and the background.
41
- A new look usually means changing the first three together.
42
-
43
- - **Color carries the most.** A mesh comes out at its base color, whatever the words say. Very dark colors for
44
- night, close to white for a drawing on paper. Set a color on every mesh: colors don't pass down the scene graph.
45
- - **Dark means very dark.** Dewdrop lifts dark colors. For black, stay under about `#12` in each channel and say
46
- "black". For deep darkness, use `#02` to `#06` and words such as "in deep shadow"
47
- ([colors](https://alpha.dewdrop.world/docs/renderer#colors)).
48
- - **Describe what the camera sees, in the style's words:** "the back of an owl's head" behind a character,
49
- "a plasticine tree". Use one description for each kind of object.
50
- - **Keep color words in step with the colors.** A color or lightness word overrides the mesh's color: a pale roof
51
- described as "terracotta" turns red, and a dark wall described as "pale cream" turns white. Name the material
52
- without its lightness
53
- ([descriptions](https://alpha.dewdrop.world/docs/renderer#descriptions)).
54
- - A group's description reaches every mesh under it that has none of its own; `null` gives none, and a mesh's
55
- `name` is never used ([scene graph](https://alpha.dewdrop.world/docs/descriptions)).
56
- - **The prompt describes the frame as the camera sees it:** what's in the middle and what's where, in the meshes'
57
- colors and words. A prompt that describes an object differently fights its mesh, and it can't override the colors.
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 one, only its lights light it, so give it a sky as well as a sun.
59
+ - **Brightness is relative.** The exposure adapts, so what matters is each light next to the others. A sun's
60
+ `userData.angle` softens its shadows: 0.02 to 0.05 gives a hazy sun.
61
+ - **Night is dim light, not dark colors.** Keep the materials' everyday colors, turn the lights down, and fix the
62
+ exposure so the night stays dark: `renderer.exposure = { ev: 2, strength: 0 }`, its `ev` chosen on Dewdrop
63
+ ([a fixed exposure](https://alpha.dewdrop.world/docs/lighting#a-fixed-exposure)).
64
+ - **A glowing thing is a mesh that glows:** a lamp, a candle flame, a lit window or neon is a material's
65
+ `emissive` times its `emissiveIntensity`, and it lights what's around it. For a light carried by a character,
66
+ add a `PointLight` at the flame ([glowing things](https://alpha.dewdrop.world/docs/lighting#glowing-things)).
67
+ - **Give every mesh a material with a color.** `MeshStandardMaterial` takes highlights by its `roughness` (0
68
+ polished to 1 matte) and `metalness`; `MeshBasicMaterial` is unlit. A geometry needs normals to be lit.
69
+ - **Textures show** (`map`, `emissiveMap`, `alphaMap`, `normalMap`) from PNG, JPEG or WebP, glTF models and
70
+ `DataTexture`s: their colors and larger patterns carry into the picture, and their finest detail is drawn again
71
+ in the style. A canvas or video texture doesn't show
72
+ ([textures](https://alpha.dewdrop.world/docs/lighting#textures)).
73
+ - **Foliage, fences and lace are cut-outs:** cards with a texture and an `alphaTest`, `opacity` 1 and `transparent`
74
+ off ([cut-outs](https://alpha.dewdrop.world/docs/lighting#cut-outs-and-foliage)). A transparent material is a
75
+ glow over the scene; for water, glass and ice set `userData.modelLayer = 'surface'`
76
+ ([transparency](https://alpha.dewdrop.world/docs/lighting#transparency)).
77
+ - **A drawn look on white paper needs near-white colors** and bright, even light.
78
+ - To find which mesh became a blob, give the suspects a loud color such as magenta for a moment, and check again.
79
+
80
+ Shapes ([shapes](https://alpha.dewdrop.world/docs/renderer#shapes)):
58
81
  - **Dewdrop keeps your shapes.** A style made of shapes needs them: cubes for voxel, folded flat faces for paper,
59
82
  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 ([shapes](https://alpha.dewdrop.world/docs/renderer#shapes)).
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)).
83
+ letters you want read, as meshes or in a texture.
72
84
  - **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 to 0.7 m from the camera, as
74
- its children ([camera](https://alpha.dewdrop.world/docs/camera)).
75
- - **Small moving things smear.** Make what matters large in frame. Fish, flocks and sparks: muted, about 0.6 m long
76
- or more, 8 m or more from the camera. Smoke and steam can't be built; dust kicked up is a few big soft puffs.
77
- Turn flat things to face the camera
85
+ parts a few meters from anywhere the camera goes, and characters 2.5 m or more. In first person, hold items 0.6
86
+ to 0.7 m from the camera, as its children ([camera](https://alpha.dewdrop.world/docs/camera)).
87
+ - **Small moving things lose their shape.** Make what matters large in frame. Fish, flocks and sparks: muted,
88
+ about 0.6 m long or more, 8 m or more from the camera. Turn flat things to face the camera
78
89
  ([what to watch for](https://alpha.dewdrop.world/docs/renderer#what-to-watch-for)).
79
- - To find which mesh became a blob, give the suspects a loud color such as magenta for a moment, and check again.
90
+ - **Atmosphere is words.** Mist, rain, god rays, smoke and steam go in the prompt's scene sentence: no mesh works
91
+ for a plume of smoke.
92
+
93
+ Words ([prompt and descriptions](https://alpha.dewdrop.world/docs/prompting)):
94
+ - **The prompt has exactly this form:** `style: <style phrase>. <scene sentence>`, 15 to 35 words in all.
95
+ `'style: Needle-felted wool diorama with soft studio lighting. A cozy farmyard in the morning, viewed from a high angle.'`
96
+ - **The style phrase is a medium with its light,** about 8 to 14 words: name the medium concretely ("impasto oil
97
+ painting on canvas", not "oil style"), a flat medium plainly ("flat vector illustration"), and end with the light,
98
+ in agreement with the scene's lights. Describe the look, never an artist or a studio
99
+ ([the style phrase](https://alpha.dewdrop.world/docs/prompting#the-style-phrase)).
100
+ - **The scene sentence** (at most 25 words) holds only the scene broadly, its conditions (time of day, weather, where
101
+ the light comes from, the camera's angle and framing) and at most one thing true of the whole scene. It names
102
+ nothing that has its own description, and no praise such as "highly detailed"
103
+ ([the scene sentence](https://alpha.dewdrop.world/docs/prompting#the-scene-sentence)).
104
+ - **A description is one plain string naming one thing**, with no leading "a" or "the", in one form for the whole
105
+ game: short (1 to 4 words, `plaster house`) or rich (4 to 12 words, `cracked cream plaster house with green
106
+ shutters`). Keep style words out, unless the world is made of a material (`knitted wool pumpkin`), and keep color
107
+ words in step with the mesh's color. Describe what the camera sees: `back of brown owl head` behind a character
108
+ ([descriptions](https://alpha.dewdrop.world/docs/prompting#descriptions)).
109
+ - **Describe everything in view, or nothing.** A frame with a few things described comes out worse than one with
110
+ none: describe the ground, the walls and the sky too. Every mesh of one thing gets the same string, so put it on
111
+ the group; different things get different strings; three or more small things of a kind share a plural; specks
112
+ get `null`. Only the 32 largest described things in view are read
113
+ ([what gets a description](https://alpha.dewdrop.world/docs/prompting#what-gets-a-description)).
114
+ - A group's description reaches every mesh under it that has none of its own; `null` gives none, and a mesh's
115
+ `name` is never used. `userData.instanceDescriptions` describes an instanced mesh's instances one by one
116
+ ([scene graph](https://alpha.dewdrop.world/docs/descriptions)).
117
+ - **A character close to the camera can describe its parts:** `helmet of the knight in dented steel armor`, the
118
+ part's name, `of the` and the character's own description
119
+ ([characters and their parts](https://alpha.dewdrop.world/docs/prompting#characters-and-their-parts)).
120
+ - **The sky is the background.** Describe it in `renderer.backgroundDescription`, with a matching `scene.background`
121
+ color. Big clouds are stacked white spheres about 1 km or more away.
122
+ - **A change of look is a cut**, 0.15 to 0.3 s later, with no blend. Change the prompt, lights, colors and
123
+ descriptions in the same frame ([a change of look](https://alpha.dewdrop.world/docs/renderer#a-change-of-look-is-a-cut)).
80
124
 
81
125
  The code ([limits](https://alpha.dewdrop.world/docs/limits)):
82
126
  - 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 +143,9 @@ Follow the [development flow](https://alpha.dewdrop.world/docs/development-flow)
99
143
  in its dev version; there is no local preview.
100
144
  1. **Shapes:** build the scene and the game from simple shapes, and play it until it works.
101
145
  Check that the player and the roads show. Seed any random layout.
102
- 2. **Colors:** give every mesh its base color.
103
- 3. **Descriptions:** say what each thing is and what it's made of, in the style's words.
104
- 4. **Style prompt:** set the prompt for the whole game, and the sky.
146
+ 2. **Materials and light:** give every mesh a material with a color, and light the scene.
147
+ 3. **Descriptions:** say what each thing in view is, the ground and the sky included.
148
+ 4. **Style prompt:** set the prompt for the whole game: its medium, its light and the scene.
105
149
 
106
150
  After each step, upload with `npm run dev`: it builds the game, uploads it and prints the link to play it on
107
151
  Dewdrop; in a script it returns once the game is ready to play. Upload when there is something to check, not after
@@ -109,9 +153,9 @@ every edit. If the user runs `npx dewctl dev --watch`, every save uploads by its
109
153
  build into the same folder.
110
154
 
111
155
  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 glow as you walk past?", "What does the sky look
113
- like?"): the user judges the look in motion, not from a still frame. Change one thing at a time, so you know what
114
- each change did.
156
+ user specific questions about it in motion ("Does the lantern light the path as you walk past?", "What does the
157
+ sky look like?"): the user judges the look in motion, not from a still frame. Change one thing at a time, so you
158
+ know what each change did.
115
159
 
116
160
  ## 5. Check it yourself
117
161
 
@@ -119,16 +163,16 @@ You can play the dev version in a browser tool and work it from the terminal
119
163
  ([for coding agents](https://alpha.dewdrop.world/docs/coding-agents)).
120
164
 
121
165
  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`.
166
+ `if (session.dev) globalThis.game = {scene, player, level}`, with `session` from `dewdrop-sdk`.
123
167
  2. Right after uploading, `npx dewctl seat --out .dewdrop-seat.json` gets a pass. It works once, within 10
124
168
  minutes. Keep the file out of git and out of the build folder.
125
169
  3. In a browser tool (headless is fine), set the pass's cookie, its `name` and `value`, for its `url`. Open the
126
170
  `url`, wait for `window.dewdrop`, then `await dewdrop.ready()`. Keep that page in front, and give each player a
127
171
  browser of its own. Each upload reloads the page: wait for `ready()` again
128
172
  ([headless browsers](https://alpha.dewdrop.world/docs/headless)).
129
- 4. Take screenshots after the first second, which is plain and grey. Without hardware acceleration the browser
130
- gets a half-size preview at up to 5 frames a second: fine for layout and state, so let the user judge the look
131
- in motion.
173
+ 4. Take screenshots after the first second, once the exposure and the light have settled. Without hardware
174
+ acceleration the browser gets a half-size preview at up to 5 frames a second: fine for layout and state, so let
175
+ the user judge the look in motion.
132
176
 
133
177
  From the terminal ([commands](https://alpha.dewdrop.world/docs/terminal)):
134
178
  - `npx dewctl sessions` lists your seats, newest first. `npx dewctl eval '<code>'` runs code in the newest and
@@ -140,6 +184,10 @@ From the terminal ([commands](https://alpha.dewdrop.world/docs/terminal)):
140
184
  - To hold a key for 30 frames, evaluate
141
185
  `document.dispatchEvent(new KeyboardEvent('keydown', {code: 'ArrowRight', key: 'ArrowRight', bubbles: true}))`,
142
186
  `step 30`, then dispatch its `keyup` the same way.
187
+ - To check the words, with `scene` on `globalThis.game`, list each description with the number of meshes and
188
+ instances that carry it, and those with none (a `null` description counts as neither):
189
+ `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}})()'`.
190
+ Every big thing in view should be described, in one form, and each thing by one string.
143
191
  - `npx dewctl logs` prints every seat's and the backend's console and how each session ended, with stacks in your
144
192
  source. Read it while the game plays, or keep `--follow` running
145
193
  ([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, describe the look of your whole game here…
10
- renderer.prompt='A polished turquoise cube floating in a dark blue studio, soft cinematic lighting, clean stylized 3D game art.';
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
- const cube=new THREE.Mesh(new THREE.BoxGeometry(1.5,1.5,1.5),new THREE.MeshStandardMaterial({color:'#4edbb1',roughness:0.65}));
14
- // …and what this mesh is.
15
- cube.userData.description='A polished turquoise cube';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dewctl",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "Build and publish three.js games on Dewdrop.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/logs.js CHANGED
@@ -6,13 +6,19 @@ import {sleep} from './client.js';
6
6
  const WAIT_MS=25000,MOST_REST_MS=30000;
7
7
  // The characters but tab and line breaks that a terminal takes as commands rather than text, shown as `?`.
8
8
  export const CONTROL=/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g;
9
+ // Text from Dewdrop as printed: a game's own words reach it — its console, what its code threw, its compile errors —
10
+ // so each control character is shown as `?`, and no game moves the cursor, retitles the window or writes the clipboard.
11
+ export const printable=text=>String(text).replace(CONTROL,'?');
12
+ // A value printed as JSON: JSON.stringify writes the controls below space as escapes itself, but not DEL and the C1
13
+ // controls, which a terminal may take as commands too; they are written as escapes as well, the JSON reading the same.
14
+ export const json=(value,indent)=>JSON.stringify(value,null,indent).replace(/[\x7f-\x9f]/g,c=>`\\u00${c.charCodeAt(0).toString(16)}`);
9
15
  const two=n=>String(n).padStart(2,'0');
10
16
  // A line as printed: this computer's time of it, where it came from — the page of a seat, named by its player, the
11
17
  // backend, or a seat's session — its level, and its text, positions mapped by `maps` for the release that wrote it.
12
18
  export function format(line,maps) {
13
19
  const at=new Date(line.at),time=Number.isNaN(at.getTime())?'':`${two(at.getHours())}:${two(at.getMinutes())}:${two(at.getSeconds())} `;
14
20
  const text=maps?maps.text(line.release,String(line.text)):String(line.text);
15
- return `${time}[${line.source}${line.seat?` ${line.seat}`:''}] ${line.level}: ${text}`.replace(CONTROL,'?');
21
+ return printable(`${time}[${line.source}${line.seat?` ${line.seat}`:''}] ${line.level}: ${text}`);
16
22
  }
17
23
  // Prints `game`'s dev console from the start of what Dewdrop keeps: those lines alone, or with `follow` each new line
18
24
  // as it comes until `signal` ends it, starting again from the start when the dev version restarts. Following, a
@@ -29,7 +35,7 @@ export async function printLogs(client,game,{signal,follow=false,maps,log=consol
29
35
  catch(error) {
30
36
  if(signal?.aborted)break;
31
37
  if(!follow||!(error.transient||[429,503].includes(error.status)||error.status>=500))throw error;
32
- if(!failures++)note(error.status===503?`Waiting for ${game}'s dev version to run…`:`${error.message} Following again once Dewdrop answers.`);
38
+ if(!failures++)note(error.status===503?`Waiting for ${game}'s dev version to run…`:printable(`${error.message} Following again once Dewdrop answers.`));
33
39
  try { await sleep(Math.min(restMs*2**(failures-1),MOST_REST_MS),signal); } catch { break; }
34
40
  continue;
35
41
  }
package/src/main.js CHANGED
@@ -12,7 +12,7 @@ import {signInLink,waitForApproval} from './login.js';
12
12
  import {RUN} from './command.js';
13
13
  import {syncThumbnail} from './thumbnail.js';
14
14
  import {SourceMaps} from './sourcemap.js';
15
- import {printLogs} from './logs.js';
15
+ import {printLogs,printable,json} from './logs.js';
16
16
  import {findSeat,seatTable,codeOf,shown,machine,roomLine,frames,factor,repl} from './session.js';
17
17
 
18
18
  const HELP=`${RUN} — make three.js games on Dewdrop
@@ -194,13 +194,13 @@ async function main() {
194
194
  if(command==='login') {
195
195
  credentials.prepare();
196
196
  const link=signInLink(origin);
197
- console.log(`Open this link to sign in the Dewdrop CLI:\n\n ${link.url}\n\nCheck that the page shows ${link.code}, then choose Sign in the CLI. Waiting…`);
197
+ console.log(printable(`Open this link to sign in the Dewdrop CLI:\n\n ${link.url}\n\nCheck that the page shows ${link.code}, then choose Sign in the CLI. Waiting…`));
198
198
  if(atScreen())open(link.url);
199
199
  let me;
200
200
  try { me=await waitForApproval(client,link.token,{signal}); }
201
201
  catch(error) { throw signal.aborted?new Error('Sign-in cancelled.'):error; }
202
202
  credentials.write({token:link.token,email:me.email,expires:me.expires});
203
- console.log(`Signed in as ${me.username??me.email}.`);
203
+ console.log(printable(`Signed in as ${me.username??me.email}.`));
204
204
  return;
205
205
  }
206
206
  if(command==='logout') {
@@ -229,21 +229,21 @@ async function main() {
229
229
  if(flags.out?.split(/[\\/]/).includes('..'))throw new Error(`Name the --out file without .., such as .dewdrop-seat.json in the game's folder.`);
230
230
  if(flags.out&&project&&insideBundle(project,flags.out))throw new Error(`${flags.out} is in ${project.bundle}, which ${RUN} dev uploads, so the pass would be uploaded with the game. Write it outside that folder: --out .dewdrop-seat.json writes it in the game's folder, which uploads skip.`);
231
231
  const pass=await client.seat(game,signal);
232
- if(!flags.out){process.stdout.write(`${JSON.stringify(pass,null,2)}\n`);return;}
232
+ if(!flags.out){process.stdout.write(`${json(pass,2)}\n`);return;}
233
233
  writePrivate(flags.out,`${JSON.stringify(pass,null,2)}\n`);
234
- console.log(`Wrote a seat pass for ${game} to ${flags.out}. It expires at ${pass.expires}.`);
234
+ console.log(printable(`Wrote a seat pass for ${game} to ${flags.out}. It expires at ${pass.expires}.`));
235
235
  return;
236
236
  }
237
237
  if(command==='sessions') {
238
238
  const answer=await client.sessions(game,signal);
239
- console.log(flags.json?JSON.stringify(answer):seatTable(answer.sessions,game));
239
+ console.log(flags.json?json(answer):seatTable(answer.sessions,game));
240
240
  return;
241
241
  }
242
242
  if(command==='eval') {
243
243
  const code=await codeOf(flags.code,process.stdin,signal);
244
244
  const seat=flags.seat??(await findSeat(client,game,undefined,signal)).seat;
245
245
  const answer=await client.evaluate(game,seat,code,Boolean(flags.backend),signal);
246
- if(flags.json)console.log(JSON.stringify(await machine(client,game,answer,maps,signal)));
246
+ if(flags.json)console.log(json(await machine(client,game,answer,maps,signal)));
247
247
  else {
248
248
  const printed=await shown(client,game,answer,maps,signal);
249
249
  (printed.error?console.error:console.log)(printed.text);
@@ -255,7 +255,7 @@ async function main() {
255
255
  const fields=command==='step'?{frames:frames(flags.frames)}:command==='speed'?{k:factor(flags.k)}:{};
256
256
  const {room}=await findSeat(client,game,flags.seat,signal);
257
257
  const answer=await client.room(game,room,command,fields,signal);
258
- console.log(flags.json?JSON.stringify(answer):roomLine(room,answer,fields.k));
258
+ console.log(flags.json?json(answer):roomLine(room,answer,fields.k));
259
259
  return;
260
260
  }
261
261
  if(command==='repl') {
@@ -267,7 +267,7 @@ async function main() {
267
267
  try { state=await client.game(game); }
268
268
  catch(error) { if(error.status===404)throw new Error(`${game} isn't on Dewdrop yet. Run ${RUN} dev to create it.`); throw error; }
269
269
  const url=devPlayUrl(state);
270
- console.log(`${game}\n Dev version: ${describe(state.dev,'stopped')}${state.dev.release?` — ${url}`:''}\n Published: ${describe(state.live,'not published')}${state.live.release?` — ${state.urls.play}`:''}\n Thumbnail: ${state.urls.thumbnail??'none'}`);
270
+ console.log(printable(`${game}\n Dev version: ${describe(state.dev,'stopped')}${state.dev.release?` — ${url}`:''}\n Published: ${describe(state.live,'not published')}${state.live.release?` — ${state.urls.play}`:''}\n Thumbnail: ${state.urls.thumbnail??'none'}`));
271
271
  return;
272
272
  }
273
273
  if(command==='releases'){
@@ -276,14 +276,14 @@ async function main() {
276
276
  // What each release is to the game: the versions running it, else whether it was published before, is an older
277
277
  // dev build, or is the latest upload.
278
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');
279
- console.log(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])]));
279
+ 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
280
  return;
281
281
  }
282
282
  if(command==='delete'){
283
283
  if(!flags.release)throw new Error(`delete needs a release id from ${RUN} releases.`);
284
284
  const release=await releaseId(client,game,flags.release);
285
285
  await client.deleteRelease(game,release);
286
- console.log(`Deleted ${release.slice(0,12)} from ${game}.`);return;
286
+ console.log(printable(`Deleted ${release.slice(0,12)} from ${game}.`));return;
287
287
  }
288
288
  if(command==='delete-game'){
289
289
  if(flags.name!==game)throw new Error(`delete-game takes the game's name to confirm. Run ${RUN} delete-game ${game} to delete ${game}.`);
@@ -308,11 +308,11 @@ async function main() {
308
308
  // The thumbnail goes first, so an image Dewdrop refuses stops the publish before anything changes for players.
309
309
  if(project.thumbnail&&await syncThumbnail(project,client,current,signal))console.log(`Uploaded the thumbnail, ${project.thumbnail}.`);
310
310
  const state=await client.publish(game,release,signal);
311
- console.log(`Published ${release.slice(0,12)}. Players can open ${game} at ${state.urls.play}`);return;
311
+ console.log(printable(`Published ${release.slice(0,12)}. Players can open ${game} at ${state.urls.play}`));return;
312
312
  }
313
313
  if(flags.release){
314
314
  const release=await releaseId(client,game,flags.release);
315
- try { await client.activate(game,release,signal,state=>console.log(`Starting ${release.slice(0,12)} at ${devPlayUrl(state)}`)); }
315
+ try { await client.activate(game,release,signal,state=>console.log(printable(`Starting ${release.slice(0,12)} at ${devPlayUrl(state)}`))); }
316
316
  catch(error) { error.message=maps.text(release,error.message); throw error; }
317
317
  console.log('Ready to play.');return;
318
318
  }
@@ -330,4 +330,4 @@ async function main() {
330
330
  }
331
331
  }
332
332
  }
333
- main().catch(error=>{console.error(`dewctl: ${error.message}`);process.exitCode=1;});
333
+ main().catch(error=>{console.error(`dewctl: ${printable(error.message)}`);process.exitCode=1;});
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.9.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:'f49e446e2f4b2de2a622c7ddd56060a167b6508f'};
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
@@ -5,7 +5,7 @@
5
5
  import {createInterface} from 'node:readline';
6
6
  import {readFileSync} from 'node:fs';
7
7
  import {RUN} from './command.js';
8
- import {CONTROL} from './logs.js';
8
+ import {printable,json} from './logs.js';
9
9
 
10
10
  // No seat of the developer's playing, in their words: how to get one.
11
11
  const noSeat=game=>`No dev seat of yours is playing ${game}: open one in a browser (${RUN} seat) first.`;
@@ -23,7 +23,7 @@ export async function findSeat(client,game,seat,signal) {
23
23
  export function seatTable(sessions,game) {
24
24
  if(!sessions.length)return noSeat(game);
25
25
  const width=Math.max(4,...sessions.map(each=>each.seat.length));
26
- return [`${'SEAT'.padEnd(width)} ROOM`,...sessions.map((each,i)=>`${each.seat.padEnd(width)} ${each.room}${i===0?' (default)':''}`)].join('\n').replace(CONTROL,'?');
26
+ return printable([`${'SEAT'.padEnd(width)} ROOM`,...sessions.map((each,i)=>`${each.seat.padEnd(width)} ${each.room}${i===0?' (default)':''}`)].join('\n'));
27
27
  }
28
28
  // The code `eval` is given: the argument itself, everything on standard input for `-`, or a file's text for `@FILE`.
29
29
  // Reading standard input ends at `signal`, the input let go so the CLI can end.
@@ -49,9 +49,9 @@ export async function shown(client,game,answer,maps,signal) {
49
49
  if(typeof answer.error==='string') {
50
50
  let text=answer.error;
51
51
  if(maps)try { text=maps.text((await client.game(game,signal)).dev.release,text); } catch {}
52
- return {error:true,text:text.replace(CONTROL,'?')};
52
+ return {error:true,text:printable(text)};
53
53
  }
54
- return {error:false,text:'value' in answer?JSON.stringify(answer.value,null,2):'undefined'};
54
+ return {error:false,text:'value' in answer?json(answer.value,2):'undefined'};
55
55
  }
56
56
  // The answer to an evaluate, `--json`: as Dewdrop gave it, with the error's positions mapped as printed.
57
57
  export async function machine(client,game,answer,maps,signal) {
@@ -61,7 +61,7 @@ export async function machine(client,game,answer,maps,signal) {
61
61
  // A room's state after an action, in words, and after a speed the speed it runs at: the room rounds a factor `k`
62
62
  // down to 1/2, 1/3, 1/4 and so on, and a paused room runs at it once resumed.
63
63
  export function roomLine(room,{frame,paused},k) {
64
- const line=`Room ${room}: frame ${frame}, ${paused?'paused':'running'}.`;
64
+ const line=printable(`Room ${room}: frame ${frame}, ${paused?'paused':'running'}.`);
65
65
  if(k===undefined)return line;
66
66
  const every=Math.ceil(1/k);
67
67
  return `${line} It runs at ${every===1?'full':`1/${every}`} speed${paused?' once resumed':''}.`;
@@ -94,8 +94,9 @@ export async function repl(client,game,{seat,backend=false,maps,input=process.st
94
94
  const terminal=Boolean(input.isTTY&&output.isTTY);
95
95
  const stop=new AbortController(),{signal}=stop;
96
96
  let current=(await findSeat(client,game,seat)).seat;
97
- const say=text=>output.write(`${text}\n`);
98
- const prompt=()=>`${game} ${current}${backend?' backend':''}> `;
97
+ // Everything the console prints names what Dewdrop answered — a seat, a room, a value — so all of it is printable.
98
+ const say=text=>output.write(`${printable(text)}\n`);
99
+ const prompt=()=>printable(`${game} ${current}${backend?' backend':''}> `);
99
100
  say(`Evaluating in ${current}${backend?'\'s backend':''} of ${game}. .help lists the commands.`);
100
101
  const lines=createInterface({input,output:terminal?output:undefined,terminal,prompt:prompt()});
101
102
  // Ctrl-C at a terminal; a console reading a pipe ends at its end, once every line read is answered.
package/src/watch.js CHANGED
@@ -3,6 +3,7 @@ import {watch as watchDirectory} from 'node:fs';
3
3
  import {fingerprint,build,snapshot,followed} from './project.js';
4
4
  import {devPlayUrl} from './play.js';
5
5
  import {RUN} from './command.js';
6
+ import {printable} from './logs.js';
6
7
 
7
8
  // A byte count as a person reads it.
8
9
  export function size(bytes) {
@@ -16,7 +17,7 @@ const count=(n,noun)=>`${n} ${noun}${n===1?'':'s'}`;
16
17
  // What a push says as it goes, in the developer's terms: the files going up, or checked with Dewdrop first, the ones
17
18
  // Dewdrop turned out to lack, and each phase of a file stored over minutes.
18
19
  const telling=log=>event=>{
19
- if(event.phase!==undefined)log(PHASES[event.phase]??`Dewdrop is ${event.phase} the upload…`);
20
+ if(event.phase!==undefined)log(PHASES[event.phase]??printable(`Dewdrop is ${event.phase} the upload…`));
20
21
  else if(event.checking!==undefined)log(`Checking ${count(event.checking,'file')} (${size(event.bytes)}) with Dewdrop…`);
21
22
  else if(event.missing!==undefined)log(`Uploading ${count(event.missing,'changed file')} (${size(event.bytes)})…`);
22
23
  else if(event.files===0)log('Dewdrop has every file of the build; recording the release…');
@@ -33,7 +34,7 @@ export async function deploy(project,client,{signal,log=console.log,maps}={}) {
33
34
  const bundle=await snapshot(project);
34
35
  const {release}=await client.push(project.game,bundle,signal,telling(log));
35
36
  maps?.remember(release,bundle.directory,bundle.maps);
36
- try { await client.activate(project.game,release,signal,game=>log(`Starting ${release.slice(0,12)} at ${devPlayUrl(game)}`)); }
37
+ try { await client.activate(project.game,release,signal,game=>log(printable(`Starting ${release.slice(0,12)} at ${devPlayUrl(game)}`))); }
37
38
  catch(error) { if(maps)error.message=maps.text(release,error.message); throw error; }
38
39
  log('Ready to play.');
39
40
  return {changed:false};
@@ -69,7 +70,7 @@ export async function watch(project,client,{signal,log=console.log,deployGame=de
69
70
  following?.controller.abort();
70
71
  const controller=new AbortController(),current={game,controller};
71
72
  current.done=follow(game,signal?AbortSignal.any([signal,controller.signal]):controller.signal).catch(error=>{
72
- if(!controller.signal.aborted&&!signal?.aborted)log(`dewctl: ${error.message}`);
73
+ if(!controller.signal.aborted&&!signal?.aborted)log(`dewctl: ${printable(error.message)}`);
73
74
  }).finally(()=>{if(following===current)following=null;});
74
75
  following=current;
75
76
  };
@@ -95,13 +96,13 @@ export async function watch(project,client,{signal,log=console.log,deployGame=de
95
96
  else startFollowing(game);
96
97
  }).catch(error=>{
97
98
  if(signal?.aborted)return;
98
- log(`dewctl: ${error.message}`);
99
+ log(`dewctl: ${printable(error.message)}`);
99
100
  if(error.status===401)log(`Paused until you sign in: run ${RUN} login in another terminal, then save a file.`);
100
101
  else if(error.transient){log('Trying again in a moment.');dirty=true;changedAt=Date.now()+2000;}
101
102
  else log('Fix it and save to try again.');
102
103
  }).finally(()=>{running=null;});
103
104
  }
104
- }catch(error){log(`dewctl: ${error.message}`);log('Fix it and save to try again.');}
105
+ }catch(error){log(`dewctl: ${printable(error.message)}`);log('Fix it and save to try again.');}
105
106
  await new Promise(resolve=>setTimeout(resolve,pollMs));
106
107
  }
107
108
  await running;