Cocos Engine
Open-source, cross-platform 2D/3D game engine with Vulkan, Metal, and WebGL support for web, mobile, and instant gaming platforms
Cocos Engine is the open-source runtime framework at the heart of Cocos Creator, a free cross-platform game engine trusted by millions of developers worldwide. It enables building high-performance 2D and 3D games and interactive experiences for web, iOS, Android, HarmonyOS, and emerging instant gaming platforms like WeChat Mini Games, TikTok Mini Games, and Facebook Instant Games using TypeScript with a visual editor.
The engine’s architecture blends a C++ core for performance-critical systems — rendering, physics, scene management, and native platform adaptation — with a TypeScript API layer for scripting. This hybrid design ensures that runtime performance stays high while keeping the development experience accessible and productive. Graphics are powered by modern APIs: Vulkan on Windows and Android, Metal on macOS and iOS, and WebGL/WebGL2/WebGPU on web platforms.
Cocos Engine provides a fully customizable render pipeline, physically based rendering (PBR), an extensible surface shader system, built-in animation, particle, and physics systems, plus deep tooling integration with VSCode. The engine is designed to be integrated within the Cocos Creator editor rather than used as a standalone library, providing a cohesive authoring workflow with instant preview and one-click multi-platform deployment.
Backed by Xiamen Yaji Software Co., the project has over 9,600 GitHub stars, more than 200 contributors, and an active release cycle with regular maintenance updates. It is particularly popular in the Chinese gaming market and among teams targeting mobile-first instant gaming distribution channels.
What You Get
- Modern Multi-API Graphics Pipeline - Uses Vulkan on Windows/Android, Metal on macOS/iOS, and WebGL/WebGL2/WebGPU on web, with a unified GFX abstraction layer that handles backend switching automatically.
- Physically Based Rendering (PBR) - Implements industry-standard PBR with physically accurate lighting, camera, and material models for realistic rendering output across all supported platforms.
- Fully Customizable Render Pipeline - Forward and deferred render pipelines are built with the same public API exposed to users, enabling developers to extend or completely replace the rendering architecture.
- Extensible Surface Shader System - Material system based on GLSL 300 with automatic conversion to platform-specific shader formats; developers can fully customize surface material definitions while sharing a universal lighting model.
- TypeScript Scripting with VSCode Integration - Full TypeScript-based user API with IntelliSense, type-safe decorators, debugging, and autocompletion — no context switching between editor and scripting tools.
- Instant Gaming Platform Export - Native export targets for WeChat Mini Games, TikTok Mini Games, and Facebook Instant Games with no code changes required, enabling distribution without app store friction.
- Multi-Physics Backend Support - Ships with built-in, Bullet, Cannon.js, and PhysX physics backends, selectable at project level via a runtime physics selector abstraction.
- Marionette State Machine Animation - Advanced animation graph system with blending, masks, motion states, and parametric transitions for complex character animation workflows.
Common Use Cases
- Mobile instant games for WeChat Mini Games - A studio targeting Chinese mobile users builds lightweight 2D games that run directly inside WeChat without requiring app store installs, using Cocos Creator’s native mini-game export.
- Cross-platform 3D casual games - An indie team develops a 3D mobile game targeting iOS and Android simultaneously, using a shared TypeScript codebase and platform-specific builds generated from a single project.
- Automotive HMI digital cockpits - An automotive technology firm uses Cocos Engine’s PBR rendering and real-time scene graph to create interactive digital instrument clusters with ADAS visualization.
- Web-based interactive marketing experiences - A creative agency builds animated 3D product configurators deployed as web pages using Cocos’s WebGL/WebGPU support, without requiring plugin installation.
- Educational XR simulations - A university deploys immersive 3D biology and physics simulations to VR headsets and web browsers from the same Cocos project using multi-platform export.
- Game engine customization and extension - A game studio forks the open-source engine to implement proprietary rendering techniques or platform-specific optimizations using the custom engine workflow.
Under The Hood
Architecture Cocos Engine follows a modular, domain-partitioned architecture where each subsystem — rendering, physics, animation, UI, scene graph, audio, input — is organized as a discrete module with explicit dependencies defined in configuration files. This enables selective bundling and tree-shaking during the build step. The graphics abstraction layer (GFX) implements a Strategy pattern: abstract device and command-buffer interfaces are implemented separately for WebGL, WebGL2, WebGPU, Vulkan, and Metal, allowing the runtime to swap backends transparently. Physics backends (built-in, Bullet, Cannon.js, PhysX) are similarly decoupled behind a framework/selector abstraction, with runtime selection controlled by project configuration. The component-based scene graph integrates dependency injection via module registration and feature flags, keeping cross-system coupling minimal and enabling platform-specific behavior without conditional branching scattered across subsystems.
Tech Stack The engine is a hybrid C++ and TypeScript system. C++ handles performance-critical subsystems including the native rendering pipeline, scene management, physics simulation, and platform adaptation layers. TypeScript implements the user-facing API, game logic scripting, editor extensions, and the web-platform runtime. The build toolchain uses Node.js, Gulp, Babel with a custom Cocos Babel preset, and Browserify for transpilation and minification. TypeScript declaration files are generated via a custom build script, and Emscripten is used for WebAssembly integrations in native-backed modules. Testing uses Jest with ts-jest, a custom jsdom-based test environment, and WASM dependency mocking. ESLint with airbnb-base rules and TypeScript-ESLint enforce consistent style, supplemented by a CPP auto-fix guide for the native layer.
Code Quality The test suite is comprehensive, covering animation clip migration, graph-based animation validation, serialization, physics, particle systems, UI components, and value types across dozens of spec files. TypeScript strict mode is enforced, and the decorator-based metadata system (@ccclass, @serializable, @tooltip) provides compile-time type safety alongside runtime reflection. Naming conventions are domain-aligned and consistent across subsystems. Serialization handles circular references and object graph reconstruction through ID-based resolution. Comment density in core files is moderate — meaningful JSDoc annotations exist on public APIs, particularly in the GFX and scene-graph layers, though implementation-level comments vary. Error handling relies primarily on defensive programming and runtime assertions rather than typed exception hierarchies, which is idiomatic for game engine contexts but reduces debuggability in failure scenarios.
What Makes It Unique Cocos Engine’s most technically distinctive feature is its decorator-driven metadata system: @ccclass, @serializable, and @tooltip annotations embed runtime reflection and editor serialization metadata directly into class definitions, creating a zero-boilerplate bridge between game logic and the visual editor. No separate schema files or manual registration calls are needed — the editor reads component properties directly from class metadata. The Marionette animation graph system provides a stateful, graph-based animation controller with parametric blending, motion states, and event triggers comparable to Unity’s Animator Controller, implemented in pure TypeScript with a specialized pose graph evaluation architecture. The custom pipeline macro system enables compile-time adaptation of post-processing effects per platform capability, avoiding runtime branching overhead. Finally, the dual .ts/.jsb.ts file pattern (where .jsb.ts files shadow .ts files on native platforms via module aliasing) allows maintaining a single TypeScript API surface while substituting native bindings transparently — a pragmatic approach to cross-platform parity that eliminates wrapper boilerplate.
Self-Hosting
Cocos Engine is released under the MIT License, one of the most permissive open-source licenses available. This means you can use, modify, redistribute, and incorporate the engine into commercial products — including proprietary games — without paying royalties or releasing your game’s source code. The only requirement is retaining the copyright notice in your distributed software. There are no GPL-style copyleft obligations, so self-hosted or shipped builds are not required to open-source your game logic. The license covers the engine runtime (this repository); third-party libraries bundled in the engine (Box2D, Cannon.js, etc.) carry their own licenses, which are enumerated in the licenses/ directory.
Running Cocos Engine in production means operating the Cocos Creator editor environment alongside whatever CI/CD infrastructure you use for builds. The engine itself has no server component — games are static bundles deployed to CDN, app stores, or mini-game platforms. Native platform builds require platform-specific toolchains (Xcode for iOS/macOS, Android NDK/SDK for Android, Visual Studio for Windows), and the native layer uses CMake as its build system. There is no self-hosted game server provided by Cocos; multiplayer or backend services are the developer’s responsibility. Build pipelines are a Node.js/Gulp workflow, well-suited to CI environments. The engine’s large codebase (~360 MB) and polyglot nature (C++, TypeScript, GLSL) mean build times can be substantial for native targets.
Cocos also offers managed cloud services and a broader ecosystem under the Cocos brand — including Cocos Service integrations for analytics, push notifications, and live ops, available through the Cocos Creator editor’s Service panel. These are optional SaaS add-ons, not required for using the engine. The company provides commercial support contracts and priority issue resolution for enterprise customers, which self-hosters operating on the open-source engine alone would not receive. Documentation is extensive and community-maintained across English and Chinese, with an active forum and Discord, but production incident support relies on community goodwill unless a commercial agreement is in place.
Related Apps
Dify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
Dify
OtherGodot Engine
Developer Tools · Game Development · Design Tools
Free, MIT-licensed 2D and 3D game engine with one-click multi-platform export and no royalties.
Godot Engine
MITSupabase
Developer Tools · Databases · Search
The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.