Skip to content

[Reviewed] [Terrain 3D] Fix grass not placed inside a custom object - #2363

Merged
4ian merged 2 commits into
terrain-updatefrom
claude/upbeat-einstein-hyvhtd
Nov 18, 2026
Merged

4ian merged 2 commits into
terrain-updatefrom
claude/upbeat-einstein-hyvhtd

Conversation

@4ian

@4ian 4ian commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Stacked on #2362 (targets its terrain-update branch).

Layers of custom objects have no Three.js camera, so getThreeCamera() returned null for a terrain object placed inside another custom object. Since the lazy placement of #2362, grass in that case was not placed at all (it used to be placed, without distance fade).

  • Add one getCamera(object) helper, which walks up the custom objects containing the object and returns the camera of the scene layer of the outermost one.
  • Use it at the 5 places reading the camera: terrain levels of detail, terrain cursor raycast, grass, scattered models, scattered models cursor raycast. Terrains and scattered models inside a custom object had the same problem, less visibly (level of detail never updated, far models never hidden).
  • The helper also updates the matrix of the camera before it's read. It is otherwise only updated when the scene is drawn, so on the first frame the grass was placed around the world origin, then around the camera over the next frames within the blades-by-frame budget.
  • gdjs.CustomRuntimeObjectInstanceContainer is added to the allowed gdjs properties of Terrain3D.

Not covered: inside a custom object, grounds are still looked up with positions relative to the container, so grass only follows a terrain that is in the same custom object.

How to use it

No change for users.

Example project

None. Checks done:

  • Mock of the object with Three.js: grass nested in 2 custom objects finds the scene camera and places its chunks around it on the first frame, like grass in the scene. Not verified by rendering in GDevelop with grass inside a custom object.
  • Gameplay tests of the 26 examples of GDevelop-examples using Terrain3D (13 with grass), with GDevelop 5.6.287: 67/67 pass with the extension of this branch applied, as without it. None of them has a terrain object inside a custom object.
  • Rendering screenshots of 3d-island-terrain: they differ from the expected images (6.57% and 9.49% of the pixels, blades at other positions over the same area), because of the per-chunk random numbers of Lazy grass placement to improve performance #2362. They are pixel-identical with and without this fix. The expected images of GDevelop-examples will need an update when the extension is updated there.

AI usage

  • I used an AI to generate some part of the code.

…tom objects

Layers of custom objects have no camera: grass inside a custom object was no longer placed,
and terrains and scattered models were not updated with the distance to the camera.
Also update the matrix of the camera before reading it, so that grass is placed around
the camera on the first frame.
@4ian
4ian requested a review from a team as a code owner November 18, 2026 09:44
@4ian
4ian requested a review from a team as a code owner November 18, 2026 09:56
@4ian
4ian added this pull request to stack #2364 November 18, 2026 10:02
@4ian
4ian merged commit b7cf6a5 into main Nov 18, 2026
5 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.

2 participants