A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
test: export tests read unminified bundles, and the audio watchdog and imported components are answered by their gates
yhhad02659ec08d
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 9b68e7e32..1f1f527fc 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -31,7 +31,7 @@ env:test_registry_ondestroy test_view_api_matrixtest_hierarchy_links test_entity_activity test_transform_traversal test_ui_tree test_tween_activity test_springbonetest_shader_device test_draw_params test_per_draw_blocks test_texture_fb test_buffer_device- test_frame_pacer test_packaged_config test_mapped_file test_sdf_generator+ test_frame_pacer test_audio_watchdog test_packaged_config test_mapped_file test_sdf_generatortest_compressed_format test_batch_builder test_skeletal_batch_color test_boundary_span test_webgpu_devicetest_clip_depth test_planar_reflection test_sort_key test_retained_text test_sprite_mask_range test_sprite_draw_mode test_shadow_atlas test_particle_shapes test_lod_selection test_billboard_facing test_impostor_frames test_view_shading test_mesh_edges test_hdr_format test_probe_store test_occlusion_view test_reflection_store test_tiled_lights test_light_layers test_shadow_channelstest_text_edit test_render_graph test_device_loss test_physics_interpolationdiff --git a/desktop b/desktopindex 1dc52f201..8bf4e2d75 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 1dc52f201cda0ea6db714079113e7c90c472da67+Subproject commit 8bf4e2d7593f891a04129a88a1b7e23f4cc28a29diff --git a/pipeline/tests/export-bilibili.test.ts b/pipeline/tests/export-bilibili.test.tsindex cc44848d9..3cefbea7a 100644--- a/pipeline/tests/export-bilibili.test.ts+++ b/pipeline/tests/export-bilibili.test.ts@@ -44,6 +44,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retrdescribe('exportGame (bilibili)', () => {it('writes the appid, the version and the high-performance switches into game.json', async () => {const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',scriptsEntry: 'src/main.ts',diff --git a/pipeline/tests/export-douyin.test.ts b/pipeline/tests/export-douyin.test.tsindex bf9c88294..bccf9e5b9 100644--- a/pipeline/tests/export-douyin.test.ts+++ b/pipeline/tests/export-douyin.test.ts@@ -57,6 +57,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retrdescribe('exportGame (douyin)', () => {it('writes the vendor config Douyin reads, not the one WeChat reads', async () => {const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: path.resolve(__dirname, '../src/runtime'), packagesDir: OFFICIAL_PACKAGES,@@ -113,6 +114,7 @@ describe('exportGame (douyin)', () => {writeFileSync(path.join(esmRoot, 'esengine.js'), 'const M = () => {};\nexport default M;\n');writeFileSync(path.join(esmRoot, 'esengine.wasm'), 'wasmbytes');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: path.resolve(__dirname, '../src/runtime'), packagesDir: OFFICIAL_PACKAGES,diff --git a/pipeline/tests/export-engine-installs.test.ts b/pipeline/tests/export-engine-installs.test.tsindex 6d2280453..ae96b9258 100644--- a/pipeline/tests/export-engine-installs.test.ts+++ b/pipeline/tests/export-engine-installs.test.ts@@ -54,6 +54,7 @@ function setup(components: string[]): { root: string; out: string } {}const run = (f: { root: string; out: string }) => exportGame({+ minifyScripts: false,root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out,@@ -142,6 +143,7 @@ describe('the debug channel', () => {try {await run(f);const res = await exportGame({+ minifyScripts: false,root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: dev.out, debugChannel: { url: 'ws://192.168.1.2:37420/?token=t' },@@ -171,6 +173,7 @@ describe('a web package whose project excluded a module', () => {...setup(components), features: { modules },});const runWith = (f: ReturnType<typeof withChoice>) => exportGame({+ minifyScripts: false,root: f.root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(f.root, '_sdk'), wasmDir: path.join(f.root, '_wasm'),outDir: f.out, features: f.features,diff --git a/pipeline/tests/export-kuaishou.test.ts b/pipeline/tests/export-kuaishou.test.tsindex 374bddee7..870825bbc 100644--- a/pipeline/tests/export-kuaishou.test.ts+++ b/pipeline/tests/export-kuaishou.test.ts@@ -44,6 +44,7 @@ afterAll(() => rmSync(root, { recursive: true, force: true, maxRetries: 10, retrdescribe('exportGame (kuaishou)', () => {it('writes game.json and nothing a Kuaishou package does not carry', async () => {const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: path.resolve(__dirname, '../src/runtime'), packagesDir: OFFICIAL_PACKAGES,diff --git a/pipeline/tests/export-openpaas.test.ts b/pipeline/tests/export-openpaas.test.tsindex 7d561ff6a..36a9d032b 100644--- a/pipeline/tests/export-openpaas.test.ts+++ b/pipeline/tests/export-openpaas.test.ts@@ -46,6 +46,7 @@ describe('OpenPaaS third-party directory export', () => {const loaded = (await loadProjectPlatform(root, 'openpaas', dirs))!;const out = path.join(root, 'out');const result = await exportGame({+ minifyScripts: false,root, platform: 'openpaas', miniGameProfile: loaded.profile,entryScene: 'scenes/2d.esscene', sdkDistDir: sdk(), wasmDir: loaded.wasmDir, outDir: out,hostsDir: path.resolve(__dirname, '../src/runtime'), packagesDir: OFFICIAL_PACKAGES,diff --git a/pipeline/tests/export-project-platform.test.ts b/pipeline/tests/export-project-platform.test.tsindex 571fd52c5..d18d0108f 100644--- a/pipeline/tests/export-project-platform.test.ts+++ b/pipeline/tests/export-project-platform.test.ts@@ -90,6 +90,7 @@ describe('exportGame — a platform the project defines', () => {expect(platform).not.toBeNull();const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused', packagesDir: OFFICIAL_PACKAGES,@@ -139,6 +140,7 @@ describe('exportGame — a platform the project defines', () => {const outBare = path.join(root, 'dist-bare');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused', packagesDir: OFFICIAL_PACKAGES,@@ -158,6 +160,7 @@ describe('exportGame — a platform the project defines', () => {it('refuses an id that is neither built in nor handed a profile, rather than packaging it as web', async () => {await expect(exportGame({+ minifyScripts: false,root, entryScene: 'scenes/main.esscene',hostsDir: path.resolve(__dirname, '../src/runtime'), packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),diff --git a/pipeline/tests/export-wechat.test.ts b/pipeline/tests/export-wechat.test.tsindex 49d689905..68e425d6a 100644--- a/pipeline/tests/export-wechat.test.ts+++ b/pipeline/tests/export-wechat.test.ts@@ -75,7 +75,7 @@ describe('exportGame (wechat)', () => {writeFileSync(path.join(root, `${entry}.meta`), meta('88888888-8888-4888-8888-888888888888', 'scene'));const dir = path.join(root, 'dist-wechat-broken-video');try {- const result = await exportGame({ root, entryScene: entry,+ const result = await exportGame({ minifyScripts: false, root, entryScene: entry,hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wxwasm'), outDir: dir, platform: 'wechat' });expect(result.ok).toBe(false);@@ -93,7 +93,7 @@ describe('exportGame (wechat)', () => {const dir = path.join(root, 'dist-wechat-recook');const source = path.join(root, 'assets/hero.png');const original = readFileSync(source);- const run = () => exportGame({ root, entryScene: 'scenes/main.esscene',+ const run = () => exportGame({ minifyScripts: false, root, entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wxwasm'), outDir: dir, platform: 'wechat' });try {@@ -112,6 +112,7 @@ describe('exportGame (wechat)', () => {it('assembles a MiniGame matching the initWeChatRuntime contract', async () => {const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -197,6 +198,7 @@ describe('exportGame (wechat)', () => {writeFileSync(path.join(wxDir, 'physics.wasm'), 'wasmbytes');const outWx = path.join(root, 'dist-wechat-wxgame');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -238,6 +240,7 @@ describe('exportGame (wechat)', () => {it("judges against the project's own ceiling when it declares one", async () => {const outWx = path.join(root, 'dist-wechat-budget');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -273,6 +276,7 @@ describe('exportGame (wechat)', () => {const outWx = path.join(root, 'dist-wechat-module');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -306,6 +310,7 @@ describe('exportGame (wechat)', () => {it('carries the same hot-update delivery the web road does into the boot call', async () => {const outWx = path.join(root, 'dist-wechat-hotupdate');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -329,6 +334,7 @@ describe('exportGame (wechat)', () => {const cfg = async (debugChannel?: { url: string }) => {const out = path.join(root, debugChannel ? 'dist-wechat-dbg' : 'dist-wechat-nodbg');const res = await exportGame({+ minifyScripts: false,root, entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES, scriptsEntry: 'src/main.ts',sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wxwasm'), outDir: out,@@ -352,6 +358,7 @@ describe('exportGame (wechat)', () => {const outWx = path.join(root, 'dist-wechat-module-webonly');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -372,6 +379,7 @@ describe('exportGame (wechat)', () => {it('fails fast when the -t wechat engine runtime is missing', async () => {const outMissing = path.join(root, 'dist-wechat-missing');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -409,6 +417,7 @@ describe('exportGame (wechat)', () => {const outSpine = path.join(root, 'dist-wechat-spine');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes-spine/spine.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -435,6 +444,7 @@ describe('exportGame (wechat)', () => {it('a needed spine module missing from the runtime dir fails the export', async () => {const outBroken = path.join(root, 'dist-wechat-spine-missing');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes-spine/spine.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -468,6 +478,7 @@ describe('exportGame (wechat)', () => {const outKtx = path.join(root, 'dist-wechat-ktx2');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes-ktx2/ktx2.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -496,6 +507,7 @@ describe('exportGame (wechat)', () => {it('a .ktx2 texture without a wechat basis build fails the export', async () => {const outNoBasis = path.join(root, 'dist-wechat-ktx2-missing');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes-ktx2/ktx2.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -521,6 +533,7 @@ describe('exportGame (wechat)', () => {writeFileSync(path.join(outStale, 'wasm', 'basis.js'), 'var s = globalThis.document?.currentScript?.src;');writeFileSync(path.join(outStale, 'wasm', 'basis.wasm'), 'stalebytes');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -539,6 +552,7 @@ describe('exportGame (wechat)', () => {it('content-addressed export carries the logical path as the asset address', async () => {const outCa = path.join(root, 'dist-wechat-ca');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -583,6 +597,7 @@ describe('exportGame (wechat)', () => {const outMulti = path.join(root, 'dist-wechat-multi');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes-multi/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -620,6 +635,7 @@ describe('exportGame (wechat)', () => {it('compresses the engine binary to .wasm.br, and tells the loader THAT name', async () => {const o = path.join(root, 'dist-wx-br');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -656,6 +672,7 @@ describe('exportGame (wechat)', () => {const wxDir = path.join(root, '_wxwasm-spine');const o = path.join(root, 'dist-wx-br-side');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes-spine/spine.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -686,6 +703,7 @@ describe('exportGame (wechat)', () => {it('leaves the binary alone when the project did not ask', async () => {const o = path.join(root, 'dist-wx-nobr');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -713,6 +731,7 @@ describe('exportGame (wechat)', () => {}const o = path.join(root, 'dist-wx-glx');const exportWith = (wasmDir: string) => exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -750,6 +769,7 @@ describe('exportGame (wechat)', () => {const shipped = async (name: string): Promise<string> => {const o = path.join(root, name);const res = await exportGame({+ minifyScripts: false,root, entryScene: 'scenes/main.esscene', hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,scriptsEntry: 'src/main.ts', sdkDistDir: path.join(root, '_sdk'), wasmDir: base, outDir: o,platform: 'wechat', miniGameAppid: 'wxTEST0123456789',@@ -783,6 +803,7 @@ describe('exportGame (wechat)', () => {it('moves the engine binary into a 分包 the entry loads before booting', async () => {const o = path.join(root, 'dist-wx-subpkg');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -847,6 +868,7 @@ describe('exportGame (wechat)', () => {it('leaves the engine in the main package when the project did not ask', async () => {const o = path.join(root, 'dist-wx-nosubpkg');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -869,6 +891,7 @@ describe('exportGame (wechat)', () => {it('stages nothing the packer would refuse to upload', async () => {const o = path.join(root, 'dist-wx-suffixes');const res = await exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -941,6 +964,7 @@ describe('exportGame (wechat) — open data context', () => {}const exportIt = (root: string, out: string) => exportGame({+ minifyScripts: false,root,entryScene: 'scenes/main.esscene',hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,@@ -1045,6 +1069,7 @@ describe('two assets, one staged file', () => {const outDir = path.join(dir, 'dist-wechat');const res = await exportGame({+ minifyScripts: false,root: dir, entryScene: 'scenes/main.esscene', hostsDir: 'unused-for-wechat', packagesDir: OFFICIAL_PACKAGES,sdkDistDir: path.join(dir, '_sdk'), wasmDir: path.join(dir, '_wxwasm'),outDir, platform: 'wechat', contentAddressed: true,diff --git a/sdk/tests/physics3d-ecs.test.ts b/sdk/tests/physics3d-ecs.test.tsindex 7f256ed40..33b097afe 100644--- a/sdk/tests/physics3d-ecs.test.ts+++ b/sdk/tests/physics3d-ecs.test.ts@@ -201,7 +201,7 @@ describe('the 3D world and the ECS', () => {stepPhysics3D(app,module,bodies,DEFAULT_PHYSICS3D_CONFIG);stepPhysics3D(app,module,bodies,DEFAULT_PHYSICS3D_CONFIG);expect(called('setTransform')).toHaveLength(0);- const transform=world.get(e,Transform) as TransformData;transform.worldPosition.x=250;+ world.update(e,Transform,(t:TransformData)=>{t.worldPosition.x=250;});stepPhysics3D(app,module,bodies,DEFAULT_PHYSICS3D_CONFIG);expect(called('setTransform')[0].args.slice(1,4)).toEqual([2.5,0,0]);stepPhysics3D(app,module,bodies,DEFAULT_PHYSICS3D_CONFIG);diff --git a/tools/check-corpus-authoring.mjs b/tools/check-corpus-authoring.mjsindex 0a2e76137..238571dfe 100644--- a/tools/check-corpus-authoring.mjs+++ b/tools/check-corpus-authoring.mjs@@ -132,6 +132,9 @@ const DISPOSITION = {SpringBone: ['owed', 'no example carries a rigged character with hair or a tail yet; the first one imported with its chains goes into one'],ContentRect: ['owed', 'the Cocos importer writes it on every node it converts, and no example is an imported Cocos scene yet; the first one that is carries it'],RectAnchors: ['owed', 'the Cocos importer writes it for a Widget; it arrives in the corpus with the first imported Cocos scene'],+ NodeVisibility: ['owed', 'the glTF importer writes it for KHR_node_visibility; it arrives in the corpus with the first imported model that hides a node'],+ ParticleModelUnits: ['owed', 'the glTF importer writes it for an emitter authored in model units; it arrives with the first imported scene that carries particles'],+ CompoundCollider3D: ['owed', 'the glTF importer writes it for OMI physics shapes; it arrives with the first imported model that carries colliders'],GroupOpacity: ['owed', 'the Cocos importer writes it for a UIOpacity; it arrives in the corpus with the first imported Cocos scene'],SpringBoneCollider: ['owed', 'no example has a spring-bone chain to keep out of anything; it arrives with the first SpringBone'],FirstPersonController: ['owed', 'no example has a player who walks in the first person yet; the first-person template, when there is one, authors it'],diff --git a/tools/check-gizmo-coverage.mjs b/tools/check-gizmo-coverage.mjsindex c706bdd9e..f51c65a4f 100644--- a/tools/check-gizmo-coverage.mjs+++ b/tools/check-gizmo-coverage.mjs@@ -187,6 +187,10 @@ const DISPOSITION = {'ParticleEmitter.startSizeMax': ['renders', 'the particles drawn at it are the picture'],'ParticleEmitter.endSizeMin': ['renders', 'the particles drawn at it are the picture'],'ParticleEmitter.endSizeMax': ['renders', 'the particles drawn at it are the picture'],+ 'ParticleModelUnits.startSizeMin': ['renders', 'scaled into the emitter, whose particles drawn at it are the picture'],+ 'ParticleModelUnits.startSizeMax': ['renders', 'scaled into the emitter, whose particles drawn at it are the picture'],+ 'ParticleModelUnits.endSizeMin': ['renders', 'scaled into the emitter, whose particles drawn at it are the picture'],+ 'ParticleModelUnits.endSizeMax': ['renders', 'scaled into the emitter, whose particles drawn at it are the picture'],'ParticleEmitter.trailWidth': ['renders', 'the ribbon drawn at it is the outline'],// A world length with no region of its own: it bounds or feeds something else,