- Автор
- playcanvas
- Размер
- 700.2 MB
- Звёзды
- 17.3K
- Обновлён
- КоммитNov 19Релизv2.24.2Nov 18
- Возраст
- 12 г
- Коммиты · 90 дней
README проекта с github.com/playcanvas/engine. Одним файлом markdown: README.md.
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.
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.
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.
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.
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 |
Many games and apps have been published using the PlayCanvas engine. Here is a small selection:
You can see more games on the PlayCanvas website.
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
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.
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.
The PlayCanvas Engine is released under the MIT license.