Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ adds a line under **Unreleased**.

## Unreleased

- The simulated CodeX now stands upright, its screen facing you, and its
accelerometer reads that way (+1 g on y), in front of a softly blurred
garden so the board stands out. Three buttons under the view show or hide
its controls over it: rotation (a slider and an editable angle, to tenths
of a degree, for each of its own axes, with its axes drawn from the
accelerometer chip while it shows), ambient light (which the light sensor
reads, and which visibly lights the scene), and its buttons (the arrow keys
and A and B on the keyboard work too). The screen-only view has a display
icon.
- A lit LED's or NeoPixel's glow in the simulator stays on the light,
facing out of the board: no line cuts across it as the camera turns, and
none of it shows behind the board.
- The simulated CodeAIR can be moved by hand from the keyboard too: with the
move button on, the arrow keys and Page Up and Page Down slide and lift it
(or the reflector card), Shift with them turns and tips it, and Home sets
Expand Down
25 changes: 22 additions & 3 deletions sim/tools/showroom-sky.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
// The showroom's sky (CodeX's room, src/sim/view/view.js SHOWROOM_SKY): a
// panorama in sim/assets/showroom/sky.jpg (credited in sim/assets/LICENSE).
// Run as a script (npm run sim:assets runs it), this copies it to
// public/sim-assets/env/showroom/sky.jpg, where the site serves it.
// Run as a script (npm run sim:assets runs it), this writes it out of focus
// to public/sim-assets/env/showroom/sky.jpg, where the site serves it, so
// CodeX stands out from the garden's detail. Blurred here, once, rather than
// in the browser: Three's background blur builds its maps on the graphics
// chip, which takes most of a minute where the browser draws without one.
//
// The panorama wraps round, so it is blurred with its far edges joined: a
// strip of each side is laid beside the other before the blur, then cut away.
//
// node sim/tools/showroom-sky.mjs
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import sharp from 'sharp'

const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
const SOURCE = path.join(ROOT, 'sim/assets/showroom/sky.jpg')
const SERVED = path.join(ROOT, 'public/sim-assets/env/showroom/sky.jpg')
// Served this wide (half the source's: a blurred sky needs no more), and
// blurred by this much of its width (a Gaussian's sigma).
const WIDTH = 2048
const BLUR = 1 / 300

