Pelican Engine

面向 AI 编码工具的 TypeScript 与 WebGPU 游戏引擎

2 星标v2.0.0MITTypeScript

npm install -D -E pelican-engine

能力

Pelican Engine(鹈鹕游戏引擎)是开源的代码优先游戏引擎,一个 npm 包里带齐 SDK、运行时、渲染器、编译器和 CLI。不需要可视化编辑器,也不绑定特定 AI 平台。

  • 一个 npm 包

    SDK、运行时、渲染器、编译器和 CLI 都在 pelican-engine 里。在空目录安装后运行 npx pelican dev 即可开始,不用克隆引擎仓库。

  • 普通 TypeScript

    玩法用普通 TypeScript、自己的模块和 npm 组件来写,没有专用语法。浏览器依赖通过 runtime.create 初始化,渲染模块通过 defineRenderExtension 接入。

  • 三种渲染模式

    默认光栅渲染,原生分辨率、studio IBL、4096 阴影和各向异性过滤。在 WebGPU 下可以切换到 hybrid 或 path 路径追踪,带 PBR 和时域、空间降噪。

  • 完整的游戏基础

    内置实体、物理、动画、UI、音频和存档。内置玩法服务是可选的,规则由项目自己定。

  • 给 AI 用的工具链

    pelican guide、api、recipe 和 diagnose 可以按任务查能力、精确接口和完整配方,输出结构化诊断。新项目自带 AGENTS.md。

  • 静态部署

    可在 Windows、macOS 和 Linux 上开发(需要 Node.js 24)。npx pelican build 生成 dist/,放到普通静态服务器即可。

代码

import { defineGame, defineScene, defineMaterial } from "pelican-engine";

const paint = defineMaterial({ id: "paint", color: "#298b9d", roughness: 0.24, metalness: 0.45 });
const floor = defineMaterial({ id: "floor", color: "#8d9499", roughness: 0.8 });

export default defineGame({
  id: "hello-pelican",
  services: { physics3d: "disabled" },
  scene: defineScene({
    id: "main",
    camera: { position: [0, 2, 6], target: [0, 1, 0] },
    entities: [
      { id: "ball", transform: { position: [0, 1, 0] },
        mesh: { material: paint, geometry: { kind: "sphere", radius: 1, segments: 96 } } },
      { id: "floor", transform: { position: [0, -0.1, 0] },
        mesh: { material: floor, geometry: { kind: "box", size: [10, 0.2, 10] } } },
      { id: "sun", transform: { position: [3, 8, 5] },
        light: { kind: "directional", intensity: 3, castShadow: true } },
    ],
  }),
});

评论

正在载入…