engine README

README проекта с github.com/playcanvas/engine. Одним файлом markdown: README.md.

PlayCanvas Engine한글日本語中文

NPM Version NPM Downloads License Discord Reddit X

User Manual · API Reference · Examples · Blog · Forum

PlayCanvas is an open-source web graphics engine built on WebGPU and WebGL2. Use it to create interactive 2D and 3D apps, games and visualizations that run in any browser on any device.

Install

npm install playcanvas

Or scaffold a full project in seconds with create-playcanvas:

npm create playcanvas@latest

Release notes for every version are on the Releases page.

Usage

Here's a super-simple Hello World example - a spinning cube!

import * as pc from 'playcanvas';

const canvas = document.createElement('canvas');
document.body.appendChild(canvas);

// create a graphics device, preferring WebGPU and falling back to WebGL2
const device = await pc.createGraphicsDevice(canvas, {
  deviceTypes: [pc.DEVICETYPE_WEBGPU]
});

// create an app with only the component systems it uses
const options = new pc.AppOptions();
options.graphicsDevice = device;
options.componentSystems = [
  pc.RenderComponentSystem,
  pc.CameraComponentSystem,
  pc.LightComponentSystem
];
const app = new pc.AppBase(canvas);
app.init(options);

// fill the window and keep the canvas sized to it
app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
app.setCanvasResolution(pc.RESOLUTION_AUTO);
window.addEventListener('resize', () => app.resizeCanvas());

// create a box, a camera and a light
const box = new pc.Entity('cube');
box.addComponent('render', { type: 'box' });
app.root.addChild(box);

const camera = new pc.Entity('camera');
camera.addComponent('camera', { clearColor: new pc.Color(0.1, 0.2, 0.3) });
camera.setPosition(0, 0, 3);
app.root.addChild(camera);

const light = new pc.Entity('light');
light.addComponent('light');
light.setEulerAngles(45, 0, 0);
app.root.addChild(light);

// spin the box and start the app
app.on('update', dt => box.rotate(10 * dt, 20 * dt, 30 * dt));
app.start();

Want to play with the code yourself? Edit it on CodePen.

The package includes TypeScript declarations, and it also runs without a build step using an import map and a CDN build. Using the Engine Standalone walks through both setups, and Bundle Size and Tree Shaking lists the component systems and resource handlers an app can register.

Features

Developing with AI

Coding agents: start from the Engine guides index and the Engine API index, which link a Markdown version of every page. Developing with AI explains how to set up an agent on a project, and PlayCanvas Skills add task-specific workflows to compatible agents.

Ecosystem

Build with PlayCanvas your way:

Package Description
playcanvas Core engine (you are here)
@playcanvas/react React renderer for PlayCanvas
@playcanvas/web-components Declarative 3D via Custom Elements
create-playcanvas Project scaffolding CLI
PlayCanvas Editor Browser-based visual editor

Project Showcase

Many games and apps have been published using the PlayCanvas engine. Here is a small selection:

Seemore After The Flood Casino
Swooop Master Archer Gaussian Splat Statues
BMW i8 Star-Lord Interior Visualization

You can see more games on the PlayCanvas website.

Users

PlayCanvas is used by leading companies in video games, advertising and visualization such as:
Animech, Arm, BMW, Disney, Facebook, Famobi, Funday Factory, IGT, King, Miniclip, Leapfrog, Mojiworks, Mozilla, Nickelodeon, Nordeus, NOWWA, PikPok, PlaySide Studios, Polaris, Product Madness, Samsung, Snap, Spry Fox, Zeptolab, Zynga

Contributing

Contributions are welcome, from typo fixes to new features. CONTRIBUTING.md explains how to set up, test and submit a change. For larger changes, please open an issue first to discuss the approach.

How to build

Ensure you have Node.js 18+ installed. Then, install all of the required Node.js dependencies:

npm install

Now you can run various build options:

Command Description Outputs To
npm run build Build all engine flavors and type declarations build
npm run docs Build engine API reference docs docs

Run the unit tests with npm test and the linter with npm run lint. To run the examples browser locally, see the examples README.

License

The PlayCanvas Engine is released under the MIT license.

engine (playcanvas/engine)

Ищем в базе…

17.3K ·GitHub
Что это такое?PlayCanvas — это open-source игровой движок для создания интерактивных 3D-приложений, игр и визуализаций, которые работают в любом браузере на любом устройстве. Рендеринг построен на WebGL2 и WebGPU.
Это кодовый движок или визуальный редактор?Этот репозиторий — сам ядро движка: JavaScript-библиотека, с которой вы работаете через код. PlayCanvas Editor — визуальный редактор в браузере — это отдельный продукт той же экосистемы.
Как начать с ним проект?Разверните целый проект за секунды с помощью create-playcanvas CLI или добавьте npm-пакет playcanvas в существующий проект. Пример «Hello World» с вращающимся кубом можно отредактировать прямо на CodePen.
Нужно ли что-то устанавливать, чтобы это запустить?Для работы не нужно ничего, кроме браузера. Node.js 18+ требуется только если вы хотите собрать сам движок из исходников.
Что там есть, кроме рендерера?Физика твёрдых тел через ammo.js, анимация на основе состояний для персонажей и свойств сцены, ввод с мыши, клавиатуры, тачскрина и геймпада, а также позиционный 3D-звук на Web Audio API — плюс графика как в 3D, так и в 2D.
Его реально используют в продакшене?Да — его используют ведущие компании в играх, рекламе и визуализации, включая Disney, BMW, King, Zynga, Samsung и Snap.
Можно ли делать с ним VR- и AR-приложения?Да — в движке есть встроенная поддержка иммерсивных AR и VR через WebXR, поэтому такие проекты запускаются на XR-устройствах прямо в браузере.
Обязательно писать на JavaScript, или можно на TypeScript?И то и другое — игровую логику можно писать на TypeScript или JavaScript, а на этапе сборки даже генерируются описания типов для API движка.
Что ещё есть в экосистеме PlayCanvas?Помимо ядра движка есть React-рендерер (@playcanvas/react), декларативные Custom Elements (@playcanvas/web-components), CLI для развёртывания проектов create-playcanvas и браузерный PlayCanvas Editor.
Насколько проект зрелый?Он развивается с 2014 года и набрал около 17 000 звёзд на GitHub; в его витрине — длинный список выпущенных игр и приложений.
Какие есть похожие проекты?aframe, flutter_scene, three.js, crucible, Babylon.js, phaser, estella, Hermes3D
Автор
playcanvas
Размер
700.2 MB
Звёзды
17.3K
Возраст
12 г
Коммиты · 90 дней