Skip to content

[break] feat: Port terrain editor from cocos-creator with authoring API and fixes - #900

Open
doommm wants to merge 9 commits into
cocos:mainfrom
doommm:codex/terrain-editor
Open

[break] feat: Port terrain editor from cocos-creator with authoring API and fixes#900
doommm wants to merge 9 commits into
cocos:mainfrom
doommm:codex/terrain-editor

Conversation

@doommm

@doommm doommm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This pull request adds comprehensive support for the Terrain asset type in the asset handling and service layers, and improves type safety for asset handler types throughout the codebase. It also ensures binary content is properly handled when creating assets, and includes additional tests to verify these behaviors.

Terrain asset support:

  • Added a full set of ITerrain* interfaces and types (such as ITerrainService, ITerrainBlockData, TerrainReadResult, etc.) to the type declarations, enabling proper typing and API support for terrain editing and management features. ([[1]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dR6915-R7029), [[2]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dR7423-R7427))
  • Registered a new Terrain service in the IServiceManager interface, and imported the Terrain type for use in service APIs. ([[1]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dR5419), [[2]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dR6878))

Asset handler type safety improvements:

  • Changed ASSET_HANDLER_TYPES to a readonly tuple type and updated its usage in all type declarations to improve literal type inference and ensure all asset handler types (including "terrain" and "database") are correctly represented. ([[1]](https://github.com/cocos/cocos-cli/pull/900/files#diff-ee2f852140e8d3b6b50539ee6123466853fcbd1bf577400dc451100cf7660621L61-R61), [[2]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL63-R63), [[3]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL1061-R1063), [[4]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL5447-R5455), [[5]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL7749-R7878))
  • Updated AssetHandlerType to be a union of the literal types from ASSET_HANDLER_TYPES and any string, increasing flexibility and future-proofing the type. ([[1]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL91-R93), [[2]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL1152-R1156), [[3]](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dL7791-R7922))

Asset creation and binary content handling:

  • Fixed asset creation logic to avoid serializing Buffer content, preventing corruption of binary assets. ([src/core/assets/manager/asset-handler.tsL428-R429](https://github.com/cocos/cocos-cli/pull/900/files#diff-93b7be637fc879610bb5e2b8d3a728cb3cf80ea82f805463b7baf2647cfade02L428-R429))
  • Added a test to verify that binary content is preserved when creating assets via the filesystem bridge. ([src/core/assets/test/asset-handler-filesystem-bridge.test.tsR127-R136](https://github.com/cocos/cocos-cli/pull/900/files#diff-8200d94463ba684ba5a8c3e14967da7422c2d095ed28dbb8fd9d298a07f48c52R127-R136))

Testing and validation:

  • Added a test to ensure ASSET_HANDLER_TYPES and AssetHandlerType are correctly declared and preserve literal types in the generated .d.ts files. ([packages/cocos-cli-types/__tests__/dts-snapshot.test.tsR41-R60](https://github.com/cocos/cocos-cli/pull/900/files#diff-6f24011f84c590485167b2df90a246ebf6c355eba2fed80973300cfb48613b0cR41-R60))

Minor API improvements:

  • Added a getComponentGizmo method to the IGizmoService interface. ([packages/cocos-cli-types/__tests__/__snapshots__/dts-snapshot.test.ts.snapR6377](https://github.com/cocos/cocos-cli/pull/900/files#diff-a8348e31674835a05155d991b06289ab32594d5ea8f97984df20bd3ddb354d1dR6377))

@doommm
doommm force-pushed the codex/terrain-editor branch from 94349f6 to f7adb93 Compare September 1, 2026 07:23
@doommm
doommm requested a review from stanleyljl September 1, 2026 12:18
stanleyljl and others added 9 commits September 5, 2026 14:20
- Publish explicit Terrain snapshots, session controls, and block reads.\n- Invalidate stale Terrain state across Scene lifecycle changes.
- expose target-safe Manage and layer mutations with atomic Undo
- publish the Terrain authoring API with regression coverage
Keep extension importer names compatible while preserving built-in completions.
- Replace `layers: Array<string | null>` with `ITerrainBlockLayerSlot | null` carrying the layer index and current detail map UUID.
- Change `weight.data` from `number[]` to a defensive `Uint8Array` snapshot of the row-major RGBA8 texels.
- Read block layer detail maps from the live Terrain state via `getCurrentBlockLayerSlots` instead of the stale selection cache.
- Update the DTS snapshot, terrain service comment, and gizmo/service tests for the new binary interface.
@doommm
doommm force-pushed the codex/terrain-editor branch from f7adb93 to 18a6d9a Compare September 5, 2026 07:09
@doommm doommm changed the title WIP: Port terrain editor from cocos-creator with authoring API and fixes Feat: Port terrain editor from cocos-creator with authoring API and fixes Sep 5, 2026
@doommm
doommm marked this pull request as ready for review September 5, 2026 07:38
@doommm doommm changed the title Feat: Port terrain editor from cocos-creator with authoring API and fixes [break] feat: Port terrain editor from cocos-creator with authoring API and fixes Sep 5, 2026
@doommm doommm closed this Sep 5, 2026
@doommm doommm reopened this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants