Skip to content

[break] feat(terrain): add default layer creation and paint falloff - #940

Merged
star-e merged 2 commits into
cocos:mainfrom
doommm:codex/terrain-editor
Sep 11, 2026
Merged

[break] feat(terrain): add default layer creation and paint falloff#940
star-e merged 2 commits into
cocos:mainfrom
doommm:codex/terrain-editor

Conversation

@doommm

@doommm doommm commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and fixes to the camera and terrain editing systems, focusing on type safety, extensibility, and better state management for paint brushes and layers. The changes include new and refined TypeScript interfaces, improved runtime type safety, and enhanced API flexibility for terrain and camera services.

Camera Service Improvements:

  • Added a getCamera() method to the ICameraService interface and its implementation, allowing safe access to the editor camera instance. The camera reference is now optional, and all usages are updated accordingly. [1] [2] [3] [4] [5] [6]
  • Updated test snapshots to reflect the new camera import and interface changes. [1] [2]

Terrain Paint Brush and Session State:

  • Introduced ITerrainPaintBrushState and ITerrainPaintBrushPatch to explicitly support a falloff property for paint brushes, improving type safety and clarity. All relevant state and session patch interfaces are updated to use these types. [1] [2] [3] [4] [5]
  • Updated terrain gizmo logic to properly handle and retain paint brush falloff values, ensuring consistent UI and editing behavior. [1] [2] [3] [4]

Terrain Layer and Service API:

  • The addLayer method in ITerrainService now accepts an optional layer argument, defaulting to built-in values when omitted, enhancing API flexibility. [1] [2]
  • Added TerrainLayerError and error code types to standardize error reporting for layer authoring failures.

Runtime and Type Safety Enhancements:

  • Declared runtime fields on the engine's Terrain component for editor integration, improving type safety and maintainability. [1] [2]

Miscellaneous Fixes and Refactoring:

  • Improved type annotations and argument handling in terrain layer and brush-related methods for better safety and code clarity. [1] [2]

File Formatting

  • reformat some files in terrain module

These changes collectively enhance the robustness, maintainability, and usability of the camera and terrain editing subsystems.

- addLayer with no layer argument falls back to a CLI-owned built-in
  Texture2D and material defaults, throwing TerrainLayerError when
  the internal asset is unavailable
- persist Paint circle-brush falloff (clamped 0..1) across image-brush
  selection via getTerrainPaintBrushState
- type the terrain gizmo: drop `as any` casts, add Camera.getCamera,
  Terrain manager/isTerrainChange module augmentation, blockCount tuple
@doommm doommm changed the title feat(terrain): add default layer creation and paint falloff [break] feat(terrain): add default layer creation and paint falloff Sep 10, 2026
@doommm
doommm requested a review from stanleyljl September 11, 2026 03:21
@star-e
star-e merged commit 0423628 into cocos:main Sep 11, 2026
8 checks passed
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.

3 participants