mirror of
https://github.com/galacean/engine.git
synced 2026-06-20 18:16:04 +08:00
Both `Transform._parentChange` and `UITransform._parentChange` relied on internal helpers (`_updateAllWorldFlag` / `_updateWorldFlagWithParentRectChange`) that early-exit when the self-entity already has all target world dirty flags set. Combined with `_parentTransformCache` potentially resolved to `null` during partial clone/instantiate construction, a reparented subtree could keep descendants' `worldMatrix` cached at identity — e.g. a UI layer rendered at (0, 0) instead of inheriting the new parent's world position. Both methods now delegate to new `_propagateReparentDirty(UI)` helpers which unconditionally recurse over the whole subtree, setting `_worldAssociatedChange` flags and `_isParentDirty = true` on every descendant so that subsequent `_getParentTransform()` calls re-resolve the parent chain. UITransform's alignment-driven size/position recompute path is preserved. Observed in Galacean engine 2.0.0-alpha.24 when a prefab was pool-instantiated, its sub-tree world properties were accessed (caching `null` parent), then the prefab was `addChild`-ed under a positioned parent. Added three white-box tests in `tests/src/core/Transform.test.ts` covering (a) reparent after clone + child world access, (b) self-has-all-world-flags-set early-exit case, (c) descendant cached null parent case. RED → GREEN verified.