LittleJS 现在支持 2D 和 3D 了
LittleJS is 2D and 3D now

原始链接: https://frankforce.com/littlejs-is-2d-and-3d-now/

LittleJS 发布了迄今为止最大的更新,同时仍是一个小巧、快速、无依赖的 HTML5 游戏引擎。它现在包含完整的 3D 渲染器,并与 2D 共享画布,因此网格、地形、体素、灯光、阴影、雾、着色器和粒子可与常规 LittleJS 对象自由混合。2D 也获得了动态光照、单向平台、扫掠碰撞、视差和更好的性能。内置的 2D/3D 关卡编辑器可让你暂停、就地编辑关卡,并支持撤销、自动保存和预制件。粒子效果库可一行代码提供火焰、烟雾、爆炸、雨等效果。渲染核心经过重做,以实现更快的 WebGL2 批处理和实例化 3D,并与其他引擎进行了基准测试。新的 AI 工具包括模板、智能体指令、Claude Code 插件、GPT 和 LittleJS Arcade。示例浏览器有 100 多个可实时编辑的示例。游戏创作活动于 10 月 2 日至 11 月 2 日举行,新网站 littlejsengine.com 展示了所有内容。

相关文章

原文

LittleJS just got the biggest update since it launched! It is still the small, fast, dependency-free HTML5 game engine it always was. Now it also has a full 3D renderer sharing the canvas with your 2D game, built-in level editors, a library of ready-made particle effects, a much faster core, and new tools for making games with AI.

2D and 3D in the same engine

This is the big one! Meshes and shape builders, terrain and voxel maps with collision, shadow maps, colored lights and spotlights, fog, reflections, particles, trails, cameras, and custom shaders on any object. 3D objects are regular LittleJS objects with the same physics, children and timers as 2D, so the two mix freely: a 2D UI over a 3D scene, or a 2D game inside a 3D world.

Prefer Three.js for rendering? There is a plugin for that too!

2D got plenty as well: a new dynamic lighting system, one-way platforms, swept bullet collision, parallax layers, and improved object collision performance.

New Tools

Level editors, 2D and 3D, built into the engine. Press Escape in a debug build to pause the game, edit the level in place with undo, autosave and prefabs, then play on. The editor guide shows how to make them an editor for your own game. 2D levels load and save as Tiled JSON.

Particle effects library. Fire, smoke, sparks, explosions, rain and more, each one line: particleEffect('fire', pos), in 2D or 3D. Every effect takes scale, hue and saturation, and the particle designer tweaks them or builds new ones. Most games will not need anything else.

The example browser has over 100 short examples, each a single file that explains what it shows and how it works, with live editing and a Share button that puts your edited code in a link. It is the best place to learn the engine.

Even Faster

The rendering core was reworked: batched 2D sprites on WebGL2, instanced 3D drawing, and far less per-draw overhead. To measure it I built a WebGL Engine Bench: the same two scenes, moving sprites and lit cubes, through LittleJS, PixiJS, Three.js, PlayCanvas, Phaser and Babylon.js, reporting how many objects each holds at 60 fps.

On my machine LittleJS matched the fastest paths of the other engines and beat them in several. That is one machine and two workloads, so run it on yours: it works in the browser with nothing to install, and results and scene improvements from other engine maintainers are welcome.

Made for AI

LittleJS has a small, well documented API, with the whole thing in one reference file. That is exactly what coding AIs are good at, and it is the same thing that makes it readable for people. So it is now a first-class goal:

  • The LittleJS AI toolkit: starter templates, helper modules and agent instructions for any coding AI, Claude Code, Copilot, Codex or Cursor.
  • The Claude Code plugin installs with two commands. Ask for a game and you get a complete, playable project, engine included, that opens from a file with no server and no npm install. Because the engine already does the rendering, input, physics and audio, the AI’s effort goes into your game.
  • The LittleJS GPT builds games inside ChatGPT with no code at all.
  • The LittleJS Arcade: 50+ small games made this way, all open source, all usable as starters.

Why?

LittleJS was always meant to be a general purpose engine, that I could use for all my games. I started it small on purpose, with js13k as the proving ground, because keeping the core tiny and simple from day one is what makes an engine easy to learn and fast to run.

Everything since has built on that core: people wanted to make more and more ambitious things with it, and what they asked for most was 3D and tools. I wanted the 3D side to feel exactly like the 2D side, same objects, same loop, same small API, not a separate framework bolted on.

The other reason is the community. LittleJS is not a one-person project any more: engine fixes, plugins, examples and a lot of games have come from other people, and the best way to push an engine forward is for people to make things with it. The third LittleJS Game Jam is running right now, October 2 to November 2. Come make something!

Try it!

The new website littlejsengine.com is a demo of all of this: a train ride through every feature, running on the engine.

Thanks for reading! Give us a star oh GitHub if you like the project. 🚂

联系我们 contact @ memedata.com