Repository iconcurepo.dev
Blog
engine preview

playcanvas / engine

3d-gaussian-splatting3dgsgame-developmentgame-engine

Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF

17.4k Stars
visibility343 Watchers
fork_right2.1k Forks
JavaScript
historyUpdated recently

description 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

  • 🧊 Graphics - Advanced 2D + 3D graphics engine built on WebGL2 & WebGPU, with physically based materials, clustered lighting, soft shadows and WebGPU compute shaders
  • 💠 Gaussian Splatting - First-class support for loading, streaming and rendering 3D Gaussian Splats
  • 🎨 Post-Processing - HDR effects pipeline with bloom, SSAO, TAA, depth of field and color grading
  • ✨ Particles - GPU-accelerated particle systems
  • 🔘 User Interface - Text, images, buttons, layouts and scroll views for 2D and 3D UI
  • 🥽 XR - Built-in support for immersive AR and VR experiences via WebXR
  • ⚛️ Physics - Full integration with 3D rigid-body physics engine ammo.js
  • 🏃 Animation - Powerful state-based animations for characters and arbitrary scene properties
  • 🎮 Input - Mouse, keyboard, touch and gamepad APIs
  • 🔊 Sound - 3D positional sounds built on the Web Audio API
  • 📦 Assets - Asynchronous streaming system built on glTF 2.0, Draco, Meshopt and Basis compression
  • 📜 Scripts - Write game behaviors in TypeScript or JavaScript

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:

PackageDescription
playcanvasCore engine (you are here)
@playcanvas/reactReact renderer for PlayCanvas
@playcanvas/web-componentsDeclarative 3D via Custom Elements
create-playcanvasProject scaffolding CLI
PlayCanvas EditorBrowser-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](ht