const { width, height } = await sharp(SOURCE).metadata()
const sigma = width * BLUR
const pad = Math.ceil(sigma * 4)
const wrapped = await sharp(SOURCE).extend({ left: pad, right: pad, extendWith: 'repeat' }).blur(sigma).toBuffer()
fs.mkdirSync(path.dirname(SERVED), { recursive: true })
fs.copyFileSync(SOURCE, SERVED)
await sharp(wrapped)
.extract({ left: pad, top: 0, width, height })
.resize(WIDTH, WIDTH / 2)
.jpeg({ quality: 82, mozjpeg: true })
.toFile(SERVED)
console.log('showroom sky', fs.statSync(SERVED).size)
19 changes: 12 additions & 7 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,15 +774,18 @@ You just told a machine what to do, and it listened. Keep going!`,
'sim.stoppedTitle': 'The simulator stopped',
'sim.stoppedDetail': 'Reload the page to start it again.',
'sim.problemTitle': 'The simulator hit a problem',
'sim.keysCodex': 'Arrow keys press its direction pad, A and B its buttons; Shift and the arrow keys turn it about its own X and Y axes, Shift with Page Up and Page Down about its Z axis, Home lays it flat again; plus and minus zoom, F shows its screen alone. The Rotate buttons turn it too.',
'sim.keysCodex': 'Arrow keys press its direction pad, A and B its buttons; Shift and the arrow keys turn it about its own X and Y axes, Shift with Page Up and Page Down about its Z axis, Home stands it upright again; plus and minus zoom, F shows its screen alone. The rotation sliders turn it too.',
'sim.rotate.label': 'Rotate CodeX about its own axes',
'sim.rotate.title': 'Rotate',
'sim.rotate.back': 'Turn back about {axis}',
'sim.rotate.on': 'Turn about {axis}',
'sim.rotate.title': 'Rotation',
'sim.rotate.slider': 'Turn about {axis}',
'sim.rotate.degrees': 'Degrees about {axis}',
'sim.light.title': 'Ambient light',
'sim.light.value': '{lux} lux',
'sim.pad.note': 'Your keyboard works too: the arrow keys and A and B, once you click the CodeX view.',
'sim.worldAxes': 'World axes',
'sim.cameraView': 'CodeAIR’s camera',
'sim.lcdLabel': 'The CodeX screen',
'sim.rotate.reset': 'Reset',
'sim.rotate.reset': 'Upright',
'sim.keys3d': 'Arrow keys turn or move the camera, plus and minus zoom.',
'sim.viewLabel': 'Simulated {device}. {keys}',
'sim.ready': 'Simulator ready. Press Run!',
Expand Down Expand Up @@ -818,8 +821,10 @@ You just told a machine what to do, and it listened. Keep going!`,
'simPanel.courseTitle': 'A line course of black tape on the floor',
'simPanel.course': 'Line course',
'simPanel.noCourse': 'No course',
'simPanel.lightTitle': 'Light on the sensor (lux)',
'simPanel.light': 'Light on the sensor, lux',
'simPanel.rotateShow': 'Rotation: turn CodeX about its own axes',
'simPanel.lightShow': 'Ambient light: how bright the room is',
'simPanel.buttonsShow': "CodeX's buttons",
'simPanel.speed': 'Simulation speed',
'simPanel.speedValue': '{speed}×',
'simPanel.buttons': "The board's buttons (hold Space or Enter)",
Expand Down Expand Up @@ -878,7 +883,7 @@ You just told a machine what to do, and it listened. Keep going!`,
'codex.down': 'Down',
'codex.buttonA': 'Button A',
'codex.buttonB': 'Button B',
'codex.fullTitle': 'Screen only: the CodeX screen filling the view (F, or Esc to go back)',
'codex.fullTitle': 'Display: the CodeX screen alone, filling the view (F, or Esc to go back)',

// The simulated board in words, for a screen reader
'compass.east': 'east',
Expand Down
19 changes: 12 additions & 7 deletions src/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,15 +749,18 @@ Le acabas de decir a una máquina qué hacer, y te hizo caso. ¡Sigue así!`,
'sim.stoppedTitle': 'El simulador se detuvo',
'sim.stoppedDetail': 'Vuelve a cargar la página para iniciarlo otra vez.',
'sim.problemTitle': 'El simulador tuvo un problema',
'sim.keysCodex': 'Las flechas presionan su control de dirección, A y B sus botones; Mayús y las flechas lo giran sobre sus propios ejes X e Y, Mayús con Re Pág y Av Pág sobre su eje Z, Inicio lo deja plano otra vez; más y menos hacen zoom, F muestra solo su pantalla. Los botones de Girar también lo giran.',
'sim.keysCodex': 'Las flechas presionan su control de dirección, A y B sus botones; Mayús y las flechas lo giran sobre sus propios ejes X e Y, Mayús con Re Pág y Av Pág sobre su eje Z, Inicio la vuelve a poner de pie; más y menos hacen zoom, F muestra solo su pantalla. Los controles deslizantes de rotación también la giran.',
'sim.rotate.label': 'Girar la CodeX sobre sus propios ejes',
'sim.rotate.title': 'Girar',
'sim.rotate.back': 'Girar hacia atrás sobre {axis}',
'sim.rotate.on': 'Girar sobre {axis}',
'sim.rotate.title': 'Rotación',
'sim.rotate.slider': 'Girar sobre {axis}',
'sim.rotate.degrees': 'Grados sobre {axis}',
'sim.light.title': 'Luz ambiente',
'sim.light.value': '{lux} lux',
'sim.pad.note': 'Tu teclado también funciona: las flechas y A y B, después de hacer clic en la vista de la CodeX.',
'sim.worldAxes': 'Ejes del mundo',
'sim.cameraView': 'Cámara del CodeAIR',
'sim.lcdLabel': 'La pantalla de la CodeX',
'sim.rotate.reset': 'Restablecer',
'sim.rotate.reset': 'De pie',
'sim.keys3d': 'Las flechas giran o mueven la cámara, más y menos hacen zoom.',
'sim.viewLabel': '{device} simulado. {keys}',
'sim.ready': 'Simulador listo. ¡Presiona Ejecutar!',
Expand Down Expand Up @@ -793,8 +796,10 @@ Le acabas de decir a una máquina qué hacer, y te hizo caso. ¡Sigue así!`,
'simPanel.courseTitle': 'Un recorrido de cinta negra en el piso',
'simPanel.course': 'Recorrido',
'simPanel.noCourse': 'Sin recorrido',
'simPanel.lightTitle': 'Luz sobre el sensor (lux)',
'simPanel.light': 'Luz sobre el sensor, lux',
'simPanel.rotateShow': 'Rotación: girar la CodeX sobre sus propios ejes',
'simPanel.lightShow': 'Luz ambiente: qué tan iluminada está la sala',
'simPanel.buttonsShow': 'Los botones de la CodeX',
'simPanel.speed': 'Velocidad de simulación',
'simPanel.speedValue': '{speed}×',
'simPanel.buttons': 'Los botones de la placa (mantén presionado Espacio o Enter)',
Expand Down Expand Up @@ -853,7 +858,7 @@ Le acabas de decir a una máquina qué hacer, y te hizo caso. ¡Sigue así!`,
'codex.down': 'Abajo',
'codex.buttonA': 'Botón A',
'codex.buttonB': 'Botón B',
'codex.fullTitle': 'Solo la pantalla: la pantalla de la CodeX llenando la vista (F, o Esc para volver)',
'codex.fullTitle': 'Pantalla: solo la pantalla de la CodeX, llenando la vista (F, o Esc para volver)',

// La placa simulada en palabras, para un lector de pantalla
'compass.east': 'este',
Expand Down
6 changes: 5 additions & 1 deletion src/sim/sim-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ export class SimDevice extends EventTarget {
return this._resetting
}
orient(q) { this._post({ t: 'input', what: 'orient', q }) }
setLight(lux) { this._post({ t: 'input', what: 'light', lux }) }
// The light on CodeX's sensor, in lux: the program reads it, and the view lights the scene to match.
setLight(lux) {
this._post({ t: 'input', what: 'light', lux })
this.view?.setLight?.(lux)
}
// CodeAIR in a hand (world/codeair.js hold): a pose it follows, any of
// { x, y, z, heading, roll, pitch }; release lets go.
hold(pose) { this._post({ t: 'input', what: 'hold', pose }) }
Expand Down
Loading
Loading