kukemc/gandi3
About
Scratch, turned into a visual 2D game engine: dockable editor, physics, 2D lighting, particles, tilemaps, animation state machines, a debugger, and a CLI for AI coding agents.
Learning & EducationWhat you can do
- Collaboration & Version History: Real-time multiplayer editing (live collaborator cursors and per-user undo), automatic version history, and a project-level asset library.
- Embedded Code Files: Store and edit JS, Python, JSON, GLSL, and other text/code files directly inside .sb3 projects with Monaco Editor.
- Expressive Blocks: Expandable-argument blocks (➕ / ➖) and enhanced custom blocks supporting C shapes, return values, custom colors, and async execution.
- Bilingual & Touch-Ready: Native English and Simplified Chinese interface with full tablet touch support.
Measured star growth
- in 24h
- Collecting history
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Original
English · 简体中文
Launch Editor · Documentation · Website · Contributing · Changelog
Workspace · 2D Engine · Themes & Plugins · Art & Audio · Debugger · Performance · Text & AI · Getting Started
Gandi 3 rebuilds Scratch—the visual block language millions learned to program with—into a visual 2D game engine. You still write logic with familiar blocks, backed by a modern design language, a dockable multi-window workspace, built-in 2D engine systems (physics, lighting, particles, tile maps, animation state machines, input, and a full debugger), and deep customization across themes, plugins, and extensions. Both the editor and runtime are engineered to stay smooth even on projects with tens of thousands of blocks.
Standard Scratch .sb3 files and Gandi 2 projects open directly out of the box.
Core Features
Design Language, Multi-Window and Custom Layouts
Gandi 3 is redesigned from the ground up around a cohesive, low-noise game-engine design language—unified hierarchy, crisp surfaces, optional glassmorphism, consistent context menus, and customizable shortcuts—built for long creative sessions.
- Multi-Window, Multi-Target Editing: Break out of Scratch's single-sprite view. Open workspaces, costume editors, or sound editors for multiple sprites side by side and drag blocks, costumes, or sounds directly across windows. Split a sprite's logic into multiple script pages and fold long scripts into named code frames.
- Dockable Everything & Custom Layouts: Stage, sprite tree, standalone block palette, workspaces, costumes, audio, assets, and debugger are all independent panels. Split, tab, float, edge-snap, or collapse any window into a mini bar; save named layouts (e.g. Coding, Art, Level Design), lock them against accidental drags, switch in one click, or share via import/export.
- Multi-Scene Architecture: Organize a game into separate scenes (menus, levels, boss arenas), each with its own stage, sprites, and variables. Run scenes concurrently in the background or render one inside another as a picture-in-picture view.
- Fast Global Search & Quick Add: Search live blocks across every sprite and scene (with pinyin matching), batch find-and-replace values or entire blocks, and middle-click Quick Add to turn a typed phrase into a ready-to-drop stack of blocks.
| Multi-window cross-sprite block dragging | Free-form split docking & custom layouts |
|---|---|
![]() |
![]() |
Built-In 2D Game Engine
Configure core engine systems visually without boilerplate code—ready the moment you click the green flag:
| 2D Lighting Point, spot, and directional lights, real-time sprite shadows, normal maps, emission, and bloom. Pick a preset atmosphere and place a few lights to turn a scene into night, an interior, or a warm town square. |
Particles A full real-time VFX editor for fire, smoke, rain, snow, explosions, and magic—with multi-layer emitters, sub-emitters, and live preview. Attach effects to sprites or place them directly in a scene. |
![]() |
![]() |
| Animation Automatic clip detection from costume names, a timeline with event and property tracks, and state machines with transitions, blend spaces, layers, and parameters. Imports sprite sheets, Aseprite files, and GIFs. |
Tile Maps Square, isometric, and hex grids with terrain brushes, rule layers, and per-tile collisions and tags. Imports maps directly from Tiled, LDtk, and RPG Maker. |
![]() |
![]() |
| Physics Rigid bodies, colliders, joints, fluids, soft bodies, ropes, and force fields. Configure physical behavior visually in the rig editor—no glue scripts needed. |
Input System Action-based input abstraction with rebindable keys, key groups, gamepad support, on-screen touch controls, and a ready-to-use in-game keybindings screen. |
Custom Themes, Plugins and Extensions
Every layer of Gandi 3—from visual appearance and block geometry to editor UI and engine capabilities—is designed to be freely customized and extended.
- Theme Engine & Theme Studio: Far more than a dark/light toggle. Ships with 11 distinct presets (Dark, Light, Deep Sea, Pine, Amethyst Glass, Ember, Warm Sand, Morning Mist, High Contrast, Terminal Pixel, and Candy). Theme Studio exposes core palettes, corner radius, shadows, glass blur, motion intensity, fonts, background images, UI sound effects, and even Scratch block geometry (unit scale, notch height/width, corner radius, hat curve, input roundness, and category colors)—all exportable and shareable.
| Candy preset: pastel surfaces, pill geometry & soft glass | Pixel preset: monospace terminal & sharp 90° blocks |
|---|---|
![]() |
- Editor Plugin SDK: Extend the editor itself via URL or local
.jsfiles using the same versionedctx.editorSDK that powers built-in enhancements (batch block marquee selection, searchable dropdowns, jump-to-custom-block definition, and multi-line block input editors). Plugins can register native dockable/floating panels, top-bar buttons, settings pages, commands, and shortcuts, and programmatically manipulate layouts, themes, scenes, and the workspace—with automatic cleanup on unload.
window.MyGandiPlugin = {
id: 'me.hello-panel',
name: 'Hello Panel',
setup(ctx) {
ctx.registerPanel('main', 'Hello Panel', host => {
host.textContent = `Sprites: ${ctx.vm.runtime.targets.length}`;
});
ctx.registerEntry({
id: 'open',
label: 'Hello Panel',
onClick: () => ctx.openPanel('main', true)
});
}
};
- Open Extension Library & Engine Extension API: Compatible with Scratch, Gandi, and community extensions—browse and install from the built-in Extension Library or load any custom extension URL/file. Beyond adding blocks, third-party extensions can use the Engine Extension API (
window.__gandi3Engine) to mount native inspector sections, custom tools, stage overlays, and scene settings right inside the editor—the exact same API powering Gandi 3's own physics, lighting, and particle engines.
Built-In Art and Audio Tools
- Costume Editor: An infinite-canvas vector and bitmap editor with layers, boolean path operations, masks, blend modes, text on a path, onion skinning, tweens, and WebM export. GIFs and videos work natively as costumes.
- Music Workstation: A multi-track arranger, piano roll, per-track mixer with effect chains, a SoundFont instrument library, and a waveform editor.
Debug Workbench and Diagnostics
An 11-tab Debug Workbench built to surface both logic bugs and frame drops:
- Breakpoints & Stepping: Step in, step over, and step out, alongside conditional, variable, broadcast, and clone breakpoints.
- Profiling & Inspection: Frame performance recording, live watch expressions, render statistics, and memory inspection.
- Automated Diagnostics & Live Overlays: 13 built-in diagnostic rules explain what is slowing your project down and how to fix it, complemented by an F3-style on-stage overlay and a static Problems panel while you edit.
Compiler, Clones and Runtime Performance
Gandi 3 deeply re-engineered the VM compiler, thread scheduler, clone lifecycle, broadcast dispatch, WebGL renderer, and block workspace for large-scale projects. Every number below comes from measured before-and-after runs on the same machine; see the editor and runtime performance reports for methodology and full benchmarks.
- Deep VM Compiler Optimizations: Project-wide unboxed numeric variable slots, constant folding, custom-block inlining, and constant-argument specialization; non-yielding scripts and
foreverloop bodies compile into plain JS functions (eliminating generator resume overhead); synchronous direct calls, monomorphic argument shapes, and inlinecompiletemplates accelerate extension-heavy loops by 2–7×. - 10,000+ Clones & High-Churn Particle Loops: Per-sprite thread tracking and two-ended removal eliminate O(N) full-table scans when spawning or deleting clones—over 10,000–11,450 active clones run at a locked 60 fps, and 5,000-clone particle churn (100 spawned & deleted per frame) stays at 57–60 fps.
- Indexed Broadcasts & Zero-Churn Scheduling: Per-broadcast receiver caching, incremental thread-table maintenance, compiled-artifact reuse across threads, and reduced short-lived GC pressure lift a broadcast-driven action engine (2,700 new threads and 34,000 extension calls per frame) from 25 fps to 60–76 fps.
- Instanced WebGL Rendering & Bitmask Collisions: Multi-texture
drawArraysInstancedsprite batching (up to 8 textures per draw call), off-screen culling, unified VRAM budgeting with in-place context recovery, plus 1-bit silhouette + hierarchical occupancy bitmask collision detection (full-screen miss cut from 24.4 ms to 93 µs). - Large-Workspace Viewport Culling: Three-tier SVG block culling with hysteresis and incremental DOM diffing keeps a single 19,899-block sprite smooth to pan and zoom.
| Benchmark | Before | Gandi 3 |
|---|---|---|
| Zoom a sprite with 19,899 blocks | 1,679 ms / frame | 17 ms (97×) |
| DOM nodes in that workspace | 106,690 | 3,345 (32×) |
| 10,000 clones, each running its own script (60 / 120 cap) | 38 fps | 60 / 97 fps |
| 11,450 bouncing clones stress test | ~5 fps | 60 fps (locked) |
| 5,000 clones, spawning & deleting 100 per frame | 30–38 fps | 57–60 fps |
| Broadcast-driven action engine (2,700 threads & 34k ext calls / frame) | 25 fps | 60–76 fps |
| Software raytracer written in blocks | 2.3 fps | 7.9 fps (3.4×) |
| Canvas-extension project (120 fps cap) | 30 fps | 118 fps (3.9×) |
Text Syntax, Code Mode and AI Workflows
- Block Text Syntax: Every script converts losslessly to a JavaScript-like text syntax and compiles back into identical blocks. Control flow, operators, variables, and lists read like familiar code.
- Code Mode (Experimental): Edit a script page directly as text with autocompletion and debugger integration.
- Gandi CLI: Connect AI coding agents such as Claude Code and Codex directly to the project open in your browser. Agents can create sprites, write blocks, draw costumes, configure physics and lighting, then run the game headlessly, capture screenshots, and verify runtime variables before handing the result back.
const score = stage.variable("score", 0);
when.flagclicked(() => {
score = 0;
repeat(10, () => {
motion.movesteps(10);
if (sensing.touchingobject("_edge_")) {
score += 1;
looks.say(`bounced ${score} times`);
}
});
});
npm install -g @kukemc/gandi-cli
gandi up # connect to the editor open in your browser
More Capabilities
- Collaboration & Version History: Real-time multiplayer editing (live collaborator cursors and per-user undo), automatic version history, and a project-level asset library.
- Embedded Code Files: Store and edit JS, Python, JSON, GLSL, and other text/code files directly inside
.sb3projects with Monaco Editor. - Expressive Blocks: Expandable-argument blocks (
➕/➖) and enhanced custom blocks supporting C shapes, return values, custom colors, and async execution. - Bilingual & Touch-Ready: Native English and Simplified Chinese interface with full tablet touch support.
Browse the full feature documentation →
Getting Started
Requires Node.js 20+ and pnpm 9 (run corepack enable to activate the matching pnpm version).
git clone https://github.com/kukemc/gandi3.git
cd gandi3
pnpm install
pnpm dev # start the editor at http://localhost:5173
Common workspace commands:
pnpm typecheck # type-check the editor
pnpm test # run runtime and CLI unit tests
pnpm build # production build (engine extensions + editor)
pnpm build:blocks # recompile the block engine with Closure Compiler (see packages/blocks)
Repository Structure
Gandi 3 uses a pnpm monorepo organized by engine subsystem so cross-cutting changes can land in a single pull request:
packages/
editor/ Editor UI: Vite + React + TypeScript
vm/ Runtime: threads, scheduler, compiler, scenes, tile maps, animation, input
render/ WebGL renderer: skins, compositing, tile-map rendering
blocks/ Block editor, forked from scratch-blocks (Blockly)
fx/ Lighting, particle, and physics engine extensions
cli/ Gandi CLI for AI agents (published to npm as @kukemc/gandi-cli)
tests/e2e/ Browser acceptance tests
examples/ Sample projects
Feature documentation lives in packages/editor/docs/features. The hosted online services (collaboration backend, community workshop, and website) are maintained separately and are not included in this repository.
Why Gandi 3
I'm an independent developer who genuinely loves Scratch. Visual blocks remain the most approachable way to program I know—direct manipulation, immediate feedback, and clear logic make building things a joy. Yet the moment you try to build a full-scale game, the ceiling shows up quickly: there is no built-in physics, 2D lighting, scene management, tile maps, or real debugger, and a single sprite with ten thousand blocks brings the editor to a crawl.
Gandi 3 aims to bring a Godot- or Unity-caliber 2D game engine workflow to Scratch—so newcomers can start in minutes and ship real games with the blocks they already know. A solid foundation is already in place, though there is still plenty left to build; that is why the entire engine and editor are open-sourced under the MIT License so the Scratch community can shape it together.
Note: Gandi 3 is an independent open-source project supported and sponsored by Cocrea. It is not affiliated with or endorsed by the Scratch Foundation.
Official Partner & Sponsor
Gandi 3 is proudly supported and sponsored by Cocrea, where it serves as a core creation tool for the community.
Contributing
Contributions of every size matter—whether fixing a typo, improving translations, writing documentation, creating a plugin or example project, reporting a bug, or building a new engine system.
- Read the Contributing Guide for development setup, code conventions, and pull request guidelines.
- Browse issues labeled
good first issueto find approachable starting points. - Follow our Code of Conduct.
- Found a security vulnerability? Please report it privately via SECURITY.md rather than opening a public issue.
Acknowledgements
Gandi 3 stands on the shoulders of the open-source Scratch ecosystem. Our sincere thanks to the projects and teams that made this possible:
- Scratch Foundation · GitHub
For creating Scratch and open-sourcing its runtime, renderer, and block architecture—inspiring millions of creators around the world. Gandi 3 builds directly uponscratch-vm,scratch-render,scratch-blocks, andscratch-parser. - TurboWarp · GitHub
For pioneering the Scratch compiler and runtime optimizations that dramatically expanded what Scratch projects can run. Gandi 3's runtime draws directly onTurboWarp/scratch-vmand@turbowarp/*packages. - Gandi-IDE
For open-sourcing runtime and renderer enhancements built for ambitious projects and helping grow the Scratch creator community, includingGandi-IDE/scratch-vmandGandi-IDE/scratch-render. - Google Blockly · GitHub
For building the extensible visual programming library that underpinsscratch-blocksand Gandi 3's block workspace.
We are also grateful to the broader open-source community and every contributor who reports issues, shares ideas, or submits pull requests.
License
Gandi 3 is open-sourced under the MIT License.
Directories derived from upstream projects retain their original open-source licenses:
- Runtime (
packages/vm): MPL-2.0 (scratch-parserunder BSD-3-Clause) - Renderer (
packages/render): BSD-3-Clause - Block Editor (
packages/blocks): Apache-2.0
See COPYRIGHT.md for full directory-level attributions and bundled asset licenses.
"Scratch" is a trademark of the Scratch Foundation. Gandi 3 is not affiliated with or endorsed by the Scratch Foundation.
The MIT License applies to the source code only and does not grant any trademark or branding rights. The "Gandi" name, the Gandi logo, and related visual brand assets are the copyright and trademark property of Cocrea. Derivatives and third-party commercial distributions may not use these names or logos, or imply official endorsement, without prior written permission.
If Gandi 3 helps you build something you're proud of, consider leaving a ⭐ so more creators can find it.
Explore related projects
Loading…






